Ref T515, added failover flag for addingRemoteModelFailed

* adjusted signatures
* renamings and minor style adjustments
This commit is contained in:
Klaus Basan
2019-01-24 12:19:39 +01:00
committed by Mat Sutcliffe
parent f316c63fbe
commit 6470c61d0a
12 changed files with 38 additions and 29 deletions

View File

@@ -116,7 +116,7 @@ namespace BlackCore
void modelMatchingCompleted(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); void modelMatchingCompleted(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
//! Adding a remote aircraft failed //! Adding a remote aircraft failed
void addingRemoteModelFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, bool disabled, const BlackMisc::CStatusMessage &message); void addingRemoteModelFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, bool disabled, bool failover, const BlackMisc::CStatusMessage &message);
//! Aircraft rendering changed //! Aircraft rendering changed
void aircraftRenderingChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); void aircraftRenderingChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);

View File

@@ -84,7 +84,7 @@ namespace BlackCore
"weatherGridReceived", this, SIGNAL(weatherGridReceived(BlackMisc::Weather::CWeatherGrid, BlackMisc::CIdentifier))); "weatherGridReceived", this, SIGNAL(weatherGridReceived(BlackMisc::Weather::CWeatherGrid, BlackMisc::CIdentifier)));
Q_ASSERT(s); Q_ASSERT(s);
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"addingRemoteModelFailed", this, SIGNAL(addingRemoteModelFailed(BlackMisc::Simulation::CSimulatedAircraft, bool, BlackMisc::CStatusMessage))); "addingRemoteModelFailed", this, SIGNAL(addingRemoteModelFailed(BlackMisc::Simulation::CSimulatedAircraft, bool, bool, BlackMisc::CStatusMessage)));
Q_ASSERT(s); Q_ASSERT(s);
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"driverMessages", this, SIGNAL(driverMessages(BlackMisc::CStatusMessageList))); "driverMessages", this, SIGNAL(driverMessages(BlackMisc::CStatusMessageList)));

View File

@@ -352,7 +352,7 @@ namespace BlackCore
void aircraftRenderingChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); void aircraftRenderingChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
//! Adding the remote model failed //! Adding the remote model failed
void physicallyAddingRemoteModelFailed(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, bool disabled, const BlackMisc::CStatusMessage &message); void physicallyAddingRemoteModelFailed(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft, bool disabled, bool requestFailover, const BlackMisc::CStatusMessage &message);
//! An airspace snapshot was handled //! An airspace snapshot was handled
void airspaceSnapshotHandled(); void airspaceSnapshotHandled();

View File

@@ -493,9 +493,10 @@ namespace BlackGui
ui->sp_MappingComponentSplitter->setSizes(newSizes); ui->sp_MappingComponentSplitter->setSizes(newSizes);
} }
void CMappingComponent::onAddingRemoteAircraftFailed(const CSimulatedAircraft &aircraft, bool disabled, const CStatusMessage &message) void CMappingComponent::onAddingRemoteAircraftFailed(const CSimulatedAircraft &aircraft, bool disabled, bool failover, const CStatusMessage &message)
{ {
this->tokenBucketUpdate(); this->tokenBucketUpdate();
Q_UNUSED(failover);
Q_UNUSED(aircraft); Q_UNUSED(aircraft);
Q_UNUSED(message); Q_UNUSED(message);
Q_UNUSED(disabled); Q_UNUSED(disabled);

View File

@@ -144,7 +144,7 @@ namespace BlackGui
void showAircraftModelDetails(bool show); void showAircraftModelDetails(bool show);
//! Adding a remote aircraft failed //! Adding a remote aircraft failed
void onAddingRemoteAircraftFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, bool disabled, const BlackMisc::CStatusMessage &message); void onAddingRemoteAircraftFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, bool disabled, bool failover, const BlackMisc::CStatusMessage &message);
//! Timer update //! Timer update
void timerUpdate(); void timerUpdate();

View File

@@ -183,9 +183,11 @@ namespace BlackGui
} }
} }
void CSimulatorComponent::onAddingRemoteModelFailed(const CSimulatedAircraft &aircraft, bool disabled, const CStatusMessage &message) void CSimulatorComponent::onAddingRemoteModelFailed(const CSimulatedAircraft &aircraft, bool disabled, bool failover, const CStatusMessage &message)
{ {
ui->comp_StatusMessages->appendStatusMessageToList(CStatusMessage(this).warning(u"Adding model failed, disabled: %1: '%2'") << boolToYesNo(disabled) << aircraft.toQString(true)); ui->comp_StatusMessages->appendStatusMessageToList(CStatusMessage(this).
warning(u"Adding model '%1' failed, disabled: %2: failover: %3 detials: %4")
<< aircraft.getModelString() << boolToYesNo(disabled) << boolToYesNo(failover) << aircraft.toQString(true));
ui->comp_StatusMessages->appendStatusMessageToList(message); ui->comp_StatusMessages->appendStatusMessageToList(message);
} }

View File

@@ -67,7 +67,7 @@ namespace BlackGui
void onSimulatorStatusChanged(int status); void onSimulatorStatusChanged(int status);
//! \copydoc ISimulator::addingRemoteModelFailed //! \copydoc ISimulator::addingRemoteModelFailed
void onAddingRemoteModelFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, bool disabled, const BlackMisc::CStatusMessage &message); void onAddingRemoteModelFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, bool disabled, bool failover, const BlackMisc::CStatusMessage &message);
//! \copydoc ISimulator::onSimulatorMessages //! \copydoc ISimulator::onSimulatorMessages
void onSimulatorMessages(const BlackMisc::CStatusMessageList &messages); void onSimulatorMessages(const BlackMisc::CStatusMessageList &messages);

View File

@@ -83,7 +83,7 @@ namespace BlackGui
ui->cb_ExclNoExcludedModels->setChecked(mode.testFlag(CAircraftMatcherSetup::ExcludeNoExcluded)); ui->cb_ExclNoExcludedModels->setChecked(mode.testFlag(CAircraftMatcherSetup::ExcludeNoExcluded));
ui->cb_ExclNoDbData->setChecked(mode.testFlag(CAircraftMatcherSetup::ExcludeNoDbData)); ui->cb_ExclNoDbData->setChecked(mode.testFlag(CAircraftMatcherSetup::ExcludeNoDbData));
ui->cb_ModelSetRemoveFailed->setChecked(mode.testFlag(CAircraftMatcherSetup::ModelSetRemoveFailedModel)); ui->cb_ModelSetRemoveFailed->setChecked(mode.testFlag(CAircraftMatcherSetup::ModelSetRemoveFailedModel));
ui->cb_ModelFailedFailover->setChecked(mode.testFlag(CAircraftMatcherSetup::ModelFailoverWhenNoModelCanBeLoaded)); ui->cb_ModelFailedFailover->setChecked(mode.testFlag(CAircraftMatcherSetup::ModelFailoverIfNoModelCanBeAdded));
ui->cb_ModelSetVerification->setChecked(mode.testFlag(CAircraftMatcherSetup::ModelVerificationAtStartup)); ui->cb_ModelSetVerification->setChecked(mode.testFlag(CAircraftMatcherSetup::ModelVerificationAtStartup));
this->setMatchingAlgorithm(setup); this->setMatchingAlgorithm(setup);

View File

@@ -139,7 +139,7 @@ namespace BlackMisc
static const QString exExcl("excl.excluded"); static const QString exExcl("excl.excluded");
static const QString removeFromModelSet("rem.from model set"); static const QString removeFromModelSet("rem.from model set");
static const QString verification("Verify models at startup"); static const QString verification("Verify models at startup");
static const QString modelFailedLoad("Replace models failed to load"); static const QString modelFailedAdded("Replace models failed to be added");
switch (modeFlag) switch (modeFlag)
{ {
@@ -159,7 +159,7 @@ namespace BlackMisc
case ExcludeNoExcluded: return exExcl; case ExcludeNoExcluded: return exExcl;
case ModelSetRemoveFailedModel: return removeFromModelSet; case ModelSetRemoveFailedModel: return removeFromModelSet;
case ModelVerificationAtStartup: return verification; case ModelVerificationAtStartup: return verification;
case ModelFailoverWhenNoModelCanBeLoaded: return modelFailedLoad; case ModelFailoverIfNoModelCanBeAdded: return modelFailedAdded;
default: break; default: break;
} }
@@ -184,7 +184,7 @@ namespace BlackMisc
if (mode.testFlag(ScorePreferColorLiveries)) { modes << modeFlagToString(ScorePreferColorLiveries); } if (mode.testFlag(ScorePreferColorLiveries)) { modes << modeFlagToString(ScorePreferColorLiveries); }
if (mode.testFlag(ModelSetRemoveFailedModel)) { modes << modeFlagToString(ModelSetRemoveFailedModel); } if (mode.testFlag(ModelSetRemoveFailedModel)) { modes << modeFlagToString(ModelSetRemoveFailedModel); }
if (mode.testFlag(ModelVerificationAtStartup)) { modes << modeFlagToString(ModelVerificationAtStartup); } if (mode.testFlag(ModelVerificationAtStartup)) { modes << modeFlagToString(ModelVerificationAtStartup); }
if (mode.testFlag(ModelFailoverWhenNoModelCanBeLoaded)) { modes << modeFlagToString(ModelFailoverWhenNoModelCanBeLoaded); } if (mode.testFlag(ModelFailoverIfNoModelCanBeAdded)) { modes << modeFlagToString(ModelFailoverIfNoModelCanBeAdded); }
return modes.join(", "); return modes.join(", ");
} }
@@ -229,7 +229,7 @@ namespace BlackMisc
if (excludeNoExcluded) { mode |= ExcludeNoExcluded; } if (excludeNoExcluded) { mode |= ExcludeNoExcluded; }
if (modelSetRemoveFailedModel) { mode |= ModelSetRemoveFailedModel; } if (modelSetRemoveFailedModel) { mode |= ModelSetRemoveFailedModel; }
if (modelVerification) { mode |= ModelVerificationAtStartup; } if (modelVerification) { mode |= ModelVerificationAtStartup; }
if (modelFailover) { mode |= ModelFailoverWhenNoModelCanBeLoaded; } if (modelFailover) { mode |= ModelFailoverIfNoModelCanBeAdded; }
return mode; return mode;
} }
} // namespace } // namespace

View File

@@ -55,14 +55,14 @@ namespace BlackMisc
ExcludeNoExcluded = 1 << 14, ExcludeNoExcluded = 1 << 14,
ExcludeDefault = ExcludeNoExcluded | ExcludeNoDbData, ExcludeDefault = ExcludeNoExcluded | ExcludeNoDbData,
// --- model set --- // --- model set ---
ModelSetRemoveFailedModel = 1 << 15, ModelSetRemoveFailedModel = 1 << 15,
ModelVerificationAtStartup = 1 << 16, ModelVerificationAtStartup = 1 << 16,
ModelFailoverWhenNoModelCanBeLoaded = 1 << 17, ModelFailoverIfNoModelCanBeAdded = 1 << 17,
// --- others --- // --- others ---
ModeNone = 0, ModeNone = 0,
ModeByFLags = ByMilitary | ByVtol, ModeByFLags = ByMilitary | ByVtol,
// ModeDefaultSet = ModelSetRemoveFailedModel | ModelVerificationAtStartup | ModelFailoverWhenNoModelCanBeLoaded, // ModeDefaultSet = ModelSetRemoveFailedModel | ModelVerificationAtStartup | ModelFailoverWhenNoModelCanBeLoaded,
ModeDefaultSet = ModelSetRemoveFailedModel | ModelFailoverWhenNoModelCanBeLoaded, ModeDefaultSet = ModelSetRemoveFailedModel | ModelFailoverIfNoModelCanBeAdded,
ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries | ExcludeDefault, ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries | ExcludeDefault,
ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery | ExcludeDefault, ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery | ExcludeDefault,
ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore | ExcludeDefault, ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore | ExcludeDefault,
@@ -111,6 +111,10 @@ namespace BlackMisc
//! \sa ModelVerificationOnStartup //! \sa ModelVerificationOnStartup
bool doVerificationAtStartup() const { return this->getMatchingMode().testFlag(ModelVerificationAtStartup); } bool doVerificationAtStartup() const { return this->getMatchingMode().testFlag(ModelVerificationAtStartup); }
//! Failover if model cannot be loaded
//! \sa ModelFailoverIfNoModelCanBeAdded
bool doModelAddFailover() const { return this->getMatchingMode().testFlag(ModelFailoverIfNoModelCanBeAdded); }
//! Set startup verification //! Set startup verification
void setVerificationAtStartup(bool verify); void setVerificationAtStartup(bool verify);

View File

@@ -951,7 +951,7 @@ namespace BlackSimPlugin
if (!msg.isEmpty() && msg.isWarningOrAbove()) if (!msg.isEmpty() && msg.isWarningOrAbove())
{ {
CLogMessage::preformatted(msg); CLogMessage::preformatted(msg);
emit this->physicallyAddingRemoteModelFailed(CSimulatedAircraft(), false, msg); emit this->physicallyAddingRemoteModelFailed(CSimulatedAircraft(), false, false, msg);
} }
// trigger adding pending aircraft if there are any // trigger adding pending aircraft if there are any
@@ -972,16 +972,16 @@ namespace BlackSimPlugin
CLogMessage(this).warning(u"Model failed to be added: '%1' details: %2") << simObject.getAircraftModelString() << simObject.getAircraft().toQString(true); CLogMessage(this).warning(u"Model failed to be added: '%1' details: %2") << simObject.getAircraftModelString() << simObject.getAircraft().toQString(true);
CStatusMessage verifyMsg; CStatusMessage verifyMsg;
const bool canBeUsed = this->verifyFailedAircraftInfo(simObject, verifyMsg); // aircraft.cfg existing? const bool verifiedAircraft = this->verifyFailedAircraftInfo(simObject, verifyMsg); // aircraft.cfg existing?
if (!verifyMsg.isEmpty()) { CLogMessage::preformatted(verifyMsg); } if (!verifyMsg.isEmpty()) { CLogMessage::preformatted(verifyMsg); }
if (!canBeUsed || simObject.getAddingExceptions() >= ThresholdAddException) if (!verifiedAircraft || simObject.getAddingExceptions() >= ThresholdAddException)
{ {
const CStatusMessage m = !canBeUsed ? const CStatusMessage msg = verifiedAircraft ?
CLogMessage(this).warning(u"Model '%1' %2 failed verification and will be disabled") << simObject.getAircraftModelString() << simObject.toQString() : CLogMessage(this).warning(u"Model '%1' %2 failed %3 time(s) before and will be disabled") << simObject.getAircraftModelString() << simObject.toQString() << simObject.getAddingExceptions() :
CLogMessage(this).warning(u"Model '%1' %2 failed %3 time(s) before and will be disabled") << simObject.getAircraftModelString() << simObject.toQString() << simObject.getAddingExceptions(); CLogMessage(this).warning(u"Model '%1' %2 failed verification and will be disabled") << simObject.getAircraftModelString() << simObject.toQString();
this->updateAircraftEnabled(simObject.getCallsign(), false); // disable this->updateAircraftEnabled(simObject.getCallsign(), false); // disable
emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, m); emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, true, msg); // verify failed
} }
else else
{ {
@@ -1195,7 +1195,7 @@ namespace BlackSimPlugin
{ {
const CStatusMessage m = CLogMessage(this).warning(u"Aircraft removed again multiple times and will be disabled, '%1' '%2' object id '%3'") << callsign.toQString() << simObject.getAircraftModelString() << objectID; const CStatusMessage m = CLogMessage(this).warning(u"Aircraft removed again multiple times and will be disabled, '%1' '%2' object id '%3'") << callsign.toQString() << simObject.getAircraftModelString() << objectID;
this->updateAircraftEnabled(simObject.getCallsign(), false); this->updateAircraftEnabled(simObject.getCallsign(), false);
emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, m); emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, true, m); // directly removed again
} }
else else
{ {
@@ -1412,7 +1412,7 @@ namespace BlackSimPlugin
for (const CSimConnectObject &simObjOutdated : outdatedAdded) for (const CSimConnectObject &simObjOutdated : outdatedAdded)
{ {
const CStatusMessage msg = CStatusMessage(this).warning(msgText.arg(simObjOutdated.getCallsign().asString(), simObjOutdated.toQString())); const CStatusMessage msg = CStatusMessage(this).warning(msgText.arg(simObjOutdated.getCallsign().asString(), simObjOutdated.toQString()));
emit this->physicallyAddingRemoteModelFailed(simObjOutdated.getAircraft(), true, msg); emit this->physicallyAddingRemoteModelFailed(simObjOutdated.getAircraft(), true, true, msg); // outdated
} }
// if this aircraft is also outdated, ignore // if this aircraft is also outdated, ignore
@@ -1547,7 +1547,7 @@ namespace BlackSimPlugin
{ {
const CStatusMessage msg = CStatusMessage(this).error(u"SimConnect, can not create AI traffic: '%1' '%2'") << callsign.toQString() << modelString; const CStatusMessage msg = CStatusMessage(this).error(u"SimConnect, can not create AI traffic: '%1' '%2'") << callsign.toQString() << modelString;
CLogMessage::preformatted(msg); CLogMessage::preformatted(msg);
emit this->physicallyAddingRemoteModelFailed(newRemoteAircraft, true, msg); emit this->physicallyAddingRemoteModelFailed(newRemoteAircraft, true, true, msg); // SimConnect error
} }
else else
{ {

View File

@@ -215,14 +215,16 @@ namespace BlackSimPlugin
{ {
bool success = simulatorFsxP3D->setSimConnectObjectId(requestId, objectId); bool success = simulatorFsxP3D->setSimConnectObjectId(requestId, objectId);
if (!success) { break; } // not an request ID of ours if (!success) { break; } // not an request ID of ours
success = simulatorFsxP3D->simulatorReportedObjectAdded(objectId); // trigger follow up actions success = simulatorFsxP3D->simulatorReportedObjectAdded(objectId); // adding failed (no IDs), trigger follow up actions
if (!success) if (!success)
{ {
// getting here would mean object was removed in the meantime
// otherwise we will detect it in verification
const CSimConnectObject simObject = simulatorFsxP3D->getSimObjectForObjectId(objectId); const CSimConnectObject simObject = simulatorFsxP3D->getSimObjectForObjectId(objectId);
const CSimulatedAircraft remoteAircraft(simObject.getAircraft()); const CSimulatedAircraft remoteAircraft(simObject.getAircraft());
const CStatusMessage msg = CStatusMessage(simulatorFsxP3D).error(u"Cannot add object %1, cs: '%2' model: '%3'") << objectId << remoteAircraft.getCallsignAsString() << remoteAircraft.getModelString(); const CStatusMessage msg = CStatusMessage(simulatorFsxP3D).error(u"Cannot add object %1, cs: '%2' model: '%3'") << objectId << remoteAircraft.getCallsignAsString() << remoteAircraft.getModelString();
CLogMessage::preformatted(msg); CLogMessage::preformatted(msg);
emit simulatorFsxP3D->physicallyAddingRemoteModelFailed(remoteAircraft, false, msg); emit simulatorFsxP3D->physicallyAddingRemoteModelFailed(remoteAircraft, false, false, msg);
} }
} }
break; // SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID break; // SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID