Commit 0dfc4085ed22088fb6ae752f128274eef02c9b6b
1 parent
69a54fc2
Exists in
master
and in
98 other branches
Give the possibility to define max dim. sizes for a DDServer parameter (5798)
Showing
7 changed files
with
87 additions
and
35 deletions
Show diff stats
config/xsd/parameter/getddbase.xsd
... | ... | @@ -16,6 +16,9 @@ |
16 | 16 | </xs:sequence> |
17 | 17 | <xs:attribute name="name" type="xs:string" use="required" /> |
18 | 18 | <xs:attribute name="useNearestValue" type="xs:boolean" /> |
19 | + <xs:attribute name="maxDim1Size" type="xs:int" /> | |
20 | + <xs:attribute name="maxDim2Size" type="xs:int" /> | |
21 | + <xs:attribute name="maxDim3Size" type="xs:int" /> | |
19 | 22 | <xs:attribute name="dim3Num" type="xs:int" /> |
20 | 23 | <xs:attribute name="dim3CutIndex" type="xs:int" /> |
21 | 24 | </xs:complexType> | ... | ... |
src/ParamGetImpl/DDServerInterface/GetDDBaseNode.cc
... | ... | @@ -118,6 +118,30 @@ public: |
118 | 118 | xmlFree(lUseNearestValue); |
119 | 119 | } |
120 | 120 | |
121 | + // maxDim1Size | |
122 | + xmlChar* lmaxDim1Size = xmlGetProp(pNode, (const xmlChar *) "maxDim1Size"); | |
123 | + if (lmaxDim1Size != NULL) | |
124 | + { | |
125 | + lParamGet->setMaxDim1Size(atoi((const char*)lmaxDim1Size)); | |
126 | + xmlFree(lmaxDim1Size); | |
127 | + } | |
128 | + | |
129 | + // maxDim2Size | |
130 | + xmlChar* lmaxDim2Size = xmlGetProp(pNode, (const xmlChar *) "maxDim2Size"); | |
131 | + if (lmaxDim2Size != NULL) | |
132 | + { | |
133 | + lParamGet->setMaxDim2Size(atoi((const char*)lmaxDim2Size)); | |
134 | + xmlFree(lmaxDim2Size); | |
135 | + } | |
136 | + | |
137 | + // maxDim3Size | |
138 | + xmlChar* lmaxDim3Size = xmlGetProp(pNode, (const xmlChar *) "maxDim3Size"); | |
139 | + if (lmaxDim3Size != NULL) | |
140 | + { | |
141 | + lParamGet->setMaxDim3Size(atoi((const char*)lmaxDim3Size)); | |
142 | + xmlFree(lmaxDim3Size); | |
143 | + } | |
144 | + | |
121 | 145 | // dim3Num |
122 | 146 | xmlChar* lDim3NumValue = xmlGetProp(pNode, (const xmlChar *) "dim3Num"); |
123 | 147 | if (lDim3NumValue != NULL) | ... | ... |
src/ParamGetImpl/DDServerInterface/ParamGetDDBase.cc
... | ... | @@ -35,11 +35,12 @@ namespace AMDA { |
35 | 35 | namespace Parameters { |
36 | 36 | |
37 | 37 | ParamGetDDBase::ParamGetDDBase(Parameter ¶meter) : |
38 | - ParamGet_CRTP<ParamGetDDBase>(parameter), _parName(""), _viName(""), _dim3Num(-1), _dim3CutIndex(-1), _pusher(NULL), _timeStamp(0) { | |
38 | + ParamGet_CRTP<ParamGetDDBase>(parameter), _parName(""), _viName(""), _maxDim1Size(-1), _maxDim2Size(-1), _maxDim3Size(-1), _dim3Num(-1), _dim3CutIndex(-1), _pusher(NULL), _timeStamp(0) { | |
39 | 39 | } |
40 | 40 | |
41 | 41 | ParamGetDDBase::ParamGetDDBase(const ParamGetDDBase &pParamGetDDBase, Parameter ¶meter) : |
42 | 42 | ParamGet_CRTP<ParamGetDDBase>(pParamGetDDBase, parameter), _parName(pParamGetDDBase._parName), _viName(pParamGetDDBase._viName) |
43 | + , _maxDim1Size(pParamGetDDBase._maxDim1Size), _maxDim2Size(pParamGetDDBase._maxDim2Size), _maxDim3Size(pParamGetDDBase._maxDim3Size) | |
43 | 44 | , _dim3Num(pParamGetDDBase._dim3Num), _dim3CutIndex(pParamGetDDBase._dim3CutIndex) |
44 | 45 | , _pusher(pParamGetDDBase._pusher), _infoRequestList(pParamGetDDBase._infoRequestList), _timeStamp(pParamGetDDBase._timeStamp) { |
45 | 46 | } |
... | ... | @@ -53,7 +54,7 @@ namespace AMDA { |
53 | 54 | /// Create ParamData |
54 | 55 | _vi = VirtualInstrumentManager::getInstance()->getVirtualInstrument( |
55 | 56 | _viName); |
56 | - _pusher = _vi->getParamPusher(_parName, _dim3Num, _dim3CutIndex); | |
57 | + _pusher = _vi->getParamPusher(_parName, _maxDim1Size, _maxDim2Size, _maxDim3Size, _dim3Num, _dim3CutIndex); | |
57 | 58 | //Param info |
58 | 59 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(_parameter.getInfoId(),true); |
59 | 60 | if ((paramInfo != nullptr) && (isnan(_pusher->getFillValue())) && (!isnan(paramInfo->getFillValue()))) | ... | ... |
src/ParamGetImpl/DDServerInterface/ParamGetDDBase.hh
... | ... | @@ -55,6 +55,15 @@ namespace AMDA { |
55 | 55 | const std::string& getViName() const { |
56 | 56 | return _viName; |
57 | 57 | } |
58 | + int getMaxDim1Size() { | |
59 | + return _maxDim1Size; | |
60 | + } | |
61 | + int getMaxDim2Size() { | |
62 | + return _maxDim2Size; | |
63 | + } | |
64 | + int getMaxDim3Size() { | |
65 | + return _maxDim3Size; | |
66 | + } | |
58 | 67 | int getDim3Num() { |
59 | 68 | return _dim3Num; |
60 | 69 | } |
... | ... | @@ -69,6 +78,15 @@ namespace AMDA { |
69 | 78 | void setViName(const char* viName) { |
70 | 79 | _viName = viName; |
71 | 80 | } |
81 | + void setMaxDim1Size(const int maxDim1Size) { | |
82 | + _maxDim1Size = maxDim1Size; | |
83 | + } | |
84 | + void setMaxDim2Size(const int maxDim2Size) { | |
85 | + _maxDim2Size = maxDim2Size; | |
86 | + } | |
87 | + void setMaxDim3Size(const int maxDim3Size) { | |
88 | + _maxDim3Size = maxDim3Size; | |
89 | + } | |
72 | 90 | void setDim3Num(const int dim3Num) { |
73 | 91 | _dim3Num = dim3Num; |
74 | 92 | } |
... | ... | @@ -123,6 +141,9 @@ namespace AMDA { |
123 | 141 | |
124 | 142 | std::string _parName; /**< param name for current virtual instrument */ |
125 | 143 | std::string _viName; /**< virtual instrument name */ |
144 | + int _maxDim1Size; | |
145 | + int _maxDim2Size; | |
146 | + int _maxDim3Size; | |
126 | 147 | int _dim3Num; |
127 | 148 | int _dim3CutIndex; |
128 | 149 | Base::Pusher* _pusher; /**< Responsible push data into the good container. */ | ... | ... |
src/ParamGetImpl/DDServerInterface/Pusher.hh
... | ... | @@ -24,7 +24,7 @@ namespace Base { |
24 | 24 | * of the corresponding type ( scalar or vector or Tab2D of short or int or float or double or ... type). |
25 | 25 | */ |
26 | 26 | struct Pusher { |
27 | - Pusher (int dim1Size=1,int dim2Size=1) : _dim1Size(dim1Size), _dim2Size(dim2Size), _paramData(NULL), _fillValue(NAN) {} | |
27 | + Pusher (int maxDim1Size=1,int maxDim2Size=1) : _maxDim1Size(maxDim1Size), _maxDim2Size(maxDim2Size), _paramData(NULL), _fillValue(NAN) {} | |
28 | 28 | virtual ~Pusher() {} |
29 | 29 | virtual void put(DD_data_t *data) = 0; |
30 | 30 | virtual void putNaN() = 0; |
... | ... | @@ -34,8 +34,8 @@ namespace Base { |
34 | 34 | double getFillValue() { |
35 | 35 | return _fillValue; |
36 | 36 | } |
37 | - int _dim1Size; /*!< Used for vector and Tab2D */ | |
38 | - int _dim2Size; /*!< Used for Tab2D */ | |
37 | + int _maxDim1Size; /*!< Used for vector and Tab2D */ | |
38 | + int _maxDim2Size; /*!< Used for Tab2D */ | |
39 | 39 | ParamData* _paramData; /*!< return ParamData to a Process*/ |
40 | 40 | protected: |
41 | 41 | float _fillValue; /*!< When this value is different of NAN, into the raw data, it is replaced by NAN into ParamData. */ |
... | ... | @@ -81,7 +81,7 @@ public: |
81 | 81 | |
82 | 82 | SpecParamData* _specParamData; |
83 | 83 | |
84 | - Pusher(int dim1Size, int dim2Size, int dim3Size = 1, int dim1Num = 0, int dim2Num = 1, int dim3Num = -1, int dim3CutIndex = -1) : Base::Pusher(dim1Size,dim2Size), _dim3Size(dim3Size), _dim1Num(dim1Num), _dim2Num(dim2Num), _dim3Num(dim3Num), _dim3CutIndex(dim3CutIndex) { | |
84 | + Pusher(int maxDim1Size, int maxDim2Size, int maxDim3Size, int dim1Num = 0, int dim2Num = 1, int dim3Num = -1, int dim3CutIndex = -1) : Base::Pusher(maxDim1Size,maxDim2Size), _maxDim3Size(maxDim3Size), _dim1Num(dim1Num), _dim2Num(dim2Num), _dim3Num(dim3Num), _dim3CutIndex(dim3CutIndex) { | |
85 | 85 | _paramData = _specParamData = createParamData(); |
86 | 86 | } |
87 | 87 | |
... | ... | @@ -92,26 +92,27 @@ public: |
92 | 92 | _specParamData->getDataList().resize(data->VarNumber); |
93 | 93 | |
94 | 94 | for (int index = 0; index < data->VarNumber; index++) { |
95 | - ElemenType elem = ElemenType(_dim1Size,_dim2Size); | |
96 | - for (int dim1Index= 0; dim1Index < _dim1Size; ++dim1Index) | |
95 | + ElemenType elem = ElemenType(_maxDim1Size,_maxDim2Size); | |
96 | + elem << NotANumber(); | |
97 | + for (int dim1Index= 0; dim1Index < data->Dimensions[_dim1Num]; ++dim1Index) | |
97 | 98 | { |
98 | - for (int dim2Index= 0; dim2Index < _dim2Size; ++dim2Index) | |
99 | + for (int dim2Index= 0; dim2Index < data->Dimensions[_dim2Num]; ++dim2Index) | |
99 | 100 | { |
100 | 101 | int dataIndex = 0; |
101 | 102 | if (_dim3Num >= 0 && _dim3Num < 3 && data->DimNumber == 3) { |
102 | - int cutIndex = (_dim3CutIndex >= 0 && _dim3CutIndex < _dim3Size) ? _dim3CutIndex : 0; | |
103 | + int cutIndex = (_dim3CutIndex >= 0 && _dim3CutIndex < data->Dimensions[_dim3Num]) ? _dim3CutIndex : 0; | |
103 | 104 | if (_dim3Num == 0) { |
104 | - dataIndex = cutIndex*_dim1Size*_dim2Size + dim1Index*_dim2Size + dim2Index; | |
105 | + dataIndex = cutIndex*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim1Index*data->Dimensions[_dim2Num] + dim2Index; | |
105 | 106 | } |
106 | 107 | else if (_dim3Num == 1) { |
107 | - dataIndex = dim1Index*_dim2Size*_dim3Size + cutIndex*_dim2Size + dim2Index; | |
108 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + cutIndex*data->Dimensions[_dim2Num] + dim2Index; | |
108 | 109 | } |
109 | 110 | else { |
110 | - dataIndex = dim1Index*_dim1Size*_dim2Size + dim2Index*_dim1Size + cutIndex; | |
111 | + dataIndex = dim1Index*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim2Index*data->Dimensions[_dim1Num] + cutIndex; | |
111 | 112 | } |
112 | 113 | } |
113 | 114 | else { |
114 | - dataIndex = dim1Index*_dim2Size+dim2Index; | |
115 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]+dim2Index; | |
115 | 116 | } |
116 | 117 | BaseElemenType baseElem = lData[index][dataIndex]; |
117 | 118 | if (!isnan(_fillValue)) |
... | ... | @@ -130,9 +131,9 @@ public: |
130 | 131 | |
131 | 132 | void putNaN() { |
132 | 133 | _specParamData->getDataList().resize(1); |
133 | - ElemenType nanElem = ElemenType(_dim1Size,_dim2Size); | |
134 | - for(int i = 0; i < _dim1Size; ++i) { | |
135 | - for(int j = 0; j < _dim2Size; ++j) { | |
134 | + ElemenType nanElem = ElemenType(_maxDim1Size,_maxDim2Size); | |
135 | + for(int i = 0; i < _maxDim1Size; ++i) { | |
136 | + for(int j = 0; j < _maxDim2Size; ++j) { | |
136 | 137 | nanElem[i][j] = ((BaseElemenType)NAN); |
137 | 138 | } |
138 | 139 | } |
... | ... | @@ -140,12 +141,12 @@ public: |
140 | 141 | } |
141 | 142 | |
142 | 143 | SpecParamData* createParamData() { |
143 | - return new ParamDataSpec< Tab2DData<typename MapType<type>::Type> >(_dim1Size,_dim2Size); | |
144 | + return new ParamDataSpec< Tab2DData<typename MapType<type>::Type> >(_maxDim1Size,_maxDim2Size); | |
144 | 145 | } |
145 | 146 | |
146 | 147 | private: |
147 | 148 | |
148 | - int _dim3Size; | |
149 | + int _maxDim3Size; | |
149 | 150 | |
150 | 151 | int _dim1Num; |
151 | 152 | |
... | ... | @@ -168,7 +169,7 @@ public: |
168 | 169 | |
169 | 170 | SpecParamData* _specParamData; |
170 | 171 | |
171 | - Pusher(int dim) : Base::Pusher(dim) { | |
172 | + Pusher(int maxDimSize) : Base::Pusher(maxDimSize) { | |
172 | 173 | _paramData = _specParamData = createParamData(); |
173 | 174 | } |
174 | 175 | |
... | ... | @@ -179,7 +180,10 @@ public: |
179 | 180 | _specParamData->getDataList().resize(data->VarNumber); |
180 | 181 | |
181 | 182 | for (int index = 0; index < data->VarNumber; index++) { |
182 | - ElemenType elem = ElemenType(lData[index],lData[index]+_dim1Size); | |
183 | + ElemenType elem = ElemenType(); | |
184 | + elem.resize(_maxDim1Size); | |
185 | + elem << NotANumber(); | |
186 | + std::copy (lData[index], lData[index] + data->Dimensions[0], elem.begin()); | |
183 | 187 | if(!isnan(_fillValue)) { |
184 | 188 | for(auto it = elem.begin(); it != elem.end(); ++it) { |
185 | 189 | double crt_val = *it; |
... | ... | @@ -196,14 +200,13 @@ public: |
196 | 200 | void putNaN() { |
197 | 201 | _specParamData->getDataList().resize(1); |
198 | 202 | ElemenType nanElem = ElemenType(); |
199 | - for(int i = 0; i < _dim1Size; ++i) { | |
200 | - nanElem.push_back((BaseElemenType)NAN); | |
201 | - } | |
203 | + nanElem.resize(_maxDim1Size); | |
204 | + nanElem << NotANumber(); | |
202 | 205 | _specParamData->getDataList().push_back(nanElem); |
203 | 206 | } |
204 | 207 | |
205 | 208 | SpecParamData* createParamData() { |
206 | - return new ParamDataSpec< std::vector<typename MapType<type>::Type> >(_dim1Size); | |
209 | + return new ParamDataSpec< std::vector<typename MapType<type>::Type> >(_maxDim1Size); | |
207 | 210 | } |
208 | 211 | |
209 | 212 | }; | ... | ... |
src/ParamGetImpl/DDServerInterface/VirtualInstrument.cc
... | ... | @@ -196,7 +196,7 @@ namespace DDServerInterface { |
196 | 196 | } |
197 | 197 | |
198 | 198 | //TODO Replace by DD_Client::getParamType |
199 | - AMDA::Parameters::Base::Pusher* VirtualInstrument::getParamPusher( const std::string& pParName, int dim3Num, int dim3CutIndex) { | |
199 | + AMDA::Parameters::Base::Pusher* VirtualInstrument::getParamPusher( const std::string& pParName, int maxDim1Size, int maxDim2Size, int maxDim3Size, int dim3Num, int dim3CutIndex) { | |
200 | 200 | |
201 | 201 | AMDA::Parameters::Base::Pusher* lPusher = nullptr; |
202 | 202 | int error = 0; |
... | ... | @@ -283,16 +283,16 @@ namespace DDServerInterface { |
283 | 283 | switch (numDataType) |
284 | 284 | { |
285 | 285 | case DD_FLOAT: |
286 | - lPusher = new Pusher<DD_FLOAT, AMDA::Parameters::ContainerType::CT_TAB1D>(data->Dimensions[0]); | |
286 | + lPusher = new Pusher<DD_FLOAT, AMDA::Parameters::ContainerType::CT_TAB1D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[0]); | |
287 | 287 | break; |
288 | 288 | case DD_INT : |
289 | - lPusher = new Pusher<DD_INT, AMDA::Parameters::ContainerType::CT_TAB1D>(data->Dimensions[0]); | |
289 | + lPusher = new Pusher<DD_INT, AMDA::Parameters::ContainerType::CT_TAB1D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[0]); | |
290 | 290 | break; |
291 | 291 | case DD_SHORT : |
292 | - lPusher = new Pusher<DD_SHORT, AMDA::Parameters::ContainerType::CT_TAB1D>(data->Dimensions[0]); | |
292 | + lPusher = new Pusher<DD_SHORT, AMDA::Parameters::ContainerType::CT_TAB1D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[0]); | |
293 | 293 | break; |
294 | 294 | case DD_DOUBLE : |
295 | - lPusher = new Pusher<DD_DOUBLE, AMDA::Parameters::ContainerType::CT_TAB1D>(data->Dimensions[0]); | |
295 | + lPusher = new Pusher<DD_DOUBLE, AMDA::Parameters::ContainerType::CT_TAB1D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[0]); | |
296 | 296 | break; |
297 | 297 | default : |
298 | 298 | BOOST_THROW_EXCEPTION( |
... | ... | @@ -312,16 +312,16 @@ namespace DDServerInterface { |
312 | 312 | switch (numDataType) |
313 | 313 | { |
314 | 314 | case DD_FLOAT: |
315 | - lPusher = new Pusher<DD_FLOAT, AMDA::Parameters::ContainerType::CT_TAB2D>(data->Dimensions[dim1N],data->Dimensions[dim2N],dim3Size,dim1N,dim2N,dim3Num,dim3CutIndex); | |
315 | + lPusher = new Pusher<DD_FLOAT, AMDA::Parameters::ContainerType::CT_TAB2D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[dim1N], maxDim2Size > -1 ? maxDim2Size : data->Dimensions[dim2N], maxDim3Size > -1 ? maxDim3Size : dim3Size, dim1N, dim2N, dim3Num, dim3CutIndex); | |
316 | 316 | break; |
317 | 317 | case DD_INT : |
318 | - lPusher = new Pusher<DD_INT, AMDA::Parameters::ContainerType::CT_TAB2D>(data->Dimensions[dim1N],data->Dimensions[dim2N],dim3Size,dim1N,dim2N,dim3Num,dim3CutIndex); | |
318 | + lPusher = new Pusher<DD_INT, AMDA::Parameters::ContainerType::CT_TAB2D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[dim1N], maxDim2Size > -1 ? maxDim2Size : data->Dimensions[dim2N], maxDim3Size > -1 ? maxDim3Size : dim3Size, dim1N, dim2N, dim3Num, dim3CutIndex); | |
319 | 319 | break; |
320 | 320 | case DD_SHORT : |
321 | - lPusher = new Pusher<DD_SHORT, AMDA::Parameters::ContainerType::CT_TAB2D>(data->Dimensions[dim1N],data->Dimensions[dim2N],dim3Size,dim1N,dim2N,dim3Num,dim3CutIndex); | |
321 | + lPusher = new Pusher<DD_SHORT, AMDA::Parameters::ContainerType::CT_TAB2D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[dim1N], maxDim2Size > -1 ? maxDim2Size : data->Dimensions[dim2N], maxDim3Size > -1 ? maxDim3Size : dim3Size, dim1N, dim2N, dim3Num, dim3CutIndex); | |
322 | 322 | break; |
323 | 323 | case DD_DOUBLE : |
324 | - lPusher = new Pusher<DD_DOUBLE, AMDA::Parameters::ContainerType::CT_TAB2D>(data->Dimensions[dim1N],data->Dimensions[dim2N],dim3Size,dim1N,dim2N,dim3Num,dim3CutIndex); | |
324 | + lPusher = new Pusher<DD_DOUBLE, AMDA::Parameters::ContainerType::CT_TAB2D>(maxDim1Size > -1 ? maxDim1Size : data->Dimensions[dim1N], maxDim2Size > -1 ? maxDim2Size : data->Dimensions[dim2N], maxDim3Size > -1 ? maxDim3Size : dim3Size, dim1N, dim2N, dim3Num, dim3CutIndex); | |
325 | 325 | break; |
326 | 326 | default : |
327 | 327 | BOOST_THROW_EXCEPTION( | ... | ... |
src/ParamGetImpl/DDServerInterface/VirtualInstrument.hh
... | ... | @@ -83,7 +83,7 @@ public: |
83 | 83 | /** |
84 | 84 | * @brief Responsible push data into the good container. |
85 | 85 | */ |
86 | - AMDA::Parameters::Base::Pusher* getParamPusher(const std::string& pParName, int dim3Num, int dim3CutIndex); | |
86 | + AMDA::Parameters::Base::Pusher* getParamPusher(const std::string& pParName, int maxDim1Size, int maxDim2Size, int maxDim3Size, int dim3Num, int dim3CutIndex); | |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return a ParamFlowSPtr on the specified interval. | ... | ... |