mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Ref T259, Ref T243 situation/parts/lights adjustments
* guessing now in parts/lights (so it can be used with all sims) * minor renamings * init FSX data definitions from parts
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
|
||||
#include "simconnectdatadefinition.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
#include "blackmisc/aviation/aircraftenginelist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <tuple>
|
||||
|
||||
@@ -186,6 +188,16 @@ namespace BlackSimPlugin
|
||||
return hr;
|
||||
}
|
||||
|
||||
DataDefinitionRemoteAircraftPartsWithoutLights::DataDefinitionRemoteAircraftPartsWithoutLights()
|
||||
{
|
||||
this->resetToInvalid();
|
||||
}
|
||||
|
||||
DataDefinitionRemoteAircraftPartsWithoutLights::DataDefinitionRemoteAircraftPartsWithoutLights(const CAircraftParts &parts)
|
||||
{
|
||||
this->initFromParts(parts);
|
||||
}
|
||||
|
||||
bool DataDefinitionRemoteAircraftPartsWithoutLights::operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const
|
||||
{
|
||||
return std::tie(flapsLeadingEdgeLeftPercent, flapsLeadingEdgeRightPercent, flapsTrailingEdgeLeftPercent, flapsTrailingEdgeRightPercent,
|
||||
@@ -204,6 +216,19 @@ namespace BlackSimPlugin
|
||||
engine4Combustion = on ? 1 : 0;
|
||||
}
|
||||
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::setEngine(int number1based, bool on)
|
||||
{
|
||||
double v = on ? 1.0 : 0.0;
|
||||
switch (number1based)
|
||||
{
|
||||
case 1: engine1Combustion = v; break;
|
||||
case 2: engine2Combustion = v; break;
|
||||
case 3: engine3Combustion = v; break;
|
||||
case 4: engine4Combustion = v; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::resetAllFlaps()
|
||||
{
|
||||
flapsLeadingEdgeLeftPercent = 0;
|
||||
@@ -231,6 +256,21 @@ namespace BlackSimPlugin
|
||||
engine4Combustion = -1;
|
||||
}
|
||||
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::initFromParts(const CAircraftParts &parts)
|
||||
{
|
||||
gearHandlePosition = parts.isGearDown() ? 1.0 : 0.0;
|
||||
flapsTrailingEdgeLeftPercent = flapsTrailingEdgeRightPercent = parts.getFlapsPercent() / 100.0;
|
||||
flapsLeadingEdgeLeftPercent = flapsLeadingEdgeRightPercent = parts.getFlapsPercent() * 0.2 / 100.0;
|
||||
spoilersHandlePosition = parts.isSpoilersOut() ? 1.0 : 0.0;
|
||||
this->setAllEngines(false); // init
|
||||
|
||||
int e = 1;
|
||||
for (const CAircraftEngine &engine : parts.getEngines())
|
||||
{
|
||||
this->setEngine(e++, engine.isOn());
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftLights DataDefinitionRemoteAircraftLights::toLights() const
|
||||
{
|
||||
return CAircraftLights(lightStrobe, lightLanding, lightTaxi, lightBeacon, lightNav, lightLogo, lightRecognition, lightCabin);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <algorithm>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc { namespace Aviation { class CAircraftParts; }}
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace FsxCommon
|
||||
@@ -85,12 +86,21 @@ namespace BlackSimPlugin
|
||||
double engine3Combustion; //!< Engine 3 combustion flag
|
||||
double engine4Combustion; //!< Engine 4 combustion flag
|
||||
|
||||
//! Ctor
|
||||
DataDefinitionRemoteAircraftPartsWithoutLights();
|
||||
|
||||
//! Ctor
|
||||
DataDefinitionRemoteAircraftPartsWithoutLights(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! Equal to other parts
|
||||
bool operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const;
|
||||
|
||||
//! All engines on/off
|
||||
void setAllEngines(bool on);
|
||||
|
||||
//! Set given engine
|
||||
void setEngine(int number1based, bool on);
|
||||
|
||||
//! Reset all flaps
|
||||
void resetAllFlaps();
|
||||
|
||||
@@ -99,6 +109,9 @@ namespace BlackSimPlugin
|
||||
|
||||
//! Reset to invalid values
|
||||
void resetToInvalid();
|
||||
|
||||
//! Init from parts
|
||||
void initFromParts(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
};
|
||||
|
||||
//! Data for aircraft lighs
|
||||
|
||||
Reference in New Issue
Block a user