mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
Remove old xswiftbus interpolator code
ref T259
This commit is contained in:
committed by
Klaus Basan
parent
66b661fe9c
commit
e1538573fe
@@ -371,8 +371,6 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (!isConnected()) { return false; }
|
||||
|
||||
if (c_driverInterpolation)
|
||||
{
|
||||
if (mode == CInterpolatorMulti::ModeUnknown) { return false; }
|
||||
if (callsign.isEmpty())
|
||||
{
|
||||
@@ -385,12 +383,6 @@ namespace BlackSimPlugin
|
||||
return m_xplaneAircraftObjects[callsign].setInterpolatorMode(mode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_trafficProxy->setInterpolatorMode(callsign.asString(), mode == CInterpolatorMulti::ModeSpline);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QDBusConnection CSimulatorXPlane::connectionFromString(const QString &str)
|
||||
{
|
||||
@@ -402,17 +394,9 @@ namespace BlackSimPlugin
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
|
||||
{
|
||||
if (c_driverInterpolation)
|
||||
{
|
||||
return m_xplaneAircraftObjects.contains(callsign);
|
||||
}
|
||||
else
|
||||
{
|
||||
//! \todo XP implement isRenderedAircraft correctly. This is a workaround, but not telling me if a callsign is really(!) visible in simulator
|
||||
return getAircraftInRangeForCallsign(callsign).isRendered();
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::updateOwnSimulatorCockpit(const Simulation::CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||
{
|
||||
@@ -501,8 +485,6 @@ namespace BlackSimPlugin
|
||||
bool CSimulatorXPlane::physicallyAddRemoteAircraft(const CSimulatedAircraft &newRemoteAircraft)
|
||||
{
|
||||
Q_ASSERT(isConnected());
|
||||
if (c_driverInterpolation)
|
||||
{
|
||||
// entry checks
|
||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
|
||||
Q_ASSERT_X(!newRemoteAircraft.getCallsign().isEmpty(), Q_FUNC_INFO, "empty callsign");
|
||||
@@ -524,25 +506,6 @@ namespace BlackSimPlugin
|
||||
CSimulatedAircraft remoteAircraftCopy(newRemoteAircraft);
|
||||
remoteAircraftCopy.setRendered(rendered);
|
||||
emit this->aircraftRenderingChanged(remoteAircraftCopy);
|
||||
}
|
||||
else
|
||||
{
|
||||
CAircraftModel aircraftModel = newRemoteAircraft.getModel();
|
||||
QString livery = aircraftModel.getLivery().getCombinedCode(); //! \todo livery resolution for XP
|
||||
m_trafficProxy->addPlane(newRemoteAircraft.getCallsign().asString(), aircraftModel.getModelString(),
|
||||
newRemoteAircraft.getAircraftIcaoCode().getDesignator(),
|
||||
newRemoteAircraft.getAirlineIcaoCode().getDesignator(),
|
||||
livery);
|
||||
|
||||
CLogMessage(this).info("XP: Added aircraft %1") << newRemoteAircraft.getCallsign().toQString();
|
||||
|
||||
bool rendered = true;
|
||||
updateAircraftRendered(newRemoteAircraft.getCallsign(), rendered);
|
||||
|
||||
CSimulatedAircraft remoteAircraftCopy(newRemoteAircraft);
|
||||
remoteAircraftCopy.setRendered(rendered);
|
||||
emit this->aircraftRenderingChanged(remoteAircraftCopy);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -550,8 +513,6 @@ namespace BlackSimPlugin
|
||||
{
|
||||
Q_ASSERT(isConnected());
|
||||
|
||||
if (c_driverInterpolation)
|
||||
{
|
||||
// only remove from sim
|
||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread");
|
||||
if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft
|
||||
@@ -576,14 +537,6 @@ namespace BlackSimPlugin
|
||||
// bye
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_trafficProxy->removePlane(callsign.asString());
|
||||
this->updateAircraftRendered(callsign, false);
|
||||
CLogMessage(this).info("XP: Removed aircraft %1") << callsign.toQString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int CSimulatorXPlane::physicallyRemoveAllRemoteAircraft()
|
||||
{
|
||||
@@ -591,8 +544,6 @@ namespace BlackSimPlugin
|
||||
//! \todo XP driver obtain number of removed aircraft
|
||||
resetHighlighting();
|
||||
|
||||
if (c_driverInterpolation)
|
||||
{
|
||||
// remove one by one
|
||||
int r = 0;
|
||||
const CCallsignSet callsigns = m_xplaneAircraftObjects.getAllCallsigns();
|
||||
@@ -602,15 +553,6 @@ namespace BlackSimPlugin
|
||||
}
|
||||
return r;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int r = getAircraftInRangeCount();
|
||||
m_trafficProxy->removeAllPlanes();
|
||||
this->updateMarkAllAsNotRendered();
|
||||
CLogMessage(this).info("XP: Removed all aircraft");
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
CCallsignSet CSimulatorXPlane::physicallyRenderedAircraft() const
|
||||
{
|
||||
|
||||
@@ -155,7 +155,6 @@ namespace BlackSimPlugin
|
||||
void requestRemoteAircraftDataFromXPlane();
|
||||
void updateRemoteAircraftFromSimulator(const QString &callsign, double latitudeDeg, double longitudeDeg, double elevationMeters, double modelVerticalOffsetMeters);
|
||||
|
||||
static constexpr bool c_driverInterpolation = true;
|
||||
static constexpr int GuessRemoteAircraftPartsCycle = 20; //!< guess every n-th cycle
|
||||
|
||||
// XSwiftBus interpolation
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#endif
|
||||
#include "traffic.h"
|
||||
#include "utils.h"
|
||||
#include "blackmisc/simulation/interpolator.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "XPMPMultiplayer.h"
|
||||
@@ -33,8 +31,7 @@
|
||||
namespace XSwiftBus
|
||||
{
|
||||
CTraffic::Plane::Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_, QString modelName_)
|
||||
: id(id_), callsign(callsign_), aircraftIcao(aircraftIcao_), airlineIcao(airlineIcao_), livery(livery_), modelName(modelName_),
|
||||
interpolator(callsign)
|
||||
: id(id_), callsign(callsign_), aircraftIcao(aircraftIcao_), airlineIcao(airlineIcao_), livery(livery_), modelName(modelName_)
|
||||
{
|
||||
std::memset(static_cast<void *>(&surfaces), 0, sizeof(surfaces));
|
||||
surfaces.lights.bcnLights = surfaces.lights.landLights = surfaces.lights.navLights = surfaces.lights.strbLights = 1;
|
||||
@@ -228,27 +225,6 @@ namespace XSwiftBus
|
||||
m_planesById.clear();
|
||||
}
|
||||
|
||||
void CTraffic::addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime, qint64 timeOffset)
|
||||
{
|
||||
Plane *plane = m_planesByCallsign.value(callsign, nullptr);
|
||||
if (!plane) { return; }
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
CAircraftSituation situation(
|
||||
callsign,
|
||||
CCoordinateGeodetic(latitude, longitude, altitude),
|
||||
CHeading(heading, CHeading::True, CAngleUnit::deg()),
|
||||
CAngle(pitch, CAngleUnit::deg()),
|
||||
CAngle(roll, CAngleUnit::deg()),
|
||||
CSpeed(0, CSpeedUnit::kts())
|
||||
);
|
||||
situation.setMSecsSinceEpoch(relativeTime + QDateTime::currentMSecsSinceEpoch());
|
||||
situation.setTimeOffsetMs(timeOffset);
|
||||
// plane->interpolator.addAircraftSituation(situation);
|
||||
}
|
||||
|
||||
void CTraffic::setPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading)
|
||||
{
|
||||
Plane *plane = m_planesByCallsign.value(callsign, nullptr);
|
||||
@@ -261,41 +237,6 @@ namespace XSwiftBus
|
||||
plane->position.heading = static_cast<float>(heading);
|
||||
}
|
||||
|
||||
void CTraffic::addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
||||
double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset)
|
||||
{
|
||||
Plane *plane = m_planesByCallsign.value(callsign, nullptr);
|
||||
if (!plane) { return; }
|
||||
const auto surfaces = std::make_pair(relativeTime + timeOffset + QDateTime::currentMSecsSinceEpoch(), [ = ](Plane * plane)
|
||||
{
|
||||
plane->hasSurfaces = true;
|
||||
plane->targetGearPosition = gear;
|
||||
plane->surfaces.flapRatio = flap;
|
||||
plane->surfaces.spoilerRatio = spoiler;
|
||||
plane->surfaces.speedBrakeRatio = speedBrake;
|
||||
plane->surfaces.slatRatio = slat;
|
||||
plane->surfaces.wingSweep = wingSweep;
|
||||
plane->surfaces.thrust = thrust;
|
||||
plane->surfaces.yokePitch = elevator;
|
||||
plane->surfaces.yokeHeading = rudder;
|
||||
plane->surfaces.yokeRoll = aileron;
|
||||
plane->surfaces.lights.landLights = landLight;
|
||||
plane->surfaces.lights.bcnLights = beaconLight;
|
||||
plane->surfaces.lights.strbLights = strobeLight;
|
||||
plane->surfaces.lights.navLights = navLight;
|
||||
plane->surfaces.lights.flashPattern = lightPattern;
|
||||
});
|
||||
|
||||
if (plane->hasSurfaces) { plane->pendingSurfaces.push_back(surfaces); }
|
||||
else { surfaces.second(plane); }
|
||||
|
||||
// BlackMisc::Aviation::CAircraftParts parts;
|
||||
// parts.setOnGround(onGround);
|
||||
// parts.setMSecsSinceEpoch(relativeTime + QDateTime::currentMSecsSinceEpoch());
|
||||
// parts.setTimeOffsetMs(timeOffset);
|
||||
// plane->interpolator.addAircraftParts(parts);
|
||||
}
|
||||
|
||||
void CTraffic::setPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
||||
double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround)
|
||||
{
|
||||
@@ -332,23 +273,6 @@ namespace XSwiftBus
|
||||
else { plane->xpdr.mode = xpmpTransponderMode_Standby; }
|
||||
}
|
||||
|
||||
void CTraffic::setInterpolatorMode(const QString &callsign, bool spline)
|
||||
{
|
||||
Plane *plane = m_planesByCallsign.value(callsign, nullptr);
|
||||
if (plane)
|
||||
{
|
||||
plane->interpolator.setMode(spline ? BlackMisc::Simulation::CInterpolatorMulti::ModeSpline
|
||||
: BlackMisc::Simulation::CInterpolatorMulti::ModeLinear);
|
||||
}
|
||||
else if (callsign.isEmpty())
|
||||
{
|
||||
for (const auto &callsign : BlackMisc::makeKeysRange(BlackMisc::as_const(m_planesByCallsign)))
|
||||
{
|
||||
setInterpolatorMode(callsign, spline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTraffic::requestRemoteAircraftData()
|
||||
{
|
||||
if (m_planesByCallsign.empty()) { return; }
|
||||
@@ -386,8 +310,6 @@ namespace XSwiftBus
|
||||
switch (dataType)
|
||||
{
|
||||
case xpmpDataType_Position:
|
||||
{
|
||||
if (c_driverInterpolation)
|
||||
{
|
||||
const auto io_position = static_cast<XPMPPlanePosition_t *>(io_data);
|
||||
io_position->lat = plane->position.lat;
|
||||
@@ -399,45 +321,12 @@ namespace XSwiftBus
|
||||
std::strncpy(io_position->label, plane->label, sizeof(plane->label)); // fixme don't need to copy on every frame
|
||||
return xpmpData_NewData;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign setup;
|
||||
BlackMisc::Simulation::CInterpolationStatus status;
|
||||
BlackMisc::Aviation::CAircraftSituation situation = plane->interpolator.getInterpolatedSituation(-1, setup, status);
|
||||
if (! status.hasValidSituation()) { return xpmpData_Unavailable; }
|
||||
|
||||
//! \fixme KB 2018-01 commented out with T229. Change detection needs to go somewhere else
|
||||
// if (! status.hasChangedPosition()) { return xpmpData_Unchanged; }
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
const auto io_position = static_cast<XPMPPlanePosition_t *>(io_data);
|
||||
io_position->lat = situation.latitude().value(CAngleUnit::deg());
|
||||
io_position->lon = situation.longitude().value(CAngleUnit::deg());
|
||||
io_position->elevation = situation.getAltitude().value(CLengthUnit::ft());
|
||||
io_position->pitch = static_cast<float>(situation.getPitch().value(CAngleUnit::deg()));
|
||||
io_position->roll = static_cast<float>(situation.getBank().value(CAngleUnit::deg()));
|
||||
io_position->heading = static_cast<float>(situation.getHeading().value(CAngleUnit::deg()));
|
||||
std::strncpy(io_position->label, plane->label, sizeof(plane->label)); // fixme don't need to copy on every frame
|
||||
return xpmpData_NewData;
|
||||
}
|
||||
}
|
||||
|
||||
case xpmpDataType_Surfaces:
|
||||
if (plane->hasSurfaces)
|
||||
{
|
||||
const auto currentTime = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
if (! c_driverInterpolation)
|
||||
{
|
||||
while (! plane->pendingSurfaces.isEmpty() && plane->pendingSurfaces.constFirst().first <= currentTime)
|
||||
{
|
||||
//! \todo if gear is currently retracted, look ahead and pull gear position from pendingSurfaces up to 5 seconds in the future
|
||||
plane->pendingSurfaces.constFirst().second(plane);
|
||||
plane->pendingSurfaces.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
if (plane->surfaces.gearPosition != plane->targetGearPosition)
|
||||
{
|
||||
// interpolate gear position
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
|
||||
#include "datarefs.h"
|
||||
#include "terrainprobe.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/simulation/interpolatormulti.h"
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
@@ -106,16 +104,9 @@ namespace XSwiftBus
|
||||
//! Remove all traffic aircraft
|
||||
void removeAllPlanes();
|
||||
|
||||
//! Add the position of a traffic aircraft
|
||||
void addPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading, qint64 relativeTime, qint64 timeOffset);
|
||||
|
||||
//! Set the position of a traffic aircraft
|
||||
void setPlanePosition(const QString &callsign, double latitude, double longitude, double altitude, double pitch, double roll, double heading);
|
||||
|
||||
//! Add the flight control surfaces and lights of a traffic aircraft
|
||||
void addPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
||||
double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround, qint64 relativeTime, qint64 timeOffset);
|
||||
|
||||
//! Set the flight control surfaces and lights of a traffic aircraft
|
||||
void setPlaneSurfaces(const QString &callsign, double gear, double flap, double spoiler, double speedBrake, double slat, double wingSweep, double thrust,
|
||||
double elevator, double rudder, double aileron, bool landLight, bool beaconLight, bool strobeLight, bool navLight, int lightPattern, bool onGround);
|
||||
@@ -123,9 +114,6 @@ namespace XSwiftBus
|
||||
//! Set the transponder of a traffic aircraft
|
||||
void setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident);
|
||||
|
||||
//! Set interpolation mode for a traffic aircraft
|
||||
void setInterpolatorMode(const QString &callsign, bool spline);
|
||||
|
||||
//! Request traffic plane data. A signal remoteAircraftData will be emitted for each known plane
|
||||
void requestRemoteAircraftData();
|
||||
|
||||
@@ -133,8 +121,6 @@ namespace XSwiftBus
|
||||
bool m_initialized = false;
|
||||
bool m_enabled = false;
|
||||
|
||||
static constexpr bool c_driverInterpolation = true;
|
||||
|
||||
void emitSimFrame();
|
||||
|
||||
static int preferences(const char *section, const char *name, int def);
|
||||
@@ -151,10 +137,8 @@ namespace XSwiftBus
|
||||
bool hasSurfaces = false;
|
||||
bool hasXpdr = false;
|
||||
char label[32] {};
|
||||
BlackMisc::Simulation::CInterpolatorMulti interpolator;
|
||||
CTerrainProbe terrainProbe;
|
||||
XPMPPlaneSurfaces_t surfaces;
|
||||
QVector<std::pair<qint64, std::function<void(Plane *)>>> pendingSurfaces;
|
||||
float targetGearPosition = 0;
|
||||
qint64 prevSurfacesLerpTime = 0;
|
||||
XPMPPlaneRadar_t xpdr;
|
||||
|
||||
Reference in New Issue
Block a user