Commit f28f7c0e15ad117b4165eb23df255c919845f7c0
1 parent
966bd5f8
Exists in
master
and in
66 other branches
Add param info request to get components and tables definitions
Showing
5 changed files
with
222 additions
and
105 deletions
Show diff stats
config/AMDAIntegrationConfig.php
@@ -130,6 +130,9 @@ define('NEWKERNEL_INFO_DIR', NEWKERNEL_BASE_PATH.'config/'); | @@ -130,6 +130,9 @@ define('NEWKERNEL_INFO_DIR', NEWKERNEL_BASE_PATH.'config/'); | ||
130 | //Path to local parameters database for the new kernel | 130 | //Path to local parameters database for the new kernel |
131 | define('PARAMS_LOCALDB_DIR', IHM_SRC_DIR.'generic_data/newKernelDDBase/'); | 131 | define('PARAMS_LOCALDB_DIR', IHM_SRC_DIR.'generic_data/newKernelDDBase/'); |
132 | 132 | ||
133 | +//Path to local parameters information files | ||
134 | +define('PARAMS_LOCALINFO_DIR', IHM_SRC_DIR.'generic_data/ParamInfo/'); | ||
135 | + | ||
133 | //Path to dir that include DD.res file | 136 | //Path to dir that include DD.res file |
134 | define('DDRES_DIR', NEWKERNEL_BASE_PATH.'app-debug/'); | 137 | define('DDRES_DIR', NEWKERNEL_BASE_PATH.'app-debug/'); |
135 | 138 |
src/InputOutput/IHMImpl/Config/IHMConfigClass.php
@@ -10,7 +10,7 @@ class IHMConfigClass | @@ -10,7 +10,7 @@ class IHMConfigClass | ||
10 | private static $genericDataDir = "generic_data/"; | 10 | private static $genericDataDir = "generic_data/"; |
11 | 11 | ||
12 | private static $functionsDir = "Functions/"; | 12 | private static $functionsDir = "Functions/"; |
13 | - | 13 | + |
14 | private static $constantsFile = "constants.xml"; | 14 | private static $constantsFile = "constants.xml"; |
15 | 15 | ||
16 | private static $functionsFile = "functions.xml"; | 16 | private static $functionsFile = "functions.xml"; |
@@ -95,6 +95,11 @@ class IHMConfigClass | @@ -95,6 +95,11 @@ class IHMConfigClass | ||
95 | { | 95 | { |
96 | return PARAMS_LOCALDB_DIR; | 96 | return PARAMS_LOCALDB_DIR; |
97 | } | 97 | } |
98 | + | ||
99 | + public static function getLocalParamInfoPath() | ||
100 | + { | ||
101 | + return PARAMS_LOCALINFO_DIR; | ||
102 | + } | ||
98 | 103 | ||
99 | public static function getSharedTTPath() | 104 | public static function getSharedTTPath() |
100 | { | 105 | { |
src/InputOutput/IHMImpl/ParamInfo/IHMInputOutputParamInfoClass.php
@@ -26,19 +26,35 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -26,19 +26,35 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
26 | switch ($input->type) { | 26 | switch ($input->type) { |
27 | case 'plot_init' : | 27 | case 'plot_init' : |
28 | $this->paramInfoData->setType(ParamInfoTypeEnumClass::PLOTINIT); | 28 | $this->paramInfoData->setType(ParamInfoTypeEnumClass::PLOTINIT); |
29 | + | ||
30 | + if (!isset($input->paramId) || empty($input->paramId)) | ||
31 | + throw new Exception("Param info request need a param id as argument"); | ||
32 | + $paramFilePath = IHMConfigClass::getLocalParamDBPath().$input->paramId.".xml"; | ||
33 | + | ||
34 | + if (!file_exists($paramFilePath)) | ||
35 | + throw new Exception("Cannot find parameter definition file"); | ||
36 | + | ||
37 | + $this->paramInfoData->setFilePath($paramFilePath); | ||
38 | + break; | ||
39 | + case 'param_info' : | ||
40 | + $this->paramInfoData->setType(ParamInfoTypeEnumClass::PARAMINFO); | ||
41 | + | ||
42 | + if (!isset($input->paramId) || empty($input->paramId)) | ||
43 | + throw new Exception("Param info request need a param id as argument"); | ||
44 | + | ||
45 | + | ||
46 | + $paramInfoFilePath = IHMConfigClass::getLocalParamInfoPath().'info_'.$input->paramId.".xml"; | ||
47 | + | ||
48 | + if (!file_exists($paramInfoFilePath)) | ||
49 | + throw new Exception("Cannot find parameter info file " . $paramInfoFilePath); | ||
50 | + | ||
51 | + $this->paramInfoData->setFilePath($paramInfoFilePath); | ||
29 | break; | 52 | break; |
30 | default : | 53 | default : |
31 | throw new Exception("Para info request type '".$input->type."' not yet implemented"); | 54 | throw new Exception("Para info request type '".$input->type."' not yet implemented"); |
32 | } | 55 | } |
33 | - if (!isset($input->paramId) || empty($input->paramId)) | ||
34 | - throw new Exception("Param info request need a param id as argument"); | ||
35 | - $paramFilePath = IHMConfigClass::getLocalParamDBPath().$input->paramId.".xml"; | ||
36 | - | ||
37 | - if (!file_exists($paramFilePath)) | ||
38 | - throw new Exception("Cannot find parameter definition file"); | ||
39 | 56 | ||
40 | $this->paramInfoData->setParamId($input->paramId); | 57 | $this->paramInfoData->setParamId($input->paramId); |
41 | - $this->paramInfoData->setParamPath($paramFilePath); | ||
42 | 58 | ||
43 | return $this->paramInfoData; | 59 | return $this->paramInfoData; |
44 | } | 60 | } |
@@ -48,86 +64,14 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -48,86 +64,14 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
48 | */ | 64 | */ |
49 | public function getOutput($data) | 65 | public function getOutput($data) |
50 | { | 66 | { |
51 | - $result = array("success" => false, "message" => "Cannot load plot init"); | ||
52 | - | ||
53 | switch ($data->getType()) { | 67 | switch ($data->getType()) { |
54 | case ParamInfoTypeEnumClass::PLOTINIT : | 68 | case ParamInfoTypeEnumClass::PLOTINIT : |
55 | - if (($data->getResultNode() != NULL) && ($data->getResultNode()->getName() == "plot") && (count($data->getResultNode()->getChildren()) >= 1)) { | ||
56 | - $result_data = array(); | ||
57 | - | ||
58 | - $panelNode = $data->getResultNode()->getChildren()[0]; | ||
59 | - | ||
60 | - $plotNode = NULL; | ||
61 | - if (count($panelNode->getChildren()) >= 1) { | ||
62 | - foreach ($panelNode->getChildren() as $crtNode) { | ||
63 | - if (!in_array($crtNode->getName(), array('timePlot', 'epochPlot', 'xyPlot', 'instantPlot', 'statusPlot', 'tickPlot'))) | ||
64 | - continue; | ||
65 | - $plotNode = $crtNode; | ||
66 | - break; | ||
67 | - } | ||
68 | - | ||
69 | - if (isset($plotNode)) { | ||
70 | - $result_data['panel'] = array(); | ||
71 | - switch ($plotNode->getName()) { | ||
72 | - case 'timePlot' : | ||
73 | - $result_data['panel']['plotType'] = 'timePlot'; | ||
74 | - | ||
75 | - break; | ||
76 | - case 'epochPlot' : | ||
77 | - $result_data['panel']['plotType'] = 'epochPlot'; | ||
78 | - | ||
79 | - break; | ||
80 | - case 'xyPlot' : | ||
81 | - $result_data['panel']['plotType'] = 'xyPlot'; | ||
82 | - $result_data['panel']['isotropic'] = ($plotNode->getIsIsotropic() == "true"); | ||
83 | - $result_data['additionalObjects'] = $this->unmarshallAdditionalObjectsData($plotNode); | ||
84 | - break; | ||
85 | - case 'instantPlot' : | ||
86 | - $result_data['panel']['plotType'] = 'instantPlot'; | ||
87 | - | ||
88 | - break; | ||
89 | - case 'statusPlot' : | ||
90 | - $result_data['panel']['plotType'] = 'statusPlot'; | ||
91 | - | ||
92 | - break; | ||
93 | - case 'tickPlot' : | ||
94 | - $result_data['panel']['plotType'] = 'tickPlot'; | ||
95 | - | ||
96 | - break; | ||
97 | - } | ||
98 | - | ||
99 | - $result_data['draw'] = $this->unmarshallDrawData($plotNode, $data->getParamId()); | ||
100 | - } | ||
101 | - | ||
102 | - $result = array( | ||
103 | - "success" => true, | ||
104 | - "data" => $result_data | ||
105 | - ); | ||
106 | - //var_dump($result); | ||
107 | - } | ||
108 | - | ||
109 | - /*if (count($paramsNode->getChildren()) >= 1) { | ||
110 | - $paramNode = $paramsNode->getChildren()[0]; | ||
111 | - if (count($paramNode->getChildren()) >= 1) { | ||
112 | - $drawNode = $paramNode->getChildren()[0]; | ||
113 | - | ||
114 | - | ||
115 | - switch ($drawNode->getName()) { | ||
116 | - case 'serie' : | ||
117 | - $data['drawType'] = 'serie'; | ||
118 | - break; | ||
119 | - case 'orbitserie' : | ||
120 | - $data['drawType'] = 'orbit-serie'; | ||
121 | - break; | ||
122 | - } | ||
123 | - | ||
124 | - $result = array( | ||
125 | - "success" => true, | ||
126 | - "data" => $data | ||
127 | - ); | ||
128 | - } | ||
129 | - }*/ | ||
130 | - } | 69 | + $result = array("success" => false, "message" => "Cannot get plot init"); |
70 | + $this->getOutputPlotInit($data, $result); | ||
71 | + break; | ||
72 | + case ParamInfoTypeEnumClass::PARAMINFO : | ||
73 | + $result = array("success" => false, "message" => "Cannot get param info"); | ||
74 | + $this->getOutputParamInfo($data, $result); | ||
131 | break; | 75 | break; |
132 | default: | 76 | default: |
133 | //Nothing ToDo | 77 | //Nothing ToDo |
@@ -136,6 +80,94 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | @@ -136,6 +80,94 @@ class IHMInputOutputParamInfoClass implements InputOutputInterface | ||
136 | return $result; | 80 | return $result; |
137 | } | 81 | } |
138 | 82 | ||
83 | + private function getOutputParamInfo($data, &$result) { | ||
84 | + if (($data->getResult() != NULL)) { | ||
85 | + $result = array( | ||
86 | + "success" => true, | ||
87 | + "data" => $data->getResult() | ||
88 | + ); | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + private function getOutputPlotInit($data, &$result) { | ||
93 | + if (($data->getResult() != NULL) && ($data->getResult()->getName() == "plot") && (count($data->getResult()->getChildren()) >= 1)) { | ||
94 | + $result_data = array(); | ||
95 | + | ||
96 | + $panelNode = $data->getResult()->getChildren()[0]; | ||
97 | + | ||
98 | + $plotNode = NULL; | ||
99 | + if (count($panelNode->getChildren()) >= 1) { | ||
100 | + foreach ($panelNode->getChildren() as $crtNode) { | ||
101 | + if (!in_array($crtNode->getName(), array('timePlot', 'epochPlot', 'xyPlot', 'instantPlot', 'statusPlot', 'tickPlot'))) | ||
102 | + continue; | ||
103 | + $plotNode = $crtNode; | ||
104 | + break; | ||
105 | + } | ||
106 | + | ||
107 | + if (isset($plotNode)) { | ||
108 | + $result_data['panel'] = array(); | ||
109 | + switch ($plotNode->getName()) { | ||
110 | + case 'timePlot' : | ||
111 | + $result_data['panel']['plotType'] = 'timePlot'; | ||
112 | + | ||
113 | + break; | ||
114 | + case 'epochPlot' : | ||
115 | + $result_data['panel']['plotType'] = 'epochPlot'; | ||
116 | + | ||
117 | + break; | ||
118 | + case 'xyPlot' : | ||
119 | + $result_data['panel']['plotType'] = 'xyPlot'; | ||
120 | + $result_data['panel']['isotropic'] = ($plotNode->getIsIsotropic() == "true"); | ||
121 | + $result_data['additionalObjects'] = $this->unmarshallAdditionalObjectsData($plotNode); | ||
122 | + break; | ||
123 | + case 'instantPlot' : | ||
124 | + $result_data['panel']['plotType'] = 'instantPlot'; | ||
125 | + | ||
126 | + break; | ||
127 | + case 'statusPlot' : | ||
128 | + $result_data['panel']['plotType'] = 'statusPlot'; | ||
129 | + | ||
130 | + break; | ||
131 | + case 'tickPlot' : | ||
132 | + $result_data['panel']['plotType'] = 'tickPlot'; | ||
133 | + | ||
134 | + break; | ||
135 | + } | ||
136 | + | ||
137 | + $result_data['draw'] = $this->unmarshallDrawData($plotNode, $data->getParamId()); | ||
138 | + } | ||
139 | + | ||
140 | + $result = array( | ||
141 | + "success" => true, | ||
142 | + "data" => $result_data | ||
143 | + ); | ||
144 | + //var_dump($result); | ||
145 | + } | ||
146 | + | ||
147 | + /*if (count($paramsNode->getChildren()) >= 1) { | ||
148 | + $paramNode = $paramsNode->getChildren()[0]; | ||
149 | + if (count($paramNode->getChildren()) >= 1) { | ||
150 | + $drawNode = $paramNode->getChildren()[0]; | ||
151 | + | ||
152 | + | ||
153 | + switch ($drawNode->getName()) { | ||
154 | + case 'serie' : | ||
155 | + $data['drawType'] = 'serie'; | ||
156 | + break; | ||
157 | + case 'orbitserie' : | ||
158 | + $data['drawType'] = 'orbit-serie'; | ||
159 | + break; | ||
160 | + } | ||
161 | + | ||
162 | + $result = array( | ||
163 | + "success" => true, | ||
164 | + "data" => $data | ||
165 | + ); | ||
166 | + } | ||
167 | + }*/ | ||
168 | + } | ||
169 | + } | ||
170 | + | ||
139 | private function unmarshallDrawData($plotNode, $paramId) { | 171 | private function unmarshallDrawData($plotNode, $paramId) { |
140 | $result_data = array(); | 172 | $result_data = array(); |
141 | 173 |
src/Request/ParamInfoRequestClass.php
@@ -14,9 +14,11 @@ class ParamInfoRequestClass extends RequestAbstractClass | @@ -14,9 +14,11 @@ class ParamInfoRequestClass extends RequestAbstractClass | ||
14 | if (!isset($this->requestData)) | 14 | if (!isset($this->requestData)) |
15 | return false; | 15 | return false; |
16 | 16 | ||
17 | - //Force load of node files to init the NodeFactory | ||
18 | - foreach (glob(dirname(__FILE__)."/ParamsRequestImpl/Nodes/Requests/*NodeClass.php") as $filename) { | ||
19 | - require_once $filename; | 17 | + if ($this->requestData->getType() == ParamInfoTypeEnumClass::PLOTINIT) { |
18 | + //Force load of node files to init the NodeFactory | ||
19 | + foreach (glob(dirname(__FILE__)."/ParamsRequestImpl/Nodes/Requests/*NodeClass.php") as $filename) { | ||
20 | + require_once $filename; | ||
21 | + } | ||
20 | } | 22 | } |
21 | 23 | ||
22 | return TRUE; | 24 | return TRUE; |
@@ -30,15 +32,31 @@ class ParamInfoRequestClass extends RequestAbstractClass | @@ -30,15 +32,31 @@ class ParamInfoRequestClass extends RequestAbstractClass | ||
30 | $dom = new DOMDocument("1.0","UTF-8"); | 32 | $dom = new DOMDocument("1.0","UTF-8"); |
31 | $dom->preserveWhiteSpace = false; | 33 | $dom->preserveWhiteSpace = false; |
32 | $dom->formatOutput = true; | 34 | $dom->formatOutput = true; |
33 | - $res = $dom->load($this->requestData->getParamPath()); | ||
34 | 35 | ||
36 | + $res = $dom->load($this->requestData->getFilePath()); | ||
37 | + | ||
35 | $this->requestData->setSuccess(false); | 38 | $this->requestData->setSuccess(false); |
36 | - | 39 | + |
37 | if (!$res) { | 40 | if (!$res) { |
38 | - $this->requestData->setLastErrorMessage("Cannot load parameter file"); | 41 | + $this->requestData->setLastErrorMessage("Cannot load file"); |
39 | return false; | 42 | return false; |
40 | } | 43 | } |
41 | 44 | ||
45 | + switch ($this->requestData->getType()) { | ||
46 | + case ParamInfoTypeEnumClass::PLOTINIT : | ||
47 | + $this->runFromParamFile($dom); | ||
48 | + break; | ||
49 | + case ParamInfoTypeEnumClass::PARAMINFO : | ||
50 | + $this->runFromParamInfoFile($dom); | ||
51 | + break; | ||
52 | + default : | ||
53 | + $this->requestData->setLastErrorMessage("Unknown ParamInfo type"); | ||
54 | + } | ||
55 | + | ||
56 | + return $this->requestData->getSuccess(); | ||
57 | + } | ||
58 | + | ||
59 | + private function runFromParamFile($dom) { | ||
42 | $paramNode = new ParamNodeClass(); | 60 | $paramNode = new ParamNodeClass(); |
43 | 61 | ||
44 | try { | 62 | try { |
@@ -60,14 +78,72 @@ class ParamInfoRequestClass extends RequestAbstractClass | @@ -60,14 +78,72 @@ class ParamInfoRequestClass extends RequestAbstractClass | ||
60 | $this->requestData->setLastErrorMessage("Cannot parse plot node"); | 78 | $this->requestData->setLastErrorMessage("Cannot parse plot node"); |
61 | return false; | 79 | return false; |
62 | } | 80 | } |
63 | - $this->requestData->setResultNode($plotNode); | 81 | + $this->requestData->setResult($plotNode); |
64 | $this->requestData->setSuccess(true); | 82 | $this->requestData->setSuccess(true); |
65 | - break; | 83 | + return true; |
66 | default : | 84 | default : |
67 | $this->requestData->setLastErrorMessage("Unknown param info request"); | 85 | $this->requestData->setLastErrorMessage("Unknown param info request"); |
68 | } | 86 | } |
69 | 87 | ||
70 | - return $this->requestData->getSuccess(); | 88 | + return false; |
89 | + } | ||
90 | + | ||
91 | + private function runFromParamInfoFile($dom) { | ||
92 | + $result = array(); | ||
93 | + | ||
94 | + // Dimensions | ||
95 | + $dimsNodes = $dom->getElementsByTagName("dimensions"); | ||
96 | + if ($dimsNodes->length > 0) { | ||
97 | + $dimsNode = $dimsNodes->item(0); | ||
98 | + $result['dimensions'] = array( | ||
99 | + 'dim_1' => $dimsNode->getAttribute("dim_1"), | ||
100 | + 'dim_2' => $dimsNode->getAttribute("dim_2") | ||
101 | + ); | ||
102 | + } | ||
103 | + | ||
104 | + // Components | ||
105 | + $compNodes = $dom->getElementsByTagName("components"); | ||
106 | + if ($compNodes->length > 0) { | ||
107 | + $compNode = $compNodes->item(0); | ||
108 | + $result['components'] = array(); | ||
109 | + foreach ($compNode->getElementsByTagName("component") as $componentNode) { | ||
110 | + $result['components'][] = array( | ||
111 | + 'index_1' => $componentNode->getAttribute("index_1"), | ||
112 | + 'index_2' => $componentNode->getAttribute("index_2"), | ||
113 | + 'name' => $componentNode->getAttribute("name") | ||
114 | + ); | ||
115 | + } | ||
116 | + } | ||
117 | + | ||
118 | + // Tables | ||
119 | + $tablesNodes = $dom->getElementsByTagName("tables"); | ||
120 | + if ($tablesNodes->length > 0) { | ||
121 | + $tablesNode = $tablesNodes->item(0); | ||
122 | + $result['tables'] = array(); | ||
123 | + foreach ($tablesNode->getElementsByTagName("table") as $tableNode) { | ||
124 | + $tableResult = array( | ||
125 | + 'relatedDim' => $tableNode->getAttribute("relatedDim"), | ||
126 | + 'name' => $tableNode->getAttribute("name"), | ||
127 | + 'units' => $tableNode->getAttribute("units"), | ||
128 | + 'channels' => array() | ||
129 | + ); | ||
130 | + | ||
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 | + ); | ||
137 | + } | ||
138 | + | ||
139 | + $result['tables'][] = $tableResult; | ||
140 | + } | ||
141 | + } | ||
142 | + | ||
143 | + $this->requestData->setResult($result); | ||
144 | + $this->requestData->setSuccess(true); | ||
145 | + | ||
146 | + return true; | ||
71 | } | 147 | } |
72 | } | 148 | } |
73 | ?> | 149 | ?> |
74 | \ No newline at end of file | 150 | \ No newline at end of file |
src/Request/ParamInfoRequestDataClass.php
@@ -9,6 +9,7 @@ abstract class ParamInfoTypeEnumClass | @@ -9,6 +9,7 @@ abstract class ParamInfoTypeEnumClass | ||
9 | { | 9 | { |
10 | const UNKNOWN = ""; | 10 | const UNKNOWN = ""; |
11 | const PLOTINIT = "plot_init"; | 11 | const PLOTINIT = "plot_init"; |
12 | + const PARAMINFO = "param_info"; | ||
12 | } | 13 | } |
13 | 14 | ||
14 | /** | 15 | /** |
@@ -18,19 +19,19 @@ abstract class ParamInfoTypeEnumClass | @@ -18,19 +19,19 @@ abstract class ParamInfoTypeEnumClass | ||
18 | */ | 19 | */ |
19 | class ParamInfoRequestDataClass extends RequestDataClass | 20 | class ParamInfoRequestDataClass extends RequestDataClass |
20 | { | 21 | { |
21 | - private $paramPath = ""; | 22 | + private $filePath = ""; |
22 | private $paramId = ""; | 23 | private $paramId = ""; |
23 | private $type = ParamInfoTypeEnumClass::UNKNOWN; | 24 | private $type = ParamInfoTypeEnumClass::UNKNOWN; |
24 | - private $resultNode = NULL; | 25 | + private $result = NULL; |
25 | 26 | ||
26 | - public function getParamPath() | 27 | + public function getFilePath() |
27 | { | 28 | { |
28 | - return $this->paramPath; | 29 | + return $this->filePath; |
29 | } | 30 | } |
30 | 31 | ||
31 | - public function setParamPath($paramPath) | 32 | + public function setFilePath($filePath) |
32 | { | 33 | { |
33 | - $this->paramPath = $paramPath; | 34 | + $this->filePath = $filePath; |
34 | } | 35 | } |
35 | 36 | ||
36 | public function getType() | 37 | public function getType() |
@@ -43,14 +44,14 @@ class ParamInfoRequestDataClass extends RequestDataClass | @@ -43,14 +44,14 @@ class ParamInfoRequestDataClass extends RequestDataClass | ||
43 | $this->type = $type; | 44 | $this->type = $type; |
44 | } | 45 | } |
45 | 46 | ||
46 | - public function getResultNode() | 47 | + public function getResult() |
47 | { | 48 | { |
48 | - return $this->resultNode; | 49 | + return $this->result; |
49 | } | 50 | } |
50 | 51 | ||
51 | - public function setResultNode($resultNode) | 52 | + public function setResult($result) |
52 | { | 53 | { |
53 | - $this->resultNode = $resultNode; | 54 | + $this->result = $result; |
54 | } | 55 | } |
55 | 56 | ||
56 | public function getParamId() | 57 | public function getParamId() |