Public Member Functions | |
virtual | ~QEleConfigHandler () |
dtor | |
bool | Add (const QEleChannelConfig &config) |
schedule changes in electronics configuration for a certain logical channel | |
bool | Replace (const QEleChannelConfig &config) |
same as Add(), but if a previously requested configuration exists, it is replaced by the new one. | |
void | RemoveConfig (int lg) |
remove scheduled configuration for channel lg (if any) | |
void | RemoveAllConfigs () |
remove all scheduled configurations | |
void | SetSleepAfterChangeSec (unsigned int sleepSec) |
set time to sleep after changing electronics configuration | |
void | SetExternalBiasV (float extBiasVolt) |
set external bias voltage in Volts | |
bool | Apply () |
apply electronics configuration previously requested with calls to Add() or Replace() functions | |
const QEleChannelConfig * | GetConfig (unsigned int lg, unsigned int id) |
get configuration associated to the given id and for the given logical channel | |
bool | Reset (int settingsBasket, const std::set< int > &activeChannels) |
reset this object to its initial configuration | |
void | SetWrongPolarityChannels (const std::set< int > &channels) |
set list of channels with wrong bias polarity (due to bad hardware cabling). | |
const QError & | GetError () const |
get last error | |
bool | ResetError () |
reset error | |
bool | ConfigOngoing () |
bool | IsActiveChannel (int lg) const |
Static Public Member Functions | |
static QEleConfigHandler & | GetInstance () |
get reference to singleton | |
Private Member Functions | |
QEleConfigHandler () | |
ctor | |
bool | SyncThread () |
void | CheckThread () |
bool | InterruptExecution () |
interrupt thread execution | |
bool | GetCratesToKill (const std::set< int > &activeChannels) |
read from db the list of daq crates involved in electronics changes | |
void | ClearMaps () |
Private Attributes | |
std::map< int, QEleChannelConfig * > | fInputConfigs |
std::map< int, QEleChannelConfig * > | fTmpConfigs |
std::map< int, std::vector < QEleChannelConfig * > > | fPastConfigs |
std::set< unsigned int > | fCratesToKill |
std::set< int > | fWrongPolarityChannels |
int | fSettingsBasket |
unsigned int | fSleepAfterChangeSec |
float | fExtBiasV |
boost::mutex * | fMutex |
boost::thread * | fThread |
QError | fError |
Static Private Attributes | |
static QEleConfigHandler * | gMe = NULL |
bool QEleConfigHandler::Add | ( | const QEleChannelConfig & | config | ) |
schedule changes in electronics configuration for a certain logical channel
config | object storing electronics configuration to be applied |
References fInputConfigs, fPastConfigs, and QEleChannelConfig::GetLg().
Referenced by MLCBaseController::NextConf().
bool QEleConfigHandler::Replace | ( | const QEleChannelConfig & | config | ) |
same as Add(), but if a previously requested configuration exists, it is replaced by the new one.
References fInputConfigs, fPastConfigs, and QEleChannelConfig::GetLg().
void QEleConfigHandler::SetSleepAfterChangeSec | ( | unsigned int | sleepSec | ) | [inline] |
set time to sleep after changing electronics configuration
The sleep time is actually doubled compared to the specified value, since two calls to sleep() are present: one after modifying the external bias, and the other one after changing the electronics configuration.
References fSleepAfterChangeSec.
Referenced by MLCBaseController::NextConf().
bool QEleConfigHandler::Apply | ( | ) |
apply electronics configuration previously requested with calls to Add() or Replace() functions
References CheckThread(), fCratesToKill, fError, fExtBiasV, fInputConfigs, fMutex, fPastConfigs, fSettingsBasket, fSleepAfterChangeSec, fThread, fTmpConfigs, fWrongPolarityChannels, and SyncThread().
Referenced by MLCBaseController::NextConf().
const QEleChannelConfig * QEleConfigHandler::GetConfig | ( | unsigned int | lg, | |
unsigned int | id | |||
) |
get configuration associated to the given id and for the given logical channel
lg | logical channel | |
id | electronics configuration id |
References CheckThread(), fPastConfigs, and QOnlineMessenger::OLWarn().
bool QEleConfigHandler::Reset | ( | int | settingsBasket, | |
const std::set< int > & | activeChannels | |||
) |
reset this object to its initial configuration
settingsBasket | settings basket to be used for channel mapping | |
activeChannels | list of channels to be handled by this object |
References ClearMaps(), fPastConfigs, fSettingsBasket, GetCratesToKill(), and InterruptExecution().
Referenced by MLCBaseController::InitHandler().
void QEleConfigHandler::SetWrongPolarityChannels | ( | const std::set< int > & | channels | ) | [inline] |
set list of channels with wrong bias polarity (due to bad hardware cabling).
The polarity for the channels belonging to this list will be inverted with respect to what is found in the corresponding QEleChannelConfig object.
References fWrongPolarityChannels.
Referenced by MLCBaseController::InitHandler().
bool QEleConfigHandler::ResetError | ( | ) |
reset error
References ConfigOngoing(), fError, and QError::Set().
bool QEleConfigHandler::ConfigOngoing | ( | ) |
References CheckThread(), and fThread.
Referenced by MLCBaseController::Do(), and ResetError().
bool QEleConfigHandler::IsActiveChannel | ( | int | lg | ) | const [inline] |
check whether a given logical channel is active
References fPastConfigs.
Referenced by MLCMeasCollector::Do().
bool QEleConfigHandler::SyncThread | ( | ) | [private] |
Check the status of a possible electronics configuration thread.
If fThread is NULL this method does nothing and returns false.
Otherwise it executes a timed_join on the thread with a timeout of 50 ms. If the join succeeds, it returns true, otherwise it returns false.
When this method returns true, the content of fError should be checked to discover the exit status of the thread.
References fThread.
Referenced by Apply(), CheckThread(), and InterruptExecution().
void QEleConfigHandler::CheckThread | ( | ) | [private] |
Call SyncThread() and, in case of success, update configuration maps
References fError, fPastConfigs, fTmpConfigs, and SyncThread().
Referenced by Apply(), ConfigOngoing(), and GetConfig().
bool QEleConfigHandler::InterruptExecution | ( | ) | [private] |
interrupt thread execution
References fThread, and SyncThread().
Referenced by Reset(), and ~QEleConfigHandler().
bool QEleConfigHandler::GetCratesToKill | ( | const std::set< int > & | activeChannels | ) | [private] |
read from db the list of daq crates involved in electronics changes
activeChannels | list of channels involved in electronics changes |
References fCratesToKill, fError, fSettingsBasket, QDbDetector::GetDaqCrates(), and QError::Set().
Referenced by Reset().
void QEleConfigHandler::ClearMaps | ( | ) | [private] |
delete content of the three maps storing electronics configuration
References fInputConfigs, fPastConfigs, and fTmpConfigs.
Referenced by Reset(), and ~QEleConfigHandler().
QEleConfigHandler * QEleConfigHandler::gMe = NULL [static, private] |
static pointer to the instance of this object
Referenced by GetInstance().
std::map<int, QEleChannelConfig*> QEleConfigHandler::fInputConfigs [private] |
map storing the input configurations received from calls to Add() and Replace().
key: lg channel, value: pointer to corresponding electronics config
Referenced by Add(), Apply(), ClearMaps(), RemoveAllConfigs(), RemoveConfig(), and Replace().
std::map<int, QEleChannelConfig*> QEleConfigHandler::fTmpConfigs [private] |
temporary storage for the configurations that are being applied. See documentation for Apply() for further details.
the map has same structure as fInputConfigs
Referenced by Apply(), CheckThread(), and ClearMaps().
std::map<int, std::vector<QEleChannelConfig*> > QEleConfigHandler::fPastConfigs [private] |
key: lg, value: a vector of QEleChannelConfigs*
The i-th element of the vector stores the configuration with id i
Referenced by Add(), Apply(), CheckThread(), ClearMaps(), GetConfig(), IsActiveChannel(), Replace(), and Reset().
std::set<unsigned int> QEleConfigHandler::fCratesToKill [private] |
list of daq crates acquiring at least one of the channels that are involved in electronics changes (this list is set in the Reset() method)
Referenced by Apply(), and GetCratesToKill().
std::set<int> QEleConfigHandler::fWrongPolarityChannels [private] |
set of channels with wrong bias polarity (bad hardware cabling)
Referenced by Apply(), and SetWrongPolarityChannels().
int QEleConfigHandler::fSettingsBasket [private] |
settings basket to be used for channel mapping
Referenced by Apply(), GetCratesToKill(), and Reset().
unsigned int QEleConfigHandler::fSleepAfterChangeSec [private] |
time in seconds to sleep after changing the external bias and after applying new electronics configuration
Referenced by Apply(), and SetSleepAfterChangeSec().
float QEleConfigHandler::fExtBiasV [private] |
external bias in V
Referenced by Apply(), and SetExternalBiasV().
boost::mutex* QEleConfigHandler::fMutex [private] |
used to avoid concurent calls to Apply()
Referenced by Apply(), and ~QEleConfigHandler().
boost::thread* QEleConfigHandler::fThread [private] |
thread where the electronics configuration are applied
Referenced by Apply(), ConfigOngoing(), InterruptExecution(), and SyncThread().
QError QEleConfigHandler::fError [private] |
in case of any error, is set to something other than QERR_SUCCESS and is reset as soon as ResetError() is called.
Referenced by Apply(), CheckThread(), GetCratesToKill(), GetError(), and ResetError().