Formatting, minor tweaks

This commit is contained in:
Klaus Basan
2018-04-27 02:32:41 +02:00
committed by Roland Winklmeier
parent a8ab2a37b8
commit 1f3e5c6abf
11 changed files with 34 additions and 13 deletions

View File

@@ -41,7 +41,6 @@ using namespace BlackMisc::Simulation;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Weather;
using namespace BlackCore;
using namespace BlackCore::Db;
namespace BlackCore
@@ -317,8 +316,10 @@ namespace BlackCore
this->stopHighlighting();
this->logicallyRemoveRemoteAircraft(callsign);
if (!this->isAircraftInRange(callsign)) { return false; }
const QPointer<CSimulatorCommon> myself(this);
QTimer::singleShot(2500, this, [ = ]
{
if (myself.isNull()) { return; }
if (this->isShuttingDown()) { return; }
if (!this->isAircraftInRange(callsign)) { return; }
const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign);
@@ -583,6 +584,16 @@ namespace BlackCore
m_timerId = -1;
}
QString CSimulatorCommon::getInvalidSituationLogMessage(const CCallsign &callsign, const CInterpolationStatus &status, const QString &details) const
{
static const QString msg("Cs: '%1' Interpolation: '%2'");
const QString m = msg.arg(callsign.asString(), status.toQString());
if (details.isEmpty()) { return m; }
static const QString addDetails(" details: '%1'");
return m + addDetails.arg(details);
}
void CSimulatorCommon::onRecalculatedRenderedAircraft(const CAirspaceAircraftSnapshot &snapshot)
{
if (!snapshot.isValidSnapshot()) { return;}
@@ -729,7 +740,7 @@ namespace BlackCore
const PartsLog p = m_interpolationLogger.getLastPartsLog(cs);
QString dm;
static const QString sep("\n");
static const QString sep("\n------\n");
if (s.tsCurrent > 0)
{
dm = QStringLiteral("Setup: ") % s.usedSetup.toQString(true) %
@@ -744,8 +755,10 @@ namespace BlackCore
}
const int t = 4500 + (qrand() % 1000); // makes sure not always using the same time difference
const QPointer<CSimulatorCommon> myself(this);
QTimer::singleShot(t, this, [ = ]
{
if (myself.isNull()) { return; }
this->displayLoggedSituationInSimulator(cs, stopLogging, times - 1);
});
}

View File

@@ -198,6 +198,9 @@ namespace BlackCore
//! Kill timer if id is valid
void safeKillTimer();
//! Info about invalid situation
QString getInvalidSituationLogMessage(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Simulation::CInterpolationStatus &status, const QString &details = {}) const;
bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold)
bool m_autoCalcAirportDistance = true; //!< automatically calculate airport distance and bearing
int m_timerId = -1; //!< dispatch timer id

View File

@@ -99,5 +99,6 @@ namespace BlackMisc
} // ns
Q_DECLARE_METATYPE(BlackMisc::Aviation::CHeading)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CHeading::ReferenceNorth)
#endif // guard

View File

@@ -357,7 +357,7 @@ namespace BlackMisc
template <class MU, class PQ>
QString CPhysicalQuantity<MU, PQ>::convertToQString(bool i18n) const
{
if (this->isNull()) { return i18n ? QCoreApplication::translate("CPhysicalQuantity", "undefined") : "undefined"; }
if (this->isNull()) { return QStringLiteral("null"); }
return this->valueRoundedWithUnit(this->getUnit(), -1, i18n);
}

View File

@@ -19,7 +19,6 @@ namespace BlackMisc
{
namespace PhysicalQuantities
{
/*!
* Speed class, e.g. "m/s", "NM/h", "km/h", "ft/s"
*/
@@ -36,8 +35,8 @@ namespace BlackMisc
CSpeed(const QString &unitString) : CPhysicalQuantity(unitString) {}
};
}
}
} // ns
} // ns
Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CSpeed)

View File

@@ -31,7 +31,7 @@ namespace BlackMisc
{
namespace Simulation
{
//! Current situation in the sky analyzed.
//! Current situation in the skies analyzed.
class BLACKMISC_EXPORT CAirspaceAircraftSnapshot : public CValueObject<CAirspaceAircraftSnapshot>
{
public:

View File

@@ -15,6 +15,7 @@
#include "simulatorplugininfo.h"
#include "aircraftmodel.h"
#include "blackmisc/provider.h"
#include "blackmisc/pq/length.h"
#include "blackmisc/geo/coordinategeodeticlist.h"
#include "blackmisc/geo/elevationplane.h"

View File

@@ -121,9 +121,12 @@ namespace BlackSimPlugin
//! Set Simconnect object id
void setObjectId(DWORD id);
//! Set Simconnect object id
//! Get Simconnect object id
DWORD getObjectId() const { return m_objectId; }
//! Get Simconnect object id
QString getObjectIdAsString() const { return QString::number(this->getObjectId()); }
//! Valid request id?
bool hasValidRequestId() const { return m_validRequestId; }

View File

@@ -723,8 +723,10 @@ namespace BlackSimPlugin
if (!toBeAddedAircraft.isEmpty())
{
const CSimulatedAircraft nextPendingAircraft(m_addPendingAircraft.front());
const QPointer <CSimulatorFsxCommon> myself(this);
QTimer::singleShot(100, this, [ = ]
{
if (myself.isNull()) { return; }
this->physicallyAddRemoteAircraftImpl(nextPendingAircraft, mode);
});
}
@@ -742,7 +744,7 @@ namespace BlackSimPlugin
const CSimConnectObject simObject = m_simConnectObjects.getSimObjectForObjectId(objectID);
if (!simObject.hasValidRequestAndObjectId()) { return false; } // object id from somewhere else
const CCallsign callsign(simObject.getCallsign());
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign for removed object");
if (simObject.isPendingRemoved())
{

View File

@@ -97,7 +97,7 @@ namespace BlackSimPlugin
};
//! FSX Simulator Implementation
class CSimulatorFsxCommon : public BlackSimPlugin::FsCommon::CSimulatorFsCommon
class CSimulatorFsxCommon : public FsCommon::CSimulatorFsCommon
{
Q_OBJECT
Q_INTERFACES(BlackCore::ISimulator)

View File

@@ -721,12 +721,11 @@ namespace BlackSimPlugin
}
else
{
CLogMessage(this).warning("Invalid situation for callsign: '%1' info: '%2'")
<< callsign
<< interpolatorStatus.toQString();
CLogMessage(this).warning(this->getInvalidSituationLogMessage(callsign, interpolatorStatus));
}
this->updateRemoteAircraftParts(xplaneAircraft, parts, partsStatus);
} // all callsigns
const qint64 dt = QDateTime::currentMSecsSinceEpoch() - currentTimestamp;