GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrameIO.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #include "FactoryItem.h"
24 
25 #ifndef ADF_FrameIO
26 #include "FrameIO.h"
27 #endif
28 
29 #ifndef ADF_DFAgent
30 #include "DFAgent.h"
31 #endif
32 #ifndef ADF_Key
33 #include "Key.h"
34 #endif
35 #ifndef ADF_KeyFactory
36 #include "KeyFactory.h"
37 #endif
38 #ifndef ADF_ConfigurationFrame
39 #include "ConfigurationFrame.h"
40 #endif
41 #ifndef ADF_Trigger
42 #include "Trigger.h"
43 #endif
44 
45 using namespace ADF;
46 
47 BaseFrameIO::BaseFrameIO(const char *name):
48  fName(name),
49  fStatus(kUndefined),
50  fConfAgent(0x0),
51  Log(name)
52 {
53  Log.SetProcessMethod("BaseFrameIO(const char *name)");
54  Log << info << "Global agent is cloned ..." << nline;
55  fConfAgent =
56  ConfAgent::theGlobalAgent()->Clone(fName.data());
57  Log << info << "... DONE" << dolog;
58 }
59 
61 {
62  if ( fConfAgent )
63  delete fConfAgent;
64  fConfAgent = 0x0;
65 }
66 
68 {
69  const char *status = 0x0;
70  switch (s) {
71  case kUndefined:
72  status = "kUndefined";
73  break;
74  case kRunning:
75  status = "kRunning";
76  break;
77  case kStopped:
78  status = "kStopped";
79  break;
80  case kSuspended:
81  status = "kSuspended";
82  break;
83  case kIdle:
84  status = "kIdle";
85  break;
86  case kFinished:
87  status = "kFinished";
88  break;
89  };
90  return status;
91 }
92 
94 {
95  GetConfAgent()->GetDFAgent()->SetModel(model);
96 }
97 
99 {
100  return GetConfAgent()->GetDFAgent()->GetModel() ;
101 }
102 
103 void BaseFrameIO::Print(std::ostream &out) const
104 {
105  out << " " << GetName() << " (" << GetType()
106  << ") current status : " << GetStringStatus(GetStatus()) << std::endl;
107  out << " Model is : " << ConfAgent::GetStringModel(GetModel()) << std::endl;
108 }
109 
110 FrameIO::FrameIO(const char *name):
111  BaseFrameIO(name),
112  fDefaultInFB(0x0),
113  fDefaultOuFB(0x0),
114  fInFB(0x0),
115  fOuFB(0x0),
116  fKeyIn(0x0),
117  fConfIO(0x0),
118  fRegisteredTriggers(),
119  fRunningTriggers(),
120  fWriteOnlyTriggers(),
121  fZombieTriggers(),
122  fGlobalCounter(0.0,aMByte,"bytes read for global reconfiguration"),
123  fNoTrigCounterIN(0.0,100u*aMByte,"untriggered read bytes"),
124  fNoTrigCounterOUT(0.0,100u*aMByte,"untriggered written bytes"),
125  fTrigCountersIN(),
126  fTrigCountersOUT(),
127  fRead(0u), fWritten(0u), fTriggerRate(0u), fDoRewind (true)
128 {
129  Log.SetProcessMethod("FrameIO()");
130 
131  // Default is NullBlock means nothing can be read, anything is written
132  fDefaultInFB =
133  new NullBlock();
134  fDefaultInFB->SetModeIO(ConfAgent::kRead);
135  fInFB = fDefaultInFB;
136 
137  fDefaultOuFB =
138  new NullBlock();
139  fDefaultOuFB->SetModeIO(ConfAgent::kWrite);
140  fOuFB = fDefaultOuFB;
141 
142  // external triggers are not owned by this.
143  fRegisteredTriggers.SetOwner(false);
144  fRunningTriggers.SetOwner(false);
145  fWriteOnlyTriggers.SetOwner(false);
146  fZombieTriggers.SetOwner(false);
147 
148  InitFromAgent();
149 
150  Log << dolog;
151 }
152 
154 {
155  Log.SetProcessMethod("InitFromAgent");
156 
157  // get from ConfAgent the current definition of the input key
158  // if it fails, IO becomes undefined !
159  FactoryItem key_in_item
160  ( GetConfAgent()->GetDFAgent()->GetPrimaryKey() ) ;
161 
162  // set correct endian for that key factory
163  // KeyFactory::SetEndian(GetConfAgent()->GetDFAgent()->GetEndian(),key_in_item.GetFactoryName());
164  Key *new_key =
165  MainKeyFactory::theMainFactory().New(key_in_item);
166 
167  // cannot read anymore the data flow.
168  if ( new_key == 0x0 ) {
170  Log << dolog;
171  return false;
172  }
173 
174  // change key to read the data flow
175  if ( fKeyIn )
176  delete fKeyIn;
177  fKeyIn = new_key;
178 
179  // change the trigger for global reconfiguration
180  if ( fConfIO )
181  delete fConfIO;
182 
183  key_in_item =
185 
186  fConfIO =
187  new FrameTrigger("DataFlow Auto-Reconfiguration");
188  fConfIO->Add(GetConfAgent()->GetDFAgent()->GetAutoConfKey(),
189  GetConfAgent()->GetDFAgent()->GetAutoConfFrame());
190 
191  if ( fConfIO->IsZombie() )
192  fConfIO->Active(false);
193  else {
194  fConfIO->Active(true);
195  Log << info << "The data flow is auto-reconfigurable "
197  }
198 
199  Log << dolog; return true;
200 }
201 
203 {
204  // external triggers are not owned by this.
205  fRegisteredTriggers.Delete(); fRunningTriggers.Delete(); fZombieTriggers.Delete();
206 
207  fInFB = fOuFB = 0x0;
208 
209  if ( fDefaultInFB )
210  delete fDefaultInFB;
211  fDefaultInFB = 0x0;
212  if ( fDefaultOuFB )
213  delete fDefaultOuFB;
214  fDefaultOuFB = 0x0;
215 
216  if ( fKeyIn )
217  delete fKeyIn;
218  fKeyIn = 0x0;
219  if ( fConfIO )
220  delete fConfIO;
221  fConfIO = 0x0;
222 }
223 
225 {
226  tri->Active(true);
227 
228  // already a zombie ...
229  if ( tri->IsZombie() ) {
230  // just to be sure and add it to the list of zombie
231  tri->Active(false);
232  zomb.Add( tri );
233  return tri->IsActive();
234  }
235  // now try to adapt it to the new definition of the dataflow
236  if ( tri->Reconfigure(GetConfAgent()) )
237  run.Add( tri );
238  else {
239  tri->Active(false);
240  if ( tri->IsZombie() )
241  zomb.Add( tri );
242  }
243 
244  return tri->IsActive();
245 }
246 
247 Bool_t FrameIO::RecordGlobalConfiguration(const std::string keep)
248 {
249  Bool_t ok = true;
250 
251  if ( !fConfIO->IsActive() )
252  return false;
253 
254  Log.SetProcessMethod("RecordGlobalConfiguration(const std::string)");
255 
256  ConfigurationFrame *cframe
257  = dynamic_cast<ConfigurationFrame *>( fConfIO->GetInputFrame() );
258 
259  // just to be sure ....
260  cframe->Unlink();
261  cframe->FastReset();
262 
263  // ask agent to fill the Frame and add it to the ouput flow
264  // conf frame in +,== mode so that it does not reset the next actor by simply complete/modify it
265  GetConfAgent()->SetStreamOption("+,==");
266  ok = ok && GetConfAgent()->Configure(cframe,"out");
267  if ( keep != "NO" )
268  GetConfAgent()->Configure(keep.data(),"out");
269 
270  //
271  if ( fOuFB->Reserve(cframe->GetLength(),true) ) {
272  fOuFB->AddFrame((*cframe));
273  fWritten++;
274  fGlobalCounter += cframe->GetLength();
275  }
276  else {
278  Log << warning
279  << "Global configuration frame cannot be sent to output " << nline;
280  ok = false;
281  }
282 
283  Log << dolog; return ok;
284 }
285 
287 {
288  Log.SetProcessMethod("DoGlobalReconfiguration()");
289  Log << info << "In "
290  << GetName()
291  << " a Global configuration frame has been found ==> reconfiguration " << nline;
292 
293  // it exists since this method is called once fConfIO has triggered
294  // reconfigure the agent from the conf frame
295  ConfigurationFrame *cframe
296  = dynamic_cast<ConfigurationFrame *>( fConfIO->GetInputFrame() );
297 
298  Bool_t ok =
299  GetConfAgent()->Configure(cframe,"in");
300  cframe->Unlink(); // because the conf frame will be rebuilt there
301 
302  if ( !ok ) {
303  Log << error << "Reconfiguration of ConfAgent fails !!! ==> Stop, status undefined " << nline;
305  GetConfAgent()->DoConfigure( Log() );
307  Log << dolog;
308 
310 
311  return false;
312  }
313  // the conf agent has been modified successfully ... try to set up FrameIO with the new conditions
314  if ( ! InitFromAgent() ) {
315  Log << error << "Reconfiguration of FrameIO from new ConfAgent fails !!! " << dolog;
316  return false;
317  }
318  else fConfIO->Fired(true); // because fConfIO is re-built in InitFromAgent and this has been called because a frame has been found
319 
320  // now loop over all the triggers to modify them if possible
321  // or to move them to the list of
322  // and to reconstruct the inner triggers
323  fRunningTriggers.Clear();
324  for(UInt_t i = 0u ; i < fRegisteredTriggers.GetSize() ; i++ ){
325 
326  DFTrigger *trig =
327  fRegisteredTriggers.At(i);
328 
329  Bool_t ok;
330  if ( trig->GetInputFrame() )
331  ok = Check(trig,fRunningTriggers,fZombieTriggers);
332  else
333  ok = Check(trig,fWriteOnlyTriggers,fZombieTriggers);
334 
335  if ( ok )
336  Log << info << "Trigger - " << trig->GetName()
337  << " - is suitable for the current dataflow ==> set ACTIVE " << nline;
338  else
339  Log << info << "Trigger - " << trig->GetName()
340  << " - is NOT suitable for the current dataflow ==> set INACTIVE " << nline;
341  }
342 
343  //
344  Log << info << "Reconfiguration of ConfAgent from Configuration Frame is done properly. New Conf : " << nline;
345 
346  // send snapshot in the log system only if global debug flag is higher or equal to 1
347  if ( Log.IsDebug(1) ) {
349  GetConfAgent()->DoConfigure( Log() );
351  }
352 
353  // now rebuild the conf frame (since output frame could be added at check and save it
355 
356  Log << dolog; return true;
357 }
358 
360 {
361  if ( GetStatus() != BaseFrameIO::kRunning )
362  return false;
363 
364  fInFB->Snapshot();
365  return fInFB->NextFrame(fKeyIn);
366 }
367 
369 {
370  Log.SetProcessMethod("Register(DFTrigger *trig)");
371 
372  if ( trig->GetInputFrame() == 0x0 && trig->GetOutputFrame() == 0x0 ) {
373  Log << warning << "Cannot registered an incomplete trigger : " << trig->GetName() << dolog;
374 // fZombieTriggers.Add(trig);
375 // not needed @ this level, keep zombie for reconfiguration failure only
376  return false ;
377  }
378  // add it to the stack of registered triggers together with some counters
379  // triggers with @ least an input frame
380  if ( trig->GetInputFrame() ) {
381 
382  // read/write trigger
383  fRegisteredTriggers.Add( trig );
384  // if ok add the current trigger to the running trigger otherwise on zombie list
385  Check(trig,fRunningTriggers,fZombieTriggers);
386 
387  // send new information to the log
388  if ( trig->IsActive() )
389  Log << info << "A new RUNNING Trigger has just been added : " << trig->GetName() << nline;
390  else
391  Log << info << "A new NON RUNNING Trigger has just been added : " << trig->GetName() << nline;
392 
393  // show the trigger definition
394  for (UInt_t which = 0u; which < trig->GetNbInputFrame(); which++) {
395  Frame *frame = trig->GetInputFrame(which);
396  if ( frame ) {
397  if ( which == 0u ) {
398  Log << "# " << trig->GetDFOption(which) << " " << frame->GetKey()->GetSignature() << frame->GetSignature() << nline;
399  }
400  else {
401  Log << " + " << trig->GetDFOption(which) << " " << frame->GetKey()->GetSignature() << frame->GetSignature() << nline;
402  }
403  }
404  }
405  if ( trig->GetOutputFrame() )
406  Log << "==> " << trig->GetOutputFrame()->GetKey()->GetSignature() << "" << trig->GetOutputFrame()->GetSignature() << nline;
407 
408  }
409  else {
410 
411  fRegisteredTriggers.Add( trig );
412  // if ok add the current trigger to the running trigger otherwise on zombie list
413  Check(trig,fWriteOnlyTriggers,fZombieTriggers);
414 
415  Log << info << "A new WRITE ONLY Trigger has just been added : " << trig->GetName() << nline;
416  if ( trig->GetOutputFrame() )
417  Log << "==> " << trig->GetOutputFrame()->GetKey()->GetSignature() << trig->GetOutputFrame()->GetSignature() << nline;
418  }
419 
420  // a counter is associated based on the unique id of a trigger
421  Counter c_in(0.0,100u*aMByte,"bytes read"); Counter c_out(0.0,100u*aMByte,"bytes written");
422 
423  while ( fTrigCountersIN.size() <= trig->GetUniqueID() ) {
424  fTrigCountersIN.push_back(c_in); fTrigCountersOUT.push_back(c_out);
425  }
426  fTrigCountersIN[trig->GetUniqueID()] = c_in; fTrigCountersOUT[trig->GetUniqueID()] = c_out;
427 
428  Log << dolog;
429  //
430  return true;
431 }
432 
433 DFTrigger *FrameIO::GetTrigger(const Char_t *trigname)
434 {
435  DFTrigger *answer = 0x0;
436 
437  for(UInt_t i = 0u ; i < fRegisteredTriggers.GetSize() ; i++ ){
438  DFTrigger *trig =
439  fRegisteredTriggers.At(i);
440  if ( trig->GetName().find(trigname) == 0 ) {
441  answer = trig;
442  }
443  }
444  return answer;
445 }
446 
447 Bool_t FrameIO::Notify(Bool_t with_inner_trigger)
448 {
449  // writing mode only
450  if ( fInFB->GetModeIO() == ConfAgent::kWrite )
451  return false;
452 
453  // check if it is ok to process the data flow
454  if ( GetStatus() == BaseFrameIO::kIdle )
456  if ( GetStatus() != BaseFrameIO::kRunning )
457  return false;
458 
459  // if true a new frame is coming and fKeyIn already linked
460  Long64_t pos = fInFB->GetOffset();
461  while ( NextFrame() ) {
462 
463  // a new frame has been read
464  fRead++;
465  if ( pos == fInFB->GetSize() ) {
466  Log << error << " A New Frame found but the position in the input block has not changed " << pos << " " << fInFB->GetSize() << dolog ;
467  break;
468  }
469  else {
470  // Log << info << " changed position " << pos << " " << fInFB->GetSize() << dolog ;
471  pos = fInFB->GetOffset();
472  }
473 
474  Bool_t is_treated = false;
475 
476  // check if this is a global reconfiguratiopn frame
477  if ( fConfIO->IsActive() ) {
478  if ( fConfIO->GetInputFrame()->Link(fInFB->GetFrame(),0u) ) {
479  if ( fConfIO->Check() ) {
480  if ( ! DoGlobalReconfiguration() )
481  return false; // cannot write it on the output datablock
482 
483  // the reconfiguration has been done and the user wants to be informed, so returns
484  if ( with_inner_trigger )
485  return true;
486 
487  is_treated = true;
488  }
489  else fConfIO->GetInputFrame()->Unlink();
490  }
491  }
492  // check in the list of inner trigger if one fired.
493 
494  // check in the list of running trigger if one fired.
495  Bool_t all_trigger_ok;
496  all_trigger_ok = false;
497  for( UShort_t i = 0u; i < fRunningTriggers.GetSize(); i++ ) {
498 
499  Bool_t this_ok = false;
500 
501  // check just active triggers.
502  DFTrigger *trig = fRunningTriggers.At(i);
503  if ( trig->IsActive() ) {
504  // first is the main frame of expected type
505  if ( trig->GetInputFrame()->Link(fInFB->GetFrame(),0u) )
506  this_ok = trig->Check();
507  }
508  if (this_ok) {
509  fTrigCountersIN[trig->GetUniqueID()]
510  += trig->GetInputFrame()->GetLength();
511  all_trigger_ok = true;
512  }
513  else trig->GetInputFrame()->Unlink();
514  } // i
515 
516  // a trigger has fired so it returns to the users
517  if ( all_trigger_ok )
518  { fTriggerRate+=1u; return all_trigger_ok; }
519 
520  // means a reconfiguration frame has been found, copy on output
521  // does not depend of the model : they are always written ... done previously
522  if ( is_treated )
523  continue;
524 
525  // follow FramIO model
526  ConfAgent::EModel model
527  = GetModel();
528 
529  // we are here in case nothing has trigged
530  fNoTrigCounterIN +=
531  fInFB->GetFrame().Size();
532 
533  // not a usefull frame, do the proper action depending of the model
534  switch( model ){
535  case ConfAgent::kStrict:
536  // reject the current frame
537  break;
538  case ConfAgent::kSafe:
539  case ConfAgent::kGrowing:
540  // able to write the frame on the output data flow
541  // if not set also eob because called with true
542  if ( fOuFB->Reserve(fInFB->GetFrame().Size(),true) ) {
543  fOuFB->AddFrame(fInFB->GetFrame());
544  fWritten++;
545  fNoTrigCounterOUT +=
546  fInFB->GetFrame().Size();
547  }
548  else {
550  // to avoid loosing the current frame, only if it is just because
551  // the free size is too low,. Avoid the case for which the input is too big compare to the out
552  if ( fOuFB->GetSize() != 0u )
553  fInFB->BackToSnapshot();
554  else {
555  // SetStatus(BaseFrameIO::kFinished);
556  fInFB->SetEoB(true);
557  Log << error << " INPUT FRAME too high " << fInFB->GetFrame().Size() << " for the outpout block " << nline;
558  // SetStatus(BaseFrameIO::kError);
559  }
560  return false;
561  }
562  break;
563  } // model
564  }
565  if ( GetStatus() == BaseFrameIO::kRunning )
567 
568  return false;
569 }
570 
571 void FrameIO::Print(std::ostream &out) const
572 {
573  BaseFrameIO::Print(out);
574  out << " ---> Global Informations \n";
575  out << " + # of triggers registered : " << fRegisteredTriggers.GetSize() << std::endl;
576  out << " + # of triggers running : " << fRunningTriggers.GetSize() << std::endl;
577  out << " + # of triggers lost (zombie) : " << fZombieTriggers.GetSize() << std::endl;
578  out << " + # of fired triggers : " << fTriggerRate << std::endl;
579  out << " + # frame read : " << fRead << std::endl;
580  out << " + # frame written : " << fWritten << std::endl;
581  if ( fConfIO->IsActive() ) {
582  out << " The dataflow is auto-reconfigurable " << std::endl;
583  out << " +";
584  fGlobalCounter.Print(out);
585  }
586  out << " ---> Details per trigger \n";
587  for( UShort_t i = 0u; i < fRegisteredTriggers.GetSize(); i++ ){
588 
589  DFTrigger *trig = fRegisteredTriggers.At(i); // if ( trig == 0x0 ) continue;
590 
591  out << " " << trig->GetName() << " is : \n";
592  if ( trig->IsActive() )
593  out << " + active " << std::endl;
594  else
595  out << " + inactive " << std::endl;
596  out << " +";
597  fTrigCountersIN[trig->GetUniqueID()].Print(out);
598  out << " +";
599  fTrigCountersOUT[trig->GetUniqueID()].Print(out);
600  }//i
601  out << " Frames without external trigger : \n";
602  out << " +";
603  fNoTrigCounterIN.Print(out);
604  out << " +";
605  fNoTrigCounterOUT.Print(out);
606 }
607 
609 {
610  // for efficiency, the log system is activated only in case of real need
611  //Log.SetProcessMethod("Record(DFTrigger *trig)");
612 
613  //if ( GetStatus() != BaseFrameIO::kRunning ) {
614  // Log.SetProcessMethod("Record(DFTrigger *trig)");
615  // Log << error << "Status is not kRunning !" << dolog;
616  // return false;
617  //}
618 
619  //if ( trig->GetOutputFrame() == 0x0 )
620  // return true; // nothing to record ... read only triggers
621 
622  if ( fOuFB->GetModeIO() == ConfAgent::kRead ) {
623  Log.SetProcessMethod("Record(DFTrigger *trig)");
624  Log << error << "Output frame block is not writable !" << dolog;
625  return false;
626  }
627 
628  Bool_t ok = true;
629 
630  // build the complete output frame
631  // if not a composite frame, only the output frame is returned, otherwise
632  // a frame which embedds the output is returned
633  // clone of the main input
634  ConfAgent::EModel mod = GetModel();
635  Frame *result = trig->GetEmbeddedOutputFrame(mod);
636  if ( result ) {
637 
638  // in case the input frame is not a container for the produced output frame.
639  Frame *inframe = trig->GetInputFrame();
640 
641  // required length for the full frame
642  UInt_t needed = result->GetLength();
643 
644  // in case of non-embedded frame, the input frame is written
645  // on the output dataflow, depending on the model
646  if ( !result->IsComposite() && inframe ) {
647  switch( GetModel() ){
648  case ConfAgent::kStrict:
649  case ConfAgent::kSafe:
650  if ( !trig->IsConsumable() )
651  needed += inframe->GetLength();
652  break;
653  case ConfAgent::kGrowing:
654  needed += inframe->GetLength();
655  break;
656  }
657  }
658 
659  // cannot put all the frames on the output, so get out
660  if ( fOuFB->Reserve(needed,true) == false ) {
661  Log.SetProcessMethod("Record(DFTrigger *trig)");
662  Log << error << "Cannot write any more in output block " << dolog;
663  return false;
664  }
665 
666  // to keep the current position
667  fOuFB->Snapshot();
668 
669  // Export the frame in the destination buffer
670  ok = ok && fOuFB->AddFrame((*result));
671  if ( !result->IsComposite() && inframe && ok ) {
672  switch( GetModel() ){
673  case ConfAgent::kStrict:
674  case ConfAgent::kSafe:
675  if ( !trig->IsConsumable() )
676  ok = ok && fOuFB->AddFrame((*inframe));
677  break;
678  case ConfAgent::kGrowing:
679  ok = ok && fOuFB->AddFrame((*inframe));
680  break;
681  }
682  }
683  if ( ok ) {
684  fWritten++;
685  fTrigCountersOUT[trig->GetUniqueID()] += needed;
686  }
687  else {
688  fOuFB->BackToSnapshot();
689  Log.SetProcessMethod("Record(DFTrigger *trig)");
690  Log << error << "Cannot write output frame, back to snapshot " << nline << dolog;
691  ok = false;
692  }
693  }
694  else {
695  Log.SetProcessMethod("Record(DFTrigger *trig)");
696  Log << error << "Cannot fill output frame " << nline << dolog;
697  ok = false;
698  }
699 
700  /*Log << dolog; */return ok;
701 }
702 
703 
705 {
706  Bool_t ok = true;
707 
708  // first treat pending WriteOnlytrigger
709  for( UShort_t i = 0u; i < fWriteOnlyTriggers.GetSize(); i++ ) {
710  DFTrigger *trig = fWriteOnlyTriggers.At(i);
711  if ( trig->IsActive() && trig->IsFired() )
712  ok = ok && Record(trig);
713  trig->Fired(false);
714  } // i
715  // check running triggers.
716  for( UShort_t i = 0u; i < fRunningTriggers.GetSize(); i++ ) {
717  DFTrigger *trig = fRunningTriggers.At(i);
718  if ( trig->IsActive() && trig->IsFired() )
719  ok = ok && Record(trig);
720  }
721  return ok;
722 }
723 
725 {
726  if ( in ) {
727  // rewind to be ready to read the input block
728  fInFB = in;
729  if ( fDoRewind )
730  fInFB->Rewind(ConfAgent::kRead);
731  }
732  if ( out ) {
733  fOuFB = out;
734  // rewind to be ready to write in the output block
735  if ( fDoRewind ) {
736  fOuFB->Rewind(ConfAgent::kWrite);
737  }
738  }
739 }
740 
742 {
743  if ( in )
744  fInFB = fDefaultInFB;
745  if ( out )
746  fOuFB = fDefaultOuFB;
747 }
748 
749 
750 
751 
virtual UInt_t GetLength() const
total length for that frame
Definition: Frame.h:360
virtual Bool_t Check(DFTrigger *, PtrStack< DFTrigger > &, PtrStack< DFTrigger > &)
check if a trigger is suitable for the dataflow
Definition: FrameIO.cpp:224
virtual BufferIO & GetFrame(UInt_t which=0u)=0
the new frame is wrapped in a BufferIO object for transportation between the different classes ...
virtual void SetLevel(ELevel lev, unsigned short verbosity=0u)
To get the current level of the message.
const FactoryItem & GetPrimaryKey() const
Just to know if the size of the frame is coded on 2 bytes, 4 bytes ... or 8 bytes.
Definition: DFAgent.cpp:256
virtual Key * GetKey()=0
To get the Key associated to this frame.
EStatus GetStatus() const
Definition: FrameIO.h:126
virtual Long64_t GetSize(UInt_t=0u) const
size of the current block
Definition: FrameBlock.h:141
Base class for a Key.
Definition: Key.h:56
header file for FactoryItem.cpp
Base class for a Frame.
Definition: Frame.h:73
header file for KeyFactory.cpp
virtual void Unlink()
Copy a buffer to this Frame.
Definition: Frame.h:433
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual Frame * GetOutputFrame()=0
to get back the output frame
Bool_t DoGlobalReconfiguration()
Definition: FrameIO.cpp:286
const FactoryItem & GetSignature() const
Definition: Key.h:115
Bool_t InitFromAgent()
Definition: FrameIO.cpp:153
virtual Bool_t Notify(Bool_t with_inner_trigger=false)
To know the number of registered triggers.
Definition: FrameIO.cpp:447
static const Char_t * GetStringModel(ConfAgent::EModel)
Definition: ConfAgent.cpp:78
EStatus
current state of the FrameIO
Definition: FrameIO.h:74
A configuration frame is just an encapsulation of a string.
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
Definition: FrameIO.cpp:103
A Block of Frames.
Definition: FrameBlock.h:43
LogMessage & error(LogMessage &)
Bool_t IsActive() const
Check if this trigger is in fired state.
Definition: Trigger.h:126
virtual DFAgent * GetDFAgent()=0
to get the Data Flow Agent in charge of knowing the structure of the DF
void SetEoB(Bool_t b)
Definition: FrameBlock.h:89
A Counter.
Definition: Counter.h:42
ConfAgent::EModel GetModel() const
Definition: FrameIO.cpp:98
ConfAgent::EMode GetModeIO() const
Return the operating mode.
Definition: FrameBlock.h:79
virtual void SetModeIO(ConfAgent::EMode mode)
Definition: FrameBlock.h:81
virtual Bool_t Check()
Check if the currently read key fired this trigger. If yes, IsFired is true.
Definition: Trigger.h:138
void SetModel(ConfAgent::EModel model)
Definition: FrameIO.cpp:93
header file for Key.cpp
static ConfAgent * theGlobalAgent(std::string="Agata")
to get the global agent
Definition: ConfAgent.cpp:402
void Fired(Bool_t b=true)
Fired (default) or not this trigger.
Definition: Trigger.h:106
UInt_t GetUniqueID()
Definition: Trigger.h:99
UInt_t Size() const
it returns the maximum number of bytes in this buffer
Definition: BufferIO.h:220
virtual UInt_t GetNbInputFrame() const =0
number of input frames that define this trigger
header file for Trigger.cpp
virtual Bool_t IsComposite() const
tells if this frame is a composite frame i.e. if it is composed of sub-frames
Definition: Frame.h:212
virtual Bool_t Register(DFTrigger *)
To register a trigger.
Definition: FrameIO.cpp:368
const UInt_t aMByte
Definition: BaseBuffer.h:36
BaseFrameIO(const char *)
Definition: FrameIO.cpp:47
virtual const std::string & GetName() const
Name of this FrameIO.
Definition: FrameIO.h:99
Base class for a generic frame trigger.
Definition: Trigger.h:249
Base class to get/write Frames.
Definition: FrameIO.h:70
virtual Frame * GetEmbeddedOutputFrame(ConfAgent::EModel model=ConfAgent::kStrict)=0
Return the true output frame.
virtual Bool_t Configure(ConfigurationFrame *, const char *option="in", Bool_t allow_init=false)
configuration from/to a configuration frame : extact string from the frame and call DoConfigure ...
Definition: DotConf.cpp:343
virtual const Char_t * GetType() const
Definition: FrameIO.h:105
virtual ConfAgent * Clone(const char *comment="Clone of the global ConfAgent")=0
Clone of the main (global) Agent.
virtual void Detach(FrameBlock *in, FrameBlock *out)
Definition: FrameIO.cpp:741
void SetStatus(EStatus stat)
Definition: FrameIO.h:110
virtual void SetProcessMethod(const char *)
To set the current method.
virtual void BackToSnapshot()
back to the last position
Definition: FrameBlock.h:174
PtrStack.
Definition: PtrStack.h:59
virtual void Unlink()=0
UnLink a buffer to this Frame.
virtual Frame * GetInputFrame(UInt_t which=0u)=0
to get back the frames that define this trigger
void Active(Bool_t b=true)
Active this trigger.
Definition: Trigger.h:122
bool IsDebug(short debug_to_test) const
to test if the required debug level is lower that the global one
LogMessage & nline(LogMessage &)
virtual ~FrameIO()
Definition: FrameIO.cpp:202
virtual Bool_t DoConfigure(std::istream &, Bool_t allow_init)
configure this from an input stream
virtual Long64_t GetOffset(UInt_t=0u) const
Current position.
Definition: FrameBlock.h:147
virtual Bool_t NextFrame()
to know if there is a next frame of the dataflow
Definition: FrameIO.cpp:359
const std::string & GetName() const
Definition: Trigger.h:102
void Add(T *t)
Add a new pointer on the stack.
Definition: PtrStack.h:97
It implements a black hole for Frames.
Definition: FrameBlock.h:323
Bool_t IsFired() const
Check if this trigger is in fired state.
Definition: Trigger.h:110
virtual Bool_t NextFrame(Key *)=0
true if there is a new frame available in the block
FrameIO(const char *)
Definition: FrameIO.cpp:110
virtual Bool_t AddFrame(const BufferIO &, UInt_t=0u)
Add a Frame to the block.
Definition: FrameBlock.h:154
header file for DFAgent.cpp
virtual UInt_t GetLength() const =0
total length for that frame
EModel
Model for FrameIO.
Definition: ConfAgent.h:69
Bool_t IsZombie() const
Check if this trigger is in fired state.
Definition: Trigger.h:114
Base class for a trigger on a data flow.
Definition: Trigger.h:155
header file for FrameIO.cpp
ConfAgent::EModel GetModel() const
Definition: DFAgent.h:152
ADF::LogMessage & endl(ADF::LogMessage &log)
void SetModel(ConfAgent::EModel model)
Definition: DFAgent.h:158
virtual Bool_t Link(const Char_t *, UInt_t, const char= 'b')=0
Link a buffer to this Frame.
virtual Bool_t Record()
Definition: FrameIO.cpp:704
virtual Bool_t Reserve(UInt_t, Bool_t=false, UInt_t=0u)
Reserve the given size for writing.
Definition: FrameBlock.h:137
virtual std::string GetDFOption(UInt_t=0u) const
data flow option for that particular input
Definition: Trigger.h:170
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
Definition: FrameIO.cpp:571
void Print(std::ostream &out=std::cout) const
Definition: Counter.cpp:53
LogMessage Log
to send messages to the log server
Definition: FrameIO.h:89
virtual void SetStreamOption(const Char_t *opt)
Definition: DotConf.h:264
LogMessage & dolog(LogMessage &)
virtual void Attach(FrameBlock *in, FrameBlock *out)
Attach a block to this. Rewind called if DoRewind set to true (Default)
Definition: FrameIO.cpp:724
virtual ~BaseFrameIO()
Definition: FrameIO.cpp:60
virtual Bool_t RecordGlobalConfiguration(const std::string="NO")
write the current configuration in the output data
Definition: FrameIO.cpp:247
const FactoryItem & GetAutoConfFrame() const
Definition: DFAgent.h:167
virtual Bool_t IsConsumable(UInt_t which=0u) const =0
to know if the frame is consumable or not
virtual DFTrigger * GetTrigger(const Char_t *)
To retrieve a trigger by its unique name.
Definition: FrameIO.cpp:433
ConfAgent * GetConfAgent() const
Return the agent which keeps the current configuration for that FrameIO.
Definition: FrameIO.h:116
virtual Bool_t Reconfigure(ConfAgent *)=0
Modify the Frame definitions respecting the new data flow definition and the acceptable Frame changes...
virtual SharedFP * Add(const FactoryItem &key_item, const FactoryItem &frame_item, bool iscons=true, const Char_t *option="")=0
Add a frame to the Embedded list of required frames.
static MainKeyFactory & theMainFactory()
the main (global) keyfactory
Definition: KeyFactory.cpp:150
virtual void Rewind(ConfAgent::EMode mode=ConfAgent::kRead)=0
Rewind to be ready to be used again.
virtual Key * New(const FactoryItem &)
build a key using item.
Definition: KeyFactory.cpp:155
virtual void Snapshot()
keep the current position
Definition: FrameBlock.h:171
virtual void FastReset()
FastReset the current frame, means the data part keep the previous values.
Definition: Frame.h:526
const FactoryItem & GetAutoConfKey() const
To get the definition of the Key and Frame associated to a global reconfiguration.
Definition: DFAgent.h:165
virtual const char * GetStringStatus(EStatus) const
string corresponding to the current status
Definition: FrameIO.cpp:67
Base class that described an item in a Factory.
Definition: FactoryItem.h:52
LogMessage & warning(LogMessage &)
const FactoryItem & GetSignature() const
Signature of that frame.
Definition: Frame.h:127