hrpEC-art.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 #include <iostream>
3 #include "hrpEC.h"
4 #include <rtm/ECFactory.h>
5 #include "hrpsys/io/iob.h"
6 #include <linux/art_task.h>
7 
8 namespace RTC
9 {
12  m_priority(ART_PRIO_MAX-1),
13  m_thread_pending (false)
14  {
15  resetProfile();
16  rtclog.setName("hrpEC");
17  coil::Properties& prop(Manager::instance().getConfig());
18 
19  // Priority
20  getProperty(prop, "exec_cxt.periodic.priority", m_priority);
21  getProperty(prop, "exec_cxt.periodic.art.priority", m_priority);
22  RTC_DEBUG(("Priority: %d", m_priority));
23  }
24 
26  {
27  int nsubstep = number_of_substeps();
28  while(1){
29  if (art_wait() == -1){
30  perror("art_wait");
31  return false;
32  }
33  if (read_iob_frame() % nsubstep == 0) break;
34  }
35  return true;
36  }
38  {
39  unsigned long period_usec
41  if (art_enter(m_priority, ART_TASK_PERIODIC, period_usec) == -1){
42  perror("art_enter");
43  return false;
44  }
45  return true;
46  }
48  {
49  if (art_exit() == -1){
50  perror("art_exit");
51  return false;
52  }
53  return true;
54  }
55 };
56 
57 
58 extern "C"
59 {
60  void hrpECInit(RTC::Manager* manager)
61  {
62  manager->registerECFactory("hrpExecutionContext",
63  RTC::ECCreate<RTC::hrpExecutionContext>,
64  RTC::ECDelete<RTC::hrpExecutionContext>);
65  std::cerr << "hrpExecutionContext for ART is registered" << std::endl;
66  }
67 };
68 
long int sec() const
void setName(const char *name)
static Manager & instance()
#define RTC_DEBUG(fmt)
unsigned long long read_iob_frame()
Definition: iob.cpp:551
void getProperty(coil::Properties &prop, const char *key, T &value)
Definition: hrpEC.h:49
void hrpECInit(RTC::Manager *manager)
Definition: hrpEC-art.cpp:60
bool registerECFactory(const char *name, ECNewFunc new_func, ECDeleteFunc delete_func)
prop
int number_of_substeps()
Definition: iob.cpp:558
long int usec() const


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50