CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BU.cc
Go to the documentation of this file.
1 //
3 // BU
4 // --
5 //
6 // Emilio Meschi <emilio.meschi@cern.ch>
7 // Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
9 
10 
12 
14 
17 #include "EventFilter/FEDInterface/interface/GlobalEventNumber.icc"
18 
19 #include "xoap/SOAPEnvelope.h"
20 #include "xoap/SOAPBody.h"
21 #include "xoap/domutils.h"
22 
23 #include <netinet/in.h>
24 #include <sstream>
25 
26 
27 using namespace std;
28 using namespace evf;
29 
30 
32 // construction/destruction
34 
35 //______________________________________________________________________________
36 BU::BU(xdaq::ApplicationStub *s)
37  : xdaq::Application(s)
38  , log_(getApplicationLogger())
39  , buAppDesc_(getApplicationDescriptor())
40  , fuAppDesc_(0)
41  , buAppContext_(getApplicationContext())
42  , fsm_(this)
43  , gui_(0)
44  , evtNumber_(0)
45  , isBuilding_(false)
46  , isSending_(false)
47  , isHalting_(false)
48  , wlBuilding_(0)
49  , asBuilding_(0)
50  , wlSending_(0)
51  , asSending_(0)
52  , wlMonitoring_(0)
53  , asMonitoring_(0)
54  , instance_(0)
55  , runNumber_(0)
56  , memUsedInMB_(0.0)
57  , deltaT_(0.0)
58  , deltaN_(0)
59  , deltaSumOfSquares_(0)
60  , deltaSumOfSizes_(0)
61  , throughput_(0.0)
62  , average_(0.0)
63  , rate_(0.0)
64  , rms_(0.0)
65  , nbEventsInBU_(0)
66  , nbEventsRequested_(0)
67  , nbEventsBuilt_(0)
68  , nbEventsSent_(0)
69  , nbEventsDiscarded_(0)
70  , mode_("RANDOM")
71  , replay_(false)
72  , crc_(true)
73  , overwriteEvtId_(true)
74  , overwriteLsId_(false)
75  , fakeLsUpdateSecs_(23)
76  , firstEvent_(1)
77  , queueSize_(32)
78  , eventBufferSize_(0x400000)
79  , msgBufferSize_(32768)
80  , fedSizeMax_(65536)
81  , fedSizeMean_(1024)
82  , fedSizeWidth_(1024)
83  , useFixedFedSize_(false)
84  , monSleepSec_(1)
85  , fakeLs_(0)
86  , gaussianMean_(0.0)
87  , gaussianWidth_(1.0)
88  , monLastN_(0)
89  , monLastSumOfSquares_(0)
90  , monLastSumOfSizes_(0)
91  , sumOfSquares_(0)
92  , sumOfSizes_(0)
93  , i2oPool_(0)
94 {
95  // initialize state machine
96  fsm_.initialize<evf::BU>(this);
97 
98  // initialize application info
99  url_ =
100  getApplicationDescriptor()->getContextDescriptor()->getURL()+"/"+
101  getApplicationDescriptor()->getURN();
102  class_ =getApplicationDescriptor()->getClassName();
103  instance_=getApplicationDescriptor()->getInstance();
104  hostname_=getApplicationDescriptor()->getContextDescriptor()->getURL();
105  sourceId_=class_.toString()+instance_.toString();
106 
107  // i2o callbacks
108  i2o::bind(this,&BU::I2O_BU_ALLOCATE_Callback,I2O_BU_ALLOCATE,XDAQ_ORGANIZATION_ID);
109  i2o::bind(this,&BU::I2O_BU_DISCARD_Callback, I2O_BU_DISCARD, XDAQ_ORGANIZATION_ID);
110 
111  // allocate i2o memery pool
112  string i2oPoolName=sourceId_+"_i2oPool";
113  try {
114  toolbox::mem::HeapAllocator *allocator=new toolbox::mem::HeapAllocator();
115  toolbox::net::URN urn("toolbox-mem-pool",i2oPoolName);
116  toolbox::mem::MemoryPoolFactory* poolFactory=
117  toolbox::mem::getMemoryPoolFactory();
118  i2oPool_=poolFactory->createPool(urn,allocator);
119  }
121  string s="Failed to create pool: "+i2oPoolName;
122  LOG4CPLUS_FATAL(log_,s);
123  XCEPT_RETHROW(xcept::Exception,s,e);
124  }
125 
126  // web interface
127  xgi::bind(this,&evf::BU::webPageRequest,"Default");
128  gui_=new WebGUI(this,&fsm_);
129  gui_->setSmallAppIcon("/rubuilder/bu/images/bu32x32.gif");
130  gui_->setLargeAppIcon("/rubuilder/bu/images/bu64x64.gif");
131 
132  vector<toolbox::lang::Method*> methods=gui_->getMethods();
133  vector<toolbox::lang::Method*>::iterator it;
134  for (it=methods.begin();it!=methods.end();++it) {
135  if ((*it)->type()=="cgi") {
136  string name=static_cast<xgi::MethodSignature*>(*it)->name();
137  xgi::bind(this,&evf::BU::webPageRequest,name);
138  }
139  }
140  xgi::bind(this,&evf::BU::customWebPage,"customWebPage");
141 
142 
143  // export parameters to info space(s)
145 
146  // findRcmsStateListener
148 
149  // compute parameters for fed size generation (a la Emilio)
152  (0.5*
153  (1+std::sqrt
154  (1.0+4.0*
155  fedSizeWidth_.value_*fedSizeWidth_.value_/
156  fedSizeMean_.value_/fedSizeMean_.value_))));
157 
158  // start monitoring thread, once and for all
160 
161  // propagate crc flag to BUEvent
163 }
164 
165 
166 //______________________________________________________________________________
168 {
169  while (!events_.empty()) { delete events_.back(); events_.pop_back(); }
170 }
171 
172 
174 // implementation of member functions
176 
177 //______________________________________________________________________________
178 bool BU::configuring(toolbox::task::WorkLoop* wl)
179 {
180  isHalting_=false;
181  try {
182  LOG4CPLUS_INFO(log_,"Start configuring ...");
183  reset();
184  LOG4CPLUS_INFO(log_,"Finished configuring!");
185  fsm_.fireEvent("ConfigureDone",this);
186  }
187  catch (xcept::Exception &e) {
188  string msg = "configuring FAILED: " + (string)e.what();
189  fsm_.fireFailed(msg,this);
190  }
191 
192  return false;
193 }
194 
195 
196 //______________________________________________________________________________
197 bool BU::enabling(toolbox::task::WorkLoop* wl)
198 {
199  isHalting_=false;
200  try {
201  LOG4CPLUS_INFO(log_,"Start enabling ...");
202  // determine valid fed ids (assumes Playback EP is already configured hence PBRDP::instance
203  // not null in case we are playing back)
205  for (unsigned int i=0;i<(unsigned int)FEDNumbering::MAXFEDID+1;i++)
206  if (FEDNumbering::inRange(i)) validFedIds_.push_back(i);
207  }
208  else{
209  for (unsigned int i=0;i<(unsigned int)FEDNumbering::MAXFEDID+1;i++)
210  if (FEDNumbering::inRangeNoGT(i)) validFedIds_.push_back(i);
211  }
214  LOG4CPLUS_INFO(log_,"Finished enabling!");
215  fsm_.fireEvent("EnableDone",this);
216  }
217  catch (xcept::Exception &e) {
218  string msg = "enabling FAILED: " + (string)e.what();
219  fsm_.fireFailed(msg,this);
220  }
221 
222  return false;
223 }
224 
225 
226 //______________________________________________________________________________
227 bool BU::stopping(toolbox::task::WorkLoop* wl)
228 {
229  try {
230  LOG4CPLUS_INFO(log_,"Start stopping :) ...");
231 
232  if (0!=PlaybackRawDataProvider::instance()) { /*&&
233  (!replay_.value_||nbEventsBuilt_<(uint32_t)events_.size())) { */
234  lock();
235  freeIds_.push(events_.size());
236  unlock();
237  postBuild();
238  while (!builtIds_.empty()) {
239  LOG4CPLUS_INFO(log_,"wait to flush ... #builtIds="<<builtIds_.size());
240  ::sleep(1);
241  }
242  // let the playback go to the last event and exit
244  while (!PlaybackRawDataProvider::instance()->areFilesClosed()) usleep(1000000);
245  usleep(100000);
246  }
247 
248  lock();
249  builtIds_.push(events_.size());
250  unlock();
251 
252  postSend();
253  while (!sentIds_.empty()) {
254  LOG4CPLUS_INFO(log_,"wait to flush ...");
255  ::sleep(1);
256  }
257  reset();
258  //postBuild();
259  /* this is not needed and should not run if reset is called
260  if (0!=PlaybackRawDataProvider::instance()&&
261  (replay_.value_&&nbEventsBuilt_>=(uint32_t)events_.size())) {
262  lock();
263  freeIds_.push(events_.size());
264  unlock();
265  postBuild();
266  }
267  */
268  LOG4CPLUS_INFO(log_,"Finished stopping!");
269  fsm_.fireEvent("StopDone",this);
270  }
271  catch (xcept::Exception &e) {
272  string msg = "stopping FAILED: " + (string)e.what();
273  fsm_.fireFailed(msg,this);
274  }
275  return false;
276 }
277 
278 
279 //______________________________________________________________________________
280 bool BU::halting(toolbox::task::WorkLoop* wl)
281 {
282  try {
283  LOG4CPLUS_INFO(log_,"Start halting ...");
284  isHalting_=true;
285  if (isBuilding_&&isSending_) {
286  lock();
287  freeIds_.push(events_.size());
288  builtIds_.push(events_.size());
289  unlock();
290  postBuild();
291  postSend();
292  }
294  (!replay_.value_||nbEventsBuilt_<(uint32_t)events_.size())) {
296  while (!PlaybackRawDataProvider::instance()->areFilesClosed()) usleep(1000000);
297  usleep(100000);
298  }
299  LOG4CPLUS_INFO(log_,"Finished halting!");
300  fsm_.fireEvent("HaltDone",this);
301  }
302  catch (xcept::Exception &e) {
303  string msg = "halting FAILED: " + (string)e.what();
304  fsm_.fireFailed(msg,this);
305  }
306  return false;
307 }
308 
309 
310 //______________________________________________________________________________
311 xoap::MessageReference BU::fsmCallback(xoap::MessageReference msg)
313 {
314  return fsm_.commandCallback(msg);
315 }
316 
317 
318 //______________________________________________________________________________
319 void BU::I2O_BU_ALLOCATE_Callback(toolbox::mem::Reference *bufRef)
320 {
321  if (isHalting_) {
322  LOG4CPLUS_WARN(log_,"Ignore BU_ALLOCATE message while halting.");
323  bufRef->release();
324  return;
325  }
326 
327  I2O_MESSAGE_FRAME *stdMsg;
328  I2O_BU_ALLOCATE_MESSAGE_FRAME *msg;
329 
330  stdMsg=(I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
331  msg =(I2O_BU_ALLOCATE_MESSAGE_FRAME*)stdMsg;
332 
333  if (0==fuAppDesc_) {
334  I2O_TID fuTid=stdMsg->InitiatorAddress;
335  fuAppDesc_=i2o::utils::getAddressMap()->getApplicationDescriptor(fuTid);
336  }
337 
338  for (unsigned int i=0;i<msg->n;i++) {
339  unsigned int fuResourceId=msg->allocate[i].fuTransactionId;
340  lock();
341  rqstIds_.push(fuResourceId);
342  postRqst();
344  nbEventsInBU_++;
345  unlock();
346  }
347 
348  bufRef->release();
349 }
350 
351 
352 //______________________________________________________________________________
353 void BU::I2O_BU_DISCARD_Callback(toolbox::mem::Reference *bufRef)
354 {
355  if (isHalting_) {
356  LOG4CPLUS_WARN(log_,"Ignore BU_DISCARD message while halting.");
357  bufRef->release();
358  return;
359  }
360 
361  I2O_MESSAGE_FRAME *stdMsg=(I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
362  I2O_BU_DISCARD_MESSAGE_FRAME*msg =(I2O_BU_DISCARD_MESSAGE_FRAME*)stdMsg;
363  unsigned int buResourceId=msg->buResourceId[0];
364 
365  lock();
366  int result=sentIds_.erase(buResourceId);
367  unlock();
368 
369  if (!result) {
370  LOG4CPLUS_ERROR(log_,"can't discard unknown buResourceId '"<<buResourceId<<"'");
371  }
372  else {
373  lock();
374  freeIds_.push(buResourceId);
375  nbEventsDiscarded_.value_++;
376  unlock();
377  postBuild();
378  }
379 
380  bufRef->release();
381 }
382 
383 
384 //______________________________________________________________________________
385 void BU::actionPerformed(xdata::Event& e)
386 {
387  gui_->monInfoSpace()->lock();
388  if (e.type()=="urn:xdata-event:ItemGroupRetrieveEvent") {
389  mode_=(0==PlaybackRawDataProvider::instance())?"RANDOM":"PLAYBACK";
390  if (0!=i2oPool_) memUsedInMB_=i2oPool_->getMemoryUsage().getUsed()*9.53674e-07;
391  else memUsedInMB_=0.0;
392  }
393  else if (e.type()=="ItemChangedEvent") {
394  string item=dynamic_cast<xdata::ItemChangedEvent&>(e).itemName();
395  if (item=="crc") BUEvent::setComputeCrc(crc_.value_);
396  }
397  gui_->monInfoSpace()->unlock();
398 }
399 
400 
401 //______________________________________________________________________________
404 {
405  string name=in->getenv("PATH_INFO");
406  if (name.empty()) name="defaultWebPage";
407  static_cast<xgi::MethodSignature*>(gui_->getMethod(name))->invoke(in,out);
408 }
409 
410 
411 //______________________________________________________________________________
414 {
415  *out<<"<html></html>"<<endl;
416 }
417 
418 
419 //______________________________________________________________________________
421 {
422  try {
423  LOG4CPLUS_INFO(log_,"Start 'building' workloop");
424  wlBuilding_=
425  toolbox::task::getWorkLoopFactory()->getWorkLoop(sourceId_+
426  "Building",
427  "waiting");
428  if (!wlBuilding_->isActive()) wlBuilding_->activate();
429  asBuilding_=toolbox::task::bind(this,&BU::building,sourceId_+"Building");
430  wlBuilding_->submit(asBuilding_);
431  isBuilding_=true;
432  }
433  catch (xcept::Exception& e) {
434  string msg = "Failed to start workloop 'building'.";
435  XCEPT_RETHROW(evf::Exception,msg,e);
436  }
437 }
438 
439 
440 //______________________________________________________________________________
441 bool BU::building(toolbox::task::WorkLoop* wl)
442 {
443  waitBuild();
444  lock();
445  unsigned int buResourceId=freeIds_.front(); freeIds_.pop();
446  unlock();
447 
448  if (buResourceId>=(uint32_t)events_.size()) {
449  LOG4CPLUS_INFO(log_,"shutdown 'building' workloop.");
450  isBuilding_=false;
451  return false;
452  }
453 
454  if (!isHalting_) {
455  BUEvent* evt=events_[buResourceId];
456  if(generateEvent(evt)) {
457  lock();
458  nbEventsBuilt_++;
459  builtIds_.push(buResourceId);
460  unlock();
461 
462  postSend();
463  }
464  else {
465  LOG4CPLUS_INFO(log_,"building:received null post");
466  lock();
467  unsigned int saveBUResourceId = buResourceId;
468  //buResourceId = freeIds_.front(); freeIds_.pop();
469  freeIds_.push(saveBUResourceId);
470  unlock();
471  isBuilding_=false;
472  return false;
473  }
474  }
475  return true;
476 }
477 
478 
479 //______________________________________________________________________________
481 {
482  try {
483  LOG4CPLUS_INFO(log_,"Start 'sending' workloop");
484  wlSending_=toolbox::task::getWorkLoopFactory()->getWorkLoop(sourceId_+
485  "Sending",
486  "waiting");
487  if (!wlSending_->isActive()) wlSending_->activate();
488 
489  asSending_=toolbox::task::bind(this,&BU::sending,sourceId_+"Sending");
490  wlSending_->submit(asSending_);
491  isSending_=true;
492  }
493  catch (xcept::Exception& e) {
494  string msg = "Failed to start workloop 'sending'.";
495  XCEPT_RETHROW(evf::Exception,msg,e);
496  }
497 }
498 
499 
500 //______________________________________________________________________________
501 bool BU::sending(toolbox::task::WorkLoop* wl)
502 {
503  waitSend();
504  lock();
505  unsigned int buResourceId=builtIds_.front(); builtIds_.pop();
506  unlock();
507 
508  if (buResourceId>=(uint32_t)events_.size()) {
509  LOG4CPLUS_INFO(log_,"shutdown 'sending' workloop.");
510  isSending_=false;
511  return false;
512  }
513 
514  if (!isHalting_) {
515  waitRqst();
516  lock();
517  unsigned int fuResourceId=rqstIds_.front(); rqstIds_.pop();
518  unlock();
519 
520  BUEvent* evt=events_[buResourceId];
521  toolbox::mem::Reference* msg=createMsgChain(evt,fuResourceId);
522 
523  lock();
524  sumOfSquares_+=(uint64_t)evt->evtSize()*(uint64_t)evt->evtSize();
525  sumOfSizes_ +=evt->evtSize();
526  nbEventsInBU_--;
527  nbEventsSent_++;
528  sentIds_.insert(buResourceId);
529  unlock();
530 
531  buAppContext_->postFrame(msg,buAppDesc_,fuAppDesc_);
532  }
533 
534  return true;
535 }
536 
537 
538 //______________________________________________________________________________
540 {
541  struct timezone timezone;
542  gettimeofday(&monStartTime_,&timezone);
543 
544  try {
545  LOG4CPLUS_INFO(log_,"Start 'monitoring' workloop");
547  toolbox::task::getWorkLoopFactory()->getWorkLoop(sourceId_+
548  "Monitoring",
549  "waiting");
550  if (!wlMonitoring_->isActive()) wlMonitoring_->activate();
551  asMonitoring_=toolbox::task::bind(this,&BU::monitoring,sourceId_+"Monitoring");
552  wlMonitoring_->submit(asMonitoring_);
553  }
554  catch (xcept::Exception& e) {
555  string msg = "Failed to start workloop 'monitoring'.";
556  XCEPT_RETHROW(evf::Exception,msg,e);
557  }
558 }
559 
560 
561 //______________________________________________________________________________
562 bool BU::monitoring(toolbox::task::WorkLoop* wl)
563 {
564  struct timeval monEndTime;
565  struct timezone timezone;
566 
567  gettimeofday(&monEndTime,&timezone);
568 
569  lock();
570  unsigned int monN =nbEventsBuilt_.value_;
571  uint64_t monSumOfSquares=sumOfSquares_;
572  unsigned int monSumOfSizes =sumOfSizes_;
573  uint64_t deltaSumOfSquares;
574  unlock();
575 
576  gui_->monInfoSpace()->lock();
577 
578  deltaT_.value_=deltaT(&monStartTime_,&monEndTime);
579  monStartTime_=monEndTime;
580 
581  deltaN_.value_=monN-monLastN_;
582  monLastN_=monN;
583 
584  deltaSumOfSquares=monSumOfSquares-monLastSumOfSquares_;
585  deltaSumOfSquares_.value_=(double)deltaSumOfSquares;
586  monLastSumOfSquares_=monSumOfSquares;
587 
588  deltaSumOfSizes_.value_=monSumOfSizes-monLastSumOfSizes_;
589  monLastSumOfSizes_=monSumOfSizes;
590 
591  if (deltaT_.value_!=0) {
592  throughput_=deltaSumOfSizes_.value_/deltaT_.value_;
593  rate_ =deltaN_.value_/deltaT_.value_;
594  }
595  else {
596  throughput_=0.0;
597  rate_ =0.0;
598  }
599 
600  double meanOfSquares,mean,squareOfMean,variance;
601 
602  if(deltaN_.value_!=0) {
603  meanOfSquares=deltaSumOfSquares_.value_/((double)(deltaN_.value_));
604  mean=((double)(deltaSumOfSizes_.value_))/((double)(deltaN_.value_));
605  squareOfMean=mean*mean;
606  variance=meanOfSquares-squareOfMean;
607  average_=deltaSumOfSizes_.value_/deltaN_.value_;
608  rms_ =std::sqrt(variance);
609  }
610  else {
611  average_=0.0;
612  rms_ =0.0;
613  }
614 
615  gui_->monInfoSpace()->unlock();
616 
617  ::sleep(monSleepSec_.value_);
618 
619  return true;
620 }
621 
622 
623 
625 // implementation of private member functions
627 
628 //______________________________________________________________________________
630 {
631  if (0==gui_) {
632  LOG4CPLUS_ERROR(log_,"No GUI, can't export parameters");
633  return;
634  }
635 
636  gui_->addMonitorParam("url", &url_);
637  gui_->addMonitorParam("class", &class_);
638  gui_->addMonitorParam("instance", &instance_);
639  gui_->addMonitorParam("hostname", &hostname_);
640  gui_->addMonitorParam("runNumber", &runNumber_);
641  gui_->addMonitorParam("stateName", fsm_.stateName());
642  gui_->addMonitorParam("memUsedInMB", &memUsedInMB_);
643  gui_->addMonitorParam("deltaT", &deltaT_);
644  gui_->addMonitorParam("deltaN", &deltaN_);
645  gui_->addMonitorParam("deltaSumOfSquares", &deltaSumOfSquares_);
646  gui_->addMonitorParam("deltaSumOfSizes", &deltaSumOfSizes_);
647  gui_->addMonitorParam("throughput", &throughput_);
648  gui_->addMonitorParam("average", &average_);
649  gui_->addMonitorParam("rate", &rate_);
650  gui_->addMonitorParam("rms", &rms_);
651 
652  gui_->addMonitorCounter("nbEvtsInBU", &nbEventsInBU_);
653  gui_->addMonitorCounter("nbEvtsRequested", &nbEventsRequested_);
654  gui_->addMonitorCounter("nbEvtsBuilt", &nbEventsBuilt_);
655  gui_->addMonitorCounter("nbEvtsSent", &nbEventsSent_);
656  gui_->addMonitorCounter("nbEvtsDiscarded", &nbEventsDiscarded_);
657 
658  gui_->addStandardParam("mode", &mode_);
659  gui_->addStandardParam("replay", &replay_);
660  gui_->addStandardParam("overwriteEvtId", &overwriteEvtId_);
661  gui_->addStandardParam("overwriteLsId", &overwriteLsId_);
662  gui_->addStandardParam("fakeLsUpdateSecs", &fakeLsUpdateSecs_);
663  gui_->addStandardParam("crc", &crc_);
664  gui_->addStandardParam("firstEvent", &firstEvent_);
665  gui_->addStandardParam("queueSize", &queueSize_);
666  gui_->addStandardParam("eventBufferSize", &eventBufferSize_);
667  gui_->addStandardParam("msgBufferSize", &msgBufferSize_);
668  gui_->addStandardParam("fedSizeMax", &fedSizeMax_);
669  gui_->addStandardParam("fedSizeMean", &fedSizeMean_);
670  gui_->addStandardParam("fedSizeWidth", &fedSizeWidth_);
671  gui_->addStandardParam("useFixedFedSize", &useFixedFedSize_);
672  gui_->addStandardParam("monSleepSec", &monSleepSec_);
673  gui_->addStandardParam("rcmsStateListener", fsm_.rcmsStateListener());
674  gui_->addStandardParam("foundRcmsStateListener",fsm_.foundRcmsStateListener());
675 
676 
678 
679  gui_->addItemChangedListener("crc",this);
680 
681 }
682 
683 
684 //______________________________________________________________________________
685 void BU::reset()
686 {
687  gui_->resetCounters();
688 
689  deltaT_ =0.0;
690  deltaN_ = 0;
691  deltaSumOfSquares_ = 0;
692  deltaSumOfSizes_ = 0;
693 
694  throughput_ =0.0;
695  average_ = 0;
696  rate_ = 0;
697  rms_ = 0;
698 
699  monLastN_ = 0;
701  monLastSumOfSizes_ = 0;
702 
703  while (events_.size()) {
704  delete events_.back();
705  events_.pop_back();
706  }
707 
708  while (!rqstIds_.empty()) rqstIds_.pop();
709  while (!freeIds_.empty()) freeIds_.pop();
710  while (!builtIds_.empty()) builtIds_.pop();
711  sentIds_.clear();
712 
713  sem_init(&lock_,0,1);
714  sem_init(&buildSem_,0,queueSize_);
715  sem_init(&sendSem_,0,0);
716  sem_init(&rqstSem_,0,0);
717 
718  for (unsigned int i=0;i<queueSize_;i++) {
719  events_.push_back(new BUEvent(i,eventBufferSize_));
720  freeIds_.push(i);
721  }
722  validFedIds_.clear();
723  fakeLs_=0;
724 }
725 
726 //______________________________________________________________________________
727 double BU::deltaT(const struct timeval *start,const struct timeval *end)
728 {
729  unsigned int sec;
730  unsigned int usec;
731 
732  sec = end->tv_sec - start->tv_sec;
733 
734  if(end->tv_usec > start->tv_usec) {
735  usec = end->tv_usec - start->tv_usec;
736  }
737  else {
738  sec--;
739  usec = 1000000 - ((unsigned int )(start->tv_usec - end->tv_usec));
740  }
741 
742  return ((double)sec) + ((double)usec) / 1000000.0;
743 }
744 
745 
746 //______________________________________________________________________________
748 {
749  // replay?
750  if (replay_.value_&&nbEventsBuilt_>=(uint32_t)events_.size())
751  {
754  return true;
755  }
756  // PLAYBACK mode
758 
759  unsigned int runNumber,evtNumber;
760 
761  FEDRawDataCollection* event=
762  PlaybackRawDataProvider::instance()->getFEDRawData(runNumber,evtNumber);
763  if(event == 0) return false;
764  evt->initialize(evtNumber);
765 
766  for (unsigned int i=0;i<validFedIds_.size();i++) {
767  unsigned int fedId =validFedIds_[i];
768  unsigned int fedSize=event->FEDData(fedId).size();
769  unsigned char* fedAddr=event->FEDData(fedId).data();
770  if (overwriteEvtId_.value_ && fedAddr != 0) {
771  fedh_t *fedHeader=(fedh_t*)fedAddr;
772  fedHeader->eventid=(fedHeader->eventid&0xFF000000)+(evtNumber&0x00FFFFFF);
773  }
774  if (fedSize>0) evt->writeFed(fedId,fedAddr,fedSize);
775  }
776  delete event;
777  }
778  // RANDOM mode
779  else {
780  unsigned int evtNumber=(firstEvent_+evtNumber_++)%0x1000000;
781  evt->initialize(evtNumber);
782  unsigned int fedSizeMin=fedHeaderSize_+fedTrailerSize_;
783  for (unsigned int i=0;i<validFedIds_.size();i++) {
784  unsigned int fedId(validFedIds_[i]);
785  unsigned int fedSize(fedSizeMean_);
786  if (!useFixedFedSize_) {
787  double logFedSize=CLHEP::RandGauss::shoot(gaussianMean_,gaussianWidth_);
788  fedSize=(unsigned int)(std::exp(logFedSize));
789  if (fedSize<fedSizeMin) fedSize=fedSizeMin;
790  if (fedSize>fedSizeMax_) fedSize=fedSizeMax_;
791  fedSize-=fedSize%8;
792  }
793 
794  evt->writeFed(fedId,0,fedSize);
795  evt->writeFedHeader(i);
796  evt->writeFedTrailer(i);
797  }
798 
799  }
800  return true;
801 }
802 
803 
804 //______________________________________________________________________________
805 toolbox::mem::Reference *BU::createMsgChain(BUEvent* evt,
806  unsigned int fuResourceId)
807 {
808  unsigned int msgHeaderSize =sizeof(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME);
809  unsigned int msgPayloadSize=msgBufferSize_-msgHeaderSize;
810 
811  if((msgPayloadSize%4)!=0) LOG4CPLUS_ERROR(log_,"Invalid Payload Size.");
812 
813  /*Overwrite lumisection value stored in the event*/
814  if (overwriteLsId_.value_) {
815  //getting new time and increase LS if past 23 sec
816  struct timezone tz;
817  if (!fakeLs_) {
818  fakeLs_++;
819  gettimeofday(&lastLsUpdate_,&tz);
820  }
821  else {
822  timeval newLsUpdate;
823  gettimeofday(&newLsUpdate,&tz);
824  if ((unsigned long)1000000*newLsUpdate.tv_sec+newLsUpdate.tv_usec
825  - (unsigned long)1000000*lastLsUpdate_.tv_sec+lastLsUpdate_.tv_usec
826  >= fakeLsUpdateSecs_.value_*1000000)
827  {
828  fakeLs_++;
829  lastLsUpdate_=newLsUpdate;
830  }
831  }
832 
833  int gtpFedPos_=-1;
834  int egtpFedPos_=-1;
835  for (size_t k=0;k<validFedIds_.size();k++) {
837  //insert ls value into gtp fed
838  unsigned char * fgtpAddr = evt->fedAddr(k);
839  unsigned int fgtpSize = evt->fedSize(k);
840  if (fgtpAddr && fgtpSize) {
841  gtpFedPos_=(int)k;
842  evtn::evm_board_sense(fgtpAddr,fgtpSize);
843  *((unsigned short*)fgtpAddr
844  +sizeof(fedh_t)/sizeof(unsigned short)
845  + (evtn::EVM_GTFE_BLOCK*2 + evtn::EVM_TCS_LSBLNR_OFFSET)*evtn::SLINK_HALFWORD_SIZE /sizeof(unsigned short)
846  ) = (unsigned short)fakeLs_-1;
847  }
848  }
850  //insert orbit value into gtpe fed
851  unsigned char * fegtpAddr = evt->fedAddr(egtpFedPos_);
852  unsigned int fegtpSize = evt->fedSize(egtpFedPos_);
853  if (fegtpAddr && fegtpSize) {
854  egtpFedPos_=(int)k;
855  *( (unsigned int*)fegtpAddr + evtn::GTPE_ORBTNR_OFFSET * evtn::SLINK_HALFWORD_SIZE/sizeof(unsigned int)
856  ) = (unsigned int)(fakeLs_-1)*0x00100000;
857  }
858  }
859  }
860  if (gtpFedPos_<0) LOG4CPLUS_ERROR(log_,"Unable to find GTP FED in event!");
861  if (egtpFedPos_<0 && gtpFedPos_<0) LOG4CPLUS_ERROR(log_,"Unable to find GTP or GTPE FED in event!");
862  }
863 
864  toolbox::mem::Reference *head =0;
865  toolbox::mem::Reference *tail =0;
866  toolbox::mem::Reference *bufRef=0;
867 
868  I2O_MESSAGE_FRAME *stdMsg=0;
869  I2O_PRIVATE_MESSAGE_FRAME *pvtMsg=0;
870  I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME *block =0;
871 
872  unsigned int iFed =0;
873  unsigned int nSuperFrag =64;
874  unsigned int nFedPerSuperFrag=validFedIds_.size()/nSuperFrag;
875  unsigned int nBigSuperFrags =validFedIds_.size()%nSuperFrag;
876 
877  if (evt->nFed()<nSuperFrag) {
878  nSuperFrag=evt->nFed();
879  nFedPerSuperFrag=1;
880  nBigSuperFrags=0;
881  }
882  else
883  {
884  nFedPerSuperFrag=evt->nFed()/nSuperFrag;
885  nBigSuperFrags =evt->nFed()%nSuperFrag;
886  }
887  // loop over all super fragments
888  for (unsigned int iSuperFrag=0;iSuperFrag<nSuperFrag;iSuperFrag++) {
889 
890  // compute index of last fed in this super fragment
891  unsigned int nFed=iFed+nFedPerSuperFrag;
892  if (iSuperFrag<nBigSuperFrags) ++nFed;
893 
894  // compute number of blocks in this super fragment
895  unsigned int nBlock =0;
896  unsigned int curbSize=frlHeaderSize_;
897  unsigned int totSize =curbSize;
898  for (unsigned int i=iFed;i<nFed;i++) {
899  curbSize+=evt->fedSize(i);
900  totSize+=evt->fedSize(i);
901  if (curbSize>msgPayloadSize) {
902  curbSize+=frlHeaderSize_*(curbSize/msgPayloadSize);
903  if(curbSize%msgPayloadSize)totSize+=frlHeaderSize_*(curbSize/msgPayloadSize);
904  else totSize+=frlHeaderSize_*((curbSize/msgPayloadSize)-1);
905  curbSize=curbSize%msgPayloadSize;
906  }
907  }
908  nBlock=totSize/msgPayloadSize+(totSize%msgPayloadSize>0 ? 1 : 0);
909 
910 
911  // loop over all blocks (msgs) in the current super fragment
912  unsigned int remainder =0;
913  bool fedTrailerLeft=false;
914  bool last =false;
915  bool warning =false;
916  unsigned char *startOfPayload=0;
917  U32 payload(0);
918 
919  for(unsigned int iBlock=0;iBlock<nBlock;iBlock++) {
920 
921  // If last block and its partial (there can be only 0 or 1 partial)
922  payload=msgPayloadSize;
923 
924  // Allocate memory for a fragment block / message
925  try {
926  bufRef=toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,
928  }
929  catch(xcept::Exception &e) {
930  LOG4CPLUS_FATAL(log_,"xdaq::frameAlloc failed");
931  }
932 
933  // Fill in the fields of the fragment block / message
934  stdMsg=(I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
935  pvtMsg=(I2O_PRIVATE_MESSAGE_FRAME*)stdMsg;
936  block =(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME*)stdMsg;
937 
938  pvtMsg->XFunctionCode =I2O_FU_TAKE;
939  pvtMsg->OrganizationID =XDAQ_ORGANIZATION_ID;
940 
941  stdMsg->MessageSize =(msgHeaderSize + payload) >> 2;
942  stdMsg->Function =I2O_PRIVATE_MESSAGE;
943  stdMsg->VersionOffset =0;
944  stdMsg->MsgFlags =0;
945  stdMsg->InitiatorAddress=i2o::utils::getAddressMap()->getTid(buAppDesc_);
946  stdMsg->TargetAddress =i2o::utils::getAddressMap()->getTid(fuAppDesc_);
947 
948  block->buResourceId =evt->buResourceId();
949  block->fuTransactionId =fuResourceId;
950  block->blockNb =iBlock;
951  block->nbBlocksInSuperFragment=nBlock;
952  block->superFragmentNb =iSuperFrag;
953  block->nbSuperFragmentsInEvent=nSuperFrag;
954  block->eventNumber =evt->evtNumber();
955 
956  // Fill in payload
957  startOfPayload =(unsigned char*)block+msgHeaderSize;
958  frlh_t* frlHeader=(frlh_t*)startOfPayload;
959  frlHeader->trigno=evt->evtNumber();
960  frlHeader->segno =iBlock;
961 
962  unsigned char *startOfFedBlocks=startOfPayload+frlHeaderSize_;
963  payload -=frlHeaderSize_;
964  frlHeader->segsize =payload;
965  unsigned int leftspace=payload;
966 
967  // a fed trailer was left over from the previous block
968  if(fedTrailerLeft) {
969  memcpy(startOfFedBlocks,
970  evt->fedAddr(iFed)+evt->fedSize(iFed)-fedTrailerSize_,
972 
973  startOfFedBlocks+=fedTrailerSize_;
974  leftspace -=fedTrailerSize_;
975  remainder =0;
976  fedTrailerLeft =false;
977 
978  // if this is the last fed, adjust block (msg) size and set last=true
979  if((iFed==nFed-1) && !last) {
980  frlHeader->segsize-=leftspace;
981  int msgSize=stdMsg->MessageSize << 2;
982  msgSize -=leftspace;
983  bufRef->setDataSize(msgSize);
984  stdMsg->MessageSize = msgSize >> 2;
985  frlHeader->segsize=frlHeader->segsize | FRL_LAST_SEGM;
986  last=true;
987  }
988 
989  // !! increment iFed !!
990  iFed++;
991  }
992 
996  if (remainder>0) {
997 
998  // the remaining fed fits entirely into the new block
999  if(payload>=remainder) {
1000  memcpy(startOfFedBlocks,
1001  evt->fedAddr(iFed)+evt->fedSize(iFed)-remainder,
1002  remainder);
1003 
1004  startOfFedBlocks+=remainder;
1005  leftspace -=remainder;
1006 
1007  // if this is the last fed in the superfragment, earmark it
1008  if(iFed==nFed-1) {
1009  frlHeader->segsize-=leftspace;
1010  int msgSize=stdMsg->MessageSize << 2;
1011  msgSize -=leftspace;
1012  bufRef->setDataSize(msgSize);
1013  stdMsg->MessageSize = msgSize >> 2;
1014  frlHeader->segsize=frlHeader->segsize | FRL_LAST_SEGM;
1015  last=true;
1016  }
1017 
1018  // !! increment iFed !!
1019  iFed++;
1020 
1021  // start new fed -> set remainder to 0!
1022  remainder=0;
1023  }
1024  // the remaining payload fits, but not the fed trailer
1025  else if (payload>=(remainder-fedTrailerSize_)) {
1026  memcpy(startOfFedBlocks,
1027  evt->fedAddr(iFed)+evt->fedSize(iFed)-remainder,
1028  remainder-fedTrailerSize_);
1029 
1030  frlHeader->segsize=remainder-fedTrailerSize_;
1031  fedTrailerLeft =true;
1032  leftspace -=(remainder-fedTrailerSize_);
1033  remainder =fedTrailerSize_;
1034  }
1035  // the remaining payload fits only partially, fill whole block
1036  else {
1037  memcpy(startOfFedBlocks,
1038  evt->fedAddr(iFed)+evt->fedSize(iFed)-remainder,payload);
1039  remainder-=payload;
1040  leftspace =0;
1041  }
1042  }
1043 
1047  if(remainder==0) {
1048 
1049  // loop on feds
1050  while(iFed<nFed) {
1051 
1052  // if the next header does not fit, jump to following block
1053  if((int)leftspace<fedHeaderSize_) {
1054  frlHeader->segsize-=leftspace;
1055  break;
1056  }
1057 
1058  memcpy(startOfFedBlocks,evt->fedAddr(iFed),fedHeaderSize_);
1059 
1060  leftspace -=fedHeaderSize_;
1061  startOfFedBlocks+=fedHeaderSize_;
1062 
1063  // fed fits with its trailer
1064  if(evt->fedSize(iFed)-fedHeaderSize_<=leftspace) {
1065  memcpy(startOfFedBlocks,
1066  evt->fedAddr(iFed)+fedHeaderSize_,
1067  evt->fedSize(iFed)-fedHeaderSize_);
1068 
1069  leftspace -=(evt->fedSize(iFed)-fedHeaderSize_);
1070  startOfFedBlocks+=(evt->fedSize(iFed)-fedHeaderSize_);
1071  }
1072  // fed payload fits only without fed trailer
1073  else if(evt->fedSize(iFed)-fedHeaderSize_-fedTrailerSize_<=leftspace) {
1074  memcpy(startOfFedBlocks,
1075  evt->fedAddr(iFed)+fedHeaderSize_,
1077 
1078  leftspace -=(evt->fedSize(iFed)-fedHeaderSize_-fedTrailerSize_);
1079  frlHeader->segsize-=leftspace;
1080  fedTrailerLeft =true;
1081  remainder =fedTrailerSize_;
1082 
1083  break;
1084  }
1085  // fed payload fits only partially
1086  else {
1087  memcpy(startOfFedBlocks,evt->fedAddr(iFed)+fedHeaderSize_,leftspace);
1088  remainder=evt->fedSize(iFed)-fedHeaderSize_-leftspace;
1089  leftspace=0;
1090 
1091  break;
1092  }
1093 
1094  // !! increase iFed !!
1095  iFed++;
1096 
1097  } // while (iFed<fedN_)
1098 
1099  // earmark the last block
1100  if (iFed==nFed && remainder==0 && !last) {
1101  frlHeader->segsize-=leftspace;
1102  int msgSize=stdMsg->MessageSize << 2;
1103  msgSize -=leftspace;
1104  bufRef->setDataSize(msgSize);
1105  stdMsg->MessageSize=msgSize >> 2;
1106  frlHeader->segsize =frlHeader->segsize | FRL_LAST_SEGM;
1107  last=true;
1108  }
1109 
1110  } // if (remainder==0)
1111 
1112  if(iSuperFrag==0&&iBlock==0) { // This is the first fragment block / message
1113  head=bufRef;
1114  tail=bufRef;
1115  }
1116  else {
1117  tail->setNextReference(bufRef);
1118  tail=bufRef;
1119  }
1120 
1121  if((iBlock==nBlock-1) && remainder!=0) {
1122  nBlock++;
1123  warning=true;
1124  }
1125 
1126  } // for (iBlock)
1127 
1128  // fix case where block estimate was wrong
1129  if(warning) {
1130  toolbox::mem::Reference* next=head;
1131  do {
1132  block =(I2O_EVENT_DATA_BLOCK_MESSAGE_FRAME*)next->getDataLocation();
1133  if (block->superFragmentNb==iSuperFrag)
1134  block->nbBlocksInSuperFragment=nBlock;
1135  } while((next=next->getNextReference()));
1136  }
1137 
1138  } // iSuperFrag < nSuperFrag
1139 
1140  return head; // return the top of the chain
1141 }
1142 
1143 //______________________________________________________________________________
1144 void BU::dumpFrame(unsigned char* data,unsigned int len)
1145 {
1146  char left1[20];
1147  char left2[20];
1148  char right1[20];
1149  char right2[20];
1150 
1151  printf("Byte 0 1 2 3 4 5 6 7\n");
1152 
1153  int c(0);
1154  int pos(0);
1155 
1156  for (unsigned int i=0;i<(len/8);i++) {
1157  int rpos(0);
1158  int off(3);
1159  for (pos=0;pos<12;pos+=3) {
1160  sprintf(&left1[pos],"%2.2x ",
1161  ((unsigned char*)data)[c+off]);
1162  sprintf(&right1[rpos],"%1c",
1163  ((data[c+off] > 32)&&(data[c+off] < 127)) ? data[c+off] : '.');
1164  sprintf (&left2[pos],"%2.2x ",
1165  ((unsigned char*)data)[c+off+4]);
1166  sprintf (&right2[rpos],"%1c",
1167  ((data[c+off+4] > 32)&&(data[c+off+4]<127)) ? data[c+off+4] : '.');
1168  rpos++;
1169  off--;
1170  }
1171  c+=8;
1172 
1173  printf ("%4d: %s%s || %s%s %p\n",
1174  c-8, left1, left2, right1, right2, &data[c-8]);
1175  }
1176 
1177  fflush(stdout);
1178 }
1179 
1180 
1182 // xdaq instantiator implementation macro
1184 
1185 XDAQ_INSTANTIATOR_IMPL(BU)
static const char runNumber_[]
void setLargeAppIcon(CString_t &icon)
Definition: WebGUI.h:74
xdata::UnsignedInteger32 nbEventsInBU_
Definition: BU.h:201
int i
Definition: DBlmapReader.cc:9
const unsigned int EVM_TCS_LSBLNR_OFFSET
void initialize(unsigned int evtNumber)
Definition: BUEvent.cc:74
void resetCounters()
Definition: WebGUI.cc:217
void unlock()
Definition: BU.h:111
#define Input(cl)
Definition: vmac.h:189
bool configuring(toolbox::task::WorkLoop *wl)
Definition: BU.cc:178
void webPageRequest(xgi::Input *in, xgi::Output *out)
Definition: BU.cc:402
xdata::Boolean overwriteEvtId_
Definition: BU.h:211
toolbox::task::ActionSignature * asMonitoring_
Definition: BU.h:177
xdata::Double memUsedInMB_
Definition: BU.h:188
unsigned int evtNumber() const
Definition: BUEvent.h:28
xdata::Boolean replay_
Definition: BU.h:209
static void setComputeCrc(bool computeCrc)
Definition: BUEvent.h:37
std::queue< unsigned int > builtIds_
Definition: BU.h:158
double gaussianWidth_
Definition: BU.h:228
void addStandardParam(CString_t &name, Param_t *param)
Definition: WebGUI.cc:134
bool sending(toolbox::task::WorkLoop *wl)
Definition: BU.cc:501
void exportParameters()
Definition: WebGUI.cc:200
xdata::String mode_
Definition: BU.h:208
bool writeFed(unsigned int id, unsigned char *data, unsigned int size)
Definition: BUEvent.cc:83
xdata::UnsignedInteger32 msgBufferSize_
Definition: BU.h:217
xdata::String class_
Definition: BU.h:184
StateMachine fsm_
Definition: BU.h:149
xdaq::ApplicationContext * buAppContext_
Definition: BU.h:146
toolbox::mem::Reference * createMsgChain(evf::BUEvent *evt, unsigned int fuResourceId)
Definition: BU.cc:805
unsigned int buResourceId() const
Definition: BUEvent.h:27
virtual FEDRawDataCollection * getFEDRawData()
xdata::Boolean useFixedFedSize_
Definition: BU.h:221
double deltaT(const struct timeval *start, const struct timeval *end)
Definition: BU.cc:727
Logger log_
Definition: BU.h:137
xdata::UnsignedInteger32 fedSizeWidth_
Definition: BU.h:220
static const int frlHeaderSize_
Definition: BU.h:252
std::queue< unsigned int > rqstIds_
Definition: BU.h:156
bool isSending_
Definition: BU.h:164
void setSmallAppIcon(CString_t &icon)
Definition: WebGUI.h:75
void addMonitorParam(CString_t &name, Param_t *param)
Definition: WebGUI.cc:145
void addItemChangedListener(CString_t &name, xdata::ActionListener *l)
Definition: WebGUI.cc:238
xdata::Double rate_
Definition: BU.h:197
bool monitoring(toolbox::task::WorkLoop *wl)
Definition: BU.cc:562
xdata::UnsignedInteger32 instance_
Definition: BU.h:185
unsigned int evtNumber_
Definition: BU.h:160
sem_t sendSem_
Definition: BU.h:245
void postBuild()
Definition: BU.h:113
xdata::Boolean overwriteLsId_
Definition: BU.h:212
bool writeFedHeader(unsigned int i)
Definition: BUEvent.cc:106
void sleep(Duration_t)
Definition: Utils.h:163
xdata::Double throughput_
Definition: BU.h:195
xdata::UnsignedInteger32 fakeLsUpdateSecs_
Definition: BU.h:213
const unsigned int SLINK_HALFWORD_SIZE
Definition: FEDConstants.h:7
void startMonitoringWorkLoop()
Definition: BU.cc:539
static const int fedTrailerSize_
Definition: BU.h:254
void initialize(T *app)
Definition: StateMachine.h:84
void lock()
Definition: BU.h:110
void customWebPage(xgi::Input *in, xgi::Output *out)
Definition: BU.cc:412
void waitSend()
Definition: BU.h:114
bool stopping(toolbox::task::WorkLoop *wl)
Definition: BU.cc:227
void actionPerformed(xdata::Event &e)
Definition: BU.cc:385
void waitRqst()
Definition: BU.h:116
unsigned char * fedAddr(unsigned int i) const
Definition: BUEvent.cc:146
xdata::Double deltaSumOfSquares_
Definition: BU.h:192
void startBuildingWorkLoop()
Definition: BU.cc:420
xdata::Bag< xdaq2rc::ClassnameAndInstance > * rcmsStateListener()
Definition: StateMachine.h:72
WebGUI * gui_
Definition: BU.h:152
void fireFailed(const std::string &errorMsg, void *originator)
xoap::MessageReference fsmCallback(xoap::MessageReference msg)
Definition: BU.cc:311
unsigned int sumOfSizes_
Definition: BU.h:236
static PlaybackRawDataProvider * instance()
void reset()
Definition: BU.cc:685
toolbox::task::ActionSignature * asBuilding_
Definition: BU.h:169
toolbox::task::WorkLoop * wlSending_
Definition: BU.h:172
xdata::UnsignedInteger32 nbEventsSent_
Definition: BU.h:204
void I2O_BU_ALLOCATE_Callback(toolbox::mem::Reference *bufRef)
Definition: BU.cc:319
xdata::UnsignedInteger32 nbEventsRequested_
Definition: BU.h:202
xdata::Double rms_
Definition: BU.h:198
Definition: BU.h:49
virtual ~BU()
Definition: BU.cc:167
T sqrt(T t)
Definition: SSEVec.h:46
unsigned int evtSize() const
Definition: BUEvent.h:29
uint64_t sumOfSquares_
Definition: BU.h:235
std::string sourceId_
Definition: BU.h:180
toolbox::task::WorkLoop * wlBuilding_
Definition: BU.h:168
bool isBuilding_
Definition: BU.h:163
tuple result
Definition: query.py:137
xdata::Boolean crc_
Definition: BU.h:210
xdaq::ApplicationDescriptor * buAppDesc_
Definition: BU.h:140
sem_t lock_
Definition: BU.h:243
unsigned int fedId(unsigned int i) const
Definition: BUEvent.h:32
xdata::Double deltaT_
Definition: BU.h:190
double gaussianMean_
Definition: BU.h:227
bool isHalting_
Definition: BU.h:165
xdata::UnsignedInteger32 monSleepSec_
Definition: BU.h:222
#define end
Definition: vmac.h:38
void dumpFrame(unsigned char *data, unsigned int len)
Definition: BU.cc:1144
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
toolbox::task::ActionSignature * asSending_
Definition: BU.h:173
bool writeFedTrailer(unsigned int i)
Definition: BUEvent.cc:123
bool evm_board_sense(const unsigned char *p, size_t size)
xdata::UnsignedInteger32 deltaN_
Definition: BU.h:191
void fireEvent(const std::string &evtType, void *originator)
int k[5][pyjets_maxn]
std::vector< unsigned int > validFedIds_
Definition: BU.h:161
tuple out
Definition: dbtoconf.py:99
sem_t buildSem_
Definition: BU.h:244
toolbox::task::WorkLoop * wlMonitoring_
Definition: BU.h:176
xdata::String hostname_
Definition: BU.h:186
unsigned long long uint64_t
Definition: Time.h:15
xdata::UnsignedInteger32 fedSizeMax_
Definition: BU.h:218
void exportParameters()
Definition: BU.cc:629
xdata::String * stateName()
Definition: StateMachine.h:69
bool generateEvent(evf::BUEvent *evt)
Definition: BU.cc:747
bool halting(toolbox::task::WorkLoop *wl)
Definition: BU.cc:280
xdata::InfoSpace * monInfoSpace()
Definition: WebGUI.h:72
sem_t rqstSem_
Definition: BU.h:246
void waitBuild()
Definition: BU.h:112
xdata::Double average_
Definition: BU.h:196
xdata::Boolean * foundRcmsStateListener()
Definition: StateMachine.h:78
toolbox::mem::Pool * i2oPool_
Definition: BU.h:240
xdata::UnsignedInteger32 deltaSumOfSizes_
Definition: BU.h:193
unsigned int eventid
Definition: fed_header.h:33
bool building(toolbox::task::WorkLoop *wl)
Definition: BU.cc:441
unsigned int fedSize(unsigned int i) const
Definition: BUEvent.h:33
std::vector< evf::BUEvent * > events_
Definition: BU.h:155
xdata::UnsignedInteger32 runNumber_
Definition: BU.h:187
xdata::UnsignedInteger32 eventBufferSize_
Definition: BU.h:216
static bool inRange(int)
xdata::UnsignedInteger32 fedSizeMean_
Definition: BU.h:219
void I2O_BU_DISCARD_Callback(toolbox::mem::Reference *bufRef)
Definition: BU.cc:353
std::queue< unsigned int > freeIds_
Definition: BU.h:157
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: BU.h:143
unsigned int monLastN_
Definition: BU.h:232
#define Output(cl)
Definition: vmac.h:193
std::set< unsigned int > sentIds_
Definition: BU.h:159
void startSendingWorkLoop()
Definition: BU.cc:480
unsigned int monLastSumOfSizes_
Definition: BU.h:234
uint64_t monLastSumOfSquares_
Definition: BU.h:233
timeval lastLsUpdate_
Definition: BU.h:225
xdata::UnsignedInteger32 nbEventsDiscarded_
Definition: BU.h:205
void addMonitorCounter(CString_t &name, Counter_t *counter)
Definition: WebGUI.cc:178
void postSend()
Definition: BU.h:115
static const int fedHeaderSize_
Definition: BU.h:253
xdata::UnsignedInteger32 queueSize_
Definition: BU.h:215
unsigned int nFed() const
Definition: BUEvent.h:31
bool enabling(toolbox::task::WorkLoop *wl)
Definition: BU.cc:197
unsigned int fakeLs_
Definition: BU.h:224
xdata::UnsignedInteger32 nbEventsBuilt_
Definition: BU.h:203
struct timeval monStartTime_
Definition: BU.h:231
static bool inRangeNoGT(int)
void postRqst()
Definition: BU.h:117
xdata::String url_
Definition: BU.h:183
const unsigned int GTPE_ORBTNR_OFFSET
void findRcmsStateListener()
xdata::UnsignedInteger32 firstEvent_
Definition: BU.h:214