35 #ifndef ADF_KeyFactory
38 #ifndef ADF_ConfigurationFrame
69 const char *status = 0x0;
72 status =
"kUndefined";
81 status =
"kSuspended";
118 fRegisteredTriggers(),
120 fWriteOnlyTriggers(),
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"),
127 fRead(0u), fWritten(0u), fTriggerRate(0u), fDoRewind (true)
135 fInFB = fDefaultInFB;
140 fOuFB = fDefaultOuFB;
143 fRegisteredTriggers.SetOwner(
false);
144 fRunningTriggers.SetOwner(
false);
145 fWriteOnlyTriggers.SetOwner(
false);
146 fZombieTriggers.SetOwner(
false);
168 if ( new_key == 0x0 ) {
195 Log <<
info <<
"The data flow is auto-reconfigurable "
205 fRegisteredTriggers.Delete(); fRunningTriggers.Delete(); fZombieTriggers.Delete();
279 <<
"Global configuration frame cannot be sent to output " <<
nline;
291 <<
" a Global configuration frame has been found ==> reconfiguration " <<
nline;
303 Log <<
error <<
"Reconfiguration of ConfAgent fails !!! ==> Stop, status undefined " <<
nline;
315 Log <<
error <<
"Reconfiguration of FrameIO from new ConfAgent fails !!! " <<
dolog;
318 else fConfIO->
Fired(
true);
323 fRunningTriggers.Clear();
324 for(UInt_t i = 0u ; i < fRegisteredTriggers.GetSize() ; i++ ){
327 fRegisteredTriggers.At(i);
331 ok =
Check(trig,fRunningTriggers,fZombieTriggers);
333 ok =
Check(trig,fWriteOnlyTriggers,fZombieTriggers);
337 <<
" - is suitable for the current dataflow ==> set ACTIVE " <<
nline;
340 <<
" - is NOT suitable for the current dataflow ==> set INACTIVE " <<
nline;
344 Log <<
info <<
"Reconfiguration of ConfAgent from Configuration Frame is done properly. New Conf : " <<
nline;
383 fRegisteredTriggers.Add( trig );
385 Check(trig,fRunningTriggers,fZombieTriggers);
391 Log <<
info <<
"A new NON RUNNING Trigger has just been added : " << trig->
GetName() <<
nline;
411 fRegisteredTriggers.Add( trig );
413 Check(trig,fWriteOnlyTriggers,fZombieTriggers);
415 Log <<
info <<
"A new WRITE ONLY Trigger has just been added : " << trig->
GetName() <<
nline;
423 while ( fTrigCountersIN.size() <= trig->
GetUniqueID() ) {
424 fTrigCountersIN.push_back(c_in); fTrigCountersOUT.push_back(c_out);
437 for(UInt_t i = 0u ; i < fRegisteredTriggers.GetSize() ; i++ ){
439 fRegisteredTriggers.At(i);
440 if ( trig->
GetName().find(trigname) == 0 ) {
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 ;
474 Bool_t is_treated =
false;
479 if ( fConfIO->
Check() ) {
484 if ( with_inner_trigger )
495 Bool_t all_trigger_ok;
496 all_trigger_ok =
false;
497 for( UShort_t i = 0u; i < fRunningTriggers.GetSize(); i++ ) {
499 Bool_t this_ok =
false;
502 DFTrigger *trig = fRunningTriggers.At(i);
506 this_ok = trig->
Check();
511 all_trigger_ok =
true;
517 if ( all_trigger_ok )
518 { fTriggerRate+=1u;
return all_trigger_ok; }
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;
582 out <<
" The dataflow is auto-reconfigurable " <<
std::endl;
584 fGlobalCounter.
Print(out);
586 out <<
" ---> Details per trigger \n";
587 for( UShort_t i = 0u; i < fRegisteredTriggers.GetSize(); i++ ){
589 DFTrigger *trig = fRegisteredTriggers.At(i);
591 out <<
" " << trig->
GetName() <<
" is : \n";
593 out <<
" + active " << std::endl;
601 out <<
" Frames without external trigger : \n";
603 fNoTrigCounterIN.
Print(out);
605 fNoTrigCounterOUT.
Print(out);
624 Log <<
error <<
"Output frame block is not writable !" <<
dolog;
660 if ( fOuFB->
Reserve(needed,
true) == false ) {
662 Log <<
error <<
"Cannot write any more in output block " <<
dolog;
670 ok = ok && fOuFB->
AddFrame((*result));
676 ok = ok && fOuFB->
AddFrame((*inframe));
679 ok = ok && fOuFB->
AddFrame((*inframe));
709 for( UShort_t i = 0u; i < fWriteOnlyTriggers.GetSize(); i++ ) {
710 DFTrigger *trig = fWriteOnlyTriggers.At(i);
716 for( UShort_t i = 0u; i < fRunningTriggers.GetSize(); i++ ) {
717 DFTrigger *trig = fRunningTriggers.At(i);
744 fInFB = fDefaultInFB;
746 fOuFB = fDefaultOuFB;
virtual UInt_t GetLength() const
total length for that frame
virtual Bool_t Check(DFTrigger *, PtrStack< DFTrigger > &, PtrStack< DFTrigger > &)
check if a trigger is suitable for the dataflow
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.
virtual Key * GetKey()=0
To get the Key associated to this frame.
EStatus GetStatus() const
virtual Long64_t GetSize(UInt_t=0u) const
size of the current block
header file for FactoryItem.cpp
header file for KeyFactory.cpp
virtual void Unlink()
Copy a buffer to this Frame.
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual Frame * GetOutputFrame()=0
to get back the output frame
Bool_t DoGlobalReconfiguration()
const FactoryItem & GetSignature() const
virtual Bool_t Notify(Bool_t with_inner_trigger=false)
To know the number of registered triggers.
static const Char_t * GetStringModel(ConfAgent::EModel)
EStatus
current state of the FrameIO
A configuration frame is just an encapsulation of a string.
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
LogMessage & error(LogMessage &)
Bool_t IsActive() const
Check if this trigger is in fired state.
virtual DFAgent * GetDFAgent()=0
to get the Data Flow Agent in charge of knowing the structure of the DF
ConfAgent::EModel GetModel() const
ConfAgent::EMode GetModeIO() const
Return the operating mode.
virtual void SetModeIO(ConfAgent::EMode mode)
virtual Bool_t Check()
Check if the currently read key fired this trigger. If yes, IsFired is true.
void SetModel(ConfAgent::EModel model)
static ConfAgent * theGlobalAgent(std::string="Agata")
to get the global agent
void Fired(Bool_t b=true)
Fired (default) or not this trigger.
UInt_t Size() const
it returns the maximum number of bytes in this buffer
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
virtual Bool_t Register(DFTrigger *)
To register a trigger.
BaseFrameIO(const char *)
virtual const std::string & GetName() const
Name of this FrameIO.
Base class for a generic frame trigger.
Base class to get/write Frames.
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 ...
virtual const Char_t * GetType() const
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)
void SetStatus(EStatus stat)
virtual void SetProcessMethod(const char *)
To set the current method.
virtual void BackToSnapshot()
back to the last position
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.
bool IsDebug(short debug_to_test) const
to test if the required debug level is lower that the global one
LogMessage & nline(LogMessage &)
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.
virtual Bool_t NextFrame()
to know if there is a next frame of the dataflow
const std::string & GetName() const
void Add(T *t)
Add a new pointer on the stack.
It implements a black hole for Frames.
Bool_t IsFired() const
Check if this trigger is in fired state.
virtual Bool_t NextFrame(Key *)=0
true if there is a new frame available in the block
virtual Bool_t AddFrame(const BufferIO &, UInt_t=0u)
Add a Frame to the block.
header file for DFAgent.cpp
virtual UInt_t GetLength() const =0
total length for that frame
Bool_t IsZombie() const
Check if this trigger is in fired state.
Base class for a trigger on a data flow.
header file for FrameIO.cpp
ConfAgent::EModel GetModel() const
ADF::LogMessage & endl(ADF::LogMessage &log)
void SetModel(ConfAgent::EModel model)
virtual Bool_t Link(const Char_t *, UInt_t, const char= 'b')=0
Link a buffer to this Frame.
virtual Bool_t Reserve(UInt_t, Bool_t=false, UInt_t=0u)
Reserve the given size for writing.
virtual std::string GetDFOption(UInt_t=0u) const
data flow option for that particular input
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
void Print(std::ostream &out=std::cout) const
LogMessage Log
to send messages to the log server
virtual void SetStreamOption(const Char_t *opt)
LogMessage & dolog(LogMessage &)
virtual void Attach(FrameBlock *in, FrameBlock *out)
Attach a block to this. Rewind called if DoRewind set to true (Default)
virtual Bool_t RecordGlobalConfiguration(const std::string="NO")
write the current configuration in the output data
const FactoryItem & GetAutoConfFrame() const
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.
ConfAgent * GetConfAgent() const
Return the agent which keeps the current configuration for that FrameIO.
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
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.
virtual void Snapshot()
keep the current position
virtual void FastReset()
FastReset the current frame, means the data part keep the previous values.
const FactoryItem & GetAutoConfKey() const
To get the definition of the Key and Frame associated to a global reconfiguration.
virtual const char * GetStringStatus(EStatus) const
string corresponding to the current status
Base class that described an item in a Factory.
LogMessage & warning(LogMessage &)
const FactoryItem & GetSignature() const
Signature of that frame.