AddLocalVI.php
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* @file AddLocalVI.php
* @version
* @brief DD Server Tools:
* @arg
*/
if (!function_exists('__autoload'))
{
function __autoload($class_name) {
require_once $class_name . '.php';
}
}
$shortopts = "j:";
$longopts = array("json:");
$options = getopt($shortopts, $longopts);
$json_file = "";
if (array_key_exists("json",$options)) {
$json_file = $options["json"];
}
else if (array_key_exists("j",$options)) {
$json_file = $options["j"];
}
if (!empty($json_file)) {
if (!file_exists($json_file)) {
echo "[ERROR] Cannot find json file: ".$json_file.PHP_EOL;
exit(1);
}
$json_string = file_get_contents($json_file);
$json_obj = json_decode($json_string);
if (empty($json_obj)) {
echo "[ERROR] Cannot decode json data from: ".$json_file.PHP_EOL;
exit(1);
}
}
putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH"));
putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin");
set_include_path("./:".getenv("DATAMANAGER").":".getenv("REMOTEDATA").":".getenv("CALLEXT"));
if (!isset($json_obj)) {
/*
* DEFINITIONS TO FILL
*/
$brief = "jedi"; // prefix $argv[1]
$ViId = "juno_jedi_i180"; // $argv[2]
$mission = "JUNO"; // $argv[3]
$instrument= "JEDI"; // $argv[4]
$mission_dir = "JUNO/"; // $argv[5]
$location = "JEDI/I_180"; // $argv[6]
$min_sampling = 2;// $argv[7]
$max_sampling = 3;// $argv[8] // 0 if constant sampling
$no_compression = TRUE; // set to FALSE to compress data file
/*
* DO NOT TOUCH
*/
}
else {
if (!isset($json_obj->brief) || !isset($json_obj->ViId) || !isset($json_obj->mission) || !isset($json_obj->instrument) ||
!isset($json_obj->mission_dir) || !isset($json_obj->location) || !isset($json_obj->min_sampling)) {
echo "[ERROR] Missing some required arguments in json file: ".$json_file.PHP_EOL;
exit(1);
}
$brief = $json_obj->brief;
$ViId = $json_obj->ViId;
$mission = $json_obj->mission;
$instrument = $json_obj->instrument;
$mission_dir = $json_obj->mission_dir;
$location = $json_obj->location;
$min_sampling = $json_obj->min_sampling;
$max_sampling = isset($json_obj->max_sampling) ? $json_obj->max_sampling : 0;
$no_compression = isset($json_obj->no_compression) ? $json_obj->no_compression : false;
}
$base = "LOCAL";
$baseMgr = new DDBaseMgr();
if ($baseMgr->viExists($ViId, $base)) die("$ViId Already Exists!!!".PHP_EOL);
$baseMgr->setViId($ViId);
$baseMgr->setViInfo($brief);
$baseMgr->setViParentsInfo($base, $mission, $instrument);
$baseMgr->setViLocation($mission_dir, $location);
$baseMgr->setViSampling($min_sampling, $max_sampling);
$baseMgr->setViNoCompression($no_compression);
$baseMgr->createVi();
?>