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 <core/threading/thread.h>
29 #include <aspect/blocked_timing.h>
30 #include <aspect/logging.h>
31 #include <aspect/configurable.h>
32 #include <aspect/clock.h>
33 #include <aspect/blackboard.h>
34 #include <aspect/thread_producer.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 }
44 
46 : public fawkes::Thread,
48  public fawkes::LoggingAspect,
50  public fawkes::ClockAspect,
52 {
53  public:
55 
56  virtual void init();
57  virtual void finalize();
58  virtual void loop();
59 
60  void write_blackboard();
61 
62  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
63  protected: virtual void run() { Thread::run(); }
64 
65  private:
66  void close_interfaces();
67  float led_process(fawkes::LedInterface *iface);
68  void set_mode(Roomba500::Mode mode);
69 
70  private:
71  fawkes::LedInterface *__led_if_debris;
72  fawkes::LedInterface *__led_if_spot;
73  fawkes::LedInterface *__led_if_dock;
74  fawkes::LedInterface *__led_if_check_robot;
75  fawkes::LedInterface *__led_if_clean_color;
76  fawkes::LedInterface *__led_if_clean_intensity;
77  fawkes::SwitchInterface *__switch_if_vacuuming;
78  fawkes::SwitchInterface *__switch_if_but_clean;
79  fawkes::SwitchInterface *__switch_if_but_spot;
80  fawkes::SwitchInterface *__switch_if_but_dock;
81  fawkes::SwitchInterface *__switch_if_but_minute;
82  fawkes::SwitchInterface *__switch_if_but_hour;
83  fawkes::SwitchInterface *__switch_if_but_day;
84  fawkes::SwitchInterface *__switch_if_but_schedule;
85  fawkes::SwitchInterface *__switch_if_but_clock;
86  //fawkes::MotorInterface *__motor_if;
87  fawkes::BatteryInterface *__battery_if;
88  fawkes::Roomba500Interface *__roomba500_if;
89 
91 
92  std::string __cfg_conntype;
93  std::string __cfg_mode;
94  std::string __cfg_device;
95  std::string __cfg_bttype;
96  bool __cfg_btsave;
97  bool __cfg_btfast;
98  bool __cfg_query_mode;
99  bool __cfg_play_fanfare;
100 
101  unsigned int __greeting_loop_count;
102 
103  int __battery_percent;
104 
105  class WorkerThread;
106  WorkerThread *__wt;
107 };
108 
109 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
BatteryInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Worker thread for the Roomba 500 thread.
Mode
Roomba 500 operation mode.
Definition: roomba_500.h:148
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:35
Roomba500Interface Fawkes BlackBoard Interface.
Thread aspect to access configuration data.
Definition: configurable.h:35
LedInterface Fawkes BlackBoard Interface.
Definition: LedInterface.h:33