Commit 193183ca5b67941655f08859146b212d97b6dcc2
1 parent
c1f5c606
Exists in
master
and in
78 other branches
Give the possibility to define some parameters time restriction in a request + A…
…pply time restriction on paramaters (#5768)
Showing
11 changed files
with
252 additions
and
111 deletions
Show diff stats
config/xsd/request/request.xsd
@@ -27,6 +27,19 @@ | @@ -27,6 +27,19 @@ | ||
27 | </xs:sequence> | 27 | </xs:sequence> |
28 | </xs:complexType> | 28 | </xs:complexType> |
29 | </xs:element> | 29 | </xs:element> |
30 | + | ||
31 | + <xs:element name="paramsTimeRestrictions" minOccurs="0" maxOccurs="1"> | ||
32 | + <xs:complexType> | ||
33 | + <xs:sequence> | ||
34 | + <xs:element name="param" minOccurs="0" maxOccurs="unbounded"> | ||
35 | + <xs:complexType> | ||
36 | + <xs:attribute name="id" type="xs:string" /> | ||
37 | + <xs:attribute name="restriction" type="xs:int" /> | ||
38 | + </xs:complexType> | ||
39 | + </xs:element> | ||
40 | + </xs:sequence> | ||
41 | + </xs:complexType> | ||
42 | + </xs:element> | ||
30 | 43 | ||
31 | <xs:element name="outputs"> | 44 | <xs:element name="outputs"> |
32 | <xs:complexType> | 45 | <xs:complexType> |
src/ParamGetImpl/DDServerInterface/ParamGetDDBase.cc
@@ -55,7 +55,7 @@ namespace AMDA { | @@ -55,7 +55,7 @@ namespace AMDA { | ||
55 | /// Create ParamData | 55 | /// Create ParamData |
56 | _vi = VirtualInstrumentManager::getInstance()->getVirtualInstrument( | 56 | _vi = VirtualInstrumentManager::getInstance()->getVirtualInstrument( |
57 | _viName); | 57 | _viName); |
58 | - _pusher = _vi->getParamPusher(_parName, _maxDim1Size, _maxDim2Size, _maxDim3Size, _dim3Num, _dim3CutIndex, _minSumIndex, _maxSumIndex); | 58 | + _pusher = _vi->getParamPusher(_parName, _maxDim1Size, _maxDim2Size, _maxDim3Size, _dim3Num, _dim3CutIndex, _minSumIndex, _maxSumIndex, _parameter.getTimeRestriction()); |
59 | //Param info | 59 | //Param info |
60 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(_parameter.getInfoId(),true); | 60 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(_parameter.getInfoId(),true); |
61 | if ((paramInfo != nullptr) && (isnan(_pusher->getFillValue())) && (!isnan(paramInfo->getOriginalFillValue()))) | 61 | if ((paramInfo != nullptr) && (isnan(_pusher->getFillValue())) && (!isnan(paramInfo->getOriginalFillValue()))) |
@@ -114,8 +114,8 @@ namespace AMDA { | @@ -114,8 +114,8 @@ namespace AMDA { | ||
114 | else { | 114 | else { |
115 | do { | 115 | do { |
116 | result += lPacket->data->VarNumber; | 116 | result += lPacket->data->VarNumber; |
117 | - _pusher->put(lPacket->data.get()); | ||
118 | - updateTimeInParamData(lPacket->time.get()); | 117 | + LOG4CXX_DEBUG(gLogger, "put data " << lPacket->data->VarNumber); |
118 | + _pusher->put(lPacket->data.get(), lPacket->time.get()); | ||
119 | delete lPacket; | 119 | delete lPacket; |
120 | } while( ( lPacket = _paramFlow->tryGet())); | 120 | } while( ( lPacket = _paramFlow->tryGet())); |
121 | 121 | ||
@@ -144,25 +144,6 @@ namespace AMDA { | @@ -144,25 +144,6 @@ namespace AMDA { | ||
144 | return result; | 144 | return result; |
145 | } | 145 | } |
146 | 146 | ||
147 | - void ParamGetDDBase::updateTimeInParamData(DD_data_t* data) { | ||
148 | - LOG4CXX_DEBUG(gLogger, "updateTimeInParamData data->VarNumber = " << data->VarNumber); | ||
149 | - //ParamData is created, add data | ||
150 | - //The capacity must be == at Data | ||
151 | - double t = 0.; | ||
152 | - for (int index = 0; index < data->VarNumber; index++) { | ||
153 | - if (data->type == DD_CHAR) { | ||
154 | - t = DD_Time2Double((char *) data->Variables[index]); | ||
155 | - } | ||
156 | - else if (data->type == DD_DOUBLE) { | ||
157 | - t = *((double*)data->Variables[index]); | ||
158 | - } | ||
159 | - else { | ||
160 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::ex_msg("Unknown time type")); | ||
161 | - } | ||
162 | - _paramData->getTimeList().push_back(t); | ||
163 | - } | ||
164 | - } | ||
165 | - | ||
166 | void ParamGetDDBase::getDDInfo() { | 147 | void ParamGetDDBase::getDDInfo() { |
167 | for (InfoRequestList::iterator lIt = _infoRequestList.begin(); | 148 | for (InfoRequestList::iterator lIt = _infoRequestList.begin(); |
168 | lIt != _infoRequestList.end(); ++lIt) { | 149 | lIt != _infoRequestList.end(); ++lIt) { |
src/ParamGetImpl/DDServerInterface/ParamGetDDBase.hh
@@ -141,12 +141,6 @@ namespace AMDA { | @@ -141,12 +141,6 @@ namespace AMDA { | ||
141 | private: | 141 | private: |
142 | 142 | ||
143 | /** | 143 | /** |
144 | - * @brief update time in the ParamData | ||
145 | - * @details Must be call after createParamData | ||
146 | - */ | ||
147 | - void updateTimeInParamData(DD_data_t *data); | ||
148 | - | ||
149 | - /** | ||
150 | * Create ParamData from getDataTypeInfo. | 144 | * Create ParamData from getDataTypeInfo. |
151 | */ | 145 | */ |
152 | void createParamData(); | 146 | void createParamData(); |
src/ParamGetImpl/DDServerInterface/Pusher.hh
@@ -24,9 +24,9 @@ namespace Base { | @@ -24,9 +24,9 @@ namespace Base { | ||
24 | * of the corresponding type ( scalar or vector or Tab2D of short or int or float or double or ... type). | 24 | * of the corresponding type ( scalar or vector or Tab2D of short or int or float or double or ... type). |
25 | */ | 25 | */ |
26 | struct Pusher { | 26 | struct Pusher { |
27 | - Pusher (int maxDim1Size=1,int maxDim2Size=1) : _maxDim1Size(maxDim1Size), _maxDim2Size(maxDim2Size), _paramData(NULL), _fillValue(NAN) {} | 27 | + Pusher (int maxDim1Size=1,int maxDim2Size=1) : _maxDim1Size(maxDim1Size), _maxDim2Size(maxDim2Size), _paramData(NULL), _fillValue(NAN), _timeRestriction(NAN) {} |
28 | virtual ~Pusher() {} | 28 | virtual ~Pusher() {} |
29 | - virtual void put(DD_data_t *data) = 0; | 29 | + virtual void put(DD_data_t *data, DD_data_t *timeData) = 0; |
30 | virtual void putNaN() = 0; | 30 | virtual void putNaN() = 0; |
31 | void setFillValue(double pFillValue) { | 31 | void setFillValue(double pFillValue) { |
32 | _fillValue = pFillValue; | 32 | _fillValue = pFillValue; |
@@ -34,11 +34,35 @@ namespace Base { | @@ -34,11 +34,35 @@ namespace Base { | ||
34 | double getFillValue() { | 34 | double getFillValue() { |
35 | return _fillValue; | 35 | return _fillValue; |
36 | } | 36 | } |
37 | + void setTimeRestriction(double timeRestriction) { | ||
38 | + _timeRestriction = timeRestriction; | ||
39 | + } | ||
40 | + double getTimeRestriction() { | ||
41 | + return _timeRestriction; | ||
42 | + } | ||
43 | + | ||
44 | + double getTimeByIndex(DD_data_t* data, int index) { | ||
45 | + if (index >= data->VarNumber) { | ||
46 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::ex_msg("Try to access to a time outside of the available range")); | ||
47 | + } | ||
48 | + if (data->type == DD_CHAR) { | ||
49 | + return DD_Time2Double((char *) data->Variables[index]); | ||
50 | + } | ||
51 | + else if (data->type == DD_DOUBLE) { | ||
52 | + return *((double*)data->Variables[index]); | ||
53 | + } | ||
54 | + else { | ||
55 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::ex_msg("Unknown time type")); | ||
56 | + } | ||
57 | + return 0.; | ||
58 | + } | ||
59 | + | ||
37 | int _maxDim1Size; /*!< Used for vector and Tab2D */ | 60 | int _maxDim1Size; /*!< Used for vector and Tab2D */ |
38 | int _maxDim2Size; /*!< Used for Tab2D */ | 61 | int _maxDim2Size; /*!< Used for Tab2D */ |
39 | ParamData* _paramData; /*!< return ParamData to a Process*/ | 62 | ParamData* _paramData; /*!< return ParamData to a Process*/ |
40 | protected: | 63 | protected: |
41 | float _fillValue; /*!< When this value is different of NAN, into the raw data, it is replaced by NAN into ParamData. */ | 64 | float _fillValue; /*!< When this value is different of NAN, into the raw data, it is replaced by NAN into ParamData. */ |
65 | + double _timeRestriction; | ||
42 | }; | 66 | }; |
43 | } | 67 | } |
44 | 68 | ||
@@ -85,102 +109,117 @@ public: | @@ -85,102 +109,117 @@ public: | ||
85 | _paramData = _specParamData = createParamData(); | 109 | _paramData = _specParamData = createParamData(); |
86 | } | 110 | } |
87 | 111 | ||
88 | - void put(DD_data_t *data) { | 112 | + void put(DD_data_t *data, DD_data_t *timeData) { |
89 | BaseElemenType **lData = reinterpret_cast<BaseElemenType **>(data->Variables); | 113 | BaseElemenType **lData = reinterpret_cast<BaseElemenType **>(data->Variables); |
90 | 114 | ||
91 | //ParamData is created, add data | 115 | //ParamData is created, add data |
92 | _specParamData->getDataList().resize(data->VarNumber); | 116 | _specParamData->getDataList().resize(data->VarNumber); |
93 | 117 | ||
94 | 118 | ||
119 | + if(_dim3CutIndex == -1 && _minSumIndex != -1 && _maxSumIndex != -1){ | ||
120 | + for (int index = 0; index < data->VarNumber; index++) { | ||
121 | + double t = getTimeByIndex(timeData, index); | ||
122 | + _paramData->getTimeList().push_back(t); | ||
95 | 123 | ||
96 | - if(_dim3CutIndex == -1 && _minSumIndex != -1 && _maxSumIndex != -1){ | ||
97 | - for (int index = 0; index < data->VarNumber; index++) { | ||
98 | - ElemenType elem = ElemenType(_maxDim1Size,_maxDim2Size); | ||
99 | - elem << NotANumber(); | ||
100 | - for (int dim1Index= 0; dim1Index < data->Dimensions[_dim1Num]; ++dim1Index) | ||
101 | - { | ||
102 | - for (int dim2Index= 0; dim2Index < data->Dimensions[_dim2Num]; ++dim2Index) | ||
103 | - { | ||
104 | - BaseElemenType cumulatedElement; | ||
105 | - cumulatedElement << NotANumber() ; | ||
106 | - for(int sumIndex=_minSumIndex; sumIndex <= _maxSumIndex; ++sumIndex){ | ||
107 | - int dataIndex = 0; | ||
108 | - if (_dim3Num >= 0 && _dim3Num < 3 && data->DimNumber == 3) { | ||
109 | - int curentIndex = (sumIndex >= 0 && sumIndex < data->Dimensions[_dim3Num]) ? sumIndex : 0; | ||
110 | - if (_dim3Num == 0) { | ||
111 | - dataIndex = curentIndex*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim1Index*data->Dimensions[_dim2Num] + dim2Index; | ||
112 | - } | ||
113 | - else if (_dim3Num == 1) { | ||
114 | - dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + curentIndex*data->Dimensions[_dim2Num] + dim2Index; | ||
115 | - } | ||
116 | - else { | ||
117 | - dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + dim2Index*data->Dimensions[_dim3Num] + curentIndex; | ||
118 | - } | 124 | + if ((getTimeRestriction() > 0) && !isnan(getTimeRestriction())) { |
125 | + if (t >= getTimeRestriction()) { | ||
126 | + putNaN(); | ||
127 | + continue; | ||
119 | } | 128 | } |
120 | - else { | ||
121 | - dataIndex = dim1Index*data->Dimensions[_dim2Num]+dim2Index; | ||
122 | - } | ||
123 | - BaseElemenType baseElem = lData[index][dataIndex]; | ||
124 | - if (!isnan(_fillValue)) | ||
125 | - { | ||
126 | - double crt_val = baseElem; | ||
127 | - bool is_fill_value = isApproximatelyEqual(crt_val, _fillValue); | ||
128 | - if(is_fill_value) | ||
129 | - baseElem << NotANumber(); | 129 | + } |
130 | + | ||
131 | + ElemenType elem = ElemenType(_maxDim1Size,_maxDim2Size); | ||
132 | + elem << NotANumber(); | ||
133 | + for (int dim1Index= 0; dim1Index < data->Dimensions[_dim1Num]; ++dim1Index) | ||
134 | + { | ||
135 | + for (int dim2Index= 0; dim2Index < data->Dimensions[_dim2Num]; ++dim2Index) | ||
136 | + { | ||
137 | + BaseElemenType cumulatedElement; | ||
138 | + cumulatedElement << NotANumber() ; | ||
139 | + for(int sumIndex=_minSumIndex; sumIndex <= _maxSumIndex; ++sumIndex){ | ||
140 | + int dataIndex = 0; | ||
141 | + if (_dim3Num >= 0 && _dim3Num < 3 && data->DimNumber == 3) { | ||
142 | + int curentIndex = (sumIndex >= 0 && sumIndex < data->Dimensions[_dim3Num]) ? sumIndex : 0; | ||
143 | + if (_dim3Num == 0) { | ||
144 | + dataIndex = curentIndex*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim1Index*data->Dimensions[_dim2Num] + dim2Index; | ||
145 | + } | ||
146 | + else if (_dim3Num == 1) { | ||
147 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + curentIndex*data->Dimensions[_dim2Num] + dim2Index; | ||
148 | + } | ||
149 | + else { | ||
150 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + dim2Index*data->Dimensions[_dim3Num] + curentIndex; | ||
151 | + } | ||
152 | + } | ||
153 | + else { | ||
154 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]+dim2Index; | ||
155 | + } | ||
156 | + BaseElemenType baseElem = lData[index][dataIndex]; | ||
157 | + if (!isnan(_fillValue)) | ||
158 | + { | ||
159 | + double crt_val = baseElem; | ||
160 | + bool is_fill_value = isApproximatelyEqual(crt_val, _fillValue); | ||
161 | + if(is_fill_value) | ||
162 | + baseElem << NotANumber(); | ||
163 | + } | ||
164 | + if (!isNAN(baseElem)) { | ||
165 | + if (isNAN(cumulatedElement)) | ||
166 | + cumulatedElement << ElemNull(); | ||
167 | + cumulatedElement += baseElem; | ||
168 | + } | ||
169 | + } | ||
170 | + elem[dim1Index][dim2Index] = cumulatedElement; | ||
130 | } | 171 | } |
131 | - if (!isNAN(baseElem)) { | ||
132 | - if (isNAN(cumulatedElement)) | ||
133 | - cumulatedElement << ElemNull(); | ||
134 | - cumulatedElement += baseElem; | ||
135 | - } | ||
136 | - } | ||
137 | - elem[dim1Index][dim2Index] = cumulatedElement; | ||
138 | - } | ||
139 | - | ||
140 | } | 172 | } |
141 | - _specParamData->getDataList().push_back(elem); | 173 | + _specParamData->getDataList().push_back(elem); |
142 | } | 174 | } |
143 | - | ||
144 | - | ||
145 | - | ||
146 | - }else{ | ||
147 | - for (int index = 0; index < data->VarNumber; index++) { | ||
148 | - ElemenType elem = ElemenType(_maxDim1Size,_maxDim2Size); | ||
149 | - elem << NotANumber(); | ||
150 | - for (int dim1Index= 0; dim1Index < data->Dimensions[_dim1Num]; ++dim1Index) | ||
151 | - { | ||
152 | - for (int dim2Index= 0; dim2Index < data->Dimensions[_dim2Num]; ++dim2Index) | 175 | + }else{ |
176 | + for (int index = 0; index < data->VarNumber; index++) { | ||
177 | + double t = getTimeByIndex(timeData, index); | ||
178 | + _paramData->getTimeList().push_back(t); | ||
179 | + | ||
180 | + if ((getTimeRestriction() > 0) && !isnan(getTimeRestriction())) { | ||
181 | + if (getTimeByIndex(data, index) >= getTimeRestriction()) { | ||
182 | + putNaN(); | ||
183 | + continue; | ||
184 | + } | ||
185 | + } | ||
186 | + | ||
187 | + ElemenType elem = ElemenType(_maxDim1Size,_maxDim2Size); | ||
188 | + elem << NotANumber(); | ||
189 | + for (int dim1Index= 0; dim1Index < data->Dimensions[_dim1Num]; ++dim1Index) | ||
153 | { | 190 | { |
154 | - int dataIndex = 0; | ||
155 | - if (_dim3Num >= 0 && _dim3Num < 3 && data->DimNumber == 3) { | ||
156 | - int cutIndex = (_dim3CutIndex >= 0 && _dim3CutIndex < data->Dimensions[_dim3Num]) ? _dim3CutIndex : 0; | ||
157 | - if (_dim3Num == 0) { | ||
158 | - dataIndex = cutIndex*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim1Index*data->Dimensions[_dim2Num] + dim2Index; | ||
159 | - } | ||
160 | - else if (_dim3Num == 1) { | ||
161 | - dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + cutIndex*data->Dimensions[_dim2Num] + dim2Index; | 191 | + for (int dim2Index= 0; dim2Index < data->Dimensions[_dim2Num]; ++dim2Index) |
192 | + { | ||
193 | + int dataIndex = 0; | ||
194 | + if (_dim3Num >= 0 && _dim3Num < 3 && data->DimNumber == 3) { | ||
195 | + int cutIndex = (_dim3CutIndex >= 0 && _dim3CutIndex < data->Dimensions[_dim3Num]) ? _dim3CutIndex : 0; | ||
196 | + if (_dim3Num == 0) { | ||
197 | + dataIndex = cutIndex*data->Dimensions[_dim1Num]*data->Dimensions[_dim2Num] + dim1Index*data->Dimensions[_dim2Num] + dim2Index; | ||
198 | + } | ||
199 | + else if (_dim3Num == 1) { | ||
200 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + cutIndex*data->Dimensions[_dim2Num] + dim2Index; | ||
201 | + } | ||
202 | + else { | ||
203 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + dim2Index*data->Dimensions[_dim3Num] + cutIndex; | ||
204 | + } | ||
162 | } | 205 | } |
163 | else { | 206 | else { |
164 | - dataIndex = dim1Index*data->Dimensions[_dim2Num]*data->Dimensions[_dim3Num] + dim2Index*data->Dimensions[_dim3Num] + cutIndex; | 207 | + dataIndex = dim1Index*data->Dimensions[_dim2Num]+dim2Index; |
165 | } | 208 | } |
209 | + BaseElemenType baseElem = lData[index][dataIndex]; | ||
210 | + if (!isnan(_fillValue)) | ||
211 | + { | ||
212 | + double crt_val = baseElem; | ||
213 | + bool is_fill_value = isApproximatelyEqual(crt_val, _fillValue); | ||
214 | + if(is_fill_value) | ||
215 | + baseElem << NotANumber(); | ||
216 | + } | ||
217 | + elem[dim1Index][dim2Index] = baseElem; | ||
166 | } | 218 | } |
167 | - else { | ||
168 | - dataIndex = dim1Index*data->Dimensions[_dim2Num]+dim2Index; | ||
169 | - } | ||
170 | - BaseElemenType baseElem = lData[index][dataIndex]; | ||
171 | - if (!isnan(_fillValue)) | ||
172 | - { | ||
173 | - double crt_val = baseElem; | ||
174 | - bool is_fill_value = isApproximatelyEqual(crt_val, _fillValue); | ||
175 | - if(is_fill_value) | ||
176 | - baseElem << NotANumber(); | ||
177 | - } | ||
178 | - elem[dim1Index][dim2Index] = baseElem; | ||
179 | } | 219 | } |
220 | + _specParamData->getDataList().push_back(elem); | ||
180 | } | 221 | } |
181 | - _specParamData->getDataList().push_back(elem); | ||
182 | } | 222 | } |
183 | - } | ||
184 | } | 223 | } |
185 | 224 | ||
186 | void putNaN() { | 225 | void putNaN() { |
@@ -231,13 +270,23 @@ public: | @@ -231,13 +270,23 @@ public: | ||
231 | _paramData = _specParamData = createParamData(); | 270 | _paramData = _specParamData = createParamData(); |
232 | } | 271 | } |
233 | 272 | ||
234 | - void put(DD_data_t *data) { | 273 | + void put(DD_data_t *data, DD_data_t *timeData) { |
235 | BaseElemenType **lData = reinterpret_cast<BaseElemenType **>(data->Variables); | 274 | BaseElemenType **lData = reinterpret_cast<BaseElemenType **>(data->Variables); |
236 | 275 | ||
237 | //ParamData is created, add data | 276 | //ParamData is created, add data |
238 | _specParamData->getDataList().resize(data->VarNumber); | 277 | _specParamData->getDataList().resize(data->VarNumber); |
239 | 278 | ||
240 | for (int index = 0; index < data->VarNumber; index++) { | 279 | for (int index = 0; index < data->VarNumber; index++) { |
280 | + double t = getTimeByIndex(timeData, index); | ||
281 | + _paramData->getTimeList().push_back(t); | ||
282 | + | ||
283 | + if ((getTimeRestriction() > 0) && !isnan(getTimeRestriction())) { | ||
284 | + if (t >= getTimeRestriction()) { | ||
285 | + putNaN(); | ||
286 | + continue; | ||
287 | + } | ||
288 | + } | ||
289 | + | ||
241 | ElemenType elem = ElemenType(); | 290 | ElemenType elem = ElemenType(); |
242 | elem.resize(_maxDim1Size); | 291 | elem.resize(_maxDim1Size); |
243 | elem << NotANumber(); | 292 | elem << NotANumber(); |
@@ -290,7 +339,7 @@ public: | @@ -290,7 +339,7 @@ public: | ||
290 | _paramData = _specParamData = createParamData(); | 339 | _paramData = _specParamData = createParamData(); |
291 | } | 340 | } |
292 | 341 | ||
293 | - void put(DD_data_t *data) { | 342 | + void put(DD_data_t *data, DD_data_t *timeData) { |
294 | BaseElemenType **lData = reinterpret_cast<BaseElemenType **>(data->Variables); | 343 | BaseElemenType **lData = reinterpret_cast<BaseElemenType **>(data->Variables); |
295 | 344 | ||
296 | //ParamData is created, add data | 345 | //ParamData is created, add data |
@@ -303,6 +352,16 @@ public: | @@ -303,6 +352,16 @@ public: | ||
303 | BaseElemenType nanElem; | 352 | BaseElemenType nanElem; |
304 | nanElem << NotANumber(); | 353 | nanElem << NotANumber(); |
305 | for (int index = 0; index < data->VarNumber; index++) { | 354 | for (int index = 0; index < data->VarNumber; index++) { |
355 | + double t = getTimeByIndex(timeData, index); | ||
356 | + _paramData->getTimeList().push_back(t); | ||
357 | + | ||
358 | + if ((getTimeRestriction() > 0) && !isnan(getTimeRestriction())) { | ||
359 | + if (t >= getTimeRestriction()) { | ||
360 | + putNaN(); | ||
361 | + continue; | ||
362 | + } | ||
363 | + } | ||
364 | + | ||
306 | double crt_val = *lData[index]; | 365 | double crt_val = *lData[index]; |
307 | bool is_fill_value = isApproximatelyEqual(crt_val, _fillValue); | 366 | bool is_fill_value = isApproximatelyEqual(crt_val, _fillValue); |
308 | if(!is_fill_value) { | 367 | if(!is_fill_value) { |
@@ -314,6 +373,16 @@ public: | @@ -314,6 +373,16 @@ public: | ||
314 | } | 373 | } |
315 | else { | 374 | else { |
316 | for (int index = 0; index < data->VarNumber; index++) { | 375 | for (int index = 0; index < data->VarNumber; index++) { |
376 | + double t = getTimeByIndex(timeData, index); | ||
377 | + _paramData->getTimeList().push_back(t); | ||
378 | + | ||
379 | + if ((getTimeRestriction() > 0) && !isnan(getTimeRestriction())) { | ||
380 | + if (t >= getTimeRestriction()) { | ||
381 | + putNaN(); | ||
382 | + continue; | ||
383 | + } | ||
384 | + } | ||
385 | + | ||
317 | _specParamData->getDataList().push_back(*lData[index]); | 386 | _specParamData->getDataList().push_back(*lData[index]); |
318 | } | 387 | } |
319 | 388 |
src/ParamGetImpl/DDServerInterface/VirtualInstrument.cc
@@ -196,7 +196,7 @@ namespace DDServerInterface { | @@ -196,7 +196,7 @@ namespace DDServerInterface { | ||
196 | } | 196 | } |
197 | 197 | ||
198 | //TODO Replace by DD_Client::getParamType | 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, int minSumIndex, int maxSumIndex) { | 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, double timeRestriction) { |
200 | 200 | ||
201 | AMDA::Parameters::Base::Pusher* lPusher = nullptr; | 201 | AMDA::Parameters::Base::Pusher* lPusher = nullptr; |
202 | int error = 0; | 202 | int error = 0; |
@@ -340,6 +340,9 @@ namespace DDServerInterface { | @@ -340,6 +340,9 @@ namespace DDServerInterface { | ||
340 | BOOST_THROW_EXCEPTION(exception() << errno_code(AMDA_TYPE_DATA_UNKNOWN)); | 340 | BOOST_THROW_EXCEPTION(exception() << errno_code(AMDA_TYPE_DATA_UNKNOWN)); |
341 | } | 341 | } |
342 | lPusher->setFillValue(_fillValue); | 342 | lPusher->setFillValue(_fillValue); |
343 | + if (timeRestriction > 0. && !isnan(timeRestriction)) { | ||
344 | + lPusher->setTimeRestriction(timeRestriction); | ||
345 | + } | ||
343 | } else { | 346 | } else { |
344 | LOG4CXX_INFO(gLogger, "VirtualInstrument::getParamPusher( "<< lId <<", " << pParName << ") returns = (" << error << ")"); | 347 | LOG4CXX_INFO(gLogger, "VirtualInstrument::getParamPusher( "<< lId <<", " << pParName << ") returns = (" << error << ")"); |
345 | lDDClient.DD_Close(lId); | 348 | lDDClient.DD_Close(lId); |
src/ParamGetImpl/DDServerInterface/VirtualInstrument.hh
@@ -83,7 +83,7 @@ public: | @@ -83,7 +83,7 @@ public: | ||
83 | /** | 83 | /** |
84 | * @brief Responsible push data into the good container. | 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, int minSumIndex, int maxSumIndex); | 86 | + AMDA::Parameters::Base::Pusher* getParamPusher(const std::string& pParName, int maxDim1Size, int maxDim2Size, int maxDim3Size, int dim3Num, int dim3CutIndex, int minSumIndex, int maxSumIndex, double timeRestriction); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * @return a ParamFlowSPtr on the specified interval. | 89 | * @return a ParamFlowSPtr on the specified interval. |
src/Parameters/ParamOutput.cc
@@ -46,6 +46,16 @@ void ParamOutput::init(TimeIntervalListSPtr pTimeIntervalList) { | @@ -46,6 +46,16 @@ void ParamOutput::init(TimeIntervalListSPtr pTimeIntervalList) { | ||
46 | } | 46 | } |
47 | 47 | ||
48 | _currentTimeInterval = _timeIntervalList->begin(); | 48 | _currentTimeInterval = _timeIntervalList->begin(); |
49 | + | ||
50 | + // Update params time restrictions | ||
51 | + std::map<std::string, double> paramsTimeRestrictions = _parameterManager.getParamsTimeRestrictions(); | ||
52 | + for (std::map<std::string, double>::iterator it = paramsTimeRestrictions.begin(); it != paramsTimeRestrictions.end(); ++it) { | ||
53 | + ParameterSPtr p = _parameterManager.getParameter(it->first); | ||
54 | + if (p != nullptr) { | ||
55 | + p->setTimeRestriction(it->second); | ||
56 | + } | ||
57 | + } | ||
58 | + | ||
49 | init(); | 59 | init(); |
50 | } | 60 | } |
51 | 61 |
src/Parameters/Parameter.cc
@@ -34,6 +34,7 @@ namespace Parameters { | @@ -34,6 +34,7 @@ namespace Parameters { | ||
34 | _timeResolution(0) , | 34 | _timeResolution(0) , |
35 | _gapThreshold(pParamMng.getDefaultGapThreshold()) , | 35 | _gapThreshold(pParamMng.getDefaultGapThreshold()) , |
36 | _referenceParameter(""), | 36 | _referenceParameter(""), |
37 | + _timeRestriction(NAN), | ||
37 | establishConnectionToDo(true){ | 38 | establishConnectionToDo(true){ |
38 | } | 39 | } |
39 | 40 |
src/Parameters/Parameter.hh
@@ -196,6 +196,14 @@ namespace AMDA { | @@ -196,6 +196,14 @@ namespace AMDA { | ||
196 | return _isTableIndexParam; | 196 | return _isTableIndexParam; |
197 | } | 197 | } |
198 | 198 | ||
199 | + void setTimeRestriction(double restriction) { | ||
200 | + _timeRestriction = restriction; | ||
201 | + } | ||
202 | + | ||
203 | + double getTimeRestriction() { | ||
204 | + return _timeRestriction; | ||
205 | + } | ||
206 | + | ||
199 | protected: | 207 | protected: |
200 | 208 | ||
201 | typedef std::map<DataClient *, ParamInterval*> DataClientList; | 209 | typedef std::map<DataClient *, ParamInterval*> DataClientList; |
@@ -270,6 +278,8 @@ namespace AMDA { | @@ -270,6 +278,8 @@ namespace AMDA { | ||
270 | static bool _isTableIndexParam; | 278 | static bool _isTableIndexParam; |
271 | 279 | ||
272 | 280 | ||
281 | + double _timeRestriction; | ||
282 | + | ||
273 | private: | 283 | private: |
274 | bool establishConnectionToDo; | 284 | bool establishConnectionToDo; |
275 | }; | 285 | }; |
src/Parameters/ParameterManager.hh
@@ -155,6 +155,14 @@ namespace AMDA | @@ -155,6 +155,14 @@ namespace AMDA | ||
155 | 155 | ||
156 | ParameterSPtr findParamInParameterList(const std::string& paramId); | 156 | ParameterSPtr findParamInParameterList(const std::string& paramId); |
157 | 157 | ||
158 | + void addParamTimeRestriction(const std::string& paramId, double restriction) { | ||
159 | + _paramsTimeRestrictions[paramId] = restriction; | ||
160 | + } | ||
161 | + | ||
162 | + std::map<std::string, double> getParamsTimeRestrictions() { | ||
163 | + return _paramsTimeRestrictions; | ||
164 | + } | ||
165 | + | ||
158 | protected: | 166 | protected: |
159 | /** | 167 | /** |
160 | * @return The real parameter if the process is empty. | 168 | * @return The real parameter if the process is empty. |
@@ -197,6 +205,11 @@ private: | @@ -197,6 +205,11 @@ private: | ||
197 | * @brief default value for the gap threshold of all parameters | 205 | * @brief default value for the gap threshold of all parameters |
198 | */ | 206 | */ |
199 | double _defaultGapThreshold; | 207 | double _defaultGapThreshold; |
208 | + | ||
209 | + /* | ||
210 | + * @bried define some parameters time restrictions | ||
211 | + */ | ||
212 | + std::map<std::string, double> _paramsTimeRestrictions; | ||
200 | }; | 213 | }; |
201 | 214 | ||
202 | } /* namespace Parameters */ | 215 | } /* namespace Parameters */ |
src/XMLRequest/XMLRequestParser.cc
@@ -28,6 +28,7 @@ | @@ -28,6 +28,7 @@ | ||
28 | #include "Catalog.hh" | 28 | #include "Catalog.hh" |
29 | 29 | ||
30 | #include <boost/filesystem.hpp> | 30 | #include <boost/filesystem.hpp> |
31 | +#include <boost/lexical_cast.hpp> | ||
31 | 32 | ||
32 | // Using namespace | 33 | // Using namespace |
33 | using namespace log4cxx; | 34 | using namespace log4cxx; |
@@ -297,6 +298,43 @@ public: | @@ -297,6 +298,43 @@ public: | ||
297 | } | 298 | } |
298 | }; | 299 | }; |
299 | 300 | ||
301 | +class ParamTimeRestrictionNode : public NodeCfg | ||
302 | +{ | ||
303 | +public: | ||
304 | + void proceed(xmlNodePtr pNode,const AMDA::Parameters::CfgContext& pContext) { | ||
305 | + ParameterManager* lParameterManager = pContext.get<ParameterManager*>(); | ||
306 | + | ||
307 | + xmlChar* lParamName = xmlGetProp(pNode, (const xmlChar *) "id"); | ||
308 | + std::string paramNameStr; | ||
309 | + if (lParamName) { | ||
310 | + paramNameStr = std::string((char*)lParamName); | ||
311 | + xmlFree(lParamName); | ||
312 | + } | ||
313 | + else { | ||
314 | + ERROR_EXCEPTION( ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@id") | ||
315 | + } | ||
316 | + | ||
317 | + xmlChar* lRestrictionTime = xmlGetProp(pNode, (const xmlChar *) "restriction"); | ||
318 | + double restrictionTime = NAN; | ||
319 | + if (lRestrictionTime) { | ||
320 | + std::string restrictionTimeStr = std::string((char*)lRestrictionTime); | ||
321 | + xmlFree(lRestrictionTime); | ||
322 | + try | ||
323 | + { | ||
324 | + restrictionTime = boost::lexical_cast<double>(restrictionTimeStr); | ||
325 | + } | ||
326 | + catch (boost::bad_lexical_cast &) | ||
327 | + { | ||
328 | + } | ||
329 | + } | ||
330 | + else { | ||
331 | + ERROR_EXCEPTION( ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@restriction") | ||
332 | + } | ||
333 | + | ||
334 | + lParameterManager->addParamTimeRestriction(paramNameStr, restrictionTime); | ||
335 | + } | ||
336 | +}; | ||
337 | + | ||
300 | XMLRequestParser::XMLRequestParser(const char* pXSDFile) : XMLConfigurator(pXSDFile,false) { | 338 | XMLRequestParser::XMLRequestParser(const char* pXSDFile) : XMLConfigurator(pXSDFile,false) { |
301 | /* | 339 | /* |
302 | <request> | 340 | <request> |
@@ -310,6 +348,9 @@ XMLRequestParser::XMLRequestParser(const char* pXSDFile) : XMLConfigurator(pXSDF | @@ -310,6 +348,9 @@ XMLRequestParser::XMLRequestParser(const char* pXSDFile) : XMLConfigurator(pXSDF | ||
310 | <timeInterval>0000000100000000</timeInterval> | 348 | <timeInterval>0000000100000000</timeInterval> |
311 | <interval> | 349 | <interval> |
312 | </times> | 350 | </times> |
351 | + <paramsTimeRestrictions> | ||
352 | + <param id="imf" restriction="1200441599"/> | ||
353 | + </paramsTimeRestrictions> | ||
313 | <outputs> | 354 | <outputs> |
314 | <download> | 355 | <download> |
315 | <timeFormat>ISO</timeFormat> | 356 | <timeFormat>ISO</timeFormat> |
@@ -352,6 +393,12 @@ XMLRequestParser::XMLRequestParser(const char* pXSDFile) : XMLConfigurator(pXSDF | @@ -352,6 +393,12 @@ XMLRequestParser::XMLRequestParser(const char* pXSDFile) : XMLConfigurator(pXSDF | ||
352 | } | 393 | } |
353 | } | 394 | } |
354 | { | 395 | { |
396 | + // Params time restrictions node | ||
397 | + NodeGrpCfg* lParamsTimeRestrictionsNode = new NodeGrpCfg(); | ||
398 | + lRequestNode->getChildList()["paramsTimeRestrictions"] = NodeCfgSPtr(lParamsTimeRestrictionsNode); | ||
399 | + lParamsTimeRestrictionsNode->getChildList()["param"] = NodeCfgSPtr(new ParamTimeRestrictionNode); | ||
400 | + } | ||
401 | + { | ||
355 | // Output group node | 402 | // Output group node |
356 | NodeGrpCfg* lOutputNode = new NodeGrpCfg(); | 403 | NodeGrpCfg* lOutputNode = new NodeGrpCfg(); |
357 | lRequestNode->getChildList()["outputs"] = NodeCfgSPtr(lOutputNode); | 404 | lRequestNode->getChildList()["outputs"] = NodeCfgSPtr(lOutputNode); |