DABC (Data Acquisition Backbone Core)  2.9.9
Input.cxx
Go to the documentation of this file.
1 
2 /************************************************************
3  * The Data Acquisition Backbone Core (DABC) *
4  ************************************************************
5  * Copyright (C) 2009 - *
6  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
7  * Planckstr. 1, 64291 Darmstadt, Germany *
8  * Contact: http://dabc.gsi.de *
9  ************************************************************
10  * This software can be used under the GPL license *
11  * agreements as stated in LICENSE.txt file *
12  * which is part of the distribution. *
13  ************************************************************/
14 
15 #include "saftdabc/Input.h"
16 #include "saftdabc/Definitions.h"
17 
18 #include "dabc/Pointer.h"
19 #include "dabc/DataTransport.h"
20 
21 #include "mbs/MbsTypeDefs.h"
22 #include "mbs/Iterator.h"
23 //#include "mbs/SlowControlData.h"
24 
25 #include "hadaq/Iterator.h"
26 
27 #include <ctime>
28 #include "dabc/Exception.h"
29 
30 
32  dabc::DataInput (), fQueueMutex(false), fWaitingForCallback(false), fOverflowCount(0), fLastOverflowCount(0), fDevice(owner), fTimeout (1e-2),
33  fUseCallbackMode(false), fSubeventId (8),fEventNumber (0),fVerbose(false),fSingleEvents(false)
34 {
35  DOUT0("saftdabc::Input CTOR");
36  ClearEventQueue ();
37  ResetDescriptors ();
38 }
39 
41 {
42  DOUT0("saftdabc::Input DTOR");
43  Close ();
44 }
45 
46 
48  {
49  fTransport.SetObject(trans);
50  }
51 
52 bool saftdabc::Input::Read_Init (const dabc::WorkerRef& wrk, const dabc::Command& cmd)
53 {
54  DOUT3("saftdabc::Input::Read_Init...");
55  if (!dabc::DataInput::Read_Init (wrk, cmd))
56  return false;
57  fTimeout = wrk.Cfg (saftdabc::xmlTimeout, cmd).AsDouble (fTimeout);
58  fUseCallbackMode=wrk.Cfg (saftdabc::xmlCallbackMode, cmd).AsBool (fUseCallbackMode);
59  fSubeventId = wrk.Cfg (saftdabc::xmlSaftSubeventId, cmd).AsInt (fSubeventId);
60  fSingleEvents= wrk.Cfg (saftdabc::xmlSaftSingleEvent, cmd).AsBool (fSingleEvents);
61  fVerbose= wrk.Cfg (saftdabc::xmlSaftVerbose, cmd).AsBool (fVerbose);
62  fInput_Names = wrk.Cfg (saftdabc::xmlInputs, cmd).AsStrVect ();
63  fSnoop_Ids = wrk.Cfg (saftdabc::xmlEventIds, cmd).AsUIntVect ();
64  fSnoop_Masks = wrk.Cfg (saftdabc::xmlMasks, cmd).AsUIntVect ();
65  fSnoop_Offsets = wrk.Cfg (saftdabc::xmlOffsets, cmd).AsUIntVect ();
66  fSnoop_Flags = wrk.Cfg (saftdabc::xmlAcceptFlags, cmd).AsUIntVect ();
67 
68  std::string format=wrk.Cfg (saftdabc::xmlEventFormat, cmd).AsStr("MBS");
69 
70  if(format.compare(std::string("RAW"))==0)
71  fEventFormat=saft_Format_Raw;
72  else if (format.compare(std::string("MBS"))==0)
73  fEventFormat=saft_Format_Mbs;
74  else if (format.compare(std::string("HADAQ"))==0)
75  fEventFormat=saft_Format_Hadaq;
76  else
77  fEventFormat=saft_Format_Mbs;
78 
79 
80  if (! (fSnoop_Ids.size () == fSnoop_Masks.size ()) &&
81  (fSnoop_Ids.size () == fSnoop_Offsets.size ()) &&
82  (fSnoop_Ids.size () == fSnoop_Flags.size ()))
83  {
84  EOUT(
85  "saftdabc::Input %s - numbers for snoop event ids %d, masks %d, offsets %d, flags %d differ!!! - Please check configuration.", wrk.GetName(),
86  fSnoop_Ids.size(), fSnoop_Masks.size(), fSnoop_Offsets.size(), fSnoop_Flags.size());
87  return false;
88  }
89 
90 
91  DOUT1(
92  "saftdabc::Input %s - Timeout = %e s, callbackmode:%s, format:%s, subevtid:%d, single event:%s, %d hardware inputs, %d snoop event ids, verbose=%s ",
93  wrk.GetName(), fTimeout, DBOOL(fUseCallbackMode), format.c_str(), fSubeventId, DBOOL(fSingleEvents), fInput_Names.size(), fSnoop_Ids.size(), DBOOL(fVerbose));
94 
95 
96  // There set up the software conditions
97  bool rev=SetupConditions();
98  if(!rev) {
99  EOUT("Could not set up all conditions!");
100  return false;
101  }
102 
103  fDevice.SetInfo(dabc::format("Input %s Read_Init is done!",wrk.GetName()));
104  // TODO: test different variants of mainloop invokation!
105  // if we had only one input, we could start the mainloop here:
106 
107  // TEST: uncomment next line for delayed starting of mainloop from remote
109 
110  return rev;
111 }
112 
113 
114 
116 {
117  //fDevice.ClearConditions();
118  // TODO: method that just removes conditions belonging to this device?
119 
120  ClearEventQueue ();
121  ResetDescriptors ();
122  DOUT1("Input::Close - Overflow counts:%lu, previous:%lu",fOverflowCount, fLastOverflowCount);
123  return true;
124 }
125 
126 
127 
129  {
130  dabc::LockGuard gard (fQueueMutex);
131  while(!fTimingEventQueue.empty()) fTimingEventQueue.pop();
132  }
133 
134 
135 unsigned saftdabc::Input::Read_Size ()
136 {
137  try
138 {
139  DOUT3("saftdabc::Input::Read_Size...");
140 #ifdef DABC_SAFT_USE_2_0
141  saftlib::wait_for_signal();
142 #endif
143 
144  if(fUseCallbackMode) return dabc::di_DfltBufSize;
145 
146  // here may do forwarding to callback or poll with timeout if no data in queues
147  dabc::LockGuard gard (fQueueMutex);
148  bool nodata=fTimingEventQueue.empty();
149  if(fVerbose)
150  {
151  if(nodata) DOUT3("saftdabc::Input::Read_Size returns with timeout!");
152  }
153  return (nodata ? dabc::di_RepeatTimeOut: dabc::di_DfltBufSize);
154 
155 // if(fUseCallbackMode && nodata) fWaitingForCallback=true;
156 // return (nodata ? (fUseCallbackMode ? dabc::di_CallBack : dabc::di_RepeatTimeOut): dabc::di_DfltBufSize);
157 
158 
159 } // try
160  catch (std::exception& ex) // also handles std::exception
161  {
162  EOUT(" saftdabc::Input::Read_Size with std exception %s ", ex.what());
163  return dabc::di_Error;
164  }
165 #ifdef DABC_SAFT_USE_2_0
166  catch (const saftbus::Error& error)
167  {
168  /* Catch error(s) */
169  EOUT("saftdabc::Input::Read_Size with SAFTbus error %s ", error.what().c_str());
170  return false;
171 
172  }
173 #endif
174  return dabc::di_Error;
175 }
176 
178 {
179  try
180  {
181  dabc::LockGuard gard (fQueueMutex);
182  if (fTimingEventQueue.empty ())
183  {
184  if (fUseCallbackMode)
185  {
186  fWaitingForCallback = true;
187  DOUT1("saftdabc::Input::Read_Start sets fWaitingForCallback=%s", DBOOL(fWaitingForCallback));
188  return dabc::di_CallBack;
189  }
190  else
191  {
192  EOUT("saftdabc::Input::Read_Start() with empty queue in polling mode!");
193  return dabc::di_Error;
194  }
195 
196  }
197  return dabc::di_Ok;
198 
199  } // try
200  catch (std::exception& ex) // also handles std::exception
201  {
202  EOUT(" saftdabc::Input::Read_Start with std exception %s ", ex.what());
203  return dabc::di_Error;
204  }
205 
206  return dabc::di_Error;
207 }
208 
209 
211 {
212 
213  try
214  {
215  DOUT5("saftdabc::Input::Read_Complete...");
216  switch (fEventFormat)
217  {
218  case saft_Format_Raw:
219  return Write_Raw (buf);
220  case saft_Format_Hadaq:
221  return Write_Hadaq (buf);
222  case saft_Format_Mbs:
223  default:
224  return Write_Mbs (buf);
225  };
226  return dabc::di_Error;
227  } // try
228 
229 
230  #ifdef DABC_SAFT_USE_2_0
231 catch (const saftbus::Error& error)
232  {
233  EOUT("saftdabc::Input::Read_Complete with saftbus error %s", error.what().c_str());
234  return dabc::di_Error;
235  }
236 #else
237  catch (const Glib::Error& error)
238  {
239  EOUT("saftdabc::Input::Read_Complete with Glib error %s", error.what().c_str());
240  return dabc::di_Error;
241  }
242 #endif
243 
244  catch (std::exception& ex) // also handles std::exception
245  {
246  EOUT(" saftdabc::Input::Read_Complete with std exception %s ", ex.what());
247 
248  return dabc::di_Error;
249  }
250 
251 }
252 
253 
255  {
256  DOUT5("saftdabc::Input::Write_Mbs...");
257  dabc::LockGuard gard (fQueueMutex); // protect against saftlib callback <-Device thread
258  mbs::WriteIterator iter (buf);
259  if(!iter.IsPlaceForEvent(sizeof(Timing_Event), true))
260  {
261  // NEVER COME HERE for correctly configured pool?
262  EOUT("saftdabc::Input::Write_Mbs: buffer too small for a single Timing Event!");
263  return dabc::di_SkipBuffer;
264  }
265  iter.NewEvent (fEventNumber++);
266  iter.NewSubevent2 (fSubeventId);
267  iter.evnt()->iTrigger=SAFT_DABC_TRIGTYPE;
268  if(fVerbose) DOUT0("saftdabc::Input::Write_Mbs begins new event %d, mutex=0x%x, instance=0x%x",
269  fEventNumber, &fQueueMutex, (unsigned long) this);
270  //unsigned size = 0;
271  unsigned ec=0;
272  while (!fTimingEventQueue.empty ())
273  {
274  if(fSingleEvents && (ec==1))
275  {
276  if(fVerbose){
277  DOUT0("saftdabc::Input::Write_Mbs has filled single event, closing container.");
278  }
279  break;
280  }
281 
282 
283  ec++;
284  if (!iter.IsPlaceForRawData(sizeof(Timing_Event)))
285  {
286  // following check does not work, since rawdata pointer is updated in FinishSubEvent only ?
287  //uint32_t rest= iter.maxrawdatasize() - (uint32_t) ((ulong) iter.rawdata() - (ulong) iter.subevnt());
288  // no public access in mbs interator to remaining size. workaround:
289  if(fVerbose)
290  {
291  uint32_t rest= iter.maxrawdatasize() - ec * sizeof(Timing_Event);
292  DOUT0("saftdabc::Input::Write_Mbs - buffer remaining size is %d bytes too small for next timing event!",
293  rest);
294  //fVerbose=true; // switch on full debug for the following things
295  }
296  break;
297  }
298 
299 
300  Timing_Event theEvent = fTimingEventQueue.front ();
301  if(fVerbose)
302  {
303  DOUT0("saftdabc::Input::Write_Mbswith queue length %u",fTimingEventQueue.size());
304  char txt[1024];
305  theEvent.InfoMessage(txt,1024);
306  DOUT0("saftdabc::Input::Write_Mbs sees event: %s",txt);
307  }
308  unsigned len = sizeof(Timing_Event);
309  if (!iter.AddRawData (&theEvent, len)){
310 
311  DOUT0("saftdabc::Input::Write_Mbs could not add data of len=%ld to subevent of maxraw=%ld, queuelen=%u",
312  len, iter.maxrawdatasize(), fTimingEventQueue.size());
313  break;
314  }
315  fTimingEventQueue.pop ();
316 
317  // Disable event statistics, not usable with blocked device thread
318  //fDevice.AddEventStatistics(1);
319  }
320  iter.FinishSubEvent();
321  iter.FinishEvent ();
322  buf = iter.Close ();
323  //
324  //DOUT3("Read buf size = %u", buf.GetTotalSize());
325  if(fVerbose) DOUT0("saftdabc::Input::Write_Mbs closes new event %d, read buffer size=%u", fEventNumber, buf.GetTotalSize());
326  return dabc::di_Ok;
327  }
328 
329 
330 
331 
333  {
334  DOUT5("saftdabc::Input::Write_Hadaq...");
335  dabc::LockGuard gard (fQueueMutex); // protect against saftlib callback <-Device thread
336  hadaq::WriteIterator iter (buf);
337 
338  // probably this is redundant with the following check in NewEvent:
339  if(!iter.IsPlaceForEvent(sizeof(Timing_Event)))
340  {
341  // NEVER COME HERE for correctly configured pool?
342  EOUT("saftdabc::Input::Write_Hadaq: buffer too small for a single Timing Event!");
343  return dabc::di_SkipBuffer;
344  }
345 
346  // we misuse the subevent id as run number here. should be ignored by combiner module anyway.
347  if(!iter.NewEvent (fEventNumber++, fSubeventId, sizeof(hadaq::RawSubevent)+ sizeof(Timing_Event)))
348  {
349  // NEVER COME HERE for correctly configured pool?
350  EOUT("saftdabc::Input::Write_Hadaq: NewEvent fails to hold single Timing Event!");
351  return dabc::di_SkipBuffer;
352  }
353 
354  iter.NewSubevent(sizeof(Timing_Event), SAFT_DABC_TRIGTYPE);
355  char* rawbase= (char*) iter.rawdata();
356  char* cursor=rawbase;
357 
358 
359  if(fVerbose) DOUT0("saftdabc::Input::Write_Hadaq begins new event %d, mutex=0x%x, instance=0x%x",
360  fEventNumber, &fQueueMutex, (unsigned long) this);
361  unsigned rawsize = sizeof(hadaq::RawSubevent); // =0 account header in rawsize for hadtu?;
362  unsigned ec=0;
363  while (!fTimingEventQueue.empty ())
364  {
365  if(fSingleEvents && (ec==1))
366  {
367  if(fVerbose){
368  DOUT0("saftdabc::Input::Write_Hadaq has filled single event, closing container.");
369  }
370  break;
371  }
372 
373 
374  ec++;
375  if((cursor - rawbase + sizeof(Timing_Event) ) > iter.maxrawdatasize())
376  {
377  if(fVerbose)
378  {
379  uint32_t rest= iter.maxrawdatasize() - ec * sizeof(Timing_Event);
380  DOUT0("saftdabc::Input::Write_Hadaq - buffer remaining size is %d bytes too small for next timing event!",
381  rest);
382  //fVerbose=true; // switch on full debug for the following things
383  }
384  break;
385  }
386 
387 
388  Timing_Event theEvent = fTimingEventQueue.front ();
389  if(fVerbose)
390  {
391  DOUT0("saftdabc::Input::Write_Hadaq with queue length %u",fTimingEventQueue.size());
392  char txt[1024];
393  theEvent.InfoMessage(txt,1024);
394  DOUT0("saftdabc::Input::Write_Hadaq sees event: %s",txt);
395  }
396 
397  unsigned len = sizeof(Timing_Event);
398  memcpy(cursor, &theEvent,len);
399  rawsize+=len;
400  cursor+=len;
401 
402  fTimingEventQueue.pop ();
403 
404  // Disable event statistics, not usable with blocked device thread
405  //fDevice.AddEventStatistics(1);
406  } // while timing queue is not empty
407 
408  iter.FinishSubEvent(rawsize);
409  iter.FinishEvent ();
410  buf = iter.Close ();
411  if(fVerbose) DOUT0("saftdabc::Input::Write_Hadaq closes new event %d, read buffer size=%u", fEventNumber, buf.GetTotalSize());
412  return dabc::di_Ok;
413  }
414 
416  {
417  // dummy:
418  while (!fTimingEventQueue.empty ())
419  fTimingEventQueue.pop ();
420  return dabc::di_Ok;
421  }
422 
423 
424 
425 
426 
428 {
429  // PART I: treat the input conditions
430  // this is mostly stolen from saft-io-ctl.cpp
431  try
432  {
433  unsigned errcnt (0);
434 
435  // just loop over all DABC configured inputs, checking is done in device class
436  for (std::vector<std::string>::iterator confit = fInput_Names.begin (); confit != fInput_Names.end (); ++confit)
437  {
438  bool rev = fDevice.RegisterInputCondition (this, *confit);
439  if (!rev)
440  errcnt++;
441  } // for
442 
443  DOUT0("SetupConditions with %d errors for input conditions.", errcnt);
444  if (errcnt > 0)
445  return false;
446 
447  // PART II: treat any WR events on the line:
448  for (std::vector<uint64_t>::iterator snit = fSnoop_Ids.begin (), mit = fSnoop_Masks.begin (), offit = fSnoop_Offsets
449  .begin (), flit = fSnoop_Flags.begin ();
450  snit != fSnoop_Ids.end (), mit != fSnoop_Masks.end (), offit != fSnoop_Offsets.end (), flit
451  != fSnoop_Flags.end (); ++snit, ++mit, ++offit, ++flit)
452  {
453  // TODO: may we treat the situation that snoop id is given, but masks etc is not defined as wildcard case?
454  bool rev = fDevice.RegisterEventCondition (this, *snit, *mit, *offit, (unsigned char) *flit);
455  if (!rev)
456  errcnt++;
457 
458  }
459  DOUT0("SetupConditions with %d errors for snoop conditions.", errcnt);
460  if (errcnt > 0)
461  return false;
462  return true;
463 
464  } // end try
465 
466 
467  #ifdef DABC_SAFT_USE_2_0
468 catch (const saftbus::Error& error)
469  {
470  EOUT("SAFTbus error %s in SetupConditions", error.what().c_str());
471  }
472 #else
473  catch (const Glib::Error& error)
474  {
475  EOUT("Glib error %s in SetupConditions", error.what().c_str());
476  return false;
477  }
478 #endif
479 
480  catch (std::exception& ex)
481  {
482  EOUT("std exception %s in SetupConditions", ex.what());
483  return false;
484  }
485 
486  return true;
487 }
488 
489 #ifdef DABC_SAFT_USE_2_0
490  void saftdabc::Input::EventHandler (uint64_t event, uint64_t param, uint64_t deadline, uint64_t executed, uint16_t flags)
491 #else
492 void saftdabc::Input::EventHandler (guint64 event, guint64 param, guint64 deadline, guint64 executed, guint16 flags)
493 #endif
494 {
495 
496  DOUT5("saftdabc::Input::EventHandler...");
497  /* This is the signalhandler that treats condition events from saftlib*/
498  try
499  {
500  dabc::LockGuard gard (fQueueMutex);// protect against Transport thread
501  std::string description = fDevice.GetInputDescription (event);
502  // here check if we have input condition, then substract the offset:
503  if(description.compare(std::string(NON_IO_CONDITION_LABEL))!=0)
504  {
505  deadline -= IO_CONDITION_OFFSET; // like in saft-io-ctl
506  }
507 
508 
509  if (fVerbose)
510  {
511  DOUT0("saftdabc::Input::EventHandler holds mutex 0x%x, instance=0x%x",(unsigned long) &fQueueMutex, (unsigned long) this);
512  DOUT0(
513  "Input::EventHandler sees event=0x%lx, param=0x%lx , deadline=0x%lx, executed=0x%lx, flags=0x%x, description:%s", event, param, deadline, executed, flags, description.c_str());
514  DOUT0("Formatted Date:%s", saftdabc::tr_formatDate(deadline, PMODE_VERBOSE).c_str());
515  DOUT0("Eventid:%s", saftdabc::tr_formatActionEvent(event,PMODE_VERBOSE).c_str());
517 // fDevice.SetInfo (
518 // dabc::format ("Received %s at %s!", saftdabc::tr_formatActionEvent (event, PMODE_VERBOSE).c_str (),
519 // saftdabc::tr_formatDate (deadline, PMODE_VERBOSE).c_str ()));
520  }
521 
522 
523 
524 
525  uint64_t doverflow= fOverflowCount-fLastOverflowCount;
526  if (fVerbose)
527  {
528  DOUT0("saftdabc::Input::EventHandler sees overflowcount=%lu, previous=%lu, delta=%lu",fOverflowCount, fLastOverflowCount, doverflow);
529  }
530 
531  fLastOverflowCount=fOverflowCount;
532  fTimingEventQueue.push (Timing_Event (event, param, deadline, executed, flags, doverflow, description.c_str ()));
533  DOUT3("TimingEventQueue is filled with %d elements", fTimingEventQueue.size());
534  DOUT3("saftdabc::Input::EventHandler with fWaitingForCallback=%s",DBOOL(fWaitingForCallback));
535  if (fUseCallbackMode && fWaitingForCallback)
536  {
537  // do not call Read_CallBack again during transport running
538  // issue callback to dabc transport here:
539  dabc::InputTransport* tr = dynamic_cast<dabc::InputTransport*> (fTransport ());
540  if (tr != 0)
541  {
542  //unsigned datasize=fTimingEventQueue.size()* sizeof(saftdabc::Timing_Event) + sizeof(mbs::EventHeader) + sizeof(mbs::SubeventHeader);
543  // todo: adjust if using different output data format, e.g. hadtu
544 
545  unsigned datasize = dabc::di_DfltBufSize; // always use full buffer anyway.
546  tr->Read_CallBack (datasize);
547  fWaitingForCallback = false;
548  DOUT1("saftdabc::Input::EventHandler after Read_CallBack, fWaitingForCallback=%s", DBOOL(fWaitingForCallback));
549  }
550  else
551  {
552  EOUT("Worker %p is not an InputTransport, can not Read_CallBack", fTransport());
553  }
554 
555  } // if (fUseCallbackMode &
556 
557  } // try
558 
559 #ifdef DABC_SAFT_USE_2_0
560 catch (const saftbus::Error& error)
561  {
562  EOUT("saftdabc::Input::EventHandler with saftbus error %s", error.what().c_str());
563  }
564 #else
565 catch (const Glib::Error& error)
566  {
567  EOUT("saftdabc::Input::EventHandler with Glib error %s", error.what().c_str());
568  }
569 #endif
570 
571  catch (std::exception& ex)
572  {
573  EOUT(" saftdabc::Input::EventHandler with std exception %s ", ex.what());
574  }
575 
576 }
577 
578 
579 
580 
581 #ifdef DABC_SAFT_USE_2_0
582 void saftdabc::Input::OverflowHandler(uint64_t count)
583 #else
584 void saftdabc::Input::OverflowHandler(guint64 count)
585 #endif
586 {
587  DOUT1("saftdabc::Input::OverflowHandler with counts=%lu",count);
588  dabc::LockGuard gard(fQueueMutex); // protect also the counter?
589  fOverflowCount=count;
590  DOUT3("saftdabc::Input::OverflowHandler sees overflowcount=%lu, previous=%lu",fOverflowCount, fLastOverflowCount);
591 }
592 
593 
Reference on memory from memory pool.
Definition: Buffer.h:135
BufferSize_t GetTotalSize() const
Return total size of all buffer segments.
Definition: Buffer.cxx:91
Represents command with its arguments.
Definition: Command.h:99
virtual bool Read_Init(const WorkerRef &wrk, const Command &cmd)
Initialize data input, using port and command.
Definition: DataIO.h:82
void Read_CallBack(unsigned compl_res=di_Ok)
Lock guard for posix mutex.
Definition: threads.h:127
std::vector< uint64_t > AsUIntVect() const
Definition: Record.cxx:631
std::vector< std::string > AsStrVect() const
Definition: Record.cxx:923
bool AsBool(bool dflt=false) const
Definition: Record.cxx:477
std::string AsStr(const std::string &dflt="") const
Definition: Record.cxx:749
int64_t AsInt(int64_t dflt=0) const
Definition: Record.cxx:501
double AsDouble(double dflt=0.) const
Definition: Record.cxx:549
const char * GetName() const
Return name of referenced object, if object not assigned, returns "---".
Definition: Reference.cxx:167
Reference on dabc::Worker
Definition: Worker.h:466
RecordField Cfg(const std::string &name, Command cmd=nullptr) const
Returns configuration record of specified name.
Definition: Worker.h:482
Write iterator for HADAQ events/subevents.
Definition: Iterator.h:104
Write iterator for MBS events/subevents.
Definition: Iterator.h:97
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
void OverflowHandler(guint64 count)
This is a signalhandler that treats overflow counter events.
Definition: Input.cxx:584
bool Close()
Definition: Input.cxx:115
virtual unsigned Read_Start(dabc::Buffer &buf)
Prepare buffer for reading (if required)
Definition: Input.cxx:177
void SetTransportRef(dabc::InputTransport *trans)
Definition: Input.cxx:47
unsigned Write_Mbs(dabc::Buffer &buf)
Fill output buffer with mbs formatted data.
Definition: Input.cxx:254
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 ClearEventQueue()
clear input queue of timing events
Definition: Input.cxx:128
virtual ~Input()
Definition: Input.cxx:40
bool SetupConditions()
set up saftlib conditions from the configuration.
Definition: Input.cxx:427
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
#define DOUT0(args ...)
Definition: logging.h:156
#define DOUT5(args ...)
Definition: logging.h:188
#define DOUT3(args ...)
Definition: logging.h:176
#define EOUT(args ...)
Definition: logging.h:150
#define DOUT1(args ...)
Definition: logging.h:162
#define DBOOL(arg)
Definition: logging.h:191
Event manipulation API.
Definition: api.h:23
std::string format(const char *fmt,...)
Definition: string.cxx:49
@ di_Ok
Definition: DataIO.h:38
@ di_CallBack
Definition: DataIO.h:39
@ di_DfltBufSize
Definition: DataIO.h:42
@ di_RepeatTimeOut
Definition: DataIO.h:36
@ di_SkipBuffer
Definition: DataIO.h:41
@ di_Error
Definition: DataIO.h:40
const char * xmlCallbackMode
switch between polling for data or callback mode
Definition: Factory.cxx:60
const char * xmlOffsets
WR event offsets to snoop.
Definition: Factory.cxx:41
const char * xmlSaftVerbose
switch between silent or verbose event receiver mode
Definition: Factory.cxx:48
const char * xmlInputs
EXPLODER input name items that should be latched with timestamp.
Definition: Factory.cxx:32
const char * xmlAcceptFlags
WR event accept flags to snoop.
Definition: Factory.cxx:45
const char * xmlEventIds
WR event ids to snoop.
Definition: Factory.cxx:39
@ saft_Format_Hadaq
Definition: Input.h:53
@ saft_Format_Raw
Definition: Input.h:51
@ saft_Format_Mbs
Definition: Input.h:52
const char * xmlTimeout
time out for polling mode
Definition: Factory.cxx:62
const char * xmlSaftSubeventId
Definition: Factory.cxx:53
const guint32 PMODE_VERBOSE
Definition: Device.h:295
std::string tr_formatDate(guint64 time, guint32 pmode)
Definition: Device.cxx:513
const char * xmlMasks
WR event masks to snoop.
Definition: Factory.cxx:35
const char * xmlSaftSingleEvent
Definition: Factory.cxx:55
std::string tr_formatActionEvent(guint64 id, guint32 pmode)
Definition: Device.cxx:541
const char * xmlEventFormat
Definition: Factory.cxx:57
const char * commandRunMainloop
Command to invoke the glib/dbus mainloop.
Definition: Factory.cxx:64
#define NON_IO_CONDITION_LABEL
this marks conditions that are not input conditions:
Definition: Definitions.h:27
#define IO_CONDITION_OFFSET
Definition: Definitions.h:23
#define SAFT_DABC_TRIGTYPE
tag the timing events with special trigger type.
Definition: Definitions.h:53
Hadaq subevent structure.
Definition: defines.h:262