Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
ec
hrpEC
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
{
10
hrpExecutionContext::hrpExecutionContext
()
11
:
PeriodicExecutionContext
(),
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
25
bool
hrpExecutionContext::waitForNextPeriod
()
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
}
37
bool
hrpExecutionContext::enterRT
()
38
{
39
unsigned
long
period_usec
40
= (
m_period
.
sec
()*1e6+
m_period
.
usec
())/
number_of_substeps
();
41
if
(art_enter(
m_priority
, ART_TASK_PERIODIC, period_usec) == -1){
42
perror(
"art_enter"
);
43
return
false
;
44
}
45
return
true
;
46
}
47
bool
hrpExecutionContext::exitRT
()
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
RTC
coil::TimeValue::sec
long int sec() const
RTC::hrpExecutionContext::hrpExecutionContext
hrpExecutionContext()
Definition:
hrpEC-art.cpp:10
RTC::Manager
PeriodicExecutionContext
RTC::Logger::setName
void setName(const char *name)
RTC::Manager::instance
static Manager & instance()
RTC::hrpExecutionContext::waitForNextPeriod
bool waitForNextPeriod()
Definition:
hrpEC-art.cpp:25
RTC::hrpExecutionContext::exitRT
bool exitRT()
Definition:
hrpEC-art.cpp:47
RTC_DEBUG
#define RTC_DEBUG(fmt)
RTC::hrpExecutionContext::m_priority
int m_priority
Definition:
hrpEC.h:72
read_iob_frame
unsigned long long read_iob_frame()
Definition:
iob.cpp:551
RTC::hrpExecutionContext::getProperty
void getProperty(coil::Properties &prop, const char *key, T &value)
Definition:
hrpEC.h:49
hrpECInit
void hrpECInit(RTC::Manager *manager)
Definition:
hrpEC-art.cpp:60
hrpEC.h
RTC::Manager::registerECFactory
bool registerECFactory(const char *name, ECNewFunc new_func, ECDeleteFunc delete_func)
prop
prop
coil::Properties
RTC::PeriodicExecutionContext::rtclog
Logger rtclog
ECFactory.h
number_of_substeps
int number_of_substeps()
Definition:
iob.cpp:558
RTC::hrpExecutionContext::resetProfile
void resetProfile()
Definition:
hrpEC-common.cpp:209
coil::TimeValue::usec
long int usec() const
RTC::hrpExecutionContext::enterRT
bool enterRT()
Definition:
hrpEC-art.cpp:37
RTC::PeriodicExecutionContext::m_period
coil::TimeValue m_period
hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50