Commit 52c1e2914f0bb70a510a349e76e423918d281bac
1 parent
db7ea505
Exists in
master
and in
57 other branches
Generate TT and catlog parameters for plot
Showing
8 changed files
with
537 additions
and
3 deletions
Show diff stats
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... | ... | @@ -662,8 +662,15 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
662 | 662 | $drawingEltIndex = 0; |
663 | 663 | foreach ($paramsData as $paramData) |
664 | 664 | { |
665 | + $isTTCat = ($paramData->{'param-type'} == 'ttcat'); | |
666 | + | |
665 | 667 | //Param |
666 | - $paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, isset($paramData->{'template_args'}) ? $paramData->{'template_args'} : NULL); | |
668 | + if (!$isTTCat) { | |
669 | + $paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, isset($paramData->{'template_args'}) ? $paramData->{'template_args'} : NULL); | |
670 | + } | |
671 | + else { | |
672 | + $paramInfo = $this->paramManager->addTTCatParam($paramData->{'paramid'}, $this->paramsData); | |
673 | + } | |
667 | 674 | |
668 | 675 | $paramInfo['indexes'] = array(); |
669 | 676 | |
... | ... |
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) |
... | ... |
... | ... | @@ -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/Request/ParamsRequestImpl/Nodes/Infos/InfoParamNodeClass.php
... | ... | @@ -16,7 +16,12 @@ define ("INFOPARAM_SICONV", "si_conversion"); |
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 "ParamClbManualNodeClass.php"; |
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/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 | { |
... | ... |