Fawkes API  Fawkes Development Version
battery_monitor_treeview.h
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 
00029 #include <map>
00030 #include <string>
00031 
00032 namespace fawkes {
00033   class BlackBoard;
00034   class Interface;
00035   class BatteryInterface;
00036   class InterfaceDispatcher;
00037 }
00038 
00039 class BatteryMonitorTreeView : public Gtk::TreeView
00040 {
00041  public:
00042   BatteryMonitorTreeView(BaseObjectType* cobject,
00043                          const Glib::RefPtr<Gtk::Builder> &builder);
00044   virtual ~BatteryMonitorTreeView();
00045 
00046   void add_host( const char* host );
00047   void rem_host( const char* host );
00048 
00049  protected:
00050   class BatteryRecord : public Gtk::TreeModelColumnRecord
00051   {
00052   public:
00053     BatteryRecord()
00054     {
00055       add( fqdn );
00056       add( short_name );
00057       add( absolute_soc );
00058       add( relative_soc );
00059       add( current );
00060       add( voltage );
00061     }
00062     
00063     Gtk::TreeModelColumn< Glib::ustring > fqdn;         /**< The FQDN */
00064     Gtk::TreeModelColumn< Glib::ustring > short_name;   /**< A shorter hostname (w/o domain) */
00065     Gtk::TreeModelColumn< float >         absolute_soc; /**< The battery's absolute state of charge */
00066     Gtk::TreeModelColumn< float >         relative_soc; /**< The battery's relative state of charge */
00067     Gtk::TreeModelColumn< float >         current;      /**< The battery's current */
00068     Gtk::TreeModelColumn< float >         voltage;      /**< The battery's voltage */
00069   };
00070 
00071   BatteryRecord m_battery_record;
00072   Glib::RefPtr< Gtk::ListStore > m_battery_list;
00073 
00074   std::map< std::string, fawkes::BlackBoard* > m_remote_bbs;
00075   std::map< std::string, fawkes::BatteryInterface* > m_battery_interfaces;
00076   std::map< std::string, fawkes::InterfaceDispatcher* > m_interface_dispatcher;
00077 
00078  private:
00079   void on_data_changed( fawkes::Interface* interface );
00080   void on_writer_added( fawkes::Interface* interface );
00081   void on_writer_removed( fawkes::Interface* interface );
00082 
00083   void update();
00084 
00085   Gtk::MessageDialog* m_dlg_warning;
00086 
00087   Glib::Dispatcher m_trigger_update;
00088   float m_relative_soc_threshold;
00089   std::map< std::string, unsigned int > m_below_threshold_counter;
00090 };
00091 
00092 #endif /* __TOOLS_BATTERY_MONITOR_BATTERY_MONITOR_TREE_VIEW_H_ */