Homepage Demos Overview Downloads Tutorials Reference
Credits

EStopControllerBehavior.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_EStopControllerBehavior_h_
00003 #define INCLUDED_EStopControllerBehavior_h_
00004 
00005 #include <iostream>
00006 #include "Wireless/Wireless.h"
00007 #include "Behaviors/BehaviorBase.h"
00008 #include "Motion/MotionManager.h"
00009 #include "Events/EventRouter.h"
00010 #include "Events/EventBase.h"
00011 #include "Shared/Config.h"
00012 
00013 //! Listens to control commands coming in from the command port for remotely controlling the head
00014 class EStopControllerBehavior : public BehaviorBase {
00015 
00016 public: 
00017   //! Points to the one EStopControllerBehavior object that the input
00018   //! command stream is talking to. A kludge. Dunno how you're gonna
00019   //! make sure you're not using this uninitialized.
00020   static EStopControllerBehavior * theOne;
00021   static int callback(char *buf, int bytes); //!< called by wireless when there's new data
00022 
00023 public:
00024   //! constructor
00025   EStopControllerBehavior(MotionManager::MC_ID estop)
00026     : BehaviorBase(),
00027       cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 256, 256)),
00028       estop_id(estop)
00029   {
00030     wireless->setDaemon(cmdsock);
00031     theOne=this;
00032   }
00033   //! destructor
00034   virtual ~EStopControllerBehavior() { }
00035 
00036   virtual void DoStart();
00037 
00038   virtual void DoStop();
00039 
00040   virtual void processEvent(const EventBase &);
00041 
00042   virtual std::string getName() const { return "EStop Remote Control"; }
00043   static std::string getClassDescription() {
00044     char tmp[20];
00045     sprintf(tmp,"%d",config->main.estopControl_port);
00046     return std::string("Listens to estop commands coming in from port ")+tmp;
00047   }
00048 
00049   virtual void runCommand(std::string s); //!< processes a string received from wireless
00050 
00051 protected:
00052   //! The input command stream socket
00053   Socket *cmdsock;
00054 
00055   //! The estop to control
00056   MotionManager::MC_ID estop_id;
00057 
00058 private:
00059   EStopControllerBehavior(const EStopControllerBehavior&); //!< don't call
00060   EStopControllerBehavior operator=(const EStopControllerBehavior&); //!< don't call
00061 
00062 };
00063 
00064 /*! @file
00065  * @brief Describes EStopControllerBehavior, listens to control commands coming in from the command port for remotely toggling the estop
00066  * @author tss (Creator)
00067  * 
00068  * $Author: ejt $
00069  * $Name: tekkotsu-1_5 $
00070  * $Revision: 1.1 $
00071  * $State: Rel $
00072  * $Date: 2003/10/10 00:45:01 $
00073  */
00074 
00075 #endif 

Tekkotsu v1.5
Generated Fri Oct 10 15:51:58 2003 by Doxygen 1.3.4