00001
00059 #define _EXPORT_CCL_
00060
00061 #include "CigiLosSegReqV3.h"
00062 #include "CigiSwapping.h"
00063 #include "CigiExceptions.h"
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 CigiLosSegReqV3::CigiLosSegReqV3()
00075 {
00076
00077 PacketID = CIGI_LOS_SEG_REQ_PACKET_ID_V3;
00078 PacketSize = CIGI_LOS_SEG_REQ_PACKET_SIZE_V3;
00079 Version = 3;
00080 MinorVersion = 0;
00081
00082 LosID = 0;
00083 ReqType = Basic;
00084 SrcCoordSys = Geodetic;
00085 DstCoordSys = Geodetic;
00086 ResponseCoordSys = Geodetic;
00087 AlphaThresh = 0;
00088 EntityID = 0;
00089 SrcXLat = 0.0;
00090 SrcYLon = 0.0;
00091 SrcZAlt = 0.0;
00092 DstXLat = 0.0;
00093 DstYLon = 0.0;
00094 DstZAlt = 0.0;
00095 Mask = 0;
00096 DestEntityIDValid = false;
00097 UpdatePeriod = 0;
00098 DestEntityID = 0;
00099 ValidV1or2 = true;
00100
00101 }
00102
00103
00104
00105
00106 CigiLosSegReqV3::~CigiLosSegReqV3()
00107 {
00108
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00118 int CigiLosSegReqV3::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00119 {
00120 PackPointer CDta;
00121
00122 CigiBaseLosSegReq * Data = ( CigiBaseLosSegReq *)Base;
00123
00124 CDta.c = Buff;
00125
00126 *CDta.c++ = PacketID;
00127 *CDta.c++ = PacketSize;
00128
00129 *CDta.s++ = Data->LosID;
00130
00131 Cigi_uint8 HDta = (Data->ReqType == Basic) ? 0x00 : 0x01;
00132 HDta |= (Data->SrcCoordSys == Geodetic) ? 0x00 : 0x02;
00133 HDta |= (Data->DstCoordSys == Geodetic) ? 0x00 : 0x04;
00134 HDta |= (Data->ResponseCoordSys == Geodetic) ? 0x00 : 0x08;
00135 *CDta.c++ = HDta;
00136
00137 *CDta.c++ = Data->AlphaThresh;
00138 *CDta.s++ = Data->EntityID;
00139 *CDta.d++ = Data->SrcXLat;
00140 *CDta.d++ = Data->SrcYLon;
00141 *CDta.d++ = Data->SrcZAlt;
00142 *CDta.d++ = Data->DstXLat;
00143 *CDta.d++ = Data->DstYLon;
00144 *CDta.d++ = Data->DstZAlt;
00145 *CDta.l++ = Data->Mask;
00146 *CDta.l++ = 0;
00147
00148 return(PacketSize);
00149
00150 }
00151
00152
00153
00154
00155 int CigiLosSegReqV3::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00156 {
00157 PackPointer CDta;
00158
00159 CDta.c = Buff;
00160
00161 CDta.c += 2;
00162
00163 if(!Swap)
00164 {
00165 LosID = *CDta.s++;
00166
00167 Cigi_uint16 HDta = *CDta.c++;
00168 ReqType = (ReqTypeGrp)(HDta & 0x01);
00169 SrcCoordSys = (CoordSysGrp)((HDta >> 1) & 0x01);
00170 DstCoordSys = (CoordSysGrp)((HDta >> 2) & 0x01);
00171 ResponseCoordSys = (CoordSysGrp)((HDta >> 3) & 0x01);
00172
00173 AlphaThresh = *CDta.c++;
00174 EntityID = *CDta.s++;
00175 SrcXLat = *CDta.d++;
00176 SrcYLon = *CDta.d++;
00177 SrcZAlt = *CDta.d++;
00178 DstXLat = *CDta.d++;
00179 DstYLon = *CDta.d++;
00180 DstZAlt = *CDta.d++;
00181 Mask = *CDta.l++;
00182 }
00183 else
00184 {
00185 CigiSwap2(&LosID, CDta.s++);
00186
00187 Cigi_uint16 HDta = *CDta.c++;
00188 ReqType = (ReqTypeGrp)(HDta & 0x01);
00189 SrcCoordSys = (CoordSysGrp)((HDta >> 1) & 0x01);
00190 DstCoordSys = (CoordSysGrp)((HDta >> 2) & 0x01);
00191 ResponseCoordSys = (CoordSysGrp)((HDta >> 3) & 0x01);
00192
00193 AlphaThresh = *CDta.c++;
00194 CigiSwap2(&EntityID, CDta.s++);
00195 CigiSwap8(&SrcXLat, CDta.d++);
00196 CigiSwap8(&SrcYLon, CDta.d++);
00197 CigiSwap8(&SrcZAlt, CDta.d++);
00198 CigiSwap8(&DstXLat, CDta.d++);
00199 CigiSwap8(&DstYLon, CDta.d++);
00200 CigiSwap8(&DstZAlt, CDta.d++);
00201 CigiSwap4(&Mask, CDta.l++);
00202 }
00203
00204
00205 ValidV1or2 = ((SrcCoordSys == Geodetic)&&
00206 (DstCoordSys == Geodetic));
00207
00208
00209 DestEntityIDValid = false;
00210 UpdatePeriod = 0;
00211 DestEntityID = 0;
00212
00213 return(PacketSize);
00214
00215 }
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 int CigiLosSegReqV3::SetReqType(const ReqTypeGrp ReqTypeIn, bool bndchk)
00228 {
00229
00230 #ifndef CIGI_NO_BND_CHK
00231 if(bndchk && ((ReqTypeIn < 0)||(ReqTypeIn > 1)))
00232 {
00233 #ifndef CIGI_NO_EXCEPT
00234 throw CigiValueOutOfRangeException("ReqType",(ReqTypeGrp)ReqTypeIn,0,1);
00235 #endif
00236 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00237 }
00238 #endif
00239
00240 ReqType = ReqTypeIn;
00241 return(CIGI_SUCCESS);
00242
00243 }
00244
00245
00246
00247
00248
00249 int CigiLosSegReqV3::SetSrcCoordSys(const CoordSysGrp SrcCoordSysIn, bool bndchk)
00250 {
00251
00252 #ifndef CIGI_NO_BND_CHK
00253 if(bndchk && ((SrcCoordSysIn < 0)||(SrcCoordSysIn > 1)))
00254 {
00255 #ifndef CIGI_NO_EXCEPT
00256 throw CigiValueOutOfRangeException("SrcCoordSys",(CoordSysGrp)SrcCoordSysIn,0,1);
00257 #endif
00258 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00259 }
00260 #endif
00261
00262 SrcCoordSys = SrcCoordSysIn;
00263
00264 ValidV1or2 = ((SrcCoordSys == Geodetic)&&
00265 (DstCoordSys == Geodetic));
00266
00267 return(CIGI_SUCCESS);
00268
00269 }
00270
00271
00272
00273
00274
00275 int CigiLosSegReqV3::SetDstCoordSys(const CoordSysGrp DstCoordSysIn, bool bndchk)
00276 {
00277
00278 #ifndef CIGI_NO_BND_CHK
00279 if(bndchk && ((DstCoordSysIn < 0)||(DstCoordSysIn > 1)))
00280 {
00281 #ifndef CIGI_NO_EXCEPT
00282 throw CigiValueOutOfRangeException("DstCoordSys",(CoordSysGrp)DstCoordSysIn,0,1);
00283 #endif
00284 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00285 }
00286 #endif
00287
00288 DstCoordSys = DstCoordSysIn;
00289
00290 ValidV1or2 = ((SrcCoordSys == Geodetic)&&
00291 (DstCoordSys == Geodetic));
00292
00293 return(CIGI_SUCCESS);
00294
00295 }
00296
00297
00298
00299
00300
00301 int CigiLosSegReqV3::SetResponseCoordSys(const CoordSysGrp ResponseCoordSysIn, bool bndchk)
00302 {
00303
00304 #ifndef CIGI_NO_BND_CHK
00305 if(bndchk && ((ResponseCoordSysIn < 0)||(ResponseCoordSysIn > 1)))
00306 {
00307 #ifndef CIGI_NO_EXCEPT
00308 throw CigiValueOutOfRangeException("ResponseCoordSys",(CoordSysGrp)ResponseCoordSysIn,0,1);
00309 #endif
00310 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00311 }
00312 #endif
00313
00314 ResponseCoordSys = ResponseCoordSysIn;
00315 return(CIGI_SUCCESS);
00316
00317 }
00318
00319