Commit 54219b37d80cffafbd54eb4b5f2250209f730eb6
1 parent
0a56ad20
Exists in
master
and in
58 other branches
Add support for sum into table indexes
Showing
2 changed files
with
44 additions
and
19 deletions
Show diff stats
src/InputOutput/IHMImpl/Tools/IHMExpressionParserClass.php
... | ... | @@ -86,6 +86,7 @@ class IHMExpressionParserClass |
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 | 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")))), | |
89 | 90 | ); |
90 | 91 | |
91 | 92 | //init constants, aliases and functions for test |
... | ... | @@ -345,11 +346,11 @@ class IHMExpressionParserClass |
345 | 346 | } |
346 | 347 | |
347 | 348 | /* |
348 | - * @brief detect if the element is "range" | |
349 | + * @brief detect if the element is "range" or "indexes" | |
349 | 350 | */ |
350 | - private function isRange($element) | |
351 | + private function isRangeOrIndexes($element) | |
351 | 352 | { |
352 | - return ($element == "range"); | |
353 | + return (($element == "range") || ($element == "indexes")); | |
353 | 354 | } |
354 | 355 | |
355 | 356 | /* |
... | ... | @@ -584,7 +585,7 @@ class IHMExpressionParserClass |
584 | 585 | !$this->isDecimal($element) && |
585 | 586 | !$this->isOperator($element) && |
586 | 587 | !$this->isFunction($element) && |
587 | - !$this->isRange($element) && | |
588 | + !$this->isRangeOrIndexes($element) && | |
588 | 589 | ($element != ",") && ($element != ";") && ($element != "(")); |
589 | 590 | } |
590 | 591 | |
... | ... | @@ -606,16 +607,20 @@ class IHMExpressionParserClass |
606 | 607 | /* |
607 | 608 | * @brief detect if the element is a range for a parameter |
608 | 609 | */ |
609 | - private function isParameterRange($tree, $i) | |
610 | + private function isParameterRangeOrIndexes($tree, $i, &$isIndexes) | |
610 | 611 | { |
611 | 612 | $paramId = ""; |
613 | + $isIndexes = FALSE; | |
612 | 614 | if ($i <= 0) |
613 | 615 | return false; |
614 | 616 | if (!$this->isParameter($tree[$i-1])) |
615 | 617 | return false; |
616 | - return (is_array($tree[$i]) && | |
618 | + $result = (is_array($tree[$i]) && | |
617 | 619 | (count($tree[$i] == 1)) && |
618 | - $this->isRange($tree[$i][0])); | |
620 | + $this->isRangeOrIndexes($tree[$i][0])); | |
621 | + if ($result) | |
622 | + $isIndexes = ($tree[$i][0] == "indexes"); | |
623 | + return $result; | |
619 | 624 | } |
620 | 625 | |
621 | 626 | /* |
... | ... | @@ -646,12 +651,13 @@ class IHMExpressionParserClass |
646 | 651 | /* |
647 | 652 | * @brief add a parameter range |
648 | 653 | */ |
649 | - private function addParameterRangeInParameterArray($paramId, $range, &$params) | |
654 | + private function addParameterRangeOrIndexesInParameterArray($paramId, $range, $isIndexes, &$params) | |
650 | 655 | { |
651 | 656 | $sum_parameter_id = ""; |
652 | 657 | if ((count($range) == 2) && (count($range[1]) == 3) && ($this->isInteger($range[1][0])) && ($this->isInteger($range[1][2])) & ($range[1][1] == ",")) { |
653 | - $sum_parameter_id = "sum_into_table_range_".$paramId."_0_".$range[1][0]."_".$range[1][2]; | |
654 | - $params[] = array("id" => "sum_into_table_range", | |
658 | + $sum_param = $isIndexes ? "sum_into_table_indexes" : "sum_into_table_range"; | |
659 | + $sum_parameter_id = $sum_param."_".$paramId."_0_".$range[1][0]."_".$range[1][2]; | |
660 | + $params[] = array("id" => $sum_param, | |
655 | 661 | "fullparamid" => $sum_parameter_id, |
656 | 662 | "indexes" => array(), |
657 | 663 | "calib_infos" => array(), |
... | ... | @@ -685,9 +691,10 @@ class IHMExpressionParserClass |
685 | 691 | |
686 | 692 | if ($i < count($tree) - 1) |
687 | 693 | { |
688 | - if ($this->isParameterRange($tree,$i+1)) | |
694 | + $isIndexes = FALSE; | |
695 | + if ($this->isParameterRangeOrIndexes($tree,$i+1,$isIndexes)) | |
689 | 696 | { |
690 | - $sum_parameter_id = $this->addParameterRangeInParameterArray($param, $tree[$i+1], $params); | |
697 | + $sum_parameter_id = $this->addParameterRangeOrIndexesInParameterArray($param, $tree[$i+1], $isIndexes, $params); | |
691 | 698 | $param = $sum_parameter_id; |
692 | 699 | ++$i; |
693 | 700 | } | ... | ... |
src/InputOutput/IHMImpl/Tools/IHMParamManagerClass.php
... | ... | @@ -443,12 +443,12 @@ class IHMParamManagerClass |
443 | 443 | } |
444 | 444 | |
445 | 445 | public function applyRangesAndIndexes($paramsData, $paramData, $force_total_2d, &$paramInfo) { |
446 | - $dim1_is_range = (isset($paramData->{'dim1-is-range'}) && $paramData->{'dim1-is-range'}); | |
446 | + $dim1_is_range = (isset($paramData->{'dim1-type-range'}) && ($paramData->{'dim1-type-range'} > 0)); | |
447 | 447 | $dim1_index = ($dim1_is_range || !isset($paramData->{'dim1-index'}) || ($paramData->{'dim1-index'} == '')) ? '*' : $paramData->{'dim1-index'}; |
448 | 448 | $dim1_min = (!$dim1_is_range || !isset($paramData->{'dim1-min-range'}) || ($paramData->{'dim1-min-range'} == '')) ? 0 : $paramData->{'dim1-min-range'}; |
449 | 449 | $dim1_max = (!$dim1_is_range || !isset($paramData->{'dim1-max-range'}) || ($paramData->{'dim1-max-range'} == '')) ? 0 : $paramData->{'dim1-max-range'}; |
450 | 450 | |
451 | - $dim2_is_range = (isset($paramData->{'dim2-is-range'}) && $paramData->{'dim2-is-range'}); | |
451 | + $dim2_is_range = (isset($paramData->{'dim2-type-range'}) && ($paramData->{'dim2-type-range'} > 0)); | |
452 | 452 | $dim2_index = ($dim2_is_range || !isset($paramData->{'dim2-index'}) || ($paramData->{'dim2-index'} == '')) ? '*' : $paramData->{'dim2-index'}; |
453 | 453 | $dim2_min = (!$dim2_is_range || !isset($paramData->{'dim2-min-range'}) || ($paramData->{'dim2-min-range'} == '')) ? 0 : $paramData->{'dim2-min-range'}; |
454 | 454 | $dim2_max = (!$dim2_is_range || !isset($paramData->{'dim2-max-range'}) || ($paramData->{'dim2-max-range'} == '')) ? 0 : $paramData->{'dim2-max-range'}; |
... | ... | @@ -466,7 +466,10 @@ class IHMParamManagerClass |
466 | 466 | 'max' => $dim1_max, |
467 | 467 | 'relateddim' => 0, |
468 | 468 | ); |
469 | - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args); | |
469 | + if ($paramData->{'dim1-type-range'} == 2) | |
470 | + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args); | |
471 | + else | |
472 | + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args); | |
470 | 473 | } |
471 | 474 | else if ($dim2_is_range) { |
472 | 475 | $template_args = array( |
... | ... | @@ -475,7 +478,10 @@ class IHMParamManagerClass |
475 | 478 | 'max' => $dim2_max, |
476 | 479 | 'relateddim' => 1, |
477 | 480 | ); |
478 | - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args); | |
481 | + if ($paramData->{'dim2-type-range'} == 2) | |
482 | + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args); | |
483 | + else | |
484 | + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args); | |
479 | 485 | } |
480 | 486 | else if ($dim1_index != '*') { |
481 | 487 | $paramInfo['indexes'][] = $dim1_index; |
... | ... | @@ -487,6 +493,9 @@ class IHMParamManagerClass |
487 | 493 | case 2: |
488 | 494 | //Tab2D |
489 | 495 | if ($dim1_is_range && $dim2_is_range) { |
496 | + if ($paramData->{'dim1-type-range'} != $paramData->{'dim2-type-range'}) { | |
497 | + throw new Exception("Not supported - Dimensions ranges for ".$paramInfo['id']." must have the same type for each dimensions"); | |
498 | + } | |
490 | 499 | $template_args = array( |
491 | 500 | 'paramid' => $paramInfo['id'], |
492 | 501 | 'min1' => $dim1_min, |
... | ... | @@ -495,7 +504,10 @@ class IHMParamManagerClass |
495 | 504 | 'min2' => $dim2_min, |
496 | 505 | 'max2' => $dim2_max, |
497 | 506 | ); |
498 | - $paramInfo = $this->addExistingParam('sum_into_table_range_2d', $paramsData, $template_args); | |
507 | + if ($paramData->{'dim1-type-range'} == 2) | |
508 | + $paramInfo = $this->addExistingParam('sum_into_table_indexes_2d', $paramsData, $template_args); | |
509 | + else | |
510 | + $paramInfo = $this->addExistingParam('sum_into_table_range_2d', $paramsData, $template_args); | |
499 | 511 | } |
500 | 512 | else if ($dim1_is_range) { |
501 | 513 | $template_args = array( |
... | ... | @@ -508,7 +520,10 @@ class IHMParamManagerClass |
508 | 520 | 'paramid' => $paramInfo['id'], |
509 | 521 | 'relateddim' => 1, |
510 | 522 | ); |
511 | - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink); | |
523 | + if ($paramData->{'dim1-type-range'} == 2) | |
524 | + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args, $tableLink); | |
525 | + else | |
526 | + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink); | |
512 | 527 | if ($dim2_index != '*') { |
513 | 528 | $paramInfo['indexes'][] = $dim2_index; |
514 | 529 | } |
... | ... | @@ -524,7 +539,10 @@ class IHMParamManagerClass |
524 | 539 | 'paramid' => $paramInfo['id'], |
525 | 540 | 'relateddim' => 0, |
526 | 541 | ); |
527 | - $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink); | |
542 | + if ($paramData->{'dim2-type-range'} == 2) | |
543 | + $paramInfo = $this->addExistingParam('sum_into_table_indexes', $paramsData, $template_args, $tableLink); | |
544 | + else | |
545 | + $paramInfo = $this->addExistingParam('sum_into_table_range', $paramsData, $template_args, $tableLink); | |
528 | 546 | if ($dim1_index != '*') { |
529 | 547 | $paramInfo['indexes'][] = $dim1_index; |
530 | 548 | } | ... | ... |