GetDDBaseNode.cc
4.32 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
155
156
157
158
159
/*
* GetDDBaseNode.cc
*
* Created on: Oct 31, 2012
* Author: f.casimir
*/
//#include <boost/scope_exit.hpp>
//#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<ParamGetDDBase*>();
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) {
LOG4CXX_DEBUG(gLogger, "NodeGetDDBase::proceed: '" << pNode->name << "' node")
// Context setting
ServicesServer* lServicesServer = pContext.get<ServicesServer*>();
Parameter* lParentParameter = pContext.get<Parameter*>();
ParameterManager* lParameterManager = pContext.get<ParameterManager*>();
xmlChar*lVIName = pContext.get<xmlChar*>();
// Attributes list
try {
xmlChar* lParamName = xmlGetProp(pNode, (const xmlChar *) PARAMNAME);
std::string paramNameStr;
if (lParamName) {
paramNameStr = std::string((const char*) lParamName);
xmlFree(lParamName);
}
else {
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 += paramNameStr;
lParameterManager->applyParamIdCorrection(paramId);
ParameterSPtr lParameter;
if ( lParameterManager->addParameter(lParentParameter,paramId,lParameter)) {
const char *lSouceParamGet = "DDBASE";
ParamGetDDBaseSPtr lParamGet(dynamic_cast<ParamGetDDBase*>(lServicesServer->getParamGet( lSouceParamGet, *lParameter)));
DataWriterSPtr lDataWriter( lParamGet);
std::string* xmlFileName = pContext.get<std::string*>();
lDataWriter->setSignatureTrigger(*xmlFileName);
lParamGet->setParName(paramNameStr.c_str());
lParameter->setDataWriter(lDataWriter);
lParamGet->setViName((const char*) lVIName);
AMDA::Parameters::CfgContext lContext(pContext);
lContext.push<ParamGetDDBase*>(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 (...) {
throw;
}
}
};
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<xmlChar*>(lVIName);
NodeGrpCfg::proceed(pNode, lContext);
} catch (...) {
if (lVIName) {
xmlFree(lVIName);
}
throw;
}
if (lVIName) {
xmlFree(lVIName);
}
}
}/* namespace XMLParameterConfigurator */
} /* namespace AMDA */