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 private:
00034   friend class MotionManager;
00035 
00036   //! Denotes what type of message this is (see #type)
00037   enum MsgType {
00038     addMotion,     //!< indicates the msg is actually MotionCommand to be added to the MotionManager
00039     deleteMotion,  //!< indicates the msg's #mc_id references a MotionCommand to be removed from the MotionManager
00040     unknown        //!< failsafe default until one of the others is set
00041   } type; //!< indicates what processing this message requires
00042   
00043   //! holds the process that this message was created/sent from
00044   ProcessID::ProcessID_t creatorPID;
00045   
00046   //! The id of the MotionCommand this is in reference to
00047   MC_ID mc_id;
00048 
00049   //! Sets up the header as an add motion message
00050   void setAdd(MC_ID id) {
00051     type=addMotion;
00052     mc_id=id;
00053   }
00054 
00055   //! Sets up the header as an erase motion message
00056   void setDelete(MC_ID id) {
00057     type=deleteMotion;
00058     mc_id=id;
00059   }
00060 
00061   //! resets the #mc_id to #invalid_MC_ID
00062   void clearID() { mc_id=invalid_MC_ID; }
00063   
00064 };
00065 
00066 /*! @file
00067  * @brief Defines MotionManagerMsg, a small header used by MotionManager for sending messages between processes
00068  * @author ejt (Creator)
00069  */
00070 
00071 #endif // INCLUDED_MotionManagerMsg_h

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