mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Ref T362, Ref T348 matcher saves removed models (if any) when destructed
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
@@ -39,16 +40,23 @@ namespace BlackCore
|
||||
return cats;
|
||||
}
|
||||
|
||||
CAircraftMatcher::CAircraftMatcher(const CAircraftMatcherSetup &setup, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_setup(setup)
|
||||
CAircraftMatcher::CAircraftMatcher(const CAircraftMatcherSetup &setup, QObject *parent) : QObject(parent), m_setup(setup)
|
||||
{ }
|
||||
|
||||
CAircraftMatcher::CAircraftMatcher(QObject *parent) : CAircraftMatcher(CAircraftMatcherSetup(), parent)
|
||||
{ }
|
||||
|
||||
CAircraftMatcher::~CAircraftMatcher()
|
||||
{ }
|
||||
{
|
||||
if (!m_removedModels.isEmpty())
|
||||
{
|
||||
// log the models
|
||||
const QString fileName("removed models %1.json");
|
||||
const QString ts = QDateTime::currentDateTimeUtc().toString("yyyyMMddHHmmss");
|
||||
const QString json = m_removedModels.toJsonString();
|
||||
CFileUtils::writeStringToFile(json, CFileUtils::appendFilePathsAndFixUnc(CDirectoryUtils::logDirectory(), fileName.arg(ts)));
|
||||
}
|
||||
}
|
||||
|
||||
bool CAircraftMatcher::setSetup(const CAircraftMatcherSetup &setup)
|
||||
{
|
||||
@@ -671,11 +679,11 @@ namespace BlackCore
|
||||
if (remoteAircraft.hasCallsign() && remoteAircraft.hasModelString())
|
||||
{
|
||||
const QString modelString = remoteAircraft.getModelString();
|
||||
const int r = m_modelSet.removeModelWithString(modelString, Qt::CaseInsensitive);
|
||||
if (r > 0)
|
||||
const bool r = m_modelSet.removeModelWithString(modelString, Qt::CaseInsensitive);
|
||||
if (r)
|
||||
{
|
||||
CLogMessage(this).warning("Removed model '%1' from matching model set") << modelString;
|
||||
m_removedModels.insert(modelString);
|
||||
m_removedModels.replaceOrAddModelWithString(remoteAircraft.getModel(), Qt::CaseInsensitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace BlackCore
|
||||
CAircraftMatcher(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
//! \remark saves a log of removed models if any
|
||||
virtual ~CAircraftMatcher();
|
||||
|
||||
//! Set the setup
|
||||
@@ -262,10 +263,10 @@ namespace BlackCore
|
||||
BlackMisc::Simulation::CAircraftMatcherSetup m_setup; //!< setup
|
||||
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< model to be used as default model
|
||||
BlackMisc::Simulation::CAircraftModelList m_modelSet; //!< models used for model matching
|
||||
BlackMisc::Simulation::CAircraftModelList m_removedModels; //!< removed models
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< simulator (optional)
|
||||
BlackMisc::Simulation::CMatchingStatistics m_statistics; //!< matching statistics
|
||||
QString m_modelSetInfo; //!< info string
|
||||
QSet<QString> m_removedModels; //!< models have been removed
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user