Tools¶
Description¶
The CPU software makes use of the tools documented here throughout the software.
ConfigManager¶
-
class ConfigManager¶
class for configuring the instrument based on the configuration file provided
Public Functions
-
ConfigManager()¶
constructor initialise the file paths and configuration output
-
ConfigManager(const std::string&, const std::string&, const std::string&)¶
constructor
- Parameters:
cfl – path to the local configuration file
cf – path to the configuration file to be copied over
-
void Configure()¶
reload and parse the configuration file
-
bool IsParsed()¶
check a configuration file has indeed been parsed, by checking output != -1
- Parameters:
ConfigOut – the output to be checked
-
ConfigManager()¶
InputParser¶
-
class InputParser¶
class to parse command line input to program
Public Functions
-
InputParser(int &argc, char **argv)¶
constructor.
- Parameters:
argc – command line inputs
argv – command line inputs initalise the CmdLine struct
-
CmdLineInputs *ParseCmdLineInputs()¶
parse the command line options and store the result in CmdLine
-
int PrintVersionInfo()¶
print the version of the instrument (for use with mecontrol -ver)
-
inline const std::string getCmdOption(const std::string &option) const¶
get the command line options
- Parameters:
option – flag to get option for
-
inline bool cmdOptionExists(const std::string &option) const¶
check if the command line option exists
- Parameters:
option – check if this flag exists
Public Members
-
CmdLineInputs *CmdLine = new CmdLineInputs()¶
stores the command line inputs
-
InputParser(int &argc, char **argv)¶
SynchonisedFile¶
-
class SynchronisedFile¶
handles asynchronous writing to file from multiple threads
Public Types
Public Functions
-
SynchronisedFile(std::string path)¶
constructor.
- Parameters:
path – path to the SynchronisedFile to be created
-
~SynchronisedFile()¶
destructor closes the SynchronisedFile
-
uint32_t Checksum()¶
calculate the CRC checksum and append to file
-
void Close()¶
close the SynchronisedFile
-
bool IsOpen()¶
Check if the SynchronisedFile is open.
template to allow different objects to be passed for writing write a payload to the SynchronisedFile
- Parameters:
payload – payload to be written to file
write_type – the way in which to write to file
ConfigOut – configuration output used to get number of packets for Zynq D1/D2 (optional)
Public Members
-
std::string path¶
stores the path to the file
Private Members
-
std::mutex _accessMutex¶
protection for file access
-
FILE *_ptr_to_file = nullptr¶
pointer to the SynchronisedFile
-
SynchronisedFile(std::string path)¶
-
class Access¶
handles access to the SynchronisedFile
Public Functions
constructor.
- Parameters:
sf – pointer to the Synchronisedfile to be accessed
-
uint32_t GetChecksum()¶
get the checksum of the SynchronisedFile accessed
-
void CloseSynchFile()¶
close the SynchronisedFile accessed
template to allow different objects to be passed for writing write a payload to the SynchronisedFile
- Parameters:
payload – payload to be written to file
write_type – the way in which to write to file
ConfigOut – configuration output used to get number of packets for Zynq D1/D2 (optional)
Public Members
-
std::string path¶
path to the SynchronisedFile
Private Members
-
std::shared_ptr<SynchronisedFile> _sf¶
pointer to the SynchronisedFile
log¶
-
class logstream : public std::ostringstream¶
simple logging class with different output levels and timestamp
Public Types
Public Functions
-
inline void flush()¶
print timestamp on flush
-
inline void flush()¶
CpuTools¶
-
class CpuTools¶
class to provide useful functions to other parts of the software
Public Functions
-
CpuTools()¶
default constructor
Public Static Functions
-
static std::string CommandToStr(const char *cmd)¶
function to run command and pass stdout to a string
- Parameters:
cmd – the command to send using popen NB: maximum size of returned string is limited to MAX_STR_LENGTH defined in CpuTools.h
-
static std::string IntToFixedLenStr(const int input, const int length)¶
function to convert int to a fixed length string
-
static void ClearFolder(const char *data_dir)¶
function to clear a directory
-
static std::string SpaceToUnderscore(std::string)¶
replaces spaces in a std::string with underscores
-
static bool PingConnect(const std::string &ip_address)¶
check if you can ping an IP address
- Parameters:
ip_adress – the IP address as a string
-
static bool CheckFtp()¶
check if FTP server is up
-
static std::vector<int> DelimStrToVec(std::string input_string, char delim, uint8_t size, bool check_01)¶
convert comma delimited string of ints to vector of ints
- Parameters:
input_string – string to convert
size – the number of ints expected
check_01 – set to 0 if input int is not 0 or 1
-
static std::string BuildStr(std::string stem, const std::string &sep, int val, int rep)¶
build strings with repetetive ints following a stem useful for ZynqManager telnet interface
- Parameters:
stem – the start of the string
sep – the delimiter
val – the int value to be repeated
number – of times to repeat val
-
static std::string BuildStrFromVec(std::string stem, std::string sep, std::vector<int> values)¶
like BuildStr() but for a vector argument useful for ZynqManager telnet interface
- Parameters:
stem – the start of the string
sep – the delimiter
values – vector of int values
-
static std::streampos FileSize(std::string file_path)¶
get the file size of an ifstream
- Parameters:
file_path – path to the file
-
static uint32_t BuildCpuHeader(uint32_t type, uint32_t ver)¶
build the cpu file header
- Parameters:
type – header tag of the file type
ver – header tag of the file type version
-
static uint32_t BuildCpuTimeStamp()¶
build the cpu timestamp simple UNIX timestamp
-
static std::vector<int> ReadMatrixDac10(std::string dac10_filename)¶
read the DAC10 matrix file into a vector
-
CpuTools()¶