GetSpeasyProxyNode.cc
4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
* GetSpeasyProxyNode.cc
*
* Created on: April 25, 2024
* Author: AKKODIS - Furkan
*/
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include "ServicesServer.hh"
#include "Parameter.hh"
#include "FileConfigurator.hh"
#include "ParamGet.hh"
#include "ParamGetSpeasyProxy.hh"
#include "ParameterManager.hh"
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
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<ServicesServer*>();
Parameter* lParentParameter = pContext.get<Parameter*>();
ParameterManager* lParameterManager = pContext.get<ParameterManager*>();
// 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<AMDA::SpeasyProxyInterface::ParamGetSpeasyProxy*>(lServicesServer->getParamGet( lSouceParamGet, *lParameter)));
DataWriterSPtr lDataWriter( lParamGet);
std::string* xmlFileName = pContext.get<std::string*>();
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<int>(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<int>(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<AMDA::SpeasyProxyInterface::ParamGetSpeasyProxy*>(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 */