Operations¶
Description¶
The OperationMode
base class is defined in order to ease the addition and handling of instrument modes as the automated mode switching interface is implemented and the necessary mutex and condition variables and protected as private members. The DataAquisition
and DataReduction
classes both inherit from this class.
The DataAcquisition
class describes the night-time operational mode of the instrument which is driven by data acquisition. The key function is DataAcquisition::CollectData()
, which spawns all the necessary data acquisition processes including DataAcquisition::ProcessIncomingData()
which watches the FTP directory for new files from the Zynq board and processes them. The main data acquisition is Synchronous. The PDM raw data is sent in a ZYNQ_PACKET
(see the minieuso_data_format.h
for definition) every 5.24 s (corresponding to 128*128*128 GTU). When a new ZYNQ_PACKET
is detected, the program also reads out the photodiodes and SiPM using AnalogManager and collects all this information into a CPU_PACKET
which is written to the current CPU file. There is also so asynchronous acquisition from the thermistors via the ThermManager
class, which pass a THERM_PACKET
to the active CPU file once a minute. The cameras also operate asynchronously and their pictures are stored separately. There are also other operational modes, and the details of the acquisition are specified by command line inputs to the program.
The DataReduction
class is designed to perform useful data reduction tasks during the day when data cannot be collected. Tasks involve data compression and production of small quick-look data samples that can be quickly sent down to Earth by the working astronauts to allow for a check of the instrument operating correctly. These tasks are yet to be implemented and currently the program just sleeps in day mode, however the framework is set up for the easy addition of this functionality.
OperationMode¶
-
class OperationMode¶
base class for an operational mode
Subclassed by DataAcquisition, DataReduction
Public Functions
-
OperationMode()¶
constructor
-
virtual void Start()¶
start the operational mode, virtual function for overloading
-
void Notify()¶
notify the object of a mode switch
-
void Reset()¶
reset the objects mode switch
Public Members
-
AnalogManager *Analog = new AnalogManager()¶
control of the analog subsystem
-
ThermManager *Thermistors = new ThermManager()¶
control of the thermal subsystem
Protected Attributes
-
std::mutex _m_switch¶
to handle mode switching in a thread-safe way
-
std::condition_variable _cv_switch¶
to wait for a mode switch
-
bool _switch¶
to notify of a mode switch
-
std::mutex _m_ftp¶
to handle swicthing in a thread safe way
-
std::condition_variable _cv_ftp¶
to wait for an ftp switch
-
bool _ftp¶
to notify of a mode switch
-
OperationMode()¶
DataAcquisition¶
-
class DataAcquisition : public OperationMode¶
NIGHT operational mode: data acquisition class for controlling the main acquisition (the Zynq board, the thermistors and the Analog board)
Public Types
Public Functions
-
DataAcquisition()¶
constructor
make a cpu data file for a new run
- Parameters:
run_type – defines the file run type
ConfigOut – the output of configuration parsing with ConfigManager sets up the synchonised file access and notifies the ThermManager object
-
int CloseCpuRun(RunType run_type)¶
close the CPU file run and append CRC. this closes the run and runs a CRC calculation which is the stored in the file trailer and appended
spawn thread to collect an S-curve
- Parameters:
Zynq – object to control the Zynq subsystem passed from RunInstrument
ConfigOut – output of the configuration file parsing with ConfigManager
CmdLine – output of command line options parsing with InputParser
spawn threads to collect data
- Parameters:
Zynq – object to control the Zynq subsystem passed from RunInstrument
ConfigOut – output of the configuration file parsing with ConfigManager
CmdLine – output of command line options parsing with InputParser launches the required acquisition of different subsystems in parallel
-
bool IsScurveDone()¶
check the scurve status in a thread-safe way
Public Members
-
std::shared_ptr<SynchronisedFile> CpuFile¶
synchronised file pointer
-
std::shared_ptr<Config> ConfigOut¶
output of the configuration parsing is stored here
Public Static Functions
-
static int WriteFakeZynqPkt()¶
function to generate and write a fake Zynq packet used for testing data format updates. now the Zynq test acquisition modes can be used instead
-
static int ReadFakeZynqPkt()¶
function to read a fake Zynq packet used for testing data format updates. now the Zynq test acquisition modes can be used instead
Private Functions
create cpu run file name checks if usb connected to define the data storage path
- Parameters:
run_type – defines the file run type
ConfigOut – the output of configuration parsing with ConfigManager
build the cpu file info based on runtime settings
- Parameters:
ConfigOut – the configuration file parameters and settings from RunInstrument
CmdLine – the command line parameters
read out an scurve file into an SC_PACKET.
read out a hv file into an HV_PACKET
read out a zynq data file into a ZYNQ_PACKET
-
int WriteScPkt(SC_PACKET *sc_packet)¶
write the SC_PACKET to the CPU file
- Parameters:
sc_packet – the Scurve data from the Zynq board asynchronous writes to the CPU file are handled with the SynchronisedFile class
write the HV_PACKET to the CPU file
- Parameters:
hv_packet – HV data from the Zynq board asynchronous writes to the CPU file are handled with the SynchronisedFile class
write the CPU_PACKET to the current CPU file
- Parameters:
zynq_packet – the Zynq data acquired from the PDM
hk_packet – the HK data acquired from the analog board
ConfigOut – the configuration struct output of ConfigManager asynchronous writes to the CPU file are handled with the SynchronisedFile class
read out the hv file into a HV_PACKET and store
- Parameters:
ConfigOut – output of the configuration file parsing with ConfigManager called after the Zynq acquisition is stopped in DataAcquisition::CollectData()
-
void FtpPoll(bool monitor)¶
Poll the lftp server on the Zynq to check for new files. Also clears old files from lftp server before starting.
- Parameters:
monitor – If true, wait until the instrument mode switch is sent to stop polling the FTP server.
Look for new files in the data directory and process them depending on file type
- Parameters:
ConfigOut – output of the configuration file parsing with ConfigManager
CmdLine – output of command line options parsing with InputParser
main_thread – p_thread ID of the main thread which calls the function, used to send signals
scurve – if true, blocks frm readout and only watches for Scurve and HV files uses inotify to watch the FTP directory and stops when signalled by DataAcquisition::Notify()
-
void SignalScurveDone()¶
signal that the scurve is done to data gathering thread
-
DataAcquisition()¶
DataReduction¶
-
class DataReduction : public OperationMode¶
DAY operational mode: data reduction class to handle data reduction and preparation of diagnostic samples to be sent to Earth and check the instrument is operating correctly @TODO add main functionality
Public Functions
-
DataReduction()¶
constructor
-
virtual void Start()¶
launch thread to do data reduction
Private Functions
-
int RunDataReduction()¶
data reduction procedure compresses data into .zip files
-
DataReduction()¶