mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Ref T268, moved changeRemoteAircraftModel/Enabled to CSimulatorCommon and removed duplicated code
This commit is contained in:
@@ -135,6 +135,7 @@ namespace BlackCore
|
|||||||
void CSimulatorCommon::blinkHighlightedAircraft()
|
void CSimulatorCommon::blinkHighlightedAircraft()
|
||||||
{
|
{
|
||||||
if (m_highlightedAircraft.isEmpty() || m_highlightEndTimeMsEpoch < 1) { return; }
|
if (m_highlightedAircraft.isEmpty() || m_highlightEndTimeMsEpoch < 1) { return; }
|
||||||
|
if (this->isShuttingDown()) { return; }
|
||||||
m_blinkCycle = !m_blinkCycle;
|
m_blinkCycle = !m_blinkCycle;
|
||||||
|
|
||||||
if (QDateTime::currentMSecsSinceEpoch() > m_highlightEndTimeMsEpoch)
|
if (QDateTime::currentMSecsSinceEpoch() > m_highlightEndTimeMsEpoch)
|
||||||
@@ -404,9 +405,30 @@ namespace BlackCore
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorCommon::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
||||||
|
{
|
||||||
|
if (this->isShuttingDown()) { return false; }
|
||||||
|
return aircraft.isEnabled() ?
|
||||||
|
this->physicallyAddRemoteAircraft(aircraft) :
|
||||||
|
this->physicallyRemoveRemoteAircraft(aircraft.getCallsign());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSimulatorCommon::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
|
||||||
|
{
|
||||||
|
// we expect the new model "in aircraft"
|
||||||
|
// remove upfront, and then enable / disable again
|
||||||
|
if (this->isShuttingDown()) { return false; }
|
||||||
|
const CCallsign callsign = aircraft.getCallsign();
|
||||||
|
if (!this->isPhysicallyRenderedAircraft(callsign)) { return false; }
|
||||||
|
this->physicallyRemoveRemoteAircraft(callsign);
|
||||||
|
return this->changeRemoteAircraftEnabled(aircraft);
|
||||||
|
}
|
||||||
|
|
||||||
bool CSimulatorCommon::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
bool CSimulatorCommon::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||||
{
|
{
|
||||||
if (this->isMyIdentifier(originator)) { return false; }
|
if (this->isMyIdentifier(originator)) { return false; }
|
||||||
|
if (this->isShuttingDown()) { return false; }
|
||||||
|
|
||||||
if (commandLine.isEmpty()) { return false; }
|
if (commandLine.isEmpty()) { return false; }
|
||||||
CSimpleCommandParser parser({ ".plugin", ".drv", ".driver" });
|
CSimpleCommandParser parser({ ".plugin", ".drv", ".driver" });
|
||||||
parser.parse(commandLine);
|
parser.parse(commandLine);
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ namespace BlackCore
|
|||||||
virtual BlackMisc::Aviation::CCallsignSet renderedDisabledAircraft() const override;
|
virtual BlackMisc::Aviation::CCallsignSet renderedDisabledAircraft() const override;
|
||||||
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
||||||
virtual int physicallyRemoveAllRemoteAircraft() override;
|
virtual int physicallyRemoveAllRemoteAircraft() override;
|
||||||
|
virtual bool changeRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
||||||
|
virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
||||||
virtual void clearAllRemoteAircraftData() override;
|
virtual void clearAllRemoteAircraftData() override;
|
||||||
virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const override;
|
virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -106,19 +106,14 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
bool CSimulatorEmulated::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
|
bool CSimulatorEmulated::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
|
||||||
{
|
{
|
||||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString());
|
if (canLog()) { m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString()); }
|
||||||
return true;
|
return CSimulatorCommon::changeRemoteAircraftEnabled(aircraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorEmulated::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
bool CSimulatorEmulated::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
||||||
{
|
{
|
||||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString());
|
if (canLog()) { m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString()); }
|
||||||
const int c = m_renderedAircraft.setEnabled(aircraft.getCallsign(), aircraft.isEnabled(), true); // my own simulator list
|
return CSimulatorCommon::changeRemoteAircraftEnabled(aircraft);
|
||||||
const CCallsign cs = aircraft.getCallsign();
|
|
||||||
const bool rendered = aircraft.isEnabled();
|
|
||||||
this->updateAircraftRendered(cs, rendered); // in provider
|
|
||||||
emit this->aircraftRenderingChanged(m_renderedAircraft.findFirstByCallsign(aircraft.getCallsign(), aircraft));
|
|
||||||
return c > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorEmulated::updateOwnSimulatorCockpit(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
bool CSimulatorEmulated::updateOwnSimulatorCockpit(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||||
|
|||||||
@@ -126,22 +126,6 @@ namespace BlackSimPlugin
|
|||||||
return CSimulatorCommon::getAirportsInRange();
|
return CSimulatorCommon::getAirportsInRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorFsCommon::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
|
|
||||||
{
|
|
||||||
// remove upfront, and then enable / disable again
|
|
||||||
const CCallsign callsign = aircraft.getCallsign();
|
|
||||||
if (!this->isPhysicallyRenderedAircraft(callsign)) { return false; }
|
|
||||||
this->physicallyRemoveRemoteAircraft(callsign);
|
|
||||||
return this->changeRemoteAircraftEnabled(aircraft);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimulatorFsCommon::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
|
||||||
{
|
|
||||||
return aircraft.isEnabled() ?
|
|
||||||
this->physicallyAddRemoteAircraft(aircraft) :
|
|
||||||
this->physicallyRemoveRemoteAircraft(aircraft.getCallsign());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimulatorFsCommon::onSwiftDbAirportsRead()
|
void CSimulatorFsCommon::onSwiftDbAirportsRead()
|
||||||
{
|
{
|
||||||
const CAirportList webServiceAirports = this->getWebServiceAirports();
|
const CAirportList webServiceAirports = this->getWebServiceAirports();
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ namespace BlackSimPlugin
|
|||||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||||
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override;
|
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override;
|
||||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||||
virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
|
||||||
virtual bool changeRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
|
||||||
// ---------------------- ISimulator ------------------
|
// ---------------------- ISimulator ------------------
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -577,28 +577,6 @@ namespace BlackSimPlugin
|
|||||||
return this->getAircraftInRange().findByRendered(true).getCallsigns(); // just a poor workaround
|
return this->getAircraftInRange().findByRendered(true).getCallsigns(); // just a poor workaround
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorXPlane::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
|
|
||||||
{
|
|
||||||
// remove upfront, and then enable / disable again
|
|
||||||
auto callsign = aircraft.getCallsign();
|
|
||||||
if (!this->isPhysicallyRenderedAircraft(callsign)) { return false; }
|
|
||||||
this->physicallyRemoveRemoteAircraft(callsign);
|
|
||||||
return this->changeRemoteAircraftEnabled(aircraft);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimulatorXPlane::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
|
||||||
{
|
|
||||||
if (aircraft.isEnabled())
|
|
||||||
{
|
|
||||||
this->physicallyAddRemoteAircraft(aircraft);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->physicallyRemoveRemoteAircraft(aircraft.getCallsign());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimulatorXPlane::followAircraft(const CCallsign &callsign)
|
bool CSimulatorXPlane::followAircraft(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
if (! m_trafficProxy || ! m_trafficProxy->isValid()) { return false; }
|
if (! m_trafficProxy || ! m_trafficProxy->isValid()) { return false; }
|
||||||
|
|||||||
@@ -122,8 +122,6 @@ namespace BlackSimPlugin
|
|||||||
virtual bool isTimeSynchronized() const override { return false; } // TODO: Can we query the XP intrinisc feature?
|
virtual bool isTimeSynchronized() const override { return false; } // TODO: Can we query the XP intrinisc feature?
|
||||||
virtual bool connectTo() override;
|
virtual bool connectTo() override;
|
||||||
virtual bool disconnectFrom() override;
|
virtual bool disconnectFrom() override;
|
||||||
virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
|
||||||
virtual bool changeRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
|
||||||
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator) override;
|
virtual bool updateOwnSimulatorCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator) override;
|
||||||
virtual bool updateOwnSimulatorSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) override;
|
virtual bool updateOwnSimulatorSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) override;
|
||||||
virtual void displayStatusMessage(const BlackMisc::CStatusMessage &message) const override;
|
virtual void displayStatusMessage(const BlackMisc::CStatusMessage &message) const override;
|
||||||
|
|||||||
Reference in New Issue
Block a user