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

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

Detailed Description

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:

using namespace DAQ::DDAS;
Configuration config;
ConfigurationParser parser;
std::ifstream configFile("cfgPixie16.txt", std::ios::in);
parser.parse(configFile, config);

Member Typedef Documentation

◆ SlotSpecification

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

Member Function Documentation

◆ parse()

void DAQ::DDAS::ConfigurationParser::parse ( std::istream &  input,
Configuration config 
)

Parse the contents of the cfgPixie16.txt file.

Parameters
inputThe input stream associated with the cfgPixie16 content (likely an std::ifstream)
configA configuration to store the parsed data.
Exceptions
std::runtime_errorIf the DSP parameter file has an invalid file extension.
std::runtime_errorIf 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.

Todo:
(ASC 3/13/24): Whitespace-tolerant comments could be allowed using this trim-and-inspect framework i.e. check that first character of trimmed line is a comment character. For now, anything besides whitespace will throw when parsing the configuration file.

◆ parseSlotLine()

DAQ::DDAS::ConfigurationParser::SlotSpecification DAQ::DDAS::ConfigurationParser::parseSlotLine ( std::istream &  input)

Parses a slot line.

Parameters
inputInput stream from which the line is parsed.
Exceptions
std::runtime_errorIf there are errors processing this line, e.g. the slot cannot be decoded or a file is not readable.
Returns
Tuple containing the slot number and and file paths. The filepaths will be empty strings if omitted.

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:

  • Filenames cannot have spaces in their paths.
  • Files must be readable by the user.
  • #'s must be spaced from the last file e.g.: 1 firmwaremap.txt# This is an error but, 2 firmwaremap.txt # This is ok, 3 firmwaremap.txt setfile.set # As is this.

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