TwiceAsNice  2019-02-18
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Basda::BasdardServiceWorker Class Reference

#include <BasdardServiceWorker.h>

Inheritance diagram for Basda::BasdardServiceWorker:
Inheritance graph
Collaboration diagram for Basda::BasdardServiceWorker:
Collaboration graph

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...
 
- Public Member Functions inherited from Basda::ServiceWorker
const Nice::JointPtrconfig ()
 
Nice::JointPtr cfg ()
 
Nice::JointPtr var ()
 
virtual const std::string & name ()
 
virtual WorkerThreadPtr worker ()
 
virtual Nice::Monitormonitor ()
 
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::JointPtrconfig ()
 
Nice::JointPtr cfg ()
 
Nice::JointPtr var ()
 
virtual const std::string & name ()
 
virtual WorkerThreadPtr worker ()
 
virtual Nice::Monitormonitor ()
 
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...
 
- Protected Member Functions inherited from Basda::ServiceWorker
 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
 
- Protected Attributes inherited from Basda::ServiceWorker
Nice::JointPtr m_config
 
Nice::PropertyPtr m_state
 
std::string m_name
 

Additional Inherited Members

- Protected Types inherited from Basda::ServiceWorker
typedef void(ServiceWorker::* ServiceWorkerMemFn) ()
 
typedef Branch BranchTable[6][6]
 
typedef IceUtil::Handle< WorkerThreadWorkerThreadPtr
 
typedef void(ServiceWorker::* ServiceWorkerMemFn) ()
 
typedef Branch BranchTable[6][6]
 
typedef IceUtil::Handle< WorkerThreadWorkerThreadPtr
 
- Static Protected Attributes inherited from Basda::ServiceWorker
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...
 

Constructor & Destructor Documentation

◆ BasdardServiceWorker()

Basda::BasdardServiceWorker::BasdardServiceWorker ( const Nice::JointPtr _config)

ctor. Starts the worker.


Parameters
_configThe node of the property tree The log level is set from the BASDARD.LOGLEVEL node.

◆ ~BasdardServiceWorker()

Basda::BasdardServiceWorker::~BasdardServiceWorker ( )
virtual

dtor. Dummy (does nothing in this base class).


Member Function Documentation

◆ activate()

void Basda::BasdardServiceWorker::activate ( )
virtual

Set the state to ONLINE.


Implements Basda::ServiceWorker.

◆ deactivate()

void Basda::BasdardServiceWorker::deactivate ( )
virtual

Set the state to STANDBY (unless the state machine has another target status)


Implements Basda::ServiceWorker.

◆ deinit()

void Basda::BasdardServiceWorker::deinit ( )
virtual

Set the state to OFFLINE (unless the state machine has another target status)


Implements Basda::ServiceWorker.

◆ idleOffline()

void Basda::BasdardServiceWorker::idleOffline ( )
virtual

does nothing (but to wait for state change).


Reimplemented from Basda::ServiceWorker.

◆ idleOnline()

void Basda::BasdardServiceWorker::idleOnline ( )
virtual

does nothing (but to LOG the idle state in intervals set by the LOGSTATE time intervals)


Reimplemented from Basda::ServiceWorker.

◆ idleStandby()

void Basda::BasdardServiceWorker::idleStandby ( )
virtual

does nothing (but to wait for state change).


Reimplemented from Basda::ServiceWorker.

◆ init()

void Basda::BasdardServiceWorker::init ( )
virtual

Set the state to STANDBY (unless the state machine has another target status)


Implements Basda::ServiceWorker.

◆ preinit()

void Basda::BasdardServiceWorker::preinit ( )
virtual

Initialize the basic Nice application interface, laod devices and start workers.


Reimplemented from Basda::ServiceWorker.

◆ setAllServiceState()

void Basda::BasdardServiceWorker::setAllServiceState ( const Basda::ServiceState _state)
protected

sets all worker states to a common state.


Parameters
_statethe 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.

◆ terminate()

void Basda::BasdardServiceWorker::terminate ( )
virtual

Sends all service states to SHUTDOWN and then terminates this worker itself.


Reimplemented from Basda::ServiceWorker.

◆ work()

virtual void Basda::BasdardServiceWorker::work ( )
inlinevirtual

Implements Basda::ServiceWorker.

Member Data Documentation

◆ m_loglevel

Nice::LEVEL Basda::BasdardServiceWorker::m_loglevel
protected

◆ s_status

int Basda::BasdardServiceWorker::s_status = EXIT_SUCCESS
static

The documentation for this class was generated from the following files: