AddLocalVI.php
3.49 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
92
93
94
95
96
97
98
99
100
<?php
/**
* @file AddLocalVI.php
* @version $Id: AddLocalVI.php,v 1.3 2010/10/29 14:03:53 budnik Exp $
* @brief DD Server Tools:
* @arg
*/
function makeInfoXml() {
$xml_dom = new DomDocument("1.0");
$rootElement = $xml_dom -> createElement("VI");
$rootElement -> appendChild($xml_dom -> createElement("Mission",mission));
$rootElement -> appendChild($xml_dom -> createElement("Instrument",instrument));
$rootElement -> appendChild($xml_dom -> createElement("GlobalStart"));
$rootElement -> appendChild($xml_dom -> createElement("GlobalStop"));
$rootElement -> appendChild($xml_dom -> createElement("MinSampling", MinSampling));
if (MaxSampling > MinSampling) $rootElement -> appendChild($xml_dom -> createElement("MaxSampling", MaxSampling));
$rootElement -> appendChild($xml_dom -> createElement("LocalStart"));
$rootElement -> appendChild($xml_dom -> createElement("LocalStop"));
$xml_dom -> appendChild($rootElement);
$xml_dom -> save(brief."_info.xml");
}
require_once 'mgr_ini.php';
define("CURRDIR",dirname(__FILE__));
/*
* DEFINITIONS TO FILL
*/
define("brief", "jedi"); // prefix
define("ViId", "juno_jedi_i180");
define("mission", "JUNO");
define("instrument", "JEDI");
define("MISSION_DIR", DDBASE."JUNO/");
define("location", MISSION_DIR."JEDI/I_180");
define("MinSampling", 2);
define("MaxSampling", 3); // 0 if constant sampling
/*
* DO NOT TOUCH
*/
$times = brief."_times.nc";
$info = brief."_info.nc";
$info_xml = brief."_info.xml";
$cache = brief."_cache.nc";
$DDsysDoc = new DomDocument();
$DDsysDoc->preserveWhiteSpace = false;
$DDsysDoc->formatOutput = true;
$DDsysDoc->load(DDBASE.DDsys);
$dataSet = $DDsysDoc->getElementsByTagName("VI");
/*
* Check if there is already such VI
*/
foreach ($dataSet as $theDataSet)
if (strcmp($theDataSet->getElementsByTagName("NAME")->item(0)->nodeValue, ViId) == 0)
die(ViId." Already Exists!!!\n");
$refNode = $dataSet->item(0);
$newNode = $DDsysDoc->createElement("VI");
$name = $newNode->appendChild($DDsysDoc->createElement("NAME",ViId));
$name->setAttributeNode(new DOMAttr('base', 'LOCAL'));
$name->setAttributeNode(new DOMAttr('mission', mission));
$name->setAttributeNode(new DOMAttr('instrument', instrument));
if (substr(location, -1) !== "/") $newNode->appendChild($DDsysDoc->createElement("LOCATION",location."/"));
else $newNode->appendChild($DDsysDoc->createElement("LOCATION",location));
$newNode->appendChild($DDsysDoc->createElement("TIMES",$times));
$newNode->appendChild($DDsysDoc->createElement("INFO",$info));
$newNode->appendChild($DDsysDoc->createElement("CACHE",$cache));
$newNode = $refNode->parentNode->insertBefore($newNode, $refNode);
$DDsysDoc->save(DDBASE.DDsys);
system(DDBASEBIN."/makeDDsys");
/*
* Create Real Stuff
*
*/
if (!is_dir(MISSION_DIR)) mkdir(MISSION_DIR);
if (!is_dir(location)) mkdir(location, 0775, true);
echo location."\n";
chdir(location);
if (!file_exists($times)) system("TimesUpdate -r ".$times." ".brief."_0*.nc");
if (!file_exists($info_xml)) makeInfoXml();
if (!file_exists($info)) system("infoLocal2nc ".$info_xml." ".$info);
if (!file_exists("clean")) {
copy (DDLIB."/Cash.template", $cache);
$SED = "sed 's/NAME/".brief."/g' ".DDLIB."/Clean.template > clean";
exec($SED);
exec('chmod ugo+x clean');
}
chdir(CURRDIR);
?>