OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
RTC::ExecutionContextBase Class Reference

A base class for ExecutionContext. More...

#include <ExecutionContextBase.h>

Inheritance diagram for RTC::ExecutionContextBase:
Collaboration diagram for RTC::ExecutionContextBase:

Public Member Functions

 ExecutionContextBase (const char *name)
 Constructor.
 
virtual ~ExecutionContextBase ()
 Virtual Destructor.
 
virtual void init (coil::Properties &props)
 Initialize the ExecutionContext.
 
virtual RTC::ReturnCode_t bindComponent (RTC::RTObject_impl *rtc)
 Bind the component.
 
CORBA::Boolean isRunning ()
 Check for ExecutionContext running state.
 
RTC::ReturnCode_t start ()
 Start the ExecutionContext.
 
virtual RTC::ReturnCode_t stop ()
 Stop the ExecutionContext.
 
double getRate () const
 Get execution rate(Hz) of ExecutionContext.
 
std::chrono::nanoseconds getPeriod () const
 
RTC::ReturnCode_t setRate (double rate)
 Set execution rate(Hz) of ExecutionContext.
 
RTC::ReturnCode_t addComponent (RTC::LightweightRTObject_ptr comp)
 Add an RT-component.
 
RTC::ReturnCode_t removeComponent (RTC::LightweightRTObject_ptr comp)
 Remove the RT-Component from participant list.
 
RTC::ReturnCode_t activateComponent (RTC::LightweightRTObject_ptr comp)
 Activate an RT-component.
 
RTC::ReturnCode_t deactivateComponent (RTC::LightweightRTObject_ptr comp)
 Deactivate an RT-component.
 
RTC::ReturnCode_t resetComponent (RTC::LightweightRTObject_ptr comp)
 Reset the RT-component.
 
RTC::LifeCycleState getComponentState (RTC::LightweightRTObject_ptr comp)
 Get RT-component's state.
 
RTC::ExecutionKind getKind () const
 Get the ExecutionKind.
 
RTC::ExecutionContextProfile * getProfile ()
 Getting Profile.
 
void setObjRef (RTC::ExecutionContextService_ptr ec_ptr)
 Get the reference to the CORBA object.
 
RTC::ExecutionContextService_ptr getObjRef () const
 
RTC::ReturnCode_t setKind (RTC::ExecutionKind kind)
 Set the ExecutionKind.
 
RTC::ReturnCode_t setOwner (RTC::LightweightRTObject_ptr comp)
 Setting owner component of the execution context.
 
RTC::RTObject_ptr getOwner () const
 Getting a reference of the owner component.
 
const RTC::RTCList & getComponentList () const
 Getting participant RTC list.
 
void setProperties (coil::Properties &props)
 Setting Properties.
 
coil::Properties getProperties () const
 Setting Properties.
 
const RTC::ExecutionContextProfile & getProfile () const
 Getting Profile.
 
bool isAllCurrentState (RTC::LifeCycleState state)
 
bool isAllNextState (RTC::LifeCycleState state)
 
bool isOneOfCurrentState (RTC::LifeCycleState state)
 
bool isOneOfNextState (RTC::LifeCycleState state)
 
void invokeWorker ()
 
void invokeWorkerPreDo ()
 
void invokeWorkerDo ()
 
void invokeWorkerPostDo ()
 

Static Public Member Functions

static const char * getStateString (RTC::LifeCycleState state)
 
static const char * getKindString (RTC::ExecutionKind kind)
 Converting ExecutionKind enum to string.
 

Protected Member Functions

virtual bool onIsRunning (bool running)
 
virtual RTC::ReturnCode_t onStarting ()
 
virtual RTC::ReturnCode_t onStarted ()
 
virtual RTC::ReturnCode_t onStopping ()
 
virtual RTC::ReturnCode_t onStopped ()
 
virtual double onGetRate (double rate) const
 
virtual double onSettingRate (double rate)
 
virtual RTC::ReturnCode_t onSetRate (double)
 
virtual RTC::ReturnCode_t onAddingComponent (RTC::LightweightRTObject_ptr)
 
virtual RTC::ReturnCode_t onAddedComponent (RTC::LightweightRTObject_ptr)
 
virtual RTC::ReturnCode_t onRemovingComponent (RTC::LightweightRTObject_ptr)
 
virtual RTC::ReturnCode_t onRemovedComponent (RTC::LightweightRTObject_ptr)
 
virtual RTC::ReturnCode_t onActivating (RTC::LightweightRTObject_ptr)
 
virtual RTC::ReturnCode_t onWaitingActivated (RTC_impl::RTObjectStateMachine *, long int)
 
virtual RTC::ReturnCode_t onActivated (RTC_impl::RTObjectStateMachine *, long int)
 
virtual RTC::ReturnCode_t onDeactivating (RTC::LightweightRTObject_ptr)
 
virtual RTC::ReturnCode_t onWaitingDeactivated (RTC_impl::RTObjectStateMachine *, long int)
 
virtual RTC::ReturnCode_t onDeactivated (RTC_impl::RTObjectStateMachine *, long int)
 
virtual RTC::ReturnCode_t onResetting (RTC::LightweightRTObject_ptr)
 
virtual RTC::ReturnCode_t onWaitingReset (RTC_impl::RTObjectStateMachine *, long int)
 
virtual RTC::ReturnCode_t onReset (RTC_impl::RTObjectStateMachine *, long int)
 
virtual RTC::LifeCycleState onGetComponentState (RTC::LifeCycleState state)
 
virtual RTC::ExecutionKind onGetKind (RTC::ExecutionKind kind) const
 
virtual RTC::ExecutionContextProfile * onGetProfile (RTC::ExecutionContextProfile *&profile)
 

Protected Attributes

RTC::Logger rtclog
 
RTC_impl::ExecutionContextWorker m_worker
 
RTC_impl::ExecutionContextProfile m_profile
 
std::chrono::nanoseconds m_activationTimeout
 
std::chrono::nanoseconds m_deactivationTimeout
 
std::chrono::nanoseconds m_resetTimeout
 
bool m_syncActivation
 
bool m_syncDeactivation
 
bool m_syncReset
 

Detailed Description

A base class for ExecutionContext.

A base class of ExecutionContext.

Since
0.4.0

Constructor & Destructor Documentation

◆ ExecutionContextBase()

RTC::ExecutionContextBase::ExecutionContextBase ( const char * name)
explicit

Constructor.

Constructor

◆ ~ExecutionContextBase()

virtual RTC::ExecutionContextBase::~ExecutionContextBase ( )
virtual

Virtual Destructor.

Virtual Destructor

Member Function Documentation

◆ activateComponent()

RTC::ReturnCode_t RTC::ExecutionContextBase::activateComponent ( RTC::LightweightRTObject_ptr comp)

Activate an RT-component.

The given participant RTC is Inactive and is therefore not being invoked according to the execution context’s execution kind. This operation shall cause the RTC to transition to the Active state such that it may subsequently be invoked in this execution context. The callback on_activate shall be called as a result of calling this operation. This operation shall not return until the callback has returned, and shall result in an error if the callback does.

Parameters
compThe target RT-Component for activation
Returns
The return code of ReturnCode_t type

◆ addComponent()

RTC::ReturnCode_t RTC::ExecutionContextBase::addComponent ( RTC::LightweightRTObject_ptr comp)

Add an RT-component.

The operation causes the given RTC to begin participating in the execution context. The newly added RTC will receive a call to LightweightRTComponent::attach_context and then enter the Inactive state. BAD_PARAMETER will be invoked, if the given RT-Component is null or if the given RT-Component is other than DataFlowComponent.

Parameters
compThe target RT-Component for add
Returns
The return code of ReturnCode_t type

◆ bindComponent()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::bindComponent ( RTC::RTObject_impl * rtc)
virtual

Bind the component.

Bind the component.

Reimplemented in RTC_exp::MultilayerCompositeEC.

◆ deactivateComponent()

RTC::ReturnCode_t RTC::ExecutionContextBase::deactivateComponent ( RTC::LightweightRTObject_ptr comp)

Deactivate an RT-component.

The given RTC is Active in the execution context. Cause it to transition to the Inactive state such that it will not be subsequently invoked from the context unless and until it is activated again. The callback on_deactivate shall be called as a result of calling this operation. This operation shall not return until the callback has returned, and shall result in an error if the callback does.

Parameters
compThe target RT-Component for deactivate
Returns
The return code of ReturnCode_t type

◆ getComponentList()

const RTC::RTCList & RTC::ExecutionContextBase::getComponentList ( ) const

Getting participant RTC list.

This function returns a list of participant RTC of the execution context.

Returns
Participants RTC list

◆ getComponentState()

RTC::LifeCycleState RTC::ExecutionContextBase::getComponentState ( RTC::LightweightRTObject_ptr comp)

Get RT-component's state.

This operation shall report the LifeCycleState of the given participant RTC. UNKNOWN_STATE will be returned, if the given RT-Component is not inclued in the participant list.

Parameters
compThe target RT-Component to get the state
Returns
The current state of the target RT-Component(LifeCycleState)

◆ getKind()

RTC::ExecutionKind RTC::ExecutionContextBase::getKind ( ) const

Get the ExecutionKind.

This operation shall report the execution kind of the execution context.

Returns
ExecutionKind

◆ getKindString()

static const char * RTC::ExecutionContextBase::getKindString ( RTC::ExecutionKind kind)
static

Converting ExecutionKind enum to string.

This function converts enumeration (PERIODIC, EVENT_DRIVEN, OTHER) defined in RTC::ExecutionKind to string.

Parameters
kindExecutionKind
Returns
String of ExecutionKind

◆ getObjRef()

RTC::ExecutionContextService_ptr RTC::ExecutionContextBase::getObjRef ( ) const

Get the reference to the CORBA object as ExecutioncontextService of this object.

Returns
The reference to CORBA object

◆ getOwner()

RTC::RTObject_ptr RTC::ExecutionContextBase::getOwner ( ) const

Getting a reference of the owner component.

This function returns a reference of the owner RT-Component of this execution context

Returns
a reference of the owner RT-Component

◆ getPeriod()

std::chrono::nanoseconds RTC::ExecutionContextBase::getPeriod ( ) const

◆ getProfile() [1/2]

RTC::ExecutionContextProfile * RTC::ExecutionContextBase::getProfile ( )

Getting Profile.

This function gets RTC::ExecutionContextProfile. The ownership of the obtained ExecutionContextProfile is given to caller. The caller should release obtained object when it is unneccessary anymore.

Returns
RTC::ExecutionContextProfile

◆ getProfile() [2/2]

const RTC::ExecutionContextProfile & RTC::ExecutionContextBase::getProfile ( ) const

Getting Profile.

This function gets RTC::ExecutionContextProfile.

Returns
RTC::ExecutionContextProfile

◆ getProperties()

coil::Properties RTC::ExecutionContextBase::getProperties ( ) const

Setting Properties.

This function sets ExecutionContextProfile::properties by coil::Properties.

Parameters
propsProperties to be set to ExecutionContextProfile::properties.

◆ getRate()

double RTC::ExecutionContextBase::getRate ( ) const

Get execution rate(Hz) of ExecutionContext.

This operation shall return the rate (in hertz) at which its Active participating RTCs are being invoked.

Returns
Execution cycle(Unit:Hz)

◆ getStateString()

static const char * RTC::ExecutionContextBase::getStateString ( RTC::LifeCycleState state)
static

◆ init()

virtual void RTC::ExecutionContextBase::init ( coil::Properties & props)
virtual

Initialize the ExecutionContext.

This operation initialize the ExecutionContext

Reimplemented in RTC::VxWorksInterruptExecutionContext, RTC_exp::MultilayerCompositeEC, RTC_exp::PeriodicExecutionContext, and RTC_exp::VxWorksRTExecutionContext.

◆ invokeWorker()

void RTC::ExecutionContextBase::invokeWorker ( )
inline

◆ invokeWorkerDo()

void RTC::ExecutionContextBase::invokeWorkerDo ( )
inline

◆ invokeWorkerPostDo()

void RTC::ExecutionContextBase::invokeWorkerPostDo ( )
inline

◆ invokeWorkerPreDo()

void RTC::ExecutionContextBase::invokeWorkerPreDo ( )
inline

◆ isAllCurrentState()

bool RTC::ExecutionContextBase::isAllCurrentState ( RTC::LifeCycleState state)
inline

◆ isAllNextState()

bool RTC::ExecutionContextBase::isAllNextState ( RTC::LifeCycleState state)
inline

◆ isOneOfCurrentState()

bool RTC::ExecutionContextBase::isOneOfCurrentState ( RTC::LifeCycleState state)
inline

◆ isOneOfNextState()

bool RTC::ExecutionContextBase::isOneOfNextState ( RTC::LifeCycleState state)
inline

◆ isRunning()

CORBA::Boolean RTC::ExecutionContextBase::isRunning ( )

Check for ExecutionContext running state.

This operation shall return true if the context is in the Running state. After calling the start() of this class, this function returns true, after calling to stop function of it, this function returns false.

Returns
Working status (Running:true、Stopped:false)

◆ onActivated()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onActivated ( RTC_impl::RTObjectStateMachine * ,
long int  )
inlineprotectedvirtual

◆ onActivating()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onActivating ( RTC::LightweightRTObject_ptr )
inlineprotectedvirtual

◆ onAddedComponent()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onAddedComponent ( RTC::LightweightRTObject_ptr )
inlineprotectedvirtual

◆ onAddingComponent()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onAddingComponent ( RTC::LightweightRTObject_ptr )
inlineprotectedvirtual

◆ onDeactivated()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onDeactivated ( RTC_impl::RTObjectStateMachine * ,
long int  )
inlineprotectedvirtual

◆ onDeactivating()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onDeactivating ( RTC::LightweightRTObject_ptr )
inlineprotectedvirtual

◆ onGetComponentState()

virtual RTC::LifeCycleState RTC::ExecutionContextBase::onGetComponentState ( RTC::LifeCycleState state)
inlineprotectedvirtual

◆ onGetKind()

virtual RTC::ExecutionKind RTC::ExecutionContextBase::onGetKind ( RTC::ExecutionKind kind) const
inlineprotectedvirtual

◆ onGetProfile()

virtual RTC::ExecutionContextProfile * RTC::ExecutionContextBase::onGetProfile ( RTC::ExecutionContextProfile *& profile)
inlineprotectedvirtual

◆ onGetRate()

virtual double RTC::ExecutionContextBase::onGetRate ( double rate) const
inlineprotectedvirtual

◆ onIsRunning()

virtual bool RTC::ExecutionContextBase::onIsRunning ( bool running)
inlineprotectedvirtual

◆ onRemovedComponent()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onRemovedComponent ( RTC::LightweightRTObject_ptr )
inlineprotectedvirtual

◆ onRemovingComponent()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onRemovingComponent ( RTC::LightweightRTObject_ptr )
inlineprotectedvirtual

◆ onReset()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onReset ( RTC_impl::RTObjectStateMachine * ,
long int  )
inlineprotectedvirtual

◆ onResetting()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onResetting ( RTC::LightweightRTObject_ptr )
inlineprotectedvirtual

◆ onSetRate()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onSetRate ( double )
inlineprotectedvirtual

◆ onSettingRate()

virtual double RTC::ExecutionContextBase::onSettingRate ( double rate)
inlineprotectedvirtual

◆ onStarted()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStarted ( )
inlineprotectedvirtual

◆ onStarting()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStarting ( )
inlineprotectedvirtual

◆ onStopped()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStopped ( )
inlineprotectedvirtual

◆ onStopping()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onStopping ( )
inlineprotectedvirtual

◆ onWaitingActivated()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onWaitingActivated ( RTC_impl::RTObjectStateMachine * ,
long int  )
inlineprotectedvirtual

◆ onWaitingDeactivated()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onWaitingDeactivated ( RTC_impl::RTObjectStateMachine * ,
long int  )
inlineprotectedvirtual

◆ onWaitingReset()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::onWaitingReset ( RTC_impl::RTObjectStateMachine * ,
long int  )
inlineprotectedvirtual

◆ removeComponent()

RTC::ReturnCode_t RTC::ExecutionContextBase::removeComponent ( RTC::LightweightRTObject_ptr comp)

Remove the RT-Component from participant list.

This operation causes a participant RTC to stop participating in the execution context. The removed RTC will receive a call to LightweightRTComponent::detach_context. BAD_PARAMETER will be returned, if the given RT-Component is not participating in the participant list.

Parameters
compThe target RT-Component for delete
Returns
The return code of ReturnCode_t type

◆ resetComponent()

RTC::ReturnCode_t RTC::ExecutionContextBase::resetComponent ( RTC::LightweightRTObject_ptr comp)

Reset the RT-component.

Attempt to recover the RTC when it is in Error. The ComponentAction::on_reset callback shall be invoked. This operation shall not return until the callback has returned, and shall result in an error if the callback does. If possible, the RTC developer should implement that callback such that the RTC may be returned to a valid state.

Parameters
compThe target RT-Component for reset
Returns
The return code of ReturnCode_t type

◆ setKind()

RTC::ReturnCode_t RTC::ExecutionContextBase::setKind ( RTC::ExecutionKind kind)

Set the ExecutionKind.

This operation sets the kind of the execution context.

Parameters
kindExecutionKind

◆ setObjRef()

void RTC::ExecutionContextBase::setObjRef ( RTC::ExecutionContextService_ptr ec_ptr)

Get the reference to the CORBA object.

Get the reference to the CORBA object as ExecutioncontextService of this object.

Returns
The reference to CORBA object

◆ setOwner()

RTC::ReturnCode_t RTC::ExecutionContextBase::setOwner ( RTC::LightweightRTObject_ptr comp)

Setting owner component of the execution context.

This function sets an RT-Component to be owner of the execution context.

Parameters
compan owner RT-Component of this execution context
Returns
The return code of ReturnCode_t type

◆ setProperties()

void RTC::ExecutionContextBase::setProperties ( coil::Properties & props)

Setting Properties.

This function sets ExecutionContextProfile::properties by coil::Properties.

Parameters
propsProperties to be set to ExecutionContextProfile::properties.

◆ setRate()

RTC::ReturnCode_t RTC::ExecutionContextBase::setRate ( double rate)

Set execution rate(Hz) of ExecutionContext.

This operation shall set the rate (in hertz) at which this context’s Active participating RTCs are being called. If the execution kind of the context is PERIODIC, a rate change shall result in the invocation of on_rate_changed on any RTCs realizing DataFlowComponentAction that are registered with any RTCs participating in the context.

Parameters
rateExecution cycle(Unit:Hz)
Returns
The return code of ReturnCode_t type RTC_OK: Succeed BAD_PARAMETER: Invalid value. The value might be negative.

◆ start()

RTC::ReturnCode_t RTC::ExecutionContextBase::start ( )

Start the ExecutionContext.

Request that the context enter the Running state. Once the state transition occurs, the ComponentAction::on_startup operation will be invoked. An execution context may not be started until the RT-Components that participate in it have been initialized. An execution context may be started and stopped multiple times.

Returns
The return code of ReturnCode_t type

◆ stop()

virtual RTC::ReturnCode_t RTC::ExecutionContextBase::stop ( )
virtual

Stop the ExecutionContext.

Request that the context enter the Stopped state. Once the transition occurs, the ComponentAction::on_shutdown operation will be invoked. An execution context must be stopped before the RT components that participate in it are finalized. An execution context may be started and stopped multiple times.

Returns
The return code of ReturnCode_t type

Reimplemented in RTC::ExtTrigExecutionContext, RTC::OpenHRPExecutionContext, RTC::VxWorksInterruptExecutionContext, and RTC_exp::PeriodicExecutionContext.

Member Data Documentation

◆ m_activationTimeout

std::chrono::nanoseconds RTC::ExecutionContextBase::m_activationTimeout
protected

◆ m_deactivationTimeout

std::chrono::nanoseconds RTC::ExecutionContextBase::m_deactivationTimeout
protected

◆ m_profile

RTC_impl::ExecutionContextProfile RTC::ExecutionContextBase::m_profile
protected

◆ m_resetTimeout

std::chrono::nanoseconds RTC::ExecutionContextBase::m_resetTimeout
protected

◆ m_syncActivation

bool RTC::ExecutionContextBase::m_syncActivation
protected

◆ m_syncDeactivation

bool RTC::ExecutionContextBase::m_syncDeactivation
protected

◆ m_syncReset

bool RTC::ExecutionContextBase::m_syncReset
protected

◆ m_worker

◆ rtclog

RTC::Logger RTC::ExecutionContextBase::rtclog
mutableprotected

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