mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
feat: read enginepower from SimConnect
This commit is contained in:
@@ -607,7 +607,7 @@ namespace swift::core
|
||||
|
||||
const CCallsign &ISimulator::getTestCallsign()
|
||||
{
|
||||
static const CCallsign cs("SWIFT");
|
||||
static const CCallsign cs("SWT2026");
|
||||
return cs;
|
||||
}
|
||||
|
||||
|
||||
@@ -209,6 +209,22 @@ namespace swift::gui::components
|
||||
iconRadio);
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("Transponder"), ownAircraft.getTransponderCodeFormatted(),
|
||||
iconRadio);
|
||||
|
||||
// TODO TZ
|
||||
const int engineCount = sGui->getISimulator()->getOwnAircraftParts().getEngines().getEngineCount();
|
||||
|
||||
for (int count = 0; count < engineCount; ++count)
|
||||
{
|
||||
const int engNum = count + 1;
|
||||
const int engof = sGui->getISimulator()->getOwnAircraftParts().getEngines().isEngineOn(engNum);
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("ENG%1OnOff").arg(engNum),
|
||||
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),
|
||||
engpwr < 0 ? QStringLiteral("N/A") : QString::number(engpwr, 'f', 1),
|
||||
CIcon(CIcons::ApplicationSimulator));
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorComponent::onSimulatorStatusChanged(int status)
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace swift::misc::aviation
|
||||
|
||||
private:
|
||||
int m_number = 1;
|
||||
bool m_on = true;
|
||||
bool m_on = false;
|
||||
double m_power = 0.0;
|
||||
|
||||
SWIFT_METACLASS(
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace swift::misc::aviation
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftEngineList::initEngines(int engineNumber, bool on, int enginePercentage)
|
||||
void CAircraftEngineList::initEngines(int engineNumber, bool on, double enginePercentage)
|
||||
{
|
||||
this->clear();
|
||||
for (int e = 0; e < engineNumber; e++)
|
||||
@@ -73,7 +73,7 @@ namespace swift::misc::aviation
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftEngineList::setEnginePower(int engineNumber, int percentage)
|
||||
void CAircraftEngineList::setEnginePower(int engineNumber, double percentage)
|
||||
{
|
||||
Q_ASSERT(engineNumber > 0);
|
||||
for (CAircraftEngine &engine : *this)
|
||||
@@ -86,7 +86,7 @@ namespace swift::misc::aviation
|
||||
}
|
||||
}
|
||||
|
||||
int CAircraftEngineList::getEnginePower(int engineNumber) const
|
||||
double CAircraftEngineList::getEnginePower(int engineNumber) const
|
||||
{
|
||||
Q_ASSERT(engineNumber > 0);
|
||||
return this->getEngine(engineNumber).getEnginePower();
|
||||
|
||||
@@ -57,20 +57,23 @@ namespace swift::misc::aviation
|
||||
void setEngines(const CAircraftEngine &engine, int engineNumber);
|
||||
|
||||
//! Init some engines
|
||||
void initEngines(int engineNumber, bool on, int enginePercentage);
|
||||
void initEngines(int engineNumber, bool on, double enginePercentage);
|
||||
|
||||
//! Is any engine on?
|
||||
bool isAnyEngineOn() const;
|
||||
|
||||
void setEnginePower(int engineNumber, int percentage);
|
||||
void setEnginePower(int engineNumber, double percentage);
|
||||
|
||||
int getEnginePower(int engineNumber) const;
|
||||
double getEnginePower(int engineNumber) const;
|
||||
|
||||
//! \copydoc swift::misc::mixin::JsonByMetaClass::toJson
|
||||
QJsonObject toJson() const;
|
||||
|
||||
//! \copydoc swift::misc::mixin::JsonByMetaClass::convertFromJson
|
||||
void convertFromJson(const QJsonObject &json);
|
||||
|
||||
//! Get engine count
|
||||
int getEngineCount() const { return this->size(); }
|
||||
};
|
||||
} // namespace swift::misc::aviation
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ namespace swift::simplugin::fsxcommon
|
||||
"Feet");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "SIM ON GROUND",
|
||||
"Bool");
|
||||
// 12
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "LIGHT STROBE",
|
||||
"Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "LIGHT LANDING",
|
||||
@@ -131,6 +132,7 @@ namespace swift::simplugin::fsxcommon
|
||||
SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "LIGHT CABIN", "Bool");
|
||||
hr +=
|
||||
SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "LIGHT WING", "Bool");
|
||||
// 21
|
||||
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "TRANSPONDER CODE:1",
|
||||
nullptr);
|
||||
@@ -156,15 +158,17 @@ namespace swift::simplugin::fsxcommon
|
||||
"Enum");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "COM STATUS:2",
|
||||
"Enum");
|
||||
// 33
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"FLAPS HANDLE PERCENT", "Percent Over 100");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"SPOILERS HANDLE POSITION", "Percent Over 100");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"GEAR HANDLE POSITION", "Bool");
|
||||
// 36
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "NUMBER OF ENGINES",
|
||||
"Number");
|
||||
// Simconnect supports index 1 - 4
|
||||
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"GENERAL ENG COMBUSTION:1", "Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
@@ -181,7 +185,7 @@ namespace swift::simplugin::fsxcommon
|
||||
"GENERAL ENG COMBUSTION:7", "Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"GENERAL ENG COMBUSTION:8", "Bool");
|
||||
|
||||
// 45
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"GENERAL ENG THROTTLE LEVER POSITION:1", "percent");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
@@ -198,7 +202,7 @@ namespace swift::simplugin::fsxcommon
|
||||
"GENERAL ENG THROTTLE LEVER POSITION:7", "percent");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"GENERAL ENG THROTTLE LEVER POSITION:8", "percent");
|
||||
|
||||
// 53
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "VELOCITY WORLD X",
|
||||
"Feet per second");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "VELOCITY WORLD Y",
|
||||
@@ -214,6 +218,7 @@ namespace swift::simplugin::fsxcommon
|
||||
// FS2020
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft,
|
||||
"INDICATED ALTITUDE CALIBRATED", "Feet");
|
||||
// 60
|
||||
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraftTitle, "TITLE",
|
||||
nullptr, SIMCONNECT_DATATYPE_STRING256);
|
||||
|
||||
@@ -46,7 +46,10 @@ namespace swift::simplugin::fsxcommon
|
||||
double lightBeacon; //!< Is beacon light on?
|
||||
double lightNav; //!< Is nav light on?
|
||||
double lightLogo; //!< Is logo light on?
|
||||
// 18
|
||||
double lightRecognition;
|
||||
double lightCabin; //!< Is cabin light on?
|
||||
double lightWing; //!< Is wing light on?
|
||||
// 21
|
||||
double transponderCode; //!< Transponder Code
|
||||
double com1ActiveMHz; //!< COM1 active frequency
|
||||
double com2ActiveMHz; //!< COM2 active frequency
|
||||
@@ -59,11 +62,11 @@ namespace swift::simplugin::fsxcommon
|
||||
double comTest2; //!< COM2 test
|
||||
double comStatus1; //!< COM1 status
|
||||
double comStatus2; //!< COM2 status
|
||||
// 30
|
||||
// 33
|
||||
double flapsHandlePosition; //!< Flaps handle position in percent
|
||||
double spoilersHandlePosition; //!< Spoilers out? (flag)
|
||||
double gearHandlePosition; //!< Gear handle position (flag)
|
||||
// 33
|
||||
// 36
|
||||
double numberOfEngines; //!< Number of engines
|
||||
double engine1Combustion; //!< Engine 1 combustion flag
|
||||
double engine2Combustion; //!< Engine 2 combustion flag
|
||||
@@ -73,16 +76,7 @@ namespace swift::simplugin::fsxcommon
|
||||
double engine6Combustion; //!< Engine 6 combustion flag
|
||||
double engine7Combustion; //!< Engine 7 combustion flag
|
||||
double engine8Combustion; //!< Engine 8 combustion flag
|
||||
// 42
|
||||
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
|
||||
// 48
|
||||
double altitudeCalibratedFt; //!< Altitude without temperature effect (ft, FS2020)
|
||||
// 49
|
||||
// 45
|
||||
double engine1Power; //!< Engine 1 power
|
||||
double engine2Power; //!< Engine 2 power
|
||||
double engine3Power; //!< Engine 3 power
|
||||
@@ -91,7 +85,16 @@ namespace swift::simplugin::fsxcommon
|
||||
double engine6Power; //!< Engine 6 power
|
||||
double engine7Power; //!< Engine 7 power
|
||||
double engine8Power; //!< Engine 8 power
|
||||
// 57
|
||||
// 53
|
||||
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
|
||||
};
|
||||
|
||||
//! Data struct of aircraft position
|
||||
|
||||
@@ -740,14 +740,20 @@ namespace swift::simplugin::fsxcommon
|
||||
dtb(simulatorOwnAircraft.lightNav), dtb(simulatorOwnAircraft.lightLogo));
|
||||
|
||||
CAircraftEngineList engines;
|
||||
const QList<bool> helperList { dtb(simulatorOwnAircraft.engine1Combustion),
|
||||
dtb(simulatorOwnAircraft.engine2Combustion),
|
||||
dtb(simulatorOwnAircraft.engine3Combustion),
|
||||
dtb(simulatorOwnAircraft.engine4Combustion) };
|
||||
const QList<bool> helperList {
|
||||
dtb(simulatorOwnAircraft.engine1Combustion), dtb(simulatorOwnAircraft.engine2Combustion),
|
||||
dtb(simulatorOwnAircraft.engine3Combustion), dtb(simulatorOwnAircraft.engine4Combustion),
|
||||
dtb(simulatorOwnAircraft.engine5Combustion), dtb(simulatorOwnAircraft.engine6Combustion),
|
||||
dtb(simulatorOwnAircraft.engine7Combustion), dtb(simulatorOwnAircraft.engine8Combustion)
|
||||
};
|
||||
const QList<double> powerList { simulatorOwnAircraft.engine1Power, simulatorOwnAircraft.engine2Power,
|
||||
simulatorOwnAircraft.engine3Power, simulatorOwnAircraft.engine4Power,
|
||||
simulatorOwnAircraft.engine5Power, simulatorOwnAircraft.engine6Power,
|
||||
simulatorOwnAircraft.engine7Power, simulatorOwnAircraft.engine8Power };
|
||||
|
||||
for (int index = 0; index < simulatorOwnAircraft.numberOfEngines; ++index)
|
||||
{
|
||||
engines.push_back(CAircraftEngine(index + 1, helperList.value(index, true), 100));
|
||||
engines.push_back(CAircraftEngine(index + 1, helperList.value(index, false), powerList.value(index, 0)));
|
||||
}
|
||||
|
||||
const CAircraftParts parts(lights, dtb(simulatorOwnAircraft.gearHandlePosition),
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace swift::simplugin::fsxcommon
|
||||
{
|
||||
case CSimConnectDefinitions::RequestOwnAircraft:
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionOwnAircraft) == 57 * sizeof(double),
|
||||
static_assert(sizeof(DataDefinitionOwnAircraft) == 60 * sizeof(double),
|
||||
"DataDefinitionOwnAircraft has an incorrect size.");
|
||||
const DataDefinitionOwnAircraft *ownAircaft =
|
||||
reinterpret_cast<const DataDefinitionOwnAircraft *>(&pObjData->dwData);
|
||||
|
||||
@@ -77,16 +77,7 @@ namespace swift::simplugin::msfs2024common
|
||||
double engine6Combustion; //!< Engine 6 combustion flag
|
||||
double engine7Combustion; //!< Engine 7 combustion flag
|
||||
double engine8Combustion; //!< Engine 8 combustion flag
|
||||
// 46
|
||||
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
|
||||
// 52
|
||||
double altitudeCalibratedFt; //!< Altitude without temperature effect (ft, FS2020)
|
||||
// 53
|
||||
// 45
|
||||
double engine1Power; //!< Engine 1 power
|
||||
double engine2Power; //!< Engine 2 power
|
||||
double engine3Power; //!< Engine 3 power
|
||||
@@ -95,7 +86,16 @@ namespace swift::simplugin::msfs2024common
|
||||
double engine6Power; //!< Engine 6 power
|
||||
double engine7Power; //!< Engine 7 power
|
||||
double engine8Power; //!< Engine 8 power
|
||||
// 61
|
||||
// 53
|
||||
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
|
||||
};
|
||||
|
||||
//! Data struct of aircraft position
|
||||
|
||||
@@ -946,9 +946,14 @@ namespace swift::simplugin::msfs2024common
|
||||
dtb(simulatorOwnAircraft.engine7Combustion), dtb(simulatorOwnAircraft.engine8Combustion)
|
||||
};
|
||||
|
||||
const QList<double> powerList { simulatorOwnAircraft.engine1Power, simulatorOwnAircraft.engine2Power,
|
||||
simulatorOwnAircraft.engine3Power, simulatorOwnAircraft.engine4Power,
|
||||
simulatorOwnAircraft.engine5Power, simulatorOwnAircraft.engine6Power,
|
||||
simulatorOwnAircraft.engine7Power, simulatorOwnAircraft.engine8Power };
|
||||
|
||||
for (int index = 0; index < simulatorOwnAircraft.numberOfEngines; ++index)
|
||||
{
|
||||
engines.push_back(CAircraftEngine(index + 1, helperList.value(index, true), 100));
|
||||
engines.push_back(CAircraftEngine(index + 1, helperList.value(index, false), powerList.value(index, 0)));
|
||||
}
|
||||
|
||||
const CAircraftParts parts(lights, dtb(simulatorOwnAircraft.gearHandlePosition),
|
||||
|
||||
Reference in New Issue
Block a user