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