Commit f25e55bad909f7b40122f977008c831caee60af8
1 parent
4b616b6d
Exists in
master
and in
66 other branches
Add sum in table range support
Showing
4 changed files
with
179 additions
and
50 deletions
Show diff stats
src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php
... | ... | @@ -81,19 +81,42 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas |
81 | 81 | break; |
82 | 82 | case 1: |
83 | 83 | //Tab1D |
84 | - if (isset($param->dim1) && ($param->dim1 != '') && ($param->dim1 != '*')) { | |
85 | - $paramInfo['indexes'] = array(); | |
86 | - $paramInfo['indexes'][] = $param->dim1; | |
84 | + if ($param->{'dim1-is-range'}) { | |
85 | + $template_args = array( | |
86 | + 'paramid' => $paramInfo['id'], | |
87 | + 'min' => $param->{'dim1-min-range'}, | |
88 | + 'max' => $param->{'dim1-max-range'}, | |
89 | + 'relateddim' => 0 | |
90 | + ); | |
91 | + $paramInfo = $this->paramManager->addExistingParam('sum_into_table_range', $this->paramsData, $template_args); | |
87 | 92 | } |
88 | - else if (isset($param->dim2) && ($param->dim2 != '') && ($param->dim2 != '*')) { | |
89 | - $paramInfo['indexes'] = array(); | |
90 | - $paramInfo['indexes'][] = $param->dim2; | |
93 | + else { | |
94 | + if (($param->{'dim1-index'} != '*') && ($param->{'dim1-index'} != '')) { | |
95 | + $paramInfo['indexes'] = array(); | |
96 | + $paramInfo['indexes'][] = $param->{'dim1-index'}; | |
97 | + } | |
98 | + } | |
99 | + | |
100 | + if ($param->{'dim2-is-range'}) { | |
101 | + $template_args = array( | |
102 | + 'paramid' => $paramInfo['id'], | |
103 | + 'min' => $param->{'dim2-min-range'}, | |
104 | + 'max' => $param->{'dim2-max-range'}, | |
105 | + 'relateddim' => 1 | |
106 | + ); | |
107 | + $paramInfo = $this->paramManager->addExistingParam('sum_into_table_range', $this->paramsData, $template_args); | |
108 | + } | |
109 | + else { | |
110 | + if (($param->{'dim2-index'} != '*') && ($param->{'dim2-index'} != '')) { | |
111 | + $paramInfo['indexes'] = array(); | |
112 | + $paramInfo['indexes'][] = $param->{'dim2-index'}; | |
113 | + } | |
91 | 114 | } |
92 | 115 | break; |
93 | 116 | case 2: |
94 | - if (($param->dim1 != '*') || ($param->dim2 != '*')) { | |
117 | + if (($param->{'dim1-index'} != '*') || ($param->{'dim2-index'} != '*')) { | |
95 | 118 | $paramInfo['indexes'] = array(); |
96 | - $paramInfo['indexes'][] = "[".$param->dim1.",".$param->dim2."]"; | |
119 | + $paramInfo['indexes'][] = "[".$param->{'dim1-index'}.",".$param->{'dim2-index'}."]"; | |
97 | 120 | } |
98 | 121 | break; |
99 | 122 | } |
... | ... |
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... | ... | @@ -651,28 +651,53 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
651 | 651 | $paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, $paramData->{'template_args'}); |
652 | 652 | |
653 | 653 | $paramInfo['indexes'] = array(); |
654 | - $dim1 = $paramData->{'dim1'}; | |
655 | - if ($dim1 == '') | |
656 | - $dim1 = '*'; | |
657 | - $dim2 = $paramData->{'dim2'}; | |
658 | - if ($dim2 == '') | |
659 | - $dim2 = '*'; | |
654 | + | |
655 | + $dim1_index = '*'; | |
656 | + if (!$paramData->{'dim1-is-range'}) { | |
657 | + if ($paramData->{'dim1-index'} != '') | |
658 | + $dim1_index = $paramData->{'dim1-index'}; | |
659 | + } | |
660 | + | |
661 | + $dim2_index = '*'; | |
662 | + if (!$paramData->{'dim2-is-range'}) { | |
663 | + if ($paramData->{'dim2-index'} != '') | |
664 | + $dim2_index = $paramData->{'dim2-index'}; | |
665 | + } | |
666 | + | |
660 | 667 | switch ($paramData->{'type'}) { |
661 | 668 | case 0: |
662 | 669 | //scalar - nothing to do |
663 | 670 | break; |
664 | 671 | case 1: |
665 | 672 | //Tab1D |
666 | - if (isset($dim1) && ($dim1 != '*')) { | |
667 | - $paramInfo['indexes'][] = $dim1; | |
673 | + if ($paramData->{'dim1-is-range'}) { | |
674 | + $template_args = array( | |
675 | + 'paramid' => $paramInfo['id'], | |
676 | + 'min' => $paramData->{'dim1-min-range'}, | |
677 | + 'max' => $paramData->{'dim1-max-range'}, | |
678 | + 'relateddim' => 0 | |
679 | + ); | |
680 | + $paramInfo = $this->paramManager->addExistingParam('sum_into_table_range', $this->paramsData, $template_args); | |
681 | + } | |
682 | + else if ($paramData->{'dim2-is-range'}) { | |
683 | + $template_args = array( | |
684 | + 'paramid' => $paramInfo['id'], | |
685 | + 'min' => $paramData->{'dim2-min-range'}, | |
686 | + 'max' => $paramData->{'dim2-max-range'}, | |
687 | + 'relateddim' => 1 | |
688 | + ); | |
689 | + $paramInfo = $this->paramManager->addExistingParam('sum_into_table_range', $this->paramsData, $template_args); | |
690 | + } | |
691 | + else if (isset($dim1_index) && ($dim1_index != '*')) { | |
692 | + $paramInfo['indexes'][] = $dim1_index; | |
668 | 693 | } |
669 | - else if (isset($dim2) && ($dim2 != '*')) { | |
670 | - $paramInfo['indexes'][] = $dim2; | |
694 | + else if (isset($dim2_index) && ($dim2_index != '*')) { | |
695 | + $paramInfo['indexes'][] = $dim2_index; | |
671 | 696 | } |
672 | 697 | break; |
673 | 698 | case 2: |
674 | - if (($dim1 != '*') || ($dim2 != '*')) { | |
675 | - $paramInfo['indexes'][] = "[".$dim1.",".$dim2."]"; | |
699 | + if (($dim1_index != '*') || ($dim2_index != '*')) { | |
700 | + $paramInfo['indexes'][] = "[".$dim1_index.",".$dim2_index."]"; | |
676 | 701 | } |
677 | 702 | break; |
678 | 703 | } |
... | ... |
src/InputOutput/IHMImpl/Tools/IHMExpressionParserClass.php
... | ... | @@ -45,13 +45,17 @@ class IHMExpressionParserClass |
45 | 45 | private $functionsArray; |
46 | 46 | |
47 | 47 | private $templatedParamMgr = NULL; |
48 | + | |
49 | + private $isTest = FALSE; | |
48 | 50 | |
49 | 51 | /* |
50 | 52 | * @brief Constructor |
51 | 53 | */ |
52 | - function __construct() | |
54 | + function __construct($isTest = FALSE) | |
53 | 55 | { |
54 | - $this->templatedParamMgr = new IHMParamTemplateClass(); | |
56 | + $this->isTest = $isTest; | |
57 | + if (!$isTest) | |
58 | + $this->templatedParamMgr = new IHMParamTemplateClass(); | |
55 | 59 | } |
56 | 60 | |
57 | 61 | /* |
... | ... | @@ -61,18 +65,19 @@ class IHMExpressionParserClass |
61 | 65 | { |
62 | 66 | //tests |
63 | 67 | $tests = array( |
64 | - "dst>3" => array ("expression" => "greater_than(\$dst,3)", "params" => array("dst")), | |
65 | - "@const_1<dst" => array("expression" => "(lower_than(1.0E-10,\$dst))", "params" => array("dst")), | |
66 | - "dst^#alias_2" => array("expression" => "(pow(\$dst,\$imf[1]))", "params" => array("dst","imf")), | |
67 | - "dst^2+@const_2" => array("expression" => "(pow(\$dst,2))+-2.8", "params" => array("dst")), | |
68 | - "atan(imf(2)/imf(1))+speed/100.0" => array("expression" => "atan((\$imf[2]/\$imf[1]))+(\$speed/100.0)", "params" => array("imf","speed")), | |
69 | - "shiftT_(clust1_hia_pad,60)" => array("expression" => "#timeShift(\$clust1_hia_pad;60)", "params" => array("clust1_hia_pad")), | |
70 | - "smooth_(density,1200)" => array("expression" => "#boxcar(\$density;1200)", "params" => array("density")), | |
71 | - "shiftT_(density,-600)" => array("expression" => "#timeShift(\$density;-600)", "params" => array("density")), | |
72 | - "deriv(density)" => array("expression" => "#deriv(\$density)", "params" => array("density")), | |
73 | - "abs(dst)" =>array("expression" => "abs(\$dst)", "params" => array("dst")), | |
74 | - "density*speed+(density^2-1.0)/speed" => array("expression" => "(\$density*\$speed)+((pow(\$density,2))-1.0)/\$speed", "params" => array("density","speed")), | |
75 | - "(-7<dst)&(dst<-3)" => array("expression" => "And((lower_than(-7,\$dst)),(lower_than(\$dst,-3)))", "params" => array("dst")) | |
68 | + "dst>3" => array ("expression" => "greater_than(\$dst,3)", "params" => array(array("paramid" => "dst"))), | |
69 | + "@const_1<dst" => array("expression" => "(lower_than(1.0E-10,\$dst))", "params" => array(array("paramid" =>"dst"))), | |
70 | + "dst^#alias_2" => array("expression" => "(pow(\$dst,\$imf[1]))", "params" => array(array("paramid" => "dst"),array("paramid" => "imf"))), | |
71 | + "dst^2+@const_2" => array("expression" => "(pow(\$dst,2))+-2.8", "params" => array(array("paramid" => "dst"))), | |
72 | + "atan(imf(2)/imf(1))+speed/100.0" => array("expression" => "atan((\$imf[2]/\$imf[1]))+(\$speed/100.0)", "params" => array(array("paramid" => "imf"), array("paramid" => "speed"))), | |
73 | + "shiftT_(clust1_hia_pad,60)" => array("expression" => "#timeShift(\$clust1_hia_pad;60)", "params" => array(array("paramid" => "clust1_hia_pad"))), | |
74 | + "smooth_(density,1200)" => array("expression" => "#boxcar(\$density;1200)", "params" => array(array("paramid" => "density"))), | |
75 | + "shiftT_(density,-600)" => array("expression" => "#timeShift(\$density;-600)", "params" => array(array("paramid" => "density"))), | |
76 | + "deriv(density)" => array("expression" => "#deriv(\$density)", "params" => array(array("paramid" => "density"))), | |
77 | + "abs(dst)" =>array("expression" => "abs(\$dst)", "params" => array(array("paramid" => "dst"))), | |
78 | + "density*speed+(density^2-1.0)/speed" => array("expression" => "(\$density*\$speed)+((pow(\$density,2))-1.0)/\$speed", "params" => array(array("paramid" => "density"),array("paramid" => "speed"))), | |
79 | + "(-7<dst)&(dst<-3)" => array("expression" => "And((lower_than(-7,\$dst)),(lower_than(\$dst,-3)))", "params" => array(array("paramid" => "dst"))), | |
80 | + "cass_caps_elssec4(range[0,10])" => array("expression" => "\$sum_into_table_range_cass_caps_elssec4_0_0_10", "params" => array(array("paramid" => "sum_into_table_range_cass_caps_elssec4_0_0_10"))) | |
76 | 81 | ); |
77 | 82 | |
78 | 83 | //init constants, aliases and functions for test |
... | ... | @@ -146,13 +151,19 @@ class IHMExpressionParserClass |
146 | 151 | //keep only params id |
147 | 152 | $params = array(); |
148 | 153 | foreach ($params_full as $param_full) { |
149 | - if (($templated_param_info = $this->templatedParamMgr->parseTemplatedParam($param_full["id"])) !== FALSE) { | |
154 | + if (array_key_exists("template_args", $param_full)) { | |
155 | + $params[] = array( | |
156 | + "paramid" => $param_full['id'], | |
157 | + "fullparamid" => $param_full['fullparamid'], | |
158 | + "template_args" => $param_full['template_args'] | |
159 | + ); | |
160 | + } | |
161 | + else if (!$this->isTest && (($templated_param_info = $this->templatedParamMgr->parseTemplatedParam($param_full["id"])) !== FALSE)) { | |
150 | 162 | $params[] = $templated_param_info; |
151 | 163 | } |
152 | 164 | else |
153 | 165 | $params[] = array("paramid" => $param_full["id"]); |
154 | 166 | } |
155 | - | |
156 | 167 | return array("expression" => $translated, "params" => $params); |
157 | 168 | } |
158 | 169 | |
... | ... | @@ -303,6 +314,14 @@ class IHMExpressionParserClass |
303 | 314 | $this->loadFunctions(); |
304 | 315 | return array_key_exists($element,$this->functionsArray); |
305 | 316 | } |
317 | + | |
318 | + /* | |
319 | + * @brief detect if the element is "range" | |
320 | + */ | |
321 | + private function isRange($element) | |
322 | + { | |
323 | + return ($element == "range"); | |
324 | + } | |
306 | 325 | |
307 | 326 | /* |
308 | 327 | * @brief detect if the element is an operator |
... | ... | @@ -534,7 +553,8 @@ class IHMExpressionParserClass |
534 | 553 | !$this->isDecimal($element) && |
535 | 554 | !$this->isOperator($element) && |
536 | 555 | !$this->isFunction($element) && |
537 | - ($element != ",") && ($element != ";") && ($element != "(") && ($element != ")")); | |
556 | + !$this->isRange($element) && | |
557 | + ($element != ",") && ($element != ";") && ($element != "(")); | |
538 | 558 | } |
539 | 559 | |
540 | 560 | /* |
... | ... | @@ -551,6 +571,21 @@ class IHMExpressionParserClass |
551 | 571 | (count($tree[$i] == 1)) && |
552 | 572 | $this->isInteger($tree[$i][0])); |
553 | 573 | } |
574 | + | |
575 | + /* | |
576 | + * @brief detect if the element is a range for a parameter | |
577 | + */ | |
578 | + private function isParameterRange($tree, $i) | |
579 | + { | |
580 | + $paramId = ""; | |
581 | + if ($i <= 0) | |
582 | + return false; | |
583 | + if (!$this->isParameter($tree[$i-1])) | |
584 | + return false; | |
585 | + return (is_array($tree[$i]) && | |
586 | + (count($tree[$i] == 1)) && | |
587 | + $this->isRange($tree[$i][0])); | |
588 | + } | |
554 | 589 | |
555 | 590 | /* |
556 | 591 | * @brief add a parameter |
... | ... | @@ -575,6 +610,29 @@ class IHMExpressionParserClass |
575 | 610 | return; |
576 | 611 | } |
577 | 612 | } |
613 | + | |
614 | + /* | |
615 | + * @brief add a parameter range | |
616 | + */ | |
617 | + private function addParameterRangeInParameterArray($paramId, $range, &$params) | |
618 | + { | |
619 | + $sum_parameter_id = ""; | |
620 | + if ((count($range) == 2) && (count($range[1]) == 3) && ($this->isInteger($range[1][0])) && ($this->isInteger($range[1][2])) & ($range[1][1] == ",")) { | |
621 | + $sum_parameter_id = "sum_into_table_range_".$paramId."_0_".$range[1][0]."_".$range[1][2]; | |
622 | + $params[] = array("id" => "sum_into_table_range", | |
623 | + "fullparamid" => $sum_parameter_id, | |
624 | + "indexes" => array(), | |
625 | + "calib_infos" => array(), | |
626 | + "template_args" => array( | |
627 | + "paramid" => $paramId, | |
628 | + "relateddim" => 0, | |
629 | + "min" => $range[1][0], | |
630 | + "max" => $range[1][2] | |
631 | + ) | |
632 | + ); | |
633 | + } | |
634 | + return $sum_parameter_id; | |
635 | + } | |
578 | 636 | |
579 | 637 | /* |
580 | 638 | * @brief process used to treat parameter components |
... | ... | @@ -592,16 +650,29 @@ class IHMExpressionParserClass |
592 | 650 | else if ($this->isParameter($tree[$i])) |
593 | 651 | { |
594 | 652 | $param = $tree[$i]; |
595 | - $this->addParameterIdInParameterArray($param,$params); | |
653 | + | |
596 | 654 | if ($i < count($tree) - 1) |
597 | 655 | { |
598 | - if ($this->isParameterComponent($tree,$i+1)) | |
656 | + if ($this->isParameterRange($tree,$i+1)) | |
599 | 657 | { |
600 | - $this->addParameterComponentInParameterArray($param, $tree[$i+1][0], $params); | |
601 | - $param .= ("[".$tree[$i+1][0]."]"); | |
658 | + $sum_parameter_id = $this->addParameterRangeInParameterArray($param, $tree[$i+1], $params); | |
659 | + $param = $sum_parameter_id; | |
602 | 660 | ++$i; |
603 | 661 | } |
662 | + else | |
663 | + { | |
664 | + $this->addParameterIdInParameterArray($param,$params); | |
665 | + if ($this->isParameterComponent($tree,$i+1)) | |
666 | + { | |
667 | + $this->addParameterComponentInParameterArray($param, $tree[$i+1][0], $params); | |
668 | + $param .= ("[".$tree[$i+1][0]."]"); | |
669 | + ++$i; | |
670 | + } | |
671 | + } | |
604 | 672 | } |
673 | + else | |
674 | + $this->addParameterIdInParameterArray($param,$params); | |
675 | + | |
605 | 676 | $result[] = $param; |
606 | 677 | } |
607 | 678 | else |
... | ... | @@ -733,7 +804,7 @@ class IHMExpressionParserClass |
733 | 804 | } |
734 | 805 | else if ($tree[$i] == ";") |
735 | 806 | { |
736 | - //echo "DOT COMA".PHP_EOL; | |
807 | + echo "DOT COMA".PHP_EOL; | |
737 | 808 | $translated .= ";"; |
738 | 809 | } |
739 | 810 | else if ($this->isFunction($tree[$i])) |
... | ... | @@ -752,12 +823,19 @@ class IHMExpressionParserClass |
752 | 823 | { |
753 | 824 | //echo "TEST ".$param["id"].PHP_EOL; |
754 | 825 | |
755 | - if ($param["id"] == $tree[$i]) | |
826 | + if (array_key_exists("template_args", $param)) | |
827 | + { | |
828 | + $founded = true; | |
829 | + $translated .= "\$".$param["fullparamid"]; | |
830 | + break; | |
831 | + } | |
832 | + else if ($param["id"] == $tree[$i]) | |
756 | 833 | { |
757 | 834 | $founded = true; |
758 | 835 | $translated .= ("\$".$tree[$i]); |
759 | 836 | break; |
760 | 837 | } |
838 | + | |
761 | 839 | foreach ($param["indexes"] as $index) |
762 | 840 | { |
763 | 841 | $temp = ""; |
... | ... | @@ -801,7 +879,7 @@ class IHMExpressionParserClass |
801 | 879 | } |
802 | 880 | } |
803 | 881 | |
804 | -/*$parser = new IHMExpressionParserClass(); | |
882 | +/*$parser = new IHMExpressionParserClass(TRUE); | |
805 | 883 | try { |
806 | 884 | $parser->test(); |
807 | 885 | } catch (Exception $e) { |
... | ... |
src/Request/ParamInfoRequestClass.php
... | ... | @@ -125,15 +125,18 @@ class ParamInfoRequestClass extends RequestAbstractClass |
125 | 125 | 'relatedDim' => ($tableNode->getAttribute("relatedDim") == "dim_1" ? "dim1" : "dim2"), |
126 | 126 | 'name' => $tableNode->getAttribute("name"), |
127 | 127 | 'units' => $tableNode->getAttribute("units"), |
128 | + 'variable' => ($tableNode->getAttribute("variable") === "true"), | |
128 | 129 | 'channels' => array() |
129 | 130 | ); |
130 | 131 | |
131 | - $channelNodes = $tableNode->getElementsByTagName("channel"); | |
132 | - foreach ($channelNodes as $channelNode) { | |
133 | - $tableResult['channels'][] = array( | |
134 | - 'min' => $channelNode->getAttribute("min"), | |
135 | - 'max' => $channelNode->getAttribute("max") | |
136 | - ); | |
132 | + if (!$tableResult['variable']) { | |
133 | + $channelNodes = $tableNode->getElementsByTagName("channel"); | |
134 | + foreach ($channelNodes as $channelNode) { | |
135 | + $tableResult['channels'][] = array( | |
136 | + 'min' => $channelNode->getAttribute("min"), | |
137 | + 'max' => $channelNode->getAttribute("max") | |
138 | + ); | |
139 | + } | |
137 | 140 | } |
138 | 141 | |
139 | 142 | $result['tables'][] = $tableResult; |
... | ... |