Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * battery_monitor_treeview.h - TreeView class for displaying the battery 00004 * status of the robots 00005 * 00006 * Created: Mon Apr 06 15:52:42 2009 00007 * Copyright 2009 Daniel Beck 00008 * 00009 ****************************************************************************/ 00010 00011 /* This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL file in the doc directory. 00022 */ 00023 00024 #ifndef __TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H_ 00025 #define __TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H_ 00026 00027 #include <gtkmm.h> 00028 #include <libglademm/xml.h> 00029 00030 #include <map> 00031 #include <string> 00032 00033 namespace fawkes { 00034 class BlackBoard; 00035 class Interface; 00036 class BatteryInterface; 00037 class InterfaceDispatcher; 00038 } 00039 00040 class BatteryMonitorTreeView : public Gtk::TreeView 00041 { 00042 public: 00043 BatteryMonitorTreeView( BaseObjectType* cobject, 00044 const Glib::RefPtr< Gnome::Glade::Xml >& ref_xml ); 00045 virtual ~BatteryMonitorTreeView(); 00046 00047 void add_host( const char* host ); 00048 void rem_host( const char* host ); 00049 00050 protected: 00051 class BatteryRecord : public Gtk::TreeModelColumnRecord 00052 { 00053 public: 00054 BatteryRecord() 00055 { 00056 add( fqdn ); 00057 add( short_name ); 00058 add( absolute_soc ); 00059 add( relative_soc ); 00060 add( current ); 00061 add( voltage ); 00062 } 00063 00064 Gtk::TreeModelColumn< Glib::ustring > fqdn; /**< The FQDN */ 00065 Gtk::TreeModelColumn< Glib::ustring > short_name; /**< A shorter hostname (w/o domain) */ 00066 Gtk::TreeModelColumn< float > absolute_soc; /**< The battery's absolute state of charge */ 00067 Gtk::TreeModelColumn< float > relative_soc; /**< The battery's relative state of charge */ 00068 Gtk::TreeModelColumn< float > current; /**< The battery's current */ 00069 Gtk::TreeModelColumn< float > voltage; /**< The battery's voltage */ 00070 }; 00071 00072 BatteryRecord m_battery_record; 00073 Glib::RefPtr< Gtk::ListStore > m_battery_list; 00074 00075 std::map< std::string, fawkes::BlackBoard* > m_remote_bbs; 00076 std::map< std::string, fawkes::BatteryInterface* > m_battery_interfaces; 00077 std::map< std::string, fawkes::InterfaceDispatcher* > m_interface_dispatcher; 00078 00079 private: 00080 void on_data_changed( fawkes::Interface* interface ); 00081 void on_writer_added( fawkes::Interface* interface ); 00082 void on_writer_removed( fawkes::Interface* interface ); 00083 00084 void update(); 00085 00086 Gtk::MessageDialog* m_dlg_warning; 00087 00088 Glib::Dispatcher m_trigger_update; 00089 float m_relative_soc_threshold; 00090 std::map< std::string, unsigned int > m_below_threshold_counter; 00091 }; 00092 00093 #endif /* __TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H_ */