CigiRateCtrlV2.cpp

Go to the documentation of this file.
00001 
00055 #define _EXPORT_CCL_
00056 
00057 #include "CigiRateCtrlV2.h"
00058 #include "CigiSwapping.h"
00059 #include "CigiExceptions.h"
00060 
00061 #include <memory.h>
00062 
00063 
00064 #ifdef CIGI_LITTLE_ENDIAN
00065    #define CIGI_SCOPY2 CigiSwap2
00066    #define CIGI_SCOPY4 CigiSwap4
00067    #define CIGI_SCOPY8 CigiSwap8
00068 #else
00069    #define CIGI_SCOPY2 CigiCopy2
00070    #define CIGI_SCOPY4 CigiCopy4
00071    #define CIGI_SCOPY8 CigiCopy8
00072 #endif
00073 
00074 
00075 
00076 
00077 // ====================================================================
00078 // Construction/Destruction
00079 // ====================================================================
00080 
00081 
00082 // ================================================
00083 // CigiRateCtrlV2
00084 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00085 CigiRateCtrlV2::CigiRateCtrlV2()
00086 {
00087 
00088    PacketID = CIGI_RATE_CTRL_PACKET_ID_V2;
00089    PacketSize = CIGI_RATE_CTRL_PACKET_SIZE_V2;
00090    Version = 2;
00091    MinorVersion = 0;
00092 
00093    EntityID = 0;
00094    ArtPartIDV1 = 0;
00095    ArtPartIDV3 = 0;
00096    ApplyToArtPart = false;
00097    CoordSys = Local;
00098    XRate = 0.0;
00099    YRate = 0.0;
00100    ZRate = 0.0;
00101    RollRate = 0.0;
00102    PitchRate = 0.0;
00103    YawRate = 0.0;
00104 
00105 }
00106 
00107 // ================================================
00108 // ~CigiRateCtrlV2
00109 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00110 CigiRateCtrlV2::~CigiRateCtrlV2()
00111 {
00112 
00113 }
00114 
00115 // ====================================================================
00116 // Pack and Unpack
00117 // ====================================================================
00118 
00119 // ================================================
00120 // Pack
00121 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00122 int CigiRateCtrlV2::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00123 {
00124    double DBuf[6];
00125 
00126    Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00127 
00128    PackPointer CDta;
00129 
00130    CigiBaseRateCtrl * Data = ( CigiBaseRateCtrl *)Base;
00131 
00132    CDta.d = DBuf;
00133 
00134    *CDta.c++ = PacketID;
00135    *CDta.c++ = PacketSize;
00136 
00137    CIGI_SCOPY2(CDta.s++, &Data->EntityID);
00138    *CDta.c++ = Data->ArtPartIDV1;
00139 
00140    *CDta.c++ = 0;
00141    *CDta.s++ = 0;
00142 
00143    CIGI_SCOPY4(CDta.f++, &Data->XRate);
00144    CIGI_SCOPY4(CDta.f++, &Data->YRate);
00145    CIGI_SCOPY4(CDta.f++, &Data->ZRate);
00146    CIGI_SCOPY4(CDta.f++, &Data->RollRate);
00147    CIGI_SCOPY4(CDta.f++, &Data->PitchRate);
00148    CIGI_SCOPY4(CDta.f++, &Data->YawRate);
00149 
00150    memcpy(Buff,tBuf,CIGI_RATE_CTRL_PACKET_SIZE_V2);
00151 
00152    return(PacketSize);
00153 
00154 }
00155 
00156 // ================================================
00157 // Unpack
00158 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00159 int CigiRateCtrlV2::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00160 {
00161    double DBuf[6];
00162 
00163    Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00164 
00165    union ArtPartConv
00166    {
00167       Cigi_uint8 uc;
00168       Cigi_int8 c;
00169    } ArtC;
00170 
00171    PackPointer CDta;
00172 
00173    memcpy(tBuf,Buff,CIGI_RATE_CTRL_PACKET_SIZE_V2);
00174 
00175    CDta.d = DBuf;
00176 
00177    CDta.c += 2;  // Step over packet id and size
00178 
00179    CIGI_SCOPY2(&EntityID, CDta.s++);
00180    ArtPartIDV1 = *CDta.c++;
00181 
00182    CDta.c += 3;
00183 
00184    CIGI_SCOPY4(&XRate, CDta.f++);
00185    CIGI_SCOPY4(&YRate, CDta.f++);
00186    CIGI_SCOPY4(&ZRate, CDta.f++);
00187    CIGI_SCOPY4(&RollRate, CDta.f++);
00188    CIGI_SCOPY4(&PitchRate, CDta.f++);
00189    CIGI_SCOPY4(&YawRate, CDta.f++);
00190 
00191    if(ArtPartIDV1 == -1)
00192    {
00193 
00194       ApplyToArtPart = false;
00195 
00196       ArtPartIDV3 = 0;
00197 
00198    }
00199    else
00200    {
00201 
00202       ApplyToArtPart = true;
00203 
00204       ArtC.c = ArtPartIDV1;
00205       ArtPartIDV3 = ArtC.uc;
00206       
00207 
00208    }
00209 
00210    CoordSys = Local;
00211 
00212    return(PacketSize);
00213 
00214 }
00215 
00216 
00217 
00218 // ====================================================================
00219 // Accessors
00220 // ====================================================================
00221 
00222 
00223 // ================================================
00224 // SetArtPartID
00225 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00226 int CigiRateCtrlV2::SetArtPartID(const Cigi_int8 ArtPartIDIn, bool bndchk)
00227 {
00228    union ArtPartConv
00229    {
00230       Cigi_uint8 uc;
00231       Cigi_int8 c;
00232    } ArtC;
00233 
00234    ArtPartIDV1 = ArtPartIDIn;
00235 
00236    if(ArtPartIDV1 == -1)
00237    {
00238 
00239       ApplyToArtPart = false;
00240 
00241       ArtPartIDV3 = 0;
00242 
00243    }
00244    else
00245    {
00246 
00247       ApplyToArtPart = true;
00248 
00249       ArtC.c = ArtPartIDV1;
00250       ArtPartIDV3 = ArtC.uc;
00251       
00252 
00253    }
00254 
00255    return(CIGI_SUCCESS);
00256 }
00257 
00258 
00259 

Generated on Wed Apr 29 08:59:59 2009 for CCL by  doxygen 1.4.7