DABC (Data Acquisition Backbone Core)  2.9.9
Input.h
Go to the documentation of this file.
1 // $Id: Input.h 2216 2014-04-03 13:59:28Z 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 SAFT_INPUT_H
17 #define SAFT_INPUT_H
18 
19 #ifndef DABC_DataIO
20 #include "dabc/DataIO.h"
21 #endif
22 
23 #include "dabc/logging.h"
24 
25 #include <string>
26 #include <queue>
27 #include <cstdint>
28 
29 #include <iostream>
30 //#include <iomanip>
31 
32 
33 
34 #include "saftdabc/Device.h"
35 #include "saftdabc/Definitions.h"
36 
37 #ifndef DABC_SAFT_USE_2_0
38 #include <giomm.h>
39 #include <glib.h>
40 #endif
41 
42 
43 namespace saftdabc
44 {
45 
46 //class DeviceRef;
47 
48 
50 {
54 };
55 
56 
57 
64 class Input: public dabc::DataInput
65 {
66 
67 private:
68 
69 
70 
73  std::queue<saftdabc::Timing_Event> fTimingEventQueue;
74 
75 
78 
81 
82 
84  uint64_t fOverflowCount;
85 
88 
89 
90 
91 protected:
92 
93 
94 
97 
100 
102  double fTimeout;
103 
106 
107 
109  unsigned fSubeventId;
110 
113 
114 
116  bool fVerbose;
117 
120 
123 
125  std::vector<std::string> fInput_Names;
126 
127 // /** Translation table IO name <> prefix
128 // * like in saft-io-ctl implementation*/
129 // std::map<Glib::ustring, guint64> fMap_PrefixName;
130 //
131 
133  std::vector<uint64_t> fSnoop_Masks;
134 
136  std::vector<uint64_t> fSnoop_Ids;
137 
138  /* contains offsets of all events to be snooped*/
139  std::vector<uint64_t> fSnoop_Offsets;
140 
141  /* contains accept flag bitmask of all events to be snooped:
142  * 0x1=late, 0x2=early, 0x4= conflict, 0x8=delayed
143  * TODO:*/
144  std::vector<uint64_t> fSnoop_Flags;
145 
147  bool SetupConditions ();
148 
149 
151  {
152  fInput_Names.clear ();
153  fSnoop_Masks.clear ();
154  fSnoop_Ids.clear ();
155  fSnoop_Offsets.clear ();
156  fSnoop_Flags.clear ();
157  }
158 
160  void ClearEventQueue ();
161 
162  bool Close ();
163 
165  unsigned Write_Mbs (dabc::Buffer& buf);
166 
168  unsigned Write_Hadaq (dabc::Buffer& buf);
169 
171  unsigned Write_Raw (dabc::Buffer& buf);
172 
173 public:
174  Input (const saftdabc::DeviceRef &owner);
175  virtual ~Input ();
176 
177  virtual bool Read_Init (const dabc::WorkerRef& wrk, const dabc::Command& cmd);
178 
180 
181  virtual unsigned Read_Size ();
182  virtual unsigned Read_Start (dabc::Buffer& buf);
183  virtual unsigned Read_Complete (dabc::Buffer& buf);
184 
185  virtual double Read_Timeout ()
186  {
187  return fTimeout;
188  }
189 
190 #ifdef DABC_SAFT_USE_2_0
192  void EventHandler (uint64_t event, uint64_t param, uint64_t deadline, uint64_t executed, uint16_t flags = 0xF);
193 
194 
196  void OverflowHandler(uint64_t count);
197 
198 #else
200  void EventHandler (guint64 event, guint64 param, guint64 deadline, guint64 executed, guint16 flags = 0xF);
201 
202 
204  void OverflowHandler(guint64 count);
205 #endif
206 
207 
208 };
209 
210 }
211 
212 #endif
Reference on memory from memory pool.
Definition: Buffer.h:135
Represents command with its arguments.
Definition: Command.h:99
Interface for implementing any kind of data input.
Definition: DataIO.h:61
posix pthread mutex
Definition: threads.h:61
Reference on the arbitrary object
Definition: Reference.h:73
Reference on dabc::Worker
Definition: Worker.h:466
The saftlib timing message input implementation for DABC.
Definition: Input.h:65
void EventHandler(guint64 event, guint64 param, guint64 deadline, guint64 executed, guint16 flags=0xF)
This is the signalhandler that treats condition events from saftlib.
Definition: Input.cxx:492
unsigned Write_Raw(dabc::Buffer &buf)
Fill output buffer with raw timing events.
Definition: Input.cxx:415
std::vector< uint64_t > fSnoop_Masks
contains masks of all events to be snooped
Definition: Input.h:133
void OverflowHandler(guint64 count)
This is a signalhandler that treats overflow counter events.
Definition: Input.cxx:584
virtual double Read_Timeout()
Provide timeout value.
Definition: Input.h:185
dabc::Mutex fQueueMutex
Mutex to protect timingeventqueue.
Definition: Input.h:77
bool Close()
Definition: Input.cxx:115
virtual unsigned Read_Start(dabc::Buffer &buf)
Prepare buffer for reading (if required)
Definition: Input.cxx:177
std::vector< std::string > fInput_Names
contains names of all hardware inputs to be latched
Definition: Input.h:125
void SetTransportRef(dabc::InputTransport *trans)
Definition: Input.cxx:47
bool fWaitingForCallback
flag to avoid invoking transport callback before transport done
Definition: Input.h:80
unsigned Write_Mbs(dabc::Buffer &buf)
Fill output buffer with mbs formatted data.
Definition: Input.cxx:254
dabc::Reference fTransport
worker that is running this data input.
Definition: Input.h:99
virtual bool Read_Init(const dabc::WorkerRef &wrk, const dabc::Command &cmd)
Initialize data input, using port and command.
Definition: Input.cxx:52
Input(const saftdabc::DeviceRef &owner)
Definition: Input.cxx:31
void ResetDescriptors()
Definition: Input.h:150
std::vector< uint64_t > fSnoop_Flags
Definition: Input.h:144
void ClearEventQueue()
clear input queue of timing events
Definition: Input.cxx:128
bool fVerbose
verbose mode for timing events
Definition: Input.h:116
virtual ~Input()
Definition: Input.cxx:40
bool fUseCallbackMode
switch to work with time out polling or transport call back mode
Definition: Input.h:105
uint64_t fOverflowCount
current overflow counter of all configured inputs
Definition: Input.h:84
DeviceRef fDevice
use dabc reference instead of direct pointer here.
Definition: Input.h:96
long fEventNumber
Event number.
Definition: Input.h:112
double fTimeout
timeout (in seconds) for readout polling.
Definition: Input.h:102
EventFormats_t fEventFormat
Definition: Input.h:122
bool SetupConditions()
set up saftlib conditions from the configuration.
Definition: Input.cxx:427
unsigned fSubeventId
full mbs id number for saft subevent
Definition: Input.h:109
std::vector< uint64_t > fSnoop_Offsets
Definition: Input.h:139
uint64_t fLastOverflowCount
previous overflow counter of all configured inputs
Definition: Input.h:87
std::queue< saftdabc::Timing_Event > fTimingEventQueue
this contains single queue for all snooped WR events.
Definition: Input.h:73
bool fSingleEvents
single events for each mbs container
Definition: Input.h:119
unsigned Write_Hadaq(dabc::Buffer &buf)
Fill output buffer with hadaq formatted data.
Definition: Input.cxx:332
virtual unsigned Read_Size()
Defines required buffer size for next operation.
Definition: Input.cxx:135
virtual unsigned Read_Complete(dabc::Buffer &buf)
Complete reading of the buffer from source,.
Definition: Input.cxx:210
std::vector< uint64_t > fSnoop_Ids
contains event ids of all events to be snooped
Definition: Input.h:136
GSI Simplified API for Timing Library (saftlib) plug-in for dabc.
Definition: Definitions.h:57
EventFormats_t
Definition: Input.h:50
@ saft_Format_Hadaq
Definition: Input.h:53
@ saft_Format_Raw
Definition: Input.h:51
@ saft_Format_Mbs
Definition: Input.h:52