mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
[skip ci] last changes
This commit is contained in:
@@ -221,7 +221,7 @@ namespace swift::gui::components
|
||||
engof < 0 ? QStringLiteral("N/A") : QString::number(engof, 'd', 1),
|
||||
CIcon(CIcons::ApplicationSimulator));
|
||||
const double engpwr = sGui->getISimulator()->getOwnAircraftParts().getEngines().getEnginePower(engNum);
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("ENG%1Pwr").arg(engNum),
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("ENG%1PwrPct").arg(engNum),
|
||||
engpwr < 0 ? QStringLiteral("N/A") : QString::number(engpwr, 'f', 1),
|
||||
CIcon(CIcons::ApplicationSimulator));
|
||||
}
|
||||
|
||||
@@ -753,8 +753,12 @@ namespace swift::simplugin::fsxcommon
|
||||
|
||||
for (int index = 0; index < simulatorOwnAircraft.numberOfEngines; ++index)
|
||||
{
|
||||
CONST DOUBLE engine_rpm = (powerList.value(index) - 20) * 100 /
|
||||
20; // convert to 0-100% range, -20 is idle power, 20 is max power, so 40 range
|
||||
// this is a bit of a guess, but it seems that idle is around 30% in the sim, so
|
||||
// I use that as 0% for better resolution
|
||||
// because we read "GENERAL ENG PCT MAX RPM" and send "GENERAL ENG THROTTLE LEVER POSITION"
|
||||
CONST DOUBLE factor = 30.0;
|
||||
DOUBLE engine_rpm = (powerList.value(index, 0) - factor) * 100 / (100 - factor);
|
||||
if (engine_rpm < 0) engine_rpm = 0;
|
||||
engines.push_back(CAircraftEngine(index + 1, helperList.value(index, false), engine_rpm));
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,8 @@ namespace swift::simplugin::msfs2024common
|
||||
"GEAR HANDLE POSITION", "Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "NUMBER OF ENGINES",
|
||||
"Number");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "ENGINE TYPE",
|
||||
"Number");
|
||||
// Simconnect supports index 1 - 4
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"GENERAL ENG COMBUSTION:1", "Bool");
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace swift::simplugin::msfs2024common
|
||||
double gearHandlePosition; //!< Gear handle position (flag)
|
||||
// 36
|
||||
double numberOfEngines; //!< Number of engines
|
||||
double engineType; //!< Engine type
|
||||
double engine1Combustion; //!< Engine 1 combustion flag
|
||||
double engine2Combustion; //!< Engine 2 combustion flag
|
||||
double engine3Combustion; //!< Engine 3 combustion flag
|
||||
@@ -77,7 +78,7 @@ namespace swift::simplugin::msfs2024common
|
||||
double engine6Combustion; //!< Engine 6 combustion flag
|
||||
double engine7Combustion; //!< Engine 7 combustion flag
|
||||
double engine8Combustion; //!< Engine 8 combustion flag
|
||||
// 45
|
||||
// 46
|
||||
double engine1Power; //!< Engine 1 power
|
||||
double engine2Power; //!< Engine 2 power
|
||||
double engine3Power; //!< Engine 3 power
|
||||
@@ -86,16 +87,16 @@ namespace swift::simplugin::msfs2024common
|
||||
double engine6Power; //!< Engine 6 power
|
||||
double engine7Power; //!< Engine 7 power
|
||||
double engine8Power; //!< Engine 8 power
|
||||
// 53
|
||||
// 54
|
||||
double velocityWorldX; //!< Velocity World X
|
||||
double velocityWorldY; //!< Velocity World Y
|
||||
double velocityWorldZ; //!< Velocity World Z
|
||||
double rotationVelocityBodyX; //!< Rotation Velocity Body X
|
||||
double rotationVelocityBodyY; //!< Rotation Velocity Body Y
|
||||
double rotationVelocityBodyZ; //!< Rotation Velocity Body Z
|
||||
// 59
|
||||
double altitudeCalibratedFt; //!< Altitude without temperature effect (ft, FS2020)
|
||||
// 60
|
||||
double altitudeCalibratedFt; //!< Altitude without temperature effect (ft, FS2020)
|
||||
// 61
|
||||
};
|
||||
|
||||
//! Data struct of aircraft position
|
||||
|
||||
@@ -888,6 +888,26 @@ namespace swift::simplugin::msfs2024common
|
||||
aircraftSituation.setAltitude(
|
||||
CAltitude(simulatorOwnAircraft.altitudeFt, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
}
|
||||
|
||||
double CSimulatorMsfs2024::calcEngineFactor(int engineType)
|
||||
{
|
||||
// this is a bit of a guess, but it seems that idle is around 30% in the sim, so
|
||||
// I use that as 0% for better resolution
|
||||
// because we read "GENERAL ENG PCT MAX RPM" and send "GENERAL ENG THROTTLE LEVER POSITION"
|
||||
double factor = 30.0; // default factor, keep 30% as 0% for better resolution
|
||||
switch (engineType)
|
||||
{
|
||||
case 0: factor = 25.0; break; // piston, seems to be around 30% at idle
|
||||
case 1: factor = 40.0; break; // jet, seems to be around 55% at idle
|
||||
case 2: factor = 25.0; break; // none, seems to be around 0% at idle
|
||||
case 3: factor = 80.0; break; // helo, seems to be around 99% at idle
|
||||
case 4: factor = 30.0; break; // unsupported, seems to be around 30% at idle
|
||||
case 5: factor = 40.0; break; // turboprop, seems to be around 40% at idle
|
||||
case 6: factor = 1.0; break; // electric, seems to be around 0% at idle
|
||||
default: factor = 30.0; break; // default, keep 30% factor
|
||||
}
|
||||
return factor;
|
||||
}
|
||||
|
||||
void CSimulatorMsfs2024::updateOwnAircraftFromSimulator(const DataDefinitionOwnAircraft &simulatorOwnAircraft)
|
||||
{
|
||||
@@ -951,9 +971,13 @@ namespace swift::simplugin::msfs2024common
|
||||
simulatorOwnAircraft.engine5Power, simulatorOwnAircraft.engine6Power,
|
||||
simulatorOwnAircraft.engine7Power, simulatorOwnAircraft.engine8Power };
|
||||
|
||||
DOUBLE factor = this->calcEngineFactor(static_cast<int>(simulatorOwnAircraft.engineType)); // clears all pending aircraft etc
|
||||
|
||||
for (int index = 0; index < simulatorOwnAircraft.numberOfEngines; ++index)
|
||||
{
|
||||
engines.push_back(CAircraftEngine(index + 1, helperList.value(index, false), powerList.value(index, 0)));
|
||||
DOUBLE engine_rpm = (powerList.value(index, 0) - factor) * 100 / (100 - factor);
|
||||
if (engine_rpm < 0) engine_rpm = 0;
|
||||
engines.push_back(CAircraftEngine(index + 1, helperList.value(index, false), engine_rpm));
|
||||
}
|
||||
|
||||
const CAircraftParts parts(lights, dtb(simulatorOwnAircraft.gearHandlePosition),
|
||||
|
||||
@@ -499,6 +499,9 @@ namespace swift::simplugin::msfs2024common
|
||||
setTrueAltitude(swift::misc::aviation::CAircraftSituation &aircraftSituation,
|
||||
const swift::simplugin::msfs2024common::DataDefinitionOwnAircraft &simulatorOwnAircraft);
|
||||
|
||||
double calcEngineFactor(int engineType);
|
||||
|
||||
|
||||
//! Called when data about our own aircraft are received
|
||||
void updateOwnAircraftFromSimulator(const DataDefinitionOwnAircraft &simulatorOwnAircraft);
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace swift::simplugin::msfs2024common
|
||||
{
|
||||
case CSimConnectDefinitions::RequestOwnAircraft:
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionOwnAircraft) == 60 * sizeof(double),
|
||||
static_assert(sizeof(DataDefinitionOwnAircraft) == 61 * sizeof(double),
|
||||
"DataDefinitionOwnAircraft has an incorrect size.");
|
||||
const DataDefinitionOwnAircraft *ownAircaft =
|
||||
reinterpret_cast<const DataDefinitionOwnAircraft *>(&pObjData->dwData);
|
||||
|
||||
Reference in New Issue
Block a user