Commit 23fdb05a authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

import adf into the gammaware

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@576 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent 41555f81
#
# 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 1 Init
#
#
Endian: kLittle
#
# List of factories required
#
# Factories for Keys
#
KeyFactory: Default
KeyFactory: Agata
#
# Factories for Frames
#
FrameFactory: Agata
#
#
# Version of the primary key that structures the data flow
# and the frame expected to reconfigure it
#
PrimaryKey: Default FS 0 1
#
AutoConf: Agata conf:global 2 0 Agata conf:global 0 0
#
#
# Current Frames going through the data flow
#
#
# end of Data Flow Defaults
#
#////ADF::ConfAgent_end////
#
#////ADF::AgataKeyFactory_beg//// Init
#
# Definition of the message part for Agata like Keys
#
# Format: KeyNAME message mask
#
# KeyNAME is the string to be passed to the AgataKeyFactory. It should be unique !
# 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
#
# XX = Sub-detector number (associated to a given factories)
# 01 for Agata (Agata factory), others are for Ancillaries
# YY = 01 (Frame type)
# 01 data
# 02 service (configuration,info,interface)
# ZZ = Level inside the data flow
#
agata 0xFA000000 0xFF000000
conf 0xFA000200 0xFF00FF00
conf:global 0xFA000200 0xFFFFFFFF
conf:crystal 0xFA010201 0xFFFFFFFF
conf:psa 0xFA010202 0xFFFFFFFF
data 0xFA010000 0xFFFF0000
data:crystal 0xFA010101 0xFFFFFFFF
data:psa 0xFA010102 0xFFFFFFFF
event:data:psa 0xFA010103 0xFFFFFFFF
event:data 0xFA010104 0xFFFFFFFF
data:tracked 0xFA010105 0xFFFFFFFF
#
#////ADF::AgataKeyFactory_end////
#
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* agata(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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef ADF_ADFConfig
#include "ADFConfig.h"
#endif
#if ADF_STANDALONE == 1
#include "standalone/Env.h"
#else
#include "Env.h"
#endif
std::string ADF::BeginOfRecord(const char *class_name)
{
std::string bor = "#////"; bor += class_name; bor += "_beg////"; return bor;
}
std::string ADF::EndOfRecord(const char *class_name)
{
std::string eor = "#////"; eor += class_name; eor += "_end////"; return eor;
}
std::string ADF::GetPathToConfFile()
{
std::string tmp;
#if ADF_STANDALONE == 1
tmp = ADFPATHCONFFILE;
#else
tmp = Gw::Env::GetPath("LibPath");
#endif
return tmp;
}
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* agata(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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file ADFConfig.h to set informations about the ADF configuration
*
*
*/
#ifndef ADF_ADFConfig
#define ADF_ADFConfig
#define ADF_CONFIG_H ADF_ADFConfig
#include <string>
/* Define to 1 if compiled as a standalone library */
#define ADF_STANDALONE 0
/* Define to 1 if you have the Narval on your system </narval/xxx.h> header file. */
#define HAVE_NARVAL_H 0
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to the full name of this package. */
#undef PACKAGE_NAME
// ROOT includes in case the library is embedded in GammaWare
#if ADF_STANDALONE == 0
#ifndef ROOT_Bytes
#include <Bytes.h>
#endif
#else
//---- types from ROOT -------------------------------------------------------------------
typedef char Char_t; //Signed Character 1 byte (char)
typedef unsigned char UChar_t; //Unsigned Character 1 byte (unsigned char)
typedef short Short_t; //Signed Short integer 2 bytes (short)
typedef unsigned short UShort_t; //Unsigned Short integer 2 bytes (unsigned short)
typedef int Int_t; //Signed integer 4 bytes (int)
typedef unsigned int UInt_t; //Unsigned integer 4 bytes (unsigned int)
// Note: Long_t and ULong_t are currently not portable types
#ifdef R__B64
typedef long Long_t; //Signed long integer 8 bytes (long)
typedef unsigned long ULong_t; //Unsigned long integer 8 bytes (unsigned long)
#else
typedef long Long_t; //Signed long integer 4 bytes (long)
typedef unsigned long ULong_t; //Unsigned long integer 4 bytes (unsigned long)
#endif
#if defined(R__WIN32)
typedef __int64 Long64_t; //Portable signed long integer 8 bytes
typedef unsigned __int64 ULong64_t; //Portable unsigned long integer 8 bytes
#else
typedef long long Long64_t; //Portable signed long integer 8 bytes
typedef unsigned long long ULong64_t; //Portable unsigned long integer 8 bytes
#endif
typedef float Float_t; //Float 4 bytes (float)
typedef double Double_t; //Double 8 bytes
typedef double Double32_t; //Double 8 bytes in memory, written as a 4 bytes float
typedef bool Bool_t; //Boolean (0=false, 1=true) (bool)
#ifndef NULL
#define NULL 0
#endif
#endif
namespace ADF {
const UInt_t kMaxUChar_t = UChar_t(~0);
const Int_t kMaxChar_t = kMaxUChar_t >> 1;
const Int_t kMinChar_t = -kMaxChar_t - 1;
const UInt_t kMaxUShort_t = UShort_t(~0);
const Int_t kMaxShort_t = kMaxUShort_t >> 1;
const Int_t kMinShort_t = -kMaxShort_t - 1;
const UInt_t kMaxUInt_t = UInt_t(~0);
const Int_t kMaxInt_t = Int_t(kMaxUInt_t >> 1);
const Int_t kMinInt_t = -kMaxInt_t - 1;
const char kBool_t[] = "B";
const char kUShort_t[] = "US";
const char kShort_t[] = "S";
const char kUInt_t[] = "UI";
const char kInt_t[] = "I";
const char kULong64_t[] = "UL";
const char kLong64_t[] = "L";
const char kFloat_t[] = "F";
const char kDouble_t[] = "D";
std::string BeginOfRecord(const char *class_name);
std::string EndOfRecord(const char *class_name);
std::string GetPathToConfFile();
}
#endif
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file ADFObjects.cpp compiled in libGWADF.so */
#ifndef ADF_ADFObjects
#include "ADFObjects.h"
#endif
#ifndef ADF_BufferIO
#include "BufferIO.h"
#endif
#include <string>
using namespace ADF;
GObject::GObject() : fDataItems(), fDataLinks(), fArrayOfItems()
{
fDataItems.SetOwner(true);
fDataLinks.SetOwner(true);
}
GObject::~GObject()
{
fArrayOfItems.clear(); fDataItems.Delete(); fDataLinks.Delete();
}
NamedItem *GObject::IsItem(NamedItem *item)
{
return IsItem(item->Name().data(),item->Type().data());
}
NamedItem *GObject::IsItem(const Char_t *name, const Char_t *type)
{
UInt_t i, size = fArrayOfItems.size(); NamedItem *item = NULL;
for (i = 0u; i < size; i++) {
if ( fArrayOfItems[i].first->Name() == name && fArrayOfItems[i].first->IsType(type) ) {
item = fArrayOfItems[i].first;
}
}
return item;
}
Bool_t GObject::LinkItem(const Char_t *name, const Char_t *type, void *extern_address)
{
// datalink->Link(local_address,extern_address);
// Get ==> copy extern to local (Get methods always extract a value from an object
// Set ==> copy local to extern
Bool_t ok = false;
UInt_t i, size = fArrayOfItems.size(); NamedItem *item = NULL;
for (i = 0u; i < size; i++) {
if ( fArrayOfItems[i].first->Name() == name && fArrayOfItems[i].first->IsType(type) ) {
if ( fArrayOfItems[i].second )
return false; // already linked, only one possible
else {
item = fArrayOfItems[i].first;
DataLink *link =
item->GetDataLink(extern_address);
if ( link ) {
fArrayOfItems[i].second = link;
fDataLinks.Add(link);
ok = true;
}
}
}
}
return ok;
/*
// first look for a object with the same name and type in fDataItems
UInt_t i, size = fDataLinks.GetSize(); NamedItem *item = NULL;
for (i = 0; i < size; i++) {
if ( fDataItems.At(i)->Name().compare(name) == 0 )
item = fDataItems.At(i);
}
if ( item == NULL )
return false; // no item with such a name
if ( item->IsType(type) == false )
return false; // the item does not have the rigth type
DataLink *link = item->GetDataLink(extern_address);
if ( link == NULL )
return false;
fDataLinks.Add(link); // the link is ok, so added to the list of links
return true; */
}
Bool_t GObject::AddItem(NamedItem *item)
{
// check if an itenm with the same name and type already exist
UInt_t i, size = fArrayOfItems.size();
for (i = 0; i < size; i++) {
if (fArrayOfItems[i].first->Name() == item->Name() &&
fArrayOfItems[i].first->Type() == item->Type()) {
return false;
}
}
std::pair <NamedItem *,DataLink *> p;
p.first = item;
p.second = NULL;
fArrayOfItems.push_back( p ); fDataItems.Add(item);
return true;
}
void GObject::TransfertLink(GObject &to)
{
// loop on items in the from object
UInt_t i, sizei = fArrayOfItems.size();
for (i = 0u; i < sizei; i++) {
NamedItem *itemi = fArrayOfItems[i].first;
// this item has been linked
if ( fArrayOfItems[i].second ) {
// loop from a similar item in the to object
if ( to.IsItem(itemi) ) {
to.LinkItem(itemi->Name().data(),itemi->Type().data(),
fArrayOfItems[i].second->A2());
}
}
}
}
void GObject::SetItems() const
{
UInt_t i, size = fDataLinks.GetSize();
for (i = 0; i < size; i++)
fDataLinks.At(i)->CopyA2_to_A1();
}
void GObject::GetItems()
{
UInt_t i, size = fDataLinks.GetSize();
for (i = 0; i < size; i++)
fDataLinks.At(i)->CopyA1_to_A2();
}
void GObject::Reset()
{
UInt_t i, size = fDataItems.GetSize();
for (i = 0; i < size; i++)
fDataItems.At(i)->Reset();
}
void GObject::SetItems(BufferIO &buf) const
{
// first read items
UInt_t i, size = fDataItems.GetSize();
for (i = 0; i < size; i++)
fDataItems.At(i)->SetItem(buf);
}
void GObject::GetItems(const BufferIO &buf)
{
UInt_t i, size = fDataItems.GetSize();
for (i = 0; i < size; i++)
fDataItems.At(i)->GetItem(buf);
}
void Hit::SetHit(const Hit &ahit)
{
// position
SetXYZ(ahit.GetX(),ahit.GetY(),ahit.GetZ());
// error on position
SetDXYZ(ahit.GetDX(),ahit.GetDY(),ahit.GetDZ());
// energy and time
SetE(ahit.GetE()); SetDE(ahit.GetDE());
SetT(ahit.GetT()); SetDT(ahit.GetDT());
// status
SetStatus(ahit.GetStatus());
}
Signal *Signal::New(UInt_t length, const char *type)
{
Signal *sig = NULL; std::string stype = type;
// allocate the proper type
if ( stype.compare(kUShort_t) == 0 )
sig = new SignalUS(length);
if ( stype.compare(kShort_t) == 0 )
sig = new SignalS(length);
if ( stype.compare(kUInt_t) == 0 )
sig = new SignalUI(length);
if ( stype.compare(kInt_t) == 0 )
sig = new SignalI(length);
if ( stype.compare(kFloat_t) == 0 )
sig = new SignalF(length);
if ( stype.compare(kDouble_t) == 0 )
sig = new SignalD(length);
// What if the given string does not correspond to a good type ??
if ( sig == NULL )
sig = new SignalUS(length);
return sig;
}
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file AgataCompositeFrame.cpp compiled in libGWADF.so */
#ifndef ADF_AgataCompositeFrame
#include "AgataCompositeFrame.h"
#endif
using namespace ADF;
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** @file AgataCompositeFrame.h header file for AgataCompositeFrame.cpp */
#ifndef ADF_AgataCompositeFrame
#define ADF_AgataCompositeFrame
#ifndef ADF_CompositeFrame
#include "CompositeFrame.h"
#endif
namespace ADF
{
class AgataFrameFactory;
//! General interface
/*!
*/
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) {;}
public:
virtual ~AgataCompositeFrame()
{;}
};
} // namespace ADF
#endif
namespace ADF
{
} // namespace ADF
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* 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 *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file AgataConfigurationFrame.cpp compiled in libGWADF.so */
#ifndef ADF_AgataConfigurationFrame
#include "AgataConfigurationFrame.h"
#endif
using namespace ADF;
UInt_t AgataConfigurationFrame::Write()
{
UInt_t offset = ( String().size() + GetKey()->GetKeyLength() ) % 8u;
if ( offset > 0u ) {
char c = 0;
// UInt_t size = String().size();
// size = String().size() + GetKey()->GetKeyLength();
String().append(8u - offset, c);
}
return ConfigurationFrame::Write();
}