DABC (Data Acquisition Backbone Core)  2.9.9
ClientTransport.h
Go to the documentation of this file.
1 // $Id: ClientTransport.h 3862 2018-05-11 10:06:18Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef MBS_ClientTransport
17 #define MBS_ClientTransport
18 
19 #ifndef DABC_SocketThread
20 #include "dabc/SocketThread.h"
21 #endif
22 
23 #ifndef DABC_DataIO
24 #include "dabc/DataIO.h"
25 #endif
26 
27 #ifndef MBS_MbsTypeDefs
28 #include "mbs/MbsTypeDefs.h"
29 #endif
30 
31 namespace mbs {
32 
36  public dabc::DataInput {
37 
38  protected:
39 
40  enum EIOState {
41  ioInit, // initial state
42  ioRecvInfo, // receiving server info
43  ioReady, // ready for work
44  ioRecvHeader, // receiving buffer header
47  ioComplBuffer, // at this stage buffer must be completed
48  ioClosing, // sending message to server that client is closing
49  ioError, // error detected
50  ioClosed // socket was closed by server
51  };
52 
53  enum EEvents {
56  };
57 
58  mbs::TransportInfo fServInfo; // data, send by transport server in the beginning
60  bool fSwapping;
61  bool fSpanning;
62 
64  char fSendBuf[12];
65 
66  int fKind; // values from EMbsServerKinds
67 
69 
71 
72 
73  // this is part from SocketAddon
74 
75  virtual void ObjectCleanup();
76 
77  virtual void OnThreadAssigned();
78 
79  virtual double ProcessTimeout(double last_diff);
80 
81  virtual void ProcessEvent(const dabc::EventId&);
82 
83  virtual void OnSendCompleted();
84  virtual void OnRecvCompleted();
85 
86  virtual void OnSocketError(int err, const std::string &info);
87 
88  void SubmitRequest();
89  void MakeCallback(unsigned sz);
90 
91  unsigned ReadBufferSize();
92  bool IsDabcEnabledOnMbsSide(); // indicates if new format is enabled on mbs side
93 
94  virtual dabc::WorkerAddon* Read_GetAddon() { return this; }
95 
96  public:
97 
98  ClientTransport(int fd, int kind);
99  virtual ~ClientTransport();
100 
101  int Kind() const { return fKind; }
102 
103 
104  // this is interface from DataInput
105 
106  virtual unsigned Read_Size();
107  virtual unsigned Read_Start(dabc::Buffer& buf);
108  virtual unsigned Read_Complete(dabc::Buffer& buf);
109  virtual double Read_Timeout() { return 0.1; }
110 
111  };
112 
113 }
114 
115 #endif
116 
Reference on memory from memory pool.
Definition: Buffer.h:135
Interface for implementing any kind of data input.
Definition: DataIO.h:61
@ evntSocketLast
from this event number one can add more socket system events
Definition: SocketThread.h:94
Socket addon for handling I/O events.
Definition: SocketThread.h:144
Generic addon for dabc::Worker.
Definition: Worker.h:49
Client transport for different kinds of MBS server.
void MakeCallback(unsigned sz)
ClientTransport(int fd, int kind)
virtual unsigned Read_Size()
Defines required buffer size for next operation.
virtual unsigned Read_Complete(dabc::Buffer &buf)
Complete reading of the buffer from source,.
virtual void OnSocketError(int err, const std::string &info)
Generic error handler.
virtual dabc::WorkerAddon * Read_GetAddon()
Returns addon, provided by data input If specified, supposed that I/O object is double-deriver from D...
bool fSpanning
when true, MBS could deliver spanned events
virtual void OnSendCompleted()
Method called when send operation is completed.
dabc::Buffer fSpanBuffer
buffer rest, which should be copied and merged into next buffer
virtual unsigned Read_Start(dabc::Buffer &buf)
Prepare buffer for reading (if required)
mbs::BufferHeader fHeader
virtual double Read_Timeout()
Provide timeout value.
virtual double ProcessTimeout(double last_diff)
mbs::TransportInfo fServInfo
virtual void OnThreadAssigned()
virtual void OnRecvCompleted()
Method called when receive operation is completed.
virtual void ProcessEvent(const dabc::EventId &)
virtual void ObjectCleanup()
User method to cleanup object content before it will be destroyed Main motivation is to release any r...
Support for MBS - standard GSI DAQ.
Definition: api.h:36
Event structure, exchanged between DABC threads.
Definition: Thread.h:70
MBS buffer header.
Definition: MbsTypeDefs.h:152
MBS server info structure.
Definition: MbsTypeDefs.h:197