DABC (Data Acquisition Backbone Core)  2.9.9
ClientOutput.h
Go to the documentation of this file.
1 // $Id: ClientOutput.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 AQUA_ClientOutput
17 #define AQUA_ClientOutput
18 
19 
20 #ifndef DABC_SocketThread
21 #include "dabc/SocketThread.h"
22 #endif
23 
24 #ifndef DABC_DataIO
25 #include "dabc/DataIO.h"
26 #endif
27 
28 namespace aqua {
29 
34  struct SendHeader {
35  int64_t counter;
36  int64_t bufsize;
37  };
38 
40  public dabc::DataOutput {
41  protected:
42 
43  enum OutputState {
44  oDisconnected, // when server not connected
45  oReady, // socket ready to send new data
46  oSendingBuffer, // when buffer can be send
47  oCompleteSend, // when send was completed
48  oError // error state
49  };
50 
53  std::string fServerName;
55 
57 
59  int64_t fBufCounter;
60 
61  virtual void OnThreadAssigned();
62  virtual void OnSendCompleted();
63  virtual void OnRecvCompleted();
64 
65  virtual void OnSocketError(int errnum, const std::string &info);
66 
67  virtual double ProcessTimeout(double lastdiff);
68 
69  virtual WorkerAddon* Write_GetAddon() { return this; }
70 
71  bool ConnectAquaServer();
72 
73  void MakeCallBack(unsigned arg);
74 
75 
76  public:
77 
78  ClientOutput(dabc::Url& url);
79  virtual ~ClientOutput();
80 
81  virtual bool Write_Init();
82 
83  virtual unsigned Write_Check();
84  virtual unsigned Write_Buffer(dabc::Buffer& buf);
85  virtual unsigned Write_Complete();
86 
87  virtual double Write_Timeout();
88 
89 
90  };
91 }
92 
93 
94 #endif
virtual unsigned Write_Check()
Check if output can be done.
dabc::TimeStamp fLastConnect
Definition: ClientOutput.h:51
virtual void OnThreadAssigned()
virtual void OnSocketError(int errnum, const std::string &info)
Generic error handler.
SendHeader fSendHdr
Definition: ClientOutput.h:56
virtual ~ClientOutput()
ClientOutput(dabc::Url &url)
std::string fServerName
Definition: ClientOutput.h:53
virtual unsigned Write_Complete()
Complete writing of the buffer.
virtual void OnRecvCompleted()
Method called when receive operation is completed.
void MakeCallBack(unsigned arg)
virtual double Write_Timeout()
Timeout in seconds for write operation.
virtual double ProcessTimeout(double lastdiff)
virtual bool Write_Init()
This is generic virtual method to initialize output before real work is started.
virtual unsigned Write_Buffer(dabc::Buffer &buf)
Start writing of buffer to output.
virtual void OnSendCompleted()
Method called when send operation is completed.
OutputState fState
Definition: ClientOutput.h:58
virtual WorkerAddon * Write_GetAddon()
Returns addon, provided by data output If specified, supposed that I/O object is double-derived from ...
Definition: ClientOutput.h:69
Reference on memory from memory pool.
Definition: Buffer.h:135
Interface for implementing any kind of data output.
Definition: DataIO.h:158
Socket addon for handling I/O events.
Definition: SocketThread.h:144
Uniform Resource Locator interpreter.
Definition: Url.h:33
WorkerAddon(const std::string &name)
Definition: Worker.cxx:27
Support for AQUA - A1 DAQ system.
Definition: ClientOutput.h:28
Client transport for A1 DAQ.
Definition: ClientOutput.h:34
Class for acquiring and holding timestamps.
Definition: timing.h:40