[1934] | 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" |
---|
[2143] | 7 | #include "workflow_graph.hpp" |
---|
[1934] | 8 | |
---|
| 9 | namespace xios |
---|
| 10 | { |
---|
| 11 | CServerToClientStoreFilter::CServerToClientStoreFilter(CGarbageCollector& gc, CField* field, CContextClient* client) |
---|
| 12 | : CInputPin(gc, 1) |
---|
[2143] | 13 | , field_(field), client_(client), graphEnabled(false) |
---|
[1934] | 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 | |
---|
[2143] | 31 | if(this->graphEnabled) |
---|
| 32 | { |
---|
| 33 | CWorkflowGraph::addNode("Server to Client Store filter", 5, true, 1, packets[0]); |
---|
| 34 | } |
---|
| 35 | |
---|
[1934] | 36 | if (isEOF) |
---|
| 37 | { |
---|
| 38 | msg<<(int)(-1) ; |
---|
| 39 | connector->transfer(client_,event, msg) ; |
---|
| 40 | info(20)<<"Send Data from server to client: FieldId : "<<field_->getId()<<" step : "<<nStep_<< " -->EOF"<<endl; |
---|
| 41 | } |
---|
| 42 | else |
---|
| 43 | { |
---|
| 44 | msg<<nStep_ ; |
---|
| 45 | connector->transfer(packets[0]->data, client_, event, msg) ; |
---|
| 46 | info(20)<<"Send Data from server to client: FieldId : "<<field_->getId()<<" step : "<<nStep_<<endl; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | nStep_++ ; |
---|
| 50 | } |
---|
| 51 | |
---|
[2130] | 52 | CContextClient* CServerToClientStoreFilter::getTransferedDataSize(map<int,int>& size) |
---|
| 53 | { |
---|
| 54 | size = grid_->getServerToClientConnector()->getTransferedDataSize() ; |
---|
| 55 | return client_ ; |
---|
| 56 | } |
---|
[1934] | 57 | |
---|
| 58 | bool CServerToClientStoreFilter::mustAutoTrigger() const |
---|
| 59 | { |
---|
| 60 | return true; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | bool CServerToClientStoreFilter::isDataExpected(const CDate& date) const |
---|
| 64 | { |
---|
| 65 | return true; |
---|
| 66 | } |
---|
| 67 | } // namespace xios |
---|