mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Fix sending the correct pressure altitude for a pilot position
* Before this commit, only the true altitude was known for an aircraft situation. The pressure altitude was not available anywhere yet. * This caused a wrong altitude in radar clients. * We fix this reading the pressure altitude from the simulators and set it in the own aircraft situation. * MS Flight Simulators have the pressure altitude in the APIs available. * For X-Plane and emulated simulator, we need to calculate it from the pressure at sea level. * Finally, we use the new available pressure altitude to send it to the FSD server. Maniphest Tasks: Ref T223
This commit is contained in:
committed by
Klaus Basan
parent
51a90a9a71
commit
de4fe44156
@@ -108,7 +108,7 @@ namespace BlackCore
|
||||
|
||||
//! Update position
|
||||
//! \note this is in \sa IContextOwnAircraft as we want to set test positions from the GUI / elsewhere
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) = 0;
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const BlackMisc::Aviation::CAltitude &pressureAltitude) = 0;
|
||||
|
||||
//! Update own cockpit
|
||||
virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator) = 0;
|
||||
|
||||
@@ -38,10 +38,11 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateOwnPosition
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) override
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const BlackMisc::Aviation::CAltitude &pressureAltitude) override
|
||||
{
|
||||
Q_UNUSED(position);
|
||||
Q_UNUSED(altitude);
|
||||
Q_UNUSED(pressureAltitude)
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace BlackCore
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CContextOwnAircraft::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude)
|
||||
bool CContextOwnAircraft::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const CAltitude &pressureAltitude)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << position << altitude; }
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
@@ -224,6 +224,12 @@ namespace BlackCore
|
||||
changed = true;
|
||||
m_ownAircraft.setAltitude(altitude);
|
||||
}
|
||||
|
||||
if (m_ownAircraft.getPressureAltitude() != pressureAltitude)
|
||||
{
|
||||
changed = true;
|
||||
m_ownAircraft.setPressureAltitude(pressureAltitude);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace BlackCore
|
||||
virtual bool updateOwnIcaoCodes(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcaoCode, const BlackMisc::Aviation::CAirlineIcaoCode &airlineIcaoCode) override;
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateOwnPosition
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) override;
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const BlackMisc::Aviation::CAltitude &pressureAltitude) override;
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateCockpit
|
||||
virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator) override;
|
||||
|
||||
@@ -75,9 +75,9 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1String("updateSelcal"), selcal, originator);
|
||||
}
|
||||
|
||||
bool CContextOwnAircraftProxy::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude)
|
||||
bool CContextOwnAircraftProxy::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const CAltitude &pressureAltitude)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1String("updateOwnPosition"), position, altitude);
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1String("updateOwnPosition"), position, altitude, pressureAltitude);
|
||||
}
|
||||
|
||||
bool CContextOwnAircraftProxy::updateOwnCallsign(const CCallsign &callsign)
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace BlackCore
|
||||
//! \publicsection
|
||||
//! @{
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getOwnAircraft() const override;
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) override;
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const BlackMisc::Aviation::CAltitude &pressureAltitude) override;
|
||||
virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator) override;
|
||||
virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator) override;
|
||||
virtual bool updateOwnAircraftPilot(const BlackMisc::Network::CUser &pilot) override;
|
||||
|
||||
@@ -204,8 +204,7 @@ namespace BlackCore
|
||||
{
|
||||
// Normal / Stealth mode
|
||||
VatPilotPosition pos;
|
||||
//! \fixme we need to distinguish true and pressure altitude
|
||||
pos.altitudePressure = myAircraft.getAltitude().value(CLengthUnit::ft());
|
||||
pos.altitudePressure = myAircraft.getPressureAltitude().value(CLengthUnit::ft());
|
||||
pos.altitudeTrue = myAircraft.getAltitude().value(CLengthUnit::ft());
|
||||
pos.heading = myAircraft.getHeading().value(CAngleUnit::deg());
|
||||
pos.pitch = myAircraft.getPitch().value(CAngleUnit::deg());
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#include "situationform.h"
|
||||
#include "ui_situationform.h"
|
||||
#include "blackmisc/pq/pressure.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QDoubleValidator>
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -29,14 +31,19 @@ namespace BlackGui
|
||||
|
||||
ui->le_Bank->setValidator(new QDoubleValidator(-180.0 + CAngleUnit::deg().getEpsilon(), 180.0, 3, ui->le_Bank));
|
||||
ui->le_Pitch->setValidator(new QDoubleValidator(-180.0 + CAngleUnit::deg().getEpsilon(), 180.0, 3, ui->le_Pitch));
|
||||
ui->le_Pressure->setValidator(new QDoubleValidator(980.0, 1046.0, 2, ui->le_Pressure));
|
||||
|
||||
connect(ui->hs_Bank, &QSlider::valueChanged, this, &CSituationForm::bankSliderChanged);
|
||||
connect(ui->hs_Pitch, &QSlider::valueChanged, this, &CSituationForm::pitchSliderChanged);
|
||||
connect(ui->hs_Pressure, &QSlider::valueChanged, this, &CSituationForm::pressureSliderChanged);
|
||||
connect(ui->le_Bank, &QLineEdit::editingFinished, this, &CSituationForm::bankEntered);
|
||||
connect(ui->le_Pitch, &QLineEdit::editingFinished, this, &CSituationForm::pitchEntered);
|
||||
connect(ui->le_Pressure, &QLineEdit::editingFinished, this, &CSituationForm::pressureEntered);
|
||||
connect(ui->tb_ResetBank, &QToolButton::clicked, this, &CSituationForm::resetBank);
|
||||
connect(ui->tb_ResetPitch, &QToolButton::clicked, this, &CSituationForm::resetPitch);
|
||||
connect(ui->tb_ResetPressure, &QToolButton::clicked, this, &CSituationForm::resetPressure);
|
||||
connect(ui->pb_Set, &QPushButton::clicked, this, &CSituationForm::changeAircraftSituation);
|
||||
connect(ui->pb_SetEnvironment, &QPushButton::clicked, this, &CSituationForm::changeAircraftSituation);
|
||||
connect(ui->comp_Coordinate, &CCoordinateForm::changeCoordinate, this, &CSituationForm::changeAircraftSituation);
|
||||
}
|
||||
|
||||
@@ -50,9 +57,13 @@ namespace BlackGui
|
||||
|
||||
CAircraftSituation CSituationForm::getSituation() const
|
||||
{
|
||||
CAircraftSituation s(ui->comp_Coordinate->getCoordinate());
|
||||
const BlackMisc::Geo::CCoordinateGeodetic position = ui->comp_Coordinate->getCoordinate();
|
||||
CAircraftSituation s(position);
|
||||
s.setBank(this->getBankAngle());
|
||||
s.setPitch(this->getPitchAngle());
|
||||
|
||||
CAltitude pressureAltitude(position.geodeticHeight().toPressureAltitude(this->getBarometricPressureMsl()));
|
||||
s.setPressureAltitude(pressureAltitude);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -84,6 +95,20 @@ namespace BlackGui
|
||||
return CAngle::normalizeDegrees180(vd, RoundDigits);
|
||||
}
|
||||
|
||||
double CSituationForm::getBarometricPressureMslMillibar() const
|
||||
{
|
||||
const QString v(ui->le_Pressure->text().replace(',', '.'));
|
||||
bool ok;
|
||||
double vd = v.toDouble(&ok);
|
||||
if (!ok) { vd = 1013.25; }
|
||||
return vd;
|
||||
}
|
||||
|
||||
CPressure CSituationForm::getBarometricPressureMsl() const
|
||||
{
|
||||
return CPressure (getBarometricPressureMslMillibar(), CPressureUnit::mbar());
|
||||
}
|
||||
|
||||
void CSituationForm::setReadOnly(bool readonly)
|
||||
{
|
||||
ui->comp_Coordinate->setReadOnly(readonly);
|
||||
@@ -128,6 +153,13 @@ namespace BlackGui
|
||||
ui->le_Pitch->setText(QString::number(value));
|
||||
}
|
||||
|
||||
void CSituationForm::pressureSliderChanged(int value)
|
||||
{
|
||||
const int pressure = qRound(this->getBarometricPressureMslMillibar());
|
||||
if (value == pressure) { return; } // avoid roundtrips
|
||||
ui->le_Pressure->setText(QString::number(value));
|
||||
}
|
||||
|
||||
void CSituationForm::bankEntered()
|
||||
{
|
||||
const double ad = this->getBankAngleDegrees();
|
||||
@@ -161,5 +193,22 @@ namespace BlackGui
|
||||
ui->le_Pitch->setText("0");
|
||||
ui->hs_Pitch->setValue(0);
|
||||
}
|
||||
|
||||
void CSituationForm::pressureEntered()
|
||||
{
|
||||
const double pd = this->getBarometricPressureMslMillibar();
|
||||
QString n = QString::number(pd, 'g', 4 + RoundDigits);
|
||||
if (ui->le_Pressure->validator()) { dotToLocaleDecimalPoint(n); }
|
||||
ui->le_Pressure->setText(n);
|
||||
const int pi = qRound(pd);
|
||||
if (pi == ui->hs_Pressure->value()) { return; } // avoid roundtrips
|
||||
ui->hs_Pressure->setValue(pi);
|
||||
}
|
||||
|
||||
void CSituationForm::resetPressure()
|
||||
{
|
||||
ui->le_Pressure->setText("1013.00");
|
||||
ui->hs_Pressure->setValue(1013);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -74,12 +74,21 @@ namespace BlackGui
|
||||
//! Get pitch angle
|
||||
double getPitchAngleDegrees() const;
|
||||
|
||||
//! Get barometric pressure at mean sea level
|
||||
BlackMisc::PhysicalQuantities::CPressure getBarometricPressureMsl() const;
|
||||
|
||||
//! Get pressure at mean sea level
|
||||
double getBarometricPressureMslMillibar() const;
|
||||
|
||||
void bankSliderChanged(int value);
|
||||
void pitchSliderChanged(int value);
|
||||
void pressureSliderChanged(int value);
|
||||
void bankEntered();
|
||||
void resetBank();
|
||||
void pitchEntered();
|
||||
void resetPitch();
|
||||
void pressureEntered();
|
||||
void resetPressure();
|
||||
|
||||
QScopedPointer<Ui::CSituationForm> ui;
|
||||
};
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>386</width>
|
||||
<height>324</height>
|
||||
<width>512</width>
|
||||
<height>439</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -37,7 +37,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Situation" columnstretch="1,1,1,3">
|
||||
<layout class="QGridLayout" name="gl_Situation" columnstretch="1,0,0,0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Bank">
|
||||
<property name="text">
|
||||
@@ -110,7 +110,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<spacer name="vs_Situation">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -145,7 +145,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" alignment="Qt::AlignRight">
|
||||
<item row="3" column="3" alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_Set">
|
||||
<property name="text">
|
||||
<string>set</string>
|
||||
@@ -183,6 +183,112 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Environment">
|
||||
<property name="title">
|
||||
<string>Environment</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="comp_Environment">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Environment" columnstretch="1,0,0,0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Pressure">
|
||||
<property name="text">
|
||||
<string>Pressure MSL (980 - 1046 mbar)</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_Pressure">
|
||||
<property name="text">
|
||||
<string>1013.00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="tb_ResetPressure">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/cross-white.png</normaloff>:/diagona/icons/diagona/icons/cross-white.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSlider" name="hs_Pressure">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>980</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1046</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1013</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_SetEnvironment">
|
||||
<property name="text">
|
||||
<string>set</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
@@ -30,7 +30,10 @@ namespace BlackMisc
|
||||
|
||||
CAircraftSituation::CAircraftSituation(const CCoordinateGeodetic &position, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs, const CAltitude &groundElevation)
|
||||
: m_position(position), m_heading(heading), m_pitch(pitch),
|
||||
m_bank(bank), m_groundSpeed(gs), m_groundElevation(groundElevation) {}
|
||||
m_bank(bank), m_groundSpeed(gs), m_groundElevation(groundElevation)
|
||||
{
|
||||
m_pressureAltitude = position.geodeticHeight().toPressureAltitude(CPressure(1013.25, CPressureUnit::mbar()));
|
||||
}
|
||||
|
||||
CAircraftSituation::CAircraftSituation(const CCallsign &correspondingCallsign, const CCoordinateGeodetic &position, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs, const CAltitude &groundElevation)
|
||||
: m_correspondingCallsign(correspondingCallsign),
|
||||
@@ -38,6 +41,7 @@ namespace BlackMisc
|
||||
m_bank(bank), m_groundSpeed(gs), m_groundElevation(groundElevation)
|
||||
{
|
||||
m_correspondingCallsign.setTypeHint(CCallsign::Aircraft);
|
||||
m_pressureAltitude = position.geodeticHeight().toPressureAltitude(CPressure(1013.25, CPressureUnit::mbar()));
|
||||
}
|
||||
|
||||
QString CAircraftSituation::convertToQString(bool i18n) const
|
||||
@@ -219,6 +223,12 @@ namespace BlackMisc
|
||||
return this->getGroundElevation();
|
||||
}
|
||||
|
||||
void CAircraftSituation::setPressureAltitude(const CAltitude &altitude)
|
||||
{
|
||||
Q_ASSERT(altitude.getAltitudeType() == CAltitude::PressureAltitude);
|
||||
m_pressureAltitude = altitude;
|
||||
}
|
||||
|
||||
void CAircraftSituation::setCallsign(const CCallsign &callsign)
|
||||
{
|
||||
m_correspondingCallsign = callsign;
|
||||
|
||||
@@ -187,6 +187,12 @@ namespace BlackMisc
|
||||
//! Set altitude
|
||||
void setAltitude(const CAltitude &altitude) { m_position.setGeodeticHeight(altitude); }
|
||||
|
||||
//! Get pressure altitude
|
||||
const CAltitude &getPressureAltitude() const { return m_pressureAltitude; }
|
||||
|
||||
//! Set pressure altitude
|
||||
void setPressureAltitude(const CAltitude &altitude);
|
||||
|
||||
//! Get pitch
|
||||
const PhysicalQuantities::CAngle &getPitch() const { return m_pitch; }
|
||||
|
||||
@@ -238,6 +244,7 @@ namespace BlackMisc
|
||||
private:
|
||||
CCallsign m_correspondingCallsign;
|
||||
Geo::CCoordinateGeodetic m_position;
|
||||
Aviation::CAltitude m_pressureAltitude { 0, nullptr };
|
||||
CHeading m_heading;
|
||||
PhysicalQuantities::CAngle m_pitch;
|
||||
PhysicalQuantities::CAngle m_bank;
|
||||
@@ -252,6 +259,7 @@ namespace BlackMisc
|
||||
CAircraftSituation,
|
||||
BLACK_METAMEMBER(correspondingCallsign),
|
||||
BLACK_METAMEMBER(position),
|
||||
BLACK_METAMEMBER(pressureAltitude),
|
||||
BLACK_METAMEMBER(heading),
|
||||
BLACK_METAMEMBER(pitch),
|
||||
BLACK_METAMEMBER(bank),
|
||||
|
||||
@@ -64,11 +64,11 @@ namespace BlackMisc
|
||||
void CAltitude::convertToPressureAltitude(const CPressure &seaLevelPressure)
|
||||
{
|
||||
if (m_altitudeType == PressureAltitude) { return; }
|
||||
static const CPressure standardPressure(1013.25, CPressureUnit::mbar());
|
||||
const CPressure delta = (standardPressure - seaLevelPressure);
|
||||
double deltaV = delta.value(CPressureUnit::mbar());
|
||||
deltaV *= 30.0;
|
||||
addValueSameUnit(deltaV);
|
||||
const CPressure deltaPressure = standardISASeaLevelPressure() - seaLevelPressure;
|
||||
const double deltaPressureV = deltaPressure.value(CPressureUnit::mbar());
|
||||
const double deltaAltitudeV = deltaPressureV * 30.0; // 30.0 ft per mbar
|
||||
CLength deltaAltitude(deltaAltitudeV, CLengthUnit::ft());
|
||||
*this += deltaAltitude;
|
||||
m_altitudeType = PressureAltitude;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +185,12 @@ namespace BlackMisc
|
||||
//! Set altitude
|
||||
void setAltitude(const BlackMisc::Aviation::CAltitude &altitude) { m_situation.setAltitude(altitude); }
|
||||
|
||||
//! Get pressure altitude
|
||||
const BlackMisc::Aviation::CAltitude &getPressureAltitude() const { return m_situation.getPressureAltitude(); }
|
||||
|
||||
//! Set pressure altitude
|
||||
void setPressureAltitude(const BlackMisc::Aviation::CAltitude &altitude) { m_situation.setPressureAltitude(altitude); }
|
||||
|
||||
//! Get groundspeed
|
||||
const BlackMisc::PhysicalQuantities::CSpeed &getGroundSpeed() const { return m_situation.getGroundSpeed(); }
|
||||
|
||||
|
||||
@@ -397,6 +397,7 @@ namespace BlackSimPlugin
|
||||
simDataOwnAircraft.getCom2System(),
|
||||
simDataOwnAircraft.getTransponder(),
|
||||
this->identifier());
|
||||
this->updateOwnSituation(simDataOwnAircraft.getSituation());
|
||||
reverseLookupAndUpdateOwnAircraftModel(simDataOwnAircraft.getModelString());
|
||||
}
|
||||
|
||||
|
||||
@@ -267,6 +267,7 @@ namespace BlackSimPlugin
|
||||
qint8 xpdrModeSb3Raw = 0, xpdrIdentSb3Raw = 0;
|
||||
qint32 groundspeedRaw = 0, pitchRaw = 0, bankRaw = 0, headingRaw = 0;
|
||||
qint64 altitudeRaw = 0;
|
||||
double pressureAltitudeRaw = 0; // 34B0
|
||||
qint32 groundAltitudeRaw = 0;
|
||||
qint64 latitudeRaw = 0, longitudeRaw = 0;
|
||||
qint16 lightsRaw = 0;
|
||||
@@ -311,6 +312,7 @@ namespace BlackSimPlugin
|
||||
(situationN || FSUIPC_Read(0x0560, 8, &latitudeRaw, &dwResult)) &&
|
||||
(situationN || FSUIPC_Read(0x0568, 8, &longitudeRaw, &dwResult)) &&
|
||||
(situationN || FSUIPC_Read(0x0020, 4, &groundAltitudeRaw, &dwResult)) &&
|
||||
(situationN || FSUIPC_Read(0x34B0, 8, &pressureAltitudeRaw, &dwResult)) &&
|
||||
|
||||
// model name
|
||||
FSUIPC_Read(0x3d00, 256, &modelNameRaw, &dwResult) &&
|
||||
@@ -402,11 +404,13 @@ namespace BlackSimPlugin
|
||||
CHeading heading = CHeading(headingRaw * angleCorrectionFactor, CHeading::True, CAngleUnit::deg());
|
||||
CSpeed groundspeed(groundspeedRaw / 65536.0, CSpeedUnit::m_s());
|
||||
CAltitude altitude(altitudeRaw / (65536.0 * 65536.0), CAltitude::MeanSeaLevel, CLengthUnit::m());
|
||||
CAltitude pressureAltitude(pressureAltitudeRaw, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m());
|
||||
situation.setBank(bank);
|
||||
situation.setHeading(heading);
|
||||
situation.setPitch(pitch);
|
||||
situation.setGroundSpeed(groundspeed);
|
||||
situation.setAltitude(altitude);
|
||||
situation.setPressureAltitude(pressureAltitude);
|
||||
aircraft.setSituation(situation);
|
||||
|
||||
} // situation
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace BlackSimPlugin
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "PLANE LONGITUDE", "Degrees");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "PLANE ALTITUDE", "Feet");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "PLANE ALT ABOVE GROUND", "Feet");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "PRESSURE ALTITUDE", "Meters");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "STATIC CG TO GROUND", "Feet");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "PLANE HEADING DEGREES TRUE", "Degrees");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "PLANE PITCH DEGREES", "Degrees");
|
||||
@@ -65,6 +66,7 @@ namespace BlackSimPlugin
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "GENERAL ENG COMBUSTION:2", "Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "GENERAL ENG COMBUSTION:3", "Bool");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraft, "GENERAL ENG COMBUSTION:4", "Bool");
|
||||
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataOwnAircraftTitle, "TITLE", NULL, SIMCONNECT_DATATYPE_STRING256);
|
||||
if (hr != S_OK)
|
||||
{
|
||||
|
||||
@@ -28,17 +28,18 @@ namespace BlackSimPlugin
|
||||
//! \sa SimConnect events http://msdn.microsoft.com/en-us/library/cc526980.aspx
|
||||
struct DataDefinitionOwnAircraft
|
||||
{
|
||||
double latitude; //!< Latitude (deg)
|
||||
double longitude; //!< Longitude (deg)
|
||||
double altitude; //!< Altitude (ft)
|
||||
double altitudeAGL; //!< Altitude above ground (ft)
|
||||
double cgToGround; //!< Static CG to ground (ft)
|
||||
double trueHeading; //!< True heading (deg)
|
||||
double pitch; //!< Pitch (deg)
|
||||
double bank; //!< Bank (deg)
|
||||
double velocity; //!< Ground velocity
|
||||
double elevation; //!< Elevation (ft)
|
||||
double simOnGround; //!< Is aircraft on ground?
|
||||
double latitude; //!< Latitude (deg)
|
||||
double longitude; //!< Longitude (deg)
|
||||
double altitude; //!< Altitude (ft)
|
||||
double altitudeAGL; //!< Altitude above ground (ft)
|
||||
double pressureAltitude; //!< Pressure altitude (m)
|
||||
double cgToGround; //!< Static CG to ground (ft)
|
||||
double trueHeading; //!< True heading (deg)
|
||||
double pitch; //!< Pitch (deg)
|
||||
double bank; //!< Bank (deg)
|
||||
double velocity; //!< Ground velocity
|
||||
double elevation; //!< Elevation (ft)
|
||||
double simOnGround; //!< Is aircraft on ground?
|
||||
|
||||
double lightStrobe; //!< Is strobe light on?
|
||||
double lightLanding; //!< Is landing light on?
|
||||
|
||||
@@ -371,6 +371,7 @@ namespace BlackSimPlugin
|
||||
aircraftSituation.setGroundSpeed(CSpeed(simulatorOwnAircraft.velocity, CSpeedUnit::kts()));
|
||||
aircraftSituation.setGroundElevation(CAltitude(simulatorOwnAircraft.elevation, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
aircraftSituation.setAltitude(CAltitude(simulatorOwnAircraft.altitude, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
aircraftSituation.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitude, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||
|
||||
const CAircraftLights lights(simulatorOwnAircraft.lightStrobe,
|
||||
simulatorOwnAircraft.lightLanding,
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
case CSimConnectDefinitions::RequestOwnAircraft:
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionOwnAircraft) == 30 * sizeof(double), "DataDefinitionOwnAircraft has an incorrect size.");
|
||||
static_assert(sizeof(DataDefinitionOwnAircraft) == 31 * sizeof(double), "DataDefinitionOwnAircraft has an incorrect size.");
|
||||
const DataDefinitionOwnAircraft *ownAircaft = (DataDefinitionOwnAircraft *)&pObjData->dwData;
|
||||
simulatorFsxP3D->updateOwnAircraftFromSimulator(*ownAircaft);
|
||||
break;
|
||||
|
||||
@@ -153,10 +153,15 @@ namespace BlackSimPlugin
|
||||
m_service->getTransponderModeAsync(&m_xplaneData.xpdrMode);
|
||||
m_service->getTransponderIdentAsync(&m_xplaneData.xpdrIdent);
|
||||
m_service->getAllWheelsOnGroundAsync(&m_xplaneData.onGroundAll);
|
||||
m_service->getQNHAsync(&m_xplaneData.seaLeveLPressure);
|
||||
|
||||
CAircraftSituation situation;
|
||||
situation.setPosition({ m_xplaneData.latitude, m_xplaneData.longitude, 0 });
|
||||
CAltitude altitude { m_xplaneData.altitude, CAltitude::MeanSeaLevel, CLengthUnit::m() };
|
||||
situation.setAltitude({ m_xplaneData.altitude, CAltitude::MeanSeaLevel, CLengthUnit::m() });
|
||||
CPressure seaLevelPressure({ m_xplaneData.seaLeveLPressure, CPressureUnit::inHg() });
|
||||
CAltitude pressureAltitude(altitude.toPressureAltitude(seaLevelPressure));
|
||||
situation.setPressureAltitude(pressureAltitude);
|
||||
situation.setHeading({ m_xplaneData.trueHeading, CHeading::True, CAngleUnit::deg() });
|
||||
situation.setPitch({ m_xplaneData.pitch, CAngleUnit::deg() });
|
||||
situation.setBank({ m_xplaneData.roll, CAngleUnit::deg() });
|
||||
|
||||
@@ -182,12 +182,13 @@ namespace BlackSimPlugin
|
||||
double gearReployRatio;
|
||||
QList<double> enginesN1Percentage;
|
||||
double speedBrakeRatio;
|
||||
double seaLeveLPressure;
|
||||
} m_xplaneData;
|
||||
|
||||
void resetData()
|
||||
{
|
||||
m_xplaneData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false,
|
||||
false, false, 0, 0, {}, false
|
||||
false, false, 0, 0, {}, 0.0, 0.0
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -376,6 +376,17 @@ namespace BlackSimPlugin
|
||||
}
|
||||
|
||||
|
||||
double CXSwiftBusServiceProxy::getQNH() const
|
||||
{
|
||||
return m_dbusInterface->callDBusRet<double>(QLatin1String("getQNH"));
|
||||
}
|
||||
|
||||
void CXSwiftBusServiceProxy::getQNHAsync(double *o_qnh)
|
||||
{
|
||||
m_dbusInterface->callDBusAsync(QLatin1String("getQNH"), setterCallback(o_qnh));
|
||||
}
|
||||
|
||||
|
||||
void CXSwiftBusServiceProxy::setCom1Active(int freq)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setCom1Active"), freq);
|
||||
|
||||
@@ -319,12 +319,17 @@ namespace BlackSimPlugin
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getTaxiLightsOn
|
||||
|
||||
//! @{
|
||||
bool getTaxiLightsOn() const;
|
||||
void getTaxiLightsOnAsync(bool *o_taxiLightsOn);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::getQNH
|
||||
//! @{
|
||||
double getQNH() const;
|
||||
void getQNHAsync(double *o_qnh);
|
||||
//! @}
|
||||
|
||||
//! \copydoc XSwiftBus::CService::setCom1Active
|
||||
void setCom1Active(int freq);
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ private:
|
||||
//! \param wgsLatitude WGS latitude
|
||||
//! \param wgsLongitude WGS longitude
|
||||
//! \param altitude
|
||||
void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude);
|
||||
void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude, const BlackMisc::Aviation::CAltitude &pressureAltitude);
|
||||
|
||||
//! Is given main page selected?
|
||||
//! \param mainPage index to be checked
|
||||
|
||||
@@ -47,7 +47,7 @@ bool SwiftGuiStd::reloadOwnAircraft()
|
||||
return changed;
|
||||
}
|
||||
|
||||
void SwiftGuiStd::setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const CAltitude &altitude)
|
||||
void SwiftGuiStd::setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const CAltitude &altitude, const CAltitude &pressureAltitude)
|
||||
{
|
||||
CCoordinateGeodetic coordinate(
|
||||
CLatitude::fromWgs84(wgsLatitude),
|
||||
@@ -56,5 +56,5 @@ void SwiftGuiStd::setTestPosition(const QString &wgsLatitude, const QString &wgs
|
||||
|
||||
m_ownAircraft.setPosition(coordinate);
|
||||
m_ownAircraft.setAltitude(altitude);
|
||||
sGui->getIContextOwnAircraft()->updateOwnPosition(coordinate, altitude);
|
||||
sGui->getIContextOwnAircraft()->updateOwnPosition(coordinate, altitude, pressureAltitude);
|
||||
}
|
||||
|
||||
@@ -37,23 +37,33 @@ void SwiftGuiStd::onMenuClicked()
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == ui->menu_TestLocationsEDRY)
|
||||
{
|
||||
this->setTestPosition("N 049° 18' 17", "E 008° 27' 05", CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
this->setTestPosition("N 049° 18' 17", "E 008° 27' 05",
|
||||
CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft()),
|
||||
CAltitude(312, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::ft()));
|
||||
}
|
||||
else if (sender == ui->menu_TestLocationsEDNX)
|
||||
{
|
||||
this->setTestPosition("N 048° 14′ 22", "E 011° 33′ 41", CAltitude(486, CAltitude::MeanSeaLevel, CLengthUnit::m()));
|
||||
this->setTestPosition("N 048° 14′ 22", "E 011° 33′ 41",
|
||||
CAltitude(486, CAltitude::MeanSeaLevel, CLengthUnit::m()),
|
||||
CAltitude(486, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||
}
|
||||
else if (sender == ui->menu_TestLocationsEDDM)
|
||||
{
|
||||
this->setTestPosition("N 048° 21′ 14", "E 011° 47′ 10", CAltitude(448, CAltitude::MeanSeaLevel, CLengthUnit::m()));
|
||||
this->setTestPosition("N 048° 21′ 14", "E 011° 47′ 10",
|
||||
CAltitude(448, CAltitude::MeanSeaLevel, CLengthUnit::m()),
|
||||
CAltitude(448, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||
}
|
||||
else if (sender == ui->menu_TestLocationsEDDF)
|
||||
{
|
||||
this->setTestPosition("N 50° 2′ 0", "E 8° 34′ 14", CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m()));
|
||||
this->setTestPosition("N 50° 2′ 0", "E 8° 34′ 14",
|
||||
CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m()),
|
||||
CAltitude(100, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||
}
|
||||
else if (sender == ui->menu_TestLocationsLOWW)
|
||||
{
|
||||
this->setTestPosition("N 48° 7′ 6.3588", "E 16° 33′ 39.924", CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m()));
|
||||
this->setTestPosition("N 48° 7′ 6.3588", "E 16° 33′ 39.924",
|
||||
CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m()),
|
||||
CAltitude(100, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||
}
|
||||
else if (sender == ui->menu_WindowFont)
|
||||
{
|
||||
|
||||
@@ -194,6 +194,9 @@ namespace XSwiftBus
|
||||
//! Get whether taxi lights are on
|
||||
bool getTaxiLightsOn() const { return m_taxiLightsOn.get(); }
|
||||
|
||||
//! Get barometric pressure at sea level in inches of mercury.
|
||||
double getQNH() const { return m_qnhInhg.get(); }
|
||||
|
||||
//! Set the current COM1 active frequency in kHz
|
||||
void setCom1Active(int freq) { m_com1Active.set(freq / 10); }
|
||||
|
||||
@@ -275,6 +278,7 @@ namespace XSwiftBus
|
||||
DataRef<xplane::data::sim::aircraft::engine::acf_num_engines> m_numberOfEngines;
|
||||
ArrayDataRef<xplane::data::sim::flightmodel::engine::ENGN_N1_> m_enginesN1Percentage;
|
||||
DataRef<xplane::data::sim::flightmodel2::controls::speedbrake_ratio> m_speedBrakeRatio;
|
||||
DataRef<xplane::data::sim::weather::barometer_sealevel_inhg> m_qnhInhg;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user