Handled signals are: SIGINT, SIGABRT, SIGFPE, SIGSEGV, SIGTERM, SIGUSR1, SIGUSR2, SIGTTIN, SIGTTOU. Each signal can be associated to a value of QDaqCommonDefs::ProcessStatus_t. More than one signal can be associated to the same process status. Several signals are enabled by default and serveral are not. Moreover, the association between a signal and the corresponding QDaqCommonDefs::ProcessStatus_t is not modifiable for all signals, as for the enabled/disabled state, which can be toggled only for several signals. When a signal is not enabled, the default signal handler is called. In order for a signal to be ignored, the Ignore() method must be called with the signal as argument. All signals that can be disabled can be also ignored. Follows a detailed list of the possibilities the user has to control each signal:
Public Member Functions | |
virtual | ~QProcessStatus () |
dtor | |
bool | Associate (int signalId, QDaqCommonDefs::ProcessStatus_t pStatus) |
associate a signal to a given process status | |
bool | Enable (int signalId) |
associate signal to cuore signal handler | |
bool | Disable (int signalId) |
enable handling of a signal | |
bool | Ignore (int signalId) |
ignore signal | |
bool | HasChanged () const |
tell wehter process status has changed | |
volatile QDaqCommonDefs::ProcessStatus_t | GetState () const |
get current state | |
volatile QDaqCommonDefs::ProcessStatus_t | GetPreviousState () const |
get previous state | |
volatile QDaqCommonDefs::ProcessStatus_t | GetNextState () const |
get the status the process will go into the next time that Notify() will be called. Returns current state if hasChanged() returns false | |
void | SetState (QDaqCommonDefs::ProcessStatus_t state) |
change current process status bypassing status queue vector | |
void | Notify () |
acknowledge oldest process status contained in staus queue vector | |
volatile bool | isRunning () const |
check wether current process status is QRunning_s | |
volatile bool | isPaused () const |
check wether current process status is QPaused_s | |
volatile bool | isIdle () const |
check wether current process status is QIdle_s | |
volatile bool | isReady () const |
check wether current process status is QReady_s | |
volatile bool | TrgCtrlEnabled () const |
check wether trigger control signals are enabled | |
const std::string & | GetError () const |
get error string | |
void | SetError (const std::string &errMsg) |
set error string | |
bool | isError () const |
check wether an error occurred | |
void | SetTrgCtrlEnabled (bool enabled) |
enable or disable trigger status control | |
void | InformServer () |
inform Daq Server about current process status | |
void | SetName (const std::string &name) |
set process name that will be used for communication with message logger server | |
Static Public Member Functions | |
static QProcessStatus & | GetInstance () |
get singleton Instance | |
Private Member Functions | |
QProcessStatus () | |
declare signal handler for handled signals, set error string to an empty string and disable by default trigger control signals | |
void | HandleSignal (int signalId) |
this method is called each time a registered signal is caught. It updates the status queue and inform message logger if necessary. | |
void | AssociateDefaults () |
associate default signals to be caught | |
void | AddToQueue (QDaqCommonDefs::ProcessStatus_t state) |
add state to process status queue. | |
QDaqCommonDefs::ProcessStatus_t | GetLastStatus () const |
get last status that have been added to status queue. If queue is empty current process status is returned. | |
bool | CanBeHandled (int signalId) const |
check wether requested signal can be handled | |
bool | CanBeDisabled (int signalId) const |
check wether requested signal can be disabled | |
Private Attributes | |
QDaqCommonDefs::ProcessStatus_t | fState |
current process status | |
QDaqCommonDefs::ProcessStatus_t | fPreviousState |
previous process status | |
bool | fTrgCtrl |
determine wether trigger control signals are enabled (default is disabled) | |
bool | fInformEnabled |
determine wether to inform server about changes of state | |
const size_t | kMaxQueued |
maximum number of not-notified process statuses. If process queue exceeds this size a warning is sent to stderr. | |
std::deque < QDaqCommonDefs::ProcessStatus_t > | fStatusQueue |
vector containing stauts evolution for current process contains all status changes that are newer than current state | |
std::string | fError |
error string | |
std::map< int, QDaqCommonDefs::ProcessStatus_t > | fSigMap |
map of system signal and associated process status | |
Friends | |
void | SigHandler (int) |
signal handler function |
bool QProcessStatus::Associate | ( | int | signalId, | |
QDaqCommonDefs::ProcessStatus_t | pStatus | |||
) |
associate a signal to a given process status
signalId | system signal to be associated to status pStatus | |
pStatus | process status to be associated to signal signalId |
bool QProcessStatus::Enable | ( | int | signalId | ) |
associate signal to cuore signal handler
signalId | signal to be enabled. This signal must be already associated to a value of QDaqCommonDefs::ProcessStatus_t. |
References CanBeHandled(), fInformEnabled, and SigHandler.
Referenced by Associate(), and AssociateDefaults().
void QProcessStatus::SetState | ( | QDaqCommonDefs::ProcessStatus_t | state | ) |
change current process status bypassing status queue vector
state | new process status |
References fPreviousState, fState, fStatusQueue, InformServer(), and QDaqCommonDefs::ProcessStatusEnumToString().
Referenced by QNiDigitalController::HandleNiError(), QPulserGuiInterface::Start(), and QPulserGuiInterface::Stop().
volatile bool QProcessStatus::isRunning | ( | ) | const [inline] |
check wether current process status is QRunning_s
References fState, and QDaqCommonDefs::QRunning_s.
Referenced by QBasePulserController::Run().
volatile bool QProcessStatus::isPaused | ( | ) | const [inline] |
check wether current process status is QPaused_s
References fState, and QDaqCommonDefs::QPaused_s.
volatile bool QProcessStatus::isIdle | ( | ) | const [inline] |
check wether current process status is QIdle_s
References fState, and QDaqCommonDefs::QIdle_s.
volatile bool QProcessStatus::isReady | ( | ) | const [inline] |
check wether current process status is QReady_s
References fState, and QDaqCommonDefs::QReady_s.
volatile bool QProcessStatus::TrgCtrlEnabled | ( | ) | const [inline] |
check wether trigger control signals are enabled
References fTrgCtrl.
Referenced by HandleSignal().
const std::string& QProcessStatus::GetError | ( | ) | const [inline] |
get error string
References fError.
void QProcessStatus::SetError | ( | const std::string & | errMsg | ) | [inline] |
void QProcessStatus::SetTrgCtrlEnabled | ( | bool | enabled | ) | [inline] |
enable or disable trigger status control
enable | if true, trigger control is enabled (default is disabled) |
References fTrgCtrl.
void QProcessStatus::InformServer | ( | ) |
inform Daq Server about current process status
Msg Server is informed by mean of a socket client. If error string is not empty, it is sent to Daq Server together with process status Id.
References fInformEnabled, QApolloMessenger::GetInstance(), GetState(), QApolloMessenger::SendStatus(), and QApolloMessenger::SetName().
Referenced by HandleSignal(), Notify(), and SetState().
void QProcessStatus::SetName | ( | const std::string & | name | ) | [inline] |
set process name that will be used for communication with message logger server
name | process name |
void QProcessStatus::HandleSignal | ( | int | signalId | ) | [private] |
this method is called each time a registered signal is caught. It updates the status queue and inform message logger if necessary.
signalId | system signal to be handled |
References AddToQueue(), fSigMap, fStatusQueue, GetLastStatus(), InformServer(), QDaqCommonDefs::QAskStatus_s, QDaqCommonDefs::QError_s, QDaqCommonDefs::QExiting_s, QDaqCommonDefs::QIdle_s, QDaqCommonDefs::QPaused_s, QDaqCommonDefs::QReady_s, QDaqCommonDefs::QRunning_s, QDaqCommonDefs::QStopped_s, QDaqCommonDefs::QTriggerOff_s, QDaqCommonDefs::QTriggerOn_s, SetError(), and TrgCtrlEnabled().
Referenced by SigHandler().
void QProcessStatus::AddToQueue | ( | QDaqCommonDefs::ProcessStatus_t | state | ) | [private] |
add state to process status queue.
state | status to be added to queue |
References fStatusQueue, GetLastStatus(), kMaxQueued, QDaqCommonDefs::QTriggerOff_s, and QDaqCommonDefs::QTriggerOn_s.
Referenced by HandleSignal().
void SigHandler | ( | int | ) | [friend] |
signal handler function
signalId | signal to be handled |
Referenced by Enable().