NSCL DDAS
12.1-001
Support for XIA DDAS at FRIB
|
A class to parse the contents of the cfgPixie16.txt file. More...
#include <ConfigurationParser.h>
Public Types | |
typedef std::tuple< int, std::string, std::string > | SlotSpecification |
Data returned when parsing a slot. More... | |
Public Member Functions | |
void | parse (std::istream &input, Configuration &config) |
Parse the contents of the cfgPixie16.txt file. More... | |
SlotSpecification | parseSlotLine (std::istream &input) |
Parses a slot line. More... | |
A class to parse the contents of the cfgPixie16.txt file.
This file is pretty basic. It contains information about the slot map, crate id, and settings file path. It has the following form:
CRATE_ID NUM_MODULES SLOT_MODULE_0 [Per-module-firmware-map [per-module-set-file]] SLOT_MODULE_1 [Per-module-firmware-map [per-module-set-file]] ... SLOT_MODULE_N-1 PATH_TO_SETTINGS_FILE
where CRATE_ID is a non-negative number, NUM_MODULES is a positive number, SLOT_MODULE_# is a number greater than or equal to 2, and PATH_TO_SETTINGS_FILE is a legitimate path. In the top section, the parser will ignore up to 256 characters following the leftmost integer or string found on each line. Because of this, it is customary to add notes on each of these lines. There is no convention for adding notes, though many people like to use a #. An example would be (note the varying conventions for demonstration):
1 # crate id 2 number of modules 2 | slot of first module 3 - slot of second module /path/to/setfile.set ! another comment
Note the structure shown above reflects changes for issue daqdev/DDAS#106. Each slot specification can have an optional one or two fields: The first optional field is a per slot firmware map file and the second an optional per slot .set file (since optional firmwares may require .set files of a different format).
The ConfigurationParser can be used in the following fashion:
Data returned when parsing a slot.
daqdev/DDAS#106. This typedef defines the data that can be returned when parsing a slot line. The int is the slot number. The first string is the optional firmware map (empty string if not given) and the last the optional .set file specification (empty if not given).
void DAQ::DDAS::ConfigurationParser::parse | ( | std::istream & | input, |
Configuration & | config | ||
) |
Parse the contents of the cfgPixie16.txt file.
input | The input stream associated with the cfgPixie16 content (likely an std::ifstream) |
config | A configuration to store the parsed data. |
std::runtime_error | If the DSP parameter file has an invalid file extension. |
std::runtime_error | If the configuration file contains anything other than whitespace after reading the settings file. |
Parses the configuration file line by line, extracting slot information, optional per-module firmware and DSP settings files, and the (default) per-crate DSP settings file. DSP settings files must have the file extension .set for XIA API 2 and either .set or .json for XIA API 3. Exits on any error processing the configuration file.
DAQ::DDAS::ConfigurationParser::SlotSpecification DAQ::DDAS::ConfigurationParser::parseSlotLine | ( | std::istream & | input | ) |
Parses a slot line.
input | Input stream from which the line is parsed. |
std::runtime_error | If there are errors processing this line, e.g. the slot cannot be decoded or a file is not readable. |
Slot lines consist of a mandatory slot number, and optional substitute firmware mapping file and an optional .set file for that module. Care must be taken since any populated field (other than the slot number) might actually be a comment. Requirements: