CigiShortCompCtrlV3_3.cpp

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

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