20 #ifndef RTC_PERIODICEXECUTIONCONTEXT_H 21 #define RTC_PERIODICEXECUTIONCONTEXT_H 23 #include <coil/Task.h> 24 #include <coil/Mutex.h> 25 #include <coil/Condition.h> 30 #include <rtm/idl/RTCSkel.h> 31 #include <rtm/idl/OpenRTMSkel.h> 36 #define NUM_OF_LIFECYCLESTATE 4 39 #pragma warning( disable : 4290 ) 113 double rate = 1000.0);
175 virtual int open(
void *args);
196 virtual int svc(
void);
225 virtual int close(
unsigned long flags);
255 throw (CORBA::SystemException);
285 throw (CORBA::SystemException);
314 throw (CORBA::SystemException);
336 virtual CORBA::Double
get_rate(
void)
337 throw (CORBA::SystemException);
369 throw (CORBA::SystemException);
405 throw (CORBA::SystemException);
440 throw (CORBA::SystemException);
474 throw (CORBA::SystemException);
503 throw (CORBA::SystemException);
525 throw (CORBA::SystemException);
559 throw (CORBA::SystemException);
611 throw (CORBA::SystemException);
633 throw (CORBA::SystemException);
694 m_sm.setListener(
this);
707 m_sm.setStartState(st);
856 virtual void on_error(
const ECStates& st) = 0;
883 virtual void on_reset(
const ECStates& st) = 0;
911 virtual void on_execute(
const ECStates& st) = 0;
1046 template <
class Object>
1071 :
DFPBase(id), m_obj(obj), m_active(true)
1092 m_obj->on_startup(
ec_id);
1112 m_obj->on_shutdown(
ec_id);
1169 m_obj->on_deactivated(
ec_id);
1193 m_obj->on_aborting(
ec_id);
1217 m_obj->on_error(
ec_id);
1338 m_obj->on_rate_changed(
ec_id);
1369 Comp(LightweightRTObject_ptr ref, OpenRTM::DataFlowComponent_ptr dfp,
1371 : _ref(LightweightRTObject::_duplicate(ref)),
1372 _sm(
OpenRTM::DataFlowComponent::_duplicate(dfp), id)
1379 : _ref(comp._ref), _sm(comp._sm.m_obj, comp._sm.
ec_id)
1404 : m_comp(LightweightRTObject::_duplicate(comp)) {}
1407 return comp.
_ref->_is_equivalent(m_comp);
1519 Worker() : cond_(mutex_), running_(false) {};
1577 : m_comp(
RTObject::_duplicate(comp)) {}
1580 return m_comp->_is_equivalent(comp);
1587 #pragma warning( default : 4290 ) 1603 #endif // RTC_PERIODICEXECUTIONCONTEXT_H virtual void on_shutdown(void)=0
Pure virtual function to be invoked when ExecutionContext stops.
bool m_active
State flag of the target component to manage.
Condition variable class for worker.
EXECUTION_HANDLE_TYPE_NATIVE ExecutionContextHandle_t
LightweightRTObject_var m_comp
virtual ReturnCode_t remove_component(LightweightRTObject_ptr comp)
Remove the RT-Component from participant list.
virtual ExecutionContextService_ptr getObjRef(void)
Get the reference to the CORBA object.
void operator()(Comp &comp)
std::vector< Comp > m_comps
List of the participating component.
virtual void on_reset(const ECStates &st)=0
Pure virtual function to be invoked when RT-Component resets.
virtual void on_activated(const ECStates &st)=0
Pure virtual function to be invoked when RT-Component is activated.
virtual RTC::ReturnCode_t bindComponent(RTObject_impl *rtc)
Bind the component.
A base class for ExecutionContext.
The structure for the component management.
virtual void on_state_update(const ECStates &st)=0
Pure virtual function to be periodically invoked while RT-Component is running.
void operator()(Comp &comp)
bool m_svc
The thread running flag of ExecutionContext.
DFP< OpenRTM::DataFlowComponent_var > _sm
Comp(LightweightRTObject_ptr ref, OpenRTM::DataFlowComponent_ptr dfp, ExecutionContextHandle_t id)
void on_error(const ECStates &st)
Function to be invoked while RT-Component is in the error state.
void on_rate_changed(void)
Function to be invoked when the execution cycles of ExecutionContext is changed.
#define NUM_OF_LIFECYCLESTATE
ExecutionContext base class.
virtual ReturnCode_t add_component(LightweightRTObject_ptr comp)
Add an RT-component.
virtual CORBA::Boolean is_running(void)
Check for ExecutionContext running state.
void on_deactivated(const ECStates &st)
Function to be invoked when RT-Component was deactivated.
virtual int open(void *args)
Generate internal activity thread for ExecutionContext.
Functor to invoke worker.
virtual int close(unsigned long flags)
Thread execution function for ExecutionContext.
virtual void on_aborting(const ECStates &st)=0
Pure virtual function to be invoked when RT-Component occurs error.
void on_aborting(const ECStates &st)
Function to be invoked when RT-Component occured error.
PeriodicExecutionContext()
Default Constructor.
void on_activated(const ECStates &st)
Function to be invoked when RT-Component was activated.
RTC_Utils::StateHolder< ExecContextState > ECStates
Object m_obj
The target component to manage.
RTComponent manager class.
Worker m_worker
A condition variable for external triggered worker.
bool operator()(RTObject_ptr comp)
virtual void on_execute(const ECStates &st)=0
Pure virtual function to be periodically invoked while RT-Component is running.
LifeCycleState ExecContextState
virtual void on_startup(void)=0
Pure virtual function to be invoked when ExecutionContext starts.
DFP(Object obj, ExecutionContextHandle_t id)
Default constructor.
bool m_nowait
Flag of ExecutionContext to run immediately (to run without waiting)
void on_state_update(const ECStates &st)
Function to be invoked periodically while RT-Component executes.
bool operator()(Comp &comp)
virtual ~DFPBase(void)
Destructor.
Functor to invoke on_rate_changed.
virtual void worker(void)
Get the worker to execute the state transition.
virtual ReturnCode_t start(void)
Start the ExecutionContext.
coil::Mutex m_profileMutex
coil::Guard< coil::Mutex > Guard
Functor to invoke on_startup.
virtual ReturnCode_t activate_component(LightweightRTObject_ptr comp)
Activate an RT-component.
virtual ExecContextState get_state(void)
Get the current state of the target component.
Comp & operator=(const Comp &comp)
coil::Condition< coil::Mutex > cond_
virtual ReturnCode_t reset_component(LightweightRTObject_ptr comp)
Reset the RT-component.
void PeriodicExecutionContextInit(RTC::Manager *manager)
Initialization function to register to ECFactory.
virtual ReturnCode_t stop(void)
Stop the ExecutionContext.
virtual ReturnCode_t deactivate_component(LightweightRTObject_ptr comp)
Deactivate an RT-component.
virtual ~PeriodicExecutionContext(void)
Destructor.
virtual ReturnCode_t set_rate(CORBA::Double rate)
Set execution rate(Hz) of ExecutionContext.
Logger rtclog
Logger stream.
virtual ExecutionKind get_kind(void)
Get the ExecutionKind.
virtual void on_rate_changed(void)=0
Pure virtual function to be invoked when when the execution cycles of ExecutionContext is changed...
ExecutionContextProfile m_profile
ExecutionContextProfile.
void on_startup(void)
Function to be invoked when ExecutionContext starts.
void operator()(Comp &comp)
std::vector< Comp >::iterator CompItr
virtual int svc(void)
Thread execution function for ExecutionContext.
find_comp(LightweightRTObject_ptr comp)
DFPBase(RTC::ExecutionContextHandle_t id)
Constructor.
ExecutionContextService_var m_ref
Reference to ExecutionContextService object.
void on_shutdown(void)
Function to be invoked when ExecutionContext stops.
State machine template class.
virtual void on_error(const ECStates &st)=0
Pure virtual function to be invoked while RT-Component is in the error state.
ExecutionContextHandle_t ec_id
ID of participating ExecutionContext.
bool m_running
The running state of ExecutionContext true: running, false: stopped.
virtual LifeCycleState get_component_state(LightweightRTObject_ptr comp)
Get RT-component's state.
LightweightRTObject_var _ref
virtual CORBA::Double get_rate(void)
Get execution rate(Hz) of ExecutionContext.
RTC_Utils::StateMachine< ExecContextState, DFPBase > m_sm
The state machine of the target RT-Component to manage.
virtual void on_deactivated(const ECStates &st)=0
Pure virtual function to be invoked when RT-Component is deactivated.
void on_reset(const ECStates &st)
Function to be invoked when RT-Component is reset.
Functor to invoke on_shutdown.
coil::TimeValue m_period
Execution cycle of ExecutionContext.
Functor to find the component.
void on_execute(const ECStates &st)
Periodic exection function while running RT-Component.
find_participant(RTObject_ptr comp)
virtual ExecutionContextProfile * get_profile(void)
Get the ExecutionContextProfile.
RTC::Local::ExecutionContextProfile ExecutionContextProfile
void operator()(Comp &comp)