mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
refs #863 Moved nested status classes to namespace scope.
This commit is contained in:
@@ -35,7 +35,7 @@ namespace BlackMisc
|
||||
|
||||
BlackMisc::Aviation::CAircraftSituation IInterpolator::getInterpolatedSituation(
|
||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
||||
const CInterpolationHints &hints, InterpolationStatus &status) const
|
||||
const CInterpolationHints &hints, CInterpolationStatus &status) const
|
||||
{
|
||||
status.reset();
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, const CAircraftPartsList &parts, qint64 currentTimeMsSinceEpoch,
|
||||
const CInterpolationAndRenderingSetup &setup, IInterpolator::PartsStatus &partsStatus, bool log) const
|
||||
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
|
||||
{
|
||||
Q_UNUSED(setup);
|
||||
partsStatus.reset();
|
||||
@@ -109,7 +109,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, qint64 currentTimeMsSinceEpoch,
|
||||
const CInterpolationAndRenderingSetup &setup, IInterpolator::PartsStatus &partsStatus, bool log) const
|
||||
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
|
||||
{
|
||||
partsStatus.reset();
|
||||
return this->getInterpolatedParts(callsign, this->m_aircraftParts, currentTimeMsSinceEpoch, setup, partsStatus, log);
|
||||
@@ -398,23 +398,23 @@ namespace BlackMisc
|
||||
return QString("%1 %2 %3").arg(msSinceEpochToTime(t1), msSinceEpochToTime(t2), msSinceEpochToTime(t3));
|
||||
}
|
||||
|
||||
bool IInterpolator::InterpolationStatus::allTrue() const
|
||||
bool CInterpolationStatus::allTrue() const
|
||||
{
|
||||
return m_interpolationSucceeded && m_changedPosition;
|
||||
}
|
||||
|
||||
void IInterpolator::InterpolationStatus::reset()
|
||||
void CInterpolationStatus::reset()
|
||||
{
|
||||
m_changedPosition = false;
|
||||
m_interpolationSucceeded = false;
|
||||
}
|
||||
|
||||
bool IInterpolator::PartsStatus::allTrue() const
|
||||
bool CPartsStatus::allTrue() const
|
||||
{
|
||||
return m_supportsParts;
|
||||
}
|
||||
|
||||
void IInterpolator::PartsStatus::reset()
|
||||
void CPartsStatus::reset()
|
||||
{
|
||||
m_supportsParts = false;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
class CInterpolationHints;
|
||||
struct CInterpolationStatus;
|
||||
struct CPartsStatus;
|
||||
|
||||
//! Interpolator, calculation inbetween positions
|
||||
class BLACKMISC_EXPORT IInterpolator : public QObject
|
||||
@@ -40,74 +42,27 @@ namespace BlackMisc
|
||||
//! Log category
|
||||
static QString getLogCategory() { return "swift.interpolator"; }
|
||||
|
||||
//! Status of interpolation
|
||||
struct BLACKMISC_EXPORT InterpolationStatus // does not link without export/allTrue, reset
|
||||
{
|
||||
public:
|
||||
//! Did interpolation succeed?
|
||||
bool didInterpolationSucceed() const { return m_interpolationSucceeded; }
|
||||
|
||||
//! Set succeeded
|
||||
void setInterpolationSucceeded(bool succeeded) { m_interpolationSucceeded = succeeded; }
|
||||
|
||||
//! Changed position?
|
||||
bool hasChangedPosition() const { return m_changedPosition; }
|
||||
|
||||
//! Set as changed
|
||||
void setChangedPosition(bool changed) { m_changedPosition = changed; }
|
||||
|
||||
//! all OK
|
||||
bool allTrue() const;
|
||||
|
||||
//! Reset to default values
|
||||
void reset();
|
||||
|
||||
private:
|
||||
bool m_changedPosition = false; //!< position was changed
|
||||
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
|
||||
};
|
||||
|
||||
//! Status regarding parts
|
||||
struct BLACKMISC_EXPORT PartsStatus // does not link without export/allTrue, resetx
|
||||
{
|
||||
public:
|
||||
//! all OK
|
||||
bool allTrue() const;
|
||||
|
||||
//! Supporting parts
|
||||
bool isSupportingParts() const { return m_supportsParts; }
|
||||
|
||||
//! Set support flag
|
||||
void setSupportsParts(bool supports) { m_supportsParts = supports; }
|
||||
|
||||
//! Reset to default values
|
||||
void reset();
|
||||
|
||||
private:
|
||||
bool m_supportsParts = false; //!< supports parts for given callsign
|
||||
};
|
||||
|
||||
//! Current interpolated situation
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const;
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const;
|
||||
|
||||
//! Current interpolated situation, to be implemented by subclass
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const = 0;
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const = 0;
|
||||
|
||||
//! Parts before given offset time (aka pending parts)
|
||||
virtual BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||
const Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftPartsList &parts, qint64 cutoffTime,
|
||||
const CInterpolationAndRenderingSetup &setup, PartsStatus &partsStatus, bool log = false) const;
|
||||
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false) const;
|
||||
|
||||
//! Parts before given offset time (aka pending parts)
|
||||
virtual BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||
const BlackMisc::Aviation::CCallsign &callsign, qint64 cutoffTime,
|
||||
const CInterpolationAndRenderingSetup &setup, PartsStatus &partsStatus, bool log = false) const;
|
||||
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false) const;
|
||||
|
||||
//! Add a new aircraft situation
|
||||
void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
@@ -208,6 +163,53 @@ namespace BlackMisc
|
||||
mutable QList<PartsLog> m_partsLogs; //!< logs of parts
|
||||
mutable QList<InterpolationLog> m_interpolationLogs; //!< logs of interpolation
|
||||
};
|
||||
|
||||
//! Status of interpolation
|
||||
struct BLACKMISC_EXPORT CInterpolationStatus
|
||||
{
|
||||
public:
|
||||
//! Did interpolation succeed?
|
||||
bool didInterpolationSucceed() const { return m_interpolationSucceeded; }
|
||||
|
||||
//! Set succeeded
|
||||
void setInterpolationSucceeded(bool succeeded) { m_interpolationSucceeded = succeeded; }
|
||||
|
||||
//! Changed position?
|
||||
bool hasChangedPosition() const { return m_changedPosition; }
|
||||
|
||||
//! Set as changed
|
||||
void setChangedPosition(bool changed) { m_changedPosition = changed; }
|
||||
|
||||
//! all OK
|
||||
bool allTrue() const;
|
||||
|
||||
//! Reset to default values
|
||||
void reset();
|
||||
|
||||
private:
|
||||
bool m_changedPosition = false; //!< position was changed
|
||||
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
|
||||
};
|
||||
|
||||
//! Status regarding parts
|
||||
struct BLACKMISC_EXPORT CPartsStatus
|
||||
{
|
||||
public:
|
||||
//! all OK
|
||||
bool allTrue() const;
|
||||
|
||||
//! Supporting parts
|
||||
bool isSupportingParts() const { return m_supportsParts; }
|
||||
|
||||
//! Set support flag
|
||||
void setSupportsParts(bool supports) { m_supportsParts = supports; }
|
||||
|
||||
//! Reset to default values
|
||||
void reset();
|
||||
|
||||
private:
|
||||
bool m_supportsParts = false; //!< supports parts for given callsign
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const CCallsign &callsign, const CAircraftSituationList &situations, qint64 currentTimeMsSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const
|
||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const
|
||||
{
|
||||
status.reset();
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackMisc
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
||||
const BlackMisc::Simulation::CInterpolationHints &hints, InterpolationStatus &status) const override;
|
||||
const BlackMisc::Simulation::CInterpolationHints &hints, CInterpolationStatus &status) const override;
|
||||
|
||||
//! Log category
|
||||
static QString getLogCategory() { return "swift.interpolatorlinear"; }
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace BlackSimPlugin
|
||||
|
||||
if (m_clientStatus == Disconnected) { return; }
|
||||
|
||||
IInterpolator::InterpolationStatus status;
|
||||
CInterpolationStatus status;
|
||||
CInterpolationHints hints; // \fixme 201701 #865 KB if there is an elevation provider for FS9 add it here or set elevation
|
||||
hints.setLoggingInterpolation(this->getInterpolationSetup().getLogCallsigns().contains(m_callsign));
|
||||
const CAircraftSituation situation = this->m_interpolator.getInterpolatedSituation(m_callsign, -1, this->m_interpolationSetup, hints, status);
|
||||
|
||||
@@ -899,14 +899,14 @@ namespace BlackSimPlugin
|
||||
// fetch parts, as they are needed for ground interpolation
|
||||
const bool useAircraftParts = enableAircraftParts && aircraftWithParts.contains(callsign);
|
||||
const bool logInterpolationAndParts = callsignsToLog.contains(callsign);
|
||||
IInterpolator::PartsStatus partsStatus;
|
||||
CPartsStatus partsStatus;
|
||||
partsStatus.setSupportsParts(useAircraftParts);
|
||||
|
||||
const CInterpolationAndRenderingSetup setup(getInterpolationAndRenderingSetup());
|
||||
const CAircraftParts parts = useAircraftParts ? simObj.getInterpolator()->getInterpolatedParts(callsign, -1, setup, partsStatus, logInterpolationAndParts) : CAircraftParts();
|
||||
|
||||
// get interpolated situation
|
||||
IInterpolator::InterpolationStatus interpolatorStatus;
|
||||
CInterpolationStatus interpolatorStatus;
|
||||
CInterpolationHints hints(m_hints[simObj.getCallsign()]);
|
||||
hints.setAircraftParts(useAircraftParts ? parts : CAircraftParts(), useAircraftParts);
|
||||
hints.setLoggingInterpolation(logInterpolationAndParts);
|
||||
@@ -946,7 +946,7 @@ namespace BlackSimPlugin
|
||||
m_statsUpdateAircraftTimeAvgMs = m_statsUpdateAircraftTimeTotalMs / m_statsUpdateAircraftCountMs;
|
||||
}
|
||||
|
||||
bool CSimulatorFsx::guessAndUpdateRemoteAircraftParts(const CSimConnectObject &simObj, const CAircraftSituation &interpolatedSituation, const IInterpolator::InterpolationStatus &interpolationStatus)
|
||||
bool CSimulatorFsx::guessAndUpdateRemoteAircraftParts(const CSimConnectObject &simObj, const CAircraftSituation &interpolatedSituation, const CInterpolationStatus &interpolationStatus)
|
||||
{
|
||||
if (!simObj.hasValidRequestAndObjectId()) { return false; }
|
||||
if (!interpolationStatus.didInterpolationSucceed()) { return false; }
|
||||
@@ -1017,7 +1017,7 @@ namespace BlackSimPlugin
|
||||
return this->sendRemoteAircraftPartsToSimulator(simObj, ddRemoteAircraftParts, lights);
|
||||
}
|
||||
|
||||
bool CSimulatorFsx::updateRemoteAircraftParts(const CSimConnectObject &simObj, const CAircraftParts &parts, const IInterpolator::PartsStatus &partsStatus)
|
||||
bool CSimulatorFsx::updateRemoteAircraftParts(const CSimConnectObject &simObj, const CAircraftParts &parts, const CPartsStatus &partsStatus)
|
||||
{
|
||||
if (!simObj.hasValidRequestAndObjectId()) { return false; }
|
||||
if (!partsStatus.isSupportingParts()) { return false; }
|
||||
|
||||
@@ -189,11 +189,11 @@ namespace BlackSimPlugin
|
||||
|
||||
//! Update remote aircraft parts (send to FSX)
|
||||
bool updateRemoteAircraftParts(const CSimConnectObject &simObj,
|
||||
const BlackMisc::Aviation::CAircraftParts &parts, const BlackMisc::Simulation::IInterpolator::PartsStatus &partsStatus);
|
||||
const BlackMisc::Aviation::CAircraftParts &parts, const BlackMisc::Simulation::CPartsStatus &partsStatus);
|
||||
|
||||
//! Update remote aircraft parts by guessing (send to FSX)
|
||||
bool guessAndUpdateRemoteAircraftParts(const CSimConnectObject &simObj,
|
||||
const BlackMisc::Aviation::CAircraftSituation &interpolatedSituation, const BlackMisc::Simulation::IInterpolator::InterpolationStatus &interpolationStatus);
|
||||
const BlackMisc::Aviation::CAircraftSituation &interpolatedSituation, const BlackMisc::Simulation::CInterpolationStatus &interpolationStatus);
|
||||
|
||||
//! Send parts to simulator
|
||||
bool sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObj, DataDefinitionRemoteAircraftParts &ddRemoteAircraftParts, const BlackMisc::Aviation::CAircraftLights &lights);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace XBus
|
||||
// if the setup is needed more than once, store it here to avoid multiple locks
|
||||
BlackMisc::Simulation::CInterpolationAndRenderingSetup setup;
|
||||
BlackMisc::Simulation::CInterpolationHints hints;
|
||||
BlackMisc::Simulation::IInterpolator::CPartsStatus status;
|
||||
BlackMisc::Simulation::CPartsStatus status;
|
||||
hints.setAircraftParts(interpolator.getInterpolatedParts(callsign, -1, setup, status));
|
||||
hints.setElevationProvider([this](const auto & situation)
|
||||
{
|
||||
@@ -333,7 +333,7 @@ namespace XBus
|
||||
case xpmpDataType_Position:
|
||||
{
|
||||
BlackMisc::Simulation::CInterpolationAndRenderingSetup setup;
|
||||
BlackMisc::Simulation::IInterpolator::CInterpolationStatus status;
|
||||
BlackMisc::Simulation::CInterpolationStatus status;
|
||||
const auto situation = plane->interpolator.getInterpolatedSituation(plane->callsign, -1, setup, plane->hints(), status);
|
||||
if (! status.didInterpolationSucceed()) { return xpmpData_Unavailable; }
|
||||
if (! status.hasChangedPosition()) { return xpmpData_Unchanged; }
|
||||
|
||||
Reference in New Issue
Block a user