Instrument¶
The instrument
folder contains code to handle the high-level operation of the instrument and the switching between different operational modes.
Description¶
The RunInstrument class handles the overall program flow. When the RunInstrument::Start()
function is called, the program checks for the request from the command line inputs to perform simple execute-and-exit commands such as switching on/off a subsystem with RunInstrument::LvpsSwitch()
or returning the instrument status with RunInstrument::CheckStatus()
. All member functions are documented in detail below. If no such command is required, the program continues to RunInstrument::StartUp()
which parses the configuration file and performs standard start up procedures and the to RunInstrument::CheckSystems()
which, as may guess, checks the status of the subsystems. RunInstrument then launches two background processes: instrument monitoring (checks for light level and stop signals) with RunInstrument::MonitorInstrument()
and data backup using UsbManager::RunDataBackup()
.
Once these background processes are launched, the program enters a loop which handles the switching between instrument modes. The initial mode is specified in RunInstrument::CheckSystems()
and is entered by calling RunInstrument::DayOperations()
or RunInstrument::NightOperations()
. These functions then call the relevant OperationMode::Start()
member function, which launches all the necessary processes in separate threads. These processes are documented in more detail in their respective class documentation (see DataAquisition and DataReduction). Upon receiving a signal from the RunInstrument::MonitorInstrument()
function, OperationMode::Notify()
is called and the threads are safely stopped and joined before the OperationMode::Start()
function can return. Upon return, the loop continues and the current instrument mode is checked in a switch() statement before the relevant OperationMode::Start()
function is called and the process begins again.
The RunInstrument class makes use of signal handling to react to the CTRL-C
(SIGINT) signal. Upon receiving such a signal, all open threads are joined safely or killed in the case of detached threads. Any open data acquisition is stopped and the high voltage to the PMTs is also switched off before the program exits (it can take a few seconds).
RunInstrument¶
-
class RunInstrument¶
class to handle different instrument operational modes
Public Types
Public Functions
-
RunInstrument(CmdLineInputs *CmdLine)¶
the constructor
- Parameters:
CmdLine – is a struct storing command line inputs parsed with the InputParser class
-
void Start()¶
start running the instrument according to specifications checks for execute and exit functions, then moves on to automated loop over mode switching
-
void Stop()¶
shut down procedure called when stop signal sent
-
int SetInstMode(InstrumentMode mode_to_set)¶
set the instrument mod in a thread-safe way
-
InstrumentMode GetInstMode()¶
read the instrument mode in a thread-safe way
Private Functions
-
int StartUp()¶
start-up procedure
run the start-up procedure sets up logging, parses the config file and checks for command line override to configured values
-
int LvpsSwitch()¶
execute-and-exit commands
function to switch a desired subsystem on/off as specified by the object’s CmdLine struct
-
int HvpsSwitch()¶
function to switch on the HVPS if required by the object’s CmdLine struct
-
int DebugMode()¶
function to run quick debug tests of the subsystems
-
int CheckStatus()¶
function to check the current instrument and HV status uses the ZynqManager class member functions
-
int InitInstMode()¶
initialisation
initialise the instrument mode using the current light level status light level is acquired using the AnalogManager to run an acquisition from the photodiodes
-
int CheckSystems()¶
checks the subsystems are operating as required
-
int SelectAcqOption()¶
determines the AcquisitionMode from the program inputs
-
int LaunchCam()¶
launches the camera acquisition in a robust way makes use of the CamManager member functions to check if the launch fails and reacts by trying to relaunch up to 3 times
-
int Acquisition()¶
interface to the data acquisition uses the DataAcquisition class member functions
-
int MonitorInstrument()¶
launches a background thread to monitor the instrument runs RunInstrument::PollInstrument member function
-
int PollInstrument()¶
instrument monitoring by checking the light level and shutdown signal
-
int StatusChecker()¶
launches a background thread to check and print the instrument status
-
int RunningStatusCheck()¶
print the status to the screen every STATUS_PERIOD seconds
-
int SetStop()¶
sends a stop signal to all processes in a thread-safe way
-
bool CheckStop()¶
checks if a stop signal has been sent
-
int NightOperations()¶
define main operational procedures
night time operational procedure does not return until all night processes have joined
-
int DayOperations()¶
day time operational procedure does not returnuntil all day processes have joined
Private Members
-
std::ofstream isDay¶
to write is_day.txt Giammanco 05/2019
-
std::mutex _m_stop¶
to handle stopping
Private Static Functions
-
static void SignalHandler(int signum)¶
used in operations
function to handle interrupt signals to the program
-
RunInstrument(CmdLineInputs *CmdLine)¶