CigiCompCtrlV3.cpp

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

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