mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +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 "blackgui/guiapplication.h"
|
||||||
#include "blackcore/context/contextsimulator.h"
|
#include "blackcore/context/contextsimulator.h"
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackCore::Context;
|
using namespace BlackCore::Context;
|
||||||
@@ -34,6 +36,14 @@ namespace BlackGui
|
|||||||
connect(ui->pb_TempDisableInvalid, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked);
|
connect(ui->pb_TempDisableInvalid, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked);
|
||||||
connect(ui->pb_TempDisableSelected, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked);
|
connect(ui->pb_TempDisableSelected, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked);
|
||||||
connect(ui->pb_TriggerValidation, &QPushButton::released, this, &CAircraftModelValidationComponent::triggerValidation);
|
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()
|
CAircraftModelValidationComponent::~CAircraftModelValidationComponent()
|
||||||
@@ -87,17 +97,29 @@ namespace BlackGui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSimulatorInfo sim = ui->comp_Simulator->getValue();
|
const CSimulatorInfo simulator = ui->comp_Simulator->getValue();
|
||||||
if (sGui->getIContextSimulator()->triggerModelSetValidation(sim))
|
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
|
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()
|
void CAircraftModelValidationComponent::onButtonClicked()
|
||||||
{
|
{
|
||||||
const QObject *sender = QObject::sender();
|
const QObject *sender = QObject::sender();
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ namespace BlackGui
|
|||||||
//! Trigger new validation
|
//! Trigger new validation
|
||||||
void triggerValidation();
|
void triggerValidation();
|
||||||
|
|
||||||
|
//! Last results if any
|
||||||
|
void requestLastResults();
|
||||||
|
|
||||||
//! Button has been clicked
|
//! Button has been clicked
|
||||||
void onButtonClicked();
|
void onButtonClicked();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -62,13 +62,45 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool CBackgroundValidation::triggerValidation(const CSimulatorInfo &simulator)
|
bool CBackgroundValidation::triggerValidation(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
|
const QPointer<CBackgroundValidation> myself(this);
|
||||||
|
if (simulator.isNoSimulator())
|
||||||
|
{
|
||||||
|
return this->requestLastResults();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QWriteLocker l(&m_lock);
|
QWriteLocker l(&m_lock);
|
||||||
if (m_inWork) { return false; }
|
if (m_inWork) { return false; }
|
||||||
m_simulator = simulator;
|
m_simulator = simulator;
|
||||||
m_checkedSimulatorMsgs.remove(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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +112,6 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CAircraftModelList valid;
|
CAircraftModelList valid;
|
||||||
CAircraftModelList invalid;
|
CAircraftModelList invalid;
|
||||||
CAircraftModelList models;
|
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
bool wasStopped = false;
|
bool wasStopped = false;
|
||||||
bool validated = false;
|
bool validated = false;
|
||||||
@@ -95,7 +126,7 @@ namespace BlackMisc
|
|||||||
const CAircraftMatcherSetup setup = m_matchingSettings.get();
|
const CAircraftMatcherSetup setup = m_matchingSettings.get();
|
||||||
if (!setup.doVerificationAtStartup()) { break; }
|
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);
|
msgs = CAircraftModelUtilities::validateModelFiles(models, valid, invalid, false, 25, wasStopped);
|
||||||
|
|
||||||
const qint64 deltaTimeMs = QDateTime::currentMSecsSinceEpoch() - started;
|
const qint64 deltaTimeMs = QDateTime::currentMSecsSinceEpoch() - started;
|
||||||
@@ -104,6 +135,11 @@ namespace BlackMisc
|
|||||||
validated = true;
|
validated = true;
|
||||||
|
|
||||||
QWriteLocker l(&m_lock);
|
QWriteLocker l(&m_lock);
|
||||||
|
m_lastResultValid = valid;
|
||||||
|
m_lastResultInvalid = invalid;
|
||||||
|
m_lastResultWasStopped = wasStopped;
|
||||||
|
m_lastResultSimulator = simulator;
|
||||||
|
m_lastResultMsgs = msgs;
|
||||||
m_checkedSimulatorMsgs.insert(simulator, msgs);
|
m_checkedSimulatorMsgs.insert(simulator, msgs);
|
||||||
}
|
}
|
||||||
while (false);
|
while (false);
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
bool triggerValidation(const CSimulatorInfo &simulator);
|
bool triggerValidation(const CSimulatorInfo &simulator);
|
||||||
|
|
||||||
|
//! Request last results (again), if there are any
|
||||||
|
//! \remark emits CBackgroundValidation::validated signal
|
||||||
|
//! \threadsafe
|
||||||
|
bool requestLastResults();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Validating
|
//! Validating
|
||||||
void validating(bool running);
|
void validating(bool running);
|
||||||
@@ -75,8 +80,16 @@ namespace BlackMisc
|
|||||||
mutable QReadWriteLock m_lock; //!< lock snapshot
|
mutable QReadWriteLock m_lock; //!< lock snapshot
|
||||||
std::atomic_bool m_inWork { false }; //!< indicates a running update
|
std::atomic_bool m_inWork { false }; //!< indicates a running update
|
||||||
CSimulatorInfo m_simulator;
|
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
|
// Set/caches as member as we are in own thread, central instance will not work
|
||||||
Data::CModelSetCaches m_modelSets { false, this };
|
Data::CModelSetCaches m_modelSets { false, this };
|
||||||
|
|||||||
Reference in New Issue
Block a user