CigiRateCtrlV3_2.cpp

Go to the documentation of this file.
00001 
00046 #define _EXPORT_CCL_
00047 
00048 #include "CigiRateCtrlV3_2.h"
00049 #include "CigiSwapping.h"
00050 #include "CigiExceptions.h"
00051 
00052 
00053 // ====================================================================
00054 // Construction/Destruction
00055 // ====================================================================
00056 
00057 
00058 // ================================================
00059 // CigiRateCtrlV3_2
00060 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00061 CigiRateCtrlV3_2::CigiRateCtrlV3_2()
00062 {
00063 
00064    PacketID = CIGI_RATE_CTRL_PACKET_ID_V3_2;
00065    PacketSize = CIGI_RATE_CTRL_PACKET_SIZE_V3_2;
00066    Version = 3;
00067    MinorVersion = 2;
00068 
00069    EntityID = 0;
00070    ArtPartIDV1 = 0;
00071    ArtPartIDV3 = 0;
00072    ApplyToArtPart = false;
00073    CoordSys = Local;
00074    XRate = 0.0;
00075    YRate = 0.0;
00076    ZRate = 0.0;
00077    RollRate = 0.0;
00078    PitchRate = 0.0;
00079    YawRate = 0.0;
00080 
00081 }
00082 
00083 // ================================================
00084 // ~CigiRateCtrlV3
00085 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00086 CigiRateCtrlV3_2::~CigiRateCtrlV3_2()
00087 {
00088 
00089 }
00090 
00091 // ====================================================================
00092 // Pack and Unpack
00093 // ====================================================================
00094 
00095 // ================================================
00096 // Pack
00097 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00098 int CigiRateCtrlV3_2::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00099 {
00100    PackPointer CDta;
00101 
00102    CigiBaseRateCtrl * Data = ( CigiBaseRateCtrl *)Base;
00103 
00104    CDta.c = Buff;
00105 
00106    *CDta.c++ = PacketID;
00107    *CDta.c++ = PacketSize;
00108 
00109    *CDta.s++ = Data->EntityID;
00110    *CDta.c++ = Data->ArtPartIDV3;
00111 
00112    Cigi_uint8 HDta = 0;
00113 
00114    if(Data->ApplyToArtPart)
00115       HDta = 0x01;
00116    
00117    if(Data->CoordSys == Local)
00118       HDta |= 0x02;
00119 
00120    *CDta.c++ = HDta;
00121    *CDta.s++ = 0;
00122 
00123    *CDta.f++ = Data->XRate;
00124    *CDta.f++ = Data->YRate;
00125    *CDta.f++ = Data->ZRate;
00126    *CDta.f++ = Data->RollRate;
00127    *CDta.f++ = Data->PitchRate;
00128    *CDta.f++ = Data->YawRate;
00129 
00130    return(PacketSize);
00131 
00132 }
00133 
00134 // ================================================
00135 // Unpack
00136 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00137 int CigiRateCtrlV3_2::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00138 {
00139    union ArtPartConv
00140    {
00141       Cigi_uint8 uc;
00142       Cigi_int8 c;
00143    } ArtC;
00144 
00145    PackPointer CDta;
00146 
00147    CDta.c = Buff;
00148 
00149    CDta.c += 2;  // Step over packet id and size
00150 
00151    if(!Swap)
00152    {
00153       EntityID = *CDta.s++;
00154       ArtPartIDV3 = *CDta.c++;
00155 
00156       Cigi_uint16 HDta = *CDta.c++;
00157 
00158       ApplyToArtPart = ((HDta & 0x01) != 0);
00159       CoordSys = (CoordSysGrp)((HDta >> 1) & 0x01);
00160 
00161       CDta.s++;
00162 
00163       XRate = *CDta.f++;
00164       YRate = *CDta.f++;
00165       ZRate = *CDta.f++;
00166       RollRate = *CDta.f++;
00167       PitchRate = *CDta.f++;
00168       YawRate = *CDta.f++;
00169    }
00170    else
00171    {
00172       CigiSwap2(&EntityID, CDta.s++);
00173       ArtPartIDV3 = *CDta.c++;
00174 
00175       Cigi_uint16 HDta = *CDta.c++;
00176 
00177       ApplyToArtPart = ((HDta & 0x01) != 0);
00178       CoordSys = (CoordSysGrp)((HDta >> 1) & 0x01);
00179 
00180       CDta.s++;
00181 
00182       CigiSwap4(&XRate, CDta.f++);
00183       CigiSwap4(&YRate, CDta.f++);
00184       CigiSwap4(&ZRate, CDta.f++);
00185       CigiSwap4(&RollRate, CDta.f++);
00186       CigiSwap4(&PitchRate, CDta.f++);
00187       CigiSwap4(&YawRate, CDta.f++);
00188    }
00189 
00190    if(ApplyToArtPart)
00191    {
00192 
00193       ArtC.uc = ArtPartIDV3;
00194       ArtPartIDV1 = ArtC.c;
00195 
00196    }
00197    else
00198       ArtPartIDV1 = -1;
00199 
00200 
00201    return(PacketSize);
00202 
00203 }
00204 
00205 
00206 
00207 // ====================================================================
00208 // Accessors
00209 // ====================================================================
00210 
00211 
00212 // ================================================
00213 // SetArtPartID
00214 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00215 int CigiRateCtrlV3_2::SetArtPartID(const Cigi_uint8 ArtPartIDIn, bool bndchk)
00216 {
00217    union ArtPartConv
00218    {
00219       Cigi_uint8 uc;
00220       Cigi_int8 c;
00221    } ArtC;
00222 
00223    ArtPartIDV3 = ArtPartIDIn;
00224 
00225    if(ApplyToArtPart)
00226    {
00227 
00228       ArtC.uc = ArtPartIDV3;
00229       ArtPartIDV1 = ArtC.c;
00230 
00231    }
00232    else
00233       ArtPartIDV1 = -1;
00234 
00235 
00236    return(CIGI_SUCCESS);
00237 }
00238 
00239 // ================================================
00240 // SetApplyToArtPart
00241 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00242 int CigiRateCtrlV3_2::SetApplyToArtPart(const bool ApplyToArtPartIn, bool bndchk)
00243 {
00244    union ArtPartConv
00245    {
00246       Cigi_uint8 uc;
00247       Cigi_int8 c;
00248    } ArtC;
00249 
00250    ApplyToArtPart = ApplyToArtPartIn;
00251 
00252    if(ApplyToArtPart)
00253    {
00254 
00255       ArtC.uc = ArtPartIDV3;
00256       ArtPartIDV1 = ArtC.c;
00257 
00258    }
00259    else
00260       ArtPartIDV1 = -1;
00261 
00262       return(CIGI_SUCCESS);
00263    }
00264 
00265 
00266 // ================================================
00267 // SrcCoordSys
00268 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00269 int CigiRateCtrlV3_2::SetCoordSys(const CoordSysGrp CoordSysIn, bool bndchk)
00270 {
00271 
00272 #ifndef CIGI_NO_BND_CHK
00273    if(bndchk && ((CoordSysIn < 0)||(CoordSysIn > 1)))
00274    {
00275 #ifndef CIGI_NO_EXCEPT
00276       throw CigiValueOutOfRangeException("CoordSys",(CoordSysGrp)CoordSysIn,0,1);
00277 #endif
00278       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00279    }
00280 #endif
00281 
00282    CoordSys = CoordSysIn;
00283 
00284    return(CIGI_SUCCESS);
00285 
00286 }
00287 
00288 
00289 
00290 

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