Commit 51cbca5cad0ce939cc453d6f33c1d2ea1492a97f

Authored by Benjamin Renard
1 parent 70646e70

Add constants definitions

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
@@ -303,7 +303,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -303,7 +303,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
303 303
304 //Axes 304 //Axes
305 foreach ($panelData->{'axes'} as $axisData) 305 foreach ($panelData->{'axes'} as $axisData)
306 - $this->unmarshallAxis($axisData, $plotNode); 306 + $this->unmarshallAxis($axisData, $panelData->{'constants'}, $plotNode);
307 307
308 //Params 308 //Params
309 $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode); 309 $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode);
@@ -368,28 +368,34 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -368,28 +368,34 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
368 return $plotNode; 368 return $plotNode;
369 } 369 }
370 370
371 - protected function unmarshallAxis($axisData, $plotNode) 371 + protected function unmarshallAxis($axisData, $constantsData, $plotNode)
372 { 372 {
373 //axis type 373 //axis type
  374 + $constantAxisId = '';
374 switch ($axisData->{'axis-type'}) 375 switch ($axisData->{'axis-type'})
375 { 376 {
376 case 'time' : 377 case 'time' :
377 $axisNode = $plotNode->getTimeAxis(); 378 $axisNode = $plotNode->getTimeAxis();
378 $axisNode->setFormat($axisData->{'axis-time-format'}); 379 $axisNode->setFormat($axisData->{'axis-time-format'});
  380 + $constantAxisId = 'x';
379 break; 381 break;
380 case 'epoch' : 382 case 'epoch' :
381 $axisNode = $plotNode->getEpochAxis(); 383 $axisNode = $plotNode->getEpochAxis();
382 $axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false"); 384 $axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false");
  385 + $constantAxisId = 'x';
383 break; 386 break;
384 case 'x' : 387 case 'x' :
385 $axisNode = $plotNode->getXAxis(); 388 $axisNode = $plotNode->getXAxis();
  389 + $constantAxisId = 'x';
386 break; 390 break;
387 case 'y-left' : 391 case 'y-left' :
388 $axisNode = $plotNode->addYAxis('y-left'); 392 $axisNode = $plotNode->addYAxis('y-left');
  393 + $constantAxisId = 'y-left';
389 break; 394 break;
390 case 'y-right' : 395 case 'y-right' :
391 $axisNode = $plotNode->addYAxis('y-right'); 396 $axisNode = $plotNode->addYAxis('y-right');
392 $axisNode->setPosition(RequestOutputPlotAxisElementPosition::RIGHT); 397 $axisNode->setPosition(RequestOutputPlotAxisElementPosition::RIGHT);
  398 + $constantAxisId = 'y-right';
393 break; 399 break;
394 case 'color' : 400 case 'color' :
395 $axisNode = $plotNode->getZAxis(); 401 $axisNode = $plotNode->getZAxis();
@@ -452,6 +458,14 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -452,6 +458,14 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
452 458
453 //Show tick marks 459 //Show tick marks
454 $axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false"); 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 protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode) 471 protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode)
@@ -597,7 +611,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -597,7 +611,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
597 } 611 }
598 } 612 }
599 //Line 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 //Symbol 615 //Symbol
602 if (!$paramDrawingData->{"serie-symbols-activated"}) 616 if (!$paramDrawingData->{"serie-symbols-activated"})
603 $serieNode->getSymbol()->setType(RequestOutputPlotSymbolTypeEnum::NO); 617 $serieNode->getSymbol()->setType(RequestOutputPlotSymbolTypeEnum::NO);
@@ -649,7 +663,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -649,7 +663,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
649 $iserieNode->setTableOnXAxis($paramDrawingData->{'iserie-tableonx'} ? "true" : "false"); 663 $iserieNode->setTableOnXAxis($paramDrawingData->{'iserie-tableonx'} ? "true" : "false");
650 664
651 //Line 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 //Symbol 668 //Symbol
655 if (!$paramDrawingData->{"iserie-symbols-activated"}) 669 if (!$paramDrawingData->{"iserie-symbols-activated"})
@@ -782,6 +796,27 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -782,6 +796,27 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
782 $this->unmarshallFont($textLegendData, 'legend-text-font', $legendNode->getFont()); 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 protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) 820 protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
786 { 821 {
787 if ($inputData->{$keyPrefix.'-text'} != '') 822 if ($inputData->{$keyPrefix.'-text'} != '')
@@ -888,15 +923,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -888,15 +923,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
888 $curveNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix.'-color'})); 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 protected function unmarshallSymbol($inputData, $keyPrefix, $symbolNode) 932 protected function unmarshallSymbol($inputData, $keyPrefix, $symbolNode)
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxisElementNodeClass.php
@@ -188,7 +188,12 @@ class RequestOutputPlotAxisElementNodeClass extends NodeClass @@ -188,7 +188,12 @@ class RequestOutputPlotAxisElementNodeClass extends NodeClass
188 return $this->getFirstChildByName(REQUESTOUTPUTPLOTAXISELEMENTLEGEND_NAME); 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 /* ToDo origin */ 198 /* ToDo origin */
194 199
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotConstantNodeClass.php 0 → 100644
@@ -0,0 +1,29 @@ @@ -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 \ No newline at end of file 30 \ No newline at end of file