Fawkes API  Fawkes Development Version
thread_roomba_500.h
1 
2 /***************************************************************************
3  * thread_roomba_500.h - Roomba 500 thread
4  *
5  * Created: Sun Jan 02 12:47:35 2011
6  * Copyright 2006-2010 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_ROOMBA_THREAD_ROOMBA_500_H_
24 #define _PLUGINS_ROOMBA_THREAD_ROOMBA_500_H_
25 
26 #include "roomba_500.h"
27 
28 #include <aspect/blackboard.h>
29 #include <aspect/blocked_timing.h>
30 #include <aspect/clock.h>
31 #include <aspect/configurable.h>
32 #include <aspect/logging.h>
33 #include <aspect/thread_producer.h>
34 #include <core/threading/thread.h>
35 #include <core/utils/refptr.h>
36 
37 namespace fawkes {
38 class LedInterface;
39 class SwitchInterface;
40 class MotorInterface;
41 class BatteryInterface;
42 class Roomba500Interface;
43 } // namespace fawkes
44 
47  public fawkes::LoggingAspect,
49  public fawkes::ClockAspect,
51 {
52 public:
54 
55  virtual void init();
56  virtual void finalize();
57  virtual void loop();
58 
59  void write_blackboard();
60 
61  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
62 protected:
63  virtual void
64  run()
65  {
66  Thread::run();
67  }
68 
69 private:
70  void close_interfaces();
71  float led_process(fawkes::LedInterface *iface);
72  void set_mode(Roomba500::Mode mode);
73 
74 private:
75  fawkes::LedInterface * led_if_debris_;
76  fawkes::LedInterface * led_if_spot_;
77  fawkes::LedInterface * led_if_dock_;
78  fawkes::LedInterface * led_if_check_robot_;
79  fawkes::LedInterface * led_if_clean_color_;
80  fawkes::LedInterface * led_if_clean_intensity_;
81  fawkes::SwitchInterface *switch_if_vacuuming_;
82  fawkes::SwitchInterface *switch_if_but_clean_;
83  fawkes::SwitchInterface *switch_if_but_spot_;
84  fawkes::SwitchInterface *switch_if_but_dock_;
85  fawkes::SwitchInterface *switch_if_but_minute_;
86  fawkes::SwitchInterface *switch_if_but_hour_;
87  fawkes::SwitchInterface *switch_if_but_day_;
88  fawkes::SwitchInterface *switch_if_but_schedule_;
89  fawkes::SwitchInterface *switch_if_but_clock_;
90  //fawkes::MotorInterface *motor_if_;
91  fawkes::BatteryInterface * battery_if_;
92  fawkes::Roomba500Interface *roomba500_if_;
93 
95 
96  std::string cfg_conntype_;
97  std::string cfg_mode_;
98  std::string cfg_device_;
99  std::string cfg_bttype_;
100  bool cfg_btsave_;
101  bool cfg_btfast_;
102  bool cfg_query_mode_;
103  bool cfg_play_fanfare_;
104 
105  unsigned int greeting_loop_count_;
106 
107  int battery_percent_;
108 
109  class WorkerThread;
110  WorkerThread *wt_;
111 };
112 
113 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:33
virtual void finalize()
Finalize the thread.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:33
Fawkes library namespace.
BatteryInterface Fawkes BlackBoard Interface.
virtual void init()
Initialize the thread.
virtual void loop()
Code to execute in the thread.
Thread class encapsulation of pthreads.
Definition: thread.h:45
Mode
Roomba 500 operation mode.
Definition: roomba_500.h:146
Roomba500Thread()
Constructor.
void write_blackboard()
Write data to blackboard.
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to use blocked timing.
SwitchInterface Fawkes BlackBoard Interface.
Roomba 500 integration thread.
Thread aspect to log output.
Definition: logging.h:32
Roomba500Interface Fawkes BlackBoard Interface.
Thread aspect to access configuration data.
Definition: configurable.h:32
LedInterface Fawkes BlackBoard Interface.
Definition: LedInterface.h:33