Commit 51cbca5cad0ce939cc453d6f33c1d2ea1492a97f
1 parent
70646e70
Exists in
master
and in
66 other branches
Add constants definitions
Showing
3 changed files
with
77 additions
and
13 deletions
Show diff stats
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... | ... | @@ -303,7 +303,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
303 | 303 | |
304 | 304 | //Axes |
305 | 305 | foreach ($panelData->{'axes'} as $axisData) |
306 | - $this->unmarshallAxis($axisData, $plotNode); | |
306 | + $this->unmarshallAxis($axisData, $panelData->{'constants'}, $plotNode); | |
307 | 307 | |
308 | 308 | //Params |
309 | 309 | $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode); |
... | ... | @@ -368,28 +368,34 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
368 | 368 | return $plotNode; |
369 | 369 | } |
370 | 370 | |
371 | - protected function unmarshallAxis($axisData, $plotNode) | |
371 | + protected function unmarshallAxis($axisData, $constantsData, $plotNode) | |
372 | 372 | { |
373 | 373 | //axis type |
374 | + $constantAxisId = ''; | |
374 | 375 | switch ($axisData->{'axis-type'}) |
375 | 376 | { |
376 | 377 | case 'time' : |
377 | 378 | $axisNode = $plotNode->getTimeAxis(); |
378 | 379 | $axisNode->setFormat($axisData->{'axis-time-format'}); |
380 | + $constantAxisId = 'x'; | |
379 | 381 | break; |
380 | 382 | case 'epoch' : |
381 | 383 | $axisNode = $plotNode->getEpochAxis(); |
382 | 384 | $axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false"); |
385 | + $constantAxisId = 'x'; | |
383 | 386 | break; |
384 | 387 | case 'x' : |
385 | 388 | $axisNode = $plotNode->getXAxis(); |
389 | + $constantAxisId = 'x'; | |
386 | 390 | break; |
387 | 391 | case 'y-left' : |
388 | 392 | $axisNode = $plotNode->addYAxis('y-left'); |
393 | + $constantAxisId = 'y-left'; | |
389 | 394 | break; |
390 | 395 | case 'y-right' : |
391 | 396 | $axisNode = $plotNode->addYAxis('y-right'); |
392 | 397 | $axisNode->setPosition(RequestOutputPlotAxisElementPosition::RIGHT); |
398 | + $constantAxisId = 'y-right'; | |
393 | 399 | break; |
394 | 400 | case 'color' : |
395 | 401 | $axisNode = $plotNode->getZAxis(); |
... | ... | @@ -452,6 +458,14 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
452 | 458 | |
453 | 459 | //Show tick marks |
454 | 460 | $axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false"); |
461 | + | |
462 | + //Add constants | |
463 | + if ($constantAxisId != '') | |
464 | + { | |
465 | + foreach ($constantsData as $constantData) | |
466 | + if ($constantData->{'constant-axis-id'} == $constantAxisId) | |
467 | + $this->unmarshallConstant($constantData,$axisNode); | |
468 | + } | |
455 | 469 | } |
456 | 470 | |
457 | 471 | protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode) |
... | ... | @@ -597,7 +611,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
597 | 611 | } |
598 | 612 | } |
599 | 613 | //Line |
600 | - $this->unmarshallLine($paramDrawingData, 'serie', $serieNode->getLine()); | |
614 | + $this->unmarshallLine($paramDrawingData, 'serie', $serieNode->getLine(), $paramDrawingData->{"serie-lines-activated"} ? RequestOutputPlotLineTypeEnum::LINE : RequestOutputPlotLineTypeEnum::NO); | |
601 | 615 | //Symbol |
602 | 616 | if (!$paramDrawingData->{"serie-symbols-activated"}) |
603 | 617 | $serieNode->getSymbol()->setType(RequestOutputPlotSymbolTypeEnum::NO); |
... | ... | @@ -649,7 +663,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
649 | 663 | $iserieNode->setTableOnXAxis($paramDrawingData->{'iserie-tableonx'} ? "true" : "false"); |
650 | 664 | |
651 | 665 | //Line |
652 | - $this->unmarshallLine($paramDrawingData, 'iserie', $iserieNode->getLine()); | |
666 | + $this->unmarshallLine($paramDrawingData, 'iserie', $iserieNode->getLine(), $paramDrawingData->{"iserie-lines-activated"} ? RequestOutputPlotLineTypeEnum::LINE : RequestOutputPlotLineTypeEnum::NO); | |
653 | 667 | |
654 | 668 | //Symbol |
655 | 669 | if (!$paramDrawingData->{"iserie-symbols-activated"}) |
... | ... | @@ -782,6 +796,27 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
782 | 796 | $this->unmarshallFont($textLegendData, 'legend-text-font', $legendNode->getFont()); |
783 | 797 | } |
784 | 798 | |
799 | + protected function unmarshallConstant($constantData,$axisNode) | |
800 | + { | |
801 | + $constantNode = $axisNode->addConstant(); | |
802 | + | |
803 | + //Constant value | |
804 | + switch ($axisNode->getName()) | |
805 | + { | |
806 | + case REQUESTOUTPUTPLOTTIMEAXIS_NAME : | |
807 | + date_default_timezone_set('UTC'); | |
808 | + $timeStamp = strtotime($constantData->{'constant-time-value'}); | |
809 | + $time = CommonClass::timeStampToDDTime($timeStamp); | |
810 | + $constantNode->setConstantValue($time); | |
811 | + break; | |
812 | + default : | |
813 | + $constantNode->setConstantValue($constantData->{'constant-float-value'}); | |
814 | + } | |
815 | + | |
816 | + //Curve options | |
817 | + $this->unmarshallCurve($constantData, "constant-line", $constantNode); | |
818 | + } | |
819 | + | |
785 | 820 | protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) |
786 | 821 | { |
787 | 822 | if ($inputData->{$keyPrefix.'-text'} != '') |
... | ... | @@ -888,15 +923,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
888 | 923 | $curveNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'})); |
889 | 924 | } |
890 | 925 | |
891 | - protected function unmarshallLine($inputData, $keyPrefix, $lineNode) | |
926 | + protected function unmarshallLine($inputData, $keyPrefix, $lineNode, $lineType) | |
892 | 927 | { |
893 | - if (!$inputData->{$keyPrefix."-lines-activated"}) | |
894 | - $lineNode->setType(RequestOutputPlotLineTypeEnum::NO); | |
895 | - else | |
896 | - { | |
897 | - $lineNode->setType(RequestOutputPlotLineTypeEnum::LINE); | |
898 | - $this->unmarshallCurve($inputData, $keyPrefix."-lines", $lineNode); | |
899 | - } | |
928 | + $lineNode->setType($lineType); | |
929 | + $this->unmarshallCurve($inputData, $keyPrefix."-lines", $lineNode); | |
900 | 930 | } |
901 | 931 | |
902 | 932 | protected function unmarshallSymbol($inputData, $keyPrefix, $symbolNode) |
... | ... |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxisElementNodeClass.php
... | ... | @@ -188,7 +188,12 @@ class RequestOutputPlotAxisElementNodeClass extends NodeClass |
188 | 188 | return $this->getFirstChildByName(REQUESTOUTPUTPLOTAXISELEMENTLEGEND_NAME); |
189 | 189 | } |
190 | 190 | |
191 | - /* ToDo constantLine */ | |
191 | + public function addConstant() | |
192 | + { | |
193 | + $node = new RequestOutputPlotConstantNodeClass(); | |
194 | + $this->addChild($node); | |
195 | + return $node; | |
196 | + } | |
192 | 197 | |
193 | 198 | /* ToDo origin */ |
194 | 199 | |
... | ... |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotConstantNodeClass.php
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +<?php | |
2 | + | |
3 | +define ("REQUESTOUTPUTPLOTCONSTANT_NAME", "constantLine"); | |
4 | +define ("REQUESTOUTPUTPLOTCONSTANT_VALUE", "value"); | |
5 | + | |
6 | +/** | |
7 | + * @class RequestOutputPlotConstantNodeClass | |
8 | + * @brief Definition of a constant element for a plot | |
9 | + * @details | |
10 | + */ | |
11 | +class RequestOutputPlotConstantNodeClass extends RequestOutputPlotCurveNodeClass | |
12 | +{ | |
13 | + public function __construct() | |
14 | + { | |
15 | + parent::__construct(REQUESTOUTPUTPLOTCONSTANT_NAME); | |
16 | + } | |
17 | + | |
18 | + public function setConstantValue($value) | |
19 | + { | |
20 | + $this->setAttribute(REQUESTOUTPUTPLOTCONSTANT_VALUE, $value); | |
21 | + } | |
22 | + | |
23 | + public function getConstantValue() | |
24 | + { | |
25 | + return $this->getAttribute(REQUESTOUTPUTPLOTCONSTANT_VALUE); | |
26 | + } | |
27 | +} | |
28 | + | |
29 | +?> | |
0 | 30 | \ No newline at end of file |
... | ... |