mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
refs #863 Change callsign parameter to be a member instead.
This commit is contained in:
@@ -37,14 +37,15 @@ namespace BlackMisc
|
|||||||
namespace Simulation
|
namespace Simulation
|
||||||
{
|
{
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
CInterpolator<Derived>::CInterpolator(const QString &objectName, QObject *parent) :
|
CInterpolator<Derived>::CInterpolator(const QString &objectName, const BlackMisc::Aviation::CCallsign &callsign, QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent),
|
||||||
|
m_callsign(callsign)
|
||||||
{
|
{
|
||||||
this->setObjectName(objectName);
|
this->setObjectName(objectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation(const CCallsign &callsign, qint64 currentTimeMsSinceEpoc,
|
CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation(qint64 currentTimeMsSinceEpoc,
|
||||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status)
|
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status)
|
||||||
{
|
{
|
||||||
status.reset();
|
status.reset();
|
||||||
@@ -113,7 +114,7 @@ namespace BlackMisc
|
|||||||
if (hints.isLoggingInterpolation())
|
if (hints.isLoggingInterpolation())
|
||||||
{
|
{
|
||||||
log.timestamp = currentTimeMsSinceEpoc;
|
log.timestamp = currentTimeMsSinceEpoc;
|
||||||
log.callsign = callsign;
|
log.callsign = m_callsign;
|
||||||
log.vtolAircraft = hints.isVtolAircraft();
|
log.vtolAircraft = hints.isVtolAircraft();
|
||||||
log.currentSituation = currentSituation;
|
log.currentSituation = currentSituation;
|
||||||
log.useParts = hints.hasAircraftParts();
|
log.useParts = hints.hasAircraftParts();
|
||||||
@@ -173,7 +174,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(const CCallsign &callsign, qint64 currentTimeMsSinceEpoch,
|
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(qint64 currentTimeMsSinceEpoch,
|
||||||
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log)
|
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log)
|
||||||
{
|
{
|
||||||
Q_UNUSED(setup);
|
Q_UNUSED(setup);
|
||||||
@@ -227,7 +228,7 @@ namespace BlackMisc
|
|||||||
if (log)
|
if (log)
|
||||||
{
|
{
|
||||||
PartsLog log;
|
PartsLog log;
|
||||||
log.callsign = callsign;
|
log.callsign = m_callsign;
|
||||||
log.timestamp = currentTimeMsSinceEpoch;
|
log.timestamp = currentTimeMsSinceEpoch;
|
||||||
log.parts = currentParts;
|
log.parts = currentParts;
|
||||||
CInterpolator::logParts(log);
|
CInterpolator::logParts(log);
|
||||||
|
|||||||
@@ -44,13 +44,11 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Current interpolated situation
|
//! Current interpolated situation
|
||||||
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||||
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc,
|
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status);
|
||||||
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status);
|
|
||||||
|
|
||||||
//! Parts before given offset time (aka pending parts)
|
//! Parts before given offset time (aka pending parts)
|
||||||
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||||
const Aviation::CCallsign &callsign, qint64 cutoffTime,
|
qint64 cutoffTime, const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false);
|
||||||
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false);
|
|
||||||
|
|
||||||
//! Add a new aircraft situation
|
//! Add a new aircraft situation
|
||||||
void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||||
@@ -81,6 +79,7 @@ namespace BlackMisc
|
|||||||
protected:
|
protected:
|
||||||
BlackMisc::Aviation::CAircraftSituationList m_aircraftSituations; //!< recent situations
|
BlackMisc::Aviation::CAircraftSituationList m_aircraftSituations; //!< recent situations
|
||||||
BlackMisc::Aviation::CAircraftPartsList m_aircraftParts; //!< recent parts
|
BlackMisc::Aviation::CAircraftPartsList m_aircraftParts; //!< recent parts
|
||||||
|
BlackMisc::Aviation::CCallsign m_callsign; //!< callsign
|
||||||
|
|
||||||
//! Log for interpolation
|
//! Log for interpolation
|
||||||
struct InterpolationLog
|
struct InterpolationLog
|
||||||
@@ -108,7 +107,7 @@ namespace BlackMisc
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CInterpolator(const QString &objectName, QObject *parent);
|
CInterpolator(const QString &objectName, const BlackMisc::Aviation::CCallsign &callsign, QObject *parent);
|
||||||
|
|
||||||
//! Log current interpolation cycle, only stores in memory, for performance reasons
|
//! Log current interpolation cycle, only stores in memory, for performance reasons
|
||||||
//! \remark const to allow const interpolator functions
|
//! \remark const to allow const interpolator functions
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ namespace BlackMisc
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CInterpolatorLinear(QObject *parent = nullptr) :
|
CInterpolatorLinear(const BlackMisc::Aviation::CCallsign &callsign, QObject *parent = nullptr) :
|
||||||
CInterpolator("CInterpolatorLinear", parent)
|
CInterpolator("CInterpolatorLinear", callsign, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Linear function that performs the actual interpolation
|
//! Linear function that performs the actual interpolation
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ namespace BlackMisc
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CInterpolatorSpline(QObject *parent = nullptr) :
|
CInterpolatorSpline(const BlackMisc::Aviation::CCallsign &callsign, QObject *parent = nullptr) :
|
||||||
CInterpolator("CInterpolatorSpline", parent)
|
CInterpolator("CInterpolatorSpline", callsign, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Cubic function that performs the actual interpolation
|
//! Cubic function that performs the actual interpolation
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ namespace BlackSimPlugin
|
|||||||
const CTime &updateInterval, QObject *owner) :
|
const CTime &updateInterval, QObject *owner) :
|
||||||
CDirectPlayPeer(owner, callsign),
|
CDirectPlayPeer(owner, callsign),
|
||||||
m_updateInterval(updateInterval),
|
m_updateInterval(updateInterval),
|
||||||
|
m_interpolator(callsign),
|
||||||
m_modelName(modelName)
|
m_modelName(modelName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -184,7 +185,7 @@ namespace BlackSimPlugin
|
|||||||
CInterpolationStatus status;
|
CInterpolationStatus status;
|
||||||
CInterpolationHints hints; // \fixme 201701 #865 KB if there is an elevation provider for FS9 add it here or set elevation
|
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));
|
hints.setLoggingInterpolation(this->getInterpolationSetup().getLogCallsigns().contains(m_callsign));
|
||||||
const CAircraftSituation situation = this->m_interpolator.getInterpolatedSituation(m_callsign, -1, this->m_interpolationSetup, hints, status);
|
const CAircraftSituation situation = this->m_interpolator.getInterpolatedSituation(-1, this->m_interpolationSetup, hints, status);
|
||||||
|
|
||||||
// Test only for successful interpolation. FS9 requires constant positions
|
// Test only for successful interpolation. FS9 requires constant positions
|
||||||
if (!status.didInterpolationSucceed()) { return; }
|
if (!status.didInterpolationSucceed()) { return; }
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
CSimConnectObject::CSimConnectObject(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, DWORD requestId) :
|
CSimConnectObject::CSimConnectObject(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, DWORD requestId) :
|
||||||
m_aircraft(aircraft), m_requestId(requestId), m_validRequestId(true),
|
m_aircraft(aircraft), m_requestId(requestId), m_validRequestId(true),
|
||||||
m_interpolator(QSharedPointer<BlackMisc::Simulation::CInterpolatorLinear>::create())
|
m_interpolator(QSharedPointer<BlackMisc::Simulation::CInterpolatorLinear>::create(aircraft.getCallsign()))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool CSimConnectObject::isPendingAdded() const
|
bool CSimConnectObject::isPendingAdded() const
|
||||||
|
|||||||
@@ -903,14 +903,14 @@ namespace BlackSimPlugin
|
|||||||
partsStatus.setSupportsParts(useAircraftParts);
|
partsStatus.setSupportsParts(useAircraftParts);
|
||||||
|
|
||||||
const CInterpolationAndRenderingSetup setup(getInterpolationAndRenderingSetup());
|
const CInterpolationAndRenderingSetup setup(getInterpolationAndRenderingSetup());
|
||||||
const CAircraftParts parts = useAircraftParts ? simObj.getInterpolator()->getInterpolatedParts(callsign, -1, setup, partsStatus, logInterpolationAndParts) : CAircraftParts();
|
const CAircraftParts parts = useAircraftParts ? simObj.getInterpolator()->getInterpolatedParts(-1, setup, partsStatus, logInterpolationAndParts) : CAircraftParts();
|
||||||
|
|
||||||
// get interpolated situation
|
// get interpolated situation
|
||||||
CInterpolationStatus interpolatorStatus;
|
CInterpolationStatus interpolatorStatus;
|
||||||
CInterpolationHints hints(m_hints[simObj.getCallsign()]);
|
CInterpolationHints hints(m_hints[simObj.getCallsign()]);
|
||||||
hints.setAircraftParts(useAircraftParts ? parts : CAircraftParts(), useAircraftParts);
|
hints.setAircraftParts(useAircraftParts ? parts : CAircraftParts(), useAircraftParts);
|
||||||
hints.setLoggingInterpolation(logInterpolationAndParts);
|
hints.setLoggingInterpolation(logInterpolationAndParts);
|
||||||
const CAircraftSituation interpolatedSituation = simObj.getInterpolator()->getInterpolatedSituation(callsign, currentTimestamp, setup, hints, interpolatorStatus);
|
const CAircraftSituation interpolatedSituation = simObj.getInterpolator()->getInterpolatedSituation(currentTimestamp, setup, hints, interpolatorStatus);
|
||||||
|
|
||||||
if (interpolatorStatus.allTrue())
|
if (interpolatorStatus.allTrue())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "blackmisc/simulation/interpolator.h"
|
#include "blackmisc/simulation/interpolator.h"
|
||||||
#include "blackmisc/simulation/interpolationhints.h"
|
#include "blackmisc/simulation/interpolationhints.h"
|
||||||
|
#include "blackmisc/aviation/callsign.h"
|
||||||
#include "XPMPMultiplayer.h"
|
#include "XPMPMultiplayer.h"
|
||||||
#include <XPLM/XPLMProcessing.h>
|
#include <XPLM/XPLMProcessing.h>
|
||||||
#include <XPLM/XPLMUtilities.h>
|
#include <XPLM/XPLMUtilities.h>
|
||||||
@@ -28,7 +29,7 @@ namespace XBus
|
|||||||
{
|
{
|
||||||
|
|
||||||
CTraffic::Plane::Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_)
|
CTraffic::Plane::Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_)
|
||||||
: id(id_), callsign(callsign_), aircraftIcao(aircraftIcao_), airlineIcao(airlineIcao_), livery(livery_)
|
: id(id_), callsign(callsign_), aircraftIcao(aircraftIcao_), airlineIcao(airlineIcao_), livery(livery_), interpolator(callsign)
|
||||||
{
|
{
|
||||||
std::memset(static_cast<void *>(&surfaces), 0, sizeof(surfaces));
|
std::memset(static_cast<void *>(&surfaces), 0, sizeof(surfaces));
|
||||||
surfaces.lights.bcnLights = surfaces.lights.landLights = surfaces.lights.navLights = surfaces.lights.strbLights = 1;
|
surfaces.lights.bcnLights = surfaces.lights.landLights = surfaces.lights.navLights = surfaces.lights.strbLights = 1;
|
||||||
@@ -49,7 +50,7 @@ namespace XBus
|
|||||||
BlackMisc::Simulation::CInterpolationAndRenderingSetup setup;
|
BlackMisc::Simulation::CInterpolationAndRenderingSetup setup;
|
||||||
BlackMisc::Simulation::CInterpolationHints hints;
|
BlackMisc::Simulation::CInterpolationHints hints;
|
||||||
BlackMisc::Simulation::CPartsStatus status;
|
BlackMisc::Simulation::CPartsStatus status;
|
||||||
hints.setAircraftParts(interpolator.getInterpolatedParts(callsign, -1, setup, status));
|
hints.setAircraftParts(interpolator.getInterpolatedParts(-1, setup, status));
|
||||||
hints.setElevationProvider([this](const auto & situation)
|
hints.setElevationProvider([this](const auto & situation)
|
||||||
{
|
{
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
@@ -333,7 +334,7 @@ namespace XBus
|
|||||||
{
|
{
|
||||||
BlackMisc::Simulation::CInterpolationAndRenderingSetup setup;
|
BlackMisc::Simulation::CInterpolationAndRenderingSetup setup;
|
||||||
BlackMisc::Simulation::CInterpolationStatus status;
|
BlackMisc::Simulation::CInterpolationStatus status;
|
||||||
const auto situation = plane->interpolator.getInterpolatedSituation(plane->callsign, -1, setup, plane->hints(), status);
|
const auto situation = plane->interpolator.getInterpolatedSituation(-1, setup, plane->hints(), status);
|
||||||
if (! status.didInterpolationSucceed()) { return xpmpData_Unavailable; }
|
if (! status.didInterpolationSucceed()) { return xpmpData_Unavailable; }
|
||||||
if (! status.hasChangedPosition()) { return xpmpData_Unchanged; }
|
if (! status.hasChangedPosition()) { return xpmpData_Unchanged; }
|
||||||
|
|
||||||
|
|||||||
@@ -56,13 +56,13 @@ namespace BlackMiscTest
|
|||||||
|
|
||||||
void CTestInterpolator::linearInterpolator()
|
void CTestInterpolator::linearInterpolator()
|
||||||
{
|
{
|
||||||
CInterpolatorLinear interpolator;
|
CCallsign cs("SWIFT");
|
||||||
|
CInterpolatorLinear interpolator(cs);
|
||||||
|
|
||||||
// fixed time so everything can be debugged
|
// fixed time so everything can be debugged
|
||||||
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch();
|
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch();
|
||||||
const qint64 deltaT = 5000; // ms
|
const qint64 deltaT = 5000; // ms
|
||||||
const qint64 offset = 5000;
|
const qint64 offset = 5000;
|
||||||
CCallsign cs("SWIFT");
|
|
||||||
for (int i = 0; i < IRemoteAircraftProvider::MaxSituationsPerCallsign; i++)
|
for (int i = 0; i < IRemoteAircraftProvider::MaxSituationsPerCallsign; i++)
|
||||||
{
|
{
|
||||||
CAircraftSituation s(getTestSituation(cs, i, ts, deltaT, offset));
|
CAircraftSituation s(getTestSituation(cs, i, ts, deltaT, offset));
|
||||||
@@ -95,7 +95,7 @@ namespace BlackMiscTest
|
|||||||
// from: ts - 2 * deltaT + offset
|
// from: ts - 2 * deltaT + offset
|
||||||
// to: ts + offset
|
// to: ts + offset
|
||||||
CAircraftSituation currentSituation(interpolator.getInterpolatedSituation
|
CAircraftSituation currentSituation(interpolator.getInterpolatedSituation
|
||||||
(cs, currentTime, setup, hints, status)
|
(currentTime, setup, hints, status)
|
||||||
);
|
);
|
||||||
QVERIFY2(status.didInterpolationSucceed(), "Interpolation was not succesful");
|
QVERIFY2(status.didInterpolationSucceed(), "Interpolation was not succesful");
|
||||||
QVERIFY2(status.hasChangedPosition(), "Interpolation did not changed");
|
QVERIFY2(status.hasChangedPosition(), "Interpolation did not changed");
|
||||||
@@ -125,7 +125,7 @@ namespace BlackMiscTest
|
|||||||
// from: ts - 2* deltaT + offset
|
// from: ts - 2* deltaT + offset
|
||||||
// to: ts + offset
|
// to: ts + offset
|
||||||
CAircraftSituation currentSituation(interpolator.getInterpolatedSituation
|
CAircraftSituation currentSituation(interpolator.getInterpolatedSituation
|
||||||
(cs, currentTime, setup, hints, status)
|
(currentTime, setup, hints, status)
|
||||||
);
|
);
|
||||||
QVERIFY2(status.allTrue(), "Failed interpolation");
|
QVERIFY2(status.allTrue(), "Failed interpolation");
|
||||||
QVERIFY2(currentSituation.getCallsign() == cs, "Wrong callsign");
|
QVERIFY2(currentSituation.getCallsign() == cs, "Wrong callsign");
|
||||||
@@ -145,7 +145,7 @@ namespace BlackMiscTest
|
|||||||
for (qint64 currentTime = ts - 2 * deltaT; currentTime < ts; currentTime += 250)
|
for (qint64 currentTime = ts - 2 * deltaT; currentTime < ts; currentTime += 250)
|
||||||
{
|
{
|
||||||
CPartsStatus partsStatus;
|
CPartsStatus partsStatus;
|
||||||
CAircraftParts pl(interpolator.getInterpolatedParts(cs, ts, setup, partsStatus));
|
CAircraftParts pl(interpolator.getInterpolatedParts(ts, setup, partsStatus));
|
||||||
fetchedParts++;
|
fetchedParts++;
|
||||||
QVERIFY2(partsStatus.isSupportingParts(), "Parts not supported");
|
QVERIFY2(partsStatus.isSupportingParts(), "Parts not supported");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user