source: XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/server_from_client_source_filter.cpp @ 2143

Last change on this file since 2143 was 2143, checked in by yushan, 3 years ago

Big commit on graph functionality. Add buildWorkflowGraph function for filters

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#include "server_from_client_source_filter.hpp"
2#include "grid.hpp"
3#include "exception.hpp"
4#include "calendar_util.hpp"
5#include "context.hpp"
6#include "workflow_graph.hpp"
7
8namespace xios
9{
10  CServerFromClientSourceFilter::CServerFromClientSourceFilter(CGarbageCollector& gc, CGrid* grid)
11    : COutputPin(gc)
12    , grid_(grid)
13  {
14    if (!grid_)
15      ERROR("CServerFromClientSourceFilter::CServerFromClientSourceFilter(CGarbageCollector& gc, CGrid* grid)",
16            "Impossible to construct a source filter without providing a grid.");
17  }
18
19  void CServerFromClientSourceFilter::streamData(CEventServer& event)
20  {
21    Time timeStamp ;
22    for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> timeStamp  ;
23    CDataPacketPtr packet(new CDataPacket);
24    packet->date = CContext::getCurrent()->getCalendar()->getTimeOrigin() + timeStamp*Second; // very bad, better to pass directly the date
25    packet->timestamp = timeStamp;
26    packet->status = CDataPacket::NO_ERROR;
27    grid_->getServerFromClientConnector()->transfer(event,packet->data) ;
28
29    if(this->graphEnabled)
30    {
31      this->graphPackage->filterId = CWorkflowGraph::getNodeSize();
32      packet->graphPackage = new CGraphDataPackage;
33      packet->graphPackage->fromFilter = this->graphPackage->filterId;
34      packet->graphPackage->currentField = this->graphPackage->inFields[0];
35      CWorkflowGraph::addNode("Server from Client Source filter", 1, false, 0, packet);
36    }
37    onOutputReady(packet);
38  }
39
40 
41 
42} // namespace xios
Note: See TracBrowser for help on using the repository browser.