OpenRTM-aist  1.2.1
Public Member Functions | Protected Types | Protected Attributes | List of all members
RTC_impl::ExecutionContextWorker Class Reference

ExecutionContextWorker class. More...

#include <ExecutionContextWorker.h>

Collaboration diagram for RTC_impl::ExecutionContextWorker:
Collaboration graph
[legend]

Public Member Functions

 ExecutionContextWorker ()
 Default Constructor. More...
 
virtual ~ExecutionContextWorker (void)
 Destructor. More...
 
void setECRef (RTC::ExecutionContextService_ptr ref)
 
RTC::ExecutionContextService_ptr getECRef ()
 
CORBA::Boolean isRunning (void)
 Check for ExecutionContext running state. More...
 
RTC::ReturnCode_t start (void)
 Start the ExecutionContext. More...
 
RTC::ReturnCode_t stop (void)
 Stop the ExecutionContext. More...
 
RTC::ReturnCode_t startThread (void)
 
RTC::ReturnCode_t stopThread (void)
 
RTC::ReturnCode_t rateChanged ()
 Execution rate of ExecutionContext chnaged. More...
 
RTC::ReturnCode_t activateComponent (RTC::LightweightRTObject_ptr comp, RTObjectStateMachine *&rtobj)
 Activate an RT-component. More...
 
RTC::ReturnCode_t waitActivateComplete (RTObjectStateMachine *&rtobj, coil::TimeValue timeout=1.0, long int cycle=1000)
 
RTC::ReturnCode_t deactivateComponent (RTC::LightweightRTObject_ptr comp, RTObjectStateMachine *&rtobj)
 Deactivate an RT-component. More...
 
RTC::ReturnCode_t waitDeactivateComplete (RTObjectStateMachine *&rtobj, coil::TimeValue timeout=1.0, long int cycle=1000)
 
RTC::ReturnCode_t resetComponent (RTC::LightweightRTObject_ptr com, RTObjectStateMachine *&rtobj)
 Reset the RT-component. More...
 
RTC::ReturnCode_t waitResetComplete (RTObjectStateMachine *&rtobj, coil::TimeValue timeout=1.0, long int cycle=1000)
 
RTC::LifeCycleState getComponentState (RTC::LightweightRTObject_ptr comp)
 Get RT-component's state. More...
 
const char * getStateString (RTC::LifeCycleState state)
 
RTC::ReturnCode_t addComponent (RTC::LightweightRTObject_ptr comp)
 Add an RT-component. More...
 
RTC::ReturnCode_t bindComponent (RTC::RTObject_impl *rtc)
 Bind the component. More...
 
RTC::ReturnCode_t removeComponent (RTC::LightweightRTObject_ptr comp)
 Remove the RT-Component from participant list. More...
 
RTObjectStateMachinefindComponent (RTC::LightweightRTObject_ptr comp)
 
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 ()
 
void updateComponentList ()
 Updating component list. More...
 

Protected Types

typedef std::vector< RTC_impl::RTObjectStateMachine * >::iterator CompItr
 

Protected Attributes

RTC::Logger rtclog
 Logger stream. More...
 
RTC::ExecutionContextService_var m_ref
 
bool m_running
 The running state of ExecutionContext true: running, false: stopped. More...
 
std::vector< RTC_impl::RTObjectStateMachine * > m_comps
 List of the participating component. More...
 
coil::Mutex m_mutex
 
std::vector< RTC_impl::RTObjectStateMachine * > m_addedComps
 
coil::Mutex m_addedMutex
 
std::vector< RTC_impl::RTObjectStateMachine * > m_removedComps
 
coil::Mutex m_removedMutex
 

Detailed Description

ExecutionContextWorker class.

Periodic Sampled Data Processing (for the execution cycles) ExecutionContext class

Since
0.4.0

Member Typedef Documentation

Constructor & Destructor Documentation

RTC_impl::ExecutionContextWorker::ExecutionContextWorker ( )

Default Constructor.

Default Constructor Set the following items to profile.

  • kind : PERIODIC
  • rate : 0.0
virtual RTC_impl::ExecutionContextWorker::~ExecutionContextWorker ( void  )
virtual

Destructor.

Destructor

Member Function Documentation

RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::activateComponent ( RTC::LightweightRTObject_ptr  comp,
RTObjectStateMachine *&  rtobj 
)

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
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::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.

When right after this operation is called, since other RTCs might being called their callbacks of the StateMachine, at first the RTC is added into the "Participants: m_addedComps." After RTCs callbacks are called, updateComponentList() function is invoked and RTCs are officially a member of the worker.

Parameters
compThe target RT-Component for add
Returns
The return code of ReturnCode_t type
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::bindComponent ( RTC::RTObject_impl rtc)

Bind the component.

This operation bind a RT-Component into owned context. Given argument RTObject_impl is the owner of the EC, and internally RTObject's bindContext() member function is called and obtain ec_id. The ec_id must be smaller than ECOTHER_OFFSET. After that proxy of RTObject RTObjectStateMachine is created, and it is added to the component list.

Parameters
rtcRT-Component's instances
Returns
The return code of ReturnCode_t type
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::deactivateComponent ( RTC::LightweightRTObject_ptr  comp,
RTObjectStateMachine *&  rtobj 
)

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
RTObjectStateMachine* RTC_impl::ExecutionContextWorker::findComponent ( RTC::LightweightRTObject_ptr  comp)
RTC::LifeCycleState RTC_impl::ExecutionContextWorker::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)
RTC::ExecutionContextService_ptr RTC_impl::ExecutionContextWorker::getECRef ( )
const char* RTC_impl::ExecutionContextWorker::getStateString ( RTC::LifeCycleState  state)
inline
void RTC_impl::ExecutionContextWorker::invokeWorker ( )
void RTC_impl::ExecutionContextWorker::invokeWorkerDo ( )
void RTC_impl::ExecutionContextWorker::invokeWorkerPostDo ( )
void RTC_impl::ExecutionContextWorker::invokeWorkerPreDo ( )
bool RTC_impl::ExecutionContextWorker::isAllCurrentState ( RTC::LifeCycleState  state)
bool RTC_impl::ExecutionContextWorker::isAllNextState ( RTC::LifeCycleState  state)
bool RTC_impl::ExecutionContextWorker::isOneOfCurrentState ( RTC::LifeCycleState  state)
bool RTC_impl::ExecutionContextWorker::isOneOfNextState ( RTC::LifeCycleState  state)
CORBA::Boolean RTC_impl::ExecutionContextWorker::isRunning ( void  )

Check for ExecutionContext running state.

This operation shall return true if the context is in the Running state. While the context is Running, all Active RTCs participating in the context shall be executed according to the context’s execution kind.

Returns
Check state function (Running:true、Stopping:false)
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::rateChanged ( )

Execution rate of ExecutionContext chnaged.

A call back for execution rate chang when ExecutionContext's execution rate. If set_rate() operation is called, ExecutionContextProfile::setRate() will be called, execution rate in the profile will be updated, and RTObjectStateMachine::onRateChagned() will be called with this member function.

Returns
The return code of ReturnCode_t type
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::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
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::resetComponent ( RTC::LightweightRTObject_ptr  com,
RTObjectStateMachine *&  rtobj 
)

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
void RTC_impl::ExecutionContextWorker::setECRef ( RTC::ExecutionContextService_ptr  ref)
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::start ( void  )

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
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::startThread ( void  )
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::stop ( void  )

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
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::stopThread ( void  )
void RTC_impl::ExecutionContextWorker::updateComponentList ( )

Updating component list.

RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::waitActivateComplete ( RTObjectStateMachine *&  rtobj,
coil::TimeValue  timeout = 1.0,
long int  cycle = 1000 
)
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::waitDeactivateComplete ( RTObjectStateMachine *&  rtobj,
coil::TimeValue  timeout = 1.0,
long int  cycle = 1000 
)
RTC::ReturnCode_t RTC_impl::ExecutionContextWorker::waitResetComplete ( RTObjectStateMachine *&  rtobj,
coil::TimeValue  timeout = 1.0,
long int  cycle = 1000 
)

Member Data Documentation

std::vector<RTC_impl::RTObjectStateMachine*> RTC_impl::ExecutionContextWorker::m_addedComps
protected
coil::Mutex RTC_impl::ExecutionContextWorker::m_addedMutex
mutableprotected
std::vector<RTC_impl::RTObjectStateMachine*> RTC_impl::ExecutionContextWorker::m_comps
protected

List of the participating component.

coil::Mutex RTC_impl::ExecutionContextWorker::m_mutex
mutableprotected
RTC::ExecutionContextService_var RTC_impl::ExecutionContextWorker::m_ref
protected
std::vector<RTC_impl::RTObjectStateMachine*> RTC_impl::ExecutionContextWorker::m_removedComps
protected
coil::Mutex RTC_impl::ExecutionContextWorker::m_removedMutex
mutableprotected
bool RTC_impl::ExecutionContextWorker::m_running
protected

The running state of ExecutionContext true: running, false: stopped.

RTC::Logger RTC_impl::ExecutionContextWorker::rtclog
protected

Logger stream.


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