mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T515, retrieve last validation results in distributed swift setup
This commit is contained in:
committed by
Mat Sutcliffe
parent
9623b7a1da
commit
998f0344fa
@@ -12,6 +12,8 @@
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore::Context;
|
||||
@@ -34,6 +36,14 @@ namespace BlackGui
|
||||
connect(ui->pb_TempDisableInvalid, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked);
|
||||
connect(ui->pb_TempDisableSelected, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked);
|
||||
connect(ui->pb_TriggerValidation, &QPushButton::released, this, &CAircraftModelValidationComponent::triggerValidation);
|
||||
|
||||
// 1st init when running in distributed environment
|
||||
QPointer<CAircraftModelValidationComponent> myself(this);
|
||||
QTimer::singleShot(2500, this, [ = ]
|
||||
{
|
||||
if (!myself || !sGui || sGui->isShuttingDown()) { return; }
|
||||
myself->requestLastResults();
|
||||
});
|
||||
}
|
||||
|
||||
CAircraftModelValidationComponent::~CAircraftModelValidationComponent()
|
||||
@@ -87,17 +97,29 @@ namespace BlackGui
|
||||
return;
|
||||
}
|
||||
|
||||
const CSimulatorInfo sim = ui->comp_Simulator->getValue();
|
||||
if (sGui->getIContextSimulator()->triggerModelSetValidation(sim))
|
||||
const CSimulatorInfo simulator = ui->comp_Simulator->getValue();
|
||||
if (sGui->getIContextSimulator()->triggerModelSetValidation(simulator))
|
||||
{
|
||||
this->showOverlayHTMLMessage(QStringLiteral("Triggered validation for '%1'").arg(sim.toQString(true)), 5000);
|
||||
this->showOverlayHTMLMessage(QStringLiteral("Triggered validation for '%1'").arg(simulator.toQString(true)), 5000);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->showOverlayHTMLMessage(QStringLiteral("Cannot trigger validation for '%1'").arg(sim.toQString(true)), 5000);
|
||||
this->showOverlayHTMLMessage(QStringLiteral("Cannot trigger validation for '%1'").arg(simulator.toQString(true)), 5000);
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftModelValidationComponent::requestLastResults()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->supportsContexts()) { return; }
|
||||
if (!sGui->getIContextSimulator()) { return; }
|
||||
if (sGui->getIContextSimulator()->isValidationInProgress())
|
||||
{
|
||||
this->showOverlayHTMLMessage("Validation in progress", 5000);
|
||||
return;
|
||||
}
|
||||
sGui->getIContextSimulator()->triggerModelSetValidation(CSimulatorInfo());
|
||||
}
|
||||
|
||||
void CAircraftModelValidationComponent::onButtonClicked()
|
||||
{
|
||||
const QObject *sender = QObject::sender();
|
||||
|
||||
@@ -65,6 +65,9 @@ namespace BlackGui
|
||||
//! Trigger new validation
|
||||
void triggerValidation();
|
||||
|
||||
//! Last results if any
|
||||
void requestLastResults();
|
||||
|
||||
//! Button has been clicked
|
||||
void onButtonClicked();
|
||||
};
|
||||
|
||||
@@ -62,13 +62,45 @@ namespace BlackMisc
|
||||
|
||||
bool CBackgroundValidation::triggerValidation(const CSimulatorInfo &simulator)
|
||||
{
|
||||
const QPointer<CBackgroundValidation> myself(this);
|
||||
if (simulator.isNoSimulator())
|
||||
{
|
||||
return this->requestLastResults();
|
||||
}
|
||||
|
||||
{
|
||||
QWriteLocker l(&m_lock);
|
||||
if (m_inWork) { return false; }
|
||||
m_simulator = simulator;
|
||||
m_checkedSimulatorMsgs.remove(simulator);
|
||||
}
|
||||
QTimer::singleShot(0, this, &CBackgroundValidation::doWork);
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
myself->doWork();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBackgroundValidation::requestLastResults()
|
||||
{
|
||||
|
||||
CAircraftModelList valid;
|
||||
CAircraftModelList invalid;
|
||||
CAircraftModelList models;
|
||||
CStatusMessageList msgs;
|
||||
CSimulatorInfo simulator;
|
||||
bool wasStopped = false;
|
||||
{
|
||||
QReadLocker l(&m_lock);
|
||||
simulator = m_lastResultSimulator;
|
||||
valid = m_lastResultValid;
|
||||
invalid = m_lastResultInvalid;
|
||||
msgs = m_lastResultMsgs;
|
||||
wasStopped = m_lastResultWasStopped;
|
||||
}
|
||||
if (m_lastResultSimulator.isUnspecified()) { return false; }
|
||||
emit this->validated(simulator, valid, invalid, wasStopped, msgs);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -80,7 +112,6 @@ namespace BlackMisc
|
||||
|
||||
CAircraftModelList valid;
|
||||
CAircraftModelList invalid;
|
||||
CAircraftModelList models;
|
||||
CStatusMessageList msgs;
|
||||
bool wasStopped = false;
|
||||
bool validated = false;
|
||||
@@ -95,7 +126,7 @@ namespace BlackMisc
|
||||
const CAircraftMatcherSetup setup = m_matchingSettings.get();
|
||||
if (!setup.doVerificationAtStartup()) { break; }
|
||||
|
||||
models = m_modelSets.getCachedModels(simulator);
|
||||
const CAircraftModelList models = m_modelSets.getCachedModels(simulator);
|
||||
msgs = CAircraftModelUtilities::validateModelFiles(models, valid, invalid, false, 25, wasStopped);
|
||||
|
||||
const qint64 deltaTimeMs = QDateTime::currentMSecsSinceEpoch() - started;
|
||||
@@ -104,6 +135,11 @@ namespace BlackMisc
|
||||
validated = true;
|
||||
|
||||
QWriteLocker l(&m_lock);
|
||||
m_lastResultValid = valid;
|
||||
m_lastResultInvalid = invalid;
|
||||
m_lastResultWasStopped = wasStopped;
|
||||
m_lastResultSimulator = simulator;
|
||||
m_lastResultMsgs = msgs;
|
||||
m_checkedSimulatorMsgs.insert(simulator, msgs);
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -64,6 +64,11 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
bool triggerValidation(const CSimulatorInfo &simulator);
|
||||
|
||||
//! Request last results (again), if there are any
|
||||
//! \remark emits CBackgroundValidation::validated signal
|
||||
//! \threadsafe
|
||||
bool requestLastResults();
|
||||
|
||||
signals:
|
||||
//! Validating
|
||||
void validating(bool running);
|
||||
@@ -75,8 +80,16 @@ namespace BlackMisc
|
||||
mutable QReadWriteLock m_lock; //!< lock snapshot
|
||||
std::atomic_bool m_inWork { false }; //!< indicates a running update
|
||||
CSimulatorInfo m_simulator;
|
||||
QMap<CSimulatorInfo, CStatusMessageList> m_checkedSimulatorMsgs;
|
||||
CSetting<Settings::TModelMatching> m_matchingSettings { this }; //!< settings
|
||||
|
||||
// last result values, mostly needed when running in the distributed swift system and we want to get the values
|
||||
CAircraftModelList m_lastResultValid;
|
||||
CAircraftModelList m_lastResultInvalid;
|
||||
CSimulatorInfo m_lastResultSimulator;
|
||||
CStatusMessageList m_lastResultMsgs;
|
||||
bool m_lastResultWasStopped = false;
|
||||
|
||||
QMap<CSimulatorInfo, CStatusMessageList> m_checkedSimulatorMsgs; //!< all simulators ever checked
|
||||
CSetting<Settings::TModelMatching> m_matchingSettings { this }; //!< settings
|
||||
|
||||
// Set/caches as member as we are in own thread, central instance will not work
|
||||
Data::CModelSetCaches m_modelSets { false, this };
|
||||
|
||||
Reference in New Issue
Block a user