DABC (Data Acquisition Backbone Core)  2.9.9
api.h
Go to the documentation of this file.
1 // $Id: api.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_api
17 #define MBS_api
18 
19 
20 #ifndef MBS_MbsTypeDefs
21 #include "mbs/MbsTypeDefs.h"
22 #endif
23 
24 #ifndef DABC_ModuleAsync
25 #include "dabc/ModuleAsync.h"
26 #endif
27 
28 #ifndef MBS_Iterator
29 #include "mbs/Iterator.h"
30 #endif
31 
32 #ifndef MBS_Monitor
33 #include "mbs/Monitor.h"
34 #endif
35 
36 namespace mbs {
37 
38  class ReadoutHandle;
39 
43  protected:
44 
45  friend class ReadoutHandle;
46 
51 
52  virtual int ExecuteCommand(dabc::Command cmd);
53 
54  void ProcessData();
55 
56  virtual void ProcessInputEvent(unsigned port);
57 
58  virtual void ProcessTimerEvent(unsigned timer);
59 
60  virtual int AcceptBuffer(dabc::Buffer& buf) { return dabc::cmd_false; }
61 
62  bool GetEventInTime(double maxage);
63 
64  public:
65 
66  ReadoutModule(const std::string &name, dabc::Command cmd);
67 
68  };
69 
70  // =================================================================================
71 
74  class ReadoutHandle : protected dabc::ModuleAsyncRef {
75 
77 
78 
79  static ReadoutHandle Connect(const std::string &url)
80  {
81  return DoConnect(url, "mbs::ReadoutModule");
82  }
83 
85  bool null() const { return dabc::ModuleAsyncRef::null(); }
86 
88  bool Disconnect();
89 
94  mbs::EventHeader* NextEvent(double tmout = 1.0, double maxage = -1.);
95 
98 
99  protected:
100 
101 
102  static ReadoutHandle DoConnect(const std::string &url, const char* classname);
103 
104  };
105 
106  // ==========================================================================
107 
109 
111 
112 
113  static MonitorHandle Connect(const std::string &mbsnode, int cmdport = 6019, int logport = 6007, int statport = 6008);
114 
116  bool null() const { return dabc::ModuleAsyncRef::null(); }
117 
119  bool Disconnect();
120 
122  bool MbsCmd(const std::string &cmd, double tmout=5.);
123  };
124 
125 }
126 
127 
128 #endif
#define DABC_REFERENCE(RefClass, ParentClass, T)
Definition: Reference.h:222
Reference on memory from memory pool.
Definition: Buffer.h:135
Represents command with its arguments.
Definition: Command.h:99
Reference on dabc::ModuleAsync class
Definition: ModuleAsync.h:201
Base class for user-derived code, implementing event-processing.
Definition: ModuleAsync.h:32
bool null() const
Returns true if reference contains nullptr.
Definition: Reference.h:151
bool Disconnect()
Release connection to the MBS node.
Definition: api.cxx:248
static MonitorHandle Connect(const std::string &mbsnode, int cmdport=6019, int logport=6007, int statport=6008)
Connect with MBS node.
Definition: api.cxx:218
bool MbsCmd(const std::string &cmd, double tmout=5.)
Execute MBS command.
Definition: api.cxx:268
Interface module for MBS monitoring and control.
Definition: Monitor.h:224
Read iterator for MBS events/subevents.
Definition: Iterator.h:40
Handle to organize readout of MBS data source.
Definition: api.h:74
mbs::EventHeader * GetEvent()
Get current event pointer.
Definition: api.cxx:211
static ReadoutHandle Connect(const std::string &url)
Connect with MBS server.
Definition: api.h:79
mbs::EventHeader * NextEvent(double tmout=1.0, double maxage=-1.)
Retrieve next event from the server One could specify timeout (how long one should wait for next even...
Definition: api.cxx:190
static ReadoutHandle DoConnect(const std::string &url, const char *classname)
Definition: api.cxx:136
bool Disconnect()
Disconnect from MBS server.
Definition: api.cxx:171
Module, used to readout MBS data source and provide data to the user.
Definition: api.h:42
virtual int ExecuteCommand(dabc::Command cmd)
Main method where commands are executed.
Definition: api.cxx:38
dabc::Command fCmd
current nextbuffer cmd
Definition: api.h:50
dabc::TimeStamp fLastNotFullTm
last time when queue is not full
Definition: api.h:48
virtual void ProcessTimerEvent(unsigned timer)
Method called by framework when timer event is produced.
Definition: api.cxx:121
bool GetEventInTime(double maxage)
Definition: api.cxx:127
virtual int AcceptBuffer(dabc::Buffer &buf)
Definition: api.h:60
ReadoutModule(const std::string &name, dabc::Command cmd)
Definition: api.cxx:22
void ProcessData()
Definition: api.cxx:58
dabc::TimeStamp fCurBufTm
time when buffer analysis starts
Definition: api.h:49
mbs::ReadIterator fIter
iterator, accessed only from user side
Definition: api.h:47
virtual void ProcessInputEvent(unsigned port)
Method called by framework when input event is produced.
Definition: api.cxx:114
@ cmd_false
Definition: Command.h:37
Support for MBS - standard GSI DAQ.
Definition: api.h:36
Class for acquiring and holding timestamps.
Definition: timing.h:40