mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-22 13:15:39 +08:00
Ref T260, adjusted context/remote provider
* signal from simulator -> context * return number of updated situations
This commit is contained in:
committed by
Roland Winklmeier
parent
b706a4adbe
commit
e97de13545
@@ -699,7 +699,7 @@ namespace BlackCore
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContextNetwork::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
int CContextNetwork::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
||||||
{
|
{
|
||||||
return m_airspace->updateAircraftGroundElevation(callsign, elevation);
|
return m_airspace->updateAircraftGroundElevation(callsign, elevation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace BlackCore
|
|||||||
std::function<void(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshotSlot
|
std::function<void(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshotSlot
|
||||||
) override;
|
) override;
|
||||||
virtual bool updateAircraftRendered(const BlackMisc::Aviation::CCallsign &callsign, bool rendered) override;
|
virtual bool updateAircraftRendered(const BlackMisc::Aviation::CCallsign &callsign, bool rendered) override;
|
||||||
virtual bool updateAircraftGroundElevation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Geo::CElevationPlane &elevation) override;
|
virtual int updateAircraftGroundElevation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Geo::CElevationPlane &elevation) override;
|
||||||
virtual void updateMarkAllAsNotRendered() override;
|
virtual void updateMarkAllAsNotRendered() override;
|
||||||
virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override;
|
virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|||||||
@@ -358,6 +358,8 @@ namespace BlackCore
|
|||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
c = connect(simulator, &ISimulator::physicallyAddingRemoteModelFailed, this, &CContextSimulator::addingRemoteAircraftFailed);
|
c = connect(simulator, &ISimulator::physicallyAddingRemoteModelFailed, this, &CContextSimulator::addingRemoteAircraftFailed);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
|
c = connect(simulator, &ISimulator::receivedRequestedElevation, this, &CContextSimulator::onReceivedRequestedElevation);
|
||||||
|
Q_ASSERT(c);
|
||||||
c = connect(simulator, &ISimulator::ownAircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
|
c = connect(simulator, &ISimulator::ownAircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
c = connect(simulator, &ISimulator::aircraftRenderingChanged, this, &IContextSimulator::aircraftRenderingChanged);
|
c = connect(simulator, &ISimulator::aircraftRenderingChanged, this, &IContextSimulator::aircraftRenderingChanged);
|
||||||
@@ -557,6 +559,12 @@ namespace BlackCore
|
|||||||
emit getIContextOwnAircraft()->changedAircraftCockpit(ownAircraft, IContextSimulator::InterfaceName());
|
emit getIContextOwnAircraft()->changedAircraftCockpit(ownAircraft, IContextSimulator::InterfaceName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextSimulator::onReceivedRequestedElevation(const CElevationPlane &plane, const CCallsign &callsign)
|
||||||
|
{
|
||||||
|
if (!isSimulatorSimulating()) { return; }
|
||||||
|
emit this->receivedRequestedElevation(plane, callsign);
|
||||||
|
}
|
||||||
|
|
||||||
void CContextSimulator::xCtxChangedRemoteAircraftModel(const CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator)
|
void CContextSimulator::xCtxChangedRemoteAircraftModel(const CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator)
|
||||||
{
|
{
|
||||||
if (CIdentifiable::isMyIdentifier(originator)) { return; }
|
if (CIdentifiable::isMyIdentifier(originator)) { return; }
|
||||||
|
|||||||
@@ -66,13 +66,6 @@ namespace BlackCore
|
|||||||
friend class BlackCore::CCoreFacade;
|
friend class BlackCore::CCoreFacade;
|
||||||
friend class IContextSimulator;
|
friend class IContextSimulator;
|
||||||
|
|
||||||
public:
|
|
||||||
//! Destructor
|
|
||||||
virtual ~CContextSimulator();
|
|
||||||
|
|
||||||
//! Gracefully shut down, e.g. for plugin unloading
|
|
||||||
void gracefulShutdown();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// ----------------------------- context interface -----------------------------
|
// ----------------------------- context interface -----------------------------
|
||||||
//! \publicsection
|
//! \publicsection
|
||||||
@@ -126,6 +119,15 @@ namespace BlackCore
|
|||||||
// ----------------------------- context interface -----------------------------
|
// ----------------------------- context interface -----------------------------
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Destructor
|
||||||
|
virtual ~CContextSimulator();
|
||||||
|
|
||||||
|
//! Gracefully shut down, e.g. for plugin unloading
|
||||||
|
void gracefulShutdown();
|
||||||
|
|
||||||
|
//! Simulator object
|
||||||
|
ISimulator *simulator() const;
|
||||||
|
|
||||||
//! Register dot commands
|
//! Register dot commands
|
||||||
static void registerHelp()
|
static void registerHelp()
|
||||||
{
|
{
|
||||||
@@ -136,8 +138,10 @@ namespace BlackCore
|
|||||||
BlackMisc::CSimpleCommandParser::registerCommand({".ris parts on|off", "aircraft parts"});
|
BlackMisc::CSimpleCommandParser::registerCommand({".ris parts on|off", "aircraft parts"});
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Simulator object
|
signals:
|
||||||
ISimulator *simulator() const;
|
//! A requested elevation has been received
|
||||||
|
//! \remark only meant to be used locally, not via DBus
|
||||||
|
void receivedRequestedElevation(const BlackMisc::Geo::CElevationPlane &plane, const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
@@ -192,6 +196,9 @@ namespace BlackCore
|
|||||||
//! Simulator has changed cockpit
|
//! Simulator has changed cockpit
|
||||||
void onCockpitChangedFromSimulator(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
|
void onCockpitChangedFromSimulator(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
|
||||||
|
|
||||||
|
//! Received elevation
|
||||||
|
void onReceivedRequestedElevation(const BlackMisc::Geo::CElevationPlane &plane, const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
//! Failed adding remote aircraft
|
//! Failed adding remote aircraft
|
||||||
void addingRemoteAircraftFailed(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const BlackMisc::CStatusMessage &message);
|
void addingRemoteAircraftFailed(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, const BlackMisc::CStatusMessage &message);
|
||||||
|
|
||||||
|
|||||||
@@ -337,26 +337,26 @@ namespace BlackMisc
|
|||||||
return c > 0;
|
return c > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRemoteAircraftProvider::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
int CRemoteAircraftProvider::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
||||||
{
|
{
|
||||||
if (!this->isAircraftInRange(callsign)) { return false; }
|
if (!this->isAircraftInRange(callsign)) { return 0; }
|
||||||
|
|
||||||
// update aircraft situation
|
// update aircraft situation
|
||||||
CAircraftSituationList situations = this->remoteAircraftSituations(callsign);
|
|
||||||
const int updated = situations.setGroundElevationChecked(elevation);
|
|
||||||
if (updated < 1) { return false; }
|
|
||||||
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
|
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
int updated = 0;
|
||||||
{
|
{
|
||||||
QWriteLocker l(&m_lockSituations);
|
QWriteLocker l(&m_lockSituations);
|
||||||
m_situationsByCallsign[callsign] = situations;
|
updated = m_situationsByCallsign[callsign].setGroundElevationChecked(elevation);
|
||||||
|
if (updated < 1) { return 0; }
|
||||||
m_situationsLastModified[callsign] = ts;
|
m_situationsLastModified[callsign] = ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
// aircraft updates
|
// aircraft updates
|
||||||
QWriteLocker l(&m_lockAircraft);
|
QWriteLocker l(&m_lockAircraft);
|
||||||
const int c = m_aircraftInRange.setGroundElevationChecked(callsign, elevation);
|
const int c = m_aircraftInRange.setGroundElevationChecked(callsign, elevation);
|
||||||
return c > 0;
|
Q_UNUSED(c); // just for info, expect 1
|
||||||
|
|
||||||
|
return updated; // updated situations
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRemoteAircraftProvider::updateMarkAllAsNotRendered()
|
void CRemoteAircraftProvider::updateMarkAllAsNotRendered()
|
||||||
@@ -608,7 +608,7 @@ namespace BlackMisc
|
|||||||
return this->provider()->updateAircraftRendered(callsign, rendered);
|
return this->provider()->updateAircraftRendered(callsign, rendered);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRemoteAircraftAware::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
int CRemoteAircraftAware::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||||
return this->provider()->updateAircraftGroundElevation(callsign, elevation);
|
return this->provider()->updateAircraftGroundElevation(callsign, elevation);
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Ground elevation of aircraft
|
//! Ground elevation of aircraft
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual bool updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) = 0;
|
virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) = 0;
|
||||||
|
|
||||||
//! Get reverse lookup meesages
|
//! Get reverse lookup meesages
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -252,7 +252,7 @@ namespace BlackMisc
|
|||||||
virtual bool updateAircraftNetworkModel(const Aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator) override;
|
virtual bool updateAircraftNetworkModel(const Aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator) override;
|
||||||
virtual bool updateFastPositionEnabled(const Aviation::CCallsign &callsign, bool enableFastPositonUpdates) override;
|
virtual bool updateFastPositionEnabled(const Aviation::CCallsign &callsign, bool enableFastPositonUpdates) override;
|
||||||
virtual bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered) override;
|
virtual bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered) override;
|
||||||
virtual bool updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) override;
|
virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) override;
|
||||||
virtual void updateMarkAllAsNotRendered() override;
|
virtual void updateMarkAllAsNotRendered() override;
|
||||||
virtual CStatusMessageList getAircraftPartsHistory(const Aviation::CCallsign &callsign) const override;
|
virtual CStatusMessageList getAircraftPartsHistory(const Aviation::CCallsign &callsign) const override;
|
||||||
virtual bool isAircraftPartsHistoryEnabled() const override;
|
virtual bool isAircraftPartsHistoryEnabled() const override;
|
||||||
@@ -443,7 +443,7 @@ namespace BlackMisc
|
|||||||
bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered);
|
bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered);
|
||||||
|
|
||||||
//! \copydoc IRemoteAircraftProvider::updateAircraftGroundElevation
|
//! \copydoc IRemoteAircraftProvider::updateAircraftGroundElevation
|
||||||
bool updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation);
|
int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation);
|
||||||
|
|
||||||
//! \copydoc IRemoteAircraftProvider::updateMarkAllAsNotRendered
|
//! \copydoc IRemoteAircraftProvider::updateMarkAllAsNotRendered
|
||||||
void updateMarkAllAsNotRendered();
|
void updateMarkAllAsNotRendered();
|
||||||
|
|||||||
Reference in New Issue
Block a user