| Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
SensorObserverControl.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_SensorObserverControl_h_ 00003 #define INCLUDED_SensorObserverControl_h_ 00004 00005 #include "ControlBase.h" 00006 #include "Events/EventListener.h" 00007 #include "StringInputControl.h" 00008 #include "ToggleControl.h" 00009 #include <fstream> 00010 00011 //! allows logging of sensor information to the console or file 00012 class SensorObserverControl : public ControlBase, public EventListener { 00013 public: 00014 //!constructor 00015 SensorObserverControl(); 00016 00017 //!opens a custom (embedded) menu to toggle individual sensors 00018 virtual ControlBase* doSelect(); 00019 00020 virtual void refresh(); 00021 00022 //!sends all events received to stdout and/or logfile 00023 virtual void processEvent(const EventBase& event); 00024 00025 protected: 00026 //!checks to see if logfilePath differs from the StringInputControl's value and switches it if it is 00027 void checkLogFile(); 00028 00029 //!update the real-time sub-control view (#rtCtl) 00030 void updateRT(); 00031 00032 //! The real time view for SensorObserverControl is split into a separate class for more straightfoward handling of refreshes 00033 friend class RTViewControl : public ControlBase, public EventListener { 00034 public: 00035 //constructor, pass pointer to SensorObserverControl which contains it 00036 RTViewControl(SensorObserverControl* p) : ControlBase("Real-time View"), EventListener(), parent(p), period(500) {} 00037 virtual void processEvent(const EventBase& /*event*/) { refresh(); } 00038 virtual void refresh(); 00039 virtual void pause(); 00040 virtual void deactivate(); 00041 virtual void setPeriod(unsigned int x); //!< sets #period 00042 protected: 00043 SensorObserverControl* parent; //!< a back pointer to SensorObserverControl which contains it so updateRT can be triggered 00044 unsigned int period; //!< the time to wait between automatic refreshes 00045 private: 00046 RTViewControl(const RTViewControl& ); //!< don't call 00047 RTViewControl& operator=(const RTViewControl& ); //!< don't call 00048 }; 00049 00050 //!address of the logfile, if any (empty string is no logfile) 00051 std::string logfilePath; 00052 00053 //!if a filename is given, events are logged to here 00054 std::ofstream logfile; 00055 00056 ControlBase * helpCtl; //!< control containing help info 00057 ControlBase * sensorCtl; //!< control of sensor selectors 00058 ControlBase * buttonCtl; //!< control of buttons selectors 00059 ControlBase * outputCtl; //!< control of outputs selectors 00060 ControlBase * dutyCtl; //!< control of duty selectors 00061 ToggleControl * consoleCtl; //!< turn logging to the console on and off 00062 StringInputControl * fileCtl; //!< turn logging to a file on and off 00063 RTViewControl * rtCtl; //!< a submenu containing real-time view of current values 00064 StringInputControl * rtFreqCtl; //!< the frequency at which rtCtl should be updated 00065 00066 unsigned int numListeners; //!< count of active console or file control so we know if we're actually logging 00067 00068 private: 00069 SensorObserverControl(const SensorObserverControl& ); //!< don't call 00070 SensorObserverControl& operator=(const SensorObserverControl& ); //!< don't call 00071 00072 }; 00073 00074 /*! @file 00075 * @brief Describes SensorObserverControl which allows logging of sensor information to the console or file 00076 * @author ejt (Creator) 00077 * 00078 * $Author: ejt $ 00079 * $Name: tekkotsu-2_3 $ 00080 * $Revision: 1.3 $ 00081 * $State: Exp $ 00082 * $Date: 2005/01/11 23:49:04 $ 00083 */ 00084 00085 #endif |
|
Tekkotsu v2.3 |
Generated Sat Jan 29 02:25:23 2005 by Doxygen 1.4.0 |