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__ */
BatteryMonitorTreeView::BatteryMonitorTreeView
BatteryMonitorTreeView(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
Constructor.
Definition: battery_monitor_treeview.cpp:70
BatteryMonitorTreeView::m_battery_record
BatteryRecord m_battery_record
Definition: battery_monitor_treeview.h:69
BatteryMonitorTreeView::m_battery_interfaces
std::map< std::string, fawkes::BatteryInterface * > m_battery_interfaces
Definition: battery_monitor_treeview.h:73
BatteryMonitorTreeView::BatteryRecord::absolute_soc
Gtk::TreeModelColumn< float > absolute_soc
The battery's absolute state of charge.
Definition: battery_monitor_treeview.h:63
BatteryMonitorTreeView::add_host
void add_host(const char *host)
Add given host.
Definition: battery_monitor_treeview.cpp:128
BatteryMonitorTreeView::~BatteryMonitorTreeView
virtual ~BatteryMonitorTreeView()
Destructor.
Definition: battery_monitor_treeview.cpp:92
BatteryMonitorTreeView::BatteryRecord::current
Gtk::TreeModelColumn< float > current
The battery's current.
Definition: battery_monitor_treeview.h:65
BatteryMonitorTreeView::m_interface_dispatcher
std::map< std::string, fawkes::InterfaceDispatcher * > m_interface_dispatcher
Definition: battery_monitor_treeview.h:74
BatteryMonitorTreeView::m_battery_list
Glib::RefPtr< Gtk::ListStore > m_battery_list
Definition: battery_monitor_treeview.h:70
BatteryMonitorTreeView::m_remote_bbs
std::map< std::string, fawkes::BlackBoard * > m_remote_bbs
Definition: battery_monitor_treeview.h:72
fawkes
BatteryMonitorTreeView
Definition: battery_monitor_treeview.h:38
BatteryMonitorTreeView::rem_host
void rem_host(const char *host)
Remove given host.
Definition: battery_monitor_treeview.cpp:183
fawkes::Interface
Definition: interface.h:78
BatteryMonitorTreeView::BatteryRecord::voltage
Gtk::TreeModelColumn< float > voltage
The battery's voltage.
Definition: battery_monitor_treeview.h:66
BatteryMonitorTreeView::BatteryRecord::relative_soc
Gtk::TreeModelColumn< float > relative_soc
The battery's relative state of charge.
Definition: battery_monitor_treeview.h:64
BatteryMonitorTreeView::BatteryRecord
Definition: battery_monitor_treeview.h:48
BatteryMonitorTreeView::BatteryRecord::short_name
Gtk::TreeModelColumn< Glib::ustring > short_name
A shorter hostname (w/o domain)
Definition: battery_monitor_treeview.h:62
BatteryMonitorTreeView::BatteryRecord::fqdn
Gtk::TreeModelColumn< Glib::ustring > fqdn
The FQDN.
Definition: battery_monitor_treeview.h:61