Commit eb14afd2d09bbdf31af0e80231805b88e6c38181

Authored by Hacene SI HADJ MOHAND
2 parents 6e8d82dc e4eba677

Merge branch 'master' of https://gitlab.irap.omp.eu/CDPP/AMDA_Integration

config/plotConfig.xml deleted
... ... @@ -1,60 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<root>
3   - <default>
4   - <page dimension="ISO A4" orientation="landscape" mode="color" dpi="90">
5   - <font name="sans-serif" size="8" />
6   - <margin x="5" y="5" /> <!-- in mm -->
7   - </page>
8   - <panel resolution="3000" backgroundColor="[255,255,255]"> <!-- charSizeUnits defines space to set all around plot area -->
9   - <title position="top" align="center" />
10   - <timeAxis id="timeAxis" format="dd/mm/yy" reverse="false" color="[0,0,0]" position="bottom" thickness="1">
11   - <legend text="Time, UT" />
12   - </timeAxis>
13   - <epochAxis id="epochAxis" format="dd/mm/yy" reverse="false" color="[0,0,0]" position="bottom" thickness="1">
14   - <legend text="Relative Time" />
15   - </epochAxis>
16   - <colorAxis id="colorAxis" scale="linear" color="[0,0,0]" reverse="false" position="right" />
17   - <xAxis scale="linear" reverse="false" color="[0,0,0]" position="bottom" thickness="1" />
18   - <yAxis scale="linear" reverse="false" color="[0,0,0]" position="left" thickness="1" />
19   - <timePlot xAxis="timeAxis" zAxis="colorAxis">
20   - <line type="line" style="plain" width="1" />
21   - <symbol type="no" size="4" />
22   - </timePlot>
23   - <epochPlot xAxis="epochAxis" zAxis="colorAxis">
24   - <line type="line" style="plain" width="1" />
25   - <symbol type="no" size="4" color="[0,0,255]" />
26   - </epochPlot>
27   - <xyPlot zAxis="colorAxis">
28   - <line type="no" style="plain" width="1" />
29   - <symbol type="dot" size="4" />
30   - <resampling type="auto"/>
31   - <timeTick step="0" number="0" minor="0" color="[0,0,0]">
32   - <font name="sans-serif" size="5" style="upright" weight="medium" />
33   - <firstSymbol type="triangle" size="5" color="[120,0,0]" />
34   - <symbol type="circle" size="5" color="[120,120,0]" />
35   - </timeTick>
36   - </xyPlot>
37   - <instantPlot zAxis="colorAxis">
38   - <line type="no" style="plain" color="[255,0,0]" width="1" />
39   - <symbol type="dot" size="4" color="[0,0,255]" />
40   - </instantPlot>
41   - </panel>
42   - </default>
43   - <colormap path="plplot/">
44   - <grayscale default="0"> <!-- default is map index used for auto line color generation -->
45   - <file index="0">cmap0_black_on_white.pal</file>
46   - <file index="1">cmap1_gray.pal</file>
47   - </grayscale>
48   - <color default="0">
49   - <file index="0">cmap0_default.pal</file>
50   - <file index="1">cmap1_default.pal</file>
51   - <file index="2">cmap0_test.pal</file>
52   - </color>
53   - <coloraxis default="0">
54   - <file index="0">cmap1_default.pal</file>
55   - <file index="1">cmap1_blue_red.pal</file>
56   - <file index="2">cmap1_blue_yellow.pal</file>
57   - <file index="3">cmap1_gray.pal</file>
58   - </coloraxis>
59   - </colormap>
60   -</root>
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... ... @@ -387,7 +387,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
387 387 //Panel background color
388 388 if (($panelData->{'panel-background-color'} != 'none') && ($panelData->{'panel-background-color'} != ''))
389 389 $panelNode->setBackgroundColor($this->hexColor2KernelColor($panelData->{'panel-background-color'}));
390   -
  390 +
391 391 //Panel font
392 392 $this->unmarshallFont($panelData, 'panel-font', $panelNode->getFont());
393 393  
... ... @@ -679,8 +679,15 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
679 679 $drawingEltIndex = 0;
680 680 foreach ($paramsData as $paramData)
681 681 {
  682 + $isTTCat = ($paramData->{'param-type'} == 'ttcat');
  683 +
682 684 //Param
683   - $paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, isset($paramData->{'template_args'}) ? $paramData->{'template_args'} : NULL);
  685 + if (!$isTTCat) {
  686 + $paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, isset($paramData->{'template_args'}) ? $paramData->{'template_args'} : NULL);
  687 + }
  688 + else {
  689 + $paramInfo = $this->paramManager->addTTCatParam($paramData->{'paramid'}, $this->paramsData);
  690 + }
684 691  
685 692 $paramInfo['indexes'] = array();
686 693  
... ... @@ -730,7 +737,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
730 737 case 'ispectro' :
731 738 $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
732 739 $this->unmarshallInstantSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
733   - break;
  740 + break;
  741 + case 'intervals' :
  742 + $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
  743 + $this->unmarshallIntervals($paramData->{'param-drawing-object'}, $paramNode);
  744 + break;
734 745 default :
735 746 throw new Exception('Drawing type not implemented.');
736 747 }
... ... @@ -784,6 +795,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
784 795 {
785 796 $serieNode = $paramNode->addYSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId, $colorSerieId, $paramData->{'param-drawing-object'}->{'serie-value-min'}, $paramData->{'param-drawing-object'}->{'serie-value-max'});
786 797 $serieNode->setId($paramData->{'id'});
  798 + if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
  799 + $serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
787 800 $serieNodes[] = $serieNode;
788 801 }
789 802 foreach ($indexes as $index)
... ... @@ -791,6 +804,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
791 804 $serieNode = $paramNode->addYSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId, $colorSerieId, $paramData->{'param-drawing-object'}->{'serie-value-min'}, $paramData->{'param-drawing-object'}->{'serie-value-max'});
792 805 if (count($indexes) == 1)
793 806 $serieNode->setId($paramData->{'id'});
  807 + if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'}))
  808 + $serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'});
794 809 $serieNodes[] = $serieNode;
795 810 }
796 811 }
... ... @@ -1002,7 +1017,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1002 1017  
1003 1018 protected function unmarshallSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
1004 1019 {
1005   - $spectroNode = $paramNode->addSpectro($paramDrawingData->{'spectro-yaxis'}, count($indexes) > 0 ? $indexes[0] : NULL, $paramDrawingData->{'spectro-value-min'}, $paramDrawingData->{'spectro-value-max'}, isset($paramDrawingData->{'spectro-log0-as-min'}) ? $paramDrawingData->{'spectro-log0-as-min'} : false);
  1020 + $spectroNode = $paramNode->addSpectro($paramDrawingData->{'spectro-yaxis'}, empty($paramDrawingData->{'spectro-resolution'}) ? NULL : $paramDrawingData->{'spectro-resolution'}, count($indexes) > 0 ? $indexes[0] : NULL, $paramDrawingData->{'spectro-value-min'}, $paramDrawingData->{'spectro-value-max'}, isset($paramDrawingData->{'spectro-log0-as-min'}) ? $paramDrawingData->{'spectro-log0-as-min'} : false);
1006 1021 }
1007 1022  
1008 1023 protected function unmarshallInstantSpectro($paramDrawingData, $plotNode, $paramNode, $indexes)
... ... @@ -1018,6 +1033,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1018 1033 foreach ($indexes as $index)
1019 1034 $paramNode->addStatusBar($index);
1020 1035 }
  1036 +
  1037 + protected function unmarshallIntervals($paramDrawingData, $paramNode)
  1038 + {
  1039 + $paramNode->addIntervals();
  1040 + }
1021 1041  
1022 1042 protected function unmarshallTickBar($paramDrawingData, $paramNode, $indexes)
1023 1043 {
... ... @@ -1483,9 +1503,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1483 1503 'success' => true,
1484 1504 'killed' => true);
1485 1505 default :
  1506 + $errorMsg = $data->getErrorMsg();
1486 1507 return array(
1487 1508 'success' => false,
1488   - 'message' => 'Request processing error');
  1509 + 'message' => 'Request processing error'.(!empty($errorMsg) ? "<br>(".$errorMsg.")" : ""));
1489 1510 }
1490 1511 }
1491 1512  
... ...
src/InputOutput/IHMImpl/TimeTables/IHMInputOutputTTClass.php
... ... @@ -23,6 +23,10 @@ class IHMInputOutputTTClass implements InputOutputInterface
23 23 {
24 24 if (isset($this->processDatas))
25 25 unset($this->processDatas);
  26 +
  27 + $sendToSamp = isset($input->sendToSamp) && $input->sendToSamp;
  28 + $compression = !$sendToSamp && ($input->compression !== 'none');
  29 + $format = $sendToSamp ? 'vot' : $input->fileformat;
26 30  
27 31 $final = "";
28 32  
... ... @@ -35,15 +39,17 @@ class IHMInputOutputTTClass implements InputOutputInterface
35 39 {
36 40 //create a list of data to treat
37 41 $processData = new TTRequestDataClass();
38   - if (strpos($tt->id,"sharedtimeTable_") === 0) {
39   - //Shared TimeTable
40   - $result = IHMSharedObjectsClass::getPath("timeTable", $tt->id);
  42 +
  43 + if (strpos($tt->id,"sharedtimeTable_") === 0 || strpos($tt->id,"sharedcatalog_") === 0) {
  44 + //Shared TimeTable /Catalog
  45 + $objectType = strpos($tt->id,"timeTable") != 0 ? "timeTable" : "catalog";
  46 + $result = IHMSharedObjectsClass::getPath($objectType, $tt->id);
41 47 if (!$result['success'])
42   - throw new Exception('Shared TimeTable '.$tt->name.' not found');
  48 + throw new Exception('Shared '.$objectType.' '.$tt->name.' not found');
43 49 $ttName = $result['path'];
44 50 }
45 51 else {
46   - //User TimeTable
  52 + //User TimeTable / Catalog
47 53 $ttName = IHMConfigClass::getUserTTPath().$tt->id.'.xml';
48 54 }
49 55 if (!file_exists($ttName))
... ... @@ -52,7 +58,7 @@ class IHMInputOutputTTClass implements InputOutputInterface
52 58 $processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL);
53 59 $processData->setOutputDir(IHMConfigClass::getDownloadTmpPath());
54 60  
55   - switch ($input->fileformat) {
  61 + switch ($format) {
56 62 case 'vot' :
57 63 $processData->setOutputFileFormat(TTRequestFileFormatEnum::VOTABLE);
58 64 $outputName = $tt->name.'.xml';
... ... @@ -67,6 +73,7 @@ class IHMInputOutputTTClass implements InputOutputInterface
67 73 $final .= " ".$outputName;
68 74 $processData->setType($function);
69 75 $processData->setCmd("ttConversion");
  76 + $processData->setSendToSamp($sendToSamp);
70 77  
71 78 $this->processDatas[] = $processData;
72 79 }
... ... @@ -74,7 +81,7 @@ class IHMInputOutputTTClass implements InputOutputInterface
74 81 $this->postProcessTT = new PostProcessTTClass();
75 82 $this->postProcessTT->setOutputDirAlias($this->processDatas[0]->getOutputDir());
76 83  
77   - if ($input->compression !== 'none') {
  84 + if ($compression) {
78 85 $this->postProcessTT->compression = true;
79 86 $archive = "Timetable_archive_".date('Ymd_Hi');
80 87 switch ($input->compression) {
... ... @@ -125,6 +132,14 @@ class IHMInputOutputTTClass implements InputOutputInterface
125 132  
126 133  
127 134 }
  135 + else if ($data[0]->getSendToSamp()) {
  136 + $donwload = array();
  137 + foreach ($data as $d) {
  138 + $donwload[] = $this->postProcessTT->getOutputDirAlias().$d->getOutputFileName();
  139 + }
  140 + $result = array('success'=>$data[0]->getSuccess(), 'sendToSamp' => TRUE,
  141 + 'download' => $donwload);
  142 + }
128 143 else {
129 144 $result = array('success'=>$data[0]->getSuccess(),
130 145 'download' => $this->postProcessTT->getOutputDirAlias().$data[0]->getOutputFileName());
... ...
src/InputOutput/IHMImpl/Tools/IHMExpressionParserClass.php
... ... @@ -85,6 +85,8 @@ class IHMExpressionParserClass
85 85 "2/abs(1+dst)" => array("expression" => "2/(abs(1+\$dst))", "params" => array(array("paramid" => "dst"))),
86 86 "cross(vect_1,vect_2)" => array("expression" => "(cross(\$vect_1,\$vect_2))", "params" => array(array("paramid" => "vect_1"), array("paramid" => "vect_2"))),
87 87 "cross(cross(vect_1,vect_2),vect_3)" => array("expression" => "(cross((cross(\$vect_1,\$vect_2)),\$vect_3))","params" => array(array("paramid" => "vect_1"), array("paramid" => "vect_2"), array("paramid" => "vect_3"))),
  88 + "c1_hia_pad(0,0)/c1_hia_pad(0,1)" => array ("expression" => "\$c1_hia_pad[0][0]/\$c1_hia_pad[0][1]", "params" => array(array("paramid" => "c1_hia_pad"))),
  89 + "cass_caps_elssec4(indexes[0,10])" => array("expression" => "\$sum_into_table_indexes_cass_caps_elssec4_0_0_10", "params" => array(array("paramid" => "sum_into_table_indexes", "fullparamid" => "sum_into_table_indexes_cass_caps_elssec4_0_0_10", "template_args" => array("paramid"=>"cass_caps_elssec4","relateddim"=>0,"min"=>"0","max"=>"10")))),
88 90 );
89 91  
90 92 //init constants, aliases and functions for test
... ... @@ -143,8 +145,8 @@ class IHMExpressionParserClass
143 145 //echo "Source expression : ".$expression.PHP_EOL;
144 146 //clean expression and replace constants and aliases by associated value
145 147 $this->clean($expression);
146   - $this->replaceConstants($expression);
147   - $this->replaceAliases($expression);
  148 + $this->replaceConstants($expression);
  149 + $this->replaceAliases($expression);
148 150 $this->clean($expression);
149 151  
150 152 //explode expression
... ... @@ -274,13 +276,12 @@ class IHMExpressionParserClass
274 276 $this->aliasesArray = array();
275 277  
276 278 $aliases_ = $dom->getElementsByTagName(self::$aliasNode);
277   - for ($i = 1; $i < $aliases_->length; $i++)
278   - $this->aliasesArray[self::$alias_tag.$aliases_->item($i)->getAttribute(self::$aliasNameAtt)] = $aliases_->item($i)->nodeValue;
  279 + for ($i = 0; $i < $aliases_->length; $i++)
  280 + $this->aliasesArray[self::$aliasTag.$aliases_->item($i)->getAttribute(self::$aliasNameAtt)] = $aliases_->item($i)->getAttribute('xml:id');
279 281 }
280 282  
281 283 //replace
282 284 $expression = strtr($expression, $this->aliasesArray);
283   -
284 285 //be sure that all aliases are replaced
285 286 if ($this->isAliasDetected($expression))
286 287 throw new Exception('Cannot replace some aliases : '.$expression);
... ... @@ -344,11 +345,11 @@ class IHMExpressionParserClass
344 345 }
345 346  
346 347 /*
347   - * @brief detect if the element is "range"
  348 + * @brief detect if the element is "range" or "indexes"
348 349 */
349   - private function isRange($element)
  350 + private function isRangeOrIndexes($element)
350 351 {
351   - return ($element == "range");
  352 + return (($element == "range") || ($element == "indexes"));
352 353 }
353 354  
354 355 /*
... ... @@ -583,7 +584,7 @@ class IHMExpressionParserClass
583 584 !$this->isDecimal($element) &&
584 585 !$this->isOperator($element) &&
585 586 !$this->isFunction($element) &&
586   - !$this->isRange($element) &&
  587 + !$this->isRangeOrIndexes($element) &&
587 588 ($element != ",") && ($element != ";") && ($element != "("));
588 589 }
589 590  
... ... @@ -605,16 +606,20 @@ class IHMExpressionParserClass
605 606 /*
606 607 * @brief detect if the element is a range for a parameter
607 608 */
608   - private function isParameterRange($tree, $i)
  609 + private function isParameterRangeOrIndexes($tree, $i, &$isIndexes)
609 610 {
610 611 $paramId = "";
  612 + $isIndexes = FALSE;
611 613 if ($i <= 0)
612 614 return false;
613 615 if (!$this->isParameter($tree[$i-1]))
614 616 return false;
615   - return (is_array($tree[$i]) &&
  617 + $result = (is_array($tree[$i]) &&
616 618 (count($tree[$i] == 1)) &&
617   - $this->isRange($tree[$i][0]));
  619 + $this->isRangeOrIndexes($tree[$i][0]));
  620 + if ($result)
  621 + $isIndexes = ($tree[$i][0] == "indexes");
  622 + return $result;
618 623 }
619 624  
620 625 /*
... ... @@ -633,23 +638,25 @@ class IHMExpressionParserClass
633 638 */
634 639 private function addParameterComponentInParameterArray($paramId, $component, &$params)
635 640 {
636   - foreach ($params as &$param)
637   - if ($param["id"] == $paramId)
638   - {
639   - array_push($param["indexes"],$component);
640   - return;
  641 + foreach ($params as &$param) {
  642 + if ($param["id"] == $paramId)
  643 + {
  644 + array_push($param["indexes"],$component);
  645 + return;
  646 + }
641 647 }
642 648 }
643 649  
644 650 /*
645 651 * @brief add a parameter range
646 652 */
647   - private function addParameterRangeInParameterArray($paramId, $range, &$params)
  653 + private function addParameterRangeOrIndexesInParameterArray($paramId, $range, $isIndexes, &$params)
648 654 {
649 655 $sum_parameter_id = "";
650 656 if ((count($range) == 2) && (count($range[1]) == 3) && ($this->isInteger($range[1][0])) && ($this->isInteger($range[1][2])) & ($range[1][1] == ",")) {
651   - $sum_parameter_id = "sum_into_table_range_".$paramId."_0_".$range[1][0]."_".$range[1][2];
652   - $params[] = array("id" => "sum_into_table_range",
  657 + $sum_param = $isIndexes ? "sum_into_table_indexes" : "sum_into_table_range";
  658 + $sum_parameter_id = $sum_param."_".$paramId."_0_".$range[1][0]."_".$range[1][2];
  659 + $params[] = array("id" => $sum_param,
653 660 "fullparamid" => $sum_parameter_id,
654 661 "indexes" => array(),
655 662 "calib_infos" => array(),
... ... @@ -683,9 +690,10 @@ class IHMExpressionParserClass
683 690  
684 691 if ($i < count($tree) - 1)
685 692 {
686   - if ($this->isParameterRange($tree,$i+1))
  693 + $isIndexes = FALSE;
  694 + if ($this->isParameterRangeOrIndexes($tree,$i+1,$isIndexes))
687 695 {
688   - $sum_parameter_id = $this->addParameterRangeInParameterArray($param, $tree[$i+1], $params);
  696 + $sum_parameter_id = $this->addParameterRangeOrIndexesInParameterArray($param, $tree[$i+1], $isIndexes, $params);
689 697 $param = $sum_parameter_id;
690 698 ++$i;
691 699 }
... ... @@ -694,8 +702,16 @@ class IHMExpressionParserClass
694 702 $this->addParameterIdInParameterArray($param,$params);
695 703 if ($this->isParameterComponent($tree,$i+1))
696 704 {
697   - $this->addParameterComponentInParameterArray($param, $tree[$i+1][0], $params);
698   - $param .= ("[".$tree[$i+1][0]."]");
  705 + if ((count($tree[$i+1]) == 3) && ($tree[$i+1][1] == ',') && $this->isInteger($tree[$i+1][2])) {
  706 + //2D
  707 + $this->addParameterComponentInParameterArray($param, array($tree[$i+1][0], $tree[$i+1][2]), $params);
  708 + $param .= ("[".$tree[$i+1][0]."][".$tree[$i+1][2]."]");
  709 + }
  710 + else {
  711 + //1D
  712 + $this->addParameterComponentInParameterArray($param, $tree[$i+1][0], $params);
  713 + $param .= ("[".$tree[$i+1][0]."]");
  714 + }
699 715 ++$i;
700 716 }
701 717 }
... ... @@ -835,7 +851,7 @@ class IHMExpressionParserClass
835 851  
836 852 for ($i = 0; $i < count($tree); ++$i)
837 853 {
838   - //echo "=> ".$tree[$i].PHP_EOL;
  854 + #echo "=> ".$tree[$i].PHP_EOL;
839 855 if (is_array($tree[$i]))
840 856 {
841 857 //echo "ARRAY".PHP_EOL;
... ... @@ -879,7 +895,7 @@ class IHMExpressionParserClass
879 895 $founded = false;
880 896 foreach ($params as $param)
881 897 {
882   - //echo "TEST ".$param["id"].PHP_EOL;
  898 + #echo "TEST ".$param["id"].PHP_EOL;
883 899  
884 900 if (array_key_exists("template_args", $param))
885 901 {
... ... @@ -897,8 +913,15 @@ class IHMExpressionParserClass
897 913 foreach ($param["indexes"] as $index)
898 914 {
899 915 $temp = "";
900   - $temp .= ($param["id"]."[".$index."]");
901   - //echo "TEST 2 ".$temp.PHP_EOL;
  916 + if (is_array($index) && (count($index) == 2)) {
  917 + //2D
  918 + $temp .= ($param["id"]."[".$index[0]."][".$index[1]."]");
  919 + }
  920 + else {
  921 + //1D
  922 + $temp .= ($param["id"]."[".$index."]");
  923 + }
  924 + #echo "TEST 2 ".$temp.PHP_EOL;
902 925 if ($temp == $tree[$i])
903 926 {
904 927 $founded = true;
... ... @@ -906,6 +929,7 @@ class IHMExpressionParserClass
906 929 break;
907 930 }
908 931 }
  932 +
909 933 if ($founded)
910 934 break;
911 935 }
... ...
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
... ... @@ -11,6 +11,7 @@ class IHMParamManagerClass
11 11 protected $expressionParser = null;
12 12 protected $templateParamsManager = null;
13 13 protected $paramImpexMgr = null;
  14 + protected $ttCatMgr = null;
14 15  
15 16 /*
16 17 * @brief Constructor
... ... @@ -68,6 +69,79 @@ class IHMParamManagerClass
68 69 }
69 70  
70 71 /*
  72 + * @brief Add a TT or catalog parameter
  73 + */
  74 + public function addTTCatParam($paramId, $paramsData)
  75 + {
  76 + if (!isset($this->ttCatMgr)) {
  77 + $this->ttCatMgr = new IHMTTCatLoaderClass();
  78 + }
  79 + $info = $this->ttCatMgr->getTTCatInfoFromId($paramId);
  80 +
  81 + if (!$info["success"]) {
  82 + throw new Exception($info["message"]);
  83 + }
  84 +
  85 + $status = array();
  86 + $units = "";
  87 + $ytitle = "";
  88 + $flag = "";
  89 +
  90 + if ($info["info"]["isCatalog"]) {
  91 + $parameters = $this->ttCatMgr->getCatalogParameters($paramId);
  92 + if (!$parameters["success"] || empty($parameters["parameters"])) {
  93 + throw new Exception("Error to extract first parameter of ".$paramId);
  94 + }
  95 + //For the moment, use the first parameter
  96 + $parameter = $parameters["parameters"][0];
  97 + $units = $parameter["units"];
  98 + $ytitle = !empty($parameter["name"]) ? $parameter["name"] : $parameter["id"];
  99 + $flag = $parameter["id"];
  100 + $description = $parameter["description"];
  101 + $desc_parts = array();
  102 + foreach (explode("-",$description) as $def) {
  103 + $def = trim($def);
  104 + $p = strpos($def, ":");
  105 + if ($p === FALSE) {
  106 + continue;
  107 + }
  108 + $val = substr($def, 0, $p);
  109 + $val = trim($val);
  110 + $name = substr($def, $p+1);
  111 + $name = trim($name);
  112 + $color = "";
  113 + $p = strpos($name, "[");
  114 + if ($p !== FALSE) {
  115 + $color = substr($name, $p);
  116 + $color = trim($color);
  117 + $name = substr($name, 0, $p);
  118 + $name = trim($name);
  119 + }
  120 + $status[] = array(
  121 + "min" => floatval($val),
  122 + "max" => floatval($val),
  123 + "name" => $name,
  124 + "color" => $color,
  125 + );
  126 + }
  127 + }
  128 + else {
  129 + $status = array(
  130 + array(
  131 + "min" => 1,
  132 + "max" => 1,
  133 + "name" => "Inside",
  134 + "color" => "[255,0,0]",
  135 + )
  136 + );
  137 + $ytitle = $info["info"]["name"];
  138 + }
  139 +
  140 + $paramsData->addTTCatParamToCreate($paramId, $info["info"]["path"], $info["info"]["isShared"], filemtime($info["info"]["path"]), $units, $ytitle, $status, $flag);
  141 + return array("id" => $paramId, "indexes" => array(), "calib_infos" => array());
  142 + }
  143 +
  144 + /*
71 145 * @brief Detect if it's a derived parameter
72 146 */
73 147 private function isDerivedParam($param)
... ... @@ -326,8 +400,10 @@ class IHMParamManagerClass
326 400  
327 401 if (!$res["success"])
328 402 throw new Exception('Error to load uploaded parameter file : '.$res["message"]);
  403 +
  404 + $paramId = $param;
329 405  
330   - $newParamNode = $paramsData->addLocalParamToCreate($res["param"]["id"],
  406 + $newParamNode = $paramsData->addLocalParamToCreate($paramId,
331 407 $res["param"]["info"]["viId"], $res["param"]["info"]["realVar"],
332 408 $res["param"]["info"]["minSampling"], $res["param"]["info"]["maxSampling"],
333 409 $res["param"]["info"]["type"],$res["param"]["info"]["size"],
... ... @@ -439,19 +515,48 @@ class IHMParamManagerClass
439 515 }
440 516 }
441 517  
442   - return array("id" => $res["param"]["id"], "plotType" => $res["param"]["info"]["plotType"]);
  518 + return array("id" => $paramId, "plotType" => $res["param"]["info"]["plotType"]);
443 519 }
444 520  
445 521 public function applyRangesAndIndexes($paramsData, $paramData, $force_total_2d, &$paramInfo) {
446   - $dim1_is_range = (isset($paramData->{'dim1-is-range'}) && $paramData->{'dim1-is-range'});
  522 + $dim1_min = 0;
  523 + $dim1_max = 0;
  524 + $dim2_min = 0;
  525 + $dim2_max = 0;
  526 +
  527 + $dim1_is_range = (isset($paramData->{'dim1-sum-type'}) && ($paramData->{'dim1-sum-type'} > 0));
447 528 $dim1_index = ($dim1_is_range || !isset($paramData->{'dim1-index'}) || ($paramData->{'dim1-index'} == '')) ? '*' : $paramData->{'dim1-index'};
448   - $dim1_min = (!$dim1_is_range || !isset($paramData->{'dim1-min-range'}) || ($paramData->{'dim1-min-range'} == '')) ? 0 : $paramData->{'dim1-min-range'};
449   - $dim1_max = (!$dim1_is_range || !isset($paramData->{'dim1-max-range'}) || ($paramData->{'dim1-max-range'} == '')) ? 0 : $paramData->{'dim1-max-range'};
  529 + if ($dim1_is_range) {
  530 + switch ($paramData->{'dim1-sum-type'}) {
  531 + case 1:
  532 + //Sum between a range of value
  533 + $dim1_min = !empty($paramData->{'dim1-min-value'}) ? $paramData->{'dim1-min-value'} : 0;
  534 + $dim1_max = !empty($paramData->{'dim1-max-value'}) ? $paramData->{'dim1-max-value'} : 0;
  535 + break;
  536 + case 2:
  537 + //Sum between indexes
  538 + $dim1_min = !empty($paramData->{'dim1-min-index'}) ? $paramData->{'dim1-min-index'} : 0;
  539 + $dim1_max = !empty($paramData->{'dim1-max-index'}) ? $paramData->{'dim1-max-index'} : 0;
  540 + break;
  541 + }
  542 + }
450 543  
451   - $dim2_is_range = (isset($paramData->{'dim2-is-range'}) && $paramData->{'dim2-is-range'});
  544 + $dim2_is_range = (isset($paramData->{'dim2-sum-type'}) && ($paramData->{'dim2-sum-type'} > 0));
452 545 $dim2_index = ($dim2_is_range || !isset($paramData->{'dim2-index'}) || ($paramData->{'dim2-index'} == '')) ? '*' : $paramData->{'dim2-index'};
453   - $dim2_min = (!$dim2_is_range || !isset($paramData->{'dim2-min-range'}) || ($paramData->{'dim2-min-range'} == '')) ? 0 : $paramData->{'dim2-min-range'};
454   - $dim2_max = (!$dim2_is_range || !isset($paramData->{'dim2-max-range'}) || ($paramData->{'dim2-max-range'} == '')) ? 0 : $paramData->{'dim2-max-range'};
  546 + if ($dim2_is_range) {
  547 + switch ($paramData->{'dim2-sum-type'}) {
  548 + case 1:
  549 + //Sum between a range of value
  550 + $dim2_min = !empty($paramData->{'dim2-min-value'}) ? $paramData->{'dim2-min-value'} : 0;
  551 + $dim2_max = !empty($paramData->{'dim2-max-value'}) ? $paramData->{'dim2-max-value'} : 0;
  552 + break;
  553 + case 2:
  554 + //Sum between indexes
  555 + $dim2_min = !empty($paramData->{'dim2-min-index'}) ? $paramData->{'dim2-min-index'} : 0;
  556 + $dim2_max = !empty($paramData->{'dim2-max-index'}) ? $paramData->{'dim2-max-index'} : 0;
  557 + break;
  558 + }
  559 + }
455 560  
456 561 switch ($paramData->{'type'}) {
457 562 case 0:
... ... @@ -466,7 +571,10 @@ class IHMParamManagerClass
466 571 'max' => $dim1_max,
467 572 'relateddim' => 0,
468 573 );
469   - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args);
  574 + if ($paramData->{'dim1-sum-type'} == 2)
  575 + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args);
  576 + else
  577 + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args);
470 578 }
471 579 else if ($dim2_is_range) {
472 580 $template_args = array(
... ... @@ -475,7 +583,10 @@ class IHMParamManagerClass
475 583 'max' => $dim2_max,
476 584 'relateddim' => 1,
477 585 );
478   - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args);
  586 + if ($paramData->{'dim2-sum-type'} == 2)
  587 + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args);
  588 + else
  589 + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args);
479 590 }
480 591 else if ($dim1_index != '*') {
481 592 $paramInfo['indexes'][] = $dim1_index;
... ... @@ -487,6 +598,9 @@ class IHMParamManagerClass
487 598 case 2:
488 599 //Tab2D
489 600 if ($dim1_is_range && $dim2_is_range) {
  601 + if ($paramData->{'dim1-sum-type'} != $paramData->{'dim2-sum-type'}) {
  602 + throw new Exception("Not supported - Dimensions ranges for ".$paramInfo['id']." must have the same type for each dimensions");
  603 + }
490 604 $template_args = array(
491 605 'paramid' => $paramInfo['id'],
492 606 'min1' => $dim1_min,
... ... @@ -495,7 +609,10 @@ class IHMParamManagerClass
495 609 'min2' => $dim2_min,
496 610 'max2' => $dim2_max,
497 611 );
498   - $paramInfo = $this->addExistingParam('sum_into_table_range_2d', $paramsData, $template_args);
  612 + if ($paramData->{'dim1-sum-type'} == 2)
  613 + $paramInfo = $this->addExistingParam('sum_into_table_indexes_2d', $paramsData, $template_args);
  614 + else
  615 + $paramInfo = $this->addExistingParam('sum_into_table_range_2d', $paramsData, $template_args);
499 616 }
500 617 else if ($dim1_is_range) {
501 618 $template_args = array(
... ... @@ -508,7 +625,10 @@ class IHMParamManagerClass
508 625 'paramid' => $paramInfo['id'],
509 626 'relateddim' => 1,
510 627 );
511   - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink);
  628 + if ($paramData->{'dim1-sum-type'} == 2)
  629 + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args, $tableLink);
  630 + else
  631 + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink);
512 632 if ($dim2_index != '*') {
513 633 $paramInfo['indexes'][] = $dim2_index;
514 634 }
... ... @@ -524,7 +644,10 @@ class IHMParamManagerClass
524 644 'paramid' => $paramInfo['id'],
525 645 'relateddim' => 0,
526 646 );
527   - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink);
  647 + if ($paramData->{'dim2-sum-type'} == 2)
  648 + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args, $tableLink);
  649 + else
  650 + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink);
528 651 if ($dim1_index != '*') {
529 652 $paramInfo['indexes'][] = $dim1_index;
530 653 }
... ...
src/InputOutput/IHMImpl/Tools/IHMTTCatLoaderClass.php 0 โ†’ 100644
... ... @@ -0,0 +1,235 @@
  1 +<?php
  2 +
  3 +/**
  4 + * @class IHMTTCatLoaderClass
  5 + * @brief Loader for IHM TimeTables and Catalogs properties
  6 + * @details
  7 + */
  8 +class IHMTTCatLoaderClass
  9 +{
  10 + protected $ttCatList = null;
  11 +
  12 + private static $userTTCatFile = 'Tt.xml';
  13 +
  14 + private static $mgrUserTTListNode = 'timetabList';
  15 + private static $mgrUserTTEltNode = 'timetab';
  16 +
  17 + private static $mgrUserCatListNode = 'catalogList';
  18 + private static $mgrUserCatEltNode = 'catalog';
  19 +
  20 + private static $mgrUserTTCatEltIdAtt = 'xml:id';
  21 + private static $mgrUserTTCatEltNameAtt = 'name';
  22 + private static $mgrUserTTCatEltNbIntAtt = 'intervals';
  23 +
  24 + private static $mgrUserTTCatFolderNode = 'folder';
  25 + private static $mgrUserTTCatFolderIdAtt = 'xml:id';
  26 + private static $mgrUserTTCatFolderNameAtt = 'name';
  27 +
  28 + private static $mgrSharedTTListNode = 'timeTableList';
  29 + private static $mgrSharedTTEltNode = 'timeTable';
  30 +
  31 + private static $mgrSharedCatListNode = 'catalogList';
  32 + private static $mgrSharedCatEltNode = 'catalog';
  33 +
  34 + private static $mgrSharedTTCatEltIdAtt = 'xml:id';
  35 + private static $mgrSharedTTCatEltNameAtt = 'name';
  36 + private static $mgrSharedTTCatEltNbIntAtt = 'nbIntervals';
  37 +
  38 + private static $mgrSharedTTCatFolderNode = 'folder';
  39 + private static $mgrSharedTTCatFolderIdAtt = 'xml:id';
  40 + private static $mgrSharedTTCatFolderNameAtt = 'name';
  41 +
  42 + /*
  43 + * @brief Constructor
  44 + */
  45 + function __construct()
  46 + {
  47 + }
  48 +
  49 + /*
  50 + * @brief Get info about a TT or a catalog from id
  51 + */
  52 + public function getTTCatInfoFromId($id)
  53 + {
  54 + if (!isset($this->ttCatList)) {
  55 + $this->ttCatList = $this->loadTTCatManagerFiles();
  56 + }
  57 + if (!array_key_exists($id, $this->ttCatList)) {
  58 + return array("success" => false, "message" => "Cannot retrieve TT or catalog");
  59 + }
  60 + return array("success" => true, "info" => $this->ttCatList[$id]);
  61 + }
  62 +
  63 + /*
  64 + * @brief Get parameters from id (empty for a TT)
  65 + */
  66 + public function getCatalogParameters($id)
  67 + {
  68 + $info = $this->getTTCatInfoFromId($id);
  69 + if (!$info["success"]) {
  70 + return $info;
  71 + }
  72 +
  73 + if (!$info["info"]["isCatalog"]) {
  74 + return array("success" => TRUE, "parameters" => array());
  75 + }
  76 +
  77 + $dom = new DomDocument("1.0");
  78 + if (!$dom->load($info["info"]["path"])) {
  79 + return array("success" => FALSE, "message" => "Cannot open catalog ".$id);
  80 + }
  81 +
  82 + $parametersNodes = $dom->getElementsByTagName("parameters");
  83 + if ($parametersNodes->length == 0) {
  84 + return array("success" => FALSE, "message" => "Cannot retrieve parameters node in catalog ".$id);
  85 + }
  86 +
  87 + $parametersNode = $parametersNodes->item(0);
  88 +
  89 + $parameterNodes = $parametersNode->getElementsByTagName("parameter");
  90 +
  91 + $parameters = array();
  92 + foreach ($parameterNodes as $parameterNode) {
  93 + $parameters[] = array(
  94 + "id" => $parameterNode->getAttribute("id"),
  95 + "name" => $parameterNode->getAttribute("name"),
  96 + "size" => $parameterNode->getAttribute("size"),
  97 + "type" => $parameterNode->getAttribute("type"),
  98 + "unit" => $parameterNode->getAttribute("unit"),
  99 + "description" => $parameterNode->getAttribute("description"),
  100 + "ucd" => $parameterNode->getAttribute("ucd"),
  101 + "utype" => $parameterNode->getAttribute("utype"),
  102 + );
  103 + }
  104 +
  105 + return array("success" => TRUE, "parameters" => $parameters);
  106 + }
  107 +
  108 +
  109 + /*
  110 + * @brief Load all TT and catalogs from manager files
  111 + */
  112 + private function loadTTCatManagerFiles()
  113 + {
  114 + if (isset($this->ttCatList)) {
  115 + return $this->ttCatList;
  116 + }
  117 +
  118 + return $this->loadUserTTCatManagerFile() + $this->loadSharedTTCatManagerFile();
  119 + }
  120 +
  121 + /*
  122 + * @brief Load user TT and cat manager file
  123 + */
  124 + private function loadUserTTCatManagerFile()
  125 + {
  126 + //load xml file
  127 + $dom = new DomDocument("1.0");
  128 + if (!$dom->load(IHMConfigClass::getUserWSPath() . '/' . self::$userTTCatFile))
  129 + return array();
  130 +
  131 + $ttCat = array();
  132 +
  133 + //get TT
  134 + $listNodes = $dom->getElementsByTagName(self::$mgrUserTTListNode);
  135 + if ($listNodes->length > 0) {
  136 + $this->getEltRecursively($listNodes->item(0), FALSE, FALSE, array(), $ttCat);
  137 + }
  138 +
  139 + //get catalogs
  140 + $listNodes = $dom->getElementsByTagName(self::$mgrUserCatListNode);
  141 + if ($listNodes->length > 0) {
  142 + $this->getEltRecursively($listNodes->item(0), FALSE, TRUE, array(), $ttCat);
  143 + }
  144 +
  145 + return $ttCat;
  146 + }
  147 +
  148 + /*
  149 + * @brief Load shared objects manager file
  150 + */
  151 + private function loadSharedTTCatManagerFile()
  152 + {
  153 + //load xml file
  154 + $dom = new DomDocument("1.0");
  155 + if (!$dom->load(IHMConfigClass::getSharedTreeFilePath()))
  156 + return array();
  157 +
  158 + $ttCat = array();
  159 +
  160 + //get TT
  161 + $listNodes = $dom->getElementsByTagName(self::$mgrSharedTTListNode);
  162 + if ($listNodes->length > 0) {
  163 + $this->getEltRecursively($listNodes->item(0), TRUE, FALSE, array(), $ttCat);
  164 + }
  165 +
  166 + //get catalogs
  167 + $listNodes = $dom->getElementsByTagName(self::$mgrSharedCatListNode);
  168 + if ($listNodes->length > 0) {
  169 + $this->getEltRecursively($listNodes->item(0), TRUE, TRUE, array(), $ttCat);
  170 + }
  171 +
  172 + return $ttCat;
  173 + }
  174 +
  175 + private function getEltRecursively($baseNode, $isShared, $isCatalog, $folders, &$elts) {
  176 + if ($isShared) {
  177 + $basePath = IHMConfigClass::getSharedPath();
  178 + if ($isCatalog) {
  179 + $eltNode = self::$mgrSharedCatEltNode;
  180 + $basePath .= "/CAT";
  181 + }
  182 + else {
  183 + $eltNode = self::$mgrSharedTTEltNode;
  184 + $basePath .= "/TT";
  185 + }
  186 + $eltIdAtt = self::$mgrSharedTTCatEltIdAtt;
  187 + $eltNameAtt = self::$mgrSharedTTCatEltNameAtt;
  188 + $eltNbIntAtt = self::$mgrSharedTTCatEltNbIntAtt;
  189 + $folderNode = self::$mgrSharedTTCatFolderNode;
  190 + $folderIdAtt = self::$mgrSharedTTCatFolderIdAtt;
  191 + $folderNameAtt = self::$mgrSharedTTCatFolderNameAtt;
  192 + if (!empty($folders)) {
  193 + $basePath .= "/".$folders[0]["name"]."/data";
  194 + }
  195 + }
  196 + else {
  197 + $basePath = IHMConfigClass::getUserTTPath();
  198 + if ($isCatalog) {
  199 + $eltNode = self::$mgrUserCatEltNode;
  200 + }
  201 + else {
  202 + $eltNode = self::$mgrUserTTEltNode;
  203 + }
  204 + $eltIdAtt = self::$mgrUserTTCatEltIdAtt;
  205 + $eltNameAtt = self::$mgrUserTTCatEltNameAtt;
  206 + $eltNbIntAtt = self::$mgrUserTTCatEltNbIntAtt;
  207 + $folderNode = self::$mgrUserTTCatFolderNode;
  208 + $folderIdAtt = self::$mgrUserTTCatFolderIdAtt;
  209 + $folderNameAtt = self::$mgrUserTTCatFolderNameAtt;
  210 + }
  211 +
  212 + $eltNodes = $baseNode->getElementsByTagName($eltNode);
  213 + foreach ($eltNodes as $node) {
  214 + $elts[$node->getAttribute($eltIdAtt)] = array(
  215 + "id" => $node->getAttribute($eltIdAtt),
  216 + "name" => $node->getAttribute($eltNameAtt),
  217 + "nbIntervals" => $node->getAttribute($eltNbIntAtt),
  218 + "folders" => $folders,
  219 + "path" => $basePath . "/" . $node->getAttribute($eltIdAtt). ".xml",
  220 + "isShared" => $isShared,
  221 + "isCatalog" => $isCatalog,
  222 + );
  223 + }
  224 +
  225 + $folderNodes = $baseNode->getElementsByTagName($folderNode);
  226 + foreach ($folderNodes as $node) {
  227 + $crt_folders = $folders;
  228 + $crt_folders[] = array(
  229 + "id" => $node->getAttribute($folderIdAtt),
  230 + "name" => $node->getAttribute($folderNameAtt),
  231 + );
  232 + $this->getEltRecursively($node, $isShared, $isCatalog, $crt_folders, $elts);
  233 + }
  234 + }
  235 +}
... ...
src/InputOutput/WSImpl/Params/DownloadImpl/WSInputOutputParamsDownloadClass.php
... ... @@ -31,13 +31,13 @@ class WSInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClass
31 31 $outputsNode = $requestNode->getOutputsNode();
32 32 $downloadNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::DOWNLOAD);
33 33  
34   - switch ($input->timeformat)
  34 + switch (strtoupper($input->timeformat))
35 35 {
36 36 case 'ISO08601' :
37 37 $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::ISO);
38 38 break;
39   - case 'unixtime' :
40   - $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::TIMESTAMP);
  39 + case 'UNIXTIME' :
  40 + $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::MS);
41 41 break;
42 42 default :
43 43 $downloadNode->setTimeFormat(RequestOutputDownloadTimeFormatEnum::ISO);
... ...
src/InputOutput/WSImpl/Tools/WSJobsManagerClass.php
... ... @@ -16,7 +16,7 @@ class WSJobsManagerClass extends IHMJobsManagerClass {
16 16 protected $resRootNode = array(WSConfigClass::PLOT => 'resPlotRootNode',
17 17 WSConfigClass::PARAMETER => 'resParamRootNode',
18 18 WSConfigClass::ORBIT => 'resOrbRootNode',
19   - WSConfigClass::DATASET => 'bkgDatasetRootNode');
  19 + WSConfigClass::DATASET => 'resDatasetRootNode');
20 20  
21 21 /*
22 22 * @brief Constructor
... ... @@ -36,15 +36,18 @@ class WSJobsManagerClass extends IHMJobsManagerClass {
36 36 if (!file_exists($this->jobXmlName))
37 37 {
38 38 $res = $this->createJobsFile();
39   - if (!$res['success'])
  39 + if (!$res['success']) {
  40 + error_log("WebServices Error : Cannot create WSjobs.xml", 1, email);
40 41 return $res;
  42 + }
41 43 }
42   -
43 44 $res = $this->jobXml->load($this->jobXmlName);
44   - if (!$res)
  45 + if (!$res) {
  46 + error_log("WebServices Error : Cannot load WSjobs.xml", 1, email);
45 47 return array(
46 48 "success" => false,
47 49 "message" => "Cannot load jobs file");
  50 + }
48 51  
49 52 return array("success" => true);
50 53 }
... ... @@ -265,14 +268,6 @@ class WSJobsManagerClass extends IHMJobsManagerClass {
265 268 }
266 269  
267 270 $this->deleteRequestObjectFile($id);
268   -
269   -// $job->parentNode->removeChild($job);
270   -// $res = $this->jobXml->save($this->jobXmlName);
271   -
272   - if (!$res)
273   - return array(
274   - 'success' => false,
275   - 'message' => "Cannot save jobs file");
276 271  
277 272 return array('success' => true, 'id' => $id);
278 273 }
... ...
src/Request/ParamsRequestImpl/Nodes/Infos/InfoParamNodeClass.php
... ... @@ -16,7 +16,12 @@ define (&quot;INFOPARAM_SICONV&quot;, &quot;si_conversion&quot;);
16 16 define ("INFOPARAM_TABLE", "table");
17 17 define ("INFOPARAM_FILLVAL", "fill_value");
18 18 define ("INFOPARAM_UCD", "ucd");
19   -//define ("INFOPARAM_STATUSDEF", "status_def");
  19 +define ("INFOPARAM_STATUSDEF", "status_def");
  20 +define ("INFOPARAM_STATUS", "status");
  21 +define ("INFOPARAM_STATUS_MINVAL", "minVal");
  22 +define ("INFOPARAM_STATUS_MAXVAL", "maxVal");
  23 +define ("INFOPARAM_STATUS_NAME", "name");
  24 +define ("INFOPARAM_STATUS_COLOR", "color");
20 25 define ("INFOPARAM_DATASETID", "dataset_id");
21 26  
22 27 /**
... ... @@ -51,7 +56,7 @@ class InfoParamNodeClass extends NodeClass
51 56 $this->getChildInstanceByName(INFOPARAM_TABLE,true);
52 57 $this->getChildInstanceByName(INFOPARAM_FILLVAL,true);
53 58 $this->getChildInstanceByName(INFOPARAM_UCD,true);
54   - //$this->getChildInstanceByName(INFOPARAM_STATUSDEF,true);
  59 + $this->getChildInstanceByName(INFOPARAM_STATUSDEF,true);
55 60 $this->getChildInstanceByName(INFOPARAM_DATASETID,true);
56 61 }
57 62  
... ... @@ -148,6 +153,28 @@ class InfoParamNodeClass extends NodeClass
148 153 {
149 154 return $this->getChildInstanceByName(INFOPARAM_TABLE, true);
150 155 }
  156 +
  157 + public function getStatusDef()
  158 + {
  159 + return $this->getChildInstanceByName(INFOPARAM_STATUSDEF, true);
  160 + }
  161 +
  162 + public function addStatus($min, $max, $name, $color = "")
  163 + {
  164 + $node = $this->getStatusDef();
  165 +
  166 + $statusNode = new NodeClass(INFOPARAM_STATUS);
  167 + $statusNode->setAttribute(INFOPARAM_STATUS_MINVAL, $min);
  168 + $statusNode->setAttribute(INFOPARAM_STATUS_MAXVAL, $max);
  169 + $statusNode->setAttribute(INFOPARAM_STATUS_NAME, $name);
  170 + if (!empty($color)) {
  171 + $statusNode->setAttribute(INFOPARAM_STATUS_COLOR, $color);
  172 + }
  173 +
  174 + $node->addChild($statusNode);
  175 +
  176 + return $statusNode;
  177 + }
151 178  
152 179 public function loadFromNode($xmlNode)
153 180 {
... ... @@ -208,6 +235,17 @@ class InfoParamNodeClass extends NodeClass
208 235 $ucdXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_UCD);
209 236 if (isset($ucdXmlNode))
210 237 $this->setUCD($this->getXmlNodeValue($ucdXmlNode));
  238 +
  239 + $statusDefXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_STATUSDEF);
  240 + if (isset($statusDefXmlNode)) {
  241 + foreach ($this->getXmlNodeChildren($statusDefXmlNode) as $statusNode) {
  242 + $minVal = $this->getXmlNodeAttribute($statusNode, INFOPARAM_STATUS_MINVAL);
  243 + $maxVal = $this->getXmlNodeAttribute($statusNode, INFOPARAM_STATUS_MAXVAL);
  244 + $name = $this->getXmlNodeAttribute($statusNode, INFOPARAM_STATUS_NAME);
  245 + $color = $this->getXmlNodeAttribute($statusNode, INFOPARAM_STATUS_COLOR);
  246 + $this->addStatus($minVal, $maxVal, $name, $color);
  247 + }
  248 + }
211 249  
212 250 $datasetidXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_DATASETID);
213 251 if (isset($datasetidXmlNode))
... ...
src/Request/ParamsRequestImpl/Nodes/Params/ParamGetConstantNodeClass.php 0 โ†’ 100644
... ... @@ -0,0 +1,53 @@
  1 +<?php
  2 +
  3 +require_once "ParamGetConstantParamNodeClass.php";
  4 +
  5 +define ("PARAMGETCONSTANT_VI", "constant");
  6 +
  7 +/**
  8 + * @class ParamGetConstantNodeClass
  9 + * @brief Definition of a constant getter for AMDA_Kernel
  10 + * @details
  11 +*/
  12 +class ParamGetConstantNodeClass extends NodeClass
  13 +{
  14 + public function __construct()
  15 + {
  16 + parent::__construct(PARAMGETCONSTANT_VI);
  17 + }
  18 +
  19 + public function getConstant($sampling = "60", $type = "int", $dim1 = "1", $dim2 = "1", $value = "1")
  20 + {
  21 + $nodes = $this->getChildrenByName(PARAMGETCONSTANTPARAM_NAME);
  22 +
  23 + foreach ($nodes as $node)
  24 + if (($node->getSampling() == $sampling) && ($node->getType() == $type) && ($node->getConstValue() == $value) &&
  25 + ($node->getDim1() == $dim1) && ($node->getDim2() == $dim2))
  26 + return $node;
  27 + return NULL;
  28 + }
  29 +
  30 + public function addConstant($sampling = "60", $type = "int", $dim1 = "1", $dim2 = "1", $value = "1")
  31 + {
  32 + $constantNode = new ParamGetConstantParamNodeClass();
  33 +
  34 + $constantNode->setSampling($sampling);
  35 + $constantNode->setType($type);
  36 + $constantNode->setDim1($dim1);
  37 + $constantNode->setDim2($dim2);
  38 + $constantNode->setConstValue($value);
  39 +
  40 + $this->addChild($constantNode);
  41 +
  42 + return $constantNode;
  43 + }
  44 +
  45 + public function loadFromNode($xmlNode)
  46 + {
  47 + foreach ($this->getXmlNodeChildrenByTagName($xmlNode, PARAMGETCONSTANTPARAM_NAME) as $constantXmlNode) {
  48 + $this->addConstant()->loadFromNode($constantXmlNode);
  49 + }
  50 + }
  51 +}
  52 +
  53 +?>
... ...
src/Request/ParamsRequestImpl/Nodes/Params/ParamGetConstantParamNodeClass.php 0 โ†’ 100644
... ... @@ -0,0 +1,86 @@
  1 +<?php
  2 +
  3 +define ("PARAMGETCONSTANTPARAM_NAME", "param");
  4 +define ("PARAMGETCONSTANTPARAM_SAMPLING", "sampling");
  5 +define ("PARAMGETCONSTANTPARAM_TYPE", "type");
  6 +define ("PARAMGETCONSTANTPARAM_VALUE", "value");
  7 +define ("PARAMGETCONSTANTPARAM_DIM1", "dim1");
  8 +define ("PARAMGETCONSTANTPARAM_DIM2", "dim2");
  9 +
  10 +/**
  11 + * @class ParamGetConstantParamNodeClass
  12 + * @brief Definition of a constant parameter
  13 + * @details
  14 +*/
  15 +class ParamGetConstantParamNodeClass extends NodeClass
  16 +{
  17 + public function __construct()
  18 + {
  19 + parent::__construct(PARAMGETCONSTANTPARAM_NAME);
  20 + }
  21 +
  22 + public function getSampling()
  23 + {
  24 + return $this->getAttribute(PARAMGETCONSTANTPARAM_SAMPLING);
  25 + }
  26 +
  27 + public function setSampling($sampling)
  28 + {
  29 + $this->setAttribute(PARAMGETCONSTANTPARAM_SAMPLING, $sampling);
  30 + }
  31 +
  32 + public function getType()
  33 + {
  34 + return $this->getAttribute(PARAMGETCONSTANTPARAM_TYPE);
  35 + }
  36 +
  37 + public function setType($type)
  38 + {
  39 + $this->setAttribute(PARAMGETCONSTANTPARAM_TYPE, strtolower($type));
  40 + }
  41 +
  42 + public function getConstValue()
  43 + {
  44 + return $this->getAttribute(PARAMGETCONSTANTPARAM_VALUE);
  45 + }
  46 +
  47 + public function setConstValue($value)
  48 + {
  49 + $this->setAttribute(PARAMGETCONSTANTPARAM_VALUE, $value);
  50 + }
  51 +
  52 + public function getDim1()
  53 + {
  54 + return $this->getAttribute(PARAMGETCONSTANTPARAM_DIM1);
  55 + }
  56 +
  57 + public function setDim1($dim1)
  58 + {
  59 + $this->setAttribute(PARAMGETCONSTANTPARAM_DIM1, $dim1);
  60 + }
  61 +
  62 + public function getDim2()
  63 + {
  64 + return $this->getAttribute(PARAMGETCONSTANTPARAM_DIM2);
  65 + }
  66 +
  67 + public function setDim2($dim2)
  68 + {
  69 + $this->setAttribute(PARAMGETCONSTANTPARAM_DIM2, $dim2);
  70 + }
  71 +
  72 + public function loadFromNode($xmlNode)
  73 + {
  74 + $this->setSampling($this->getXmlNodeAttribute($xmlNode, PARAMGETCONSTANTPARAM_SAMPLING));
  75 +
  76 + $this->setType($this->getXmlNodeAttribute($xmlNode, PARAMGETCONSTANTPARAM_TYPE));
  77 +
  78 + $this->setConstValue($this->getXmlNodeAttribute($xmlNode, PARAMGETCONSTANTPARAM_VALUE));
  79 +
  80 + $this->setDim1($this->getXmlNodeAttribute($xmlNode, PARAMGETCONSTANTPARAM_DIM1));
  81 +
  82 + $this->setDim2($this->getXmlNodeAttribute($xmlNode, PARAMGETCONSTANTPARAM_DIM2));
  83 + }
  84 +}
  85 +
  86 +?>
... ...
src/Request/ParamsRequestImpl/Nodes/Params/ParamNodeClass.php
... ... @@ -4,6 +4,7 @@ require_once &quot;ParamClbManualNodeClass.php&quot;;
4 4 require_once "ParamGetAmdaParamNodeClass.php";
5 5 require_once "ParamGetDDBaseNodeClass.php";
6 6 require_once "ParamGetLocalBaseNodeClass.php";
  7 +require_once "ParamGetConstantNodeClass.php";
7 8 require_once dirname(__FILE__)."/../Infos/InfoParamNodeClass.php";
8 9 require_once dirname(__FILE__)."/../Requests/RequestOutputPlotPanelNodeClass.php";
9 10  
... ... @@ -22,6 +23,7 @@ abstract class ParamGetTypeEnum
22 23 const AMDAPARAM = "AmdaParam";
23 24 const DDBASE = "DDBase";
24 25 const LOCALBASE = "LocalBase";
  26 + const CONSTANT = "Constant";
25 27 }
26 28  
27 29 /**
... ... @@ -89,6 +91,9 @@ class ParamNodeClass extends NodeClass
89 91 case ParamGetTypeEnum::LOCALBASE :
90 92 $paramGet = new ParamGetLocalBaseNodeClass();
91 93 break;
  94 + case ParamGetTypeEnum::CONSTANT :
  95 + $paramGet = new ParamGetConstantNodeClass();
  96 + break;
92 97 default :
93 98 throw new Exception('Param get node not implemented');
94 99 }
... ... @@ -164,6 +169,9 @@ class ParamNodeClass extends NodeClass
164 169 case PARAMGETLOCALBASE_VI :
165 170 $this->addParamGet(ParamGetTypeEnum::LOCALBASE)->loadFromNode($paramGetDefXmlNode);
166 171 break;
  172 + case PARAMGETCONSTANT_VI :
  173 + $this->addParamGet(ParamGetTypeEnum::CONSTANT)->loadFromNode($paramGetDefXmlNode);
  174 + break;
167 175 }
168 176 }
169 177 }
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php
... ... @@ -26,6 +26,7 @@ define (&quot;REQUESTOUTPUTPLOTSPECTRO_INDEX&quot;, &quot;index&quot;);
26 26 define ("REQUESTOUTPUTPLOTSPECTRO_MIN", "min");
27 27 define ("REQUESTOUTPUTPLOTSPECTRO_MAX", "max");
28 28 define ("REQUESTOUTPUTPLOTSPECTRO_USELOG0ASMIN", "uselog0asmin");
  29 +define ("REQUESTOUTPUTPLOTSPECTRO_RESOLUTION", "resolution");
29 30  
30 31 define ("REQUESTOUTPUTPLOTINSTANTSPECTRO_NAME", "ispectro");
31 32 define ("REQUESTOUTPUTPLOTINSTANTSPECTRO_XAXIS", "xAxis");
... ... @@ -37,6 +38,8 @@ define (&quot;REQUESTOUTPUTPLOTSTATUSBAR_INDEX&quot;, &quot;index&quot;);
37 38 define ("REQUESTOUTPUTPLOTTICKBAR_NAME", "serie");
38 39 define ("REQUESTOUTPUTPLOTTICKBAR_INDEX", "index");
39 40  
  41 +define ("REQUESTOUTPUTPLOTINTERVALS_NAME", "intervals");
  42 +
40 43 /**
41 44 * @class RequestOutputPlotParamNodeClass
42 45 * @brief Definition of a param for a plot of a plot request
... ... @@ -103,11 +106,13 @@ class RequestOutputPlotParamNodeClass extends NodeClass
103 106 return $iserieNode;
104 107 }
105 108  
106   - public function addSpectro($yAxis = "", $index = NULL, $min = NULL, $max = NULL, $uselog0asmin = FALSE)
  109 + public function addSpectro($yAxis = "", $resolution="", $index = NULL, $min = NULL, $max = NULL, $uselog0asmin = FALSE)
107 110 {
108 111 $spectroNode = new NodeClass(REQUESTOUTPUTPLOTSPECTRO_NAME);
109 112 $spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_YAXIS, $yAxis);
110 113 $spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_USELOG0ASMIN, $uselog0asmin ? "true" : "false");
  114 + if (isset($resolution))
  115 + $spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_RESOLUTION, $resolution);
111 116 if (isset($index))
112 117 $spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_INDEX, $index);
113 118 if (isset($min))
... ... @@ -174,6 +179,13 @@ class RequestOutputPlotParamNodeClass extends NodeClass
174 179 $this->addChild($tickBarNode);
175 180 return $tickBarNode;
176 181 }
  182 +
  183 + public function addIntervals()
  184 + {
  185 + $intervalsNode = new NodeClass(REQUESTOUTPUTPLOTINTERVALS_NAME);
  186 + $this->addChild($intervalsNode);
  187 + return $intervalsNode;
  188 + }
177 189  
178 190 public function loadFromNode($xmlNode)
179 191 {
... ... @@ -199,8 +211,9 @@ class RequestOutputPlotParamNodeClass extends NodeClass
199 211 $index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_INDEX);
200 212 $min = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_MIN);
201 213 $max = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_MAX);
  214 + $resolution = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_RESOLUTION);
202 215 $uselog0asmin = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_USELOG0ASMIN) == "true";
203   - $node = $this->addSpectro($yAxis, $index, $min, $max, $uselog0asmin);
  216 + $node = $this->addSpectro($yAxis, $resolution, $index, $min, $max, $uselog0asmin);
204 217 break;
205 218 case REQUESTOUTPUTPLOTXSERIE_NAME :
206 219 $xAxis = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_XAXIS);
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotYSerieNodeClass.php
... ... @@ -8,6 +8,7 @@ define (&quot;REQUESTOUTPUTPLOTYSERIE_TIMEPLOT_NAME&quot;, &quot;serie&quot;);
8 8  
9 9 define ("REQUESTOUTPUTPLOTYSERIE_XID", "xId");
10 10 define ("REQUESTOUTPUTPLOTYSERIE_INDEX", "index");
  11 +define ("REQUESTOUTPUTPLOTYSERIE_RESOLUTION", "resolution");
11 12 define ("REQUESTOUTPUTPLOTYSERIE_RESAMPLING", "resampling");
12 13 define ("REQUESTOUTPUTPLOTYSERIE_ERRORBAR", "errorBar");
13 14  
... ... @@ -33,6 +34,16 @@ class RequestOutputPlotYSerieNodeClass extends RequestOutputPlotBaseSerieNodeCla
33 34 return $this->getAttribute(REQUESTOUTPUTPLOTYSERIE_INDEX);
34 35 }
35 36  
  37 + public function setResolution($resolution)
  38 + {
  39 + $this->setAttribute(REQUESTOUTPUTPLOTYSERIE_RESOLUTION, $resolution);
  40 + }
  41 +
  42 + public function getResolution()
  43 + {
  44 + return $this->getAttribute(REQUESTOUTPUTPLOTYSERIE_RESOLUTION);
  45 + }
  46 +
36 47 public function setXId($xId)
37 48 {
38 49 $this->setAttribute(REQUESTOUTPUTPLOTYSERIE_XID, $xId);
... ...
src/Request/ParamsRequestImpl/ParamsRequestDataClass.php
... ... @@ -169,6 +169,39 @@ class ParamsRequestDataClass extends ProcessRequestDataClass
169 169  
170 170 $this->processParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif);
171 171 }
  172 +
  173 + public function addTTCatParamToCreate($paramId, $ttCatFilePath, $isShared, $dateModif, $units, $ytitle, $status, $flag = "")
  174 + {
  175 + $newParam = new ParamNodeClass();
  176 + $newParam->setId($paramId);
  177 + if (!empty($units)) {
  178 + $newParam->getInfo()->setUnits($units);
  179 + }
  180 + if (!empty($ytitle)) {
  181 + $newParam->getInfo()->setShortName($ytitle);
  182 + }
  183 + else {
  184 + $newParam->getInfo()->setShortName($paramId);
  185 + }
  186 + if (!empty($status)) {
  187 + foreach ($status as $def) {
  188 + $newParam->getInfo()->addStatus($def["min"], $def["max"], $def["name"], $def["color"]);
  189 + }
  190 + }
  191 + $constantGetNode = $newParam->addParamGet(ParamGetTypeEnum::CONSTANT);
  192 + $constantParamNode = $constantGetNode->addConstant();
  193 + $constantParamNode->setSampling(1);
  194 + $process = "#ttcat_to_param(\$constant_1_".$constantParamNode->getType()."_";
  195 + $process .= $constantParamNode->getConstValue()."_".$constantParamNode->getDim1()."_".$constantParamNode->getDim2().";".$ttCatFilePath;
  196 + if (!empty($flag)) {
  197 + $process .= ";".$flag;
  198 + }
  199 + $process .= ")";
  200 + $newParam->setProcess($process, "Transform Time Table or Catalog to a parameter", !$isShared);
  201 + $newParam->setOutput();
  202 +
  203 + $this->processParamsToCreate[$paramId] = array('param' => $newParam, 'dateModif' => $dateModif);
  204 + }
172 205  
173 206 public function getLocalParamsToCreate()
174 207 {
... ...
src/Request/ProcessRequestImpl/Process/ProcessClass.php
... ... @@ -8,11 +8,13 @@ class ProcessClass
8 8 {
9 9 private $command;
10 10 private $postProcessCmd;
  11 + private $getErrorMsgCmd;
11 12  
12 13 private $outputFile;
13 14 private $exitCodeFile;
14 15 private $processFile;
15 16 private $execTimeFile;
  17 + private $errorMsgFile;
16 18  
17 19 private $pID;
18 20 private $runningPath;
... ... @@ -21,22 +23,24 @@ class ProcessClass
21 23 /*
22 24 * @brief Constructor
23 25 */
24   - function __construct($command, $postProcessCmd = "")
  26 + function __construct($command, $postProcessCmd = "", $getErrorMsgCmd = "")
25 27 {
26 28 $this->command = $command;
27 29 $this->postProcessCmd = $postProcessCmd;
  30 + $this->getErrorMsgCmd = $getErrorMsgCmd;
28 31 $this->pID = 0;
29 32 }
30 33  
31 34 /*
32 35 * @brief Init an existing process
33 36 */
34   - public function init($outputFile, $exitCodeFile, $processFile, $execTimeFile, $pid, $runningPath, $runningStart)
  37 + public function init($outputFile, $exitCodeFile, $processFile, $execTimeFile, $errorMsgFile, $pid, $runningPath, $runningStart)
35 38 {
36 39 $this->outputFile = $outputFile;
37 40 $this->exitCodeFile = $exitCodeFile;
38 41 $this->processFile = $processFile;
39 42 $this->execTimeFile = $execTimeFile;
  43 + $this->errorMsgFile = $errorMsgFile;
40 44 $this->pID = $pid;
41 45 $this->runningPath = $runningPath;
42 46 $this->runningStart = $runningStart;
... ... @@ -83,6 +87,14 @@ class ProcessClass
83 87 }
84 88  
85 89 /*
  90 + * @brief Get the error msg file
  91 + */
  92 + public function getErrorMsgFile()
  93 + {
  94 + return $this->errorMsgFile;
  95 + }
  96 +
  97 + /*
86 98 * @brief Get the running path of the request
87 99 */
88 100 public function getRunningPath()
... ... @@ -119,6 +131,38 @@ class ProcessClass
119 131 return intval($result);
120 132 }
121 133  
  134 + public function getErrorMsg()
  135 + {
  136 + switch ($this->getExitCode())
  137 + {
  138 + case 0:
  139 + return ""; //No error
  140 + case -1000:
  141 + return "No process Id";
  142 + case -1001:
  143 + return "Request is running.";
  144 + case -1002:
  145 + return "Cannot access to the request directory";
  146 + case -1003:
  147 + return "Cannot retrieve exit code file";
  148 + case -1004:
  149 + return "Cannot read exit code file";
  150 + }
  151 + if (!file_exists($this->errorMsgFile)) {
  152 + return "Cannot retrieve error message file";
  153 + }
  154 + $result = file_get_contents($this->errorMsgFile);
  155 +
  156 + if ($result === false)
  157 + return "Cannot read error message file";
  158 +
  159 + $result = trim($result);
  160 + if (empty($result))
  161 + return "Unknown error";
  162 +
  163 + return $result;
  164 + }
  165 +
122 166 /*
123 167 * @brief Get execution time of the process
124 168 */
... ... @@ -159,6 +203,7 @@ class ProcessClass
159 203 return false;
160 204  
161 205 $cmd = 'nohup ./'.$this->processFile.' > /dev/null 2>&1 & echo $!';
  206 +
162 207 exec($cmd,$op);
163 208 $this->pID = (int)$op[0];
164 209 $this->runningStart = time();
... ... @@ -215,8 +260,8 @@ class ProcessClass
215 260 if (!chdir($this->runningPath))
216 261 return false;
217 262  
218   - //if (!$keep_log && file_exists($this->outputFile))
219   - // unlink($this->outputFile);
  263 + if (!$keep_log && file_exists($this->outputFile))
  264 + unlink($this->outputFile);
220 265  
221 266 if (file_exists($this->exitCodeFile))
222 267 unlink($this->exitCodeFile);
... ... @@ -226,7 +271,10 @@ class ProcessClass
226 271  
227 272 if (file_exists($this->execTimeFile))
228 273 unlink($this->execTimeFile);
229   -
  274 +
  275 + if (file_exists($this->errorMsgFile))
  276 + unlink($this->errorMsgFile);
  277 +
230 278 return true;
231 279 }
232 280  
... ... @@ -245,6 +293,7 @@ class ProcessClass
245 293 $this->exitCodeFile = "cmd_exitcode";
246 294 $this->processFile = "cmd_process";
247 295 $this->execTimeFile = "cmd_exec_time";
  296 + $this->errorMsgFile = "cmd_errormsg";
248 297  
249 298 if (file_exists($this->outputFile))
250 299 unlink($this->outputFile);
... ... @@ -258,12 +307,19 @@ class ProcessClass
258 307 if (file_exists($this->execTimeFile))
259 308 unlink($this->execTimeFile);
260 309  
  310 + if (file_exists($this->errorMsgFile))
  311 + unlink($this->errorMsgFile);
  312 +
261 313 file_put_contents($this->processFile, "#!/bin/bash".PHP_EOL);
262 314 foreach ($envArray as $key => $value)
263 315 file_put_contents($this->processFile,"export ".$key."=".$value.PHP_EOL, FILE_APPEND);
264 316 file_put_contents($this->processFile, "CMD_START=`echo $(($(date +%s%N)/1000000))`".PHP_EOL, FILE_APPEND);
265 317 file_put_contents($this->processFile, $this->command." > ".$this->outputFile." 2>&1".PHP_EOL, FILE_APPEND);
266   - file_put_contents($this->processFile, "echo $? > ".$this->exitCodeFile.PHP_EOL, FILE_APPEND);
  318 + file_put_contents($this->processFile, "ERROR_CODE=$?".PHP_EOL, FILE_APPEND);
  319 + file_put_contents($this->processFile, "echo \$ERROR_CODE > ".$this->exitCodeFile.PHP_EOL, FILE_APPEND);
  320 + file_put_contents($this->processFile, "if [ \$ERROR_CODE -ne 0 ] && [ \"".$this->getErrorMsgCmd."\" != \"\" ]; then".PHP_EOL, FILE_APPEND);
  321 + file_put_contents($this->processFile, " ".$this->getErrorMsgCmd." > ".$this->errorMsgFile.PHP_EOL, FILE_APPEND);
  322 + file_put_contents($this->processFile, "fi;".PHP_EOL, FILE_APPEND);
267 323 file_put_contents($this->processFile, "CMD_STOP=`echo $(($(date +%s%N)/1000000))`".PHP_EOL, FILE_APPEND);
268 324 file_put_contents($this->processFile, "echo $((\$CMD_STOP-\$CMD_START)) > ".$this->execTimeFile.PHP_EOL, FILE_APPEND);
269 325 if ($this->postProcessCmd != "")
... ...
src/Request/ProcessRequestImpl/Process/ProcessManagerClass.php
... ... @@ -19,9 +19,9 @@ class ProcessManagerClass
19 19 /*
20 20 * @brief Run a process
21 21 */
22   - public function runProcess($cmd, $runningPath, $envArray, $postProcessCmd, $batchEnabled)
  22 + public function runProcess($cmd, $runningPath, $envArray, $postProcessCmd, $getErrorMsgCmd, $batchEnabled)
23 23 {
24   - $process = new ProcessClass($cmd, $postProcessCmd);
  24 + $process = new ProcessClass($cmd, $postProcessCmd, $getErrorMsgCmd);
25 25  
26 26 if (!$process->run($runningPath, $envArray))
27 27 return array("success" => false, "message" => "Cannot run the process");
... ... @@ -159,8 +159,10 @@ class ProcessManagerClass
159 159 $this->updateProcessStatusToNode($dom,$processNode,"exitcodefile",$process->getExitCodeFile());
160 160 $this->updateProcessStatusToNode($dom,$processNode,"processfile",$process->getProcessFile());
161 161 $this->updateProcessStatusToNode($dom,$processNode,"exectimefile",$process->getExecTimeFile());
  162 + $this->updateProcessStatusToNode($dom,$processNode,"errormsgfile",$process->getErrorMsgFile());
162 163 $this->updateProcessStatusToNode($dom,$processNode,"exitcode",$process->getExitCode());
163 164 $this->updateProcessStatusToNode($dom,$processNode,"exectime",$process->getExecTime());
  165 + $this->updateProcessStatusToNode($dom,$processNode,"errormsg",$process->getErrorMsg());
164 166 $this->updateProcessStatusToNode($dom,$processNode,"PID",$process->getPID());
165 167 $this->updateProcessStatusToNode($dom,$processNode,"runningpath",$process->getRunningPath());
166 168 $this->updateProcessStatusToNode($dom,$processNode,"runningstart",$process->getRunningStart());
... ... @@ -180,8 +182,10 @@ class ProcessManagerClass
180 182 "exitcodefile" => $this->getNodeValueFromNode($processNode, "exitcodefile"),
181 183 "processfile" => $this->getNodeValueFromNode($processNode, "processfile"),
182 184 "exectimefile" => $this->getNodeValueFromNode($processNode, "exectimefile"),
  185 + "errormsgfile" => $this->getNodeValueFromNode($processNode, "errormsgfile"),
183 186 "exitcode" => $this->getNodeValueFromNode($processNode, "exitcode"),
184 187 "exectime" => $this->getNodeValueFromNode($processNode, "exectime"),
  188 + "errormsg" => $this->getNodeValueFromNode($processNode, "errormsg"),
185 189 "PID" => $this->getNodeValueFromNode($processNode, "PID"),
186 190 "runningpath" => $this->getNodeValueFromNode($processNode, "runningpath"),
187 191 "runningstart" => $this->getNodeValueFromNode($processNode, "runningstart"),
... ... @@ -239,10 +243,11 @@ class ProcessManagerClass
239 243 $processFile = $processInfo["processfile"];
240 244 $exitCodeFile = $processInfo["exitcodefile"];
241 245 $execTimeFile = $processInfo["exectimefile"];
  246 + $errorMsgFile = isset($processInfo["errormsgfile"]) ? $processInfo["errormsgfile"] : "";
242 247 $pid = $processInfo["PID"];
243 248 $runningPath = $processInfo["runningpath"];
244 249 $runningStart = $processInfo["runningstart"];
245   - $process->init($outputFile, $exitCodeFile, $processFile, $execTimeFile, $pid, $runningPath, $runningStart);
  250 + $process->init($outputFile, $exitCodeFile, $processFile, $execTimeFile, $errorMsgFile, $pid, $runningPath, $runningStart);
246 251 return $process;
247 252 }
248 253  
... ...
src/Request/ProcessRequestImpl/ProcessRequestClass.php
... ... @@ -32,6 +32,8 @@ class ProcessRequestClass extends RequestAbstractClass
32 32 }
33 33 }
34 34  
  35 + $this->requestData->setGetErrorMsgCmd(KernelConfigClass::getKernelBinPath()."amdaGetErrorMsg \$ERROR_CODE");
  36 +
35 37 return true;
36 38 }
37 39  
... ... @@ -90,6 +92,9 @@ class ProcessRequestClass extends RequestAbstractClass
90 92 else
91 93 $this->requestData->setStatus(ProcessStatusEnumClass::DONE);
92 94 $this->requestData->setErrorCode($processInfo['exitcode']);
  95 + if (!empty($processInfo['exitcode'])) {
  96 + $this->requestData->setErrorMsg($processInfo['errormsg']);
  97 + }
93 98 $this->requestData->setExecTime($processInfo['exectime']);
94 99 $processMgr->deleteProcess($processInfo['id'], $result['success']);
95 100 }
... ... @@ -121,6 +126,7 @@ class ProcessRequestClass extends RequestAbstractClass
121 126 $this->requestData->getWorkingPath(),
122 127 $this->requestData->getEnvVars(),
123 128 $this->requestData->getPostCmd(),
  129 + $this->requestData->getGetErrorMsgCmd(),
124 130 $this->requestData->getBatchEnable());
125 131 if ($result['success']) {
126 132 $return_code = TRUE;
... ...
src/Request/ProcessRequestImpl/ProcessRequestDataClass.php
... ... @@ -40,11 +40,13 @@ class ProcessRequestDataClass extends RequestDataClass
40 40 private $cmd = "";
41 41 private $envVars = array();
42 42 private $postCmd = "";
  43 + private $getErrorMsgCmd = "";
43 44 private $id = "";
44 45 private $type = ProcessTypeEnumClass::UNKNOWN;
45 46 private $batchEnable = true;
46 47 private $status = ProcessStatusEnumClass::UNKNOWN;
47 48 private $exitCode = 0;
  49 + private $errorMsg = "";
48 50 private $execTime = 0;
49 51 private $start = 0;
50 52 private $runningPath = "";
... ... @@ -99,6 +101,16 @@ class ProcessRequestDataClass extends RequestDataClass
99 101 $this->postCmd = $postCmd;
100 102 }
101 103  
  104 + public function getGetErrorMsgCmd()
  105 + {
  106 + return $this->getErrorMsgCmd;
  107 + }
  108 +
  109 + public function setGetErrorMsgCmd($getErrorMsgCmd)
  110 + {
  111 + $this->getErrorMsgCmd = $getErrorMsgCmd;
  112 + }
  113 +
102 114 public function getId()
103 115 {
104 116 return $this->id;
... ... @@ -169,6 +181,16 @@ class ProcessRequestDataClass extends RequestDataClass
169 181 $this->exitCode = $errorCode;
170 182 }
171 183  
  184 + public function getErrorMsg()
  185 + {
  186 + return $this->errorMsg;
  187 + }
  188 +
  189 + public function setErrorMsg($errorMsg)
  190 + {
  191 + $this->errorMsg = $errorMsg;
  192 + }
  193 +
172 194 public function getExecTime()
173 195 {
174 196 return $this->execTime;
... ...
src/Request/TTRequestImpl/TTRequestDataClass.php
... ... @@ -33,6 +33,7 @@ class TTRequestDataClass extends RequestDataClass
33 33 private $cmd = "";
34 34 private $envVars = array();
35 35 private $exitCode = 0;
  36 + private $sendToSamp = FALSE;
36 37  
37 38 public function getInputFileName()
38 39 {
... ... @@ -83,6 +84,16 @@ class TTRequestDataClass extends RequestDataClass
83 84 {
84 85 $this->outputDir = $outputDir;
85 86 }
  87 +
  88 + public function setSendToSamp($sendToSamp)
  89 + {
  90 + $this->sendToSamp = $sendToSamp;
  91 + }
  92 +
  93 + public function getSendToSamp($sendToSamp)
  94 + {
  95 + return $this->sendToSamp;
  96 + }
86 97  
87 98 public function getCmd()
88 99 {
... ... @@ -126,4 +137,4 @@ class TTRequestDataClass extends RequestDataClass
126 137 }
127 138 }
128 139  
129   -?>
130 140 \ No newline at end of file
  141 +?>
... ...