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