TwiceAsNice
2019-02-18
|
#include <BasdardServiceWorker.h>
Public Member Functions | |
BasdardServiceWorker (const Nice::JointPtr &_config) | |
ctor. Starts the worker. More... | |
virtual | ~BasdardServiceWorker () |
dtor. Dummy (does nothing in this base class). More... | |
virtual void | idleOffline () |
does nothing (but to wait for state change). More... | |
virtual void | idleStandby () |
does nothing (but to wait for state change). More... | |
virtual void | idleOnline () |
does nothing (but to LOG the idle state in intervals set by the LOGSTATE time intervals) More... | |
virtual void | preinit () |
Initialize the basic Nice application interface, laod devices and start workers. More... | |
virtual void | init () |
Set the state to STANDBY (unless the state machine has another target status) More... | |
virtual void | deinit () |
Set the state to OFFLINE (unless the state machine has another target status) More... | |
virtual void | activate () |
Set the state to ONLINE. More... | |
virtual void | deactivate () |
Set the state to STANDBY (unless the state machine has another target status) More... | |
virtual void | work () |
virtual void | terminate () |
Sends all service states to SHUTDOWN and then terminates this worker itself. More... | |
![]() | |
const Nice::JointPtr & | config () |
Nice::JointPtr | cfg () |
Nice::JointPtr | var () |
virtual const std::string & | name () |
virtual WorkerThreadPtr | worker () |
virtual Nice::Monitor & | monitor () |
virtual void | lock () |
virtual void | unlock () |
bool | stateIsSettled () |
bool | stateHasChanged () |
void | changeState (Basda::ServiceState _state) |
change state to a new state If the state is the current state, or a negative state, do nothing. Otherwise change the "next" state in the state machine and notify all threads. More... | |
bool | tryChangeState (Basda::ServiceState _state, const Nice::Time &_timeout=Nice::Time::seconds(0.0)) |
change state to a new state More... | |
void | waitForState (Basda::ServiceState _state) |
wait (indefinitely) until the worker has reached a spcifici state More... | |
bool | timedWaitForState (Basda::ServiceState _state, const Nice::Time &_timeout) |
wait (indefinitely) until the worker has reached a specific state More... | |
bool | changeStateOnlyFromTo (Basda::ServiceState _from, Basda::ServiceState _to) |
wait (indefinitely) until the worker has reached a spcifici state More... | |
Basda::ServiceState | state () |
Basda::ServiceState | stateNow () |
Basda::ServiceState | stateNext () |
Basda::ServiceState | stateLast () |
bool | isTransit () |
bool | isTerminated () |
const Nice::JointPtr & | config () |
Nice::JointPtr | cfg () |
Nice::JointPtr | var () |
virtual const std::string & | name () |
virtual WorkerThreadPtr | worker () |
virtual Nice::Monitor & | monitor () |
virtual void | lock () |
virtual void | unlock () |
bool | stateIsSettled () |
bool | stateHasChanged () |
void | changeState (Basda::ServiceState _state) |
bool | tryChangeState (Basda::ServiceState _state, const Nice::Time &_timeout=Nice::Time::seconds(0.0)) |
void | waitForState (Basda::ServiceState _state) |
bool | timedWaitForState (Basda::ServiceState _state, const Nice::Time &_timeout) |
bool | changeStateOnlyFromTo (Basda::ServiceState _from, Basda::ServiceState _to) |
Basda::ServiceState | state () |
Basda::ServiceState | stateNow () |
Basda::ServiceState | stateNext () |
Basda::ServiceState | stateLast () |
bool | isTransit () |
bool | isTerminated () |
Static Public Attributes | |
static int | s_status = EXIT_SUCCESS |
Protected Member Functions | |
void | setAllServiceState (const Basda::ServiceState &_state) |
sets all worker states to a common state. More... | |
![]() | |
ServiceWorker (const Nice::JointPtr &_jointPtr) | |
ctor More... | |
virtual | ~ServiceWorker () |
dtor Does nothing (in this base class) More... | |
void | triggerState (const Basda::ServiceStateMachine &_state) |
change state to a new state More... | |
void | sendStateStatus (const std::string &_action, int _percent) |
void | setState (Basda::ServiceState _next) |
virtual void | waitForNewState () |
virtual bool | timedWaitForNewState (const Nice::Time &_timeout) |
virtual void | abort () |
does nothing. More... | |
virtual void | stop () |
does nothing. More... | |
virtual void | packin () |
schedule ONLINE as the next target state. More... | |
virtual void | errorOffline () |
set the target state to OFFLINE. More... | |
virtual void | errorStandby () |
set the target state to OFFLINE. More... | |
virtual void | errorOnline () |
set the target state to OFFLINE. More... | |
virtual void | errorWorking () |
set the target state to OFFLINE. More... | |
ServiceWorker (const Nice::JointPtr &_jointPtr) | |
virtual | ~ServiceWorker () |
void | triggerState (const Basda::ServiceStateMachine &_state) |
void | sendStateStatus (const std::string &_action, int _percent) |
void | setState (Basda::ServiceState _next) |
virtual void | waitForNewState () |
virtual bool | timedWaitForNewState (const Nice::Time &_timeout) |
virtual void | abort () |
virtual void | stop () |
virtual void | packin () |
virtual void | errorOffline () |
virtual void | errorStandby () |
virtual void | errorOnline () |
virtual void | errorWorking () |
Protected Attributes | |
Nice::LEVEL | m_loglevel |
![]() | |
Nice::JointPtr | m_config |
Nice::PropertyPtr | m_state |
std::string | m_name |
Additional Inherited Members | |
![]() | |
typedef void(ServiceWorker::* | ServiceWorkerMemFn) () |
typedef Branch | BranchTable[6][6] |
typedef IceUtil::Handle< WorkerThread > | WorkerThreadPtr |
typedef void(ServiceWorker::* | ServiceWorkerMemFn) () |
typedef Branch | BranchTable[6][6] |
typedef IceUtil::Handle< WorkerThread > | WorkerThreadPtr |
![]() | |
static BranchTable | s_stateTable |
A table which tells which state should go via which intermediate state to a target state. The 6 states are SHUTDOWN, OFFLINE, STANDBY, ONLINE, WORKING and ERROR. The principles are that. More... | |
Basda::BasdardServiceWorker::BasdardServiceWorker | ( | const Nice::JointPtr & | _config | ) |
ctor. Starts the worker.
_config | The node of the property tree The log level is set from the BASDARD.LOGLEVEL node. |
|
virtual |
dtor. Dummy (does nothing in this base class).
|
virtual |
|
virtual |
Set the state to STANDBY (unless the state machine has another target status)
Implements Basda::ServiceWorker.
|
virtual |
Set the state to OFFLINE (unless the state machine has another target status)
Implements Basda::ServiceWorker.
|
virtual |
|
virtual |
does nothing (but to LOG the idle state in intervals set by the LOGSTATE time intervals)
Reimplemented from Basda::ServiceWorker.
|
virtual |
|
virtual |
Set the state to STANDBY (unless the state machine has another target status)
Implements Basda::ServiceWorker.
|
virtual |
Initialize the basic Nice application interface, laod devices and start workers.
Reimplemented from Basda::ServiceWorker.
|
protected |
sets all worker states to a common state.
_state | the new target state. If the workers are in working state and the new state is SHUTDOWN, the abort() functions are called on the workers. For workers not in the TERMINATED state we try with a timeout of 1/3 second to change their state. Then we give a time of up 30 seconds to have the workers either to terminate or to settle into the new state. Those that don't do that are cancelled. |
|
virtual |
Sends all service states to SHUTDOWN and then terminates this worker itself.
Reimplemented from Basda::ServiceWorker.
|
inlinevirtual |
Implements Basda::ServiceWorker.
|
protected |
|
static |