mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-05 17:05:57 +08:00
feat(msfs): Set engine RPM on remote aircraft
This commit is contained in:
@@ -114,6 +114,12 @@ namespace swift::gui::editors
|
||||
ui->cb_AircraftPartsEngine4->setChecked(on);
|
||||
ui->cb_AircraftPartsEngine5->setChecked(on);
|
||||
ui->cb_AircraftPartsEngine6->setChecked(on);
|
||||
ui->sb_AircraftPartsEngine1RpmPercentage->setValue(on ? 80 : 0);
|
||||
ui->sb_AircraftPartsEngine2RpmPercentage->setValue(on ? 80 : 0);
|
||||
ui->sb_AircraftPartsEngine3RpmPercentage->setValue(on ? 80 : 0);
|
||||
ui->sb_AircraftPartsEngine4RpmPercentage->setValue(on ? 80 : 0);
|
||||
ui->sb_AircraftPartsEngine5RpmPercentage->setValue(on ? 80 : 0);
|
||||
ui->sb_AircraftPartsEngine6RpmPercentage->setValue(on ? 80 : 0);
|
||||
}
|
||||
|
||||
aviation::CAircraftParts CAircraftPartsForm::guiToAircraftParts() const
|
||||
@@ -125,9 +131,12 @@ namespace swift::gui::editors
|
||||
ui->cb_AircraftPartsLightsRecognition->isChecked(), ui->cb_AircraftPartsLightsCabin->isChecked(),
|
||||
ui->cb_AircraftPartsLightsWing->isChecked());
|
||||
const CAircraftEngineList engines(
|
||||
{ ui->cb_AircraftPartsEngine1->isChecked(), ui->cb_AircraftPartsEngine2->isChecked(),
|
||||
ui->cb_AircraftPartsEngine3->isChecked(), ui->cb_AircraftPartsEngine4->isChecked(),
|
||||
ui->cb_AircraftPartsEngine5->isChecked(), ui->cb_AircraftPartsEngine6->isChecked() });
|
||||
{ { ui->cb_AircraftPartsEngine1->isChecked(), ui->sb_AircraftPartsEngine1RpmPercentage->value() },
|
||||
{ ui->cb_AircraftPartsEngine2->isChecked(), ui->sb_AircraftPartsEngine2RpmPercentage->value() },
|
||||
{ ui->cb_AircraftPartsEngine3->isChecked(), ui->sb_AircraftPartsEngine3RpmPercentage->value() },
|
||||
{ ui->cb_AircraftPartsEngine4->isChecked(), ui->sb_AircraftPartsEngine4RpmPercentage->value() },
|
||||
{ ui->cb_AircraftPartsEngine5->isChecked(), ui->sb_AircraftPartsEngine5RpmPercentage->value() },
|
||||
{ ui->cb_AircraftPartsEngine6->isChecked(), ui->sb_AircraftPartsEngine6RpmPercentage->value() } });
|
||||
const CAircraftParts parts(
|
||||
lights, ui->cb_AircraftPartsGearDown->isChecked(), ui->sb_AircraftPartsFlapsPercentage->value(),
|
||||
ui->cb_AircraftPartsSpoilers->isChecked(), engines, ui->cb_AircraftPartsIsOnGround->isChecked());
|
||||
@@ -157,6 +166,12 @@ namespace swift::gui::editors
|
||||
ui->cb_AircraftPartsEngine4->setChecked(engines.isEngineOn(4));
|
||||
ui->cb_AircraftPartsEngine5->setChecked(engines.isEngineOn(5));
|
||||
ui->cb_AircraftPartsEngine6->setChecked(engines.isEngineOn(6));
|
||||
ui->sb_AircraftPartsEngine1RpmPercentage->setValue(engines.getEngineRpmPct(1));
|
||||
ui->sb_AircraftPartsEngine2RpmPercentage->setValue(engines.getEngineRpmPct(2));
|
||||
ui->sb_AircraftPartsEngine3RpmPercentage->setValue(engines.getEngineRpmPct(3));
|
||||
ui->sb_AircraftPartsEngine4RpmPercentage->setValue(engines.getEngineRpmPct(4));
|
||||
ui->sb_AircraftPartsEngine5RpmPercentage->setValue(engines.getEngineRpmPct(5));
|
||||
ui->sb_AircraftPartsEngine6RpmPercentage->setValue(engines.getEngineRpmPct(6));
|
||||
}
|
||||
|
||||
void CAircraftPartsForm::guiToJson()
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="3">
|
||||
<item row="8" column="0" colspan="3">
|
||||
<widget class="QTextEdit" name="te_AircraftPartsJson"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
@@ -260,7 +260,97 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2" alignment="Qt::AlignRight">
|
||||
<item row="7" column="0" colspan="3" alignment="Qt::AlignLeft">
|
||||
<widget class="QFrame" name="fr2_Engines">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl2_Engines">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="sb_AircraftPartsEngine1RpmPercentage">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>7</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="sb_AircraftPartsEngine2RpmPercentage">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>8</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="sb_AircraftPartsEngine3RpmPercentage">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>9</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QSpinBox" name="sb_AircraftPartsEngine4RpmPercentage">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>7</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QSpinBox" name="sb_AircraftPartsEngine5RpmPercentage">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QSpinBox" name="sb_AircraftPartsEngine6RpmPercentage">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>11</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="2" alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_Set">
|
||||
<property name="text">
|
||||
<string>set</string>
|
||||
@@ -291,6 +381,12 @@
|
||||
<tabstop>cb_AircraftPartsEngine4</tabstop>
|
||||
<tabstop>cb_AircraftPartsEngine5</tabstop>
|
||||
<tabstop>cb_AircraftPartsEngine6</tabstop>
|
||||
<tabstop>sb_AircraftPartsEngine1RpmPercentage</tabstop>
|
||||
<tabstop>sb_AircraftPartsEngine2RpmPercentage</tabstop>
|
||||
<tabstop>sb_AircraftPartsEngine3RpmPercentage</tabstop>
|
||||
<tabstop>sb_AircraftPartsEngine4RpmPercentage</tabstop>
|
||||
<tabstop>sb_AircraftPartsEngine5RpmPercentage</tabstop>
|
||||
<tabstop>sb_AircraftPartsEngine6RpmPercentage</tabstop>
|
||||
<tabstop>te_AircraftPartsJson</tabstop>
|
||||
<tabstop>pb_Set</tabstop>
|
||||
</tabstops>
|
||||
|
||||
@@ -236,6 +236,14 @@ namespace swift::simplugin::fsxcommon
|
||||
"GENERAL ENG COMBUSTION:3", "Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPartsWithoutLights,
|
||||
"GENERAL ENG COMBUSTION:4", "Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPartsWithoutLights,
|
||||
"GENERAL ENG THROTTLE LEVER POSITION:1", "percent");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPartsWithoutLights,
|
||||
"GENERAL ENG THROTTLE LEVER POSITION:2", "percent");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPartsWithoutLights,
|
||||
"GENERAL ENG THROTTLE LEVER POSITION:3", "percent");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftPartsWithoutLights,
|
||||
"GENERAL ENG THROTTLE LEVER POSITION:4", "percent");
|
||||
|
||||
// Lights (other definition)
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraftTitle, "TITLE",
|
||||
@@ -470,23 +478,39 @@ namespace swift::simplugin::fsxcommon
|
||||
rhs.engine4Combustion);
|
||||
}
|
||||
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::setAllEngines(bool on)
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::setAllEngines(bool on, double engineRpmPct)
|
||||
{
|
||||
engine1Combustion = on ? 1 : 0;
|
||||
engine2Combustion = on ? 1 : 0;
|
||||
engine3Combustion = on ? 1 : 0;
|
||||
engine4Combustion = on ? 1 : 0;
|
||||
engine1RpmPct = engineRpmPct;
|
||||
engine2RpmPct = engineRpmPct;
|
||||
engine3RpmPct = engineRpmPct;
|
||||
engine4RpmPct = engineRpmPct;
|
||||
}
|
||||
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::setEngine(int number1based, bool on)
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::setEngine(int number1based, bool on, double engineRpmPct)
|
||||
{
|
||||
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;
|
||||
case 1:
|
||||
engine1Combustion = v;
|
||||
engine1RpmPct = engineRpmPct;
|
||||
break;
|
||||
case 2:
|
||||
engine2Combustion = v;
|
||||
engine2RpmPct = engineRpmPct;
|
||||
break;
|
||||
case 3:
|
||||
engine3Combustion = v;
|
||||
engine3RpmPct = engineRpmPct;
|
||||
break;
|
||||
case 4:
|
||||
engine4Combustion = v;
|
||||
engine4RpmPct = engineRpmPct;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -513,6 +537,10 @@ namespace swift::simplugin::fsxcommon
|
||||
engine2Combustion = -1;
|
||||
engine3Combustion = -1;
|
||||
engine4Combustion = -1;
|
||||
engine1RpmPct = -1;
|
||||
engine2RpmPct = -1;
|
||||
engine3RpmPct = -1;
|
||||
engine4RpmPct = -1;
|
||||
}
|
||||
|
||||
void DataDefinitionRemoteAircraftPartsWithoutLights::initFromParts(const CAircraftParts &parts)
|
||||
@@ -525,10 +553,13 @@ namespace swift::simplugin::fsxcommon
|
||||
flapsLeadingEdgeLeftPercent = lead;
|
||||
flapsLeadingEdgeRightPercent = lead;
|
||||
spoilersHandlePosition = parts.isSpoilersOut() ? 1.0 : 0.0;
|
||||
this->setAllEngines(false); // init
|
||||
this->setAllEngines(false, 0.0); // init
|
||||
|
||||
int e = 1;
|
||||
for (const CAircraftEngine &engine : parts.getEngines()) { this->setEngine(e++, engine.isOn()); }
|
||||
for (const CAircraftEngine &engine : parts.getEngines())
|
||||
{
|
||||
this->setEngine(e++, engine.isOn(), engine.getEngineRpmPct());
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftLights DataDefinitionRemoteAircraftLights::toLights() const
|
||||
|
||||
@@ -152,6 +152,10 @@ namespace swift::simplugin::fsxcommon
|
||||
double engine2Combustion; //!< Engine 2 combustion flag
|
||||
double engine3Combustion; //!< Engine 3 combustion flag
|
||||
double engine4Combustion; //!< Engine 4 combustion flag
|
||||
double engine1RpmPct; //!< Engine 1 RPM [%]
|
||||
double engine2RpmPct; //!< Engine 2 RPM [%]
|
||||
double engine3RpmPct; //!< Engine 3 RPM [%]
|
||||
double engine4RpmPct; //!< Engine 4 RPM [%]
|
||||
|
||||
//! Ctor
|
||||
DataDefinitionRemoteAircraftPartsWithoutLights();
|
||||
@@ -163,10 +167,10 @@ namespace swift::simplugin::fsxcommon
|
||||
bool operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const;
|
||||
|
||||
//! All engines on/off
|
||||
void setAllEngines(bool on);
|
||||
void setAllEngines(bool on, double engineRpmPct);
|
||||
|
||||
//! Set given engine
|
||||
void setEngine(int number1based, bool on);
|
||||
void setEngine(int number1based, bool on, double engineRpmPct);
|
||||
|
||||
//! Reset all flaps
|
||||
void resetAllFlaps();
|
||||
|
||||
@@ -2101,7 +2101,7 @@ namespace swift::simplugin::fsxcommon
|
||||
|
||||
void CSimulatorFsxCommon::updateRemoteAircraft()
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionRemoteAircraftPartsWithoutLights) == sizeof(double) * 10,
|
||||
static_assert(sizeof(DataDefinitionRemoteAircraftPartsWithoutLights) == sizeof(double) * 14,
|
||||
"DataDefinitionRemoteAircraftPartsWithoutLights has an incorrect size.");
|
||||
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user