#include <CigiWeatherCtrlV1.h>
Inheritance diagram for CigiWeatherCtrlV1:
Public Member Functions | |
CigiWeatherCtrlV1 () | |
virtual | ~CigiWeatherCtrlV1 () |
virtual int | Pack (CigiBasePacket *Base, Cigi_uint8 *Buff, void *Spec) const |
virtual int | Unpack (Cigi_uint8 *Buff, bool Swap, void *Spec) |
int | SetPhenomenonType (const Cigi_uint16 PhenomenonTypeIn, bool bndchk=true) |
Cigi_uint16 | GetPhenomenonType (void) const |
int | SetOpacity (const float OpacityIn, bool bndchk=true) |
float | GetOpacity (void) const |
int | SetWindDir (const float WindDirIn, bool bndchk=true) |
float | GetWindDir (void) const |
Definition at line 60 of file CigiWeatherCtrlV1.h.
CigiWeatherCtrlV1::CigiWeatherCtrlV1 | ( | ) |
General Constructor
Definition at line 84 of file CigiWeatherCtrlV1.cpp.
References CigiBaseWeatherCtrl::Aerosol, CigiBaseWeatherCtrl::AirTemp, CigiBaseWeatherCtrl::BaroPress, CigiBaseWeatherCtrl::BaseElev, CIGI_WEATHER_CTRL_PACKET_ID_V1, CIGI_WEATHER_CTRL_PACKET_SIZE_V1, CigiBaseWeatherCtrl::CloudType, CigiBaseWeatherCtrl::Coverage, CigiBaseWeatherCtrl::EntityID, CigiBaseWeatherCtrl::Global, CigiBaseWeatherCtrl::HorizWindSp, CigiBaseWeatherCtrl::Humidity, CigiBaseWeatherCtrl::LayerID, CigiBasePacket::MinorVersion, CigiBaseWeatherCtrl::None, CigiBaseWeatherCtrl::Opacity, CigiBasePacket::PacketID, CigiBasePacket::PacketSize, CigiBaseWeatherCtrl::PhenomenonType, CigiBaseWeatherCtrl::RandomLightningEn, CigiBaseWeatherCtrl::RandomWindsEn, CigiBaseWeatherCtrl::RegionID, CigiBaseWeatherCtrl::Scope, CigiBaseWeatherCtrl::ScudEn, CigiBaseWeatherCtrl::ScudFreq, CigiBaseWeatherCtrl::Severity, CigiBaseWeatherCtrl::Thickness, CigiBaseWeatherCtrl::Transition, CigiBasePacket::Version, CigiBaseWeatherCtrl::VertWindSp, CigiBaseWeatherCtrl::VisibilityRng, CigiBaseWeatherCtrl::WeatherEn, and CigiBaseWeatherCtrl::WindDir.
00085 { 00086 00087 PacketID = CIGI_WEATHER_CTRL_PACKET_ID_V1; 00088 PacketSize = CIGI_WEATHER_CTRL_PACKET_SIZE_V1; 00089 Version = 1; 00090 MinorVersion = 0; 00091 00092 EntityID = 0; 00093 RegionID = 0; 00094 LayerID = 0; 00095 Humidity = 0; 00096 PhenomenonType = 0; 00097 WeatherEn = false; 00098 ScudEn = false; 00099 RandomWindsEn = false; 00100 RandomLightningEn = false; 00101 CloudType = None; 00102 Scope = Global; 00103 Severity = 0; 00104 AirTemp = 0.0; 00105 VisibilityRng = 0.0; 00106 Opacity = 0.0; 00107 ScudFreq = 0.0; 00108 Coverage = 0.0; 00109 BaseElev = 0.0; 00110 Thickness = 0.0; 00111 Transition = 0.0; 00112 HorizWindSp = 0.0; 00113 VertWindSp = 0.0; 00114 WindDir = 0.0; 00115 BaroPress = 1013.25; 00116 Aerosol = 0.0; 00117 00118 }
CigiWeatherCtrlV1::~CigiWeatherCtrlV1 | ( | ) | [virtual] |
float CigiWeatherCtrlV1::GetOpacity | ( | void | ) | const [inline] |
Gets the Opacity value.
Definition at line 140 of file CigiWeatherCtrlV1.h.
00140 { return(Opacity); }
Cigi_uint16 CigiWeatherCtrlV1::GetPhenomenonType | ( | void | ) | const [inline] |
Gets the PhenomenonType value.
Definition at line 123 of file CigiWeatherCtrlV1.h.
00123 { return(PhenomenonType); }
float CigiWeatherCtrlV1::GetWindDir | ( | void | ) | const [inline] |
Gets the WindDir value.
Definition at line 157 of file CigiWeatherCtrlV1.h.
00157 { return(WindDir); }
int CigiWeatherCtrlV1::Pack | ( | CigiBasePacket * | Base, | |
Cigi_uint8 * | Buff, | |||
void * | Spec | |||
) | const [virtual] |
The virtual Pack function for CIGI 1
Base | - A pointer to the instance of the packet to be packed. (Downcast to CigiBasePacket) | |
Buff | - A pointer to the current pack point. | |
Spec | - A pointer to special data - This is not used in this class. |
Implements CigiBaseWeatherCtrl.
Definition at line 135 of file CigiWeatherCtrlV1.cpp.
References CigiBaseWeatherCtrl::AirTemp, CigiBaseWeatherCtrl::BaseElev, PackPointerUnion::c, CIGI_SCOPY2, CIGI_SCOPY4, CIGI_WEATHER_CTRL_PACKET_SIZE_V1, CigiBaseWeatherCtrl::Coverage, PackPointerUnion::d, CigiBaseWeatherCtrl::Entity, CigiBaseWeatherCtrl::EntityID, PackPointerUnion::f, CigiBaseWeatherCtrl::HorizWindSp, CigiBaseWeatherCtrl::LayerID, CigiBaseWeatherCtrl::Opacity, CigiBasePacket::PacketID, CigiBasePacket::PacketSize, CigiBaseWeatherCtrl::PhenomenonType, CigiBaseWeatherCtrl::RandomWindsEn, PackPointerUnion::s, CigiBaseWeatherCtrl::Scope, CigiBaseWeatherCtrl::ScudEn, CigiBaseWeatherCtrl::ScudFreq, CigiBaseWeatherCtrl::Severity, CigiBaseWeatherCtrl::Thickness, CigiBaseWeatherCtrl::Transition, CigiBasePacket::Version, CigiBaseWeatherCtrl::VisibilityRng, CigiBaseWeatherCtrl::WeatherEn, and CigiBaseWeatherCtrl::WindDir.
00136 { 00137 double DBuf[6]; 00138 00139 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf; 00140 00141 PackPointer CDta; 00142 00143 CigiBaseWeatherCtrl * Data = ( CigiBaseWeatherCtrl *)Base; 00144 00145 CDta.d = DBuf; 00146 00147 *CDta.c++ = PacketID; 00148 *CDta.c++ = PacketSize; 00149 00150 CIGI_SCOPY2(CDta.s++, &Data->EntityID); 00151 00152 Cigi_uint8 HDta = (Data->WeatherEn) ? 0x80 : 0x00; 00153 HDta |= (Data->ScudEn) ? 0x40 : 0x00; 00154 HDta |= (Data->RandomWindsEn) ? 0x20 : 0x00; 00155 HDta |= (Data->Severity << 2) & 0x1c; 00156 00157 *CDta.c++ = HDta; 00158 *CDta.c++ = 0x00; 00159 00160 00161 Cigi_uint16 tType = 0; 00162 if(Data->Version <= 2) 00163 tType = Data->PhenomenonType; 00164 else 00165 { 00166 if(Data->Scope == CigiBaseWeatherCtrl::Entity) 00167 tType = 0; 00168 else 00169 { 00170 tType = (Cigi_uint16)Data->LayerID; 00171 if(tType == 0) 00172 tType = 3; 00173 } 00174 } 00175 CIGI_SCOPY2(CDta.s++, &tType); 00176 00177 00178 CIGI_SCOPY4(CDta.f++, &Data->AirTemp); 00179 00180 if(Data->PhenomenonType == 3) 00181 CIGI_SCOPY4(CDta.f++, &Data->VisibilityRng); 00182 else 00183 CIGI_SCOPY4(CDta.f++, &Data->Opacity); 00184 00185 00186 CIGI_SCOPY4(CDta.f++, &Data->ScudFreq); 00187 CIGI_SCOPY4(CDta.f++, &Data->Coverage); 00188 CIGI_SCOPY4(CDta.f++, &Data->BaseElev); 00189 CIGI_SCOPY4(CDta.f++, &Data->Thickness); 00190 CIGI_SCOPY4(CDta.f++, &Data->Transition); 00191 CIGI_SCOPY4(CDta.f++, &Data->HorizWindSp); 00192 00193 float Wndir = Data->WindDir; 00194 if(Wndir < 0.0f) 00195 Wndir += 360.0; 00196 CIGI_SCOPY4(CDta.f++, &Wndir); 00197 00198 memcpy(Buff,tBuf,CIGI_WEATHER_CTRL_PACKET_SIZE_V1); 00199 00200 return(PacketSize); 00201 00202 }
int CigiWeatherCtrlV1::SetOpacity | ( | const float | OpacityIn, | |
bool | bndchk = true | |||
) |
Sets the Opacity with bound checking control
OpacityIn | - Visibility through a weather system | |
bndchk | - Enables (true) or disables (false) bounds checking. |
Definition at line 327 of file CigiWeatherCtrlV1.cpp.
References CIGI_ERROR_VALUE_OUT_OF_RANGE, CIGI_SUCCESS, CigiBaseWeatherCtrl::Opacity, and CigiBaseWeatherCtrl::VisibilityRng.
00328 { 00329 00330 #ifndef CIGI_NO_BND_CHK 00331 if(bndchk && ((OpacityIn < 0.0)||(OpacityIn > 100.0))) 00332 { 00333 #ifndef CIGI_NO_EXCEPT 00334 throw CigiValueOutOfRangeException("Opacity",(float)OpacityIn,0.0,100.0); 00335 #endif 00336 return(CIGI_ERROR_VALUE_OUT_OF_RANGE); 00337 } 00338 #endif 00339 00340 Opacity = OpacityIn; 00341 VisibilityRng = ((Opacity/100.0f)*70000.0f); 00342 00343 return(CIGI_SUCCESS); 00344 00345 }
int CigiWeatherCtrlV1::SetPhenomenonType | ( | const Cigi_uint16 | PhenomenonTypeIn, | |
bool | bndchk = true | |||
) |
Sets the PhenomenonType with bound checking control
PhenomenonTypeIn | - What kind of weather is being controlled | |
bndchk | - Enables (true) or disables (false) bounds checking. |
Definition at line 297 of file CigiWeatherCtrlV1.cpp.
References CIGI_SUCCESS, CigiBaseWeatherCtrl::Entity, CigiBaseWeatherCtrl::Global, CigiBaseWeatherCtrl::LayerID, CigiBaseWeatherCtrl::PhenomenonType, and CigiBaseWeatherCtrl::Scope.
00298 { 00299 Cigi_uint16 LayerTbl[7] = { 1,1,2,0,4,5,8 }; 00300 00301 PhenomenonType = PhenomenonTypeIn; 00302 00303 if(PhenomenonType == 0) 00304 { 00305 LayerID = 1; 00306 Scope = Entity; 00307 } 00308 else 00309 { 00310 Scope = Global; 00311 00312 if(PhenomenonType < 7) 00313 LayerID = (Cigi_uint8)LayerTbl[PhenomenonType]; 00314 else if(PhenomenonType < 256) 00315 LayerID = (Cigi_uint8)PhenomenonType; 00316 else 00317 LayerID = 255; 00318 } 00319 00320 return(CIGI_SUCCESS); 00321 }
int CigiWeatherCtrlV1::SetWindDir | ( | const float | WindDirIn, | |
bool | bndchk = true | |||
) |
Sets the WindDir with bound checking control
WindDirIn | - Wind direction | |
bndchk | - Enables (true) or disables (false) bounds checking. |
Definition at line 351 of file CigiWeatherCtrlV1.cpp.
References CIGI_ERROR_VALUE_OUT_OF_RANGE, CIGI_SUCCESS, and CigiBaseWeatherCtrl::WindDir.
00352 { 00353 00354 #ifndef CIGI_NO_BND_CHK 00355 if(bndchk && ((WindDirIn < 0.0)||(WindDirIn > 360.0))) 00356 { 00357 #ifndef CIGI_NO_EXCEPT 00358 throw CigiValueOutOfRangeException("WindDir",(float)WindDirIn,0.0,360.0); 00359 #endif 00360 return(CIGI_ERROR_VALUE_OUT_OF_RANGE); 00361 } 00362 #endif 00363 00364 WindDir = WindDirIn; 00365 return(CIGI_SUCCESS); 00366 00367 }
int CigiWeatherCtrlV1::Unpack | ( | Cigi_uint8 * | Buff, | |
bool | Swap, | |||
void * | Spec | |||
) | [virtual] |
The virtual Unpack function for CIGI 1
Buff | - A pointer to the current pack point. | |
Swap | - N/A for V1 & V2 | |
Spec | - A pointer to special data - This is not used in this class. |
Implements CigiBaseWeatherCtrl.
Definition at line 207 of file CigiWeatherCtrlV1.cpp.
References CigiBaseWeatherCtrl::Aerosol, CigiBaseWeatherCtrl::AirTemp, CigiBaseWeatherCtrl::BaroPress, CigiBaseWeatherCtrl::BaseElev, PackPointerUnion::c, CIGI_SCOPY2, CIGI_SCOPY4, CIGI_WEATHER_CTRL_PACKET_SIZE_V1, CigiBaseWeatherCtrl::CloudType, CigiBaseWeatherCtrl::Coverage, PackPointerUnion::d, CigiBaseWeatherCtrl::Entity, CigiBaseWeatherCtrl::EntityID, PackPointerUnion::f, CigiBaseWeatherCtrl::Global, CigiBaseWeatherCtrl::HorizWindSp, CigiBaseWeatherCtrl::Humidity, CigiBaseWeatherCtrl::LayerID, CigiBaseWeatherCtrl::None, CigiBaseWeatherCtrl::Opacity, CigiBasePacket::PacketSize, CigiBaseWeatherCtrl::PhenomenonType, CigiBaseWeatherCtrl::RandomLightningEn, CigiBaseWeatherCtrl::RandomWindsEn, CigiBaseWeatherCtrl::RegionID, PackPointerUnion::s, CigiBaseWeatherCtrl::Scope, CigiBaseWeatherCtrl::ScudEn, CigiBaseWeatherCtrl::ScudFreq, CigiBaseWeatherCtrl::Severity, CigiBaseWeatherCtrl::Thickness, CigiBaseWeatherCtrl::Transition, CigiBaseWeatherCtrl::VertWindSp, CigiBaseWeatherCtrl::VisibilityRng, CigiBaseWeatherCtrl::WeatherEn, and CigiBaseWeatherCtrl::WindDir.
00208 { 00209 double DBuf[6]; 00210 00211 Cigi_uint8 *tBuf = (Cigi_uint8 *)DBuf; 00212 00213 PackPointer CDta; 00214 00215 Cigi_uint16 LayerTbl[7] = { 1,1,2,0,4,5,8 }; 00216 00217 00218 memcpy(tBuf,Buff,CIGI_WEATHER_CTRL_PACKET_SIZE_V1); 00219 00220 CDta.d = DBuf; 00221 00222 CDta.c += 2; // Step over packet id and size 00223 00224 CIGI_SCOPY2(&EntityID, CDta.s++); 00225 00226 Cigi_uint8 HDta = *CDta.c++; 00227 WeatherEn = ((HDta & 0x80) != 0); 00228 ScudEn = ((HDta & 0x40) != 0); 00229 RandomWindsEn = ((HDta & 0x20) != 0); 00230 Severity = (HDta >> 2) & 0x07; 00231 00232 CDta.c++; 00233 00234 CIGI_SCOPY2(&PhenomenonType, CDta.s++); 00235 00236 CIGI_SCOPY4(&AirTemp, CDta.f++); 00237 00238 if(PhenomenonType == 3) 00239 { 00240 CIGI_SCOPY4(&VisibilityRng, CDta.f++); 00241 Opacity = ((VisibilityRng/70000.0f)*100.0f); 00242 } 00243 else 00244 { 00245 CIGI_SCOPY4(&Opacity, CDta.f++); 00246 VisibilityRng = ((Opacity/100.0f)*70000.0f); 00247 } 00248 00249 CIGI_SCOPY4(&ScudFreq, CDta.f++); 00250 CIGI_SCOPY4(&Coverage, CDta.f++); 00251 CIGI_SCOPY4(&BaseElev, CDta.f++); 00252 CIGI_SCOPY4(&Thickness, CDta.f++); 00253 CIGI_SCOPY4(&Transition, CDta.f++); 00254 CIGI_SCOPY4(&HorizWindSp, CDta.f++); 00255 CIGI_SCOPY4(&WindDir, CDta.f++); 00256 00257 RegionID = 0; 00258 Humidity = 0; 00259 RandomLightningEn = false; 00260 CloudType = None; 00261 00262 if(PhenomenonType == 0) 00263 { 00264 LayerID = 1; 00265 Scope = Entity; 00266 } 00267 else 00268 { 00269 Scope = Global; 00270 00271 if(PhenomenonType < 7) 00272 LayerID = (Cigi_uint8)LayerTbl[PhenomenonType]; 00273 else if(PhenomenonType < 256) 00274 LayerID = (Cigi_uint8)PhenomenonType; 00275 else 00276 LayerID = 255; 00277 } 00278 00279 VertWindSp = 0.0f; 00280 BaroPress = 1013.25f; 00281 Aerosol = 0.0f; 00282 00283 return(PacketSize); 00284 00285 }