refs #873, better guessing of parts (clients without aircraft config)

This commit is contained in:
Klaus Basan
2017-02-01 19:49:54 +01:00
committed by Mathew Sutcliffe
parent f0cbe3b332
commit 01b79a76a6
3 changed files with 55 additions and 5 deletions

View File

@@ -191,6 +191,27 @@ namespace BlackSimPlugin
rhs.engine1Combustion, rhs.engine2Combustion, rhs.engine3Combustion, rhs.engine4Combustion); rhs.engine1Combustion, rhs.engine2Combustion, rhs.engine3Combustion, rhs.engine4Combustion);
} }
void DataDefinitionRemoteAircraftParts::setAllEngines(bool on)
{
engine1Combustion = on ? 1 : 0;
engine2Combustion = on ? 1 : 0;
engine3Combustion = on ? 1 : 0;
engine4Combustion = on ? 1 : 0;
}
void DataDefinitionRemoteAircraftParts::resetAllFlaps()
{
flapsLeadingEdgeLeftPercent = 0;
flapsLeadingEdgeRightPercent = 0;
flapsTrailingEdgeLeftPercent = 0;
flapsTrailingEdgeRightPercent = 0;
}
void DataDefinitionRemoteAircraftParts::resetSpoilers()
{
spoilersHandlePosition = 0;
}
CAircraftLights DataDefinitionRemoteAircraftLights::toLights() const CAircraftLights DataDefinitionRemoteAircraftLights::toLights() const
{ {
return CAircraftLights(lightStrobe, lightLanding, lightTaxi, lightBeacon, lightNav, lightLogo); return CAircraftLights(lightStrobe, lightLanding, lightTaxi, lightBeacon, lightNav, lightLogo);

View File

@@ -90,6 +90,15 @@ namespace BlackSimPlugin
//! Equal to other parts //! Equal to other parts
bool operator==(const DataDefinitionRemoteAircraftParts &rhs) const; bool operator==(const DataDefinitionRemoteAircraftParts &rhs) const;
//! All engines on/off
void setAllEngines(bool on);
//! Reset all flaps
void resetAllFlaps();
//! Reset spoilers
void resetSpoilers();
}; };
//! Data for aircraft lighs //! Data for aircraft lighs

View File

@@ -954,26 +954,27 @@ namespace BlackSimPlugin
if (!simObj.hasValidRequestAndObjectId()) { return false; } if (!simObj.hasValidRequestAndObjectId()) { return false; }
if (!interpolationStatus.didInterpolationSucceed()) { return false; } if (!interpolationStatus.didInterpolationSucceed()) { return false; }
CAircraftLights lights;
DataDefinitionRemoteAircraftParts ddRemoteAircraftParts = {}; // init members DataDefinitionRemoteAircraftParts ddRemoteAircraftParts = {}; // init members
const bool isOnGround = interpolatedSituation.isOnGround() == CAircraftSituation::OnGround; const bool isOnGround = interpolatedSituation.isOnGround() == CAircraftSituation::OnGround;
ddRemoteAircraftParts.gearHandlePosition = isOnGround ? 1 : 0; const double gsKts = interpolatedSituation.getGroundSpeed().value(CSpeedUnit::kts());
CAircraftLights lights; ddRemoteAircraftParts.setAllEngines(true);
// when first detected moving, lights on // when first detected moving, lights on
if (isOnGround) if (isOnGround)
{ {
ddRemoteAircraftParts.gearHandlePosition = 1;
lights.setTaxiOn(true); lights.setTaxiOn(true);
lights.setBeaconOn(true); lights.setBeaconOn(true);
lights.setNavOn(true); lights.setNavOn(true);
double gskmh = interpolatedSituation.getGroundSpeed().value(CSpeedUnit::km_h()); if (gsKts > 5)
if (gskmh > 7.5)
{ {
// mode taxi // mode taxi
lights.setTaxiOn(true); lights.setTaxiOn(true);
lights.setLandingOn(false); lights.setLandingOn(false);
} }
else if (gskmh > 40) else if (gsKts > 30)
{ {
// mode accelaration for takeoff // mode accelaration for takeoff
lights.setTaxiOn(false); lights.setTaxiOn(false);
@@ -984,15 +985,34 @@ namespace BlackSimPlugin
// slow movements or parking // slow movements or parking
lights.setTaxiOn(false); lights.setTaxiOn(false);
lights.setLandingOn(false); lights.setLandingOn(false);
ddRemoteAircraftParts.setAllEngines(false);
} }
} }
else else
{ {
// not on ground
ddRemoteAircraftParts.gearHandlePosition = 0;
lights.setTaxiOn(false); lights.setTaxiOn(false);
lights.setBeaconOn(true); lights.setBeaconOn(true);
lights.setNavOn(true); lights.setNavOn(true);
// landing lights for < 10000ft (normally MSL, here ignored) // landing lights for < 10000ft (normally MSL, here ignored)
lights.setLandingOn(interpolatedSituation.getAltitude().value(CLengthUnit::ft()) < 10000); lights.setLandingOn(interpolatedSituation.getAltitude().value(CLengthUnit::ft()) < 10000);
if (!simObj.isVtol() && interpolatedSituation.hasGroundElevation())
{
if (interpolatedSituation.getHeightAboveGround().value(CLengthUnit::ft()) < 1000)
{
ddRemoteAircraftParts.gearHandlePosition = 1;
ddRemoteAircraftParts.flapsTrailingEdgeRightPercent = 25;
ddRemoteAircraftParts.flapsTrailingEdgeLeftPercent = 25;
}
else if (interpolatedSituation.getHeightAboveGround().value(CLengthUnit::ft()) < 2000)
{
ddRemoteAircraftParts.gearHandlePosition = 1;
ddRemoteAircraftParts.flapsTrailingEdgeRightPercent = 10;
ddRemoteAircraftParts.flapsTrailingEdgeLeftPercent = 10;
}
}
} }
return this->sendRemoteAircraftPartsToSimulator(simObj, ddRemoteAircraftParts, lights); return this->sendRemoteAircraftPartsToSimulator(simObj, ddRemoteAircraftParts, lights);