OpenRTM-aist  1.2.1
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RTC_exp::PeriodicExecutionContext Class Reference

PeriodicExecutionContext class. More...

#include <PeriodicExecutionContext.h>

Inheritance diagram for RTC_exp::PeriodicExecutionContext:
Inheritance graph
[legend]
Collaboration diagram for RTC_exp::PeriodicExecutionContext:
Collaboration graph
[legend]

Classes

struct  WorkerThreadCtrl
 Condition variable class for worker. More...
 

Public Member Functions

 PeriodicExecutionContext ()
 Default Constructor. More...
 
virtual ~PeriodicExecutionContext (void)
 Destructor. More...
 
virtual void init (coil::Properties &props)
 Initialize the ExecutionContext. More...
 
virtual int open (void *args)
 Generate internal activity thread for ExecutionContext. More...
 
virtual int svc (void)
 Thread execution function for ExecutionContext. More...
 
virtual int close (unsigned long flags)
 Thread execution function for ExecutionContext. More...
 
virtual CORBA::Boolean is_running (void) throw (CORBA::SystemException)
 Check for ExecutionContext running state. More...
 
virtual RTC::ReturnCode_t start (void) throw (CORBA::SystemException)
 Start the ExecutionContext. More...
 
virtual RTC::ReturnCode_t stop (void) throw (CORBA::SystemException)
 Stop the ExecutionContext. More...
 
virtual CORBA::Double get_rate (void) throw (CORBA::SystemException)
 Get execution rate(Hz) of ExecutionContext. More...
 
virtual RTC::ReturnCode_t set_rate (CORBA::Double rate) throw (CORBA::SystemException)
 Set execution rate(Hz) of ExecutionContext. More...
 
virtual RTC::ReturnCode_t activate_component (RTC::LightweightRTObject_ptr comp) throw (CORBA::SystemException)
 Activate an RT-component. More...
 
virtual RTC::ReturnCode_t deactivate_component (RTC::LightweightRTObject_ptr comp) throw (CORBA::SystemException)
 Deactivate an RT-component. More...
 
virtual RTC::ReturnCode_t reset_component (RTC::LightweightRTObject_ptr comp) throw (CORBA::SystemException)
 Reset the RT-component. More...
 
virtual RTC::LifeCycleState get_component_state (RTC::LightweightRTObject_ptr comp) throw (CORBA::SystemException)
 Get RT-component's state. More...
 
virtual RTC::ExecutionKind get_kind (void) throw (CORBA::SystemException)
 Get the ExecutionKind. More...
 
virtual RTC::ReturnCode_t add_component (RTC::LightweightRTObject_ptr comp) throw (CORBA::SystemException)
 Add an RT-component. More...
 
virtual RTC::ReturnCode_t remove_component (RTC::LightweightRTObject_ptr comp) throw (CORBA::SystemException)
 Remove the RT-Component from participant list. More...
 
virtual RTC::ExecutionContextProfile * get_profile (void) throw (CORBA::SystemException)
 Get the ExecutionContextProfile. More...
 
- Public Member Functions inherited from RTC::ExecutionContextBase
 ExecutionContextBase (const char *name)
 Virtual Destructor. More...
 
virtual ~ExecutionContextBase (void)
 Virtual Destructor. More...
 
virtual RTC::ReturnCode_t bindComponent (RTC::RTObject_impl *rtc)
 Bind the component. More...
 
CORBA::Boolean isRunning ()
 Check for ExecutionContext running state. More...
 
RTC::ReturnCode_t start (void)
 Start the ExecutionContext. More...
 
double getRate (void) const
 Get execution rate(Hz) of ExecutionContext. More...
 
coil::TimeValue getPeriod (void) const
 
RTC::ReturnCode_t setRate (double rate)
 Set execution rate(Hz) of ExecutionContext. More...
 
RTC::ReturnCode_t addComponent (RTC::LightweightRTObject_ptr comp)
 Add an RT-component. More...
 
RTC::ReturnCode_t removeComponent (RTC::LightweightRTObject_ptr comp)
 Remove the RT-Component from participant list. More...
 
RTC::ReturnCode_t activateComponent (RTC::LightweightRTObject_ptr comp)
 Activate an RT-component. More...
 
RTC::ReturnCode_t deactivateComponent (RTC::LightweightRTObject_ptr comp)
 Deactivate an RT-component. More...
 
RTC::ReturnCode_t resetComponent (RTC::LightweightRTObject_ptr comp)
 Reset the RT-component. More...
 
RTC::LifeCycleState getComponentState (RTC::LightweightRTObject_ptr comp)
 Get RT-component's state. More...
 
const char * getStateString (RTC::LifeCycleState state)
 
RTC::ExecutionKind getKind (void) const
 Get the ExecutionKind. More...
 
RTC::ExecutionContextProfile * getProfile (void)
 Getting Profile. More...
 
void setObjRef (RTC::ExecutionContextService_ptr ec_ptr)
 Get the reference to the CORBA object. More...
 
RTC::ExecutionContextService_ptr getObjRef (void) const
 
const char * getKindString (RTC::ExecutionKind kind) const
 Converting ExecutionKind enum to string. More...
 
RTC::ReturnCode_t setKind (RTC::ExecutionKind kind)
 Set the ExecutionKind. More...
 
RTC::ReturnCode_t setOwner (RTC::LightweightRTObject_ptr comp)
 Setting owner component of the execution context. More...
 
const RTC::RTObject_ptr getOwner () const
 Getting a reference of the owner component. More...
 
const RTC::RTCList & getComponentList () const
 Getting participant RTC list. More...
 
void setProperties (coil::Properties &props)
 Setting Properties. More...
 
const coil::Properties getProperties () const
 Setting Properties. More...
 
const RTC::ExecutionContextProfile & getProfile (void) const
 Getting Profile. More...
 
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 ()
 
- Public Member Functions inherited from coil::Task
 Task ()
 Constructor. More...
 
virtual ~Task ()
 Destructor. More...
 
virtual void activate ()
 Create a thread. More...
 
virtual int wait (void)
 Waiting for the thread terminate. More...
 
virtual int suspend (void)
 Suspending the task. More...
 
virtual int resume (void)
 Resuming the suspended task. More...
 
virtual void reset ()
 Reset of task count. More...
 
virtual void finalize ()
 Finalizing the task. More...
 

Protected Member Functions

template<class T >
void getProperty (coil::Properties &prop, const char *key, T &value)
 
virtual RTC::ReturnCode_t onStarted ()
 onStarted() template function More...
 
virtual RTC::ReturnCode_t onStopping ()
 onStopping() template function More...
 
virtual RTC::ReturnCode_t onAddedComponent (RTC::LightweightRTObject_ptr rtobj)
 onAddedComponent() template function More...
 
virtual RTC::ReturnCode_t onRemovedComponent (RTC::LightweightRTObject_ptr rtobj)
 onRemovedComponent() template function More...
 
virtual RTC::ReturnCode_t onWaitingActivated (RTC_impl::RTObjectStateMachine *comp, long int count)
 onWaitingActivated() template function More...
 
virtual RTC::ReturnCode_t onActivated (RTC_impl::RTObjectStateMachine *comp, long int count)
 onActivated() template function More...
 
virtual RTC::ReturnCode_t onWaitingDeactivated (RTC_impl::RTObjectStateMachine *comp, long int count)
 onWaitingDeactivated() template function More...
 
virtual RTC::ReturnCode_t onDeactivated (RTC_impl::RTObjectStateMachine *comp, long int count)
 onDeactivated() template function More...
 
virtual RTC::ReturnCode_t onWaitingReset (RTC_impl::RTObjectStateMachine *comp, long int count)
 onWaitingReset() template function More...
 
virtual RTC::ReturnCode_t onReset (RTC_impl::RTObjectStateMachine *comp, long int count)
 onReset() template function More...
 
virtual void setCpuAffinity (coil::Properties &props)
 setting CPU affinity from given properties More...
 
bool threadRunning ()
 
- Protected Member Functions inherited from RTC::ExecutionContextBase
virtual bool onIsRunning (bool running)
 
virtual RTC::ReturnCode_t onStarting ()
 
virtual RTC::ReturnCode_t onStopped ()
 
virtual double onGetRate (double rate) const
 
virtual double onSettingRate (double rate)
 
virtual RTC::ReturnCode_t onSetRate (double rate)
 
virtual RTC::ReturnCode_t onAddingComponent (RTC::LightweightRTObject_ptr rtobj)
 
virtual RTC::ReturnCode_t onRemovingComponent (RTC::LightweightRTObject_ptr rtobj)
 
virtual RTC::ReturnCode_t onActivating (RTC::LightweightRTObject_ptr comp)
 
virtual RTC::ReturnCode_t onDeactivating (RTC::LightweightRTObject_ptr comp)
 
virtual RTC::ReturnCode_t onResetting (RTC::LightweightRTObject_ptr comp)
 
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
 Logger stream. More...
 
bool m_svc
 The thread running flag of ExecutionContext. More...
 
coil::Mutex m_svcmutex
 
WorkerThreadCtrl m_workerthread
 A condition variable for external triggered worker. More...
 
bool m_nowait
 Flag of ExecutionContext to run immediately (to run without waiting) More...
 
coil::CpuMask m_cpu
 CPU affinity mask list. More...
 
- Protected Attributes inherited from RTC::ExecutionContextBase
RTC::Logger rtclog
 
RTC_impl::ExecutionContextWorker m_worker
 
RTC_impl::ExecutionContextProfile m_profile
 
coil::TimeValue m_activationTimeout
 
coil::TimeValue m_deactivationTimeout
 
coil::TimeValue m_resetTimeout
 
bool m_syncActivation
 
bool m_syncDeactivation
 
bool m_syncReset
 

Additional Inherited Members

- Static Public Member Functions inherited from coil::Task
static void * svc_run (void *args=0)
 Start thread Execution. More...
 

Detailed Description

PeriodicExecutionContext class.

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

Since
0.4.0

Constructor & Destructor Documentation

RTC_exp::PeriodicExecutionContext::PeriodicExecutionContext ( )

Default Constructor.

Default Constructor Set the following items to profile.

  • kind : PERIODIC
  • rate : 0.0
virtual RTC_exp::PeriodicExecutionContext::~PeriodicExecutionContext ( void  )
virtual

Destructor.

Destructor

Member Function Documentation

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::activate_component ( RTC::LightweightRTObject_ptr  comp)
throw (CORBA::SystemException
)
virtual

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
virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::add_component ( RTC::LightweightRTObject_ptr  comp)
throw (CORBA::SystemException
)
virtual

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
virtual int RTC_exp::PeriodicExecutionContext::close ( unsigned long  flags)
virtual

Thread execution function for ExecutionContext.

This function is invoked when activity thread for ExecutionContext exits. Deactivate the component object and notify it to manager. This is coil::Task class method's override.

Parameters
flagsFlag of the close
Returns
The close result

Reimplemented from coil::Task.

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::deactivate_component ( RTC::LightweightRTObject_ptr  comp)
throw (CORBA::SystemException
)
virtual

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
virtual RTC::LifeCycleState RTC_exp::PeriodicExecutionContext::get_component_state ( RTC::LightweightRTObject_ptr  comp)
throw (CORBA::SystemException
)
virtual

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)
virtual RTC::ExecutionKind RTC_exp::PeriodicExecutionContext::get_kind ( void  )
throw (CORBA::SystemException
)
virtual

Get the ExecutionKind.

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

Returns
ExecutionKind
virtual RTC::ExecutionContextProfile* RTC_exp::PeriodicExecutionContext::get_profile ( void  )
throw (CORBA::SystemException
)
virtual

Get the ExecutionContextProfile.

This operation provides a profile “descriptor” for the execution context.

Returns
ExecutionContextProfile
virtual CORBA::Double RTC_exp::PeriodicExecutionContext::get_rate ( void  )
throw (CORBA::SystemException
)
virtual

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)
template<class T >
void RTC_exp::PeriodicExecutionContext::getProperty ( coil::Properties prop,
const char *  key,
T &  value 
)
inlineprotected
virtual void RTC_exp::PeriodicExecutionContext::init ( coil::Properties props)
virtual

Initialize the ExecutionContext.

This operation initialize the ExecutionContext

Reimplemented from RTC::ExecutionContextBase.

virtual CORBA::Boolean RTC_exp::PeriodicExecutionContext::is_running ( void  )
throw (CORBA::SystemException
)
virtual

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)
virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onActivated ( RTC_impl::RTObjectStateMachine comp,
long int  count 
)
protectedvirtual

onActivated() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onAddedComponent ( RTC::LightweightRTObject_ptr  rtobj)
protectedvirtual

onAddedComponent() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onDeactivated ( RTC_impl::RTObjectStateMachine comp,
long int  count 
)
protectedvirtual

onDeactivated() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onRemovedComponent ( RTC::LightweightRTObject_ptr  rtobj)
protectedvirtual

onRemovedComponent() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onReset ( RTC_impl::RTObjectStateMachine comp,
long int  count 
)
protectedvirtual

onReset() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onStarted ( )
protectedvirtual

onStarted() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onStopping ( )
protectedvirtual

onStopping() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onWaitingActivated ( RTC_impl::RTObjectStateMachine comp,
long int  count 
)
protectedvirtual

onWaitingActivated() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onWaitingDeactivated ( RTC_impl::RTObjectStateMachine comp,
long int  count 
)
protectedvirtual

onWaitingDeactivated() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::onWaitingReset ( RTC_impl::RTObjectStateMachine comp,
long int  count 
)
protectedvirtual

onWaitingReset() template function

Reimplemented from RTC::ExecutionContextBase.

Referenced by getProperty().

virtual int RTC_exp::PeriodicExecutionContext::open ( void *  args)
virtual

Generate internal activity thread for ExecutionContext.

Generate internal activity thread and run. This is coil::Task class method's override.

Parameters
argsUsually give 0
Returns
The generation result

Reimplemented from coil::Task.

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::remove_component ( RTC::LightweightRTObject_ptr  comp)
throw (CORBA::SystemException
)
virtual

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
virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::reset_component ( RTC::LightweightRTObject_ptr  comp)
throw (CORBA::SystemException
)
virtual

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
virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::set_rate ( CORBA::Double  rate)
throw (CORBA::SystemException
)
virtual

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
virtual void RTC_exp::PeriodicExecutionContext::setCpuAffinity ( coil::Properties props)
protectedvirtual

setting CPU affinity from given properties

Referenced by getProperty().

virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::start ( void  )
throw (CORBA::SystemException
)
virtual

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
virtual RTC::ReturnCode_t RTC_exp::PeriodicExecutionContext::stop ( void  )
throw (CORBA::SystemException
)
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 from RTC::ExecutionContextBase.

virtual int RTC_exp::PeriodicExecutionContext::svc ( void  )
virtual

Thread execution function for ExecutionContext.

Thread execution function for ExecutionContext. Invoke the registered components operation.

Returns
The execution result

Reimplemented from coil::Task.

bool RTC_exp::PeriodicExecutionContext::threadRunning ( )
inlineprotected

References m_svc, and m_svcmutex.

Member Data Documentation

coil::CpuMask RTC_exp::PeriodicExecutionContext::m_cpu
protected

CPU affinity mask list.

bool RTC_exp::PeriodicExecutionContext::m_nowait
protected

Flag of ExecutionContext to run immediately (to run without waiting)

bool RTC_exp::PeriodicExecutionContext::m_svc
protected

The thread running flag of ExecutionContext.

Referenced by threadRunning().

coil::Mutex RTC_exp::PeriodicExecutionContext::m_svcmutex
protected

Referenced by threadRunning().

WorkerThreadCtrl RTC_exp::PeriodicExecutionContext::m_workerthread
protected

A condition variable for external triggered worker.

RTC::Logger RTC_exp::PeriodicExecutionContext::rtclog
protected

Logger stream.


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