Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
FlashIPAddrBehavior.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_FlashIPAddrBehavior_h_ 00003 #define INCLUDED_FlashIPAddrBehavior_h_ 00004 00005 #ifndef TGT_HAS_LEDS 00006 # error FlashIPAddrBehavior requires a target with LEDs 00007 #endif 00008 00009 #include "Behaviors/BehaviorBase.h" 00010 #include "Motion/MotionManager.h" 00011 #include "Motion/MotionSequenceMC.h" 00012 00013 //! Displays IP address by speaking the digits and flashing a series of numbers on the LED face panel 00014 /*! Will only run the display on DoStart() if the flash_on_start 00015 * config variable is set. Otherwise you will need to hold down the 00016 * buttons specified by #button1 and #button2 to trigger the display. 00017 * Note that if the e-stop is active it will intercept the button 00018 * events, so turn off e-stop first. */ 00019 class FlashIPAddrBehavior : public BehaviorBase { 00020 public: 00021 //! constructor 00022 FlashIPAddrBehavior() 00023 : BehaviorBase("FlashIPAddrBehavior"), sounds(), ms(), ms_id(MotionManager::invalid_MC_ID) 00024 {} 00025 00026 virtual void DoStart(); //!< if the Config::behavior_config::flash_on_start flag is set, will setup and run 00027 virtual void DoStop(); //!< halts any display which may be in progress 00028 00029 //! Receives button events, timers, and motman manager pruning notifications 00030 virtual void processEvent(const EventBase& e); 00031 00032 static std::string getClassDescription() { 00033 std::string pre="Displays IP address by flashing a series of numbers on the LED face panel;"; 00034 #ifdef TGT_HAS_BUTTONS 00035 pre+=" Hold down "; 00036 pre+=buttonNames[button1]; 00037 pre+=" and "; 00038 pre+=buttonNames[button2]; 00039 pre+=" to trigger any time while running"; 00040 #else 00041 pre+=" Set configuration file to enable display on boot."; 00042 #endif 00043 return pre; 00044 } 00045 virtual std::string getDescription() const { return getClassDescription(); } 00046 00047 protected: 00048 typedef XLargeMotionSequenceMC MSMC_t; //!< used to flash the LEDs to report the IP address 00049 00050 void loadSounds(); //!< loads the numeric sounds into memory 00051 void releaseSounds(); //!< releases the numeric sounds 00052 void setupSequence(); //!< construct the motion sequence for flashing leds, request timers to play corresponding sound file 00053 00054 #ifdef TGT_HAS_BUTTONS 00055 static const unsigned int button1=ChinButOffset; //!< one of two buttons which must be pressed together to trigger the report without using the Controller 00056 static const unsigned int button2=HeadFrButOffset; //!< one of two buttons which must be pressed together to trigger the report without using the Controller 00057 #endif 00058 00059 static const unsigned int ACTIVATE_TIMER=-1U; //!< timer id to specify both trigger buttons have been down long enough 00060 std::vector<std::string> sounds; //!< sound to play, corresponding to timers to coincide with corresponding digit on the LEDs (could be done with chained sounds, but this is cooler) 00061 static const unsigned int delay=64; //!< time (in milliseconds) to expect #ms to be delayed before it actually starts 00062 00063 SharedObject<MSMC_t> ms; //!< motion sequence used to control the LEDs 00064 MotionManager::MC_ID ms_id; //!< id number of #ms 00065 }; 00066 00067 /*! @file 00068 * @brief Describes FlashIPAddrBehavior, which displays IP address by flashing a series of numbers on the LED face panel 00069 * @author ejt (Creator) 00070 * 00071 * $Author: ejt $ 00072 * $Name: tekkotsu-4_0 $ 00073 * $Revision: 1.3 $ 00074 * $State: Exp $ 00075 * $Date: 2007/08/05 16:16:04 $ 00076 */ 00077 00078 #endif |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:54:53 2007 by Doxygen 1.5.4 |