DABC (Data Acquisition Backbone Core)  2.9.9
Device.cxx
Go to the documentation of this file.
1 /********************************************************************
2  * The Data Acquisition Backbone Core (DABC)
3  ********************************************************************
4  * Copyright (C) 2009-
5  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
6  * Planckstr. 1
7  * 64291 Darmstadt
8  * Germany
9  * Contact: http://dabc.gsi.de
10  ********************************************************************
11  * This software can be used under the GPL license agreements as stated
12  * in LICENSE.txt file which is part of the distribution.
13  ********************************************************************/
14 #include "saftdabc/Device.h"
15 
16 #include "dabc/logging.h"
17 #include "dabc/Command.h"
18 #include "dabc/DataTransport.h"
19 
20 
21 #include "mbs/MbsTypeDefs.h"
22 
23 #include "saftdabc/Definitions.h"
24 #include "saftdabc/Input.h"
25 
26 
27 
28 
29 saftdabc::Device::Device (const std::string &name, dabc::Command cmd) :
30  dabc::Device (name),fConditionMutex(true)
31 {
32 
33 #ifndef DABC_SAFT_USE_2_0
34  Gio::init(); // required at the beginnning !
35 #endif
36  fBoardName = Cfg (saftdabc::xmlDeviceName, cmd).AsStr (name);
37 
38 
39 #ifdef DABC_SAFT_USE_2_0
40  std::map<std::string, std::string> devices = saftlib::SAFTd_Proxy::create()->getDevices();
41 #else
42  fGlibMainloop= Glib::MainLoop::create(); //Glib::MainLoop::create(true) to run immediately?
43  std::map<Glib::ustring, Glib::ustring> devices = saftlib::SAFTd_Proxy::create()->getDevices();
44 #endif
45 
46  fTimingReceiver = saftlib::TimingReceiver_Proxy::create(devices[fBoardName]);
47 
48 
49 // TODO: export some interactive commands for web interface
50  CreateCmdDef (saftdabc::commandRunMainloop);
51  CreatePar (saftdabc::parEventRate).SetRatemeter (false, 3.).SetUnits ("Events");
52 
53  SetDevInfoParName("SaftDeviceInfo");
54  CreatePar(fDevInfoName, "info").SetSynchron(true, 2., false).SetDebugLevel(2);
55  // PublishPars ("$CONTEXT$/SaftDevice");
56 // note that access to web parameters is blocked after mainloop is executed in device thread!
57 
58  DOUT1("Created SAFTDABC device %s\n",fBoardName.c_str());
59 }
60 
62 {
63  DOUT1("saftdabc::Device::OnThreadAssigned()...");
65 
66  // we better start main loop in command execution context of device
67  // RunGlibMainLoop(); // JAM immediately stay in main loop after thread has been started. does it work?
68  //bool res=Submit(dabc::Command(saftdabc::commandRunMainloop)); // postpone mainloop into command execute
69  // DOUT1("saftdabc::Device::OnThreadAssigned() is leaving with mainloop command result=%s!",DBOOL(res));
70 }
71 
72 
74 {
75  // TODO: put mainloop into background thread here?
76 #ifdef DABC_SAFT_USE_2_0
77  DOUT1("WARNING: No GlibMainLoop for saftlib > 2.0, not started!");
78 #else
79  DOUT1("RunGlibMainLoop starts.");
80  fGlibMainloop->run();
81  DOUT1("RunGlibMainLoop after fGlibMainloop->run();");
82 #endif
83 }
84 
85 
87 {
88  DOUT1("saftdabc::Device destructor \n");
89  // NOTE: all time consuming cleanups and delete board is moved to object cleanup due to dabc shutdown mechanisms
90 }
91 
93 {
94  DOUT1("saftdabc::Device DestroyByOwnThread()was called \n");
95  // optionally clenaup something here?
96  //ClearConditions();
97 #ifndef DABC_SAFT_USE_2_0
98  fGlibMainloop->quit();
99 #endif
100 
102 }
103 
104 
105 
106 
108 {
109  //ClearConditions();
110  //fGlibMainloop->quit();
112 }
113 
115 {
116  // probably we have to define special command to register conditions first and then run
117  // main glib context loop here?
118 
119 
120 
121 
122  // TODO: implement generic commands for:
123  // start stop acquisition
124  // open close file -> to readout module
125  // enable/disable trigger
126  // reset pexor/frontends (with virtual methods for user)
127  // init frontends (with virtual methods for user)
128 
129  DOUT1 ("saftdabc::Device::ExecuteCommand- %s", cmd.GetName ());
130  bool res = false;
132  {
133  DOUT1("Executing Command %s ", saftdabc::commandRunMainloop);
134  RunGlibMainLoop();
135  return cmd_bool (res);;
136  }
137 // else if (cmd.IsName (saftdabc::commandStopAcq))
138 // {
139 // DOUT1("Executing Command %s ", saftdabc::commandStopAcq);
140 // res = StopAcquisition ();
141 // return cmd_bool (res);;
142 // }
143 // else if (cmd.IsName (saftdabc::commandInitAcq))
144 // {
145 // DOUT1("Executing Command %s ", saftdabc::commandInitAcq);
146 // res = InitDAQ ();
147 // return cmd_bool (res == 0);
148 // }
149 
150 // else
151  return dabc::Device::ExecuteCommand (cmd);
152 }
153 
155 {
156  dabc::PortRef portref = port;
157  saftdabc::Input* dinput = new saftdabc::Input (this);
158  DOUT0(
159  "~~~~~~~~~~~~~~~~~ saftdabc::Device::CreateTransport port %s isinp %s", portref.ItemName ().c_str (), DBOOL (portref.IsInput ()));
160 
161  if (!dinput->Read_Init(port, cmd)) {
162  EOUT("Input object for %s cannot be initialized", portref.ItemName ().c_str ());
163  delete dinput;
164  return 0;
165  }
166 
167  dabc::InputTransport* transport =new dabc::InputTransport(cmd, portref, dinput, true);
168  dinput->SetTransportRef(transport); // provide back reference for callback mode
169  DOUT1("saftdabc::Device::CreateTransport creates new transport instance %p", transport);
170  DOUT1 ("Device thread %p, %s\n", thread ().GetObject (), thread ().GetName ());
171  return transport;
172 }
173 
174 
175 
176 
177 
178 void saftdabc::Device::SetInfo(const std::string &info, bool forceinfo)
179 {
180 // DOUT0("SET INFO: %s", info.c_str());
181 
183 
184  if (!fDevInfoName.empty()) par = Par(fDevInfoName);
185 
186  par.SetValue(info);
187  if (forceinfo)
188  par.FireModified();
189 }
190 
191 
192 
193 bool saftdabc::Device::RegisterInputCondition(saftdabc::Input* receiver, std::string& name)
194 {
195  if(receiver==0) return false;
196 
197  try{
198  dabc::LockGuard gard(fConditionMutex);
199  bool found=false;
200  const char* ioname=name.c_str(); // JAM need this hop because of map with Glib::ustring? better copy as is...
201 
202 
203 #ifdef DABC_SAFT_USE_2_0
204 std::map<std::string, std::string> inputs = fTimingReceiver->getInputs();
205  //
206  // // here check if input names from config exist in the input list:
207  for (std::map<std::string, std::string>::iterator it=inputs.begin(); it!=inputs.end(); ++it)
208 
209 #else
210  std::map<std::string, std::string> devices std::map< Glib::ustring, Glib::ustring > inputs = fTimingReceiver->getInputs();
211  //
212  // // here check if input names from config exist in the input list:
213  for (std::map<Glib::ustring,Glib::ustring>::iterator it=inputs.begin(); it!=inputs.end(); ++it)
214 #endif
215 
216  {
217  if (it->first == ioname)
218  {
219  found=true;
220  break;
221  }
222  }
223  if(!found) return false;
224 
225  // TODO: fix id definitions for appropriate inputs in dabc data stream!
226  // up to now we append descriptions to dabc timing events
227 #ifdef DABC_SAFT_USE_2_0
228  uint64_t prefix;
229 #else
230  guint64 prefix;
231 #endif
232  prefix = ECA_EVENT_ID_LATCH + (fMap_PrefixName.size()*2);
233 
234 
235  bool rev =
236  RegisterEventCondition (receiver, prefix, -2, IO_CONDITION_OFFSET,
238 
239  if(rev)
240  {
241  fMap_PrefixName[ioname] = prefix; // TODO: instead of variable prefix mappings, usee fix id definitions for dabc data stream!
242  DOUT0("Registered input condition for %s with prefix 0x%lx", ioname, prefix);
243  SetInfo(dabc::format("Registered input condition for %s with prefix 0x%lx", ioname, prefix));
244  }
245  else
246  {
247  DOUT0("Error registering input condition %s ", ioname);
248  return false;
249  }
250  /* Setup the event */
251 
252 #ifdef DABC_SAFT_USE_2_0
253  std::shared_ptr<saftlib::Input_Proxy> input = saftlib::Input_Proxy::create(inputs[ioname]);
254  #else
255  Glib::RefPtr<saftlib::Input_Proxy> input = saftlib::Input_Proxy::create(inputs[ioname]);
256 #endif
257 
258  input->setEventEnable(false);
259  input->setEventPrefix(prefix);
260  input->setEventEnable(true);
261 
262  DOUT0("RegisterInputCondition: Input event is enabled."); // any more infos to show here?
263  return true;
264 
265 
266 
267 }
268 
269 #ifdef DABC_SAFT_USE_2_0
270  catch (const saftbus::Error& error)
271  {
272  /* Catch error(s) */
273  EOUT("SAFTbus error %s in RegisterInputCondition for %s ", error.what().c_str(), name.c_str());
274  return false;
275 
276  }
277 #else
278  catch (const Glib::Error& error)
279  {
280  /* Catch error(s) */
281  EOUT("Glib error %s in RegisterInputCondition for %s ", error.what().c_str(), name.c_str());
282  return false;
283 
284  }
285 #endif
286 
287 
288 }
289 
290 // todo: additional function arguments for condition flags (bool or another flagmask?)
291 
292 #ifdef DABC_SAFT_USE_2_0
293 bool saftdabc::Device::RegisterEventCondition (saftdabc::Input* receiver, uint64_t id, uint64_t mask, int64_t offset,
294  unsigned char flags)
295 #else
296 bool saftdabc::Device::RegisterEventCondition (saftdabc::Input* receiver, guint64 id, guint64 mask, gint64 offset,
297  unsigned char flags)
298 #endif
299 {
300  if (receiver == 0)
301  return false;
302  bool acconflict = ((flags & SAFT_DABC_ACCEPT_CONFLICT)== SAFT_DABC_ACCEPT_CONFLICT);
303  bool acdelayed = ((flags & SAFT_DABC_ACCEPT_DELAYED)== SAFT_DABC_ACCEPT_DELAYED);
304  bool acearly = ((flags & SAFT_DABC_ACCEPT_EARLY)== SAFT_DABC_ACCEPT_EARLY);
305  bool aclate = ((flags & SAFT_DABC_ACCEPT_LATE)== SAFT_DABC_ACCEPT_LATE);
306 
307  try
308  {
309  dabc::LockGuard gard(fConditionMutex);
310  fActionSinks.push_back (saftlib::SoftwareActionSink_Proxy::create (fTimingReceiver->NewSoftwareActionSink ("")));
311  fActionSinks.back()->OverflowCount.connect(sigc::mem_fun (receiver, &saftdabc::Input::OverflowHandler));
312  fConditionProxies.push_back (
313  saftlib::SoftwareCondition_Proxy::create (fActionSinks.back ()->NewCondition (true, id, mask, offset)));
314  fConditionProxies.back ()->Action.connect (sigc::mem_fun (receiver, &saftdabc::Input::EventHandler));
315 
316  fConditionProxies.back ()->setAcceptConflict (acconflict);
317  fConditionProxies.back ()->setAcceptDelayed (acdelayed);
318  fConditionProxies.back ()->setAcceptEarly (acearly);
319  fConditionProxies.back ()->setAcceptLate (aclate);
320 
321  fConditionProxies.back ()->Disown (); // do we need this here?
322 
323  // DOUT0("RegisterEventCondition: Creating condition proxy %s done.",fConditionProxies.back()->get_name().c_str());
324  // JAM the above does not work since currently saftlib breaks interface inheritance to Gio::Dbus::Proxy !
325 
326  DOUT0(
327  "RegisterEventCondition: id=0x%lx , mask=0x%lx , offset=0x%lx , early=%d, late=%d, conflict=%d, delayed=%d", id, mask, offset, acearly, aclate, acconflict, acdelayed);
328  // any more infos to show here?
329  SetInfo (
330  dabc::format (
331  "RegisterEventCondition: id=0x%lx , mask=0x%lx , offset=0x%lx , early=%d, late=%d, conflict=%d, delayed=%d",
332  id, mask, offset, acearly, aclate, acconflict, acdelayed));
333  return true;
334  }
335 
336 
337 #ifdef DABC_SAFT_USE_2_0
338  catch (const saftbus::Error& error)
339  {
340  /* Catch error(s) */
341  EOUT(
342  "SAFTbus error %s in RegisterEventCondition for id=0x%lx , mask=0x%lx , offset=0x%lx , early=%d, late=%d, conflict=%d, delayed=%d", error.what().c_str(), id, mask, offset, acearly, aclate, acconflict, acdelayed);
343  return false;
344  }
345 #else
346  catch (const Glib::Error& error)
347  {
348  /* Catch error(s) */
349  EOUT(
350  "Glib error %s in RegisterEventCondition for id=0x%lx , mask=0x%lx , offset=0x%lx , early=%d, late=%d, conflict=%d, delayed=%d", error.what().c_str(), id, mask, offset, acearly, aclate, acconflict, acdelayed);
351  return false;
352 
353  }
354 #endif
355 }
356 
357 
358 #ifdef DABC_SAFT_USE_2_0
359  const std::string saftdabc::Device::GetInputDescription(uint64_t event)
360 #else
361  const std::string saftdabc::Device::GetInputDescription (guint64 event)
362 #endif
363 {
364  try
365  {
366  dabc::LockGuard gard(fConditionMutex);
367 #ifdef DABC_SAFT_USE_2_0
368  std::string catched_io = NON_IO_CONDITION_LABEL ;//"WR_Event";
369  for (std::map<std::string, uint64_t>::iterator it = fMap_PrefixName.begin (); it != fMap_PrefixName.end (); ++it)
370 #else
371  Glib::ustring catched_io = NON_IO_CONDITION_LABEL ;//"WR_Event";
372  for (std::map<Glib::ustring, guint64>::iterator it = fMap_PrefixName.begin (); it != fMap_PrefixName.end (); ++it)
373 #endif
374  {
375  if (event == it->second)
376  {
377  catched_io = it->first;
378  }
379  } /* Rising */
380 
381 #ifdef DABC_SAFT_USE_2_0
382  for (std::map<std::string, uint64_t>::iterator it = fMap_PrefixName.begin (); it != fMap_PrefixName.end (); ++it)
383 #else
384  for (std::map<Glib::ustring, guint64>::iterator it = fMap_PrefixName.begin (); it != fMap_PrefixName.end (); ++it)
385 #endif
386  {
387  if (event - 1 == it->second)
388  {
389  catched_io = it->first;
390  }
391  } /* Falling */
392 
393  if (catched_io != NON_IO_CONDITION_LABEL)
394  {
395  if ((event & 1))
396  {
397  catched_io.append (" Rising");
398  }
399  else
400  {
401  catched_io.append (" Falling");
402  }
403  }
404 #ifdef DABC_SAFT_USE_2_0
405  return catched_io;
406 #else
407  return catched_io.raw ();
408 #endif
409 
410  }
411 
412 #ifdef DABC_SAFT_USE_2_0
413  catch (const saftbus::Error& error)
414 #else
415  catch (const Glib::Error& error)
416 #endif
417  {
418  /* Catch error(s) */
419  EOUT("Error %s in GetInputDescription", error.what().c_str());
420  return std::string ("NONE");
421  }
422 
423 }
424 
425 void saftdabc::Device::AddEventStatistics (unsigned numevents)
426 {
427  Par (saftdabc::parEventRate).SetValue (numevents);
428 
429 }
430 
432 {
433 
434  try
435  {
436  dabc::LockGuard gard(fConditionMutex);
437  // first destroy conditions if possible:
438  // we use our existing handles in container:_
439 
440 #ifdef DABC_SAFT_USE_2_0
441  for (std::vector<std::shared_ptr<saftlib::SoftwareCondition_Proxy> >::iterator cit = fConditionProxies.begin ();
442  cit != fConditionProxies.end (); ++cit)
443  {
444  std::shared_ptr<saftlib::SoftwareCondition_Proxy> destroy_condition = *cit;
445 #else
446 
447  for (std::vector<Glib::RefPtr<saftlib::SoftwareCondition_Proxy> >::iterator cit = fConditionProxies.begin ();
448  cit != fConditionProxies.end (); ++cit)
449  {
450  Glib::RefPtr < saftlib::SoftwareCondition_Proxy > destroy_condition = *cit;
451 #endif
452 
453  if (destroy_condition->getDestructible () && (destroy_condition->getOwner () == ""))
454  {
455  DOUT0("ClearConditions will destroy condition of ID:0x%lx .", destroy_condition->getID());
456  destroy_condition->Destroy ();
457  // JAM: why does saft-io-ctl example use here container
458  // std::vector <Glib::RefPtr<saftlib::InputCondition_Proxy> > prox;
459  // with statements like:
460  // prox.push_back ( saftlib::InputCondition_Proxy::create(name));
461  // prox.back()->Destroy();
462  // non optimized code or mandatory for some reasons?
463  //
464 
465  }
466  else
467  {
468 
469  DOUT0(
470  "ClearConditions found non destructible condition of ID:0x%x , owner=%s", destroy_condition->getID(), destroy_condition->getOwner().c_str());
471  }
472  }
473 
474  // clear registered proxies
475  fConditionProxies.clear();
476 
477 
478  // then clean up action sinks:
479  // the remote action sinks in saftd service will have removed their conditions on Destroy()
480  // do we need to get rid of the sinks explicitely?
481  // for the moment, just remove references, seems that dtor will send appropriate signals to service JAM2016-9
482  fActionSinks.clear();
483 
484  }
485 
486  #ifdef DABC_SAFT_USE_2_0
487  catch (const saftbus::Error& error)
488  {
489  /* Catch error(s) */
490  EOUT("SAFTbus error %s in ClearConditions", error.what().c_str());
491 
492 }
493 #else
494  catch (const Glib::Error& error)
495  {
496  /* Catch error(s) */
497  EOUT("Glib error %s in ClearConditions", error.what().c_str());
498  return false;
499 
500  }
501 #endif
502  return true;
503 }
504 
505 
507 
510 #ifdef DABC_SAFT_USE_2_0
511 std::string saftdabc::tr_formatDate(uint64_t time, uint32_t pmode)
512 #else
513 std::string saftdabc::tr_formatDate(guint64 time, guint32 pmode)
514 #endif
515 {
516  uint64_t ns = time % 1000000000;
517  time_t s = time / 1000000000;
518  struct tm *tm = gmtime(&s);
519  char date[40];
520  char full[80];
521  std::string temp;
522 
523  if (pmode & PMODE_VERBOSE) {
524  strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", tm);
525  snprintf(full, sizeof(full), "%s.%09ld", date, (long)ns);
526  }
527  else if (pmode & PMODE_DEC)
528  snprintf(full, sizeof(full), "0d%lu.%09ld",s,(long)ns);
529  else
530  snprintf(full, sizeof(full), "0x%016llx", (unsigned long long)time);
531 
532  temp = full;
533 
534  return temp;
535 } //tr_formatDate
536 
537 /* format EvtID to a string */
538 #ifdef DABC_SAFT_USE_2_0
539 std::string saftdabc::tr_formatActionEvent(uint64_t id, uint32_t pmode)
540 #else
541 std::string saftdabc::tr_formatActionEvent(guint64 id, guint32 pmode)
542 #endif
543 {
544  std::stringstream full;
545  std::string fmt = "";
546  int width = 0;
547 
548  if (pmode & PMODE_HEX) {full << std::hex << std::setfill('0'); width = 16; fmt = "0x";}
549  if (pmode & PMODE_DEC) {full << std::dec << std::setfill('0'); width = 20; fmt = "0d";}
550  if (pmode & PMODE_VERBOSE) {
551  full << " FID: " << fmt << std::setw(1) << ((id >> 60) & 0xf);
552  full << " GID: " << fmt << std::setw(4) << ((id >> 48) & 0xfff);
553  full << " EVTNO: " << fmt << std::setw(4) << ((id >> 36) & 0xfff);
554  full << " SID: " << fmt << std::setw(4) << ((id >> 24) & 0xfff);
555  full << " BPID: " << fmt << std::setw(5) << ((id >> 14) & 0x3fff);
556  full << " RES: " << fmt << std::setw(4) << (id & 0x3ff);
557  }
558  else full << " EvtID: " << fmt << std::setw(width) << std::setfill('0') << id;
559 
560  return full.str();
561 } //tr_formatActionEvent
562 
563 #ifdef DABC_SAFT_USE_2_0
564 std::string saftdabc::tr_formatActionParam(uint64_t param, uint32_t evtNo, uint32_t pmode)
565 #else
566 std::string saftdabc::tr_formatActionParam(guint64 param, guint32 evtNo, guint32 pmode)
567 #endif
568 {
569  std::stringstream full;
570  std::string fmt = "";
571  int width = 0;
572 
573  if (pmode & PMODE_HEX) {full << std::hex << std::setfill('0'); width = 16; fmt = "0x";}
574  if (pmode & PMODE_DEC) {full << std::dec << std::setfill('0'); width = 20; fmt = "0d";}
575 
576  switch (evtNo) {
577  case 0x0 :
578  // add some code
579  break;
580  case 0x1 :
581  // add some code
582  break;
583  default :
584  full << " Param: " << fmt << std::setw(width) << param;
585  } // switch evtNo
586 
587  return full.str();
588 } // tr_formatActionParam
589 
590 #ifdef DABC_SAFT_USE_2_0
591 std::string saftdabc::tr_formatActionFlags(uint16_t flags, uint64_t delay, uint32_t pmode)
592 #else
593 std::string saftdabc::tr_formatActionFlags(guint16 flags, guint64 delay, guint32 pmode)
594 #endif
595 {
596  std::stringstream full;
597 
598  full << "";
599 
600  if (flags) {
601  full << "!";
602  if (flags & 1) full << "late (by " << delay << " ns)";
603  if (flags & 2) full << "early (by " << -delay << " ns)";
604  if (flags & 4) full << "conflict (delayed by " << delay << " ns)";
605  if (flags & 8) full << "delayed (by " << delay << " ns)";
606  } // if flags
607 
608  return full.str();
609 } // tr_formatActionFlags
610 
611 
612 
Represents command with its arguments.
Definition: Command.h:99
virtual void ObjectCleanup()
Central cleanup method for worker.
Definition: Device.cxx:35
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
Definition: Device.cxx:43
Special info parameter class.
Definition: Parameter.h:300
Lock guard for posix mutex.
Definition: threads.h:127
bool SetValue(const RecordField &v)
Set parameter value.
Definition: Parameter.h:205
void FireModified()
Can be called by user to signal framework that parameter was modified.
Definition: Parameter.cxx:555
Reference on the dabc::Port class
Definition: Port.h:195
bool IsInput() const
Returns true if it is input port.
Definition: Port.h:199
Reference on the arbitrary object
Definition: Reference.h:73
const char * GetName() const
Return name of referenced object, if object not assigned, returns "---".
Definition: Reference.cxx:167
bool IsName(const char *name) const
Returns true if object name is the same as specified one.
Definition: Reference.cxx:177
std::string ItemName(bool compact=true) const
Produce string, which can be used as name argument in dabc::mgr.FindItem(name) call.
Definition: Reference.cxx:241
Base class for transport implementations.
Definition: Transport.h:37
virtual void OnThreadAssigned()
Definition: Worker.h:392
virtual bool DestroyByOwnThread()
Inherited method from Object, invoked at the moment when worker requested to be destroyed by its thre...
Definition: Worker.cxx:194
void RunGlibMainLoop()
this function keeps glib main loop alive.
Definition: Device.cxx:73
virtual bool DestroyByOwnThread()
here we may insert some actions to the device cleanup methods
Definition: Device.cxx:92
const std::string GetInputDescription(guint64 event)
Return text description of input belonging to given event id, e.g.
Definition: Device.cxx:361
virtual void ObjectCleanup()
Central cleanup method for worker.
Definition: Device.cxx:107
virtual ~Device()
Definition: Device.cxx:86
Device(const std::string &name, dabc::Command cmd)
Definition: Device.cxx:29
bool ClearConditions()
clean up all existing saftlib conditions
Definition: Device.cxx:431
void OnThreadAssigned()
need to start timeout here
Definition: Device.cxx:61
void SetInfo(const std::string &info, bool forceinfo=true)
set info parameter.
Definition: Device.cxx:178
bool RegisterEventCondition(saftdabc::Input *receiver, guint64 id, guint64 mask, gint64 offset, unsigned char acceptflags)
Register input event per id to snoop on NewCondition(bool active, guint64 id, guint64 mask,...
Definition: Device.cxx:296
virtual dabc::Transport * CreateTransport(dabc::Command cmd, const dabc::Reference &port)
Definition: Device.cxx:154
virtual int ExecuteCommand(dabc::Command cmd)
Main method where commands are executed.
Definition: Device.cxx:114
void AddEventStatistics(unsigned numevents)
add numevents to the event ratemeter.
Definition: Device.cxx:425
bool RegisterInputCondition(saftdabc::Input *receiver, std::string &ioname)
Register input of name to snoop on NewCondition(bool active, guint64 id, guint64 mask,...
Definition: Device.cxx:193
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
void OverflowHandler(guint64 count)
This is a signalhandler that treats overflow counter events.
Definition: Input.cxx:584
void SetTransportRef(dabc::InputTransport *trans)
Definition: Input.cxx:47
virtual bool Read_Init(const dabc::WorkerRef &wrk, const dabc::Command &cmd)
Initialize data input, using port and command.
Definition: Input.cxx:52
#define DOUT0(args ...)
Definition: logging.h:156
#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
const char * parEventRate
Name of event rate parameter.
Definition: Factory.cxx:66
const guint32 PMODE_DEC
Definition: Device.h:293
const guint32 PMODE_HEX
Definition: Device.h:294
std::string tr_formatActionParam(guint64 param, guint32 evtNo, guint32 pmode)
Definition: Device.cxx:566
const guint32 PMODE_VERBOSE
Definition: Device.h:295
const char * xmlDeviceName
name of the saft device, e.g.
Definition: Factory.cxx:29
std::string tr_formatDate(guint64 time, guint32 pmode)
Definition: Device.cxx:513
std::string tr_formatActionEvent(guint64 id, guint32 pmode)
Definition: Device.cxx:541
std::string tr_formatActionFlags(guint16 flags, guint64 delay, guint32 pmode)
Definition: Device.cxx:593
const char * commandRunMainloop
Command to invoke the glib/dbus mainloop.
Definition: Factory.cxx:64
#define SAFT_DABC_ACCEPT_CONFLICT
Definition: Definitions.h:46
#define NON_IO_CONDITION_LABEL
this marks conditions that are not input conditions:
Definition: Definitions.h:27
#define ECA_EVENT_ID_LATCH
JAM we use the same definitions from saft-io-ctl.
Definition: Definitions.h:21
#define SAFT_DABC_ACCEPT_LATE
these flags are dabc proprietary up to now, since saftlib uses separate boolean setters:
Definition: Definitions.h:44
#define IO_CONDITION_OFFSET
Definition: Definitions.h:23
#define SAFT_DABC_ACCEPT_DELAYED
Definition: Definitions.h:47
#define SAFT_DABC_ACCEPT_EARLY
Definition: Definitions.h:45