Commit 23b74e4b7098d6165b6e9ff6489adc110e187f73
1 parent
2bf065de
Exists in
master
and in
100 other branches
spectra in remote
Showing
2 changed files
with
102 additions
and
17 deletions
Show diff stats
php/RemoteDataCenter/CDAWEB.php
@@ -45,6 +45,22 @@ class CDAWEB extends RemoteDataCenterClientClass | @@ -45,6 +45,22 @@ class CDAWEB extends RemoteDataCenterClientClass | ||
45 | return $res; | 45 | return $res; |
46 | } | 46 | } |
47 | 47 | ||
48 | + public function checkParamIsReal() | ||
49 | + { | ||
50 | + $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId." 4"; | ||
51 | + $res = shell_exec($cmd); | ||
52 | + | ||
53 | + return $res; | ||
54 | + } | ||
55 | + | ||
56 | + public function checkIsSpectra() | ||
57 | + { | ||
58 | + $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId." 5"; | ||
59 | + $res = shell_exec($cmd); | ||
60 | + | ||
61 | + return $res; | ||
62 | + } | ||
63 | + | ||
48 | public function setInfoFile() | 64 | public function setInfoFile() |
49 | { | 65 | { |
50 | $this->infoFile = strtolower($this->ViId).".nc"; | 66 | $this->infoFile = strtolower($this->ViId).".nc"; |
php/RemoteDataCenter/RemoteParamManager.php
@@ -97,13 +97,13 @@ class RemoteParamManager | @@ -97,13 +97,13 @@ class RemoteParamManager | ||
97 | // <output/> | 97 | // <output/> |
98 | // </param> | 98 | // </param> |
99 | 99 | ||
100 | - public function makeInternalParamXml() | 100 | + public function makeInternalParamXml($isSpectra) |
101 | { | 101 | { |
102 | if (!$this->center->ViId) return false; | 102 | if (!$this->center->ViId) return false; |
103 | if (!$this->center->ParamId) return false; | 103 | if (!$this->center->ParamId) return false; |
104 | 104 | ||
105 | // $this->paramId = strtolower($this->center->baseID."_".$this->center->ViId."_".$this->center->ParamId); | 105 | // $this->paramId = strtolower($this->center->baseID."_".$this->center->ViId."_".$this->center->ParamId); |
106 | - | 106 | + |
107 | $xmlNameRemote = RemoteData."/PARAMS/".$this->paramId.".xml"; | 107 | $xmlNameRemote = RemoteData."/PARAMS/".$this->paramId.".xml"; |
108 | $xmlNameTemp = PARAMS_LOCALDB_DIR."/".$this->paramId.".xml"; | 108 | $xmlNameTemp = PARAMS_LOCALDB_DIR."/".$this->paramId.".xml"; |
109 | 109 | ||
@@ -114,7 +114,9 @@ class RemoteParamManager | @@ -114,7 +114,9 @@ class RemoteParamManager | ||
114 | if (file_exists($xmlNameRemote)) { | 114 | if (file_exists($xmlNameRemote)) { |
115 | return copy($xmlNameRemote, $xmlNameTemp); | 115 | return copy($xmlNameRemote, $xmlNameTemp); |
116 | } | 116 | } |
117 | - | 117 | + if (!$this->center->checkParamIsReal()) |
118 | + return false; | ||
119 | + | ||
118 | $xml = new DomDocument("1.0"); | 120 | $xml = new DomDocument("1.0"); |
119 | $paramNode = $xml->createElement("param"); | 121 | $paramNode = $xml->createElement("param"); |
120 | $xml->appendChild($paramNode); | 122 | $xml->appendChild($paramNode); |
@@ -127,7 +129,8 @@ class RemoteParamManager | @@ -127,7 +129,8 @@ class RemoteParamManager | ||
127 | 129 | ||
128 | $size = $this->center->getParamSize(); | 130 | $size = $this->center->getParamSize(); |
129 | //TODO spectra components | 131 | //TODO spectra components |
130 | - if ($size > 1) | 132 | + |
133 | + if ($size > 1 && !$isSpectra) | ||
131 | { | 134 | { |
132 | $components = strtolower($this->center->getParamComponents()); | 135 | $components = strtolower($this->center->getParamComponents()); |
133 | } | 136 | } |
@@ -140,7 +143,9 @@ class RemoteParamManager | @@ -140,7 +143,9 @@ class RemoteParamManager | ||
140 | if (!$fillValue) | 143 | if (!$fillValue) |
141 | $fillValue = null; | 144 | $fillValue = null; |
142 | 145 | ||
143 | - $infoNode->appendChild($xml->createElement("components",$components)); | 146 | + if ($components) |
147 | + $infoNode->appendChild($xml->createElement("components",$components)); | ||
148 | + | ||
144 | $infoNode->appendChild($xml->createElement("units",$this->center->getParamUnits())); | 149 | $infoNode->appendChild($xml->createElement("units",$this->center->getParamUnits())); |
145 | $infoNode->appendChild($xml->createElement("coordinates_system")); | 150 | $infoNode->appendChild($xml->createElement("coordinates_system")); |
146 | $infoNode->appendChild($xml->createElement("tensor_order")); | 151 | $infoNode->appendChild($xml->createElement("tensor_order")); |
@@ -161,7 +166,13 @@ class RemoteParamManager | @@ -161,7 +166,13 @@ class RemoteParamManager | ||
161 | $paramNode->appendChild($infoNode); | 166 | $paramNode->appendChild($infoNode); |
162 | $paramNode->appendChild($getNode); | 167 | $paramNode->appendChild($getNode); |
163 | $paramNode->appendChild($xml->createElement("process")); | 168 | $paramNode->appendChild($xml->createElement("process")); |
164 | - $paramNode->appendChild($xml->createElement("output")); | 169 | + $output = $xml->createElement("output"); |
170 | + | ||
171 | + if ($isSpectra) { | ||
172 | + $output->appendChild($this->makeSpectraNode($xml)); | ||
173 | + } | ||
174 | + | ||
175 | + $paramNode->appendChild($output); | ||
165 | 176 | ||
166 | $res = $xml->save($xmlNameRemote); | 177 | $res = $xml->save($xmlNameRemote); |
167 | 178 | ||
@@ -171,6 +182,55 @@ class RemoteParamManager | @@ -171,6 +182,55 @@ class RemoteParamManager | ||
171 | return $res; | 182 | return $res; |
172 | } | 183 | } |
173 | 184 | ||
185 | + protected function makeSpectraNode($xml) | ||
186 | + { | ||
187 | + $yAxis = $xml->createElement("yAxis"); | ||
188 | + $digitalAxis = $xml->createElement("digitalAxis"); | ||
189 | + $digitalAxis->setAttribute('id',"y-left"); | ||
190 | +// $digitalAxis->setAttribute('scale',"logarithmic"); | ||
191 | + $yAxis->appendChild($digitalAxis); | ||
192 | + | ||
193 | + $zAxis = $xml->createElement("zAxis"); | ||
194 | + $colorAxis = $xml->createElement("colorAxis"); | ||
195 | + $colorAxis->setAttribute('colorMapIndex',"1"); | ||
196 | + $colorAxis->setAttribute('scale',"logarithmic"); | ||
197 | + $zAxis->appendChild($colorAxis); | ||
198 | + | ||
199 | + $axes = $xml->createElement("axes"); | ||
200 | + $axes->appendChild($yAxis); | ||
201 | + $axes->appendChild($zAxis); | ||
202 | + | ||
203 | + $spectro = $xml->createElement("spectro"); | ||
204 | + $spectro->setAttribute('yAxis',"y-left"); | ||
205 | + $param = $xml->createElement("param"); | ||
206 | + $param->setAttribute('id',$this->paramId); | ||
207 | + $param->appendChild($spectro); | ||
208 | + | ||
209 | + $params = $xml->createElement("params"); | ||
210 | + $params->appendChild($param); | ||
211 | + | ||
212 | + $timePlot = $xml->createElement("timePlot"); | ||
213 | + $timePlot->appendChild($params); | ||
214 | + $timePlot->appendChild($axes); | ||
215 | + | ||
216 | + $plot = $xml->createElement("plot"); | ||
217 | + $plot->appendChild($timePlot); | ||
218 | + | ||
219 | + return $plot; | ||
220 | + } | ||
221 | + | ||
222 | + protected function makeOurComponents($node, $size) | ||
223 | + { | ||
224 | + for ($i = 0; $i < $size; $i++) | ||
225 | + { | ||
226 | + $compNode = $this->xmlDom->createElement("component"); | ||
227 | + $compNode->setAttribute('xml:id',$this->paramId."($i)"); | ||
228 | + $compNode->setAttribute('name',"comp_$i"); // LABEL | ||
229 | + | ||
230 | + $node->appendChild($compNode); | ||
231 | + } | ||
232 | + } | ||
233 | + | ||
174 | protected function makeComponents($node, $size, $components) | 234 | protected function makeComponents($node, $size, $components) |
175 | { | 235 | { |
176 | $compArray = explode(",",$components); | 236 | $compArray = explode(",",$components); |
@@ -195,19 +255,21 @@ class RemoteParamManager | @@ -195,19 +255,21 @@ class RemoteParamManager | ||
195 | // Node to be added | 255 | // Node to be added |
196 | $nodeRemote = $this->center->baseDom->getElementById($id); | 256 | $nodeRemote = $this->center->baseDom->getElementById($id); |
197 | // No such node in base.xml | 257 | // No such node in base.xml |
258 | + | ||
198 | if (!$nodeRemote) return false; | 259 | if (!$nodeRemote) return false; |
199 | 260 | ||
200 | if ($nodeRemote->tagName == 'dataset') | 261 | if ($nodeRemote->tagName == 'dataset') |
201 | { | 262 | { |
263 | + | ||
202 | $this->center->setViId($nodeRemote->getAttribute('name')); | 264 | $this->center->setViId($nodeRemote->getAttribute('name')); |
203 | $status = $this->center->addViToDD(); | 265 | $status = $this->center->addViToDD(); |
204 | - | 266 | + |
205 | if (!$status) return false; | 267 | if (!$status) return false; |
206 | - | ||
207 | - $remoteDatasetInfo = DDSERVICE."/BASE/INFO/bases/".$this->center->baseID."/".$this->center->infoFile; | 268 | + |
269 | + $remoteDatasetInfo = BASE."/INFO/bases/".$this->center->baseID."/".$this->center->infoFile; | ||
208 | $localDatasetInfo = RemoteData.$this->center->baseID."/".$this->center->infoFile; | 270 | $localDatasetInfo = RemoteData.$this->center->baseID."/".$this->center->infoFile; |
209 | 271 | ||
210 | - if (!copy($remoteDatasetInfo,$localDatasetInfo)) return false; | 272 | + if (!copy($remoteDatasetInfo,$localDatasetInfo)) return false; |
211 | } | 273 | } |
212 | 274 | ||
213 | $node = $this->xmlDom->importNode($nodeRemote); | 275 | $node = $this->xmlDom->importNode($nodeRemote); |
@@ -217,18 +279,25 @@ class RemoteParamManager | @@ -217,18 +279,25 @@ class RemoteParamManager | ||
217 | $this->center->setParamId($nodeRemote->getAttribute('name')); | 279 | $this->center->setParamId($nodeRemote->getAttribute('name')); |
218 | $this->center->setViId($nodeRemote->parentNode->getAttribute('name')); | 280 | $this->center->setViId($nodeRemote->parentNode->getAttribute('name')); |
219 | $this->center->setInfoFile(); | 281 | $this->center->setInfoFile(); |
282 | + $isSpectra = $this->center->checkIsSpectra(); | ||
283 | + if (!$this->makeInternalParamXml($isSpectra)) return false; | ||
220 | 284 | ||
221 | - if (!$this->makeInternalParamXml()) return false; | ||
222 | - | ||
223 | - if (($size = $this->center->getParamSize()) > 1) | ||
224 | - { | ||
225 | - // make components and args | ||
226 | - $components = $this->center->getParamComponents(); | ||
227 | - $this->makeComponents($node, $size, $components); // return false; | 285 | + if ( (($size = $this->center->getParamSize()) > 1) && !$isSpectra ) |
286 | + { | ||
287 | + // make components and args | ||
288 | + $components = $this->center->getParamComponents(); | ||
289 | + if ($components == -1) { | ||
290 | + $this->makeOurComponents($node, $size); | ||
291 | + } | ||
292 | + else { | ||
293 | + $this->makeComponents($node, $size, $components); // return false; | ||
294 | + } | ||
228 | } | 295 | } |
229 | 296 | ||
230 | // convert remote paramID into AMDA paramID | 297 | // convert remote paramID into AMDA paramID |
231 | $node->setAttribute("xml:id", strtr(strtolower($node->getAttribute("xml:id")), ":","_")); | 298 | $node->setAttribute("xml:id", strtr(strtolower($node->getAttribute("xml:id")), ":","_")); |
299 | + if ($isSpectra) | ||
300 | + $node->setAttribute("display_type","spectrogram"); | ||
232 | } | 301 | } |
233 | 302 | ||
234 | $parentRemote= $nodeRemote->parentNode; | 303 | $parentRemote= $nodeRemote->parentNode; |