Ref T259, Ref T243 formatting

This commit is contained in:
Klaus Basan
2018-03-03 17:18:29 +01:00
parent d6e99ad313
commit 03af49348b
9 changed files with 31 additions and 29 deletions

View File

@@ -1278,7 +1278,7 @@ namespace BlackCore
{ {
const QJsonDocument doc(jsonObject); const QJsonDocument doc(jsonObject);
const QString partsAsString = doc.toJson(QJsonDocument::Compact); const QString partsAsString = doc.toJson(QJsonDocument::Compact);
const CStatusMessage message(getLogCategories(), BlackMisc::CStatusMessage::SeverityInfo, callsign.isEmpty() ? callsign.toQString() + ": " + partsAsString.trimmed() : partsAsString.trimmed()); const CStatusMessage message(getLogCategories(), CStatusMessage::SeverityInfo, callsign.isEmpty() ? callsign.toQString() + ": " + partsAsString.trimmed() : partsAsString.trimmed());
if (m_aircraftPartsHistory.contains(callsign)) if (m_aircraftPartsHistory.contains(callsign))
{ {
CStatusMessageList &msgs = m_aircraftPartsHistory[callsign]; CStatusMessageList &msgs = m_aircraftPartsHistory[callsign];

View File

@@ -87,7 +87,7 @@ namespace BlackCore
} }
} }
BlackMisc::CSequence<QString> CPluginManagerSimulator::acceptedIids() const CSequence<QString> CPluginManagerSimulator::acceptedIids() const
{ {
return return
{ {

View File

@@ -48,9 +48,9 @@ using namespace BlackCore::Db;
namespace BlackCore namespace BlackCore
{ {
CSimulatorCommon::CSimulatorCommon(const CSimulatorPluginInfo &info, CSimulatorCommon::CSimulatorCommon(const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider, IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider,
IWeatherGridProvider *weatherGridProvider, IWeatherGridProvider *weatherGridProvider,
QObject *parent) QObject *parent)
: ISimulator(parent), : ISimulator(parent),
COwnAircraftAware(ownAircraftProvider), COwnAircraftAware(ownAircraftProvider),

View File

@@ -898,7 +898,7 @@ namespace BlackCore
//! we set a dynamically updating offset time here //! we set a dynamically updating offset time here
situation.setCurrentUtcTime(); situation.setCurrentUtcTime();
int offsetMs = self->markReceivedPositionAndGetOffsetTime(situation.getCallsign(), situation.getMSecsSinceEpoch()); const int offsetMs = self->markReceivedPositionAndGetOffsetTime(situation.getCallsign(), situation.getMSecsSinceEpoch());
situation.setTimeOffsetMs(offsetMs); situation.setTimeOffsetMs(offsetMs);
CTransponder::TransponderMode mode = CTransponder::StateStandby; CTransponder::TransponderMode mode = CTransponder::StateStandby;

View File

@@ -27,10 +27,10 @@ namespace BlackMisc
namespace Aviation namespace Aviation
{ {
CAircraftSituation::CAircraftSituation() CAircraftSituation::CAircraftSituation()
: m_groundElevation( { 0, nullptr }, CAltitude::MeanSeaLevel) {} : m_groundElevation({ 0, nullptr }, CAltitude::MeanSeaLevel) {}
CAircraftSituation::CAircraftSituation(const CCallsign &correspondingCallsign) CAircraftSituation::CAircraftSituation(const CCallsign &correspondingCallsign)
: m_correspondingCallsign(correspondingCallsign), m_groundElevation( { 0, nullptr }, CAltitude::MeanSeaLevel) : m_correspondingCallsign(correspondingCallsign), m_groundElevation({ 0, nullptr }, CAltitude::MeanSeaLevel)
{} {}
CAircraftSituation::CAircraftSituation(const CCoordinateGeodetic &position, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs, const CAltitude &groundElevation) CAircraftSituation::CAircraftSituation(const CCoordinateGeodetic &position, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs, const CAltitude &groundElevation)

View File

@@ -222,10 +222,11 @@ namespace BlackMisc
} }
template <typename Derived> template <typename Derived>
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(qint64 currentTimeMsSinceEpoch, CAircraftParts CInterpolator<Derived>::getInterpolatedParts(
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
{ {
// this code is used by linear and spline interpolator // (!) this code is used by linear and spline interpolator
Q_UNUSED(setup); Q_UNUSED(setup);
partsStatus.reset(); partsStatus.reset();
if (currentTimeMsSinceEpoch < 0) { currentTimeMsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); } if (currentTimeMsSinceEpoch < 0) { currentTimeMsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); }
@@ -246,8 +247,8 @@ namespace BlackMisc
// stop if we don't have any parts // stop if we don't have any parts
if (validParts.isEmpty()) { return {}; } if (validParts.isEmpty()) { return {}; }
partsStatus.setSupportsParts(true);
partsStatus.setSupportsParts(true);
CAircraftParts currentParts; CAircraftParts currentParts;
do do
{ {
@@ -343,9 +344,9 @@ namespace BlackMisc
hasOffset ? hasOffset ?
parts.getTimeOffsetMs() : parts.getTimeOffsetMs() :
m_aircraftSituations.isEmpty() ? IRemoteAircraftProvider::DefaultOffsetTimeMs : m_aircraftSituations.front().getTimeOffsetMs(); m_aircraftSituations.isEmpty() ? IRemoteAircraftProvider::DefaultOffsetTimeMs : m_aircraftSituations.front().getTimeOffsetMs();
CAircraftParts copy(parts); CAircraftParts partsCopy(parts);
copy.setTimeOffsetMs(offset); partsCopy.setTimeOffsetMs(offset); // we set the offset of the situation
CInterpolator<Derived>::addAircraftParts(copy); CInterpolator<Derived>::addAircraftParts(partsCopy);
return; return;
} }

View File

@@ -69,9 +69,10 @@ using namespace BlackMisc::Weather;
namespace namespace
{ {
inline QString xswiftbusServiceName() inline const QString &xswiftbusServiceName()
{ {
return QStringLiteral("org.swift-project.xswiftbus"); static const QString name("org.swift-project.xswiftbus");
return name;
} }
} }
@@ -303,7 +304,7 @@ namespace BlackSimPlugin
this->reverseLookupAndUpdateOwnAircraftModel(model); this->reverseLookupAndUpdateOwnAircraftModel(model);
} }
void CSimulatorXPlane::displayStatusMessage(const BlackMisc::CStatusMessage &message) const void CSimulatorXPlane::displayStatusMessage(const CStatusMessage &message) const
{ {
// No assert here as status message may come because of network problems // No assert here as status message may come because of network problems
if (!isConnected()) { return; } if (!isConnected()) { return; }
@@ -586,7 +587,7 @@ namespace BlackSimPlugin
if (! isRemoteAircraftSupportingParts(situation.getCallsign())) if (! isRemoteAircraftSupportingParts(situation.getCallsign()))
{ {
// if aircraft not supporting parts then guess the basics (onGround, gear, lights) // if aircraft not supporting parts then guess the basics (onGround, gear, lights)
//! \todo not working for vtol //! \todo not working for VTOL
BlackMisc::Aviation::CAircraftParts parts; BlackMisc::Aviation::CAircraftParts parts;
parts.setMSecsSinceEpoch(situation.getMSecsSinceEpoch()); parts.setMSecsSinceEpoch(situation.getMSecsSinceEpoch());
parts.setTimeOffsetMs(situation.getTimeOffsetMs()); parts.setTimeOffsetMs(situation.getTimeOffsetMs());
@@ -1009,23 +1010,23 @@ namespace BlackSimPlugin
m_trafficProxy->requestRemoteAircraftData(); m_trafficProxy->requestRemoteAircraftData();
} }
void CSimulatorXPlane::updateRemoteAircraftFromSimulator(const QString &callsign_, double latitude, double longitude, double groundElevation, double modelVerticalOffset) void CSimulatorXPlane::updateRemoteAircraftFromSimulator(const QString &callsign, double latitudeDeg, double longitudeDeg, double elevationMeters, double modelVerticalOffsetMeters)
{ {
CCallsign callsign(callsign_); const CCallsign cs(callsign);
if (!m_xplaneAircraftObjects.contains(callsign)) { return; } if (!m_xplaneAircraftObjects.contains(cs)) { return; }
CElevationPlane elevation(CLatitude(latitude, CAngleUnit::deg()), CLongitude(longitude, CAngleUnit::deg()), CAltitude(groundElevation, CLengthUnit::m())); CElevationPlane elevation(CLatitude(latitudeDeg, CAngleUnit::deg()), CLongitude(longitudeDeg, CAngleUnit::deg()), CAltitude(elevationMeters, CLengthUnit::m()));
elevation.setSinglePointRadius(); elevation.setSinglePointRadius();
CInterpolationHints &hints = m_hints[callsign];
hints.setElevationPlane(elevation); // update elevation
// The entire vertical offset (CG offset) is still very experimental in X-Plane. Libxplanemp simply calculates the lowest Y // The entire vertical offset (CG offset) is still very experimental in X-Plane. Libxplanemp simply calculates the lowest Y
// value from all the OpenGL model vertices. I assume its in meters. // value from all the OpenGL model vertices. I assume its in meters.
// The unit of modelVerticalOffset is still very unknown. This needs to be confirmed. // The unit of modelVerticalOffset is still very unknown. This needs to be confirmed.
hints.setCGAboveGround({ modelVerticalOffset, CLengthUnit::m() }); CInterpolationHints &hints = m_hints[cs];
hints.setElevationPlane(elevation); // update elevation
hints.setCGAboveGround({ modelVerticalOffsetMeters, CLengthUnit::m() });
// set it in the remote aircraft provider // set it in the remote aircraft provider
this->updateAircraftGroundElevation(callsign, elevation); this->updateAircraftGroundElevation(cs, elevation);
} }
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info, BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,

View File

@@ -159,7 +159,7 @@ namespace BlackSimPlugin
bool sendRemoteAircraftPartsToSimulator(const CXPlaneMPAircraft &xplaneAircraft, const BlackMisc::Aviation::CAircraftParts &parts); bool sendRemoteAircraftPartsToSimulator(const CXPlaneMPAircraft &xplaneAircraft, const BlackMisc::Aviation::CAircraftParts &parts);
void requestRemoteAircraftDataFromXPlane(); void requestRemoteAircraftDataFromXPlane();
void updateRemoteAircraftFromSimulator(const QString &callsign, double latitude, double longitude, double elevation, double modelVerticalOffset); void updateRemoteAircraftFromSimulator(const QString &callsign, double latitudeDeg, double longitudeDeg, double elevationMeters, double modelVerticalOffsetMeters);
static constexpr bool c_driverInterpolation = true; static constexpr bool c_driverInterpolation = true;
static constexpr int GuessRemoteAircraftPartsCycle = 20; //!< guess every n-th cycle static constexpr int GuessRemoteAircraftPartsCycle = 20; //!< guess every n-th cycle
@@ -237,7 +237,7 @@ namespace BlackSimPlugin
virtual void stopImpl() override; virtual void stopImpl() override;
private: private:
//! \brief Check if XSwiftBus service is already registered //! Check if XSwiftBus service is already registered
bool isXSwiftBusRunning() const; bool isXSwiftBusRunning() const;
void serviceRegistered(const QString &serviceName); void serviceRegistered(const QString &serviceName);

View File

@@ -64,7 +64,7 @@ namespace BlackSimPlugin
//! \copydoc XSwiftBus::CTraffic::remoteAircraftData //! \copydoc XSwiftBus::CTraffic::remoteAircraftData
//! \remark from simulator to driver for elevation and CG //! \remark from simulator to driver for elevation and CG
void remoteAircraftData(const QString &callsign, double latitude, double longitude, double elevation, double modelVerticalOffset); void remoteAircraftData(const QString &callsign, double latitudeDeg, double longitudeDeg, double elevationMeters, double modelVerticalOffsetMeters);
public slots: public slots:
//! \copydoc XSwiftBus::CTraffic::initialize //! \copydoc XSwiftBus::CTraffic::initialize