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