CigiShortCompCtrlV3.cpp

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

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