ParamTable.cc
6.95 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/**
* ParamTable.cc
*
* Created on: 10 oct. 2014
* Author: AKKA
*/
#include "ParamTable.hh"
#include "Parameter.hh"
using namespace log4cxx;
namespace AMDA {
namespace Info {
LoggerPtr ParamTable::_logger(Logger::getLogger("AMDA-Kernel.ParamTable"));
ParamTable::ParamTable(const char *paramId) : _paramId(paramId),
_tableName(""), _tableUnits("")
{
}
ParamTable::~ParamTable()
{
}
/*
* @brief Set name of the table
*/
void ParamTable::setName(std::string name)
{
_tableName = name;
}
/*
* @brief Get name of the table
*/
std::string ParamTable::getName(void)
{
return _tableName;
}
/*
* @brief Set units
*/
void ParamTable::setUnits(std::string units)
{
_tableUnits = units;
}
/*
* @brief Get units of the table
*/
std::string ParamTable::getUnits(void)
{
return _tableUnits;
}
ParamBoundsTable::ParamBoundsTable(const char *paramId, const char *boundsName) :
ParamTable(paramId), _boundsName(boundsName)
{
}
/*
* @brief Get size of the table
*/
int ParamBoundsTable::getSize(ParameterManager *parameterManager)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_boundsName];
return pTableInfo->size() - 1;
}
/*
* @brief Get a bounds for a specified index
*/
t_TableBound ParamBoundsTable::getBound(ParameterManager *parameterManager, unsigned int index)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
t_TableBound bound;
bound.index = index;
if (tmpParam == nullptr)
{
LOG4CXX_ERROR(_logger, "Associated parameter not reachable!");
bound.min = index;
bound.max = index+1;
return bound;
}
//get table info from parameter info list
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_boundsName];
if (index >= pTableInfo->size() - 1)
{
LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" );
bound.min = index;
bound.max = index+1;
return bound;
}
bound.min = std::min((*pTableInfo)[index], (*pTableInfo)[index+1]);
bound.max = std::max((*pTableInfo)[index], (*pTableInfo)[index+1]);
return bound;
}
ParamCenterTable::ParamCenterTable(const char *paramId, const char *centerName, double size) :
ParamTable(paramId), _centerName(centerName), _size(size)
{
}
/*
* @brief Get size of the table
*/
int ParamCenterTable::getSize(ParameterManager *parameterManager)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName];
return pTableInfo->size();
}
/*
* @brief Get a bound for a specified index
*/
t_TableBound ParamCenterTable::getBound(ParameterManager *parameterManager, unsigned int index)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
t_TableBound bound;
bound.index = index;
if (tmpParam == nullptr)
{
LOG4CXX_ERROR(_logger, "Associated parameter not reachable!");
bound.min = index;
bound.max = index+1;
return bound;
}
//get table info from parameter info list
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName];
if (index >= pTableInfo->size())
{
LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" );
bound.min = index;
bound.max = index+1;
return bound;
}
bound.min = (*pTableInfo)[index] - _size/2.;
bound.max = (*pTableInfo)[index] + _size/2.;;
return bound;
}
ParamCenterWidthTable::ParamCenterWidthTable(const char *paramId, const char *centerName, const char *widthName) :
ParamTable(paramId), _centerName(centerName), _widthName(widthName)
{
}
/*
* @brief Get size of the table
*/
int ParamCenterWidthTable::getSize(ParameterManager *parameterManager)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName];
return pTableInfo->size();
}
/*
* @brief Get a bound for a specified index
*/
t_TableBound ParamCenterWidthTable::getBound(ParameterManager *parameterManager, unsigned int index)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
t_TableBound bound;
bound.index = index;
if (tmpParam == nullptr)
{
LOG4CXX_ERROR(_logger, "Associated parameter not reachable!");
bound.min = index;
bound.max = index+1;
return bound;
}
//get table info from parameter info list
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName];
AMDA::Parameters::Parameter::InfoValuesSPtr pWidthInfo = lInfoList[_widthName];
if ((index >= pTableInfo->size()) || (index >= pWidthInfo->size()))
{
LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" );
bound.min = index;
bound.max = index+1;
return bound;
}
bound.min = (*pTableInfo)[index] - (*pWidthInfo)[index]/2.;
bound.max = (*pTableInfo)[index] + (*pWidthInfo)[index]/2.;;
return bound;
}
ParamMinMaxTable::ParamMinMaxTable(const char *paramId, const char *minName, const char *maxName) :
ParamTable(paramId), _minName(minName), _maxName(maxName)
{
}
/*
* @brief Get size of the table
*/
int ParamMinMaxTable::getSize(ParameterManager *parameterManager)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableMinInfo = lInfoList[_minName];
return pTableMinInfo->size();
}
/*
* @brief Get bound for a specified index
*/
t_TableBound ParamMinMaxTable::getBound(ParameterManager *parameterManager, unsigned int index)
{
ParameterSPtr tmpParam = parameterManager->getParameter(_paramId);
t_TableBound bound;
bound.index = index;
if (tmpParam == nullptr)
{
LOG4CXX_ERROR(_logger, "Associated parameter not reachable!");
bound.min = index;
bound.max = index+1;
return bound;
}
//get table info from parameter info list
AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList();
AMDA::Parameters::Parameter::InfoValuesSPtr pTableMinInfo = lInfoList[_minName];
AMDA::Parameters::Parameter::InfoValuesSPtr pTableMaxInfo = lInfoList[_maxName];
if ((index >= pTableMinInfo->size()) || (index >= pTableMaxInfo->size()))
{
LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" );
bound.min = index;
bound.max = index+1;
return bound;
}
bound.min = std::min((*pTableMinInfo)[index], (*pTableMaxInfo)[index]);
bound.max = std::max((*pTableMinInfo)[index], (*pTableMaxInfo)[index]);
return bound;
}
} /* namespace Info */
} /* namespace AMDA */