Ref T554, changed signature to pass model (object) and not only modelstring

Allows to test if data have changed before "remembering them for auto publish"
This commit is contained in:
Klaus Basan
2019-07-16 18:11:40 +02:00
committed by Mat Sutcliffe
parent f87004c6c8
commit fab65c23b1
7 changed files with 24 additions and 10 deletions

View File

@@ -845,7 +845,7 @@ namespace BlackCore
m_simulatorInternals.setSimulatorInstallationDirectory(s.getSimulatorDirectoryOrDefault()); m_simulatorInternals.setSimulatorInstallationDirectory(s.getSimulatorDirectoryOrDefault());
} }
void ISimulator::rememberElevationAndSimulatorCG(const CCallsign &callsign, const QString &modelString, const CElevationPlane &elevation, const CLength &simulatorCG) void ISimulator::rememberElevationAndSimulatorCG(const CCallsign &callsign, const CAircraftModel &model, const CElevationPlane &elevation, const CLength &simulatorCG)
{ {
if (callsign.isEmpty()) { return; } if (callsign.isEmpty()) { return; }
if (!elevation.isNull()) if (!elevation.isNull())
@@ -855,16 +855,24 @@ namespace BlackCore
this->rememberGroundElevation(callsign, elevation); this->rememberGroundElevation(callsign, elevation);
} }
const QString modelString = model.getModelString();
if (modelString.isEmpty()) { return; }
const CLength cgOvr = this->overriddenCGorDefault(simulatorCG, modelString); const CLength cgOvr = this->overriddenCGorDefault(simulatorCG, modelString);
if (!cgOvr.isNull() && !this->hasSameSimulatorCG(cgOvr, callsign)) if (!cgOvr.isNull() && !this->hasSameSimulatorCG(cgOvr, callsign))
{ {
this->insertCG(cgOvr, modelString, callsign); // per model string and CG this->insertCG(cgOvr, modelString, callsign); // per model string and CG
// here we know we have a valid model and CG // here we know we have a valid model and CG did change
m_autoPublishing.insert(modelString, simulatorCG); // still using CG here, not the overridden value const CSimulatorInfo sim = this->getSimulatorInfo();
m_autoPublishing.insert(modelString, simulatorCG); // still using simulator CG here, not the overridden value
// if simulator did change, add as well
if (!model.getSimulator().matchesAll(sim))
{
m_autoPublishing.insert(modelString, this->getSimulatorInfo()); m_autoPublishing.insert(modelString, this->getSimulatorInfo());
} }
} }
}
void ISimulator::emitSimulatorCombinedStatus(SimulatorStatus oldStatus) void ISimulator::emitSimulatorCombinedStatus(SimulatorStatus oldStatus)
{ {
@@ -997,7 +1005,7 @@ namespace BlackCore
void ISimulator::unload() void ISimulator::unload()
{ {
this->disconnectFrom(); // disconnect from simulator this->disconnectFrom(); // disconnect from simulator
const bool saved = m_autoPublishing.writeJsonToFile(); const bool saved = m_autoPublishing.writeJsonToFile(); // empty data are ignored
if (saved) { emit this->autoPublishDataWritten(this->getSimulatorInfo()); } if (saved) { emit this->autoPublishDataWritten(this->getSimulatorInfo()); }
m_autoPublishing.clear(); m_autoPublishing.clear();
m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider

View File

@@ -435,7 +435,7 @@ namespace BlackCore
//! Set elevation and CG in the providers and for auto publishing //! Set elevation and CG in the providers and for auto publishing
//! \sa ISimulator::updateOwnSituationAndGroundElevation //! \sa ISimulator::updateOwnSituationAndGroundElevation
void rememberElevationAndSimulatorCG(const BlackMisc::Aviation::CCallsign &callsign, const QString &modelString, const BlackMisc::Geo::CElevationPlane &elevation, const BlackMisc::PhysicalQuantities::CLength &simulatorCG); void rememberElevationAndSimulatorCG(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::Geo::CElevationPlane &elevation, const BlackMisc::PhysicalQuantities::CLength &simulatorCG);
//! Emit the combined status //! Emit the combined status
//! \param oldStatus optionally one can capture and provide the old status for comparison. In case of equal status values no signal will be sent //! \param oldStatus optionally one can capture and provide the old status for comparison. In case of equal status values no signal will be sent

View File

@@ -51,6 +51,9 @@ namespace BlackSimPlugin
//! Simulated aircraft model string //! Simulated aircraft model string
const QString &getAircraftModelString() const { return m_aircraft.getModelString(); } const QString &getAircraftModelString() const { return m_aircraft.getModelString(); }
//! Simulated aircraft model
const BlackMisc::Simulation::CAircraftModel &getAircraftModel() const { return m_aircraft.getModel(); }
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatorInfo //! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatorInfo
QString getInterpolatorInfo(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const; QString getInterpolatorInfo(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;

View File

@@ -732,7 +732,7 @@ namespace BlackSimPlugin
const CLength cg = std::isnan(cgValue) ? const CLength cg = std::isnan(cgValue) ?
CLength::null() : CLength::null() :
CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft()); CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft());
this->rememberElevationAndSimulatorCG(cs, fgAircraft.getAircraftModelString(), elevation, cg); this->rememberElevationAndSimulatorCG(cs, fgAircraft.getAircraftModel(), elevation, cg);
// loopback // loopback
if (logCallsigns.contains(cs)) if (logCallsigns.contains(cs))

View File

@@ -814,7 +814,7 @@ namespace BlackSimPlugin
if (remoteAircraftData.aboveGroundFt() < 250) if (remoteAircraftData.aboveGroundFt() < 250)
{ {
const CLength cg(remoteAircraftData.cgToGroundFt, CLengthUnit::ft()); const CLength cg(remoteAircraftData.cgToGroundFt, CLengthUnit::ft());
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModelString(), elevation, cg); this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), elevation, cg);
} }
const bool log = this->isLogCallsign(cs); const bool log = this->isLogCallsign(cs);
@@ -864,7 +864,7 @@ namespace BlackSimPlugin
so.setAircraftModelString(modelString); so.setAircraftModelString(modelString);
// update in 2 providers // update in 2 providers
this->rememberElevationAndSimulatorCG(cs, modelString, CElevationPlane::null(), cg); // env. provider this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), CElevationPlane::null(), cg); // env. provider
this->updateCGAndModelString(cs, cg, modelString); // remote aircraft provider this->updateCGAndModelString(cs, cg, modelString); // remote aircraft provider
} }

View File

@@ -1005,7 +1005,7 @@ namespace BlackSimPlugin
const CLength cg = std::isnan(cgValue) ? const CLength cg = std::isnan(cgValue) ?
CLength::null() : CLength::null() :
CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft()); CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft());
this->rememberElevationAndSimulatorCG(cs, xpAircraft.getAircraftModelString(), elevation, cg); this->rememberElevationAndSimulatorCG(cs, xpAircraft.getAircraftModel(), elevation, cg);
// loopback // loopback
if (logCallsigns.contains(cs)) if (logCallsigns.contains(cs))

View File

@@ -48,6 +48,9 @@ namespace BlackSimPlugin
//! Simulated aircraft (as added) //! Simulated aircraft (as added)
const BlackMisc::Simulation::CSimulatedAircraft &getAircraft() const { return m_aircraft; } const BlackMisc::Simulation::CSimulatedAircraft &getAircraft() const { return m_aircraft; }
//! Simulated aircraft model
const BlackMisc::Simulation::CAircraftModel &getAircraftModel() const { return m_aircraft.getModel(); }
//! Simulated aircraft model string //! Simulated aircraft model string
const QString &getAircraftModelString() const { return m_aircraft.getModelString(); } const QString &getAircraftModelString() const { return m_aircraft.getModelString(); }