NSCL DDAS 12.2-009
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 ()=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 setChannelMap (const std::vector< unsigned short > &map)
 Assign a new channel map (number of channels per module). More...
 
std::vector< unsigned short > getChannelMap ()
 Return the channel map. More...
 
unsigned short getModuleChannelCount (size_t mod)
 Get the number of channels in a module. More...
 
void setSettingsFilePath (const std::string &path)
 Set the path to the DSP settings file. More...
 
std::string getSettingsFilePath () const
 Return the path to the .set file. More...
 
void setModuleSettingsFilePath (int modnum, const std::string &path)
 Set a per-module DSP settings file. More...
 
std::string getModuleSettingsFilePath (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...
 
std::map< int, FirmwareMapgetModuleFirmwareMaps () const
 Get the per-module FW maps. More...
 
std::map< int, std::string > getModuleSetFileMap () const
 Get the per-module settings file map. 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 &cfgPixiePath)
 Generate a Configuration class object from cfgPixie16.txt. More...
 
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, cfgPixie16.txt and modevtlen.txt file. More...
 
static std::unique_ptr< ConfigurationgenerateManagedFW (const std::string &cfgPixiePath, const std::string &modEvtLenPath)
 Generate a Configuration class object from cfgPixie16.txt and modevtlen.txt files (managed FW). 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 modevtlen.txt, and cfgPixie16.txt configuration files. The configuration keeps track of the crate ID, slot map, settings file path, module event lengths, module count, the hardware types present the crate, and, if specified, the firmware and DSP settings loaded onto those modules.

A number of methods are provided to generate a Configuration object based on which of the aforementioned configuration files are present. The new function generateManagedFW() can be used to generate a valid Configuration compatible with XIA's automatic firmware management (i.e. no pre-defined default FW).

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.

Note
XIA's managed firmware will automatically grab the latest firmware file for a particular module type from the installation directory. This means the concept of a general firmware map doesn't really exist: no firmware version file is parsed and no firmware is pre-defined, unless the user specifies a firmware file. Use the FirmwareMap objects at your own peril! The Configuration class has no way to know what the system firmware is on its own.

Constructor & Destructor Documentation

◆ Configuration()

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

Constructor.

◆ ~Configuration()

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

Destructor.

Member Function Documentation

◆ generate() [1/3]

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

Generate a Configuration class object from cfgPixie16.txt.

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

◆ generate() [2/3]

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() [3/3]

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, cfgPixie16.txt and modevtlen.txt file.

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.

◆ generateManagedFW()

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

Generate a Configuration class object from cfgPixie16.txt and modevtlen.txt files (managed FW).

Parameters
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.

◆ getChannelMap()

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

Return the channel map.

Returns
Vector containing the number of channels per module.

◆ 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.

◆ getModuleChannelCount()

unsigned short DAQ::DDAS::Configuration::getModuleChannelCount ( size_t  mod)

Get the number of channels in a module.

Parameters
modThe module number (index, not slot).
Returns
Number of channels in module.
Exceptions
std::out_of_rangeif the module is out of range.

◆ getModuleEventLengths()

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

Return a copy of the module event length vector.

Returns
Vector of module event lengths.

◆ 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.

◆ getModuleFirmwareMaps()

std::map< int, FirmwareMap > DAQ::DDAS::Configuration::getModuleFirmwareMaps ( ) const
inline

Get the per-module FW maps.

Returns
Per-module FW maps.

◆ getModuleSetFileMap()

std::map< int, std::string > DAQ::DDAS::Configuration::getModuleSetFileMap ( ) const
inline

Get the per-module settings file map.

Returns
Per-module settings file map.

◆ getModuleSettingsFilePath()

std::string DAQ::DDAS::Configuration::getModuleSettingsFilePath ( 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.

◆ getNumberOfModules()

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

Return the number of modules in the crate.

Returns
The number of modules.

◆ getSettingsFilePath()

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

Return the path to the .set file.

Returns
The settings file path.

◆ 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"

◆ setChannelMap()

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

Assign a new channel map (number of channels per module).

Parameters
mapMap of channels in each module.

It is important for the caller to first call setNumberOfModules() before calling this to avoid an exception being thrown as this method ensures that the length of the channel map is the same as the expected number of modules in the system. If the user has not set the number of modules prior to calling this function, this cannot be guaranteed and the method will almost always throw.

config.setChannelMap({16, 16});
Store the system configuration information needed by Readout.
Definition: Configuration.h:88
void setChannelMap(const std::vector< unsigned short > &map)
Assign a new channel map (number of channels per module).
Definition: Configuration.cpp:80
void setNumberOfModules(size_t size)
Set the number of modules in the crate.
Definition: Configuration.cpp:30

◆ 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 number of modules in the system the same length. Without invoking setNumberOfModules() this is most likely not going to be the case.

config.setModuleHardwareMap({RevD_100MHz_12Bit, RevF_250MHz_14Bit});
@ RevF_250MHz_14Bit
Definition: HardwareRegistry.h:82
@ RevD_100MHz_12Bit
Definition: HardwareRegistry.h:78

◆ 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 vector does not match the number of modules in the system.

It is important for the caller to first call setNumberOfModules() before calling this to avoid an exception being thrown as this method ensures that the length of the module event length map is the same as the expected number of modules in the system. If the user has not set the number of modules prior to calling this function, this cannot be guaranteed and the method will almost always throw.

config.setModuleEventLengthsMap({4, 4});

◆ 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.
Todo:
(ASC 3/21/25): Clean up this class and remove everything which we do not need (e.g. default maps) and remove any hardware types which are not real or we do not support (e.g. 500m-16b rev F??)

This resizes the vectors storing the slot map, module event lengths, and hardware map to be consistent. The caller must call setNumberOfModules() prior to setting the slot map, channel map, event lengths, or hardware map. Failure to do so will at best result in an exception and/or the caller application fatally terminating.

◆ 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 as this method ensures that the length of the slot map is the same as the expected number of modules in the system. If the user has not set the number of modules prior to calling this function, this cannot be guaranteed and the method will almost always throw.

config.setSlotMap({2, 3});
void setSlotMap(const std::vector< unsigned short > &map)
Assign a new slot map.
Definition: Configuration.cpp:53

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