14using namespace swift::misc::network;
15using namespace swift::misc::simulation::data;
17namespace swift::misc::simulation
35 m_simulator = simulator;
36 m_simDirectory = simDirectory;
37 m_modelDirList = modelDirList;
43 return m_checkedSimulatorMsgs.contains(simulator);
49 m_checkedSimulatorMsgs.remove(simulator);
72 m_simulator = simulator;
73 m_simDirectory = simDirectory;
74 m_checkedSimulatorMsgs.
remove(simulator);
93 bool wasStopped =
false;
96 simulator = m_lastResultSimulator;
97 valid = m_lastResultValid;
98 invalid = m_lastResultInvalid;
99 msgs = m_lastResultMsgs;
100 wasStopped = m_lastResultWasStopped;
102 if (m_lastResultSimulator.isUnspecified())
106 emit this->
validated(simulator, valid, invalid, wasStopped, msgs);
112 Q_ASSERT_X(this->
hasStarted(), Q_FUNC_INFO,
"Worker not started yet");
113 m_updateTimer.startTimer(ms);
119 m_updateTimer.stopTimer();
122 void CBackgroundValidation::doWork()
136 bool onlyErrorsAndWarnings =
false;
139 m_wasStopped =
false;
159 const CAircraftModelList models = m_modelSets.getCachedModels(simulator);
167 QStringLiteral(
"No models in set for '%1'").arg(simulator.
toQString(
true))));
172 m_wasStopped, m_simDirectory);
176 const qint64 deltaTimeMs = now - started;
178 QStringLiteral(
"Validated in %1ms").arg(deltaTimeMs)));
182 QWriteLocker l(&m_lock);
183 m_lastResultValid = valid;
184 m_lastResultInvalid = invalid;
185 m_lastResultWasStopped = m_wasStopped;
186 m_lastResultSimulator = simulator;
187 m_lastResultMsgs = msgs;
188 m_checkedSimulatorMsgs.
insert(simulator, msgs);
198 if (m_timerBasedRuns > 3)
200 m_updateTimer.stopTimer();
208 if (e || !isTimerBased)
210 emit this->
validated(simulator, valid, invalid, m_wasStopped, msgs);
const QObject * owner() const
Owner of the worker.
CContinuousWorker(QObject *owner, const QString &name)
Constructor.
static const QString & worker()
Background task.
static const QString & modelSetCache()
Model set cache.
void push_back(const T &value)
Appends an element at the end of the sequence.
bool isEmpty() const
Synonym for empty.
iterator insert(iterator before, const T &value)
Inserts an element into the sequence.
static constexpr auto SeverityInfo
Status severities.
static constexpr auto SeverityWarning
Status severities.
Status messages, e.g. from Core -> GUI.
bool hasWarningOrErrorMessages() const
Warning or error messages.
void sortBySeverityHighestFirst()
Sort by severity, highest first.
void timeout()
Timer timed out.
bool hasStarted() const
True if the worker has started.
void freezeOrder()
Current order of list will be new order values.
QString toQString(bool i18n=false) const
Cast as QString.
bool onlyShowVerificationWarningsAndErrors() const
Verification only shown for warning/errors?
bool doVerificationAtStartup() const
Verification at startup?
Value object encapsulating a list of aircraft models.
static CStatusMessageList validateModelFiles(const CSimulatorInfo &simulator, const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmpty, int stopAtFailedFiles, std::atomic_bool &wasStopped, const QString &simulatorDir)
Validate aircraft.cfg entries.
bool wasAlreadyChecked(const CSimulatorInfo &simulator) const
Was already checked for simulator?
swift::misc::simulation::CSimulatorInfo getCurrentSimulator() const
Corresponding simulator.
void validating(bool running)
Validating.
bool requestLastValidationResults()
Request last results (again), if there are any.
static const QStringList & getLogCategories()
Log categories.
void startUpdating(std::chrono::milliseconds ms)
Start the updating timer.
void setCurrentSimulator(const CSimulatorInfo &simulator, const QString &simDirectory, const QStringList &modelDirList)
Corresponding simulator.
CBackgroundValidation(QObject *owner)
Constructor.
void beforeQuit() noexcept
Called before quit is called.
void resetAlreadyChecked(const CSimulatorInfo &simulator)
Reset checked for simulator.
bool triggerValidation(const CSimulatorInfo &simulator, const QString &simDirectory)
Trigger a validation, returns false if "work in progress".
void validated(const CSimulatorInfo &simulator, const CAircraftModelList &validModels, const CAircraftModelList &invalidModels, bool stopped, const CStatusMessageList &msgs)
Validated for simulator.
Simple hardcoded info about the corresponding simulator.
bool isSingleSimulator() const
Single simulator selected.
bool isNoSimulator() const
No simulator?
qint64 currentMSecsSinceEpoch()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * sender() const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)