Inheritance diagram for QApolloDbBase:
A single instance of this class will exist for each process involved in the CUORE DAQ.
This class has only private methods and access to them is provided by mean of friendship. This class should be never used directly. Specific purpose classes should be used instead.
This class is not meant to be used by the Event Builder because Event Builder is actually an instance of diana: it will use the diana data base interface.
The mechanisms for interfacing with the data base are implemented in the QDb base class. This class is intended to implement the policy and is optimized for the needs of the DAQ processes. Different DAQ processes need read (or write) access to different sets of information in the data base: while a process like the DaqServer (that control the whole DAQ system) will need system wide informations in almost all cases, processes like DataReader, DataSender or DataReceiver will need almost only informations related to the DAQ crate they are responsible for.
Different methods in this class are optimized for different purposes. Informations are grouped and cached in such a way that both the number of calls to this class from the DAQ processes and the interaction with the db are minimized.
Private Types | |
enum | EnvVarName_t { DbHost_s, DbPort_s, DbUser_s, DbPwd_s, DbName_s } |
enum | DbMode_t { UndefMode_s = 0, MasterMode_s = 1L << 1, TuningMode_s = 1L << 2, GuiMode_s = 1L << 3, ReadMode_s = 1L << 4 } |
Private Member Functions | |
QApolloDbBase () | |
Private constructor. Invoked at the first call of the Get() method. | |
bool | Undefined () const |
determine if db status is undefined | |
bool | Reset (unsigned short settingsBasket, unsigned int runNumber) |
reset db. DbMode is set to Master mode | |
bool | Reset (unsigned short settingsBasket) |
reset db. DbMode is set to Tuning mode | |
bool | Reset () |
reset db. DbMode is set to GUI mode | |
bool | ResetRun () |
reset db. DbMode is set to Run mode | |
const std::map< unsigned short, std::string > & | CrateMap () const |
get map of active crates and corresponding host name | |
short | GetListOfChannels (std::vector< unsigned short > &chList, unsigned short profileId=0) |
get list of active channels corresponding to given profile | |
unsigned short | GetMapping (std::map< unsigned short, QDaqChannel > &cMap) |
fill map with lg channel and corresponding hardware mapping | |
unsigned short | GetActiveChannels (std::map< unsigned short, QDaqChannel > &cMap, QDaqChannel::SettingsType_t what) |
fill map with lg channel and corresponding QDaqChannels | |
int | GetBoards (unsigned short crateId, std::map< unsigned short, std::string > &boards) |
fill boards map with slot and board name | |
int | GetActiveChannels (unsigned short crateId, unsigned short slot, QDaqChannel::SettingsType_t what, std::vector< QDaqChannel > &v) |
Fill map containing given settins for active lg chnannels belonging to the given DAQ slot and DAQ crate. | |
void | GetListOfTriggers (unsigned short lg, std::vector< std::string > &trgList) |
fill list of trigger names for the given channel | |
const QVdt & | GetTrgParameter (unsigned short trgIndex, const std::string &par_name, unsigned short lg=0) |
Get parameter for given trigger index and given channel. | |
const std::map< std::string, QVdt > & | GetTrgParameters (unsigned short trgIndex, unsigned short lg) |
Get map of parameters for given trigger and logical channel. | |
bool | Dump (unsigned short crateId, bool dump) |
dump settings and mapping for the given lg channel | |
unsigned int | GetCurrentRunNumber () const |
return current run number | |
unsigned short | GetCurrentProfile () const |
return profile associated to current run | |
RunType | GetCurrentRunType () const |
return current run type Id | |
unsigned int | GetPulserPeriod () |
get pulser period | |
void | GetRunTypes (std::map< unsigned short, std::string > &runTypes) |
fill map of run type and corresponding description | |
void | GetRuns (std::vector< unsigned int > &runs) |
get runs already present in db that refer to current detector | |
unsigned int | GetLastRun () |
get from db the run number with the most recent start date | |
void | GetSettingsBaskets (unsigned short howMany, std::map< std::string, std::vector< QVdt > > &basketsMap) |
Fill map containing settings baskets present in db. | |
unsigned short | GetSettingsBasketIds (std::vector< unsigned short > &baskets) |
fill vector containing settings basket id that are present in data base. | |
unsigned short | GetSettingsBasket (unsigned short id, std::string &comment) |
get comment associated to given settings basket id | |
void | UpdateStart (unsigned short shifterSet) |
insert into data base start time for current run | |
void | UpdateStop (StopStatus_t stopStatus, unsigned short shifterSet, unsigned short nFiles) |
insert into data base stop time for curent run | |
void | ChangeDefaultSettingsBasket (unsigned short newDefault) |
change default settings basket (used by GUI) | |
void | InsertStartComments (const std::string &comment) |
insert start user comments into the user_infos table | |
void | InsertStopComments (const std::string &comment) |
insert stop user comments into the user_infos table | |
void | Clear () |
reset internal variables and db cache | |
void | Init () |
global parameters initialization | |
void | GuessCurrentRun () |
guess current run number | |
void | InsertNewRun () |
insert a new entry ino the db RUNS table | |
void | UndoInsertRun () |
remove from runs table the entry corresponding to current run | |
void | SanitizeRunsTable () |
fill incomplete rows in runs table (needed in case of error in measurement stop) | |
bool | LoadHardwareProfile (unsigned short crateId) |
Load hardware mapping for the given Daq crate. | |
void | Load (QDaqChannel::SettingsType_t what) |
Load informations specified by 'what' for the whole system. | |
void | Load (QDaqChannel::SettingsType_t what, unsigned short crateId) |
Load informations specified by 'what' for the given crate. | |
void | LoadHwSettings (QDaqChannel::SettingsType_t setType, unsigned short crateId) |
Load hw settings specified by setType only for crateId. | |
void | LoadTriggerSettings (unsigned short crateId) |
load trigger parameters for channels belonging to given crate | |
void | LoadDefaultTriggerSettings () |
load default trigger parameters (i.e. for lg_channel=0) | |
std::string | EscapeString (const std::string &inputString, const char &toBeEscaped, const char &escapeChar) const |
escape requested charachter in a string | |
std::string | CleanString (const std::string &inputString) const |
make string suitable for sql escape chars by calling EscapeString() method as many times as needed | |
RunType | String2RunType (const std::string &s) const |
convert string to RunType | |
Static Private Member Functions | |
static QApolloDbBase & | Get () |
get a reference to QApolloDbBase | |
static std::string | GetDbEnv (EnvVarName_t name) |
Private Attributes | |
unsigned short | fProfile |
current profile | |
unsigned short | fDaqSet |
current daq set | |
unsigned short | fTrgSet |
current trigger set | |
unsigned short | fFESet |
current frontend set | |
unsigned short | fBesSet |
current bessel set | |
RunType | fRunType |
current run type | |
unsigned short | fPulserSet |
current pulser set | |
std::map< unsigned short, std::string > | fActiveCrates |
map of active Daq crates and corresponding network address | |
std::map< unsigned short, unsigned short > | fActiveChannels |
map of active channels and corresponding Daq crate | |
std::vector< unsigned short > | fLoadedHwCrates |
Daq crates for which Hardware mapping has been loaded from db. | |
std::vector< unsigned short > | fLoadedTrgCrates |
Daq crates for which Trigger settings have been loaded from db. | |
std::vector< unsigned short > | fLoadedDaqCrates |
Daq crates for which Daq settings have been loaded from db. | |
std::vector< unsigned short > | fLoadedBesCrates |
Daq crates for which Bessel settings have been loaded from db. | |
std::vector< unsigned short > | fLoadedFECrates |
Daq crates for which FrontEnd settings have been loaded from db. | |
std::vector< unsigned short > | fLoadedPulserCrates |
Daq crates for which Pulser settings have been loaded from db. | |
QApolloDbCache | fCache |
cached db informations | |
unsigned short | fMode |
current DbMode | |
bool | fRunningMode |
determine wether an incomplete run entry is present in db | |
const unsigned int | fLowerRunExcluded |
const unsigned int | fUpperRunExcluded |
Static Private Attributes | |
static bool | gCanWrite |
Determine wether this instance of QApolloDbBase can write into db. | |
static unsigned int | gRunNumber |
current run number | |
static unsigned short | gSettingsBasket |
current settings basket | |
Friends | |
class | QApolloDb |
class | QApolloDbServer |
class | QApolloDbGui |
class | QApolloDbDaq |
class | QApolloDbSlow |
enum QApolloDbBase::DbMode_t [private] |
bool QApolloDbBase::Undefined | ( | ) | const [inline, private] |
determine if db status is undefined
bool QApolloDbBase::Reset | ( | unsigned short | settingsBasket, | |
unsigned int | runNumber | |||
) | [private] |
reset db. DbMode is set to Master mode
bool QApolloDbBase::Reset | ( | unsigned short | settingsBasket | ) | [private] |
reset db. DbMode is set to Tuning mode
bool QApolloDbBase::Reset | ( | ) | [private] |
reset db. DbMode is set to GUI mode
bool QApolloDbBase::ResetRun | ( | ) | [private] |
reset db. DbMode is set to Run mode
short QApolloDbBase::GetListOfChannels | ( | std::vector< unsigned short > & | chList, | |
unsigned short | profileId = 0 | |||
) | [private] |
get list of active channels corresponding to given profile
chList | vector of active channels | |
profileId | requested profileId. If it is zero, current profile Id is assumed or an error is returned in case DAQ is not running. |
unsigned short QApolloDbBase::GetMapping | ( | std::map< unsigned short, QDaqChannel > & | cMap | ) | [private] |
fill map with lg channel and corresponding hardware mapping
cMap | map to be filled |
unsigned short QApolloDbBase::GetActiveChannels | ( | std::map< unsigned short, QDaqChannel > & | cMap, | |
QDaqChannel::SettingsType_t | what | |||
) | [private] |
fill map with lg channel and corresponding QDaqChannels
what | settings to be loaded | |
cMap | map to be filled |
int QApolloDbBase::GetBoards | ( | unsigned short | crateId, | |
std::map< unsigned short, std::string > & | boards | |||
) | [private] |
fill boards map with slot and board name
crateId | identifier of DAQ crate for which board map is filled | |
boards | map to be filled |
int QApolloDbBase::GetActiveChannels | ( | unsigned short | crateId, | |
unsigned short | slot, | |||
QDaqChannel::SettingsType_t | what, | |||
std::vector< QDaqChannel > & | v | |||
) | [private] |
Fill map containing given settins for active lg chnannels belonging to the given DAQ slot and DAQ crate.
crateId | identifier of DAQ crate for which channel map is filled | |
slot | identifier of the DAQ slot for which channel map is filled (all slots belonging to crateId are filled if slot = 0) | |
what | type of settings to be loaded. Multiple types can be loaded using the format Type1|Type2 | |
v | map to be filled |
void QApolloDbBase::GetListOfTriggers | ( | unsigned short | lg, | |
std::vector< std::string > & | trgList | |||
) | [private] |
fill list of trigger names for the given channel
If no entry corresponding to the given lg channel is found in the db then the default trigger names (i.e. lg=0) are returned.
lg | lg channel for which trigger names are returned. Default trigger names can be obtained asking for lg=0. | |
trgList | vector containing trigger names. trigger name "NULL" means that no trigger is associated with that trigger tag for that lg |
const QVdt & QApolloDbBase::GetTrgParameter | ( | unsigned short | trgIndex, | |
const std::string & | par_name, | |||
unsigned short | lg = 0 | |||
) | [private] |
Get parameter for given trigger index and given channel.
par_name | name of parameter to be returned | |
trgIndex | trigger tag for which parameter is returned. Can be 1,2,3 or 4. | |
lg | logical channel for which parameter is returned |
const std::map< std::string, QVdt > & QApolloDbBase::GetTrgParameters | ( | unsigned short | trgIndex, | |
unsigned short | lg | |||
) | [private] |
Get map of parameters for given trigger and logical channel.
trgIndex | trigger tag for which parameter is returned. | |
lg | logical channel for which parameter is returned |
bool QApolloDbBase::Dump | ( | unsigned short | crateId, | |
bool | dump | |||
) | [private] |
dump settings and mapping for the given lg channel
unsigned int QApolloDbBase::GetPulserPeriod | ( | ) | [private] |
get pulser period
void QApolloDbBase::GetRuns | ( | std::vector< unsigned int > & | runs | ) | [private] |
get runs already present in db that refer to current detector
runs | filled with existing runs for this detector. Runs are sorted. |
unsigned int QApolloDbBase::GetLastRun | ( | ) | [private] |
get from db the run number with the most recent start date
void QApolloDbBase::GetSettingsBaskets | ( | unsigned short | howMany, | |
std::map< std::string, std::vector< QVdt > > & | basketsMap | |||
) | [private] |
Fill map containing settings baskets present in db.
howMany | number of entries to be loaded. All entries are loaded if howMany is zero | |
basketsMap | Map to be filled. Map Keys are db column names; map values are QVdt vectors |
unsigned short QApolloDbBase::GetSettingsBasketIds | ( | std::vector< unsigned short > & | baskets | ) | [private] |
fill vector containing settings basket id that are present in data base.
baskets | vector that will be filled with existing setting basket id |
unsigned short QApolloDbBase::GetSettingsBasket | ( | unsigned short | id, | |
std::string & | comment | |||
) | [private] |
get comment associated to given settings basket id
id | settings basket id for which the comment is requested. If id is zero default settings basket is assumed | |
comment | reference to a string that will be filled with the comment associated to the default settings basket |
void QApolloDbBase::InsertStartComments | ( | const std::string & | comment | ) | [private] |
insert start user comments into the user_infos table
comment | user comment to be inserted |
void QApolloDbBase::InsertStopComments | ( | const std::string & | comment | ) | [private] |
insert stop user comments into the user_infos table
comment | user comment to be inserted |
void QApolloDbBase::GuessCurrentRun | ( | ) | [private] |
guess current run number
Guess current run number searching the db for a unique entry in the runs table that has neither start date nor stop date entry.
void QApolloDbBase::UndoInsertRun | ( | ) | [private] |
remove from runs table the entry corresponding to current run
This method does not perform any check. It simply executes a DELETE statement on current run and only if measurement start_date is null. In particular it returns immediately if current run number is 0 (i.e. it is not set)
std::string QApolloDbBase::EscapeString | ( | const std::string & | inputString, | |
const char & | toBeEscaped, | |||
const char & | escapeChar | |||
) | const [private] |
escape requested charachter in a string
inputString | string to be escaped | |
toBeEscaped | charcter to be escaped | |
escapeChar | escape character |
std::string QApolloDbBase::CleanString | ( | const std::string & | inputString | ) | const [private] |
make string suitable for sql escape chars by calling EscapeString() method as many times as needed
inputString | string to be cleaned |
RunType QApolloDbBase::String2RunType | ( | const std::string & | s | ) | const [private] |
convert string to RunType
s | run type string to be converted |