20 #ifndef RTC_PERIODICEXECUTIONCONTEXT_H
21 #define RTC_PERIODICEXECUTIONCONTEXT_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);
284 virtual ReturnCode_t
start(
void)
285 throw (CORBA::SystemException);
313 virtual ReturnCode_t
stop(
void)
314 throw (CORBA::SystemException);
336 virtual CORBA::Double
get_rate(
void)
337 throw (CORBA::SystemException);
368 virtual ReturnCode_t
set_rate(CORBA::Double rate)
369 throw (CORBA::SystemException);
405 throw (CORBA::SystemException);
440 throw (CORBA::SystemException);
474 throw (CORBA::SystemException);
503 throw (CORBA::SystemException);
524 virtual ExecutionKind
get_kind(
void)
525 throw (CORBA::SystemException);
558 virtual ReturnCode_t
add_component(LightweightRTObject_ptr comp)
559 throw (CORBA::SystemException);
611 throw (CORBA::SystemException);
633 throw (CORBA::SystemException);
694 m_sm.setListener(
this);
704 st.
prev = INACTIVE_STATE;
705 st.
curr = INACTIVE_STATE;
706 st.
next = INACTIVE_STATE;
707 m_sm.setStartState(st);
708 m_sm.goTo(INACTIVE_STATE);
742 virtual void on_startup(
void) = 0;
760 virtual void on_shutdown(
void) = 0;
783 virtual void on_activated(
const ECStates& st) = 0;
806 virtual void on_deactivated(
const ECStates& st) = 0;
829 virtual void on_aborting(
const ECStates& st) = 0;
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;
939 virtual void on_state_update(
const ECStates& st) = 0;
958 virtual void on_rate_changed(
void) = 0;
978 virtual void worker(
void) {
return m_sm.worker();}
997 virtual ExecContextState
get_state(
void){
return m_sm.getState();}
1046 template <
class Object>
1070 DFP(Object obj, ExecutionContextHandle_t
id)
1139 if (
m_obj->on_activated(
ec_id) != RTC::RTC_OK)
1141 m_sm.goTo(ERROR_STATE);
1243 m_sm.goTo(ERROR_STATE);
1278 m_sm.goTo(ERROR_STATE);
1311 if (
m_obj->on_state_update(
ec_id) != RTC::RTC_OK)
1313 m_sm.goTo(ERROR_STATE);
1369 Comp(LightweightRTObject_ptr ref, OpenRTM::DataFlowComponent_ptr dfp,
1370 ExecutionContextHandle_t
id)
1371 :
_ref(LightweightRTObject::_duplicate(ref)),
1372 _sm(OpenRTM::DataFlowComponent::_duplicate(dfp), id)
1404 : m_comp(LightweightRTObject::_duplicate(comp)) {}
1407 return comp.
_ref->_is_equivalent(m_comp);
1574 RTObject_var m_comp;
1577 : m_comp(RTObject::_duplicate(comp)) {}
1580 return m_comp->_is_equivalent(comp);
1587 #pragma warning( default : 4290 )
1603 #endif // RTC_PERIODICEXECUTIONCONTEXT_H
bool m_active
State flag of the target component to manage.
Definition: PeriodicExecutionContext.h:1357
virtual ReturnCode_t stop(void)
Stop the ExecutionContext.
Condition variable class for worker.
Definition: PeriodicExecutionContext.h:1517
DFP class.
Definition: PeriodicExecutionContext.h:1047
LightweightRTObject_var m_comp
Definition: PeriodicExecutionContext.h:1402
virtual ExecutionContextService_ptr getObjRef(void)
Get the reference to the CORBA object.
Definition: PeriodicExecutionContext.h:149
virtual ReturnCode_t set_rate(CORBA::Double rate)
Set execution rate(Hz) of ExecutionContext.
void operator()(Comp &comp)
Definition: PeriodicExecutionContext.h:1465
virtual ReturnCode_t deactivate_component(LightweightRTObject_ptr comp)
Deactivate an RT-component.
Utility functions for RT-Component.
std::vector< Comp > m_comps
List of the participating component.
Definition: PeriodicExecutionContext.h:1478
virtual void on_reset(const ECStates &st)=0
Pure virtual function to be invoked when RT-Component resets.
Mutex class.
Definition: Mutex.h:40
virtual void on_activated(const ECStates &st)=0
Pure virtual function to be invoked when RT-Component is activated.
Definition: PeriodicExecutionContext.h:1572
A base class for ExecutionContext.
Definition: ExecutionContextBase.h:51
The structure for the component management.
Definition: PeriodicExecutionContext.h:1367
virtual void on_state_update(const ECStates &st)=0
Pure virtual function to be periodically invoked while RT-Component is running.
~Comp(void)
Definition: PeriodicExecutionContext.h:1375
void operator()(Comp &comp)
Definition: PeriodicExecutionContext.h:1450
bool m_svc
The thread running flag of ExecutionContext.
Definition: PeriodicExecutionContext.h:1508
RT-Component class.
Definition: RTObject.h:89
DFP< OpenRTM::DataFlowComponent_var > _sm
Definition: PeriodicExecutionContext.h:1390
Comp(LightweightRTObject_ptr ref, OpenRTM::DataFlowComponent_ptr dfp, ExecutionContextHandle_t id)
Definition: PeriodicExecutionContext.h:1369
void on_error(const ECStates &st)
Function to be invoked while RT-Component is in the error state.
Definition: PeriodicExecutionContext.h:1215
Manager class.
Definition: Manager.h:80
virtual ReturnCode_t add_component(LightweightRTObject_ptr comp)
Add an RT-component.
void on_rate_changed(void)
Function to be invoked when the execution cycles of ExecutionContext is changed.
Definition: PeriodicExecutionContext.h:1336
#define NUM_OF_LIFECYCLESTATE
Definition: PeriodicExecutionContext.h:36
virtual ExecutionKind get_kind(void)
Get the ExecutionKind.
virtual ReturnCode_t start(void)
Start the ExecutionContext.
ExecutionContext base class.
void on_deactivated(const ECStates &st)
Function to be invoked when RT-Component was deactivated.
Definition: PeriodicExecutionContext.h:1167
virtual ~PeriodicExecutionContext(void)
Destructor.
virtual int close(unsigned long flags)
Thread execution function for ExecutionContext.
virtual ReturnCode_t activate_component(LightweightRTObject_ptr comp)
Activate an RT-component.
Functor to invoke worker.
Definition: PeriodicExecutionContext.h:1463
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.
Definition: PeriodicExecutionContext.h:1191
PeriodicExecutionContext()
Default Constructor.
void on_activated(const ECStates &st)
Function to be invoked when RT-Component was activated.
Definition: PeriodicExecutionContext.h:1137
Object m_obj
The target component to manage.
Definition: PeriodicExecutionContext.h:1348
TimeValue class.
Definition: TimeValue.h:40
RTComponent manager class.
Worker m_worker
A condition variable for external triggered worker.
Definition: PeriodicExecutionContext.h:1532
bool operator()(RTObject_ptr comp)
Definition: PeriodicExecutionContext.h:1578
virtual CORBA::Boolean is_running(void)
Check for ExecutionContext running state.
Comp(const Comp &comp)
Definition: PeriodicExecutionContext.h:1378
virtual void on_execute(const ECStates &st)=0
Pure virtual function to be periodically invoked while RT-Component is running.
LifeCycleState ExecContextState
Definition: PeriodicExecutionContext.h:639
virtual int svc(void)
Thread execution function for ExecutionContext.
DFP(Object obj, ExecutionContextHandle_t id)
Default constructor.
Definition: PeriodicExecutionContext.h:1070
State machine class.
Definition: StateMachine.h:263
bool m_nowait
Flag of ExecutionContext to run immediately (to run without waiting)
Definition: PeriodicExecutionContext.h:1570
void on_state_update(const ECStates &st)
Function to be invoked periodically while RT-Component executes.
Definition: PeriodicExecutionContext.h:1309
bool operator()(Comp &comp)
Definition: PeriodicExecutionContext.h:1405
Worker()
Definition: PeriodicExecutionContext.h:1519
virtual ~DFPBase(void)
Destructor.
Definition: PeriodicExecutionContext.h:724
Functor to invoke on_rate_changed.
Definition: PeriodicExecutionContext.h:1448
virtual void worker(void)
Get the worker to execute the state transition.
Definition: PeriodicExecutionContext.h:978
coil::Mutex m_profileMutex
Definition: PeriodicExecutionContext.h:1542
bool running_
Definition: PeriodicExecutionContext.h:1522
coil::Mutex mutex_
Definition: PeriodicExecutionContext.h:1519
State prev
Definition: StateMachine.h:58
Functor to invoke on_startup.
Definition: PeriodicExecutionContext.h:1418
virtual ExecContextState get_state(void)
Get the current state of the target component.
Definition: PeriodicExecutionContext.h:997
Comp & operator=(const Comp &comp)
Definition: PeriodicExecutionContext.h:1382
Logger class.
Definition: SystemLogger.h:99
DFPBase class.
Definition: PeriodicExecutionContext.h:670
coil::Condition< coil::Mutex > cond_
Definition: PeriodicExecutionContext.h:1521
virtual ReturnCode_t remove_component(LightweightRTObject_ptr comp)
Remove the RT-Component from participant list.
State holder class.
Definition: StateMachine.h:55
void PeriodicExecutionContextInit(RTC::Manager *manager)
Initialization function to register to ECFactory.
virtual ReturnCode_t reset_component(LightweightRTObject_ptr comp)
Reset the RT-component.
virtual ExecutionContextProfile * get_profile(void)
Get the ExecutionContextProfile.
virtual int open(void *args)
Generate internal activity thread for ExecutionContext.
virtual CORBA::Double get_rate(void)
Get execution rate(Hz) of ExecutionContext.
Logger rtclog
Logger stream.
Definition: PeriodicExecutionContext.h:1488
State curr
Definition: StateMachine.h:57
ExecutionContextProfile m_profile
ExecutionContextProfile.
Definition: PeriodicExecutionContext.h:1541
void on_startup(void)
Function to be invoked when ExecutionContext starts.
Definition: PeriodicExecutionContext.h:1090
Task class.
Definition: Task.h:39
void operator()(Comp &comp)
Definition: PeriodicExecutionContext.h:1435
std::vector< Comp >::iterator CompItr
Definition: PeriodicExecutionContext.h:1479
find_comp(LightweightRTObject_ptr comp)
Definition: PeriodicExecutionContext.h:1403
virtual LifeCycleState get_component_state(LightweightRTObject_ptr comp)
Get RT-component's state.
DFPBase(RTC::ExecutionContextHandle_t id)
Constructor.
Definition: PeriodicExecutionContext.h:691
ExecutionContextService_var m_ref
Reference to ExecutionContextService object.
Definition: PeriodicExecutionContext.h:1560
void on_shutdown(void)
Function to be invoked when ExecutionContext stops.
Definition: PeriodicExecutionContext.h:1110
PeriodicExecutionContext class.
Definition: PeriodicExecutionContext.h:64
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.
Definition: PeriodicExecutionContext.h:1006
bool m_running
The running state of ExecutionContext true: running, false: stopped.
Definition: PeriodicExecutionContext.h:1499
State next
Definition: StateMachine.h:59
LightweightRTObject_var _ref
Definition: PeriodicExecutionContext.h:1389
RTC_Utils::StateMachine< ExecContextState, DFPBase > m_sm
The state machine of the target RT-Component to manage.
Definition: PeriodicExecutionContext.h:1015
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.
Definition: PeriodicExecutionContext.h:1239
virtual RTC::ReturnCode_t bindComponent(RTObject_impl *rtc)
Bind the component.
Functor to invoke on_shutdown.
Definition: PeriodicExecutionContext.h:1433
coil::TimeValue m_period
Execution cycle of ExecutionContext.
Definition: PeriodicExecutionContext.h:1551
Functor to find the component.
Definition: PeriodicExecutionContext.h:1400
void on_execute(const ECStates &st)
Periodic exection function while running RT-Component.
Definition: PeriodicExecutionContext.h:1274
find_participant(RTObject_ptr comp)
Definition: PeriodicExecutionContext.h:1576
void operator()(Comp &comp)
Definition: PeriodicExecutionContext.h:1420