ArtExecutionContext.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 /*
20  * $Log$
21  */
22 
23 #include "ArtExecutionContext.h"
24 #include <rtm/ECFactory.h>
25 #include <linux/art_task.h>
26 
27 #include <iostream>
28 
29 namespace RTC
30 {
33  m_priority(ART_PRIO_MAX-1)
34  {
35  rtclog.setName("ArtEC");
36  coil::Properties& prop(Manager::instance().getConfig());
37 
38  // Priority
39  getProperty(prop, "exec_cxt.periodic.priority", m_priority);
40  getProperty(prop, "exec_cxt.periodic.art.priority", m_priority);
41  RTC_DEBUG(("Priority: %d", m_priority));
42 
43  }
44 
46  {
47  }
48 
49 
51  {
52  int usec(m_period.sec() * 1000000 + m_period.usec());
53  if (art_enter(m_priority, ART_TASK_PERIODIC, usec) == -1)
54  {
55  std::cerr << "fatal error: art_enter" << std::endl;
56  }
57  do
58  {
59  std::for_each(m_comps.begin(), m_comps.end(), invoke_worker());
60  // while (!m_running) {ACE_OS::sleep(tv);}
61  if (art_wait() == -1)
62  {
63  std::cerr << "fatal error: art_wait " << std::endl;
64  }
65  } while (m_running);
66 
67  if (art_exit() == -1)
68  {
69  std::cerr << "fatal error: art_exit" << std::endl;
70  }
71  return 0;
72  }
73 };
74 
75 
76 extern "C"
77 {
79  {
80  RTC::Manager::instance().registerECFactory("ArtExecutionContext",
81  RTC::ECCreate<RTC::ArtExecutionContext>,
82  RTC::ECDelete<RTC::ArtExecutionContext>);
83 
84  }
85 };
RT-Component.
long int sec() const
Get value of second time scale.
Definition: TimeValue.h:110
std::vector< Comp > m_comps
List of the participating component.
void ArtExecutionContextInit(RTC::Manager *manager)
Manager class.
Definition: Manager.h:80
void setName(const char *name)
Set suffix of date/time string of header.
static Manager & instance()
Get instance of the manager.
Definition: Manager.cpp:140
void getProperty(coil::Properties &prop, const char *key, T &value)
#define RTC_DEBUG(fmt)
Debug level log output macro.
Definition: SystemLogger.h:488
ArtExecutionContext class.
bool registerECFactory(const char *name, ECNewFunc new_func, ECDeleteFunc delete_func)
Register ExecutionContext Factory.
Definition: Manager.cpp:474
prop
Organization::get_organization_property ();.
Class represents a set of properties.
Definition: Properties.h:101
ExecutionContext Factory class.
virtual int svc(void)
Thread execution function for ExecutionContext.
long int usec() const
Get value of micro second time scale.
Definition: TimeValue.h:131
bool m_running
The running state of ExecutionContext true: running, false: stopped.
coil::TimeValue m_period
Execution cycle of ExecutionContext.
Functor for_each(CorbaSequence &seq, Functor f)
Apply the functor to all CORBA sequence elements.
Definition: CORBA_SeqUtil.h:98


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:56