OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
ExecutionContextWorker.h
Go to the documentation of this file.
1// -*- C++ -*-
19#ifndef RTC_EXECUTIONCONTEXTWORKER_H
20#define RTC_EXECUTIONCONTEXTWORKER_H
21
22#include <condition_variable>
23
24#include <rtm/idl/RTCSkel.h>
25#include <rtm/SystemLogger.h>
26#include <vector>
27
28#define NUM_OF_LIFECYCLESTATE 4
29
30namespace RTC
31{
32 class RTObject_impl;
33} // namespace RTC
34namespace RTC_impl
35{
36 class RTObjectStateMachine;
37 using LightweightRTObject_ptr = RTC::LightweightRTObject_ptr;
38 using LightweightRTObject_var = RTC::LightweightRTObject_var;
112 {
113
114 public:
135
136
151
152 //============================================================
153 // Object reference to EC
154 //============================================================
155 void setECRef(RTC::ExecutionContextService_ptr ref);
156 RTC::ExecutionContextService_ptr getECRef();
157
158 //============================================================
159 // ExecutionContext
160 //============================================================
185 CORBA::Boolean isRunning();
186
214 RTC::ReturnCode_t start();
215
242 RTC::ReturnCode_t stop();
243
244 RTC::ReturnCode_t startThread();
245
246 RTC::ReturnCode_t stopThread();
247
248
276 RTC::ReturnCode_t rateChanged();
277
311 RTC::ReturnCode_t activateComponent(RTC::LightweightRTObject_ptr comp,
312 RTObjectStateMachine*& rtobj);
314 std::chrono::nanoseconds timeout
315 = std::chrono::seconds(1),
316 long int cycle = 1000);
349 RTC::ReturnCode_t deactivateComponent(RTC::LightweightRTObject_ptr comp,
350 RTObjectStateMachine*& rtobj);
352 std::chrono::nanoseconds timeout
353 = std::chrono::seconds(1),
354 long int cycle = 1000);
355
387 RTC::ReturnCode_t resetComponent(RTC::LightweightRTObject_ptr comp,
388 RTObjectStateMachine*& rtobj);
389 RTC::ReturnCode_t waitResetComplete(RTObjectStateMachine*& rtobj,
390 std::chrono::nanoseconds timeout
391 = std::chrono::seconds(1),
392 long int cycle = 1000);
393
420 RTC::LifeCycleState getComponentState(RTC::LightweightRTObject_ptr comp);
421 static const char* getStateString(RTC::LifeCycleState state)
422 {
423 static const char* const st[] = {
424 "CREATED_STATE",
425 "INACTIVE_STATE",
426 "ACTIVE_STATE",
427 "ERROR_STATE"
428 };
429 return state >= RTC::CREATED_STATE && state <= RTC::ERROR_STATE ?
430 st[state] : "";
431 }
475 RTC::ReturnCode_t addComponent(RTC::LightweightRTObject_ptr comp);
476
503 RTC::ReturnCode_t bindComponent(RTC::RTObject_impl* rtc);
504
535 RTC::ReturnCode_t removeComponent(RTC::LightweightRTObject_ptr comp);
536 RTObjectStateMachine* findComponent(RTC::LightweightRTObject_ptr comp);
537
538 bool isAllCurrentState(RTC::LifeCycleState state);
539 bool isAllNextState(RTC::LifeCycleState state);
540 bool isOneOfCurrentState(RTC::LifeCycleState state);
541 bool isOneOfNextState(RTC::LifeCycleState state);
542
547
556
557 //------------------------------------------------------------
558 // member variables
559 protected:
567 RTC::Logger rtclog{"ec_worker"};
568
569 RTC::ExecutionContextService_var m_ref;
570
580 bool m_running{false};
581
589 std::vector<RTC_impl::RTObjectStateMachine*> m_comps;
590 mutable std::mutex m_mutex;
591 std::vector<RTC_impl::RTObjectStateMachine*> m_addedComps;
592 mutable std::mutex m_addedMutex;
593 std::vector<RTC_impl::RTObjectStateMachine*> m_removedComps;
594 mutable std::mutex m_removedMutex;
595 using CompItr = std::vector<RTC_impl::RTObjectStateMachine*>::iterator;
596
597 }; // class PeriodicExecutionContext
598} // namespace RTC_impl
599
600#endif // RTC_PERIODICEXECUTIONCONTEXT_H
RT component logger class.
Logger class.
Definition SystemLogger.h:101
RT-Component class.
Definition RTObject.h:93
ExecutionContextWorker class.
Definition ExecutionContextWorker.h:112
bool isAllNextState(RTC::LifeCycleState state)
RTC::ReturnCode_t activateComponent(RTC::LightweightRTObject_ptr comp, RTObjectStateMachine *&rtobj)
Activate an RT-component.
CORBA::Boolean isRunning()
Check for ExecutionContext running state.
RTC::ReturnCode_t bindComponent(RTC::RTObject_impl *rtc)
Bind the component.
RTC::ReturnCode_t start()
Start the ExecutionContext.
RTC::ReturnCode_t stopThread()
RTC::ReturnCode_t waitResetComplete(RTObjectStateMachine *&rtobj, std::chrono::nanoseconds timeout=std::chrono::seconds(1), long int cycle=1000)
RTC::ReturnCode_t removeComponent(RTC::LightweightRTObject_ptr comp)
Remove the RT-Component from participant list.
bool isAllCurrentState(RTC::LifeCycleState state)
std::mutex m_addedMutex
Definition ExecutionContextWorker.h:592
bool m_running
The running state of ExecutionContext true: running, false: stopped .
Definition ExecutionContextWorker.h:580
std::mutex m_mutex
Definition ExecutionContextWorker.h:590
RTC::ReturnCode_t startThread()
bool isOneOfNextState(RTC::LifeCycleState state)
std::mutex m_removedMutex
Definition ExecutionContextWorker.h:594
RTC::LifeCycleState getComponentState(RTC::LightweightRTObject_ptr comp)
Get RT-component's state.
void setECRef(RTC::ExecutionContextService_ptr ref)
RTObjectStateMachine * findComponent(RTC::LightweightRTObject_ptr comp)
RTC::ReturnCode_t resetComponent(RTC::LightweightRTObject_ptr comp, RTObjectStateMachine *&rtobj)
Reset the RT-component.
RTC::ExecutionContextService_var m_ref
Definition ExecutionContextWorker.h:569
RTC::ExecutionContextService_ptr getECRef()
RTC::ReturnCode_t stop()
Stop the ExecutionContext.
RTC::ReturnCode_t deactivateComponent(RTC::LightweightRTObject_ptr comp, RTObjectStateMachine *&rtobj)
Deactivate an RT-component.
virtual ~ExecutionContextWorker()
Destructor.
RTC::ReturnCode_t rateChanged()
Execution rate of ExecutionContext chnaged.
static const char * getStateString(RTC::LifeCycleState state)
Definition ExecutionContextWorker.h:421
bool isOneOfCurrentState(RTC::LifeCycleState state)
RTC::ReturnCode_t addComponent(RTC::LightweightRTObject_ptr comp)
Add an RT-component.
void updateComponentList()
Updating component list .
ExecutionContextWorker()
Default Constructor.
std::vector< RTC_impl::RTObjectStateMachine * >::iterator CompItr
Definition ExecutionContextWorker.h:595
std::vector< RTC_impl::RTObjectStateMachine * > m_comps
List of the participating component .
Definition ExecutionContextWorker.h:589
RTC::Logger rtclog
Logger stream .
Definition ExecutionContextWorker.h:567
std::vector< RTC_impl::RTObjectStateMachine * > m_addedComps
Definition ExecutionContextWorker.h:591
RTC::ReturnCode_t waitDeactivateComplete(RTObjectStateMachine *&rtobj, std::chrono::nanoseconds timeout=std::chrono::seconds(1), long int cycle=1000)
RTC::ReturnCode_t waitActivateComplete(RTObjectStateMachine *&rtobj, std::chrono::nanoseconds timeout=std::chrono::seconds(1), long int cycle=1000)
std::vector< RTC_impl::RTObjectStateMachine * > m_removedComps
Definition ExecutionContextWorker.h:593
Definition RTObjectStateMachine.h:43
Definition ExecutionContextProfile.h:29
RTC::LightweightRTObject_var LightweightRTObject_var
Definition ExecutionContextWorker.h:38
RTC::LightweightRTObject_ptr LightweightRTObject_ptr
Definition ExecutionContextWorker.h:37
RT-Component.