OpenRTM-aist 2.0.2
読み取り中…
検索中…
一致する文字列を見つけられません
PeriodicExecutionContext.h
[詳解]
1// -*- C++ -*-
19#ifndef RTC_PERIODICEXECUTIONCONTEXT2_H
20#define RTC_PERIODICEXECUTIONCONTEXT2_H
21
22#include <coil/Task.h>
23#include <condition_variable>
24#include <coil/Affinity.h>
25
27
28#include <vector>
29#include <iostream>
30
31#define NUM_OF_LIFECYCLESTATE 4
32
33namespace RTC_exp
34{
56 : public virtual POA_RTC::ExecutionContextService,
57 public virtual PortableServer::RefCountServantBase,
59 public coil::Task
60 {
61 public:
82
97
111 void init(coil::Properties& props) override;
112
137 int open(void *args) override;
138
158 int svc() override;
159
187 int close(unsigned long flags) override;
188
189 //============================================================
190 // ExecutionContext
191 //============================================================
216 CORBA::Boolean is_running() override;
217
245 RTC::ReturnCode_t start() override;
246
273 RTC::ReturnCode_t stop() override;
274
295 CORBA::Double get_rate() override;
296
326 RTC::ReturnCode_t set_rate(CORBA::Double rate) override;
327
361 RTC::ReturnCode_t
362 activate_component(RTC::LightweightRTObject_ptr comp) override;
363
396 RTC::ReturnCode_t
397 deactivate_component(RTC::LightweightRTObject_ptr comp) override;
398
430 RTC::ReturnCode_t
431 reset_component(RTC::LightweightRTObject_ptr comp) override;
432
459 RTC::LifeCycleState
460 get_component_state(RTC::LightweightRTObject_ptr comp) override;
461
481 RTC::ExecutionKind get_kind() override;
482
514 RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp) override;
515
546 RTC::ReturnCode_t
547 remove_component(RTC::LightweightRTObject_ptr comp) override;
548
568 RTC::ExecutionContextProfile* get_profile() override;
569
570 protected:
571 template <class T>
572 void getProperty(coil::Properties& prop, const char* key, T& value)
573 {
574 if (prop.findNode(key) != nullptr)
575 {
576 T tmp;
577 if (coil::stringTo(tmp, prop[key].c_str()))
578 {
579 value = tmp;
580 }
581 }
582 }
586 RTC::ReturnCode_t onStarted() override;
590 RTC::ReturnCode_t onStopping() override;
591 // template virtual functions adding/removing component
595 RTC::ReturnCode_t
596 onAddedComponent(RTC::LightweightRTObject_ptr rtobj) override;
600 RTC::ReturnCode_t
601 onRemovedComponent(RTC::LightweightRTObject_ptr rtobj) override;
602
606 RTC::ReturnCode_t
607 onWaitingActivated(RTC_impl::RTObjectStateMachine* comp, long int count) override;
611 RTC::ReturnCode_t
612 onActivated(RTC_impl::RTObjectStateMachine* comp, long int count) override;
616 RTC::ReturnCode_t
621 RTC::ReturnCode_t
622 onDeactivated(RTC_impl::RTObjectStateMachine* comp, long int count) override;
626 RTC::ReturnCode_t
627 onWaitingReset(RTC_impl::RTObjectStateMachine* comp, long int count) override;
631 RTC::ReturnCode_t
632 onReset(RTC_impl::RTObjectStateMachine* comp, long int count) override;
633
637 virtual void setCpuAffinity(coil::Properties& props);
638
640 {
641 std::lock_guard<std::mutex> guard(m_svcmutex);
642 return m_svc;
643 }
644 protected:
652 RTC::Logger rtclog{"periodic_ec"};
653
661 bool m_svc{false};
662 std::mutex m_svcmutex;
663
672 {
674 std::mutex mutex_;
675 std::condition_variable cond_;
676 bool running_{false};
677 };
678
687
696 bool m_nowait{false};
697
701 coil::CpuMask m_cpu;
702
703 }; // class PeriodicExecutionContext
704} // namespace RTC_exp
705
706
707extern "C"
708{
717}
718
719#endif // RTC_PERIODICEXECUTIONCONTEXT_H
ExecutionContext base class
void PeriodicExecutionContextInit(RTC::Manager *manager)
ECFactoryへの登録のための初期化関数
ExecutionContext用基底クラス
Definition ExecutionContextBase.h:366
Logger クラス
Definition SystemLogger.h:101
Manager クラス
Definition Manager.h:91
PeriodicExecutionContext クラス
Definition PeriodicExecutionContext.h:60
bool m_svc
ExecutionContext のスレッド実行フラグ
Definition PeriodicExecutionContext.h:661
std::mutex m_svcmutex
Definition PeriodicExecutionContext.h:662
coil::CpuMask m_cpu
CPU affinity mask list
Definition PeriodicExecutionContext.h:701
RTC::ReturnCode_t activate_component(RTC::LightweightRTObject_ptr comp) override
RTコンポーネントをアクティブ化する
RTC::ReturnCode_t start() override
ExecutionContext の実行を開始
RTC::ReturnCode_t onReset(RTC_impl::RTObjectStateMachine *comp, long int count) override
onReset() template function
PeriodicExecutionContext()
デフォルトコンストラクタ
RTC::ReturnCode_t onRemovedComponent(RTC::LightweightRTObject_ptr rtobj) override
onRemovedComponent() template function
bool threadRunning()
Definition PeriodicExecutionContext.h:639
RTC::ReturnCode_t add_component(RTC::LightweightRTObject_ptr comp) override
RTコンポーネントを追加する
~PeriodicExecutionContext() override
デストラクタ
void init(coil::Properties &props) override
ExecutionContextの初期化を行う
void getProperty(coil::Properties &prop, const char *key, T &value)
Definition PeriodicExecutionContext.h:572
RTC::ExecutionContextProfile * get_profile() override
ExecutionContextProfile を取得する
WorkerThreadCtrl m_workerthread
svn用の状態変数
Definition PeriodicExecutionContext.h:686
CORBA::Boolean is_running() override
ExecutionContext 実行状態確認関数
RTC::ReturnCode_t set_rate(CORBA::Double rate) override
ExecutionContext の実行周期(Hz)を設定する
CORBA::Double get_rate() override
ExecutionContext の実行周期(Hz)を取得する
RTC::LifeCycleState get_component_state(RTC::LightweightRTObject_ptr comp) override
RTコンポーネントの状態を取得する
RTC::ReturnCode_t stop() override
ExecutionContext の実行を停止
RTC::ReturnCode_t onAddedComponent(RTC::LightweightRTObject_ptr rtobj) override
onAddedComponent() template function
RTC::ReturnCode_t deactivate_component(RTC::LightweightRTObject_ptr comp) override
RTコンポーネントを非アクティブ化する
RTC::ReturnCode_t onActivated(RTC_impl::RTObjectStateMachine *comp, long int count) override
onActivated() template function
RTC::ReturnCode_t remove_component(RTC::LightweightRTObject_ptr comp) override
RTコンポーネントを参加者リストから削除する
RTC::ReturnCode_t reset_component(RTC::LightweightRTObject_ptr comp) override
RTコンポーネントをリセットする
int close(unsigned long flags) override
ExecutionContext 用のスレッド実行関数
RTC::ExecutionKind get_kind() override
ExecutionKind を取得する
RTC::Logger rtclog
ロガーストリーム
Definition PeriodicExecutionContext.h:652
bool m_nowait
ExecutionContext 即時実行(wait無し実行)フラグ
Definition PeriodicExecutionContext.h:696
RTC::ReturnCode_t onWaitingDeactivated(RTC_impl::RTObjectStateMachine *comp, long int count) override
onWaitingDeactivated() template function
RTC::ReturnCode_t onStopping() override
onStopping() template function
RTC::ReturnCode_t onWaitingReset(RTC_impl::RTObjectStateMachine *comp, long int count) override
onWaitingReset() template function
RTC::ReturnCode_t onStarted() override
onStarted() template function
virtual void setCpuAffinity(coil::Properties &props)
setting CPU affinity from given properties
RTC::ReturnCode_t onWaitingActivated(RTC_impl::RTObjectStateMachine *comp, long int count) override
onWaitingActivated() template function
int svc() override
ExecutionContext 用のスレッド実行関数
int open(void *args) override
ExecutionContext用アクティビティスレッドを生成する
RTC::ReturnCode_t onDeactivated(RTC_impl::RTObjectStateMachine *comp, long int count) override
onDeactivated() template function
Definition RTObjectStateMachine.h:43
Definition MultilayerCompositeEC.h:28
worker 用状態変数クラス
Definition PeriodicExecutionContext.h:672
std::mutex mutex_
Definition PeriodicExecutionContext.h:674
WorkerThreadCtrl()
Definition PeriodicExecutionContext.h:673
std::condition_variable cond_
Definition PeriodicExecutionContext.h:675
bool running_
Definition PeriodicExecutionContext.h:676