Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

FlashIPAddrBehavior.h

Go 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 #include "IPC/SharedObject.h"
00013 
00014 //! Displays IP address by speaking the digits and flashing a series of numbers on the LED face panel
00015 /*! Will only run the display on doStart() if the flash_on_start
00016  *  config variable is set.  Otherwise you will need to hold down the
00017  *  buttons specified by #button1 and #button2 to trigger the display.
00018  *  Note that if the e-stop is active it will intercept the button
00019  *  events, so turn off e-stop first. */
00020 class FlashIPAddrBehavior : public BehaviorBase {
00021 public:
00022   //! constructor
00023   FlashIPAddrBehavior()
00024     : BehaviorBase("FlashIPAddrBehavior"), sounds(), ms(), ms_id(MotionManager::invalid_MC_ID)
00025   {}
00026 
00027   virtual void doStart(); //!< if the Config::behavior_config::flash_on_start flag is set, will setup and run
00028   virtual void doStop();  //!< halts any display which may be in progress
00029 
00030   //! Receives button events, timers, and motman manager pruning notifications
00031   virtual void doEvent();
00032 
00033   static std::string getClassDescription() {
00034     std::string pre="Displays IP address by flashing a series of numbers on the LED face panel;";
00035 #ifdef TGT_HAS_BUTTONS
00036     pre+=" Hold down ";
00037     pre+=buttonNames[button1];
00038     pre+=" and ";
00039     pre+=buttonNames[button2];
00040     pre+=" to trigger any time while running";
00041 #else
00042     pre+=" Set configuration file to enable display on boot.";
00043 #endif
00044     return pre;
00045   }
00046   virtual std::string getDescription() const { return getClassDescription(); }
00047   
00048 protected:
00049   typedef XLargeMotionSequenceMC MSMC_t; //!< used to flash the LEDs to report the IP address
00050 
00051   void loadSounds();    //!< loads the numeric sounds into memory
00052   void releaseSounds(); //!< releases the numeric sounds
00053   void setupSequence(); //!< construct the motion sequence for flashing leds, request timers to play corresponding sound file
00054 
00055 #ifdef TGT_IS_AIBO
00056   static const unsigned int button1=ChinButOffset; //!< one of two buttons which must be pressed together to trigger the report without using the Controller
00057   static const unsigned int button2=HeadFrButOffset; //!< one of two buttons which must be pressed together to trigger the report without using the Controller
00058 #elif defined(TGT_HAS_BUTTONS)
00059   static const unsigned int button1=0; //!< one of two buttons which must be pressed together to trigger the report without using the Controller
00060   static const unsigned int button2=1; //!< one of two buttons which must be pressed together to trigger the report without using the Controller
00061 #endif
00062   
00063   static const unsigned int ACTIVATE_TIMER=-1U; //!< timer id to specify both trigger buttons have been down long enough
00064   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)
00065   static const unsigned int delay=64; //!< time (in milliseconds) to expect #ms to be delayed before it actually starts
00066   
00067   SharedObject<MSMC_t> ms; //!< motion sequence used to control the LEDs
00068   MotionManager::MC_ID ms_id; //!< id number of #ms
00069 };
00070 
00071 /*! @file
00072  * @brief Describes FlashIPAddrBehavior, which displays IP address by flashing a series of numbers on the LED face panel
00073  * @author ejt (Creator)
00074  */
00075 
00076 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:39 2016 by Doxygen 1.6.3