NSCL DDAS  12.1-001
Support for XIA DDAS at FRIB
Public Member Functions | Static Public Member Functions | List of all members
DAQ::DDAS::Configuration Class Reference

Store the system configuration information needed by Readout. More...

#include <Configuration.h>

Public Member Functions

 Configuration ()=default
 Constructor. More...
 
 Configuration (const Configuration &rhs)
 Copy constructor. More...
 
 ~Configuration ()=default
 Destructor. More...
 
void setCrateId (int id)
 Set the crate id for the module. More...
 
int getCrateId () const
 Return the crate id value. More...
 
void setNumberOfModules (size_t size)
 Set the number of modules in the crate. More...
 
size_t getNumberOfModules () const
 Return the number of modules in the crate. More...
 
void setSlotMap (const std::vector< unsigned short > &map)
 Assign a new slot map. More...
 
std::vector< unsigned short > getSlotMap () const
 Return the vector containing the filled slots. More...
 
void setSettingsFilePath (const std::string &path)
 Set the path to the DSP settings file. More...
 
void setModuleSettingsFilePath (int modnum, const std::string &path)
 Set a per-module DSP settings file. More...
 
std::string getSettingsFilePath () const
 Return the path to the .set file. More...
 
std::string getSettingsFilePath (int modNum)
 Returns the DSP settings file path specific to a single module. More...
 
void setFirmwareConfiguration (int specifier, const FirmwareConfiguration &config)
 Set the firmware configuration for a hardware type. More...
 
FirmwareConfigurationgetFirmwareConfiguration (int hdwrType)
 Retrieve the current firmware specifier for a particular hardware type. More...
 
void setModuleFirmwareMap (int module, const FirmwareMap &mapping)
 Sets a firmware map specific to a module. More...
 
FirmwareConfigurationgetModuleFirmwareConfiguration (int hdwrType, int modnum)
 Get the module firmware configuration information. More...
 
FirmwareMapgetDefaultFirmwareMap ()
 Return the default map of firmware information. More...
 
void setModuleEventLengths (const std::vector< int > &lengths)
 Set the lengths of events for each module. More...
 
std::vector< int > getModuleEventLengths () const
 Return a copy of the module event length vector. More...
 
void setHardwareMap (const std::vector< int > &map)
 Set the hardware map for each module. More...
 
std::vector< int > getHardwareMap () const
 Return a copy of the hardware map vector. More...
 
void print (std::ostream &stream)
 Print brief line of information for cfgPixie16.txt. More...
 

Static Public Member Functions

static std::unique_ptr< Configurationgenerate (const std::string &fwVsnPath, const std::string &cfgPixiePath)
 Generate a Configuration class object from a firmware version file and cfgPixie16.txt. More...
 
static std::unique_ptr< Configurationgenerate (const std::string &fwVsnPath, const std::string &cfgPixiePath, const std::string &modEvtLenPath)
 Generate a Configuration class object from a firmware version file and cfgPixie16.txt. More...
 

Detailed Description

Store the system configuration information needed by Readout.

The Configuration class stores all of the system configuration for a Readout program. It maintains the configuration that is read in from the DDASFirmwareVersion.txt, modevtlen.txt, and cfgPixie16.txt configuration files. The configuration therefore keeps track of the crate id, slot map, setting file path, module event lengths, module count, and all of the available firmware files for each hardware type.

It can be configured either manually or by passing it as an argument to a ConfigurationParser::parse(), FirmwareVersionFileParser::parse(), or ModEvtFileParser::parse() methods as it is in the Readout programs.

At the moment, modules are expected to output events of equal length for all channels. There is no attempt to read out channels with different lengths in a module.

Constructor & Destructor Documentation

◆ Configuration() [1/2]

DAQ::DDAS::Configuration::Configuration ( )
default

Constructor.

◆ Configuration() [2/2]

DAQ::DDAS::Configuration::Configuration ( const Configuration rhs)
inline

Copy constructor.

◆ ~Configuration()

DAQ::DDAS::Configuration::~Configuration ( )
default

Destructor.

Member Function Documentation

◆ generate() [1/2]

std::unique_ptr< DAQ::DDAS::Configuration > DAQ::DDAS::Configuration::generate ( const std::string &  fwVsnPath,
const std::string &  cfgPixiePath 
)
static

Generate a Configuration class object from a firmware version file and cfgPixie16.txt.

Parameters
fwVsnPathPath to the firmware version file.
cfgPixiePathPath to cfgPixie16.txt.
Exceptions
std::runtime_errorAny errors opening or parsing the firmware and configuration files.
Returns
Pointer to the generated Configuration object.

std::move() ensures correct ownership of the returned pointer, though we may be able to take advantage of some copy elision here.

◆ generate() [2/2]

std::unique_ptr< DAQ::DDAS::Configuration > DAQ::DDAS::Configuration::generate ( const std::string &  fwVsnPath,
const std::string &  cfgPixiePath,
const std::string &  modEvtLenPath 
)
static

Generate a Configuration class object from a firmware version file and cfgPixie16.txt.

Parameters
fwVsnPathPath to the firmware version file.
cfgPixiePathPath to cfgPixie16.txt.
modEvtLenPathPath to the modevtlen.txt file.
Exceptions
std::runtime_errorError opening or parsing the modevtlen file.
Returns
Pointer to the generated Configuration object.

std::move() ensures correct ownership of the returned pointer, though we may be able to take advantage of some copy elision here.

◆ getCrateId()

int DAQ::DDAS::Configuration::getCrateId ( ) const
inline

Return the crate id value.

Returns
The crate id.

◆ getDefaultFirmwareMap()

FirmwareMap& DAQ::DDAS::Configuration::getDefaultFirmwareMap ( )
inline

Return the default map of firmware information.

Returns
The firmware map.

◆ getFirmwareConfiguration()

DAQ::DDAS::FirmwareConfiguration & DAQ::DDAS::Configuration::getFirmwareConfiguration ( int  hdwrType)

Retrieve the current firmware specifier for a particular hardware type.

Parameters
hdwrTypeThe hardware specifier associated with the firmware configuration.
Exceptions
std::runtime_errorIf no firmware configuration exists for the provided hdwrType.
Returns
The firmware configuration associated with the hdwrType.

Searches the firmware map using std::find.

◆ getHardwareMap()

std::vector<int> DAQ::DDAS::Configuration::getHardwareMap ( ) const
inline

Return a copy of the hardware map vector.

Returns
A copy of hardware map vector.

◆ getModuleEventLengths()

std::vector<int> DAQ::DDAS::Configuration::getModuleEventLengths ( ) const
inline

Return a copy of the module event length vector.

Returns
std::vector<int> Copy of module event lengths vector.

◆ getModuleFirmwareConfiguration()

DAQ::DDAS::FirmwareConfiguration & DAQ::DDAS::Configuration::getModuleFirmwareConfiguration ( int  hwType,
int  modnum 
)

Get the module firmware configuration information.

Parameters
hwTypeThe hardware type detected in the module.
modnumModule number.
Exceptions
std::runtime_errorIf the module firmware configuraton is not in the firmware map.
Returns
The firmware configuration associated with the module.

It is an error to have a firmware configuration map file but not to have a configuration for the hardware type. If a per-module firmware map does not exist, return the default configuration.

◆ getNumberOfModules()

size_t DAQ::DDAS::Configuration::getNumberOfModules ( ) const
inline

Return the number of modules in the crate.

Returns
The number of modules.

◆ getSettingsFilePath() [1/2]

std::string DAQ::DDAS::Configuration::getSettingsFilePath ( ) const
inline

Return the path to the .set file.

Returns
The settings file path.

◆ getSettingsFilePath() [2/2]

std::string DAQ::DDAS::Configuration::getSettingsFilePath ( int  modnum)

Returns the DSP settings file path specific to a single module.

Parameters
modnumModule number.
Returns
std::string The full path to the settings file.

If there's a per-module set file it's returned otherwise return the default settings file.

◆ getSlotMap()

std::vector<unsigned short> DAQ::DDAS::Configuration::getSlotMap ( ) const
inline

Return the vector containing the filled slots.

Returns
std::vector<unsigned short> The vector containing the slots that are filled.

◆ print()

void DAQ::DDAS::Configuration::print ( std::ostream &  stream)

Print brief line of information for cfgPixie16.txt.

Parameters
streamThe ostream to write to.

Prints out a message similar to: "Crate number 1: 2 modules, in slots:2 3 DSPParFile: /path/to/file.set"

◆ setCrateId()

void DAQ::DDAS::Configuration::setCrateId ( int  id)
inline

Set the crate id for the module.

Parameters
idThe id to assign.

◆ setFirmwareConfiguration()

void DAQ::DDAS::Configuration::setFirmwareConfiguration ( int  specifier,
const FirmwareConfiguration config 
)
inline

Set the firmware configuration for a hardware type.

Parameters
specifierThe hardware type.
configThe new configuration.

Any previous FirmwareConfiguration stored will be replaced by the new configuration. If there is no previous configuration for the hardware type it will be added.

◆ setHardwareMap()

void DAQ::DDAS::Configuration::setHardwareMap ( const std::vector< int > &  map)

Set the hardware map for each module.

Parameters
mapThe hardware map.
Exceptions
std::runtime_errorif size of lengths does not match size of stored slot map.

It is necessary that the caller has previously invoked setNumberOfModules() before calling this. The logic of this method aims to keep the slot map and module event length vectors the same length. Without invoking setNumberOfModules() this is most likely not going to be the case.

◆ setModuleEventLengths()

void DAQ::DDAS::Configuration::setModuleEventLengths ( const std::vector< int > &  lengths)

Set the lengths of events for each module.

Parameters
lengthsThe module event lengths.
Exceptions
std::runtime_errorif size of lengths does not match size of stored slot map.

It is necessary that the caller has previously invoked setNumberOfModules() before calling this. The logic of this method aims to keep the slot map and module event length vectors the same length. Without invoking setNumberOfModules() this is most likely not going to be the case.

◆ setModuleFirmwareMap()

void DAQ::DDAS::Configuration::setModuleFirmwareMap ( int  module,
const FirmwareMap mapping 
)

Sets a firmware map specific to a module.

Parameters
moduleModule index.
mappingFirmware mapping for that module.

An existing map is ovewritten.

◆ setModuleSettingsFilePath()

void DAQ::DDAS::Configuration::setModuleSettingsFilePath ( int  modNum,
const std::string &  path 
)

Set a per-module DSP settings file.

Parameters
modNumModule number.
pathThe path to the settings file.

The filename path should be checked for readability by the caller.

◆ setNumberOfModules()

void DAQ::DDAS::Configuration::setNumberOfModules ( size_t  size)

Set the number of modules in the crate.

Parameters
sizeNumber of modules.

This resizes the vectors storing the slot map, module event lengths, and hardware map to be consistent. The caller should call setNumberOfModules prior to calling setSlotMap() or setModuleEventLengths().

◆ setSettingsFilePath()

void DAQ::DDAS::Configuration::setSettingsFilePath ( const std::string &  path)
inline

Set the path to the DSP settings file.

Parameters
pathThe path to the settings file.

◆ setSlotMap()

void DAQ::DDAS::Configuration::setSlotMap ( const std::vector< unsigned short > &  map)

Assign a new slot map.

Parameters
mapThe slots that are occupied.
Exceptions
std::runtime_errorWhen length of argument is different than the length of stored modevtlen vector.

It is important for the caller to first call setNumberOfModules() before calling this to avoid an exception being thrown. To avoid weird configurations, this ensures that the length of the slot map is the same as the module event length vector at all times. If the user has not set the number of modules previously, this cannot be gauranteed and the method will almost always throw.

config.setNumberOfModules(2);
config.setSlotMap({2, 3});
Configuration()=default
Constructor.

The documentation for this class was generated from the following files: