DABC (Data Acquisition Backbone Core)  2.9.9
Transport.h
Go to the documentation of this file.
1 // $Id: Transport.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 DABC_Transport
17 #define DABC_Transport
18 
19 #ifndef DABC_ModuleAsync
20 #include "dabc/ModuleAsync.h"
21 #endif
22 
23 #ifndef DABC_Device
24 #include "dabc/Device.h"
25 #endif
26 
27 namespace dabc {
28 
29  extern const unsigned AcknoledgeQueueLength;
30 
37  class Transport : public ModuleAsync {
38 
39  friend class Device;
40 
41  protected:
46  stError
47  };
48 
53  std::string fTransportInfoName;
56 
58 
59  bool isTransportRunning() const { return GetTransportState() == stRunning; }
60  bool isTransportError() const { return GetTransportState() == stError; }
61 
63  virtual void ProcessConnectionActivated(const std::string &name, bool on);
64 
65  virtual void ProcessConnectEvent(const std::string &name, bool on);
66 
67  virtual int ExecuteCommand(Command cmd);
68 
72  bool InfoExpected() const;
73 
75  virtual void ModuleCleanup();
76 
77  virtual void TransportCleanup() {}
78 
80  void ProvideInfo(int lvl, const std::string &info);
81 
82  static std::string MakeName(const PortRef& inpport, const PortRef& outport);
83 
84  public:
85  virtual const char* ClassName() const { return "Transport"; }
86 
87  Transport(dabc::Command cmd, const PortRef& inpport = 0, const PortRef& outport = 0);
88  virtual ~Transport();
89 
91  virtual bool StartTransport();
92  virtual bool StopTransport();
93 
94  bool IsInputTransport() const { return fIsInputTransport; }
95  bool IsOutputTransport() const { return fIsOutputTransport; }
96 
97  // method must be called from the transport thread
98  virtual void CloseTransport(bool witherr = false);
99  };
100 
101  // __________________________________________________
102 
103 
109  class TransportRef : public ModuleAsyncRef {
111 
112  PortRef OutputPort() { return (GetObject() && GetObject()->IsInputTransport()) ? FindPort("Output") : PortRef(); }
113 
114  PortRef InputPort() { return (GetObject() && GetObject()->IsOutputTransport()) ? FindPort("Input") : PortRef(); }
115  };
116 
117 };
118 
119 #endif
#define DABC_REFERENCE(RefClass, ParentClass, T)
Definition: Reference.h:222
Represents command with its arguments.
Definition: Command.h:99
Reference on dabc::Device class
Definition: Device.h:79
Base class for device implementation.
Definition: Device.h:43
Reference on dabc::ModuleAsync class
Definition: ModuleAsync.h:201
Base class for user-derived code, implementing event-processing.
Definition: ModuleAsync.h:32
PortRef FindPort(const std::string &name)
Return reference on the port.
Definition: Module.cxx:1031
Output port.
Definition: Port.h:301
Reference on the dabc::Port class
Definition: Port.h:195
Object * GetObject() const
Return pointer on the object.
Definition: Reference.h:129
Reference on dabc::Transport class
Definition: Transport.h:109
PortRef InputPort()
Definition: Transport.h:114
Base class for transport implementations.
Definition: Transport.h:37
Transport(dabc::Command cmd, const PortRef &inpport=0, const PortRef &outport=0)
Definition: Transport.cxx:40
bool IsInputTransport() const
Definition: Transport.h:94
@ stError
When stopped.
Definition: Transport.h:46
@ stStopped
When working.
Definition: Transport.h:45
@ stRunning
When created.
Definition: Transport.h:44
virtual bool StopTransport()
Definition: Transport.cxx:231
virtual bool StartTransport()
Methods activated by Port, when transport starts/stops.
Definition: Transport.cxx:220
bool isTransportError() const
Definition: Transport.h:60
TimeStamp fTransportInfoTm
Definition: Transport.h:55
virtual void ProcessConnectionActivated(const std::string &name, bool on)
Method called when module on other side is started.
Definition: Transport.cxx:141
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
Definition: Transport.cxx:202
virtual void CloseTransport(bool witherr=false)
Definition: Transport.cxx:196
std::string fTransportInfoName
Definition: Transport.h:53
virtual void ProcessConnectEvent(const std::string &name, bool on)
Method called by framework when connection state of the item is changed.
Definition: Transport.cxx:175
virtual void ModuleCleanup()
Reimplemented method from module.
Definition: Transport.cxx:108
ETransportState GetTransportState() const
Definition: Transport.h:57
bool fIsInputTransport
Definition: Transport.h:51
bool fIsOutputTransport
Definition: Transport.h:52
DeviceRef fTransportDevice
device, used to create transport
Definition: Transport.h:49
bool isTransportRunning() const
Definition: Transport.h:59
static std::string MakeName(const PortRef &inpport, const PortRef &outport)
Definition: Transport.cxx:26
bool IsOutputTransport() const
Definition: Transport.h:95
void ProvideInfo(int lvl, const std::string &info)
Method provides transport info to specified parameter.
Definition: Transport.cxx:127
double fTransportInfoInterval
Definition: Transport.h:54
virtual ~Transport()
Definition: Transport.cxx:103
ETransportState fTransportState
Definition: Transport.h:50
bool InfoExpected() const
Returns true when next info can be provided If info parameter was configured, one could use it regula...
Definition: Transport.cxx:120
virtual void TransportCleanup()
Definition: Transport.h:77
virtual const char * ClassName() const
Returns class name of the object.
Definition: Transport.h:85
Event manipulation API.
Definition: api.h:23
const unsigned AcknoledgeQueueLength
Definition: Transport.cxx:23
Class for acquiring and holding timestamps.
Definition: timing.h:40