/* * GetSpeasyProxyNode.cc * * Created on: April 25, 2024 * Author: AKKODIS - Furkan */ #include #include #include "ServicesServer.hh" #include "Parameter.hh" #include "FileConfigurator.hh" #include "ParamGet.hh" #include "ParamGetSpeasyProxy.hh" #include "ParameterManager.hh" #include #include using namespace AMDA::Parameters; #include "Constant.hh" #include "Config.hh" #include "GetSpeasyProxyNode.hh" using namespace AMDA::XMLConfigurator; namespace AMDA { namespace XMLParameterConfigurator { class SpeasyProxyParamNode: public AMDA::XMLConfigurator::NodeGrpCfg { public: SpeasyProxyParamNode() : AMDA::XMLConfigurator::NodeGrpCfg() {} void proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "SpeasyProxyParamNode::proceed: '" << pNode->name << "' node") // Context setting ServicesServer* lServicesServer = pContext.get(); Parameter* lParentParameter = pContext.get(); ParameterManager* lParameterManager = pContext.get(); // Attributes list try { xmlChar* lParamId = xmlGetProp(pNode, (const xmlChar*)"speasyUID"); std::string paramIdStr; if (lParamId) { paramIdStr = std::string((const char*) lParamId); xmlFree(lParamId); } else { ERROR_EXCEPTION(ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@speasyUID") } //build unique param id std::string paramId = "speasy_proxy_"; paramId += paramIdStr; lParameterManager->applyParamIdCorrection(paramId); ParameterSPtr lParameter; if ( lParameterManager->addParameter(lParentParameter,paramId,lParameter)) { const char *lSouceParamGet = "SPEASY_PROXY"; AMDA::SpeasyProxyInterface::ParamGetSpeasyProxySPtr lParamGet(dynamic_cast(lServicesServer->getParamGet( lSouceParamGet, *lParameter))); DataWriterSPtr lDataWriter( lParamGet); std::string* xmlFileName = pContext.get(); lDataWriter->setSignatureTrigger(*xmlFileName); lParamGet->setParamId(paramIdStr.c_str()); lParameter->setDataWriter(lDataWriter); //type xmlChar* value = NULL; if ((value = xmlGetProp(pNode, (const xmlChar*)"type")) != NULL) { if (strcmp((const char*)value,"float") == 0) lParamGet->setType(AMDA::SpeasyProxyInterface::SpeasyProxyParamType::TYPE_FLOAT); else if (strcmp((const char*)value,"double") == 0) lParamGet->setType(AMDA::SpeasyProxyInterface::SpeasyProxyParamType::TYPE_DOUBLE); else if (strcmp((const char*)value,"short") == 0) lParamGet->setType(AMDA::SpeasyProxyInterface::SpeasyProxyParamType::TYPE_SHORT); else if ((strcmp((const char*)value,"int") == 0) || (strcmp((const char*)value,"integer") == 0)) lParamGet->setType(AMDA::SpeasyProxyInterface::SpeasyProxyParamType::TYPE_INT); else { LOG4CXX_ERROR(gLogger, "SpeasyProxyParamNode::proceed - Unknown data type " << ((const char*)value)) } xmlFree(value); } //dim1 if ((value = xmlGetProp(pNode, (const xmlChar*)"dim1")) != NULL) { std::string dim1Str = std::string((const char*) value); boost::trim(dim1Str); int dim1 = boost::lexical_cast(dim1Str); if(dim1 >= 0 && dim1 <= 3) lParamGet->setDim1(dim1); else lParamGet->setDim1(1); xmlFree(value); } //dim2 if ((value = xmlGetProp(pNode, (const xmlChar*)"dim2")) != NULL) { std::string dim2Str = std::string((const char*) value); boost::trim(dim2Str); int dim2 = boost::lexical_cast(dim2Str); if(dim2 >= 0 && dim2 <= 3) lParamGet->setDim2(dim2); else lParamGet->setDim2(1); xmlFree(value); } //minSampling if ((value = xmlGetProp(pNode, (const xmlChar*)"minSampling")) != NULL) { lParamGet->setMinSampling(atof((const char*)value)); xmlFree(value); } AMDA::Parameters::CfgContext lContext(pContext); lContext.push(lParamGet.get()); NodeGrpCfg::proceed(pNode, lContext); } } catch (...) { throw; } } }; GetSpeasyProxyNode::GetSpeasyProxyNode() : NodeGrpCfg() { getChildList()["param"] = NodeCfgSPtr(new XMLParameterConfigurator::SpeasyProxyParamNode()); } void GetSpeasyProxyNode::proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "GetSpeasyProxyNode::proceed") AMDA::Parameters::CfgContext lContext(pContext); NodeGrpCfg::proceed(pNode, lContext); } }/* namespace XMLParameterConfigurator */ } /* namespace AMDA */