FormControlMsgs.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 #ifndef __FORM_CONTROL_MESSAGES__
00027 #define __FORM_CONTROL_MESSAGES__
00028 
00029 #define F_CTRL_MSG_ID "forCtrl"
00030 
00031 #include <Types.h>
00032 #include <string>
00033 
00034 #include <Message.h>
00035 
00036 using namespace std;
00037 using namespace MipBaselib;
00038 
00041 enum FormCtrlHeaders {
00042  FORM_CTRL_POSITION,
00043  FORM_CTRL_VIRT_POINT,
00044  FORM_CTRL_SCALE,
00045  FORM_CTRL_VP_AND_SCALE,
00046  
00047  FORM_CTRL_NUM,
00048 };
00049 
00050 
00051 static const char* formCtrlHeaderNames[FORM_CTRL_NUM] = {
00052  "robot position",
00053  "virtual point",
00054  "shape scale"
00055  "virtual point and shape scale"
00056 };
00057 
00058 
00059 class FormCtrlMsg : public Message{
00060  protected:
00061   FormCtrlMsg(){
00062    string id(F_CTRL_MSG_ID);
00063    setId(id);
00064   }
00065  
00066  public:
00067   int robotId;
00068   FormCtrlHeaders header;
00069   
00070   FormCtrlMsg(const string& inMessage){
00071    inMessage.copy((char* ) this, sizeof(FormCtrlMsg));
00072   }
00073 };
00074 
00075 
00076 class FormCtrlMsgPos : public FormCtrlMsg{
00077  public:
00078  
00079   Decimal x;
00080   Decimal y;
00081   Decimal z;
00082 
00087   FormCtrlMsgPos(int robotId_ = 0, Decimal x_=0.0, Decimal y_=0.0, Decimal z_=0.0){
00088    robotId = robotId_;
00089    header = FORM_CTRL_POSITION;
00090    x = x_;
00091    y = y_;
00092    z = z_;
00093   }
00094   
00096   FormCtrlMsgPos(const string& inMessage){
00097    constructor<FormCtrlMsgPos>(inMessage);
00098   }
00099  
00102   void encode(string& outMessage){
00103    encoder<FormCtrlMsgPos>(outMessage);
00104   }
00105 };
00106 
00107 
00108 class FormCtrlMsgVirtPoint : public FormCtrlMsg{
00109  public:
00110  
00111   Decimal x;
00112   Decimal y;
00113   Decimal z;
00114 
00119   FormCtrlMsgVirtPoint(int robotId_ = 0, Decimal x_=0.0, Decimal y_=0.0, Decimal z_=0.0){
00120    robotId = robotId_;
00121    header = FORM_CTRL_VIRT_POINT;
00122    x = x_;
00123    y = y_;
00124    z = z_;
00125   }
00126   
00128   FormCtrlMsgVirtPoint(const string& inMessage){
00129    constructor<FormCtrlMsgVirtPoint>(inMessage);
00130   }
00131  
00134   void encode(string& outMessage){
00135    encoder<FormCtrlMsgVirtPoint>(outMessage);
00136   }
00137 };
00138 
00139 
00140 class FormCtrlMsgScale : public FormCtrlMsg{
00141  public:
00142  
00143   Decimal scale;
00144 
00147   FormCtrlMsgScale(int robotId_ = 0, Decimal scale_=1.0){
00148    robotId = robotId_;
00149    header = FORM_CTRL_SCALE;
00150 
00151    scale = scale_;
00152   }
00153   
00155   FormCtrlMsgScale(const string& inMessage){
00156    constructor<FormCtrlMsgScale>(inMessage);
00157   }
00158  
00161   void encode(string& outMessage){
00162    encoder<FormCtrlMsgScale>(outMessage);
00163   }
00164 };
00165 
00166 
00167 class FormCtrlMsgVPAndScale : public FormCtrlMsg{
00168  public:
00169  
00170   Decimal x;
00171   Decimal y;
00172   Decimal z;
00173   Decimal scale;
00174 
00180   FormCtrlMsgVPAndScale(int robotId_ = 0, Decimal x_=0.0, Decimal y_=0.0, Decimal z_=0.0, Decimal scale_=1.0){
00181    robotId = robotId_;
00182    header = FORM_CTRL_VP_AND_SCALE;
00183    x = x_;
00184    y = y_;
00185    z = z_;
00186    scale = scale_;
00187   }
00188   
00190   FormCtrlMsgVPAndScale(const string& inMessage){
00191    constructor<FormCtrlMsgVPAndScale>(inMessage);
00192   }
00193  
00196   void encode(string& outMessage){
00197    encoder<FormCtrlMsgVPAndScale>(outMessage);
00198   }
00199 };
00200 
00201 
00202  
00203 #endif
00204 
00205 

Generated on Mon Feb 20 07:01:06 2017 for MIP by  doxygen 1.5.6