mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
Ref T515, added failover flag for addingRemoteModelFailed
* adjusted signatures * renamings and minor style adjustments
This commit is contained in:
committed by
Mat Sutcliffe
parent
f316c63fbe
commit
6470c61d0a
@@ -116,7 +116,7 @@ namespace BlackCore
|
||||
void modelMatchingCompleted(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! 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
|
||||
void aircraftRenderingChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace BlackCore
|
||||
"weatherGridReceived", this, SIGNAL(weatherGridReceived(BlackMisc::Weather::CWeatherGrid, BlackMisc::CIdentifier)));
|
||||
Q_ASSERT(s);
|
||||
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);
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"driverMessages", this, SIGNAL(driverMessages(BlackMisc::CStatusMessageList)));
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace BlackCore
|
||||
void aircraftRenderingChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! 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
|
||||
void airspaceSnapshotHandled();
|
||||
|
||||
@@ -493,9 +493,10 @@ namespace BlackGui
|
||||
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();
|
||||
Q_UNUSED(failover);
|
||||
Q_UNUSED(aircraft);
|
||||
Q_UNUSED(message);
|
||||
Q_UNUSED(disabled);
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace BlackGui
|
||||
void showAircraftModelDetails(bool show);
|
||||
|
||||
//! 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
|
||||
void timerUpdate();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace BlackGui
|
||||
void onSimulatorStatusChanged(int status);
|
||||
|
||||
//! \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
|
||||
void onSimulatorMessages(const BlackMisc::CStatusMessageList &messages);
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace BlackGui
|
||||
ui->cb_ExclNoExcludedModels->setChecked(mode.testFlag(CAircraftMatcherSetup::ExcludeNoExcluded));
|
||||
ui->cb_ExclNoDbData->setChecked(mode.testFlag(CAircraftMatcherSetup::ExcludeNoDbData));
|
||||
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));
|
||||
|
||||
this->setMatchingAlgorithm(setup);
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace BlackMisc
|
||||
static const QString exExcl("excl.excluded");
|
||||
static const QString removeFromModelSet("rem.from model set");
|
||||
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)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ namespace BlackMisc
|
||||
case ExcludeNoExcluded: return exExcl;
|
||||
case ModelSetRemoveFailedModel: return removeFromModelSet;
|
||||
case ModelVerificationAtStartup: return verification;
|
||||
case ModelFailoverWhenNoModelCanBeLoaded: return modelFailedLoad;
|
||||
case ModelFailoverIfNoModelCanBeAdded: return modelFailedAdded;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace BlackMisc
|
||||
if (mode.testFlag(ScorePreferColorLiveries)) { modes << modeFlagToString(ScorePreferColorLiveries); }
|
||||
if (mode.testFlag(ModelSetRemoveFailedModel)) { modes << modeFlagToString(ModelSetRemoveFailedModel); }
|
||||
if (mode.testFlag(ModelVerificationAtStartup)) { modes << modeFlagToString(ModelVerificationAtStartup); }
|
||||
if (mode.testFlag(ModelFailoverWhenNoModelCanBeLoaded)) { modes << modeFlagToString(ModelFailoverWhenNoModelCanBeLoaded); }
|
||||
if (mode.testFlag(ModelFailoverIfNoModelCanBeAdded)) { modes << modeFlagToString(ModelFailoverIfNoModelCanBeAdded); }
|
||||
|
||||
return modes.join(", ");
|
||||
}
|
||||
@@ -229,7 +229,7 @@ namespace BlackMisc
|
||||
if (excludeNoExcluded) { mode |= ExcludeNoExcluded; }
|
||||
if (modelSetRemoveFailedModel) { mode |= ModelSetRemoveFailedModel; }
|
||||
if (modelVerification) { mode |= ModelVerificationAtStartup; }
|
||||
if (modelFailover) { mode |= ModelFailoverWhenNoModelCanBeLoaded; }
|
||||
if (modelFailover) { mode |= ModelFailoverIfNoModelCanBeAdded; }
|
||||
return mode;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -55,14 +55,14 @@ namespace BlackMisc
|
||||
ExcludeNoExcluded = 1 << 14,
|
||||
ExcludeDefault = ExcludeNoExcluded | ExcludeNoDbData,
|
||||
// --- model set ---
|
||||
ModelSetRemoveFailedModel = 1 << 15,
|
||||
ModelVerificationAtStartup = 1 << 16,
|
||||
ModelFailoverWhenNoModelCanBeLoaded = 1 << 17,
|
||||
ModelSetRemoveFailedModel = 1 << 15,
|
||||
ModelVerificationAtStartup = 1 << 16,
|
||||
ModelFailoverIfNoModelCanBeAdded = 1 << 17,
|
||||
// --- others ---
|
||||
ModeNone = 0,
|
||||
ModeByFLags = ByMilitary | ByVtol,
|
||||
// ModeDefaultSet = ModelSetRemoveFailedModel | ModelVerificationAtStartup | ModelFailoverWhenNoModelCanBeLoaded,
|
||||
ModeDefaultSet = ModelSetRemoveFailedModel | ModelFailoverWhenNoModelCanBeLoaded,
|
||||
ModeDefaultSet = ModelSetRemoveFailedModel | ModelFailoverIfNoModelCanBeAdded,
|
||||
ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries | ExcludeDefault,
|
||||
ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery | ExcludeDefault,
|
||||
ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore | ExcludeDefault,
|
||||
@@ -111,6 +111,10 @@ namespace BlackMisc
|
||||
//! \sa ModelVerificationOnStartup
|
||||
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
|
||||
void setVerificationAtStartup(bool verify);
|
||||
|
||||
|
||||
@@ -951,7 +951,7 @@ namespace BlackSimPlugin
|
||||
if (!msg.isEmpty() && msg.isWarningOrAbove())
|
||||
{
|
||||
CLogMessage::preformatted(msg);
|
||||
emit this->physicallyAddingRemoteModelFailed(CSimulatedAircraft(), false, msg);
|
||||
emit this->physicallyAddingRemoteModelFailed(CSimulatedAircraft(), false, false, msg);
|
||||
}
|
||||
|
||||
// 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);
|
||||
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 (!canBeUsed || simObject.getAddingExceptions() >= ThresholdAddException)
|
||||
if (!verifiedAircraft || simObject.getAddingExceptions() >= ThresholdAddException)
|
||||
{
|
||||
const CStatusMessage m = !canBeUsed ?
|
||||
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();
|
||||
const CStatusMessage msg = verifiedAircraft ?
|
||||
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
|
||||
emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, m);
|
||||
emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, true, msg); // verify failed
|
||||
}
|
||||
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;
|
||||
this->updateAircraftEnabled(simObject.getCallsign(), false);
|
||||
emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, m);
|
||||
emit this->physicallyAddingRemoteModelFailed(simObject.getAircraft(), true, true, m); // directly removed again
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1412,7 +1412,7 @@ namespace BlackSimPlugin
|
||||
for (const CSimConnectObject &simObjOutdated : outdatedAdded)
|
||||
{
|
||||
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
|
||||
@@ -1547,7 +1547,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
const CStatusMessage msg = CStatusMessage(this).error(u"SimConnect, can not create AI traffic: '%1' '%2'") << callsign.toQString() << modelString;
|
||||
CLogMessage::preformatted(msg);
|
||||
emit this->physicallyAddingRemoteModelFailed(newRemoteAircraft, true, msg);
|
||||
emit this->physicallyAddingRemoteModelFailed(newRemoteAircraft, true, true, msg); // SimConnect error
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -215,14 +215,16 @@ namespace BlackSimPlugin
|
||||
{
|
||||
bool success = simulatorFsxP3D->setSimConnectObjectId(requestId, objectId);
|
||||
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)
|
||||
{
|
||||
// getting here would mean object was removed in the meantime
|
||||
// otherwise we will detect it in verification
|
||||
const CSimConnectObject simObject = simulatorFsxP3D->getSimObjectForObjectId(objectId);
|
||||
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();
|
||||
CLogMessage::preformatted(msg);
|
||||
emit simulatorFsxP3D->physicallyAddingRemoteModelFailed(remoteAircraft, false, msg);
|
||||
emit simulatorFsxP3D->physicallyAddingRemoteModelFailed(remoteAircraft, false, false, msg);
|
||||
}
|
||||
}
|
||||
break; // SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID
|
||||
|
||||
Reference in New Issue
Block a user