00001
00062 #define _EXPORT_CCL_
00063
00064 #include "CigiHatHotReqV3.h"
00065 #include "CigiSwapping.h"
00066 #include "CigiExceptions.h"
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 CigiHatHotReqV3::CigiHatHotReqV3()
00078 {
00079
00080 PacketID = CIGI_HAT_HOT_REQ_PACKET_ID_V3;
00081 PacketSize = CIGI_HAT_HOT_REQ_PACKET_SIZE_V3;
00082 Version = 3;
00083 MinorVersion = 0;
00084
00085 HatHotID = 0;
00086 ReqType = HAT;
00087 SrcCoordSys = Geodetic;
00088 UpdatePeriod = 0;
00089 EntityID = 0;
00090 LatOrXoff = 0.0;
00091 LonOrYoff = 0.0;
00092 AltOrZoff = 0.0;
00093 IsValidV1or2 = true;
00094
00095 }
00096
00097
00098
00099
00100 CigiHatHotReqV3::~CigiHatHotReqV3()
00101 {
00102
00103 }
00104
00105
00106
00107
00108
00109
00110
00111
00112 int CigiHatHotReqV3::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00113 {
00114 PackPointer CDta;
00115
00116 CigiBaseHatHotReq * Data = ( CigiBaseHatHotReq *)Base;
00117
00118 CDta.c = Buff;
00119
00120 *CDta.c++ = PacketID;
00121 *CDta.c++ = PacketSize;
00122
00123 *CDta.s++ = Data->HatHotID;
00124
00125 Cigi_uint8 HDta = (Cigi_uint8)(Data->ReqType & 0x03);
00126 HDta |= (Cigi_uint8)((Data->SrcCoordSys << 2) & 0x04);
00127 *CDta.c++ = HDta;
00128
00129 *CDta.c++ = 0;
00130
00131 *CDta.s++ = Data->EntityID;
00132 *CDta.d++ = Data->LatOrXoff;
00133 *CDta.d++ = Data->LonOrYoff;
00134 *CDta.d++ = Data->AltOrZoff;
00135
00136 return(PacketSize);
00137
00138 }
00139
00140
00141
00142
00143 int CigiHatHotReqV3::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00144 {
00145 PackPointer CDta;
00146
00147 CDta.c = Buff;
00148
00149 CDta.c += 2;
00150
00151 if(!Swap)
00152 {
00153 HatHotID = *CDta.s++;
00154
00155 Cigi_uint8 HDta = *CDta.c++;
00156 ReqType = (ReqTypeGrp)(HDta & 0x03);
00157 SrcCoordSys = (CoordSysGrp)((HDta >> 2) & 0x01);
00158
00159 CDta.c++;
00160
00161 EntityID = *CDta.s++;
00162 LatOrXoff = *CDta.d++;
00163 LonOrYoff = *CDta.d++;
00164 AltOrZoff = *CDta.d++;
00165 }
00166 else
00167 {
00168 CigiSwap2(&HatHotID, CDta.s++);
00169
00170 Cigi_uint8 HDta = *CDta.c++;
00171 ReqType = (ReqTypeGrp)(HDta & 0x03);
00172 SrcCoordSys = (CoordSysGrp)((HDta >> 2) & 0x01);
00173
00174 CDta.c++;
00175
00176 CigiSwap2(&EntityID, CDta.s++);
00177 CigiSwap8(&LatOrXoff, CDta.d++);
00178 CigiSwap8(&LonOrYoff, CDta.d++);
00179 CigiSwap8(&AltOrZoff, CDta.d++);
00180 }
00181
00182 IsValidV1or2 = (SrcCoordSys == Geodetic);
00183
00184 UpdatePeriod = 0;
00185
00186 return(PacketSize);
00187
00188 }
00189
00190
00191
00192
00193
00194 int CigiHatHotReqV3::GetCnvt(CigiVersionID &CnvtVersion,
00195 CigiCnvtInfoType::Type &CnvtInfo)
00196 {
00197 CnvtInfo.ProcID = CigiProcessType::TwoPassCnvtProcStd;
00198
00199 switch(CnvtVersion.CigiMajorVersion)
00200 {
00201 case 1:
00202 CnvtInfo.CnvtPacketID = CIGI_HAT_REQ_PACKET_ID_V1;
00203 break;
00204 case 2:
00205 if(ReqType == CigiBaseHatHotReq::HAT)
00206 CnvtInfo.CnvtPacketID = CIGI_HAT_REQ_PACKET_ID_V2;
00207 else
00208 CnvtInfo.CnvtPacketID = CIGI_HOT_REQ_PACKET_ID_V2;
00209 break;
00210 default:
00211
00212 CnvtInfo.CnvtPacketID = CIGI_HAT_HOT_REQ_PACKET_ID_V3;
00213 break;
00214 }
00215
00216 return(CIGI_SUCCESS);
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 int CigiHatHotReqV3::SetReqType(const ReqTypeGrp ReqTypeIn, bool bndchk)
00230 {
00231
00232 #ifndef CIGI_NO_BND_CHK
00233 if(bndchk && ((ReqTypeIn < 0)||(ReqTypeIn > 2)))
00234 {
00235 #ifndef CIGI_NO_EXCEPT
00236 throw CigiValueOutOfRangeException("ReqType",(ReqTypeGrp)ReqTypeIn,0,2);
00237 #endif
00238 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00239 }
00240 #endif
00241
00242 ReqType = ReqTypeIn;
00243 return(CIGI_SUCCESS);
00244
00245 }
00246
00247
00248
00249
00250
00251 int CigiHatHotReqV3::SetSrcCoordSys(const CoordSysGrp SrcCoordSysIn, bool bndchk)
00252 {
00253
00254 #ifndef CIGI_NO_BND_CHK
00255 if(bndchk && ((SrcCoordSysIn < 0)||(SrcCoordSysIn > 1)))
00256 {
00257 #ifndef CIGI_NO_EXCEPT
00258 throw CigiValueOutOfRangeException("SrcCoordSys",(CoordSysGrp)SrcCoordSysIn,0,1);
00259 #endif
00260 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00261 }
00262 #endif
00263
00264 SrcCoordSys = SrcCoordSysIn;
00265 return(CIGI_SUCCESS);
00266
00267 }
00268
00269