source: XIOS/dev/dev_olga/src/filter/file_writer_filter.cpp @ 1654

Last change on this file since 1654 was 1654, checked in by oabramkina, 3 years ago

Corrections for workflow visualization.

File size: 1.6 KB
Line 
1#include "file_writer_filter.hpp"
2#include "exception.hpp"
3#include "field.hpp"
4#include "utils.hpp"
5#include "workflow_graph.hpp"
6
7namespace xios
8{
9  CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field, bool buildWorkflowGraph /* =false */)
10    : CInputPin(gc, 1)
11    , field(field)
12  {
13    if (!field)
14      ERROR("CFileWriterFilter::CFileWriterFilter(CField* field)",
15            "The field cannot be null.");
16    if (buildWorkflowGraph)
17    {
18      filterId = InvalidableObject::count;
19      InvalidableObject::count++;
20    }
21  }
22
23  void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data)
24  {
25    const bool detectMissingValue = ( !field->default_value.isEmpty() &&
26                               ( (!field->detect_missing_value.isEmpty() || field->detect_missing_value == true)
27                                 || field->hasGridMask()) );
28
29    CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data;
30
31    if (detectMissingValue)
32    {
33      const double missingValue = field->default_value;
34      const size_t nbData = dataArray.numElements();
35      for (size_t idx = 0; idx < nbData; ++idx)
36      {
37        if (NumTraits<double>::isNan(dataArray(idx)))
38          dataArray(idx) = missingValue;
39      }
40    }
41
42    field->sendUpdateData(dataArray);
43
44  }
45
46  bool CFileWriterFilter::mustAutoTrigger() const
47  {
48    return true;
49  }
50
51  bool CFileWriterFilter::isDataExpected(const CDate& date) const
52  {
53    return true;
54  }
55
56  int CFileWriterFilter::getFilterId(void)
57  {
58    return filterId;
59  }
60
61} // namespace xios
Note: See TracBrowser for help on using the repository browser.