source: XIOS/dev/dev_trunk_graph/src/filter/client_to_server_store_filter.cpp @ 2027

Last change on this file since 2027 was 2027, checked in by yushan, 9 months ago

Graph intermediate commit to a tmp branch. Integrate latest modifications of branch coupling

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#include "client_to_server_store_filter.hpp"
2#include "exception.hpp"
3#include "field.hpp"
4#include "utils.hpp"
5#include "context_client.hpp"
6#include "timer.hpp"
7#include "field.hpp"
8#include "grid.hpp"
9#include "workflow_graph.hpp"
10
11namespace xios
12{
13  CClientToServerStoreFilter::CClientToServerStoreFilter(CGarbageCollector& gc, CField* field, CContextClient* client)
14    : CInputPin(gc, 1)
15    , field_(field), client_(client), graphEnabled(false)
16  {
17    if (!field)
18      ERROR("CClientToServerStoreFilter::CClientToServerStoreFilter(CGarbageCollector& gc, CField* field, CContextClient* client)",
19            "The field cannot be null.");
20  }
21
22  void CClientToServerStoreFilter::onInputReady(std::vector<CDataPacketPtr> data)
23  {
24    buildWorkflowGraph(data);
25
26    CTimer::get("Field : send data").resume();
27    CEventClient event(field_->getType(), CField::EVENT_ID_UPDATE_DATA);
28    CMessage message ;
29    message<<field_->getId() << data[0]->timestamp ;
30    field_->getSentGrid()->getClientToServerConnector(client_)->transfer(data[0]->data, client_, event, message) ;
31    CTimer::get("Field : send data").suspend();
32   }
33 
34  void CClientToServerStoreFilter::buildWorkflowGraph(std::vector<CDataPacketPtr> data)
35  {
36    if(this->graphEnabled)
37    {
38      this->graphPackage->filterId = CWorkflowGraph::getNodeSize();
39      if(!data[0]->graphPackage) data[0]->graphPackage = new CGraphDataPackage;
40     
41      std::rotate(this->graphPackage->inFields.begin(), this->graphPackage->inFields.begin() + 1, this->graphPackage->inFields.end());
42     
43      CWorkflowGraph::addNode("Client to Server Store filter", 6, true, 1, data[0]);
44     
45      CWorkflowGraph::addEdge(data[0]->graphPackage->fromFilter, this->graphPackage->filterId, data[0]);
46      // flux can be redirected to other filters. So don't change the 'from' parameter
47      data[0]->graphPackage->currentField = this->graphPackage->inFields[0];
48    }
49  }
50
51  bool CClientToServerStoreFilter::mustAutoTrigger() const
52  {
53    return true;
54  }
55
56  bool CClientToServerStoreFilter::isDataExpected(const CDate& date) const
57  {
58    return true;
59  }
60} // namespace xios
Note: See TracBrowser for help on using the repository browser.