CigiCompCtrlV1.cpp

Go to the documentation of this file.
00001 
00066 #define _EXPORT_CCL_
00067 
00068 #include "CigiCompCtrlV1.h"
00069 #include "CigiSwapping.h"
00070 #include "CigiExceptions.h"
00071 
00072 #include <memory.h>
00073 
00074 
00075 #ifdef CIGI_LITTLE_ENDIAN
00076    #define CIGI_SCOPY2 CigiSwap2
00077    #define CIGI_SCOPY4 CigiSwap4
00078    #define CIGI_SCOPY8 CigiSwap8
00079 #else
00080    #define CIGI_SCOPY2 CigiCopy2
00081    #define CIGI_SCOPY4 CigiCopy4
00082    #define CIGI_SCOPY8 CigiCopy8
00083 #endif
00084 
00085 
00086 
00087 const CigiBaseCompCtrl::CompClassV3Grp CigiCompCtrlV1::CompClassV1xV3[CigiCompCtrlV1::CompClassCnvtSz] =
00088 {
00089    EntityV3,
00090    AtmosphereV3,
00091    ViewV3
00092 };
00093 
00094 
00095 // ====================================================================
00096 // Construction/Destruction
00097 // ====================================================================
00098 
00099 
00100 // ================================================
00101 // CigiCompCtrlV1
00102 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00103 CigiCompCtrlV1::CigiCompCtrlV1()
00104 {
00105 
00106    PacketID = CIGI_COMP_CTRL_PACKET_ID_V1;
00107    PacketSize = CIGI_COMP_CTRL_PACKET_SIZE_V1;
00108    Version = 1;
00109    MinorVersion = 0;
00110 
00111    CompID = 0;
00112    InstanceID = 0;
00113    EntityID = 0;
00114    ViewID = 0;
00115    CompState = 0;
00116    CompAssoc = Entity;
00117    CompClassV2 = EntityV2;
00118    CompClassV3 = EntityV3;
00119    CompData[0] = 0;
00120    CompData[1] = 0;
00121    CompData[2] = 0;
00122    CompData[3] = 0;
00123    CompData[4] = 0;
00124    CompData[5] = 0;
00125 
00126 }
00127 
00128 // ================================================
00129 // ~CigiCompCtrlV1
00130 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00131 CigiCompCtrlV1::~CigiCompCtrlV1()
00132 {
00133 
00134 }
00135 
00136 // ====================================================================
00137 // Pack and Unpack
00138 // ====================================================================
00139 
00140 // ================================================
00141 // Pack
00142 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00143 int CigiCompCtrlV1::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00144 {
00145    double DBuf[6];
00146 
00147    Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00148 
00149    PackPointer CDta;
00150 
00151    CigiBaseCompCtrl * Data = ( CigiBaseCompCtrl *)Base;
00152 
00153    CDta.d = DBuf;
00154 
00155    *CDta.c++ = PacketID;
00156    *CDta.c++ = PacketSize;
00157 
00158    CIGI_SCOPY2(CDta.s++, &Data->EntityID);
00159 
00160    Cigi_uint8 HDta = (Data->ViewID << 3) & 0xf8;
00161    HDta |= (Data->CompAssoc << 1) & 0x06;
00162    *CDta.c++ = HDta;
00163 
00164    *CDta.c++ = 0;
00165    *CDta.s++ = 0;
00166 
00167    CIGI_SCOPY2(CDta.s++, &Data->CompID);
00168    CIGI_SCOPY2(CDta.s++, &Data->CompState);
00169    CIGI_SCOPY4(CDta.l++, &Data->CompData[0]);
00170    CIGI_SCOPY4(CDta.l++, &Data->CompData[1]);
00171 
00172    memcpy(Buff,tBuf,CIGI_COMP_CTRL_PACKET_SIZE_V1);
00173 
00174    return(PacketSize);
00175 
00176 }
00177 
00178 // ================================================
00179 // Unpack
00180 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00181 int CigiCompCtrlV1::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00182 {
00183 
00184    double DBuf[6];
00185 
00186    Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00187 
00188    PackPointer CDta;
00189 
00190    memcpy(tBuf,Buff,CIGI_COMP_CTRL_PACKET_SIZE_V1);
00191 
00192    CDta.d = DBuf;
00193 
00194    CDta.c += 2;  // Step over packet id and size
00195 
00196    CIGI_SCOPY2(&EntityID, CDta.s++);
00197 
00198    Cigi_uint8 HDta = *CDta.c++;
00199    ViewID = (HDta >> 3) & 0x1f;
00200    CompAssoc = (CompAssocGrp)((HDta >> 1) & 0x03);
00201 
00202    CDta.c += 3;
00203    
00204    CIGI_SCOPY2(&CompID, CDta.s++);
00205    CIGI_SCOPY2(&CompState, CDta.s++);
00206    CIGI_SCOPY4(&CompData[0], CDta.l++);
00207    CIGI_SCOPY4(&CompData[1], CDta.l++);
00208 
00209 
00210    if((CompAssoc >= CigiBaseCompCtrl::Entity) &&
00211       (CompAssoc <= CigiBaseCompCtrl::View))
00212    {
00213       // The Component classes in V2 valued at 0, 1, & 2
00214       //   match the classes in V1 in value and purpose.
00215       CompClassV2 = (CompClassV2Grp)CompAssoc;
00216       CompClassV3 = CompClassV1xV3[(int)CompAssoc];
00217    }
00218    else
00219    {
00220       CompClassV2 = CigiBaseCompCtrl::NoCnvtV2;
00221       CompClassV3 = CigiBaseCompCtrl::NoCnvtV3;
00222    }
00223 
00224 
00225    return(PacketSize);
00226 
00227 }
00228 
00229 
00230 // ================================================
00231 // GetCnvt
00232 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00233 int CigiCompCtrlV1::GetCnvt(CigiVersionID &CnvtVersion,
00234                             CigiCnvtInfoType::Type &CnvtInfo)
00235 {
00236    CnvtInfo.ProcID = CigiProcessType::ProcStd;
00237 
00238    // Note: CIGI_ART_PART_CTRL_PACKET_ID_V1 &
00239    // CIGI_ART_PART_CTRL_PACKET_ID_V2 are the same
00240    if(CnvtVersion.CigiMajorVersion < 3)
00241       CnvtInfo.CnvtPacketID = CIGI_COMP_CTRL_PACKET_ID_V2;
00242    else
00243       CnvtInfo.CnvtPacketID = CIGI_SHORT_COMP_CTRL_PACKET_ID_V3;
00244 
00245    return(CIGI_SUCCESS);
00246 
00247 }
00248 
00249 
00250 
00251 // ====================================================================
00252 // Accessors
00253 // ====================================================================
00254 
00255 
00256 // ================================================
00257 // ViewID
00258 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00259 int CigiCompCtrlV1::SetViewID(const Cigi_uint8 ViewIDIn, bool bndchk)
00260 {
00261 
00262 #ifndef CIGI_NO_BND_CHK
00263    if(bndchk && (ViewIDIn > 31))
00264    {
00265 #ifndef CIGI_NO_EXCEPT
00266       throw CigiValueOutOfRangeException("ViewID",(Cigi_uint8)ViewIDIn,0,31);
00267 #endif
00268       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00269    }
00270 #endif
00271 
00272    ViewID = ViewIDIn;
00273    if(CompAssoc == CigiBaseCompCtrl::View)
00274       InstanceID = ViewID;
00275 
00276    return(CIGI_SUCCESS);
00277 
00278 }
00279 
00280 
00281 // ================================================
00282 // CompAssoc
00283 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00284 int CigiCompCtrlV1::SetCompAssoc(const CompAssocGrp CompAssocIn, bool bndchk)
00285 {
00286    // V1 to V3 Component Class conversion table
00287    const CompClassV3Grp Assoc2ClassV3[3] =
00288    {
00289       EntityV3,
00290       AtmosphereV3,
00291       ViewV3
00292    };
00293 
00294 
00295 #ifndef CIGI_NO_BND_CHK
00296    if(bndchk && ((CompAssocIn < 0)||(CompAssocIn > 3)))
00297    {
00298 #ifndef CIGI_NO_EXCEPT
00299       throw CigiValueOutOfRangeException("CompAssoc",(CompAssocGrp)CompAssocIn,0,3);
00300 #endif
00301       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00302    }
00303 #endif
00304 
00305    CompAssoc = CompAssocIn;
00306 
00307    CompClassV2 = (CompClassV2Grp)CompAssoc;
00308    CompClassV3 = CompClassV1xV3[CompAssocIn];
00309 
00310    if(CompAssoc == CigiBaseCompCtrl::Entity)
00311       InstanceID = EntityID;
00312    else if(CompAssoc == CigiBaseCompCtrl::View)
00313       InstanceID = ViewID;
00314    else
00315       InstanceID = 0;
00316 
00317    return(CIGI_SUCCESS);
00318 
00319 }
00320 
00321 
00322 // ================================================
00323 // SetCompData - Cigi_uint8
00324 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00325 int CigiCompCtrlV1::SetCompData(const Cigi_uint8 CompDataIn,
00326                     const unsigned int Word,
00327                     const BytePos Pos,
00328                     bool bndchk)
00329 {
00330 
00331    int Err = 0;
00332 
00333    if(Word > 1)
00334       Err = 1;
00335    else if((Pos < 0) || (Pos > 3))
00336       Err = 2;
00337 
00338    if(Err != 0)
00339    {
00340 #ifndef CIGI_NO_BND_CHK
00341       if(bndchk)
00342       {
00343 #ifndef CIGI_NO_EXCEPT
00344          if(Err == 1)
00345             throw CigiValueOutOfRangeException("Word",Word,0,1);
00346          else
00347             throw CigiValueOutOfRangeException("Pos",Pos,0,3);
00348 #endif
00349       }
00350 #endif
00351       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00352    }
00353 
00354 
00355    int bitPos = Pos * 8;
00356 
00357    Cigi_uint32 tDta = (Cigi_uint32)CompDataIn;
00358 
00359    CompData[Word] &= ~(0x000000ff << bitPos);
00360    CompData[Word] |= ((tDta & 0x000000ff) << bitPos);
00361 
00362    return(CIGI_SUCCESS);
00363 }
00364 
00365 
00366 // ================================================
00367 // SetCompData - Cigi_int8
00368 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00369 int CigiCompCtrlV1::SetCompData(const Cigi_int8 CompDataIn,
00370                     const unsigned int Word,
00371                     const BytePos Pos,
00372                     bool bndchk)
00373 {
00374 
00375    union {
00376       Cigi_uint8 uc;
00377       Cigi_int8 sc;
00378    } cxfer;
00379 
00380    int Err = 0;
00381 
00382    if(Word > 1)
00383       Err = 1;
00384    else if((Pos < 0) || (Pos > 3))
00385       Err = 2;
00386 
00387    if(Err != 0)
00388    {
00389 #ifndef CIGI_NO_BND_CHK
00390       if(bndchk)
00391       {
00392 #ifndef CIGI_NO_EXCEPT
00393          if(Err == 1)
00394             throw CigiValueOutOfRangeException("Word",Word,0,1);
00395          else
00396             throw CigiValueOutOfRangeException("Pos",Pos,0,3);
00397 #endif
00398       }
00399 #endif
00400       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00401    }
00402 
00403 
00404    int bitPos = Pos * 8;
00405 
00406    cxfer.sc = CompDataIn;
00407    Cigi_uint32 tDta = (Cigi_uint32)cxfer.uc;
00408 
00409    CompData[Word] &= ~(0x000000ff << bitPos);
00410    CompData[Word] |= ((tDta & 0x000000ff) << bitPos);
00411 
00412    return(CIGI_SUCCESS);
00413 }
00414 
00415 
00416 // ================================================
00417 // SetCompData - Cigi_uint16
00418 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00419 int CigiCompCtrlV1::SetCompData(const Cigi_uint16 CompDataIn,
00420                     const unsigned int Word,
00421                     const HalfWordPos Pos,
00422                     bool bndchk)
00423 {
00424 
00425    int Err = 0;
00426 
00427    if(Word > 1)
00428       Err = 1;
00429    else if((Pos < 0) || (Pos > 1))
00430       Err = 2;
00431 
00432    if(Err != 0)
00433    {
00434 #ifndef CIGI_NO_BND_CHK
00435       if(bndchk)
00436       {
00437 #ifndef CIGI_NO_EXCEPT
00438          if(Err == 1)
00439             throw CigiValueOutOfRangeException("Word",Word,0,1);
00440          else
00441             throw CigiValueOutOfRangeException("Pos",Pos,0,3);
00442 #endif
00443       }
00444 #endif
00445       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00446    }
00447 
00448 
00449    int bitPos = Pos * 16;
00450 
00451    Cigi_uint32 tDta = (Cigi_uint32)CompDataIn;
00452 
00453    CompData[Word] &= ~(0x0000ffff << bitPos);
00454    CompData[Word] |= ((tDta & 0x0000ffff) << bitPos);
00455 
00456    return(CIGI_SUCCESS);
00457 }
00458 
00459 
00460 // ================================================
00461 // SetCompData - short
00462 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00463 int CigiCompCtrlV1::SetCompData(const Cigi_int16 CompDataIn,
00464                     const unsigned int Word,
00465                     const HalfWordPos Pos,
00466                     bool bndchk)
00467 {
00468 
00469    union {
00470       Cigi_int16 s16;
00471       Cigi_uint16 u16;
00472    } sxfer;
00473 
00474    int Err = 0;
00475 
00476    if(Word > 1)
00477       Err = 1;
00478    else if((Pos < 0) || (Pos > 1))
00479       Err = 2;
00480 
00481    if(Err != 0)
00482    {
00483 #ifndef CIGI_NO_BND_CHK
00484       if(bndchk)
00485       {
00486 #ifndef CIGI_NO_EXCEPT
00487          if(Err == 1)
00488             throw CigiValueOutOfRangeException("Word",Word,0,1);
00489          else
00490             throw CigiValueOutOfRangeException("Pos",Pos,0,3);
00491 #endif
00492       }
00493 #endif
00494       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00495    }
00496 
00497 
00498    int bitPos = Pos * 16;
00499 
00500    sxfer.s16 = CompDataIn;
00501    Cigi_uint32 tDta = (Cigi_uint32)sxfer.u16;
00502 
00503    CompData[Word] &= ~(0x0000ffff << bitPos);
00504    CompData[Word] |= ((tDta & 0x0000ffff) << bitPos);
00505 
00506    return(CIGI_SUCCESS);
00507 }
00508 
00509 
00510 // ================================================
00511 // SetCompData - Cigi_uint32
00512 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00513 int CigiCompCtrlV1::SetCompData(const Cigi_uint32 CompDataIn,
00514                 const unsigned int Word,
00515                 bool bndchk)
00516 {
00517 
00518    if(Word > 1)
00519    {
00520 #ifndef CIGI_NO_BND_CHK
00521       if(bndchk)
00522       {
00523 #ifndef CIGI_NO_EXCEPT
00524          throw CigiValueOutOfRangeException("Word",Word,0,1);
00525 #endif
00526       }
00527 #endif
00528       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00529    }
00530 
00531 
00532    CompData[Word] = CompDataIn;
00533 
00534    return(CIGI_SUCCESS);
00535 }
00536 
00537 
00538 // ================================================
00539 // SetCompData - long
00540 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00541 int CigiCompCtrlV1::SetCompData(const Cigi_int32 CompDataIn,
00542                 const unsigned int Word,
00543                 bool bndchk)
00544 {
00545 
00546    union {
00547       Cigi_int32 s32;
00548       Cigi_uint32 u32;
00549    } tDta;
00550 
00551    if(Word > 1)
00552    {
00553 #ifndef CIGI_NO_BND_CHK
00554       if(bndchk)
00555       {
00556 #ifndef CIGI_NO_EXCEPT
00557          throw CigiValueOutOfRangeException("Word",Word,0,1);
00558 #endif
00559       }
00560 #endif
00561       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00562    }
00563 
00564 
00565    tDta.s32 = CompDataIn;
00566    CompData[Word] = (Cigi_uint32)tDta.u32;
00567 
00568    return(CIGI_SUCCESS);
00569 }
00570 
00571 
00572 // ================================================
00573 // SetCompData - float
00574 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00575 int CigiCompCtrlV1::SetCompData(const float CompDataIn,
00576                 const unsigned int Word,
00577                 bool bndchk)
00578 {
00579 
00580    if(Word > 1)
00581    {
00582 #ifndef CIGI_NO_BND_CHK
00583       if(bndchk)
00584       {
00585 #ifndef CIGI_NO_EXCEPT
00586          throw CigiValueOutOfRangeException("Word",Word,0,1);
00587 #endif
00588       }
00589 #endif
00590       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00591    }
00592 
00593 
00594    union DtaXfer {
00595       Cigi_uint32 lDta;
00596       float fDta;
00597    } XDta;
00598 
00599    XDta.fDta = CompDataIn;
00600    CompData[Word] = XDta.lDta;
00601 
00602    return(CIGI_SUCCESS);
00603 }
00604 
00605 
00606 // ================================================
00607 // SetCompData  - Cigi_uint64
00608 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00609 int CigiCompCtrlV1::SetCompData(const Cigi_uint64 CompDataIn,
00610                 const unsigned int Pos,
00611                 bool bndchk)
00612 {
00613 
00614    if(Pos > 0)
00615    {
00616 #ifndef CIGI_NO_BND_CHK
00617       if(bndchk)
00618       {
00619 #ifndef CIGI_NO_EXCEPT
00620          throw CigiValueOutOfRangeException("Pos",Pos,0,0);
00621 #endif
00622       }
00623 #endif
00624       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00625    }
00626 
00627 
00628    int Word = Pos * 2;
00629 
00630    CompData[Word++] = (Cigi_uint32)((CompDataIn >> 32) & _I64_CONST_(0x00000000ffffffff));
00631    CompData[Word] = (Cigi_uint32)(CompDataIn & _I64_CONST_(0x00000000ffffffff));
00632 
00633    return(CIGI_SUCCESS);
00634 }
00635 
00636 
00637 // ================================================
00638 // SetCompData - double
00639 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00640 int CigiCompCtrlV1::SetCompData(const double CompDataIn,
00641                 const unsigned int Pos,
00642                 bool bndchk)
00643 {
00644 
00645    if(Pos > 0)
00646    {
00647 #ifndef CIGI_NO_BND_CHK
00648       if(bndchk)
00649       {
00650 #ifndef CIGI_NO_EXCEPT
00651          throw CigiValueOutOfRangeException("Pos",Pos,0,0);
00652 #endif
00653       }
00654 #endif
00655       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00656    }
00657 
00658    union DtaXfer {
00659       Cigi_uint64 i;
00660       double d;
00661    } XDta;
00662 
00663    XDta.d = CompDataIn;
00664 
00665    int Word = Pos * 2;
00666 
00667    CompData[Word++] = (Cigi_uint32)((XDta.i >> 32) & _I64_CONST_(0x00000000ffffffff));
00668    CompData[Word] = (Cigi_uint32)(XDta.i & _I64_CONST_(0x00000000ffffffff));
00669 
00670 
00671    return(CIGI_SUCCESS);
00672 }
00673 
00674 
00675 
00676 
00677 
00678 
00679 
00680 // ================================================
00681 // GetUCharCompData
00682 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00683 Cigi_uint8 CigiCompCtrlV1::GetUCharCompData(const unsigned int Word,
00684                                const BytePos Pos)
00685 {
00686 
00687    Cigi_uint8 tDta;
00688 
00689    int Err = 0;
00690 
00691    if(Word > 1)
00692       Err = 1;
00693    else if((Pos < 0) || (Pos > 3))
00694       Err = 2;
00695 
00696    if(Err != 0)
00697    {
00698 #ifndef CIGI_NO_EXCEPT
00699       if(Err == 1)
00700          throw CigiValueOutOfRangeException("Word",Word,0,1);
00701       else
00702          throw CigiValueOutOfRangeException("Pos",Pos,0,3);
00703 #endif
00704 
00705       tDta = 0;
00706    }
00707    else
00708       tDta = (Cigi_uint8)((CompData[Word] >> (Pos * 8)) & 0x000000ff);
00709 
00710    return(tDta);
00711 }
00712 
00713 
00714 // ================================================
00715 // GetCharCompData
00716 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00717 Cigi_int8 CigiCompCtrlV1::GetCharCompData(const unsigned int Word,
00718                      const BytePos Pos)
00719 {
00720    union {
00721       Cigi_int8 sc;
00722       Cigi_uint8 uc;
00723    } tDta;
00724 
00725    int Err = 0;
00726 
00727    if(Word > 1)
00728       Err = 1;
00729    else if((Pos < 0) || (Pos > 3))
00730       Err = 2;
00731 
00732    if(Err != 0)
00733    {
00734 #ifndef CIGI_NO_EXCEPT
00735       if(Err == 1)
00736          throw CigiValueOutOfRangeException("Word",Word,0,1);
00737       else
00738          throw CigiValueOutOfRangeException("Pos",Pos,0,3);
00739 #endif
00740 
00741       tDta.uc = 0;
00742    }
00743    else
00744       tDta.uc = (Cigi_uint8)((CompData[Word] >> (Pos * 8)) & 0x000000ff);
00745 
00746    return(tDta.sc);
00747 }
00748 
00749 
00750 // ================================================
00751 // GetUShortCompData
00752 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00753 Cigi_uint16 CigiCompCtrlV1::GetUShortCompData(const unsigned int Word,
00754                                  const HalfWordPos Pos)
00755 {
00756    Cigi_uint16 tDta;
00757 
00758    int Err = 0;
00759 
00760    if(Word > 1)
00761       Err = 1;
00762    else if((Pos < 0) || (Pos > 1))
00763       Err = 2;
00764 
00765    if(Err != 0)
00766    {
00767 #ifndef CIGI_NO_EXCEPT
00768       if(Err == 1)
00769          throw CigiValueOutOfRangeException("Word",Word,0,1);
00770       else
00771          throw CigiValueOutOfRangeException("Pos",Pos,0,1);
00772 #endif
00773 
00774       tDta = 0;
00775    }
00776    else
00777       tDta = (Cigi_uint16)((CompData[Word] >> (Pos * 16)) & 0x0000ffff);
00778 
00779    return(tDta);
00780 }
00781 
00782 
00783 // ================================================
00784 // GetShortCompData
00785 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00786 Cigi_int16 CigiCompCtrlV1::GetShortCompData(const unsigned int Word,
00787                        const HalfWordPos Pos)
00788 {
00789 
00790    union {
00791       Cigi_int16 s16;
00792       Cigi_uint16 u16;
00793    } tDta;
00794 
00795    int Err = 0;
00796 
00797    if(Word > 1)
00798       Err = 1;
00799    else if((Pos < 0) || (Pos > 1))
00800       Err = 2;
00801 
00802    if(Err != 0)
00803    {
00804 #ifndef CIGI_NO_EXCEPT
00805       if(Err == 1)
00806          throw CigiValueOutOfRangeException("Word",Word,0,1);
00807       else
00808          throw CigiValueOutOfRangeException("Pos",Pos,0,1);
00809 #endif
00810 
00811       tDta.u16 = 0;
00812    }
00813    else
00814       tDta.u16 = (Cigi_uint16)((CompData[Word] >> (Pos * 16)) & 0x0000ffff);
00815 
00816    return(tDta.s16);
00817 }
00818 
00819 
00820 // ================================================
00821 // GetULongCompData
00822 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00823 Cigi_uint32 CigiCompCtrlV1::GetULongCompData(const unsigned int Word)
00824 {
00825 
00826    Cigi_uint32 tDta;
00827 
00828 
00829    if(Word > 1)
00830    {
00831 #ifndef CIGI_NO_EXCEPT
00832       throw CigiValueOutOfRangeException("Word",Word,0,1);
00833 #endif
00834 
00835       tDta = 0;
00836    }
00837    else
00838       tDta = CompData[Word];
00839 
00840    return(tDta);
00841 }
00842 
00843 
00844 
00845 // ================================================
00846 // GetLongCompData
00847 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00848 Cigi_int32 CigiCompCtrlV1::GetLongCompData(const unsigned int Word)
00849 {
00850 
00851    union {
00852       Cigi_int32 s32;
00853       Cigi_uint32 u32;
00854    } tDta;
00855 
00856    if(Word > 1)
00857    {
00858 #ifndef CIGI_NO_EXCEPT
00859       throw CigiValueOutOfRangeException("Word",Word,0,1);
00860 #endif
00861 
00862       tDta.u32 = 0;
00863    }
00864    else
00865       tDta.u32 = (Cigi_uint32)(CompData[Word]);
00866 
00867    return(tDta.s32);
00868 }
00869 
00870 
00871 
00872 // ================================================
00873 // GetFloatCompData
00874 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00875 float CigiCompCtrlV1::GetFloatCompData(const unsigned int Word)
00876 {
00877 
00878    union {
00879       float f32;
00880       Cigi_uint32 u32;
00881    } tDta;
00882 
00883    if(Word > 1)
00884    {
00885 #ifndef CIGI_NO_EXCEPT
00886       throw CigiValueOutOfRangeException("Word",Word,0,1);
00887 #endif
00888 
00889       tDta.u32 = 0;
00890    }
00891    else
00892       tDta.u32 = (Cigi_uint32)(CompData[Word]);
00893 
00894    return(tDta.f32);
00895 }
00896 
00897 
00898 
00899 // ================================================
00900 // GetI64CompData
00901 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00902 Cigi_uint64 CigiCompCtrlV1::GetI64CompData(const unsigned int Pos)
00903 {
00904 
00905    Cigi_uint64 tDta;
00906 
00907    if(Pos > 0)
00908    {
00909 #ifndef CIGI_NO_EXCEPT
00910       throw CigiValueOutOfRangeException("Pos",Pos,0,0);
00911 #endif
00912 
00913       tDta = 0;
00914    }
00915    else
00916    {
00917       int Word = Pos * 2;
00918       Cigi_uint64 tDtah = (Cigi_uint64)(CompData[Word++]);
00919       tDtah = (tDtah << 32) & _I64_CONST_(0xffffffff00000000);
00920 
00921       Cigi_uint64 tDtal = (Cigi_uint64)(CompData[Word]);
00922       tDtal &= _I64_CONST_(0x00000000ffffffff);
00923 
00924       tDta = tDtah | tDtal;
00925    }
00926 
00927 
00928    return(tDta);
00929 }
00930 
00931 
00932 
00933 // ================================================
00934 // GetDoubleCompData
00935 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00936 double CigiCompCtrlV1::GetDoubleCompData(const unsigned int Pos)
00937 {
00938 
00939    union DtaXfer {
00940       Cigi_uint64 i;
00941       double d;
00942    } XDta;
00943 
00944    if(Pos > 1)
00945    {
00946 #ifndef CIGI_NO_EXCEPT
00947       throw CigiValueOutOfRangeException("Pos",Pos,0,0);
00948 #endif
00949 
00950       XDta.d = 0.0;
00951    }
00952    else
00953    {
00954 
00955       int Word = Pos * 2;
00956       Cigi_uint64 tDtah = (Cigi_uint64)(CompData[Word++]);
00957       tDtah = (tDtah << 32) & _I64_CONST_(0xffffffff00000000);
00958 
00959       Cigi_uint64 tDtal = (Cigi_uint64)(CompData[Word]);
00960       tDtal &= _I64_CONST_(0x00000000ffffffff);
00961 
00962       XDta.i = tDtah | tDtal;
00963 
00964    }
00965 
00966    return(XDta.d);
00967 }
00968 
00969 

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