Last change
on this file since 1875 was
1875,
checked in by ymipsl, 4 years ago
|
XIOS coupling branch
Some updates.
First coupling test is beginning to work...
YM
|
File size:
1.4 KB
|
Line | |
---|
1 | #include "file_writer_filter.hpp" |
---|
2 | #include "exception.hpp" |
---|
3 | #include "field.hpp" |
---|
4 | #include "utils.hpp" |
---|
5 | #include "context_client.hpp" |
---|
6 | |
---|
7 | namespace xios |
---|
8 | { |
---|
9 | CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field, CContextClient* client) |
---|
10 | : CInputPin(gc, 1) |
---|
11 | , field(field), client_(client) |
---|
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 | { |
---|
20 | const bool detectMissingValue = ( !field->default_value.isEmpty() && |
---|
21 | ( (!field->detect_missing_value.isEmpty() || field->detect_missing_value == true) |
---|
22 | || field->hasGridMask()) ); |
---|
23 | |
---|
24 | CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data; |
---|
25 | |
---|
26 | if (detectMissingValue) |
---|
27 | { |
---|
28 | const double missingValue = field->default_value; |
---|
29 | const size_t nbData = dataArray.numElements(); |
---|
30 | for (size_t idx = 0; idx < nbData; ++idx) |
---|
31 | { |
---|
32 | if (NumTraits<double>::isNan(dataArray(idx))) |
---|
33 | dataArray(idx) = missingValue; |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | field->sendUpdateData(data[0]->timestamp, dataArray, client_); |
---|
38 | } |
---|
39 | |
---|
40 | bool CFileWriterFilter::mustAutoTrigger() const |
---|
41 | { |
---|
42 | return true; |
---|
43 | } |
---|
44 | |
---|
45 | bool CFileWriterFilter::isDataExpected(const CDate& date) const |
---|
46 | { |
---|
47 | return true; |
---|
48 | } |
---|
49 | } // namespace xios |
---|
Note: See
TracBrowser
for help on using the repository browser.