Commit 363cacdd23affce30a4fe7c43342c68492963b78
1 parent
1ec5d7bd
Exists in
master
and in
111 other branches
use new Kernel for WS getPlot function
Showing
5 changed files
with
174 additions
and
52 deletions
Show diff stats
php/classes/WSClientInterface.php
@@ -121,9 +121,9 @@ Interface WSClientInterface | @@ -121,9 +121,9 @@ Interface WSClientInterface | ||
121 | public function getDataset($startTime, $stopTime, $datasetID, $sampling = 0, $userID = "", $password = "", | 121 | public function getDataset($startTime, $stopTime, $datasetID, $sampling = 0, $userID = "", $password = "", |
122 | $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0); | 122 | $outputFormat = WSOutputFileFormat::NETCDF, $timeFormat = WSOutputTimeFormat::ISO, $gzip = 0); |
123 | 123 | ||
124 | - /*public function getPlot($startTime, $stopTime, $missionID, $userID = "", $password = ""); | 124 | + public function getPlot($startTime, $stopTime, $missionID, $userID = "", $password = ""); |
125 | 125 | ||
126 | - public function getResultPlot($plotDirectoryURL);*/ | 126 | + public function getResultPlot($plotDirectoryURL); |
127 | 127 | ||
128 | public function getOrbites($startTime, $stopTime, $spacecraft, $coordinateSystem, $units = WSOrbitUnit::KM, | 128 | public function getOrbites($startTime, $stopTime, $spacecraft, $coordinateSystem, $units = WSOrbitUnit::KM, |
129 | $sampling = 0, $userID = "", $password = "", $outputFormat = WSOutputFileFormat::NETCDF, | 129 | $sampling = 0, $userID = "", $password = "", $outputFormat = WSOutputFileFormat::NETCDF, |
php/classes/WSClientREST.php
@@ -133,18 +133,47 @@ class WSClientREST implements WSClientInterface | @@ -133,18 +133,47 @@ class WSClientREST implements WSClientInterface | ||
133 | return $this->call(__FUNCTION__, $params); | 133 | return $this->call(__FUNCTION__, $params); |
134 | } | 134 | } |
135 | 135 | ||
136 | + public function getPlot($startTime, $stopTime, $missionID, $userID = "", $password = "") | ||
137 | + { | ||
138 | + $params = array('parameters' => array( | ||
139 | + "startTime" => $startTime, | ||
140 | + "stopTime" => $stopTime, | ||
141 | + "missionID" => $missionID | ||
142 | + )); | ||
143 | + | ||
144 | + if ($userID != "" && $password != "") | ||
145 | + { | ||
146 | + $params["parameters"]["userID"] = $userID; | ||
147 | + $params["parameters"]["password"] = $password; | ||
148 | + } | ||
149 | + | ||
150 | + return $this->call(__FUNCTION__, $params); | ||
151 | + } | ||
152 | + | ||
153 | + public function getResultPlot($plotDirectoryURL) | ||
154 | + { | ||
155 | + $params = array('parameters' => array( | ||
156 | + "plotDirectoryURL" => $plotDirectoryURL | ||
157 | + )); | ||
158 | + | ||
159 | + return $this->call(__FUNCTION__, $params); | ||
160 | + } | ||
161 | + | ||
136 | private function call($function, $params) | 162 | private function call($function, $params) |
137 | { | 163 | { |
138 | $functionURL = $this->baseURL."/".$function.".php"; | 164 | $functionURL = $this->baseURL."/".$function.".php"; |
139 | 165 | ||
140 | - $isFirstParam = true; | ||
141 | - foreach ($params as $paramName => $paramValue) | 166 | + if (isset($params['parameters'])) |
142 | { | 167 | { |
143 | - if ($isFirstParam) | ||
144 | - $functionURL .= "?"; | ||
145 | - else | ||
146 | - $functionURL .= "&"; | ||
147 | - $functionURL .= $paramName."=".$paramValue; | 168 | + $isFirstParam = true; |
169 | + foreach ($params['parameters'] as $paramName => $paramValue) | ||
170 | + { | ||
171 | + if ($isFirstParam) | ||
172 | + $functionURL .= "?"; | ||
173 | + else | ||
174 | + $functionURL .= "&"; | ||
175 | + $functionURL .= $paramName."=".$paramValue; | ||
176 | + } | ||
148 | } | 177 | } |
149 | 178 | ||
150 | return file_get_contents($functionURL); | 179 | return file_get_contents($functionURL); |
php/classes/WSClientSOAP.php
@@ -134,6 +134,32 @@ class WSClientSOAP implements WSClientInterface | @@ -134,6 +134,32 @@ class WSClientSOAP implements WSClientInterface | ||
134 | 134 | ||
135 | return $this->call(__FUNCTION__, $params); | 135 | return $this->call(__FUNCTION__, $params); |
136 | } | 136 | } |
137 | + | ||
138 | + public function getPlot($startTime, $stopTime, $missionID, $userID = "", $password = "") | ||
139 | + { | ||
140 | + $params = array('parameters' => array( | ||
141 | + "startTime" => $startTime, | ||
142 | + "stopTime" => $stopTime, | ||
143 | + "missionID" => $missionID | ||
144 | + )); | ||
145 | + | ||
146 | + if ($userID != "" && $password != "") | ||
147 | + { | ||
148 | + $params["parameters"]["userID"] = $userID; | ||
149 | + $params["parameters"]["password"] = $password; | ||
150 | + } | ||
151 | + | ||
152 | + return $this->call(__FUNCTION__, $params); | ||
153 | + } | ||
154 | + | ||
155 | + public function getResultPlot($plotDirectoryURL) | ||
156 | + { | ||
157 | + $params = array('parameters' => array( | ||
158 | + "plotDirectoryURL" => $plotDirectoryURL | ||
159 | + )); | ||
160 | + | ||
161 | + return $this->call(__FUNCTION__, $params); | ||
162 | + } | ||
137 | 163 | ||
138 | private function call($function, $params) | 164 | private function call($function, $params) |
139 | { | 165 | { |
php/classes/WebServer.php
@@ -366,6 +366,7 @@ class WebServer | @@ -366,6 +366,7 @@ class WebServer | ||
366 | 366 | ||
367 | $res = $this->init($data); | 367 | $res = $this->init($data); |
368 | $resMgr = $this->initUserMgr(); | 368 | $resMgr = $this->initUserMgr(); |
369 | + | ||
369 | $vars = $res['vars']; | 370 | $vars = $res['vars']; |
370 | $mission = $vars["missionID"]; | 371 | $mission = $vars["missionID"]; |
371 | 372 | ||
@@ -380,51 +381,90 @@ class WebServer | @@ -380,51 +381,90 @@ class WebServer | ||
380 | $dom = new DomDocument("1.0"); | 381 | $dom = new DomDocument("1.0"); |
381 | $dom->load(plotsXml); | 382 | $dom->load(plotsXml); |
382 | 383 | ||
383 | - chdir($resDirName); // Down to working directory | ||
384 | - $fileS = fopen("request.list", "w"); | ||
385 | - | ||
386 | $missionTag = $dom->getElementById($mission); | 384 | $missionTag = $dom->getElementById($mission); |
387 | $params = $missionTag->getElementsByTagName('param'); | 385 | $params = $missionTag->getElementsByTagName('param'); |
388 | 386 | ||
389 | - $yStart = 0.1; | ||
390 | - fwrite($fileS,$params->length.PHP_EOL); | ||
391 | - | ||
392 | - foreach ($params as $param) { | ||
393 | - $yStop = $yStart + 0.15; | ||
394 | - fwrite($fileS,$param->getAttribute('name').' 0 '.$yStart.' 0.95 '.$yStop.' 0 0 0 0'.PHP_EOL); | ||
395 | - $yStart += 0.15; | ||
396 | - } | ||
397 | - | ||
398 | - $startTime = strtotime($vars["startTime"]); | ||
399 | - $endTime = strtotime($vars["stopTime"]); | ||
400 | - | ||
401 | - $TIMEINTERVAL = $this->timeInterval2Days($endTime - $startTime); | ||
402 | - $STARTTIME = $this->startTime2Days($startTime); | ||
403 | - fwrite($fileS, $STARTTIME.PHP_EOL.$TIMEINTERVAL.PHP_EOL); | ||
404 | - | ||
405 | - fclose($fileS); | ||
406 | - | ||
407 | - $myParamBuilder = new ParamBuilder(); | ||
408 | - | ||
409 | -// Process Local Params without codes if they exist | ||
410 | - if (file_exists(Param."LocalParamsList.xml")) { | ||
411 | - $localParams = new DomDocument('1.0'); | ||
412 | - $localParams->load(Param."LocalParamsList.xml"); | ||
413 | - $xp = new domxpath($localParams); | ||
414 | - foreach ($params as $param) { | ||
415 | - $var = $param->getAttribute('name'); | ||
416 | - $paramTag = $xp->query('//PARAM[.="'.$var.'"]'); | ||
417 | - if ($paramTag -> length !== 0) { | ||
418 | - $myParamBuilder->paramLocalBuild($var); | ||
419 | - } | ||
420 | - } | ||
421 | - } | ||
422 | - | ||
423 | -// Run command | ||
424 | - $cmd = DDBIN."DD_Plot request.list ".$this->userID." ".$this->IP." ".DDPROJECT." ".DDPROJLIB; | ||
425 | - $reqMgr = new RequestMgr(); | ||
426 | - $pid = $reqMgr->background($cmd); | ||
427 | - | 387 | + $paramsList = array(); |
388 | + foreach ($params as $param) | ||
389 | + $paramsList[] = $param->getAttribute('name'); | ||
390 | + | ||
391 | + $requestObject = (Object) array( | ||
392 | + "nodeType" => "request", | ||
393 | + "file-format" => "PNG", | ||
394 | + "file-output" => "WS", | ||
395 | + "ws-result-file" => $resDirName."/request.list.png", | ||
396 | + "last-plotted-tab" => 1, | ||
397 | + "timesrc" => "Interval", | ||
398 | + "startDate" => $vars["startTime"], | ||
399 | + "stopDate" => $vars["stopTime"], | ||
400 | + "tabs" => array() | ||
401 | + ); | ||
402 | + | ||
403 | + $pageObject = (Object) array( | ||
404 | + "id" => 1, | ||
405 | + "multi-plot-linked" => true, | ||
406 | + "page-margins-activated" => true, | ||
407 | + "page-margin-x" => 5, | ||
408 | + "page-margin-y" => 5, | ||
409 | + "page-orientation" => "portrait", | ||
410 | + "page-dimension" => "ISO A4", | ||
411 | + "page-layout-type" => "vertical", | ||
412 | + "page-layout-object" => (Object) array( | ||
413 | + "layout-panel-height" => 0.25, | ||
414 | + "layout-panel-spacing" => 0, | ||
415 | + "layout-expand" => false | ||
416 | + ), | ||
417 | + "panels" => array() | ||
418 | + ); | ||
419 | + | ||
420 | + foreach ($paramsList as $paramToPlot) | ||
421 | + { | ||
422 | + $panelObject = (Object) array( | ||
423 | + "panel-plot-type" => "timePlot", | ||
424 | + "axes" => array(), | ||
425 | + "params" => array() | ||
426 | + ); | ||
427 | + | ||
428 | + $timeAxisObject = (Object) array( | ||
429 | + "id" => "time", | ||
430 | + "axis-type" => "time", | ||
431 | + "axis-range-extend" => true | ||
432 | + ); | ||
433 | + $panelObject->{"axes"}[] = $timeAxisObject; | ||
434 | + | ||
435 | + $yAxisObject = (Object) array( | ||
436 | + "id" => "y-left", | ||
437 | + "axis-type" => "y-left", | ||
438 | + "axis-range-extend" => true | ||
439 | + ); | ||
440 | + $panelObject->{"axes"}[] = $yAxisObject; | ||
441 | + | ||
442 | + $paramObject = (Object) array( | ||
443 | + "id" => 1, | ||
444 | + "param-id" => $paramToPlot, | ||
445 | + "param-drawing-type" => "serie", | ||
446 | + "param-drawing-object" => (Object) array( | ||
447 | + "serie-yaxis" => "y-left", | ||
448 | + "serie-lines-activated" => true | ||
449 | + ) | ||
450 | + ); | ||
451 | + $panelObject->{"params"}[] = $paramObject; | ||
452 | + | ||
453 | + $pageObject->{"panels"}[] = $panelObject; | ||
454 | + } | ||
455 | + | ||
456 | + $requestObject->{"tabs"}[] = $pageObject; | ||
457 | + | ||
458 | + require_once(INTEGRATION_SRC_DIR."RequestManager.php"); | ||
459 | + if (!isset($this->requestManager)) | ||
460 | + $this->requestManager = new RequestManagerClass(); | ||
461 | + | ||
462 | + try { | ||
463 | + $plotResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PARAMS, $requestObject); | ||
464 | + } catch (Exception $e) { | ||
465 | + if ($this->isSoap) throw new SoapFault("plot01", 'Exception detected : '.$e->getMessage()); | ||
466 | + else return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage()); | ||
467 | + } | ||
428 | 468 | ||
429 | return array('success' => true, 'plotDirectoryURL' => $ID); | 469 | return array('success' => true, 'plotDirectoryURL' => $ID); |
430 | } | 470 | } |
@@ -918,7 +958,7 @@ $vars["sampling"] = strtr($vars["sampling"], array($matches[1] => "")); | @@ -918,7 +958,7 @@ $vars["sampling"] = strtr($vars["sampling"], array($matches[1] => "")); | ||
918 | ); | 958 | ); |
919 | 959 | ||
920 | try { | 960 | try { |
921 | - $downloadResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSDELETE, id); | 961 | + $downloadResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSDELETE, $obj); |
922 | } catch (Exception $e) { | 962 | } catch (Exception $e) { |
923 | //Nothing to do | 963 | //Nothing to do |
924 | } | 964 | } |
php/testWebServer.php
@@ -121,6 +121,33 @@ function runSuiteTests($client) | @@ -121,6 +121,33 @@ function runSuiteTests($client) | ||
121 | echo "[ERROR] - Error during call of getOrbites function".PHP_EOL; | 121 | echo "[ERROR] - Error during call of getOrbites function".PHP_EOL; |
122 | else | 122 | else |
123 | echo "[OK] - getOrbites - ".$res->dataFileURLs.PHP_EOL; | 123 | echo "[OK] - getOrbites - ".$res->dataFileURLs.PHP_EOL; |
124 | + | ||
125 | + //Test getPlot function | ||
126 | + $res = $client->getPlot("2008-01-01T00:00:00", "2009-01-01T00:00:00", "ACE"); | ||
127 | + if (!isset($res) || !$res->success) | ||
128 | + echo "[ERROR] - Error during call of getPlot function".PHP_EOL; | ||
129 | + else | ||
130 | + { | ||
131 | + $plotDirectoryURL = $res->plotDirectoryURL; | ||
132 | + echo "[OK] - getPlot".PHP_EOL; | ||
133 | + while (true) | ||
134 | + { | ||
135 | + echo " -> getResultPlot".PHP_EOL; | ||
136 | + $res = $client->getResultPlot($plotDirectoryURL); | ||
137 | + if (!isset($res)) | ||
138 | + { | ||
139 | + echo "[ERROR] - Error during call of getResultPlot function".PHP_EOL; | ||
140 | + break; | ||
141 | + } | ||
142 | + else if ($res->success) | ||
143 | + { | ||
144 | + echo " -> plotFileURL : ".$res->plotFileURL.PHP_EOL; | ||
145 | + break; | ||
146 | + } | ||
147 | + echo " -> Result not ready => Wait 5s".PHP_EOL; | ||
148 | + sleep(5); | ||
149 | + } | ||
150 | + } | ||
124 | } | 151 | } |
125 | 152 | ||
126 | $clientSOAP = new WSClientSOAP("http://localhost/NEWAMDA-BENJAMIN/public/wsdl/Methods_AMDA.wsdl"); | 153 | $clientSOAP = new WSClientSOAP("http://localhost/NEWAMDA-BENJAMIN/public/wsdl/Methods_AMDA.wsdl"); |