OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
ExtTrigExecutionContext.h
Go to the documentation of this file.
1// -*- C++ -*-
18#ifndef RTC_EXTTRIGEXECUTIONCONTEXT_H
19#define RTC_EXTTRIGEXECUTIONCONTEXT_H
20
21#include <rtm/RTC.h>
22
23#include <condition_variable>
24#include <coil/Task.h>
25
27
28namespace RTC
29{
53 : public virtual POA_OpenRTM::ExtTrigExecutionContextService,
54 public virtual PortableServer::RefCountServantBase,
56 public coil::Task
57 {
58 public:
73
88
113 int open(void *args) override;
114
135 int svc() override;
136
164 int close(unsigned long flags) override;
165
166 //============================================================
167 // ExtTrigExecutionContextService
168 //============================================================
182 void tick() override;
183
184 //============================================================
185 // ExecutionContextService
186 //============================================================
211 CORBA::Boolean is_running() override;
212
240 RTC::ReturnCode_t start() override;
241
268 RTC::ReturnCode_t stop() override;
269
290 CORBA::Double get_rate() override;
291
321 RTC::ReturnCode_t set_rate(CORBA::Double rate) override;
322
356 RTC::ReturnCode_t
357 activate_component(RTC::LightweightRTObject_ptr comp) override;
358
391 RTC::ReturnCode_t
392 deactivate_component(RTC::LightweightRTObject_ptr comp) override;
393
425 RTC::ReturnCode_t
426 reset_component(RTC::LightweightRTObject_ptr comp) override;
427
454 RTC::LifeCycleState
455 get_component_state(RTC::LightweightRTObject_ptr comp) override;
456
476 RTC::ExecutionKind get_kind() override;
477
509 RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp) override;
510
541 RTC::ReturnCode_t
542 remove_component(RTC::LightweightRTObject_ptr comp) override;
543
563 RTC::ExecutionContextProfile* get_profile() override;
564
565 protected:
569 RTC::ReturnCode_t onStarted() override;
570 // template virtual functions adding/removing component
574 RTC::ReturnCode_t
575 onAddedComponent(RTC::LightweightRTObject_ptr rtobj) override;
579 RTC::ReturnCode_t
580 onRemovedComponent(RTC::LightweightRTObject_ptr rtobj) override;
584 RTC::ReturnCode_t
585 onWaitingActivated(RTC_impl::RTObjectStateMachine* comp, long int count) override;
589 RTC::ReturnCode_t
594 RTC::ReturnCode_t
595 onWaitingReset(RTC_impl::RTObjectStateMachine* comp, long int count) override;
596
597 private:
598 bool threadRunning()
599 {
600 std::lock_guard<std::mutex> guard(m_svcmutex);
601 return m_svc;
602 }
610 RTC::Logger rtclog{"exttrig_async_ec"};
611
619 bool m_svc{false};
620 std::mutex m_svcmutex;
621
629 struct Worker
630 {
631 Worker() {}
632 std::mutex mutex_;
633 std::condition_variable cond_;
634 bool ticked_{false};
635 };
636 // A condition variable for external triggered worker
637 Worker m_worker;
638 }; // class ExtTrigExecutionContext
639} // namespace RTC
640
641
642extern "C"
643{
660}
661
662#endif // RTC_EXTTRIGEXECUTIONCONTEXT_H
ExecutionContext base class.
void ExtTrigExecutionContextInit(RTC::Manager *manager)
Register Factory class for this ExecutionContext.
RTComponent header.
A base class for ExecutionContext.
Definition ExecutionContextBase.h:366
ExecutionContext class that enables one step execution.
Definition ExtTrigExecutionContext.h:57
RTC::ReturnCode_t start() override
Start the ExecutionContext.
RTC::ReturnCode_t set_rate(CORBA::Double rate) override
Set execution rate(Hz) of ExecutionContext.
int close(unsigned long flags) override
Thread execution function for ExecutionContext.
ExtTrigExecutionContext()
Constructor.
RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) override
Deactivate an RT-component.
CORBA::Boolean is_running() override
Check for ExecutionContext running state.
RTC::ReturnCode_t onWaitingActivated(RTC_impl::RTObjectStateMachine *comp, long int count) override
onWaitingActivated() template function
RTC::ExecutionKind get_kind() override
Get the ExecutionKind.
RTC::ExecutionContextProfile * get_profile() override
Get the ExecutionContextProfile.
~ExtTrigExecutionContext() override
Destructor.
CORBA::Double get_rate() override
Get execution rate(Hz) of ExecutionContext.
RTC::ReturnCode_t onAddedComponent(RTC::LightweightRTObject_ptr rtobj) override
onAddedComponent() template function
void tick() override
Move forward one step of ExecutionContext.
RTC::ReturnCode_t onStarted() override
onStarted() template function
RTC::ReturnCode_t stop() override
Stop the ExecutionContext.
RTC::LifeCycleState get_component_state(RTC::LightweightRTObject_ptr comp) override
Get RT-component's state.
RTC::ReturnCode_t remove_component(RTC::LightweightRTObject_ptr comp) override
Remove the RT-Component from participant list.
RTC::ReturnCode_t onWaitingReset(RTC_impl::RTObjectStateMachine *comp, long int count) override
onWaitingReset() template function
int svc() override
Invoke each component's operation.
RTC::ReturnCode_t onWaitingDeactivated(RTC_impl::RTObjectStateMachine *comp, long int count) override
onWaitingDeactivated() template function
RTC::ReturnCode_t activate_component(RTC::LightweightRTObject_ptr comp) override
Activate an RT-component.
int open(void *args) override
Generate internal activity thread for ExecutionContext.
RTC::ReturnCode_t onRemovedComponent(RTC::LightweightRTObject_ptr rtobj) override
onRemovedComponent() template function
RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp) override
Add an RT-component.
RTC::ReturnCode_t reset_component(RTC::LightweightRTObject_ptr comp) override
Reset the RT-component.
Logger class.
Definition SystemLogger.h:101
Manager class.
Definition Manager.h:91
Definition RTObjectStateMachine.h:43
RT-Component.