NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
Public Member Functions | List of all members
DAQ::DDAS::ConfigurationParser Class Reference

The ConfigurationParser class. More...

#include <ConfigurationParser.h>

Public Member Functions

void parse (std::istream &input, Configuration &config)
 Parse the contents of the cfgPixie16.txt file. More...
 
bool parseHardwareTypeTag (const std::string &line, int &revision, int &freq, int &resolution)
 parseHardwareTypeTag More...
 
FirmwareConfiguration extractFirmwareConfiguration (std::istream &input)
 ConfigurationParser::extractFirmwareConfiguration. More...
 
double extractClockCalibration (std::istream &input)
 ConfigurationParser::extractClockCalibration. More...
 
void updateClockCalibration (int type, double calibration)
 

Detailed Description

The ConfigurationParser class.

The ConfigurationParser class is designed to parse the contents of the cfgPixie16.txt file. This file is pretty basic. There are two main sections to it. The top section is mandatory and contains information about the slot map, crate id, and settings file path. The bottom half specifies possible overloads to the firmware configuration of the RevBCD, RevF_250MHz_14Bit, and RevF_500MHz_12Bit hardware types. It has the following form:

* CRATE_ID
* NUM_MODULES
* SLOT_MODULE_0
* SLOT_MODULE_1
* ...
* SLOT_MODULE_N-1
* PATH_TO_SETTINGS_FILE
*
* [RevX-YBit-ZMSPS]
* ComFPGACONFIG_FILE
* SPFPGACONFIG_FILE
* DSPCODE_FILE
* DSPVAR_FILE
* Clock_Calibration
*
* [100MSPS]
* ComFPGACONFIG_FILE
* SPFPGACONFIG_FILE
* DSPCODE_FILE
* DSPVAR_FILE
* Clock_Calibration
* [250MSPS]
* ComFPGACONFIG_FILE
* SPFPGACONFIG_FILE
* DSPCODE_FILE
* DSPVAR_FILE
* Clock_Calibration
* [500MSPS]
* ComFPGACONFIG_FILE
* SPFPGACONFIG_FILE
* DSPCODE_FILE
* DSPVAR_FILE
* Clock_Calibration
* 

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 an 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 man 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
* 

For the second half, the user can specify firmware information for specific hardware types using a tag. The general format is [RevX-YBit-ZMSPS], where X is a revision number, Y is the adc resolution, and Z is the adc frequency. Besides that general format, there are three more tags ([100MSPS], [250MSPS], or [500MSPS]) that can be used. These latter tags are being phased out and should no longer be used. Every tag that is provided must be followed by five lines, each containing the ComFPGAConfig, SPFPGAConfig, DSPCode, and DSPVar files and the clock calibration in order. The clock calibration should be a floating point value that is used to convert a raw timestamp in ticks to a time in nanoseconds.

The ConfigurationParser can be used in the following fashion:

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

Member Function Documentation

double DAQ::DDAS::ConfigurationParser::extractClockCalibration ( std::istream &  input)

ConfigurationParser::extractClockCalibration.

Parameters
inputthe stream to read from
Returns
the clock calibration integer that was read from the file
Exceptions
std::runtime_errorif an error occurs while processing the next line
FirmwareConfiguration DAQ::DDAS::ConfigurationParser::extractFirmwareConfiguration ( std::istream &  input)

ConfigurationParser::extractFirmwareConfiguration.

Parameters
inputthe stream to read from

The current implementation does not support reading firmware paths with whitespace in them

Returns
a firmware configuration encapsulating the data read from the file.
Exceptions
std::runtimer_errorif an error occurs while processing next 4 lines
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 failed to read in sufficient slot map data for number of modules
std::runtime_errorif settings file does not end in .set
bool DAQ::DDAS::ConfigurationParser::parseHardwareTypeTag ( const std::string &  line,
int &  revision,
int &  freq,
int &  resolution 
)

parseHardwareTypeTag

Parameters
linethe tag to parse
revisioninteger variable to store X into
freqinteger variable to store Y into
resolutioninteger variable to store Z into

Parses the values of X, Y, and Z from a tag of the form [RevX-YBit-ZMSPS].

Return values
falseif line is not in the format [RevX-YBit-ZMSPS]
trueotherwise

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