00001
00060 #define _EXPORT_CCL_
00061
00062 #include "CigiLosVectReqV2.h"
00063 #include "CigiSwapping.h"
00064 #include "CigiExceptions.h"
00065
00066 #include <memory.h>
00067
00068
00069 #ifdef CIGI_LITTLE_ENDIAN
00070 #define CIGI_SCOPY2 CigiSwap2
00071 #define CIGI_SCOPY4 CigiSwap4
00072 #define CIGI_SCOPY8 CigiSwap8
00073 #else
00074 #define CIGI_SCOPY2 CigiCopy2
00075 #define CIGI_SCOPY4 CigiCopy4
00076 #define CIGI_SCOPY8 CigiCopy8
00077 #endif
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 CigiLosVectReqV2::CigiLosVectReqV2()
00091 {
00092
00093 PacketID = CIGI_LOS_VECT_REQ_PACKET_ID_V2;
00094 PacketSize = CIGI_LOS_VECT_REQ_PACKET_SIZE_V2;
00095 Version = 2;
00096 MinorVersion = 0;
00097
00098 LosID = 0;
00099 ReqType = Extended;
00100 SrcCoordSys = Geodetic;
00101 ResponseCoordSys = Geodetic;
00102 AlphaThresh = 0;
00103 EntityID = 0;
00104 VectAz = 0.0;
00105 VectEl = 0.0;
00106 MinRange = 0.0;
00107 MaxRange = 0.0;
00108 SrcXLat = 0.0;
00109 SrcYLon = 0.0;
00110 SrcZAlt = 0.0;
00111 Mask = 0;
00112 UpdatePeriod = 0;
00113 ValidV1or2 = true;
00114
00115 }
00116
00117
00118
00119
00120 CigiLosVectReqV2::~CigiLosVectReqV2()
00121 {
00122
00123 }
00124
00125
00126
00127
00128
00129
00130
00131
00132 int CigiLosVectReqV2::Pack(CigiBasePacket * Base, Cigi_uint8 * Buff, void *Spec) const
00133 {
00134 double DBuf[6];
00135
00136 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00137
00138 PackPointer CDta;
00139
00140 CigiBaseLosVectReq * Data = ( CigiBaseLosVectReq *)Base;
00141
00142 if(!Data->ValidV1or2)
00143 return(0);
00144
00145 CDta.d = DBuf;
00146
00147 *CDta.c++ = PacketID;
00148 *CDta.c++ = PacketSize;
00149
00150 CIGI_SCOPY2(CDta.s++, &Data->LosID);
00151
00152 if(Data->VectAz < 0.0f)
00153 Data->VectAz += 360.0f;
00154
00155 CIGI_SCOPY4(CDta.f++, &Data->VectAz);
00156
00157 CIGI_SCOPY4(CDta.f++, &Data->VectEl);
00158
00159 *CDta.l++ = 0;
00160
00161 CIGI_SCOPY4(CDta.f++, &Data->MinRange);
00162 CIGI_SCOPY4(CDta.f++, &Data->MaxRange);
00163 CIGI_SCOPY8(CDta.d++, &Data->SrcZAlt);
00164 CIGI_SCOPY8(CDta.d++, &Data->SrcXLat);
00165 CIGI_SCOPY8(CDta.d++, &Data->SrcYLon);
00166
00167 memcpy(Buff,tBuf,CIGI_LOS_VECT_REQ_PACKET_SIZE_V2);
00168
00169 return(PacketSize);
00170
00171 }
00172
00173
00174
00175
00176 int CigiLosVectReqV2::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00177 {
00178 double DBuf[6];
00179
00180 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00181
00182 PackPointer CDta;
00183
00184 memcpy(tBuf,Buff,CIGI_LOS_VECT_REQ_PACKET_SIZE_V2);
00185
00186 CDta.d = DBuf;
00187
00188 CDta.c += 2;
00189
00190 CIGI_SCOPY2(&LosID, CDta.s++);
00191 CIGI_SCOPY4(&VectAz, CDta.f++);
00192 CIGI_SCOPY4(&VectEl, CDta.f++);
00193
00194 CDta.l++;
00195
00196 CIGI_SCOPY4(&MinRange, CDta.f++);
00197 CIGI_SCOPY4(&MaxRange, CDta.f++);
00198 CIGI_SCOPY8(&SrcZAlt, CDta.d++);
00199 CIGI_SCOPY8(&SrcXLat, CDta.d++);
00200 CIGI_SCOPY8(&SrcYLon, CDta.d++);
00201
00202 UpdatePeriod = 0;
00203
00204 ValidV1or2 = true;
00205
00206 return(PacketSize);
00207
00208 }
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 int CigiLosVectReqV2::SetVectAz(const float VectAzIn, bool bndchk)
00221 {
00222
00223 #ifndef CIGI_NO_BND_CHK
00224 if(bndchk && ((VectAzIn < 0.0)||(VectAzIn > 360.0)))
00225 {
00226 #ifndef CIGI_NO_EXCEPT
00227 throw CigiValueOutOfRangeException("VectAz",(float)VectAzIn,0.0,360.0);
00228 #endif
00229 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00230 }
00231 #endif
00232
00233 VectAz = VectAzIn;
00234 return(CIGI_SUCCESS);
00235
00236 }
00237
00238