Last change
on this file since 1853 was
1853,
checked in by ymipsl, 4 years ago
|
Coupling branch : replace hasServer and hasClient combination by the name of correct service : CLIENT, GATHERER or OUT_SERVER.
YM
|
File size:
1.4 KB
|
Rev | Line | |
---|
[638] | 1 | #include "file_writer_filter.hpp" |
---|
| 2 | #include "exception.hpp" |
---|
| 3 | #include "field.hpp" |
---|
[1158] | 4 | #include "utils.hpp" |
---|
[1853] | 5 | #include "context_client.hpp" |
---|
[638] | 6 | |
---|
| 7 | namespace xios |
---|
| 8 | { |
---|
[1853] | 9 | CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field, CContextClient* client) |
---|
[639] | 10 | : CInputPin(gc, 1) |
---|
[1853] | 11 | , field(field), client_(client) |
---|
[638] | 12 | { |
---|
| 13 | if (!field) |
---|
| 14 | ERROR("CFileWriterFilter::CFileWriterFilter(CField* field)", |
---|
| 15 | "The field cannot be null."); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) |
---|
| 19 | { |
---|
[1637] | 20 | const bool detectMissingValue = ( !field->default_value.isEmpty() && |
---|
| 21 | ( (!field->detect_missing_value.isEmpty() || field->detect_missing_value == true) |
---|
| 22 | || field->hasGridMask()) ); |
---|
[1251] | 23 | |
---|
| 24 | CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data; |
---|
| 25 | |
---|
[1201] | 26 | if (detectMissingValue) |
---|
[1158] | 27 | { |
---|
[1201] | 28 | const double missingValue = field->default_value; |
---|
[1251] | 29 | const size_t nbData = dataArray.numElements(); |
---|
[1158] | 30 | for (size_t idx = 0; idx < nbData; ++idx) |
---|
| 31 | { |
---|
[1474] | 32 | if (NumTraits<double>::isNan(dataArray(idx))) |
---|
[1251] | 33 | dataArray(idx) = missingValue; |
---|
[1158] | 34 | } |
---|
[1201] | 35 | } |
---|
[1158] | 36 | |
---|
[1853] | 37 | field->sendUpdateData(dataArray, client_); |
---|
[638] | 38 | } |
---|
[1158] | 39 | |
---|
[1358] | 40 | bool CFileWriterFilter::mustAutoTrigger() const |
---|
| 41 | { |
---|
| 42 | return true; |
---|
| 43 | } |
---|
| 44 | |
---|
[1158] | 45 | bool CFileWriterFilter::isDataExpected(const CDate& date) const |
---|
| 46 | { |
---|
| 47 | return true; |
---|
| 48 | } |
---|
[638] | 49 | } // namespace xios |
---|
Note: See
TracBrowser
for help on using the repository browser.