Commit 6edc9ff884a5c1bcb98ab58741453ac414366519
1 parent
1423ad2b
Exists in
master
and in
88 other branches
rm_6463
Showing
7 changed files
with
123 additions
and
17 deletions
Show diff stats
config/xsd/parameter/getddbase.xsd
... | ... | @@ -21,6 +21,8 @@ |
21 | 21 | <xs:attribute name="maxDim3Size" type="xs:int" /> |
22 | 22 | <xs:attribute name="dim3Num" type="xs:int" /> |
23 | 23 | <xs:attribute name="dim3CutIndex" type="xs:int" /> |
24 | + <xs:attribute name="minSumIndex" type="xs:int" /> | |
25 | + <xs:attribute name="maxSumIndex" type="xs:int" /> | |
24 | 26 | </xs:complexType> |
25 | 27 | |
26 | 28 | <xs:complexType name="vi-type"> | ... | ... |
src/ParamGetImpl/DDServerInterface/GetDDBaseNode.cc
... | ... | @@ -101,22 +101,46 @@ public: |
101 | 101 | paramDim3CutIndexStr = std::string((const char*) lDim3CutIndexValue); |
102 | 102 | xmlFree(lDim3CutIndexValue); |
103 | 103 | } |
104 | + | |
105 | + xmlChar* lMinSumIndexValue = xmlGetProp(pNode, (const xmlChar *) "minSumIndex"); | |
106 | + std::string paramMinSumIndexStr; | |
107 | + if (lMinSumIndexValue != NULL) { | |
108 | + paramMinSumIndexStr = std::string((const char*) lMinSumIndexValue); | |
109 | + xmlFree(lMinSumIndexValue); | |
110 | + } | |
111 | + | |
112 | + xmlChar* lMaxSumIndexValue = xmlGetProp(pNode, (const xmlChar *) "maxSumIndex"); | |
113 | + std::string paramMaxSumIndexStr; | |
114 | + if (lMaxSumIndexValue != NULL) { | |
115 | + paramMaxSumIndexStr = std::string((const char*) lMaxSumIndexValue); | |
116 | + xmlFree(lMaxSumIndexValue); | |
117 | + } | |
104 | 118 | |
105 | 119 | //build unique param id |
106 | 120 | std::string paramId = std::string((const char*) lVIName); |
107 | 121 | std::replace( paramId.begin(), paramId.end(), ':', '_'); |
108 | 122 | paramId += "_"; |
109 | 123 | paramId += paramNameStr; |
110 | - | |
124 | + if( ( !paramDim3CutIndexStr.empty() && !paramMinSumIndexStr.empty() ) || | |
125 | + ( !paramDim3CutIndexStr.empty() && !paramMaxSumIndexStr.empty() ) ){ | |
126 | + ERROR_EXCEPTION( "Too much attributes: CUT and SUM") | |
127 | + } | |
111 | 128 | if (!paramDim3NumStr.empty()) { |
129 | + if (!paramDim3CutIndexStr.empty()) { | |
112 | 130 | paramId += "_CUT_"; |
113 | 131 | paramId += paramDim3NumStr; |
114 | - if (!paramDim3CutIndexStr.empty()) { | |
115 | - paramId += "_"; | |
116 | - paramId += paramDim3CutIndexStr; | |
117 | - } | |
118 | - } | |
119 | - | |
132 | + paramId += "_"; | |
133 | + paramId += paramDim3CutIndexStr; | |
134 | + }else if( !paramMinSumIndexStr.empty() && !paramMaxSumIndexStr.empty() ){ | |
135 | + paramId += "_SUM_"; | |
136 | + paramId += paramDim3NumStr; | |
137 | + paramId += "_"; | |
138 | + paramId += paramMinSumIndexStr; | |
139 | + paramId += "_"; | |
140 | + paramId += paramMaxSumIndexStr; | |
141 | + } | |
142 | + } | |
143 | + | |
120 | 144 | lParameterManager->applyParamIdCorrection(paramId); |
121 | 145 | |
122 | 146 | ParameterSPtr lParameter; |
... | ... | @@ -176,6 +200,18 @@ public: |
176 | 200 | { |
177 | 201 | lParamGet->setDim3CutIndex(atoi(paramDim3CutIndexStr.c_str())); |
178 | 202 | } |
203 | + | |
204 | + // minSumIndex | |
205 | + if (!paramMinSumIndexStr.empty()) | |
206 | + { | |
207 | + lParamGet->setMinSumIndex(atoi(paramMinSumIndexStr.c_str())); | |
208 | + } | |
209 | + // maxSumIndex | |
210 | + if (!paramMaxSumIndexStr.empty()) | |
211 | + { | |
212 | + lParamGet->setMaxSumIndex(atoi(paramMaxSumIndexStr.c_str())); | |
213 | + } | |
214 | + | |
179 | 215 | |
180 | 216 | NodeGrpCfg::proceed(pNode, lContext); |
181 | 217 | } | ... | ... |
src/ParamGetImpl/DDServerInterface/ParamGetDDBase.cc
... | ... | @@ -35,13 +35,14 @@ namespace AMDA { |
35 | 35 | namespace Parameters { |
36 | 36 | |
37 | 37 | ParamGetDDBase::ParamGetDDBase(Parameter ¶meter) : |
38 | - ParamGet_CRTP<ParamGetDDBase>(parameter), _parName(""), _viName(""), _maxDim1Size(-1), _maxDim2Size(-1), _maxDim3Size(-1), _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), _minSumIndex(-1), _maxSumIndex(-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 | 43 | , _maxDim1Size(pParamGetDDBase._maxDim1Size), _maxDim2Size(pParamGetDDBase._maxDim2Size), _maxDim3Size(pParamGetDDBase._maxDim3Size) |
44 | 44 | , _dim3Num(pParamGetDDBase._dim3Num), _dim3CutIndex(pParamGetDDBase._dim3CutIndex) |
45 | + , _minSumIndex(pParamGetDDBase._minSumIndex), _maxSumIndex(pParamGetDDBase._maxSumIndex) | |
45 | 46 | , _pusher(pParamGetDDBase._pusher), _infoRequestList(pParamGetDDBase._infoRequestList), _timeStamp(pParamGetDDBase._timeStamp) { |
46 | 47 | } |
47 | 48 | |
... | ... | @@ -54,7 +55,7 @@ namespace AMDA { |
54 | 55 | /// Create ParamData |
55 | 56 | _vi = VirtualInstrumentManager::getInstance()->getVirtualInstrument( |
56 | 57 | _viName); |
57 | - _pusher = _vi->getParamPusher(_parName, _maxDim1Size, _maxDim2Size, _maxDim3Size, _dim3Num, _dim3CutIndex); | |
58 | + _pusher = _vi->getParamPusher(_parName, _maxDim1Size, _maxDim2Size, _maxDim3Size, _dim3Num, _dim3CutIndex, _minSumIndex, _maxSumIndex); | |
58 | 59 | //Param info |
59 | 60 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(_parameter.getInfoId(),true); |
60 | 61 | if ((paramInfo != nullptr) && (isnan(_pusher->getFillValue())) && (!isnan(paramInfo->getFillValue()))) | ... | ... |
src/ParamGetImpl/DDServerInterface/ParamGetDDBase.hh
... | ... | @@ -70,6 +70,12 @@ namespace AMDA { |
70 | 70 | int getDim3CutIndex() { |
71 | 71 | return _dim3CutIndex; |
72 | 72 | } |
73 | + int getMinSumIndex(){ | |
74 | + return _minSumIndex; | |
75 | + } | |
76 | + int getMaxSumIndex(){ | |
77 | + return _maxSumIndex; | |
78 | + } | |
73 | 79 | |
74 | 80 | // Setter methods |
75 | 81 | void setParName(const char* parName) { |
... | ... | @@ -93,6 +99,12 @@ namespace AMDA { |
93 | 99 | void setDim3CutIndex(const int dim3CutIndex) { |
94 | 100 | _dim3CutIndex = dim3CutIndex; |
95 | 101 | } |
102 | + void setMinSumIndex(const int minSumIndex) { | |
103 | + _minSumIndex = minSumIndex; | |
104 | + } | |
105 | + void setMaxSumIndex(const int maxSumIndex) { | |
106 | + _maxSumIndex = maxSumIndex; | |
107 | + } | |
96 | 108 | |
97 | 109 | // Others methods |
98 | 110 | /** |
... | ... | @@ -146,6 +158,8 @@ namespace AMDA { |
146 | 158 | int _maxDim3Size; |
147 | 159 | int _dim3Num; |
148 | 160 | int _dim3CutIndex; |
161 | + int _minSumIndex; | |
162 | + int _maxSumIndex; | |
149 | 163 | Base::Pusher* _pusher; /**< Responsible push data into the good container. */ |
150 | 164 | InfoRequestList _infoRequestList; /**< List of additional information(s) needed. */ |
151 | 165 | DDServerInterface::VirtualInstrumentSPtr _vi; /**< Virtual Instrument. */ | ... | ... |
src/ParamGetImpl/DDServerInterface/Pusher.hh
... | ... | @@ -81,7 +81,7 @@ public: |
81 | 81 | |
82 | 82 | SpecParamData* _specParamData; |
83 | 83 | |
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) { | |
84 | + Pusher(int maxDim1Size, int maxDim2Size, int maxDim3Size, int dim1Num = 0, int dim2Num = 1, int dim3Num = -1, int dim3CutIndex = -1, int minSumIndex=-1, int maxSumIndex=-1) : Base::Pusher(maxDim1Size,maxDim2Size), _maxDim3Size(maxDim3Size), _dim1Num(dim1Num), _dim2Num(dim2Num), _dim3Num(dim3Num), _dim3CutIndex(dim3CutIndex),_minSumIndex(minSumIndex), _maxSumIndex(maxSumIndex) { | |
85 | 85 | _paramData = _specParamData = createParamData(); |
86 | 86 | } |
87 | 87 | |
... | ... | @@ -90,7 +90,7 @@ public: |
90 | 90 | |
91 | 91 | //ParamData is created, add data |
92 | 92 | _specParamData->getDataList().resize(data->VarNumber); |
93 | - | |
93 | + if(_dim3CutIndex != -1 && _minSumIndex == -1 && _minSumIndex == -1){ | |
94 | 94 | for (int index = 0; index < data->VarNumber; index++) { |
95 | 95 | ElemenType elem = ElemenType(_maxDim1Size,_maxDim2Size); |
96 | 96 | elem << NotANumber(); |
... | ... | @@ -127,7 +127,56 @@ public: |
127 | 127 | } |
128 | 128 | _specParamData->getDataList().push_back(elem); |
129 | 129 | } |
130 | + | |
131 | + }else if(_dim3CutIndex == -1 && _minSumIndex != -1 && _maxSumIndex != -1){ | |
132 | + for (int index = 0; index < data->VarNumber; index++) { | |
133 | + ElemenType elem = ElemenType(_maxDim1Size,_maxDim2Size); | |
134 | + elem << NotANumber(); | |
135 | + for (int dim1Index= 0; dim1Index < data->Dimensions[_dim1Num]; ++dim1Index) | |
136 | + { | |
137 | + for (int dim2Index= 0; dim2Index < data->Dimensions[_dim2Num]; ++dim2Index) | |
138 | + { | |
139 | + BaseElemenType cumulatedElement = (BaseElemenType) 0 ; | |
140 | + for(int sumIndex=_minSumIndex; sumIndex <= _maxSumIndex; ++sumIndex){ | |
141 | + int dataIndex = 0; | |
142 | + if (_dim3Num >= 0 && _dim3Num < 3 && data->DimNumber == 3) { | |
143 | + int curentIndex = (sumIndex >= 0 && sumIndex < data->Dimensions[_dim3Num]) ? sumIndex : 0; | |
144 | + if (_dim3Num == 0) { | |
145 | + dataIndex = curentIndex*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim1Index*data->Dimensions[_dim2Num] + dim2Index; | |
146 | + } | |
147 | + else if (_dim3Num == 1) { | |
148 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + curentIndex*data->Dimensions[_dim2Num] + dim2Index; | |
149 | + } | |
150 | + else { | |
151 | + dataIndex = dim1Index*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim2Index*data->Dimensions[_dim1Num] + curentIndex; | |
152 | + } | |
153 | + } | |
154 | + else { | |
155 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]+dim2Index; | |
156 | + } | |
157 | + BaseElemenType baseElem = lData[index][dataIndex]; | |
158 | + if (!isnan(_fillValue)) | |
159 | + { | |
160 | + double crt_val = baseElem; | |
161 | + bool is_fill_value = isApproximatelyEqual(crt_val, _fillValue); | |
162 | + if(is_fill_value) | |
163 | + baseElem = (BaseElemenType) 0; | |
164 | + } | |
165 | + cumulatedElement=cumulatedElement+baseElem; | |
166 | + } | |
167 | + elem[dim1Index][dim2Index] = cumulatedElement; | |
168 | + } | |
169 | + | |
170 | + } | |
171 | + _specParamData->getDataList().push_back(elem); | |
172 | + } | |
173 | + | |
174 | + | |
175 | + | |
176 | + }else{ | |
177 | + std::cout<<"Error in calling Pusher"<<std::endl; | |
130 | 178 | } |
179 | + } | |
131 | 180 | |
132 | 181 | void putNaN() { |
133 | 182 | _specParamData->getDataList().resize(1); |
... | ... | @@ -155,6 +204,10 @@ private: |
155 | 204 | int _dim3Num; |
156 | 205 | |
157 | 206 | int _dim3CutIndex; |
207 | + | |
208 | + int _minSumIndex; | |
209 | + | |
210 | + int _maxSumIndex; | |
158 | 211 | }; |
159 | 212 | |
160 | 213 | /** | ... | ... |
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 maxDim1Size, int maxDim2Size, int maxDim3Size, 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, int minSumIndex, int maxSumIndex) { | |
200 | 200 | |
201 | 201 | AMDA::Parameters::Base::Pusher* lPusher = nullptr; |
202 | 202 | int error = 0; |
... | ... | @@ -317,16 +317,16 @@ namespace DDServerInterface { |
317 | 317 | switch (numDataType) |
318 | 318 | { |
319 | 319 | case DD_FLOAT: |
320 | - 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); | |
320 | + 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, minSumIndex, maxSumIndex); | |
321 | 321 | break; |
322 | 322 | case DD_INT : |
323 | - 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); | |
323 | + 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, minSumIndex, maxSumIndex); | |
324 | 324 | break; |
325 | 325 | case DD_SHORT : |
326 | - 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); | |
326 | + 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, minSumIndex, maxSumIndex); | |
327 | 327 | break; |
328 | 328 | case DD_DOUBLE : |
329 | - 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); | |
329 | + 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, minSumIndex, maxSumIndex); | |
330 | 330 | break; |
331 | 331 | default : |
332 | 332 | 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 maxDim1Size, int maxDim2Size, int maxDim3Size, int dim3Num, int dim3CutIndex); | |
86 | + AMDA::Parameters::Base::Pusher* getParamPusher(const std::string& pParName, int maxDim1Size, int maxDim2Size, int maxDim3Size, int dim3Num, int dim3CutIndex, int minSumIndex, int maxSumIndex); | |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return a ParamFlowSPtr on the specified interval. | ... | ... |