00001
00060 #define _EXPORT_CCL_
00061
00062 #include "CigiLosVectReqV1.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 CigiLosVectReqV1::CigiLosVectReqV1()
00091 {
00092
00093 PacketID = CIGI_LOS_VECT_REQ_PACKET_ID_V1;
00094 PacketSize = CIGI_LOS_VECT_REQ_PACKET_SIZE_V1;
00095 Version = 1;
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 CigiLosVectReqV1::~CigiLosVectReqV1()
00121 {
00122
00123 }
00124
00125
00126
00127
00128
00129
00130
00131
00132 int CigiLosVectReqV1::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++ = Data->PacketID;
00148 *CDta.c++ = Data->PacketSize;
00149
00150 CIGI_SCOPY2(CDta.s++, &Data->LosID);
00151
00152 *CDta.l++ = 0;
00153
00154 if(Data->VectAz < 0.0f)
00155 Data->VectAz += 360.0f;
00156
00157 CIGI_SCOPY4(CDta.f++, &Data->VectAz);
00158
00159 CIGI_SCOPY4(CDta.f++, &Data->VectEl);
00160 CIGI_SCOPY4(CDta.f++, &Data->MaxRange);
00161
00162 float tflt = (float)Data->SrcZAlt;
00163 CIGI_SCOPY4(CDta.f++, &tflt);
00164
00165 CIGI_SCOPY8(CDta.d++, &Data->SrcXLat);
00166 CIGI_SCOPY8(CDta.d++, &Data->SrcYLon);
00167
00168 memcpy(Buff,tBuf,CIGI_LOS_VECT_REQ_PACKET_SIZE_V1);
00169
00170 return(PacketSize);
00171
00172 }
00173
00174
00175
00176
00177 int CigiLosVectReqV1::Unpack(Cigi_uint8 * Buff, bool Swap, void *Spec)
00178 {
00179 double DBuf[6];
00180
00181 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf;
00182
00183 PackPointer CDta;
00184
00185 memcpy(tBuf,Buff,CIGI_LOS_VECT_REQ_PACKET_SIZE_V1);
00186
00187 CDta.d = DBuf;
00188
00189 CDta.c += 2;
00190
00191 CIGI_SCOPY2(&LosID, CDta.s++);
00192
00193 CDta.l++;
00194
00195 CIGI_SCOPY4(&VectAz, CDta.f++);
00196 CIGI_SCOPY4(&VectEl, CDta.f++);
00197 CIGI_SCOPY4(&MaxRange, CDta.f++);
00198
00199 float tflt;
00200 CIGI_SCOPY4(&tflt, CDta.f++);
00201 SrcZAlt = (double)tflt;
00202
00203 CIGI_SCOPY8(&SrcXLat, CDta.d++);
00204 CIGI_SCOPY8(&SrcYLon, CDta.d++);
00205
00206 UpdatePeriod = 0;
00207
00208 ValidV1or2 = true;
00209
00210 return(PacketSize);
00211
00212 }
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 int CigiLosVectReqV1::SetVectAz(const float VectAzIn, bool bndchk)
00225 {
00226
00227 #ifndef CIGI_NO_BND_CHK
00228 if(bndchk && ((VectAzIn < 0.0)||(VectAzIn > 360.0)))
00229 {
00230 #ifndef CIGI_NO_EXCEPT
00231 throw CigiValueOutOfRangeException("VectAz",(float)VectAzIn,0.0,360.0);
00232 #endif
00233 return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00234 }
00235 #endif
00236
00237 VectAz = VectAzIn;
00238 return(CIGI_SUCCESS);
00239
00240 }
00241
00242