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 
29 #include <map>
30 #include <string>
31 
32 namespace fawkes {
33  class BlackBoard;
34  class Interface;
35  class BatteryInterface;
36  class InterfaceDispatcher;
37 }
38 
39 class BatteryMonitorTreeView : public Gtk::TreeView
40 {
41  public:
42  BatteryMonitorTreeView(BaseObjectType* cobject,
43  const Glib::RefPtr<Gtk::Builder> &builder);
44  virtual ~BatteryMonitorTreeView();
45 
46  void add_host( const char* host );
47  void rem_host( const char* host );
48 
49  protected:
50  class BatteryRecord : public Gtk::TreeModelColumnRecord
51  {
52  public:
54  {
55  add( fqdn );
56  add( short_name );
57  add( absolute_soc );
58  add( relative_soc );
59  add( current );
60  add( voltage );
61  }
62 
63  Gtk::TreeModelColumn< Glib::ustring > fqdn; /**< The FQDN */
64  Gtk::TreeModelColumn< Glib::ustring > short_name; /**< A shorter hostname (w/o domain) */
65  Gtk::TreeModelColumn< float > absolute_soc; /**< The battery's absolute state of charge */
66  Gtk::TreeModelColumn< float > relative_soc; /**< The battery's relative state of charge */
67  Gtk::TreeModelColumn< float > current; /**< The battery's current */
68  Gtk::TreeModelColumn< float > voltage; /**< The battery's voltage */
69  };
70 
72  Glib::RefPtr< Gtk::ListStore > m_battery_list;
73 
74  std::map< std::string, fawkes::BlackBoard* > m_remote_bbs;
75  std::map< std::string, fawkes::BatteryInterface* > m_battery_interfaces;
76  std::map< std::string, fawkes::InterfaceDispatcher* > m_interface_dispatcher;
77 
78  private:
79  void on_data_changed( fawkes::Interface* interface );
80  void on_writer_added( fawkes::Interface* interface );
81  void on_writer_removed( fawkes::Interface* interface );
82 
83  void update();
84 
85  Gtk::MessageDialog* m_dlg_warning;
86 
87  Glib::Dispatcher m_trigger_update;
88  float m_relative_soc_threshold;
89  std::map< std::string, unsigned int > m_below_threshold_counter;
90 };
91 
92 #endif /* __TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H_ */
std::map< std::string, fawkes::InterfaceDispatcher *> m_interface_dispatcher
Interface dispatcher for the battery interfaces.
A treeview that retrieves battery data from the robots over remote blackboard connections and display...
Fawkes library namespace.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
Gtk::TreeModelColumn< Glib::ustring > short_name
A shorter hostname (w/o domain)
Gtk::TreeModelColumn< Glib::ustring > fqdn
The FQDN.
Gtk::TreeModelColumn< float > relative_soc
The battery&#39;s relative state of charge.
BatteryRecord m_battery_record
Column record object to acces the columns of the storage object.
Gtk::TreeModelColumn< float > voltage
The battery&#39;s voltage.
Gtk::TreeModelColumn< float > current
The battery&#39;s current.
std::map< std::string, fawkes::BatteryInterface *> m_battery_interfaces
Map containing the battery interfaces: hostname -> battery interface.
Gtk::TreeModelColumn< float > absolute_soc
The battery&#39;s absolute state of charge.
Column record class for the battery monitor treeview.
Glib::RefPtr< Gtk::ListStore > m_battery_list
Storage object.
std::map< std::string, fawkes::BlackBoard *> m_remote_bbs
Map with remote blackboards: hostname -> remote blackboard.