Fawkes API
Fawkes Development Version
continuous_exec_thread.h
1
2
/***************************************************************************
3
* continuous_exec_thread.h - Fawkes LuaAgent: Continuous Execution Thread
4
*
5
* Created: Thu May 26 11:49:17 2011
6
* Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#ifndef _PLUGINS_LUAAGENT_CONTINUOUS_EXEC_THREAD_H_
24
#define _PLUGINS_LUAAGENT_CONTINUOUS_EXEC_THREAD_H_
25
26
#include <aspect/blackboard.h>
27
#include <aspect/blocked_timing.h>
28
#include <aspect/clock.h>
29
#include <aspect/configurable.h>
30
#include <aspect/logging.h>
31
#include <aspect/thread_producer.h>
32
#include <core/threading/thread.h>
33
#ifdef HAVE_TF
34
# include <aspect/tf.h>
35
#endif
36
#include <utils/system/fam.h>
37
38
#include <cstdlib>
39
#include <string>
40
41
namespace
fawkes
{
42
class
ComponentLogger;
43
class
Mutex;
44
class
LuaContext;
45
class
LuaInterfaceImporter;
46
class
Interface;
47
class
SkillerInterface;
48
class
SkillerDebugInterface;
49
}
// namespace fawkes
50
51
class
LuaAgentContinuousExecutionThread
:
public
fawkes::Thread
,
52
public
fawkes::BlockedTimingAspect
,
53
public
fawkes::LoggingAspect
,
54
public
fawkes::BlackBoardAspect
,
55
public
fawkes::ConfigurableAspect
,
56
public
fawkes::ClockAspect
,
57
public
fawkes::ThreadProducerAspect
,
58
#ifdef HAVE_TF
59
public
fawkes::TransformAspect
,
60
#endif
61
public
fawkes::FamListener
62
{
63
public
:
64
LuaAgentContinuousExecutionThread
();
65
virtual
~LuaAgentContinuousExecutionThread
();
66
67
virtual
void
init
();
68
virtual
void
loop
();
69
virtual
void
finalize
();
70
71
virtual
void
fam_event
(
const
char
*filename,
unsigned
int
mask);
72
73
void
read_interfaces
();
74
void
write_interfaces
();
75
76
/** Stub to see name in backtrace for easier debugging. @see Thread::run() */
77
protected
:
78
virtual
void
79
run
()
80
{
81
Thread::run();
82
}
83
84
private
:
/* methods */
85
void
init_failure_cleanup();
86
87
class
LuaThread :
public
Thread
,
public
fawkes::LoggingAspect
88
{
89
public
:
90
LuaThread(
fawkes::LuaContext
*lua);
91
virtual
void
loop
();
92
93
/** Check if LuaThread failed.
94
* @return true if an error occured, false otherwise. */
95
bool
96
failed()
97
{
98
return
failed_;
99
}
100
101
private
:
102
fawkes::LuaContext
*lua_;
103
bool
failed_;
104
};
105
106
private
:
/* members */
107
fawkes::ComponentLogger
*clog_;
108
109
// config values
110
std::string cfg_agent_;
111
bool
cfg_watch_files_;
112
113
fawkes::SkillerInterface
*skiller_if_;
114
115
fawkes::LuaContext
* lua_;
116
fawkes::LuaInterfaceImporter
*lua_ifi_;
117
118
fawkes::Mutex
*ifi_mutex_;
119
LuaThread * lua_thread_;
120
};
121
122
#endif
fawkes::LuaContext
Definition:
context.h:49
fawkes::Mutex
Definition:
mutex.h:38
fawkes::ComponentLogger
Definition:
component.h:41
fawkes::LuaInterfaceImporter
Definition:
interface_importer.h:47
fawkes::FamListener
Definition:
fam.h:41
fawkes::ThreadProducerAspect
Definition:
thread_producer.h:38
LuaAgentContinuousExecutionThread::write_interfaces
void write_interfaces()
Update all reading interfaces.
Definition:
continuous_exec_thread.cpp:246
fawkes::BlockedTimingAspect
Definition:
blocked_timing.h:56
LuaAgentContinuousExecutionThread::LuaAgentContinuousExecutionThread
LuaAgentContinuousExecutionThread()
Constructor.
Definition:
continuous_exec_thread.cpp:67
LuaAgentContinuousExecutionThread::read_interfaces
void read_interfaces()
Update all reading interfaces.
Definition:
continuous_exec_thread.cpp:233
LuaAgentContinuousExecutionThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition:
continuous_exec_thread.h:79
fawkes::Thread::Thread
Thread(const char *name)
Constructor.
Definition:
thread.cpp:210
LuaAgentContinuousExecutionThread::fam_event
virtual void fam_event(const char *filename, unsigned int mask)
Definition:
continuous_exec_thread.cpp:255
LuaAgentContinuousExecutionThread::init
virtual void init()
Initialize the thread.
Definition:
continuous_exec_thread.cpp:111
fawkes::BlackBoardAspect
Definition:
blackboard.h:38
fawkes
fawkes::LoggingAspect
Definition:
logging.h:38
fawkes::TransformAspect
Definition:
tf.h:43
LuaAgentContinuousExecutionThread::loop
virtual void loop()
Code to execute in the thread.
Definition:
continuous_exec_thread.cpp:212
fawkes::SkillerInterface
Definition:
SkillerInterface.h:39
LuaAgentContinuousExecutionThread::~LuaAgentContinuousExecutionThread
virtual ~LuaAgentContinuousExecutionThread()
Destructor.
Definition:
continuous_exec_thread.cpp:79
LuaAgentContinuousExecutionThread
Definition:
continuous_exec_thread.h:51
fawkes::Thread
Definition:
thread.h:45
LuaAgentContinuousExecutionThread::finalize
virtual void finalize()
Finalize the thread.
Definition:
continuous_exec_thread.cpp:192
fawkes::ConfigurableAspect
Definition:
configurable.h:38
fawkes::ClockAspect
Definition:
clock.h:40
src
plugins
luaagent
continuous_exec_thread.h
Generated by
1.8.17