Commit f21eea76 authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

*** MAJOR modifications to have more multi-thread safe actors and to have an...

*** MAJOR modifications to have more multi-thread safe actors and to have an easier extendable agata key/frame system

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@1635 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent 806013d2
......@@ -2,7 +2,7 @@
# This is a begin of the ADF configuration record
# Option is Init. It means the Agent is reset before being initialised
#
#////ADF::ConfAgent_beg//// Agata 0 Init
#////ADF::ConfAgent_beg//// Agata 1 Init
#
#
Endian: kLittle
......@@ -11,12 +11,12 @@ Endian: kLittle
#
# Factories for Keys
#
KeyFactory: Default
KeyFactory: Agata
KeyFactory: Default
KeyFactory: Agata
#
# Factories for Frames
#
FrameFactory: Agata
FrameFactory: Agata
#
#
# Version of the primary key that structures the data flow
......@@ -24,7 +24,8 @@ FrameFactory: Agata
#
PrimaryKey: Default FS 0 1
#
AutoConf: Agata conf:global 2 0 Agata conf:global 0 0
# comment/uncomment to switch off/on auto-reconf
#AutoConf: Agata conf:global 2 0 Agata conf:global 0 0
#
#
# Current Frames going through the data flow
......@@ -34,7 +35,7 @@ AutoConf: Agata conf:global 2 0 Agata conf:global 0 0
#
#////ADF::ConfAgent_end////
#
#////ADF::AgataKeyFactory_beg//// - 1 Init
#////ADF::AgataKeyFactory_beg//// - -1 Init
#
# Definition of the message part for Agata like Keys
#
......@@ -44,40 +45,70 @@ AutoConf: Agata conf:global 2 0 Agata conf:global 0 0
# message is the message part as coded in the key
# mask is to be used to extract part of the message when comparing keys
#
# with 0xFAXXYYZZ
# with 0xWAXXYYZZ
#
# W = F for simple frame, C for composite frame - A means used AgataKey factory
#
# XX = Sub-detector number (associated to a given factories)
# 01 for Agata (Agata factory), pure Agata
# 02 for Agata (Agata factory), ranc Agata
# 01 for Agata (Agata Frame factory), pure Agata
# 02 for Agata (Agata Frame factory), raw ancillary for Agata
# > 02 for other factories
# YY = Frame type
# 01 data (produce by online algorithm)
# 11 meta (general, does not depend on an algorithm)
# 02 conf (conf associated)
# 03 info
# ZZ = Producer ID, should be unique in the data flow
#
agata 0xFA000000 0xFF000000
conf 0xFA000200 0xFF000F00
conf:global 0xFA000200 0xFFFFFFFF
conf:crystal 0xFA010201 0xFFFFFFFF
conf:psa 0xFA010202 0xFFFFFFFF
conf:ranc0 0xFA0202A0 0xFFFFFFFF
conf:ranc1 0xFA0202A1 0xFFFFFFFF
conf:ranc2 0xFA0202A2 0xFFFFFFFF
data 0xFA000100 0xFF000F00
# 01 data (produce/consume by algorithm)
# 11 meta (general, does not depend on an algorithm)
# 02 conf (conf associated to a data/meta frame)
# 03 algo (conf specific for an algorithm)
# 04 info (conf like, just some comments)
# 05 rmess (message, raw frame)
# 06 cmess (message, conf frame)
#
# ZZ = ALGO ID, should be unique in the data flow
#
#agata 0x0A000000 0x0F000000
#
#data 0x0A000100 0x0F000F00
data:crystal 0xFA010101 0xFFFFFFFF
data:ccrystal 0xFA010111 0xFFFFFFFF
data:psa 0xFA010102 0xFFFFFFFF
event:data:psa 0xFA010103 0xFFFFFFFF
event:data 0xFA010104 0xFFFFFFFF
data:psa 0xFA010102 0xFFFFFFFF
data:eb 0xFA010103 0xFFFFFFFF
data:merger 0xFA010104 0xFFFFFFFF
data:tracked 0xFA010105 0xFFFFFFFF
data:ranc0 0xFA0201A0 0xFFFFFFFF
data:ranc1 0xFA0201A1 0xFFFFFFFF
data:ranc2 0xFA0201A2 0xFFFFFFFF
meta 0xFA001100 0xFF00FF00
meta:sync 0xFA011100 0xFFFFFFFF
meta:vertex 0xFA011101 0xFFFFFFFF
data:ranc0 0xFA0201A0 0xFFFFFFFF
data:ranc1 0xFA0201A1 0xFFFFFFFF
data:ranc2 0xFA0201A2 0xFFFFFFFF
#
#meta 0x0A001100 0x0F00FF00
meta:eof 0x0A001100 0x0FFFFFFF
meta:sync 0xFA011101 0xFFFFFFFF
meta:vertex 0xFA011102 0xFFFFFFFF
#
#conf 0x0A000200 0x0F00FF00
conf:global 0xFA000200 0xFFFFFFFF
conf:crystal 0xFA010201 0xFFFFFFFF
conf:psa 0xFA010202 0xFFFFFFFF
conf:eb 0xFA010203 0xFFFFFFFF
conf:merger 0xFA010204 0xFFFFFFFF
conf:tracked 0xFA010205 0xFFFFFFFF
conf:ranc0 0xFA0202A0 0xFFFFFFFF
conf:ranc1 0xFA0202A1 0xFFFFFFFF
conf:ranc2 0xFA0202A2 0xFFFFFFFF
#
#algo 0xFA000300 0x0F00FF00
algo:crystal 0xFA010301 0xFFFFFFFF
algo:ccrystal 0xFA010311 0xFFFFFFFF
algo:psa 0xFA010302 0xFFFFFFFF
algo:eb 0xFA010303 0xFFFFFFFF
algo:merger 0xFA010304 0xFFFFFFFF
algo:tracked 0xFA010305 0xFFFFFFFF
#
#rmess 0x0A000400 0x0F00FF00
#cmess 0x0A000500 0x0F00FF00
#
#event 0xCA000000 0xFF000000
event:data 0xCA000100 0xFF000F00
event:data:crystal 0xCA010101 0xFFFFFFFF
event:data:psa 0xCA010102 0xFFFFFFFF
event:data:tracked 0xCA010103 0xFFFFFFFF
#
#////ADF::AgataKeyFactory_end////
#
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -40,8 +40,8 @@ class AgataCompositeFrame : public CompositeFrame
{
friend class AgataFrameFactory;
protected:
AgataCompositeFrame(const Key *akey, const Char_t *which_key, Version version)
: CompositeFrame(akey,"Agata",which_key,version) {;}
AgataCompositeFrame(Key *akey, const FactoryItem &secondary_key): CompositeFrame(akey,FactoryItem("Agata",secondary_key.GetFactoryVersion(),secondary_key.GetItemName().data(),secondary_key.GetVersion()))
{;}
public:
virtual ~AgataCompositeFrame()
{;}
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -41,8 +41,8 @@ class AgataConfigurationFrame : public ConfigurationFrame
friend class AgataFrameFactory;
protected:
AgataConfigurationFrame(const Key *key):
ConfigurationFrame(key) {;}
AgataConfigurationFrame(Key *key): ConfigurationFrame(key)
{;}
public:
virtual ~AgataConfigurationFrame()
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -41,7 +41,7 @@ class AgataDataFrame : public ConcreteDataFrame< Data_T >
friend class AgataFrameFactory;
protected:
AgataDataFrame(const Key *key):
AgataDataFrame(Key *key):
ConcreteDataFrame< Data_T >(key) {;}
//! to get from the frame the data content
......
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -48,183 +48,127 @@ using namespace ADF;
AgataFrameFactory::AgataFrameFactory(): AFrameFactory<AgataFrameFactory>("Agata")
{
// set reference to this method for log system
fLog.GetProcessName() = "AgataFrameFactory"; fLog.SetProcessMethod("AgataFrameFactory()");
AgataKeyFactory *fact = AKeyFactory<AgataKeyFactory>::theFactory();
// default key is Agata agata version 1,0 (length and message type)
if ( fact ) {
AgataKey *a_primary_key =
static_cast<AgataKey *>(fact->New("agata",Version(1,0)));
if ( a_primary_key ) {
// this is the default primary key
SetPrimaryKey(a_primary_key);
delete a_primary_key;
}
else { fLog << error << " Cannot get an AgataKey(1,0) from AgataKeyFactory" << nline; }
}
else { fLog << error << " AgataKeyFactory does not exist" << nline; }
fLog << dolog;
}
Frame *AgataFrameFactory::NewImp(const Char_t *which_frame, Version version)
SharedFP *AgataFrameFactory::DoNew(Key *key, const FactoryItem & which_frame)
{
Frame *frame = 0x0; std::string frametype = which_frame;
// Raw Frame
if ( frametype.find("agata") != std::string::npos )
frame = new AgataRawFrame(GetPrimaryKey());
// cannot deal with request asking for a version greater that this version
if ( which_frame.GetFactoryVersion() > GetMaxVersion() )
return 0x0;
// allocation is done in two steps. First Frame, then the SharedFP. Specific ones (inheriting for SharedFP) could be implemented. So far only SharedFP
SharedFP *sfp = 0x0; Frame *frame = 0x0;
// conf frames
if ( frametype.find("conf") != std::string::npos )
frame = new AgataConfigurationFrame(GetPrimaryKey());
// just a raw Frame
if ( which_frame.GetItemName().find("agata") == 0 ) {
frame = new AgataRawFrame(key);
}
// any conf frames
if ( which_frame.GetItemName().find("conf") == 0 ) {
frame = new AgataConfigurationFrame(key);
}
// any algo frames
if ( which_frame.GetItemName().find("algo") == 0 ) {
frame = new AgataConfigurationFrame(key);
}
// just a raw frame that can be used by the user to send messages
if ( which_frame.GetItemName().find("rmess") == 0 ) {
frame = new AgataRawFrame(key);
}
// just a conf frame that can be used by the user to send messages
if ( which_frame.GetItemName().find("cmess") == 0 ) {
frame = new AgataConfigurationFrame(key);
}
// data frames
// CRYSTAL --------------------------------------------------------------------------- //
if ( frametype == "data:crystal" ) {
if ( version == Version(65000,0) )
frame = new CrystalFrame_0(GetPrimaryKey());
if ( which_frame.GetItemName() == "data:crystal" ) {
if ( which_frame.GetVersion() == Version(65000,0) )
frame = new CrystalFrame_0(key);
}
/*
if ( frametype == "proxy:data:crystal" ) {
// first allocate the embedded frame USING the factory to properly set the Signature !!
// try with the version asked
ACrystalFrame *fimp = 0x0;
fimp = dynamic_cast< ACrystalFrame* > (New("data:crystal",version));
// default ?
if ( fimp == 0x0 )
fimp = dynamic_cast< ACrystalFrame* > (New("data:crystal",Version(65000,0)));
frame =
new ProxyDataFrame< ACrystalFrame, CrystalInterface >( fimp );
} */
if ( frametype == "data:ccrystal" ) {
if ( version == Version(65000,0) )
frame = new CrystalFrame_1(GetPrimaryKey());
if ( which_frame.GetItemName() == "data:ccrystal" ) {
if ( which_frame.GetVersion() == Version(65000,0) )
frame = new CrystalFrame_1(key);
}
/*
if ( frametype == "proxy:data:ccrystal" ) {
// first allocate the embedded frame USING the factory to properly set the Signature !!
// try with the version asked
ACrystalFrame *fimp = 0x0;
fimp = dynamic_cast< ACrystalFrame* > (New("data:ccrystal",version));
// default ?
if ( fimp == 0x0 )
fimp = dynamic_cast< ACrystalFrame* > (New("data:ccrystal",Version(65000,0)));
frame =
new ProxyDataFrame< ACrystalFrame, CrystalInterface >( fimp );
} */
// PSA --------------------------------------------------------------------------- //
if ( frametype == "data:psa" ) {
if ( version == Version(65000,0) )
frame = new PSAFrame_65000_0(GetPrimaryKey());
if ( version == Version(65000,1) )
frame = new PSAFrame_65000_1(GetPrimaryKey());
if ( which_frame.GetItemName() == "data:psa" ) {
if ( which_frame.GetVersion() == Version(65000,0) )
frame = new PSAFrame_65000_0(key);
if ( which_frame.GetVersion() == Version(65000,1) )
frame = new PSAFrame_65000_1(key);
}
/*
if ( frametype == "proxy:data:psa" ) {
// first allocate the embedded frame USING the factory to properly set the Signature !!
// try with the version asked
APSAFrame *fimp = 0x0;
fimp = dynamic_cast< APSAFrame* > (New("data:psa",version));
if ( fimp == 0x0 )
fimp = dynamic_cast< APSAFrame* > (New("data:psa",Version(65000,0))); // default
frame =
new ProxyDataFrame< APSAFrame, PSAInterface >( fimp );
} */
// Tracked --------------------------------------------------------------------------- //
if ( frametype == "data:tracked" ) {
if ( version == Version(65000,0) )
frame = new TrackedFrame_65000_0(GetPrimaryKey());
if ( version == Version(65000,1) )
frame = new TrackedFrame_65000_1(GetPrimaryKey());
if ( which_frame.GetItemName() == "data:tracked" ) {
if ( which_frame.GetVersion() == Version(65000,0) )
frame = new TrackedFrame_65000_0(key);
if ( which_frame.GetVersion() == Version(65000,1) )
frame = new TrackedFrame_65000_1(key);
}
/*
if ( frametype == "proxy:data:tracked" ) {
// first allocate the embedded frame USING the factory to properly set the Signature !!
// try with the version asked
ATrackedFrame *fimp = 0x0;
fimp = dynamic_cast< ATrackedFrame* > (New("data:tracked",version));
if ( fimp == 0x0 )
fimp = dynamic_cast< ATrackedFrame* > (New("data:tracked",Version(65000,0))); // default
frame =
new ProxyDataFrame< ATrackedFrame, GammaTrackedInterface >( fimp );
} */
// composite frames
// event:data --------------------------------------------------------------------------- //
if ( frametype == "event:data" ) {
// to test if the composite frame exists i.e. if the version of the key exist
Key *keytest = 0x0;
keytest = KeyFactory::New("Agata","data",version);
if ( keytest ) {
// frames are composed of any kind of agata keys
frame =
new AgataCompositeFrame(GetPrimaryKey(),"data",version);
// not needed anymore
delete keytest;
}
// by default not specific data means raw
if ( frame == 0x0 && which_frame.GetItemName().find("data") == 0 ) {
frame = new AgataRawFrame(key);
}
// event:data:psa --------------------------------------------------------------------------- //
if ( frametype == "event:data:psa" ) {
// data frames
// meta --------------------------------------------------------------------------- //
// eof End Of Frame/File
if ( which_frame.GetItemName() == "meta:eof" ) {
frame = new AgataRawFrame(key);
}
//
if ( which_frame.GetItemName() == "meta:sync" ) {
if ( which_frame.GetVersion() == Version(0,0) )
frame = new SyncFrame_0_0(key);
}
// VertexFrame
if ( which_frame.GetItemName() == "meta:vertex" ) {
if ( which_frame.GetVersion() == Version(0,0) )
frame = new VertexFrame_0_0(key);
if ( which_frame.GetVersion() == Version(0,1) )
frame = new VertexFrame_0_1(key);
if ( which_frame.GetVersion() == Version(1,0) )
frame = new VertexFrame_1_0(key);
if ( which_frame.GetVersion() == Version(1,1) )
frame = new VertexFrame_1_1(key);
}
// by default not specific data means raw
if ( frame == 0x0 && which_frame.GetItemName().find("meta") == 0 ) {
frame = new AgataRawFrame(key);
}
// meta --------------------------------------------------------------------------- //
// composite frames --------------------------------------------------------------------------- //
if ( which_frame.GetItemName().find("event") == 0 ) { //
//
std::string event_data_type(which_frame.GetItemName(),6);
// to test if the composite frame exists i.e. if the version of the key exist
Key *keytest = 0x0;
keytest = KeyFactory::New("Agata","data:psa",version);
//
FactoryItem secondary_key =
key->GetSignature();
secondary_key.SetItemName(event_data_type.data());
//
keytest = MainKeyFactory::theMainFactory().New(secondary_key);
if ( keytest ) {
// frames are composed of any kind of agata keys
frame =
new AgataCompositeFrame(GetPrimaryKey(),"data:psa",version);
new AgataCompositeFrame(key,secondary_key);
// not needed anymore
delete keytest;
}
}
// RawAncillaries --------------------------------------------------------------------------- //
if ( frametype.find("data:ranc") != std::string::npos ) {
frame = new AgataRawFrame(GetPrimaryKey());
}
}
// RawAncillaries --------------------------------------------------------------------------- //
// meta --------------------------------------------------------------------------- //
// VertexFrame
if ( frametype == "meta:vertex" ) {
if ( version == Version(0,0) )
frame = new VertexFrame_0_0(GetPrimaryKey());
if ( version == Version(0,1) )
frame = new VertexFrame_0_1(GetPrimaryKey());
if ( version == Version(1,0) )
frame = new VertexFrame_1_0(GetPrimaryKey());
if ( version == Version(1,1) )
frame = new VertexFrame_1_1(GetPrimaryKey());
}
if ( frametype == "meta:sync" ) {
if ( version == Version(0,0) )
frame = new SyncFrame_0_0(GetPrimaryKey());
}
/*
if ( frametype == "proxy:meta:vertex" ) {
// first allocate the embedded frame USING the factory to properly set the Signature !!
// try with the version asked
AVertexFrame *fimp = 0x0;
fimp = dynamic_cast< AVertexFrame* > (New("meta:vertex",version));
if ( fimp == 0x0 )
fimp = dynamic_cast< AVertexFrame* > (New("meta:vertex",Version(0,1))); // default
frame =
new ProxyDataFrame< AVertexFrame, VertexInterface >( fimp );
}
*/
// meta --------------------------------------------------------------------------- //
return frame;
// composite frames --------------------------------------------------------------------------- //
// now return SharedFP. If not specific, and frame is allocated, create a base one and add Frame to it
if ( sfp == 0x0 && frame )
sfp = new SharedFP(frame);
// WARNING : could be 0x0 !
return sfp;
}
......
/***************************************************************************
* Copyright (C) 2007 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -59,7 +59,7 @@ protected:
//! Ask this factory for a new Agata Frame
/*!
*/
virtual Frame *NewImp(const Char_t *which_frame, Version version);
virtual SharedFP *DoNew(Key *, const FactoryItem &);
};
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -28,7 +28,7 @@
// common to all agata keys
void ADF::AgataKey::Print(std::ostream &out) const
{
out << "[" << GetKeyType()
out << "[AgataKey"
<< " (" << GetVersion().GetMajor() << "," << GetVersion().GetMinor() << ")] "
<< std::dec
<< GetFrameLength()
......@@ -45,14 +45,11 @@ void ADF::AgataKey::Print(std::ostream &out) const