CigiSpecEffDefV2.cpp

Go to the documentation of this file.
00001 
00055 #define _EXPORT_CCL_
00056 
00057 #include "CigiSpecEffDefV2.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 // CigiSpecEffDefV2
00084 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00085 CigiSpecEffDefV2::CigiSpecEffDefV2()
00086 {
00087 
00088    PacketID = CIGI_SPEC_EFF_DEF_PACKET_ID_V2;
00089    PacketSize = CIGI_SPEC_EFF_DEF_PACKET_SIZE_V2;
00090    Version = 2;
00091    MinorVersion = 0;
00092 
00093    EntityID = 0;
00094    SeqDir = Forward;
00095    ColorEn = false;
00096    Red = 0;
00097    Green = 0;
00098    Blue = 0;
00099    XScale = 0.0;
00100    YScale = 0.0;
00101    ZScale = 0.0;
00102    TimeScale = 0.0;
00103    EffectCnt = 0;
00104    Separation = 0.0;
00105    BurstRate = 0.0;
00106    Duration = 0.0;
00107 
00108 }
00109 
00110 // ================================================
00111 // ~CigiSpecEffDefV2
00112 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00113 CigiSpecEffDefV2::~CigiSpecEffDefV2()
00114 {
00115 
00116 }
00117 
00118 // ====================================================================
00119 // Pack and Unpack
00120 // ====================================================================
00121 
00122 // ================================================
00123 // Pack
00124 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00125 int CigiSpecEffDefV2::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00126 {
00127    double DBuf[6];
00128 
00129    Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00130 
00131    PackPointer CDta;
00132 
00133    CigiBaseSpecEffDef * Data = ( CigiBaseSpecEffDef *)Base;
00134 
00135    CDta.d = DBuf;
00136 
00137    *CDta.c++ = PacketID;
00138    *CDta.c++ = PacketSize;
00139 
00140    CIGI_SCOPY2(CDta.h++, &Data->EntityID);
00141 
00142    Cigi_uint8 HDta = (Data->SeqDir << 7) & 0x80;
00143    HDta |= (Data->ColorEn) ? 0x40 : 0;
00144    *CDta.c++ = HDta;
00145 
00146    *CDta.c++ = Data->Red;
00147    *CDta.c++ = Data->Green;
00148    *CDta.c++ = Data->Blue;
00149 
00150    float tfScl = (float)Data->XScale / 0.015625f;
00151    Cigi_int16 tsScl = (short)tfScl;
00152    CIGI_SCOPY2(CDta.h++, &tsScl);
00153 
00154    tfScl = Data->YScale / 0.015625f;
00155    tsScl = (Cigi_int16)tfScl;
00156    CIGI_SCOPY2(CDta.h++, &tsScl);
00157 
00158    tfScl = Data->ZScale / 0.015625f;
00159    tsScl = (Cigi_int16)tfScl;
00160    CIGI_SCOPY2(CDta.h++, &tsScl);
00161 
00162    tfScl = Data->TimeScale / 0.015625f;
00163    tsScl = (Cigi_int16)tfScl;
00164    CIGI_SCOPY2(CDta.h++, &tsScl);
00165 
00166    *CDta.h++ = 0;
00167 
00168    CIGI_SCOPY2(CDta.s++, &Data->EffectCnt);
00169 
00170    CIGI_SCOPY4(CDta.f++, &Data->Separation);
00171    CIGI_SCOPY4(CDta.f++, &Data->BurstRate);
00172    CIGI_SCOPY4(CDta.f++, &Data->Duration);
00173 
00174    memcpy(Buff,tBuf,CIGI_SPEC_EFF_DEF_PACKET_SIZE_V2);
00175 
00176    return(PacketSize);
00177 
00178 }
00179 
00180 // ================================================
00181 // Unpack
00182 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00183 int CigiSpecEffDefV2::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00184 {
00185    double DBuf[6];
00186 
00187    Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00188 
00189    PackPointer CDta;
00190 
00191    memcpy(tBuf,Buff,CIGI_SPEC_EFF_DEF_PACKET_SIZE_V2);
00192 
00193    CDta.d = DBuf;
00194 
00195    CDta.c += 2;  // Step over packet id and size
00196 
00197    CIGI_SCOPY2(&EntityID, CDta.h++);
00198 
00199    Cigi_uint8 HDta = *CDta.c++;
00200    SeqDir = (SeqDirGrp)((HDta >> 7) & 0x01);
00201    ColorEn = ((HDta & 0x40) != 0);
00202 
00203    Red = *CDta.c++;
00204    Green = *CDta.c++;
00205    Blue = *CDta.c++;
00206 
00207    Cigi_int16 tsScl;
00208 
00209    CIGI_SCOPY2(&tsScl, CDta.h++);
00210    float tfScl = (float)tsScl;
00211    XScale = tfScl * 0.015625f;
00212 
00213    CIGI_SCOPY2(&tsScl, CDta.h++);
00214    tfScl = (float)tsScl;
00215    YScale = tfScl * 0.015625f;
00216 
00217    CIGI_SCOPY2(&tsScl, CDta.h++);
00218    tfScl = (float)tsScl;
00219    ZScale = tfScl * 0.015625f;
00220 
00221    CIGI_SCOPY2(&tsScl, CDta.h++);
00222    tfScl = (float)tsScl;
00223    TimeScale = tfScl * 0.015625f;
00224 
00225 
00226    CDta.h++;
00227 
00228    CIGI_SCOPY2(&EffectCnt, CDta.h++);
00229 
00230    CIGI_SCOPY4(&Separation, CDta.f++);
00231    CIGI_SCOPY4(&BurstRate, CDta.f++);
00232    CIGI_SCOPY4(&Duration, CDta.f++);
00233 
00234    return(PacketSize);
00235 
00236 }
00237 
00238 
00239 
00240 // ====================================================================
00241 // Accessors
00242 // ====================================================================
00243 
00244 

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