paramTemplateMgr = new IHMParamTemplateClass(); } /* * @brief translate input data from IHM client to AMDA_Integration module for a get param info request */ public function getInputData($input,$function,$requestId="") { $this->paramInfoData = new ParamInfoRequestDataClass(); switch ($input->type) { case 'plot_init' : $this->paramInfoData->setType(ParamInfoTypeEnumClass::PLOTINIT); if (!isset($input->paramId) || empty($input->paramId)) throw new Exception("Param info request need a param id as argument"); if ($this->paramTemplateMgr->isTemplatedParam($input->paramId)) //Use param template file $paramFilePath = $this->paramTemplateMgr->getTemplatePath($input->paramId); else $paramFilePath = IHMConfigClass::getLocalParamDBPath().$input->paramId.".xml"; if (!file_exists("$paramFilePath")) throw new Exception("Cannot find parameter definition file"); $this->paramInfoData->setFilePath($paramFilePath); break; case 'impex_plot_init' : $this->paramInfoData->setType(ParamInfoTypeEnumClass::IMPEXPLOTINIT); if (!isset($input->paramId) || empty($input->paramId)) throw new Exception("Param info request need a param id as argument"); if (!$this->paramImpexMgr) { $this->paramImpexMgr = new IHMImpexParamClass(); } $paramFilePath = $this->paramImpexMgr->getParamInfoPlotPath($input->paramId); if (!$paramFilePath || !file_exists($paramFilePath)) throw new Exception("Cannot find parameter definition file"); $this->paramInfoData->setFilePath($paramFilePath); break; case 'param_info' : $this->paramInfoData->setType(ParamInfoTypeEnumClass::PARAMINFO); if (!isset($input->paramId) || empty($input->paramId)) throw new Exception("Param info request need a param id as argument"); $templatedParams = $this->paramTemplateMgr->getParamTemplates(); if (array_key_exists($input->paramId, $templatedParams)) $this->paramInfoData->setTemplateInfo($templatedParams[$input->paramId]); $paramInfoFilePath = IHMConfigClass::getLocalParamInfoPath().'info_'.$input->paramId.".xml"; if (!file_exists($paramInfoFilePath)) throw new Exception("Cannot find parameter info file"); $this->paramInfoData->setFilePath($paramInfoFilePath); break; case 'impex_param_info' : $this->paramInfoData->setType(ParamInfoTypeEnumClass::IMPEXINFO); if (!isset($input->paramId) || empty($input->paramId)) throw new Exception("Param info request need a param id as argument"); if (!$this->paramImpexMgr) { $this->paramImpexMgr = new IHMImpexParamClass(); } $this->paramImpexMgr->setParamTemplateListFilePath($input->paramId); $templatedParams = $this->paramImpexMgr->getParamTemplates(); $simRegion = $this->paramImpexMgr->getSimulationRegion($input->paramId); // No SimulationRuns (LESIA) if ($simRegion == "UNKNOWN") $simRegion = $this->paramImpexMgr->getResourceID($input->paramId); $this->paramInfoData->setTemplateInfo($templatedParams[$simRegion]); break; default : throw new Exception("Param info request type '".$input->type."' not yet implemented"); } $this->paramInfoData->setParamId($input->paramId); return $this->paramInfoData; } /* * @brief translate output data from AMDA_Integration module to IHM client for a get param info request */ public function getOutput($data) { switch ($data->getType()) { case ParamInfoTypeEnumClass::PLOTINIT : $result = array("success" => false, "message" => "Cannot get plot init"); $this->getOutputPlotInit($data, $result); break; case ParamInfoTypeEnumClass::IMPEXPLOTINIT : $result = array("success" => false, "message" => "Cannot get impex plot init"); $this->getOutputPlotInit($data, $result); break; case ParamInfoTypeEnumClass::PARAMINFO : $result = array("success" => false, "message" => "Cannot get param info"); $this->getOutputParamInfo($data, $result); break; case ParamInfoTypeEnumClass::IMPEXINFO : $result = array("success" => false, "message" => "Cannot get impex param info"); $this->getOutputParamInfo($data, $result); break; default: //Nothing ToDo } return $result; } private function getOutputParamInfo($data, &$result) { if (($data->getResult() != NULL)) { $result = array( "success" => true, "data" => $data->getResult() ); if ($data->getTemplateInfo() != NULL) { $result["template"] = $data->getTemplateInfo(); } } } private function getOutputPlotInit($data, &$result) { if (($data->getResult() != NULL) && ($data->getResult()->getName() == "plot") && (count($data->getResult()->getChildren()) >= 1)) { $result_data = array(); $panelNodes = $data->getResult()->getChildren(); $panelNode = $panelNodes[0]; $plotNode = NULL; if (count($panelNode->getChildren()) >= 1) { foreach ($panelNode->getChildren() as $crtNode) { if (!in_array($crtNode->getName(), array('timePlot', 'epochPlot', 'xyPlot', 'instantPlot', 'statusPlot', 'tickPlot'))) continue; $plotNode = $crtNode; break; } if (isset($plotNode)) { $result_data['panel'] = array(); switch ($plotNode->getName()) { case 'timePlot' : $result_data['panel']['plotType'] = 'timePlot'; break; case 'epochPlot' : $result_data['panel']['plotType'] = 'epochPlot'; break; case 'xyPlot' : $result_data['panel']['plotType'] = 'xyPlot'; $result_data['panel']['isotropic'] = ($plotNode->getIsIsotropic() == "true"); $result_data['additionalObjects'] = $this->unmarshallAdditionalObjectsData($plotNode); break; case 'instantPlot' : $result_data['panel']['plotType'] = 'instantPlot'; break; case 'statusPlot' : $result_data['panel']['plotType'] = 'statusPlot'; break; case 'tickPlot' : $result_data['panel']['plotType'] = 'tickPlot'; break; } $result_data['draw'] = $this->unmarshallDrawData($plotNode, $data->getParamId()); } $result = array( "success" => true, "data" => $result_data ); //var_dump($result); } /*if (count($paramsNode->getChildren()) >= 1) { $paramNode = $paramsNode->getChildren()[0]; if (count($paramNode->getChildren()) >= 1) { $drawNode = $paramNode->getChildren()[0]; switch ($drawNode->getName()) { case 'serie' : $data['drawType'] = 'serie'; break; case 'orbitserie' : $data['drawType'] = 'orbit-serie'; break; } $result = array( "success" => true, "data" => $data ); } }*/ } } private function unmarshallDrawData($plotNode, $paramId) { $result_data = array(); if (!isset($plotNode)) return $result_data; $paramsNode = $plotNode->getParams(); if (!isset($paramsNode)) return $result_data; if ($this->paramTemplateMgr->isTemplatedParam($paramId)) //Use templated parameter $realParamId = $this->paramTemplateMgr->getTemplateFileName($paramId); else $realParamId = $paramId; $paramNode = $paramsNode->getParamById($realParamId); if (!isset($paramNode) || (count($paramNode->getChildren()) < 1)) return $result_data; $mainDrawNode = NULL; $otherDrawNodes = array(); foreach ($paramNode->getChildren() as $crtDrawNode) { if (in_array($crtDrawNode->getName(), array('serie', 'spectro', 'yserie', 'orbitserie'))) $mainDrawNode = $crtDrawNode; else $otherDrawNodes[$mainDrawNode->getName()] = $crtDrawNode; } if (!isset($mainDrawNode)) return $result_data; switch ($mainDrawNode->getName()) { case 'serie' : if ($plotNode->getName() == 'statusPlot') { $result_data['type'] = 'status-bar'; } else { $result_data['type'] = 'serie'; $this->unmarshallBaseSerieData($mainDrawNode, $result_data); } //if (array_key_exists('colorserie', $otherDrawNodes)) // $this->unmarshallColorSerieData($mainDrawNode, $result_data); break; case 'spectro' : $result_data['type'] = 'spectro'; $this->unmarshallSpectroData($mainDrawNode, $result_data); break; case 'yserie' : if (!array_key_exists('xserie', $otherDrawNodes)) return $result_data; $this->unmarshallBaseSerieData($mainDrawNode, $result_data); //$this->unmarshallXSerieData($mainDrawNode, $result_data); //if (array_key_exists('colorserie', $otherDrawNodes)) // $this->unmarshallColorSerieData($mainDrawNode, $result_data); break; case 'orbitserie' : $result_data['type'] = 'orbit-serie'; $result_data['serie-projection'] = $mainDrawNode->getProjection(); $this->unmarshallBaseSerieData($mainDrawNode, $result_data); //if (array_key_exists('colorserie', $otherDrawNodes)) // $this->unmarshallColorSerieData($mainDrawNode, $result_data); break; default : return $result_data; } $axesNode = $plotNode->getAxes(); if (isset($axesNode)) { $result_data['axes'] = array(); $colorAxis = $axesNode->getColorAxis(); if (isset($colorAxis)) { $result_data['axes']['color'] = array(); $this->unmarshallAxisData($colorAxis, $result_data['axes']['color']); } $xAxis = $axesNode->getDigitalAxis(RequestOutputPlotAxisTypeEnum::XAXIS, 'xaxis_id'); if (isset($xAxis)) { $result_data['axes']['xaxis_id'] = array(); $this->unmarshallAxisData($xAxis, $result_data['axes']['xaxis_id']); } $yLeftAxis = $axesNode->getDigitalAxis(RequestOutputPlotAxisTypeEnum::YAXIS, 'y-left'); if (isset($yLeftAxis)) { $result_data['axes']['y-left'] = array(); $this->unmarshallAxisData($yLeftAxis, $result_data['axes']['y-left']); } $yRightAxis = $axesNode->getDigitalAxis(RequestOutputPlotAxisTypeEnum::YAXIS, 'y-right'); if (isset($yRightAxis)) { $result_data['axes']['y-right'] = array(); $this->unmarshallAxisData($yRightAxis, $result_data['axes']['y-right']); } } return $result_data; } private function unmarshallAxisData($axisNode, &$result_array) { if (!isset($axisNode)) return; $scale = $axisNode->getScale(); if (isset($scale)) $result_array['axis-scale'] = $scale; $rangeNode = $axisNode->getRange(); if (isset($rangeNode)) { $rangeMin = $rangeNode->getMin(); if (isset($rangeMin)) $result_array['axis-range-min'] = $rangeMin; $rangeMax = $rangeNode->getMax(); if (isset($rangeMax)) $result_array['axis-range-max'] = $rangeMax; } } private function unmarshallSpectroData($drawNode, &$result_array) { if (!isset($drawNode)) return; $yAxis = $drawNode->getAttribute(REQUESTOUTPUTPLOTSPECTRO_YAXIS); if (!empty($yAxis)) $result_array['spectro-yaxis'] = $yAxis; $min = $drawNode->getAttribute(REQUESTOUTPUTPLOTSPECTRO_MIN); if (!empty($min)) $result_array['spectro-value-min'] = $min; $max = $drawNode->getAttribute(REQUESTOUTPUTPLOTSPECTRO_MAX); if (!empty($max)) $result_array['spectro-value-max'] = $max; } private function unmarshallAdditionalObjectsData($plotNode) { $result_data = array(); if (!isset($plotNode)) return $result_data; $additionalObjectsNode = $plotNode->getAdditionalObjects(); //curvePlot $result_data['curves'] = array(); $curveObjectsNode = $additionalObjectsNode->getCurveObjects(); foreach ($curveObjectsNode as $curveNode) { $crt_curve_data = array(); $crt_curve_data['curve-serie-id'] = $curveNode->getSerieId(); $this->unmarshallLineData($curveNode, "curve-line-", $crt_curve_data); if ($curveNode->isFunctionDefined()) { $crt_curve_data['curve-name'] = $curveNode->getFunction()->getFunctionName(); $crt_curve_data['curve-attributes'] = array(); foreach ($curveNode->getFunction()->getAttributes()->getChildren() as $attributeNode) { $crt_attribute_data = array(); $crt_attribute_data['curve-param-name'] = $attributeNode->getAttribute(REQUESTOUTPUTPLOTCURVEOBJECTFUNCTION_ATTRIBUTENAME); $crt_attribute_data['curve-param-value'] = $attributeNode->getAttribute(REQUESTOUTPUTPLOTCURVEOBJECTFUNCTION_ATTRIBUTEVALUE); $crt_curve_data['curve-attributes'][] = $crt_attribute_data; } } $result_data['curves'][] = $crt_curve_data; } return $result_data; } private function unmarshallBaseSerieData($drawNode, &$result_array) { if (!isset($drawNode)) return; $result_array['serie-id'] = $drawNode->getId(); $result_array['serie-yaxis'] = $drawNode->getYAxisId(); if ($drawNode->isLineDefined()) { $result_array['serie-lines-activated'] = true; $this->unmarshallLineData($drawNode->getLine(), "serie-lines-", $result_array); } if ($drawNode->isSymbolDefined()) { $result_array['serie-symbols-activated'] = true; $this->unmarshallSymbolData($drawNode->getSymbol(), "serie-symbols-", $result_array); } $colorSerieId = $drawNode->getColorSerieId(); if (!empty($colorSerieId)) { //ToDo } if ($drawNode->isTimeTicksDefined()) { $result_array['serie-timetick-activated'] = true; $result_array['serie-timetick-step'] = $drawNode->getTimeTicks()->getStep(); $result_array['serie-timetick-nbmajor'] = $drawNode->getTimeTicks()->getNumber(); $result_array['serie-timetick-nbminor'] = $drawNode->getTimeTicks()->getMinor(); $result_array['serie-timetick-color'] = $this->toHexColor($drawNode->getTimeTicks()->getColor()); if (!empty($result_array['serie-timetick-nbmajor']) && intval($result_array['serie-timetick-nbmajor']) > 0) $result_array['serie-timetick-type'] = 'nb-major'; else if (!empty($result_array['serie-timetick-step']) && intval($result_array['serie-timetick-step']) > 0) $result_array['serie-timetick-type'] = 'time-step'; else $result_array['serie-timetick-type'] = 'auto'; if ($drawNode->getTimeTicks()->isSymbolDefined()) { $this->unmarshallSymbolData($drawNode->getTimeTicks()->getSymbol(), "serie-timetick-symbols-", $result_array); } if ($drawNode->getTimeTicks()->isFirstSymbolDefined()) { $result_array['serie-timetick-firstsymbols-activated'] = true; $this->unmarshallSymbolData($drawNode->getTimeTicks()->getFirstSymbol(), "serie-timetick-firstsymbols-", $result_array); } if ($drawNode->getTimeTicks()->isFontDefined()) { $result_array['serie-timetick-font-activated'] = true; $this->unmarshallFontData($drawNode->getTimeTicks()->getFont(), "serie-timetick-font-", $result_array); } } if ($drawNode->isIntervalTicksDefined()) { $result_array['serie-intervaltick-activated'] = true; $result_array['serie-intervaltick-mode'] = $drawNode->getIntervalTicks()->getMode(); $result_array['serie-intervaltick-color'] = $this->toHexColor($drawNode->getIntervalTicks()->getColor()); if ($drawNode->getIntervalTicks()->isSymbolDefined()) { $this->unmarshallSymbolData($drawNode->getIntervalTicks()->getSymbol(), "serie-intervaltick-", $result_array); } if ($drawNode->getIntervalTicks()->isFontDefined()) { $result_array['serie-intervaltick-font-activated'] = true; $this->unmarshallFontData($drawNode->getIntervalTicks()->getFont(), "serie-intervaltick-font-", $result_array); } } } private function unmarshallLineData($lineNode, $prefix, &$result_array) { $result_array[$prefix.'style'] = $lineNode->getStyle(); $result_array[$prefix.'width'] = $lineNode->getWidth(); $result_array[$prefix.'color'] = $this->toHexColor($lineNode->getColor()); } private function unmarshallSymbolData($symbolNode, $prefix, &$result_array) { $result_array[$prefix.'type'] = $symbolNode->getType(); $result_array[$prefix.'size'] = $symbolNode->getSize(); $result_array[$prefix.'color'] = $this->toHexColor($symbolNode->getColor()); } private function unmarshallFontData($fontNode, $prefix, &$result_array) { $result_array[$prefix.'name'] = $fontNode->getFontName(); $result_array[$prefix.'size'] = $fontNode->getSize(); $result_array[$prefix.'bold'] = ($fontNode->getWeight() == RequestOutputPlotFontWeight::BOLD); $result_array[$prefix.'italic'] = ($fontNode->getStyle() == RequestOutputPlotFontStyle::ITALIC); } private function toHexColor($color) { $temp = str_replace(array('[', ']', ' '), '', $color); $arr = explode(',', $temp); if (count ($arr) != 3) return '#000000'; return '#'.sprintf('%02x', $arr[0]).sprintf('%02x', $arr[1]).sprintf('%02x', $arr[2]); } } ?>