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