Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MotionManagerMsg.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_MotionManagerMsg_h
00003 #define INCLUDED_MotionManagerMsg_h
00004 
00005 #include "IPC/ProcessID.h"
00006 
00007 //! A small header that precedes data sent by MotionManager between processes
00008 /*! Typically this is broadcast to all processes using the MotionManager so
00009  *  each process has to update its own fields of MotionManager.
00010  *
00011  *  One tricky aspect is that with the IPC mechanisms on PLATFORM_LOCAL
00012  *  the originating process will get an "echo" of the message, whereas
00013  *  on PLATFORM_APERIOS it's set up so the sender doesn't get an echo
00014  *  of its own message.  However, this complexity is handled by
00015  *  MotionManager, not here. */
00016 struct MotionManagerMsg {
00017   //! the type to use when referring to MotionCommand ID's
00018   typedef unsigned short MC_ID;
00019 
00020   //! for errors and undefined stuff
00021   static const MC_ID invalid_MC_ID=static_cast<MC_ID>(-1); 
00022 
00023   //! constructor
00024   MotionManagerMsg() : type(unknown), creatorPID(ProcessID::getID()), mc_id(invalid_MC_ID) {}
00025 
00026   //! virtual destructor
00027   /*! doesn't do anything, but don't remove it, otherwise this would no longer be a virtual base class */
00028   virtual ~MotionManagerMsg() {}
00029 
00030   //! Accessor for the id number, set by MotionManager::addMotion()
00031   MC_ID getID() const { return mc_id; }
00032 
00033 protected:
00034   //! resets the #mc_id to #invalid_MC_ID
00035   void clearID() { mc_id=invalid_MC_ID; }
00036 
00037 private:
00038   friend class MotionManager;
00039 
00040   //! Denotes what type of message this is (see #type)
00041   enum MsgType {
00042     addMotion,     //!< indicates the msg is actually MotionCommand to be added to the MotionManager
00043     deleteMotion,  //!< indicates the msg's #mc_id references a MotionCommand to be removed from the MotionManager
00044     unknown        //!< failsafe default until one of the others is set
00045   } type; //!< indicates what processing this message requires
00046   
00047   //! holds the process that this message was created/sent from
00048   ProcessID::ProcessID_t creatorPID;
00049   
00050   //! The id of the MotionCommand this is in reference to
00051   MC_ID mc_id;
00052 
00053   //! Sets up the header as an add motion message
00054   void setAdd(MC_ID id) {
00055     type=addMotion;
00056     mc_id=id;
00057   }
00058 
00059   //! Sets up the header as an erase motion message
00060   void setDelete(MC_ID id) {
00061     type=deleteMotion;
00062     mc_id=id;
00063   }
00064 
00065 };
00066 
00067 /*! @file
00068  * @brief Defines MotionManagerMsg, a small header used by MotionManager for sending messages between processes
00069  * @author ejt (Creator)
00070  *
00071  * $Author: ejt $
00072  * $Name: tekkotsu-4_0 $
00073  * $Revision: 1.7 $
00074  * $State: Exp $
00075  * $Date: 2006/09/16 17:32:39 $
00076  */
00077 
00078 #endif // INCLUDED_MotionManagerMsg_h

Tekkotsu v4.0
Generated Thu Nov 22 00:54:54 2007 by Doxygen 1.5.4