/* * GetDDBaseNode.cc * * Created on: Oct 31, 2012 * Author: f.casimir */ //#include //#include "ScopeExit.hh" #include "ServicesServer.hh" #include "Parameter.hh" #include "FileConfigurator.hh" #include "ParamGet.hh" //#include "ProcessNode.hh" #include "ParamGetDDBase.hh" #include "ParameterManager.hh" using namespace AMDA::Parameters; #include "Constant.hh" #include "Config.hh" #include "GetDDBaseNode.hh" using namespace AMDA::XMLConfigurator; namespace AMDA { namespace XMLParameterConfigurator { class DDCalibrationNode: public AMDA::XMLConfigurator::NodeCfg { public: /** * @brief read Calibration info name vi/baseParam/clb@name. */ void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& context) { LOG4CXX_DEBUG(gLogger, "CalibrationNode::proceed") ParamGetDDBase* lParamGet = context.get(); xmlChar* lParamName = NULL; try { if ((lParamName = xmlGetProp(pNode, (const xmlChar *) "name"))) { lParamGet->createInfoRequest((const char*) lParamName); } else { ERROR_EXCEPTION( ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@" << "name") } } catch (...) { if (lParamName) { xmlFree(lParamName); } throw; } if (lParamName) { xmlFree(lParamName); } } }; class BaseParamNode: public AMDA::XMLConfigurator::NodeGrpCfg { public: BaseParamNode() : AMDA::XMLConfigurator::NodeGrpCfg() { getChildList()["clb"]=NodeCfgSPtr(new DDCalibrationNode()); } /** * @brief read Parameter name vi/baseParam@name and child. */ void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { const char *lSouceParamGet = "DDBASE"; LOG4CXX_DEBUG(gLogger, "NodeGetDDBase::proceed: '" << pNode->name << "' node") // Context setting ServicesServer* lServicesServer = pContext.get(); Parameter* lParentParameter = pContext.get(); ParameterManager* lParameterManager = pContext.get(); xmlChar*lVIName = pContext.get(); // Attributes list xmlChar* lParamName = NULL; try { if (!(lParamName = xmlGetProp(pNode, (const xmlChar *) PARAMNAME))) { ERROR_EXCEPTION(ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@" << PARAMNAME) } //build unique param id std::string paramId = std::string((const char*) lVIName); std::replace( paramId.begin(), paramId.end(), ':', '_'); paramId += "_"; paramId += std::string((const char*) lParamName); lParameterManager->applyParamIdCorrection(paramId); ParameterSPtr lParameter; if ( lParameterManager->addParameter(lParentParameter,paramId,lParameter)) { ParamGetDDBaseSPtr lParamGet(dynamic_cast(lServicesServer->getParamGet( lSouceParamGet, *lParameter))); DataWriterSPtr lDataWriter( lParamGet); std::string* xmlFileName = pContext.get(); lDataWriter->setSignatureTrigger(*xmlFileName); lParamGet->setParName((const char*) lParamName); lParameter->setDataWriter(lDataWriter); lParamGet->setViName((const char*) lVIName); AMDA::Parameters::CfgContext lContext(pContext); lContext.push(lParamGet.get()); // useNearestValue xmlChar* lUseNearestValue = xmlGetProp(pNode, (const xmlChar *) "useNearestValue"); if (lUseNearestValue != NULL) { lParamGet->setUseNearestValue(strcmp((const char*)lUseNearestValue,"true") == 0); xmlFree(lUseNearestValue); } NodeGrpCfg::proceed(pNode, lContext); } } catch (...) { if (lParamName) { xmlFree(lParamName); } throw; } if (lParamName) { xmlFree(lParamName); } } }; GetDDBaseNode::GetDDBaseNode() : NodeGrpCfg() { getChildList()["baseParam"]=NodeCfgSPtr(new XMLParameterConfigurator::BaseParamNode()); } void GetDDBaseNode::proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "ViNode::proceed") xmlChar* lVIName = NULL; try { if (!(lVIName = xmlGetProp(pNode, (const xmlChar *) "name"))) { ERROR_EXCEPTION(ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@" << "name") } AMDA::Parameters::CfgContext lContext(pContext); lContext.push(lVIName); NodeGrpCfg::proceed(pNode, lContext); } catch (...) { if (lVIName) { xmlFree(lVIName); } throw; } if (lVIName) { xmlFree(lVIName); } } }/* namespace XMLParameterConfigurator */ } /* namespace AMDA */