refs #840, style and const-correctness

This commit is contained in:
Klaus Basan
2016-12-23 23:29:35 +00:00
committed by Mathew Sutcliffe
parent de72a678a2
commit 534b9fb09e
13 changed files with 74 additions and 73 deletions

View File

@@ -14,11 +14,12 @@
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/callsign.h"
#include "blackmisc/interpolator.h" #include "blackmisc/interpolator.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/pq/physicalquantity.h"
#include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/aircraftmodellist.h"
#include "blackmisc/simulation/airspaceaircraftsnapshot.h" #include "blackmisc/simulation/airspaceaircraftsnapshot.h"
#include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/pq/physicalquantity.h"
#include "blackmisc/simplecommandparser.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/statusmessage.h" #include "blackmisc/statusmessage.h"
#include "blackmisc/threadutils.h" #include "blackmisc/threadutils.h"

View File

@@ -21,10 +21,6 @@
#include "blackcore/simulator.h" #include "blackcore/simulator.h"
#include "blackmisc/interpolationrenderingsetup.h" #include "blackmisc/interpolationrenderingsetup.h"
#include "blackmisc/aviation/callsignset.h" #include "blackmisc/aviation/callsignset.h"
#include "blackmisc/connectionguard.h"
#include "blackmisc/pq/length.h"
#include "blackmisc/pq/time.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/simulation/aircraftmodelsetloader.h" #include "blackmisc/simulation/aircraftmodelsetloader.h"
#include "blackmisc/simulation/ownaircraftprovider.h" #include "blackmisc/simulation/ownaircraftprovider.h"
#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/simulation/remoteaircraftprovider.h"
@@ -33,6 +29,10 @@
#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/simulation/simulatorplugininfo.h"
#include "blackmisc/simulation/simulatorinternals.h" #include "blackmisc/simulation/simulatorinternals.h"
#include "blackmisc/weather/weathergridprovider.h" #include "blackmisc/weather/weathergridprovider.h"
#include "blackmisc/pq/length.h"
#include "blackmisc/pq/time.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/connectionguard.h"
namespace BlackMisc namespace BlackMisc
{ {

View File

@@ -39,6 +39,7 @@ using namespace BlackMisc;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network; using namespace BlackMisc::Network;
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
using namespace BlackCore; using namespace BlackCore;
namespace BlackGui namespace BlackGui

View File

@@ -38,7 +38,7 @@ namespace BlackGui
explicit CInternalsComponent(QWidget *parent = nullptr); explicit CInternalsComponent(QWidget *parent = nullptr);
//! Destructor //! Destructor
~CInternalsComponent(); virtual ~CInternalsComponent();
protected: protected:
//! \copydoc QWidget::showEvent //! \copydoc QWidget::showEvent

View File

@@ -7,7 +7,7 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackmisc/interpolationrenderingsetup.h" #include "interpolationrenderingsetup.h"
#include "stringutils.h" #include "stringutils.h"
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;

View File

@@ -7,7 +7,7 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackmisc/interpolator.h" #include "interpolator.h"
#include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/callsign.h"
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
@@ -15,7 +15,6 @@ using namespace BlackMisc::Simulation;
namespace BlackMisc namespace BlackMisc
{ {
IInterpolator::IInterpolator(IRemoteAircraftProvider *provider, const QString &objectName, QObject *parent) : IInterpolator::IInterpolator(IRemoteAircraftProvider *provider, const QString &objectName, QObject *parent) :
QObject(parent), QObject(parent),
CRemoteAircraftAware(provider) CRemoteAircraftAware(provider)
@@ -24,7 +23,7 @@ namespace BlackMisc
this->setObjectName(objectName); this->setObjectName(objectName);
} }
BlackMisc::Aviation::CAircraftSituation IInterpolator::getInterpolatedSituation(const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc, BlackMisc::Aviation::CAircraftSituation IInterpolator::getInterpolatedSituation(const CCallsign &callsign, qint64 currentTimeSinceEpoc,
bool isVtolAircraft, InterpolationStatus &status) const bool isVtolAircraft, InterpolationStatus &status) const
{ {
// has to be thread safe // has to be thread safe
@@ -37,7 +36,7 @@ namespace BlackMisc
return currentSituation; return currentSituation;
} }
CAircraftPartsList IInterpolator::getPartsBeforeTime(const CAircraftPartsList &parts, qint64 cutoffTime, BlackMisc::IInterpolator::PartsStatus &partsStatus) const CAircraftPartsList IInterpolator::getPartsBeforeTime(const CAircraftPartsList &parts, qint64 cutoffTime, IInterpolator::PartsStatus &partsStatus) const
{ {
partsStatus.reset(); partsStatus.reset();
partsStatus.setSupportsParts(true); partsStatus.setSupportsParts(true);
@@ -46,7 +45,7 @@ namespace BlackMisc
return parts.findBefore(cutoffTime); return parts.findBefore(cutoffTime);
} }
CAircraftPartsList IInterpolator::getPartsBeforeTime(const CCallsign &callsign, qint64 cutoffTime, BlackMisc::IInterpolator::PartsStatus &partsStatus) const CAircraftPartsList IInterpolator::getPartsBeforeTime(const CCallsign &callsign, qint64 cutoffTime, IInterpolator::PartsStatus &partsStatus) const
{ {
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign"); Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
partsStatus.reset(); partsStatus.reset();

View File

@@ -12,8 +12,8 @@
#ifndef BLACKMISC_INTERPOLATOR_H #ifndef BLACKMISC_INTERPOLATOR_H
#define BLACKMISC_INTERPOLATOR_H #define BLACKMISC_INTERPOLATOR_H
#include "interpolationrenderingsetup.h"
#include "blackmisc/blackmiscexport.h" #include "blackmisc/blackmiscexport.h"
#include "blackmisc/interpolationrenderingsetup.h"
#include "blackmisc/aviation/aircraftpartslist.h" #include "blackmisc/aviation/aircraftpartslist.h"
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/simulation/remoteaircraftprovider.h"
@@ -41,12 +41,8 @@ namespace BlackMisc
static QString getLogCategory() { return "swift.interpolator"; } static QString getLogCategory() { return "swift.interpolator"; }
//! Status of interpolation //! Status of interpolation
struct BLACKMISC_EXPORT InterpolationStatus struct BLACKMISC_EXPORT InterpolationStatus // does not link without export/allTrue, reset
{ {
private:
bool m_changedPosition = false; //!< position was changed
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
public: public:
//! Did interpolation succeed? //! Did interpolation succeed?
bool didInterpolationSucceed() const { return m_interpolationSucceeded; } bool didInterpolationSucceed() const { return m_interpolationSucceeded; }
@@ -65,14 +61,15 @@ namespace BlackMisc
//! Reset to default values //! Reset to default values
void reset(); void reset();
private:
bool m_changedPosition = false; //!< position was changed
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
}; };
//! Status regarding parts //! Status regarding parts
struct BLACKMISC_EXPORT PartsStatus struct BLACKMISC_EXPORT PartsStatus // does not link without export/allTrue, resetx
{ {
private:
bool m_supportsParts = false; //!< supports parts for given callsign
public: public:
//! all OK //! all OK
bool allTrue() const; bool allTrue() const;
@@ -85,6 +82,9 @@ namespace BlackMisc
//! Reset to default values //! Reset to default values
void reset(); void reset();
private:
bool m_supportsParts = false; //!< supports parts for given callsign
}; };
//! Current interpolated situation //! Current interpolated situation
@@ -114,7 +114,7 @@ namespace BlackMisc
//! Enable debug messages etc. //! Enable debug messages etc.
//! \threadsafe //! \threadsafe
void setInterpolatorSetup(const BlackMisc::CInterpolationAndRenderingSetup &setup); void setInterpolatorSetup(const CInterpolationAndRenderingSetup &setup);
protected: protected:
//! Constructor //! Constructor
@@ -122,11 +122,10 @@ namespace BlackMisc
//! Enable debug messages etc. //! Enable debug messages etc.
//! \threadsafe //! \threadsafe
BlackMisc::CInterpolationAndRenderingSetup getInterpolatorSetup() const; CInterpolationAndRenderingSetup getInterpolatorSetup() const;
BlackMisc::CInterpolationAndRenderingSetup m_setup; //!< allows to disable debug messages CInterpolationAndRenderingSetup m_setup; //!< allows to disable debug messages
mutable QReadWriteLock m_lock; //!< lock interpolator mutable QReadWriteLock m_lock; //!< lock interpolator
}; };
} // namespace } // namespace
#endif // guard #endif // guard

View File

@@ -7,20 +7,20 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackmisc/interpolatorlinear.h" #include "interpolatorlinear.h"
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/aircraftsituationlist.h" #include "blackmisc/aviation/aircraftsituationlist.h"
#include "blackmisc/aviation/altitude.h" #include "blackmisc/aviation/altitude.h"
#include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/callsign.h"
#include "blackmisc/aviation/heading.h" #include "blackmisc/aviation/heading.h"
#include "blackmisc/compare.h"
#include "blackmisc/geo/coordinategeodetic.h" #include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/pq/angle.h" #include "blackmisc/pq/angle.h"
#include "blackmisc/pq/length.h" #include "blackmisc/pq/length.h"
#include "blackmisc/pq/physicalquantity.h" #include "blackmisc/pq/physicalquantity.h"
#include "blackmisc/pq/speed.h" #include "blackmisc/pq/speed.h"
#include "blackmisc/pq/units.h" #include "blackmisc/pq/units.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/compare.h"
#include "blackmisc/range.h" #include "blackmisc/range.h"
#include "blackmisc/sequence.h" #include "blackmisc/sequence.h"
#include "blackmisc/statusmessage.h" #include "blackmisc/statusmessage.h"
@@ -29,10 +29,11 @@
#include <QList> #include <QList>
#include <array> #include <array>
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo; using namespace BlackMisc::Geo;
using namespace BlackMisc::Math; using namespace BlackMisc::Math;
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation;
namespace BlackMisc namespace BlackMisc
{ {
@@ -49,11 +50,11 @@ namespace BlackMisc
if (currentTimeMsSinceEpoc < 0) { currentTimeMsSinceEpoc = QDateTime::currentMSecsSinceEpoch(); } if (currentTimeMsSinceEpoc < 0) { currentTimeMsSinceEpoc = QDateTime::currentMSecsSinceEpoch(); }
// find the first situation not in the correct order, keep only the situations before that one // find the first situation not in the correct order, keep only the situations before that one
auto end = std::is_sorted_until(situations.begin(), situations.end(), [](auto &&a, auto &&b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); }); auto end = std::is_sorted_until(situations.begin(), situations.end(), [](auto && a, auto && b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); });
auto validSituations = makeRange(situations.begin(), end); auto validSituations = makeRange(situations.begin(), end);
// find the first situation earlier than the current time // find the first situation earlier than the current time
auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto &&s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; }); auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto && s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
auto situationsNewer = makeRange(validSituations.begin(), pivot); auto situationsNewer = makeRange(validSituations.begin(), pivot);
auto situationsOlder = makeRange(pivot, validSituations.end()); auto situationsOlder = makeRange(pivot, validSituations.end());
@@ -103,8 +104,8 @@ namespace BlackMisc
// < 0 should not happen due to the split, > 1 can happen if new values are delayed beyond split time // < 0 should not happen due to the split, > 1 can happen if new values are delayed beyond split time
// 1) values > 1 mean extrapolation // 1) values > 1 mean extrapolation
// 2) values > 2 mean no new situations coming in // 2) values > 2 mean no new situations coming in
double distanceToSplitTime = newSituation.getAdjustedMSecsSinceEpoch() - currentTimeMsSinceEpoc; const double distanceToSplitTime = newSituation.getAdjustedMSecsSinceEpoch() - currentTimeMsSinceEpoc;
double simulationTimeFraction = 1.0 - (distanceToSplitTime / deltaTime); const double simulationTimeFraction = 1.0 - (distanceToSplitTime / deltaTime);
if (simulationTimeFraction > 2.0) if (simulationTimeFraction > 2.0)
{ {
if (setup.showInterpolatorDebugMessages()) if (setup.showInterpolatorDebugMessages())
@@ -128,9 +129,9 @@ namespace BlackMisc
const CAltitude newAlt(newSituation.getAltitude()); const CAltitude newAlt(newSituation.getAltitude());
Q_ASSERT_X(oldAlt.getReferenceDatum() == newAlt.getReferenceDatum(), Q_FUNC_INFO, "mismatch in reference"); // otherwise no calculation is possible Q_ASSERT_X(oldAlt.getReferenceDatum() == newAlt.getReferenceDatum(), Q_FUNC_INFO, "mismatch in reference"); // otherwise no calculation is possible
currentSituation.setAltitude(CAltitude((newAlt - oldAlt) currentSituation.setAltitude(CAltitude((newAlt - oldAlt)
* simulationTimeFraction * simulationTimeFraction
+ oldAlt, + oldAlt,
oldAlt.getReferenceDatum())); oldAlt.getReferenceDatum()));
if (!setup.isForcingFullInterpolation() && !vtolAiracraft && newVec == oldVec && oldAlt == newAlt) if (!setup.isForcingFullInterpolation() && !vtolAiracraft && newVec == oldVec && oldAlt == newAlt)
{ {
@@ -139,7 +140,7 @@ namespace BlackMisc
} }
// Interpolate heading: HDG = (HdgB - HdgA) * t + HdgA // Interpolate heading: HDG = (HdgB - HdgA) * t + HdgA
CHeading headingBegin = oldSituation.getHeading(); const CHeading headingBegin = oldSituation.getHeading();
CHeading headingEnd = newSituation.getHeading(); CHeading headingEnd = newSituation.getHeading();
if ((headingEnd - headingBegin).value(CAngleUnit::deg()) < -180) if ((headingEnd - headingBegin).value(CAngleUnit::deg()) < -180)
@@ -153,14 +154,14 @@ namespace BlackMisc
} }
currentSituation.setHeading(CHeading((headingEnd - headingBegin) currentSituation.setHeading(CHeading((headingEnd - headingBegin)
* simulationTimeFraction * simulationTimeFraction
+ headingBegin, + headingBegin,
headingBegin.getReferenceNorth())); headingBegin.getReferenceNorth()));
// Interpolate Pitch: Pitch = (PitchB - PitchA) * t + PitchA // Interpolate Pitch: Pitch = (PitchB - PitchA) * t + PitchA
CAngle pitchBegin = oldSituation.getPitch(); const CAngle pitchBegin = oldSituation.getPitch();
CAngle pitchEnd = newSituation.getPitch(); const CAngle pitchEnd = newSituation.getPitch();
CAngle pitch = (pitchEnd - pitchBegin) * simulationTimeFraction + pitchBegin; const CAngle pitch = (pitchEnd - pitchBegin) * simulationTimeFraction + pitchBegin;
currentSituation.setPitch(pitch); currentSituation.setPitch(pitch);
// Interpolate bank: Bank = (BankB - BankA) * t + BankA // Interpolate bank: Bank = (BankB - BankA) * t + BankA
@@ -174,5 +175,4 @@ namespace BlackMisc
+ oldSituation.getGroundSpeed()); + oldSituation.getGroundSpeed());
return currentSituation; return currentSituation;
} }
} // namespace } // namespace

View File

@@ -12,10 +12,9 @@
#ifndef BLACKMISC_INTERPOLATOR_LINEAR_H #ifndef BLACKMISC_INTERPOLATOR_LINEAR_H
#define BLACKMISC_INTERPOLATOR_LINEAR_H #define BLACKMISC_INTERPOLATOR_LINEAR_H
#include "interpolator.h"
#include "blackmisc/blackmiscexport.h" #include "blackmisc/blackmiscexport.h"
#include "blackmisc/interpolator.h"
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include <QString> #include <QString>
#include <QtGlobal> #include <QtGlobal>
@@ -43,9 +42,7 @@ namespace BlackMisc
//! Log category //! Log category
static QString getLogCategory() { return "swift.interpolatorlinear"; } static QString getLogCategory() { return "swift.interpolatorlinear"; }
}; };
} // ns
} // guard
#endif // guard #endif // guard

View File

@@ -16,17 +16,20 @@
*/ */
#include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/aircraftmodellist.h"
#include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/simulation/simulatedaircraftlist.h"
#include "blackmisc/simulation/simulatorplugininfo.h"
#include "blackmisc/simulation/simulatorplugininfolist.h"
#include "blackmisc/simulation/airspaceaircraftsnapshot.h" #include "blackmisc/simulation/airspaceaircraftsnapshot.h"
#include "blackmisc/simulation/distributorlist.h" #include "blackmisc/simulation/distributorlist.h"
#include "blackmisc/simulation/distributorlistpreferences.h" #include "blackmisc/simulation/distributorlistpreferences.h"
#include "blackmisc/simulation/simulatorinternals.h" #include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/modelsettings.h"
#include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/simulation/simulatedaircraftlist.h"
#include "blackmisc/simulation/simulatorinfolist.h" #include "blackmisc/simulation/simulatorinfolist.h"
#include "blackmisc/simulation/fsx/simconnectutilities.h" #include "blackmisc/simulation/simulatorinternals.h"
#include "blackmisc/simulation/simulatorplugininfo.h"
#include "blackmisc/simulation/simulatorplugininfolist.h"
#include "blackmisc/simulation/simulatorsettings.h"
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h" #include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
#include "blackmisc/simulation/fscommon/vpilotmodelruleset.h" #include "blackmisc/simulation/fscommon/vpilotmodelruleset.h"
#include "blackmisc/simulation/fsx/simconnectutilities.h"
#endif // guard #endif // guard

View File

@@ -34,17 +34,17 @@ namespace BlackSimPlugin
MPPositionVelocity positionVelocity; MPPositionVelocity positionVelocity;
// Latitude - integer and decimal places // Latitude - integer and decimal places
double latitude = newSituation.getPosition().latitude().value(CAngleUnit::deg()) * 10001750.0 / 90.0; const double latitude = newSituation.getPosition().latitude().value(CAngleUnit::deg()) * 10001750.0 / 90.0;
positionVelocity.lat_i = static_cast<qint32>(latitude); positionVelocity.lat_i = static_cast<qint32>(latitude);
positionVelocity.lat_f = qAbs((latitude - positionVelocity.lat_i) * 65536); positionVelocity.lat_f = qAbs((latitude - positionVelocity.lat_i) * 65536);
// Longitude - integer and decimal places // Longitude - integer and decimal places
double longitude = newSituation.getPosition().longitude().value(CAngleUnit::deg()) * (65536.0 * 65536.0) / 360.0; const double longitude = newSituation.getPosition().longitude().value(CAngleUnit::deg()) * (65536.0 * 65536.0) / 360.0;
positionVelocity.lon_hi = static_cast<qint32>(longitude); positionVelocity.lon_hi = static_cast<qint32>(longitude);
positionVelocity.lon_lo = qAbs((longitude - positionVelocity.lon_hi) * 65536); positionVelocity.lon_lo = qAbs((longitude - positionVelocity.lon_hi) * 65536);
// Altitude - integer and decimal places // Altitude - integer and decimal places
double altitude = newSituation.getAltitude().value(CLengthUnit::m()); const double altitude = newSituation.getAltitude().value(CLengthUnit::m());
positionVelocity.alt_i = static_cast<qint32>(altitude); positionVelocity.alt_i = static_cast<qint32>(altitude);
positionVelocity.alt_f = (altitude - positionVelocity.alt_i) * 65536; positionVelocity.alt_f = (altitude - positionVelocity.alt_i) * 65536;
@@ -71,7 +71,6 @@ namespace BlackSimPlugin
helperPosition.setLongitude(oldPosition.longitude()); helperPosition.setLongitude(oldPosition.longitude());
CLength distanceLatitudeObj = calculateGreatCircleDistance(oldPosition, helperPosition); CLength distanceLatitudeObj = calculateGreatCircleDistance(oldPosition, helperPosition);
// Now we want the Longitude distance. Latitude must be equal for old and new position. // Now we want the Longitude distance. Latitude must be equal for old and new position.
helperPosition.setLatitude(oldPosition.latitude()); helperPosition.setLatitude(oldPosition.latitude());
helperPosition.setLongitude(newSituation.longitude()); helperPosition.setLongitude(newSituation.longitude());

View File

@@ -26,7 +26,6 @@
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network; using namespace BlackMisc::Network;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Geo; using namespace BlackMisc::Geo;
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
@@ -81,7 +80,7 @@ namespace BlackSimPlugin
situation.setPosition(position); situation.setPosition(position);
situation.setAltitude(CAltitude(dHigh + dLow, CAltitude::MeanSeaLevel, CLengthUnit::m())); situation.setAltitude(CAltitude(dHigh + dLow, CAltitude::MeanSeaLevel, CLengthUnit::m()));
double groundSpeed = positionVelocity.ground_velocity / 65536.0; const double groundSpeed = positionVelocity.ground_velocity / 65536.0;
situation.setGroundSpeed(CSpeed(groundSpeed, CSpeedUnit::m_s())); situation.setGroundSpeed(CSpeed(groundSpeed, CSpeedUnit::m_s()));
FS_PBH pbhstrct; FS_PBH pbhstrct;
@@ -113,7 +112,7 @@ namespace BlackSimPlugin
m_lobbyClient(lobbyClient) m_lobbyClient(lobbyClient)
{ {
connect(lobbyClient.data(), &CLobbyClient::disconnected, this, std::bind(&CSimulatorFs9::simulatorStatusChanged, this, 0)); connect(lobbyClient.data(), &CLobbyClient::disconnected, this, std::bind(&CSimulatorFs9::simulatorStatusChanged, this, 0));
this->m_interpolator = new BlackMisc::CInterpolatorLinear(remoteAircraftProvider, this); m_interpolator = new CInterpolatorLinear(remoteAircraftProvider, this);
m_defaultModel = m_defaultModel =
{ {
"Boeing 737-400", "Boeing 737-400",
@@ -205,7 +204,7 @@ namespace BlackSimPlugin
int CSimulatorFs9::physicallyRemoveAllRemoteAircraft() int CSimulatorFs9::physicallyRemoveAllRemoteAircraft()
{ {
if (this->m_hashFs9Clients.isEmpty()) { return 0; } if (m_hashFs9Clients.isEmpty()) { return 0; }
QList<CCallsign> callsigns(this->m_hashFs9Clients.keys()); QList<CCallsign> callsigns(this->m_hashFs9Clients.keys());
int r = 0; int r = 0;
for (const CCallsign &cs : callsigns) for (const CCallsign &cs : callsigns)
@@ -218,7 +217,7 @@ namespace BlackSimPlugin
CCallsignSet CSimulatorFs9::physicallyRenderedAircraft() const CCallsignSet CSimulatorFs9::physicallyRenderedAircraft() const
{ {
return CCollection<CCallsign>(this->m_hashFs9Clients.keys()); return CCollection<CCallsign>(m_hashFs9Clients.keys());
} }
bool CSimulatorFs9::updateOwnSimulatorCockpit(const CSimulatedAircraft &ownAircraft, const CIdentifier &originator) bool CSimulatorFs9::updateOwnSimulatorCockpit(const CSimulatedAircraft &ownAircraft, const CIdentifier &originator)
@@ -227,9 +226,9 @@ namespace BlackSimPlugin
if (!this->isSimulating()) { return false; } if (!this->isSimulating()) { return false; }
// actually those data should be the same as ownAircraft // actually those data should be the same as ownAircraft
CComSystem newCom1 = ownAircraft.getCom1System(); const CComSystem newCom1 = ownAircraft.getCom1System();
CComSystem newCom2 = ownAircraft.getCom2System(); const CComSystem newCom2 = ownAircraft.getCom2System();
CTransponder newTransponder = ownAircraft.getTransponder(); const CTransponder newTransponder = ownAircraft.getTransponder();
bool changed = false; bool changed = false;
if (newCom1.getFrequencyActive() != this->m_simCom1.getFrequencyActive()) if (newCom1.getFrequencyActive() != this->m_simCom1.getFrequencyActive())
@@ -274,7 +273,9 @@ namespace BlackSimPlugin
{ {
/* Avoid errors from CDirectPlayPeer as it may end in infinite loop */ /* Avoid errors from CDirectPlayPeer as it may end in infinite loop */
if (message.getSeverity() == BlackMisc::CStatusMessage::SeverityError && message.isFromClass<CDirectPlayPeer>()) if (message.getSeverity() == BlackMisc::CStatusMessage::SeverityError && message.isFromClass<CDirectPlayPeer>())
{
return; return;
}
if (message.getSeverity() != BlackMisc::CStatusMessage::SeverityDebug) if (message.getSeverity() != BlackMisc::CStatusMessage::SeverityDebug)
{ {
@@ -303,7 +304,7 @@ namespace BlackSimPlugin
if (m_useFsuipc && m_fsuipc) if (m_useFsuipc && m_fsuipc)
{ {
CSimulatedAircraft fsuipcAircraft(getOwnAircraft()); CSimulatedAircraft fsuipcAircraft(getOwnAircraft());
bool ok = m_fsuipc->read(fsuipcAircraft, true, true, true); const bool ok = m_fsuipc->read(fsuipcAircraft, true, true, true);
if (ok) if (ok)
{ {
updateOwnAircraftFromSimulator(fsuipcAircraft); updateOwnAircraftFromSimulator(fsuipcAircraft);
@@ -375,7 +376,8 @@ namespace BlackSimPlugin
void CSimulatorFs9::disconnectAllClients() void CSimulatorFs9::disconnectAllClients()
{ {
// Stop all FS9 client tasks // Stop all FS9 client tasks
for (auto fs9Client : m_hashFs9Clients.keys()) const QList<CCallsign> callsigns(m_hashFs9Clients.keys());
for (auto fs9Client : callsigns)
{ {
physicallyRemoveRemoteAircraft(fs9Client); physicallyRemoveRemoteAircraft(fs9Client);
} }

View File

@@ -43,7 +43,7 @@ namespace XBus
CTraffic(QObject *parent); CTraffic(QObject *parent);
//! Destructor //! Destructor
~CTraffic(); virtual ~CTraffic();
//! DBus interface name //! DBus interface name
static const QString &InterfaceName() static const QString &InterfaceName()