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

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

Developments for visualization of XIOS workflow.

Branch is spawned from trunk r1649.

Boost library is used for producing Graphviz DOT files. Current results: a DOT file representing a static workflow. For a complete proof of concept, DOT files for each timestamp should be generated. The necessary information has been collected by XIOS, it only requires rearranging the information for graphing (changes in classes CWorkflowGraph and CGraphviz).

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