NSCL DDAS 12.2-009
Support for XIA DDAS at FRIB
Public Member Functions | List of all members
CPixieSystemUtilities Class Reference

System manager class for DDAS. More...

#include <CPixieSystemUtilities.h>

Public Member Functions

 CPixieSystemUtilities ()
 Constructor. More...
 
int Boot ()
 Boot the entire system. More...
 
int SaveSetFile (char *fileName)
 Save the currently loaded DSP settings to a settings file. More...
 
int LoadSetFile (char *fileName)
 Load a new settings file. More...
 
int ExitSystem ()
 Exit the system and release resources from the modules. More...
 
void SetBootMode (int mode)
 Set the boot mode. More...
 
void SetLastErrorMessage (const char *msg)
 Set the last error message. Used by the extern "C" shims when their catch-all fires. More...
 
int GetBootMode ()
 Get the boot mode. More...
 
bool GetBootStatus ()
 Get the crate boot status. More...
 
int GetNumModules ()
 Get the number of installed modules. More...
 
int GetModuleMSPS (int module)
 Get the module ADC sampling rate in MSPS. More...
 
int GetModuleChannelCount (int module)
 Get the number of channels on the module. More...
 
const char * GetLastErrorMessage ()
 Get the reason text from the most recent failed operation. More...
 

Detailed Description

System manager class for DDAS.

This class manages the Pixie DAQ system. It controls loading and saving settings files, booting and exiting, and stores information about the state of the system which can be accessed across the ctypes interface.

Constructor & Destructor Documentation

◆ CPixieSystemUtilities()

CPixieSystemUtilities::CPixieSystemUtilities ( )

Constructor.

Default: boot in online mode and read the settings file specified in cfgPixie16.txt. The last error message is initialized to an empty string.

Member Function Documentation

◆ Boot()

int CPixieSystemUtilities::Boot ( )

Boot the entire system.

Returns
int
Return values
0On successful boot.
CPIXIEERROR_INVALID_CONFIGFailed to generate the system configuration.
!=0XIA API error code on failure.

Reads in configuration information from cfgPixie16.txt, loads settings file information, boots modules and saves configuration info.

Note
(ASC 9/11/24): Check the same envvar as e.g. the readout code to determine whether to perform a full boot or settings-only boot. In principle this could be configurable on the QtScope GUI but for now the boot mode is set the same way as it is for the readout code. An important thing to keep in mind is that getenv("DDAS_BOOT_WHEN_REQUESTED") is false iff DDAS_BOOT_WHEN_REQUESTED is not set (getenv() returns pointer to the value string which evaluates to true regardless of the value itself). When running a containerized NSCLDAQ one needs to make sure the envvar is set inside the container.

◆ ExitSystem()

int CPixieSystemUtilities::ExitSystem ( )

Exit the system and release resources from the modules.

Returns
int
Return values
0Success.
!=0XIA API error code on failure.

If the call to Pixie16ExitSystem() fails for any module, return the error code and set the booted state flag to false. The system is likely in a bad state.

◆ GetBootMode()

int CPixieSystemUtilities::GetBootMode ( )
inline

Get the boot mode.

Warning
Offline boot mode is currently only allowed for XIA API 2!
Returns
The boot mode.
Return values
0Online mode.
1Offline mode (no hardware).

◆ GetBootStatus()

bool CPixieSystemUtilities::GetBootStatus ( )
inline

Get the crate boot status.

Returns
bool
Return values
trueIf the system has been booted.
falseOtherwise.

◆ GetLastErrorMessage()

const char * CPixieSystemUtilities::GetLastErrorMessage ( )
inline

Get the reason text from the most recent failed operation.

Returns
Pointer to the stored message; empty string if none.

◆ GetModuleChannelCount()

int CPixieSystemUtilities::GetModuleChannelCount ( int  module)

Get the number of channels on the module.

Parameters
moduleModule number (zero-indexed).
Returns
The number of channels on the module.
Return values
CPIXIEERROR_NOT_BOOTEDif the system is not booted.
CPIXIEERROR_INVALID_MODULEif the module number is invalid.

Performs bounds checking on the module number. The various DAQ::DDAS::Configuration accessor methods throw but ctypes does not handle C++ exceptions so we catch them here and print the error message to stderr. The return value is an error code that can be checked by the caller.

◆ GetModuleMSPS()

int CPixieSystemUtilities::GetModuleMSPS ( int  module)

Get the module ADC sampling rate in MSPS.

Parameters
moduleModule number (zero-indexed).
Returns
The module ADC sampling rate in MSPS.
Return values
CPIXIEERROR_NOT_BOOTEDif the system is not booted.
CPIXIEERROR_INVALID_MODULEif the module number is invalid.

Performs bounds checking on the module number. The various DAQ::DDAS::Configuration accessor methods throw but ctypes does not handle C++ exceptions so we catch them here and print the error message to stderr. The return value is an error code that can be checked by the caller.

◆ GetNumModules()

int CPixieSystemUtilities::GetNumModules ( )
inline

Get the number of installed modules.

Returns
The number of modules in the crate.

◆ LoadSetFile()

int CPixieSystemUtilities::LoadSetFile ( char *  fileName)

Load a new settings file.

Parameters
fileNameSettings file name we are attempting to open.
Returns
int
Return values
0Success.
!=0XIA API error code on failure.

Check and see if the system is booted. If so, load the parameters from the settings file. If not flag that a new settings file path (potentially different from that in the cfgPixie16.txt) has been set. The flag is checked at boot to load the new settings file.

◆ SaveSetFile()

int CPixieSystemUtilities::SaveSetFile ( char *  fileName)

Save the currently loaded DSP settings to a settings file.

Parameters
fileNameName of file to save.
Returns
int
Return values
0Success.
!=0XIA API error code on failure.

File format depends on what is supported by the version of the XIA API being used. Version 3+ will save the settings file as a JSON file while in version 2 it is binary.

◆ SetBootMode()

void CPixieSystemUtilities::SetBootMode ( int  mode)
inline

Set the boot mode.

Parameters
modeSet the boot mode to this value.

◆ SetLastErrorMessage()

void CPixieSystemUtilities::SetLastErrorMessage ( const char *  msg)
inline

Set the last error message. Used by the extern "C" shims when their catch-all fires.

Parameters
msgMessage to store.

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