Fawkes API  Fawkes Development Version
battery_monitor_treeview.h
1 
2 /***************************************************************************
3  * battery_monitor_treeview.h - TreeView class for displaying the battery
4  * status of the robots
5  *
6  * Created: Mon Apr 06 15:52:42 2009
7  * Copyright 2009 Daniel Beck
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 #ifndef _TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H_
25 #define _TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H_
26 
27 #include <gtkmm.h>
28 #include <map>
29 #include <string>
30 
31 namespace fawkes {
32 class BlackBoard;
33 class Interface;
34 class BatteryInterface;
35 class InterfaceDispatcher;
36 } // namespace fawkes
37 
38 class BatteryMonitorTreeView : public Gtk::TreeView
39 {
40 public:
41  BatteryMonitorTreeView(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder);
42  virtual ~BatteryMonitorTreeView();
43 
44  void add_host(const char *host);
45  void rem_host(const char *host);
46 
47 protected:
48  class BatteryRecord : public Gtk::TreeModelColumnRecord
49  {
50  public:
52  {
53  add(fqdn);
54  add(short_name);
55  add(absolute_soc);
56  add(relative_soc);
57  add(current);
58  add(voltage);
59  }
60 
61  Gtk::TreeModelColumn<Glib::ustring> fqdn; /**< The FQDN */
62  Gtk::TreeModelColumn<Glib::ustring> short_name; /**< A shorter hostname (w/o domain) */
63  Gtk::TreeModelColumn<float> absolute_soc; /**< The battery's absolute state of charge */
64  Gtk::TreeModelColumn<float> relative_soc; /**< The battery's relative state of charge */
65  Gtk::TreeModelColumn<float> current; /**< The battery's current */
66  Gtk::TreeModelColumn<float> voltage; /**< The battery's voltage */
67  };
68 
70  Glib::RefPtr<Gtk::ListStore> m_battery_list;
71 
72  std::map<std::string, fawkes::BlackBoard *> m_remote_bbs;
73  std::map<std::string, fawkes::BatteryInterface *> m_battery_interfaces;
74  std::map<std::string, fawkes::InterfaceDispatcher *> m_interface_dispatcher;
75 
76 private:
77  void on_data_changed(fawkes::Interface *interface);
78  void on_writer_added(fawkes::Interface *interface);
79  void on_writer_removed(fawkes::Interface *interface);
80 
81  void update();
82 
83  Gtk::MessageDialog *m_dlg_warning;
84 
85  Glib::Dispatcher m_trigger_update;
86  float m_relative_soc_threshold;
87  std::map<std::string, unsigned int> m_below_threshold_counter;
88 };
89 
90 #endif /* TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H__ */
Column record class for the battery monitor treeview.
Gtk::TreeModelColumn< float > relative_soc
The battery's relative state of charge.
Gtk::TreeModelColumn< float > absolute_soc
The battery's absolute state of charge.
Gtk::TreeModelColumn< Glib::ustring > short_name
A shorter hostname (w/o domain)
Gtk::TreeModelColumn< float > current
The battery's current.
Gtk::TreeModelColumn< Glib::ustring > fqdn
The FQDN.
Gtk::TreeModelColumn< float > voltage
The battery's voltage.
A treeview that retrieves battery data from the robots over remote blackboard connections and display...
virtual ~BatteryMonitorTreeView()
Destructor.
std::map< std::string, fawkes::BlackBoard * > m_remote_bbs
Map with remote blackboards: hostname -> remote blackboard.
void rem_host(const char *host)
Remove given host.
std::map< std::string, fawkes::BatteryInterface * > m_battery_interfaces
Map containing the battery interfaces: hostname -> battery interface.
BatteryMonitorTreeView(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
Constructor.
BatteryRecord m_battery_record
Column record object to acces the columns of the storage object.
std::map< std::string, fawkes::InterfaceDispatcher * > m_interface_dispatcher
Interface dispatcher for the battery interfaces.
void add_host(const char *host)
Add given host.
Glib::RefPtr< Gtk::ListStore > m_battery_list
Storage object.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
Fawkes library namespace.