source: XIOS3/trunk/src/filter/server_to_client_store_filter.cpp @ 2628

Last change on this file since 2628 was 2628, checked in by jderouillat, 7 weeks ago

New timers integration/reporting

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#include "server_to_client_store_filter.hpp"
2#include "exception.hpp"
3#include "field.hpp"
4#include "grid.hpp"
5#include "utils.hpp"
6#include "context_client.hpp"
7#include "workflow_graph.hpp"
8
9namespace xios
10{
11  CServerToClientStoreFilter::CServerToClientStoreFilter(CGarbageCollector& gc, CField* field, CContextClient* client)
12    : CInputPin(gc, 1)
13    , field_(field), client_(client), graphEnabled(false)
14  {
15    if (!field) ERROR("CServerToClientFilter::CServerToClientFilter(CField* field)", "The field cannot be null.");
16    grid_ = field_ -> getGrid() ;
17  }
18
19  void CServerToClientStoreFilter::onInputReady(std::vector<CDataPacketPtr> packets)
20  {
21    bool isEOF ;
22    if (packets[0]->status == CDataPacket::NO_ERROR) isEOF = false ;
23    else if (packets[0]->status == CDataPacket::END_OF_STREAM) isEOF = true ;
24
25    CEventClient event(field_->getType(), CField::EVENT_ID_READ_DATA_READY);
26
27    auto connector = grid_->getServerToClientConnector() ;
28    CMessage msg ;
29    msg<<field_->getId() ;
30
31    if(this->graphEnabled)
32    {
33      CWorkflowGraph::addNode("Server to Client Store filter", 5, true, 1, packets[0]);
34    }
35
36    //if (info.isActive(logProfile)) CTimer::get("Field : send data (read)").resume();
37    if (isEOF) 
38    {
39      msg<<(int)(-1) ;
40      connector->transfer(client_,event, msg) ;
41      info(20)<<"Send Data from server to client: FieldId : "<<field_->getId()<<"  step : "<<nStep_<< " -->EOF"<<endl; 
42    }
43    else 
44    {
45      msg<<nStep_ ;
46      connector->transfer(packets[0]->data, client_, event, msg) ;
47      info(20)<<"Send Data from server to client: FieldId : "<<field_->getId()<<"  step : "<<nStep_<<endl; 
48    }
49    //if (info.isActive(logProfile)) CTimer::get("Field : send data (read)").suspend();
50
51    nStep_++ ;
52  }
53
54  CContextClient* CServerToClientStoreFilter::getTransferedDataSize(map<int,int>& size)
55  {
56    size = grid_->getServerToClientConnector()->getTransferedDataSize() ;
57    return client_ ;
58  }
59
60  bool CServerToClientStoreFilter::mustAutoTrigger() const
61  {
62    return true;
63  }
64
65  bool CServerToClientStoreFilter::isDataExpected(const CDate& date) const
66  {
67    return true;
68  }
69} // namespace xios
Note: See TracBrowser for help on using the repository browser.