mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Ref T658, adjusted usage of matching script in matcher component (for testing)
* fixed matching messages to display also the reverse lookup messages * utility function for matching
This commit is contained in:
@@ -73,14 +73,17 @@ namespace BlackGui
|
|||||||
ui->le_Callsign->setValidator(validator);
|
ui->le_Callsign->setValidator(validator);
|
||||||
|
|
||||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMatcherComponent::onSimulatorChanged);
|
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMatcherComponent::onSimulatorChanged);
|
||||||
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CModelMatcherComponent::onWebDataRead, Qt::QueuedConnection);
|
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CModelMatcherComponent::onWebDataRead, Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(ui->pb_ModelMatching, &QPushButton::pressed, this, &CModelMatcherComponent::testModelMatching);
|
connect(ui->pb_ModelMatching, &QPushButton::pressed, this, &CModelMatcherComponent::testModelMatching);
|
||||||
connect(ui->pb_ReverseLookup, &QPushButton::pressed, this, &CModelMatcherComponent::reverseLookup);
|
connect(ui->pb_ReverseLookup, &QPushButton::pressed, this, &CModelMatcherComponent::reverseLookup);
|
||||||
connect(ui->pb_Settings, &QPushButton::pressed, this, &CModelMatcherComponent::displaySettingsDialog);
|
connect(ui->pb_Settings, &QPushButton::pressed, this, &CModelMatcherComponent::displaySettingsDialog);
|
||||||
|
|
||||||
connect(ui->cb_UseWorkbench, &QCheckBox::toggled, this, &CModelMatcherComponent::onWorkbenchToggled);
|
connect(ui->cb_UseWorkbench, &QCheckBox::toggled, this, &CModelMatcherComponent::onWorkbenchToggled);
|
||||||
|
|
||||||
|
// initial settings
|
||||||
|
m_matcher.setSetup(m_matchingSettings.get());
|
||||||
|
|
||||||
this->redisplay();
|
this->redisplay();
|
||||||
ui->cb_UseWorkbench->setVisible(false);
|
ui->cb_UseWorkbench->setVisible(false);
|
||||||
}
|
}
|
||||||
@@ -153,18 +156,22 @@ namespace BlackGui
|
|||||||
void CModelMatcherComponent::testModelMatching()
|
void CModelMatcherComponent::testModelMatching()
|
||||||
{
|
{
|
||||||
ui->te_Results->clear();
|
ui->te_Results->clear();
|
||||||
CStatusMessageList msgs;
|
|
||||||
this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue()); // update model set to latest version
|
this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue()); // update model set to latest version
|
||||||
CSimulatedAircraft remoteAircraft(createAircraft());
|
CStatusMessageList msgs;
|
||||||
|
CSimulatedAircraft remoteAircraft(this->createAircraft());
|
||||||
|
m_matcher.setDefaultModel(CModelMatcherComponent::defaultModel());
|
||||||
|
|
||||||
if (ui->cb_withReverseLookup->isChecked())
|
if (ui->cb_withReverseLookup->isChecked())
|
||||||
{
|
{
|
||||||
const QString liveryString(ui->comp_LiverySelector->getRawCombinedCode());
|
const QString liveryString(ui->comp_LiverySelector->getRawCombinedCode());
|
||||||
const CAircraftModel reverseModel = CAircraftMatcher::reverseLookupModel(remoteAircraft.getModel(), liveryString, &msgs);
|
const CAircraftModel reverseModel = CAircraftMatcher::reverseLookupModel(remoteAircraft.getModel(), liveryString, m_matcher.getSetup(), &msgs);
|
||||||
remoteAircraft.setModel(reverseModel); // current model
|
remoteAircraft.setModel(reverseModel); // current model
|
||||||
}
|
}
|
||||||
|
|
||||||
m_matcher.setDefaultModel(CModelMatcherComponent::defaultModel());
|
CStatusMessageList matchingMsgs;
|
||||||
const CAircraftModel matched = m_matcher.getClosestMatch(remoteAircraft, MatchingLogAll, &msgs); // test model matching
|
const CAircraftModel matched = m_matcher.getClosestMatch(remoteAircraft, MatchingLogAll, &matchingMsgs, true); // test model matching
|
||||||
|
msgs.push_back(matchingMsgs);
|
||||||
|
|
||||||
ui->te_Results->setText(matched.toQString(true));
|
ui->te_Results->setText(matched.toQString(true));
|
||||||
ui->tvp_ResultMessages->updateContainer(msgs);
|
ui->tvp_ResultMessages->updateContainer(msgs);
|
||||||
ui->tvp_ResultMessages->fullResizeToContents();
|
ui->tvp_ResultMessages->fullResizeToContents();
|
||||||
@@ -180,19 +187,7 @@ namespace BlackGui
|
|||||||
const CAircraftMatcherSetup setup = m_matcher.getSetup();
|
const CAircraftMatcherSetup setup = m_matcher.getSetup();
|
||||||
const CSimulatedAircraft remoteAircraft(createAircraft());
|
const CSimulatedAircraft remoteAircraft(createAircraft());
|
||||||
const QString livery(ui->comp_LiverySelector->getRawCombinedCode());
|
const QString livery(ui->comp_LiverySelector->getRawCombinedCode());
|
||||||
const CAircraftModel matched = CAircraftMatcher::reverseLookupModel(remoteAircraft.getModel(), livery, &msgs);
|
const CAircraftModel matched = CAircraftMatcher::reverseLookupModel(remoteAircraft.getModel(), livery, setup, &msgs);
|
||||||
|
|
||||||
// Script
|
|
||||||
CAircraftModel matchedWithScript = matched;
|
|
||||||
if (setup.doRunMsNetworkEntryScript())
|
|
||||||
{
|
|
||||||
matchedWithScript = CAircraftMatcher::networkEntryScript(matched, setup, &msgs);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CMatchingUtils::addLogDetailsToList(&msgs, remoteAircraft.getCallsign(), QStringLiteral("No entry script used"));
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->te_Results->setText(matched.toQString(true));
|
ui->te_Results->setText(matched.toQString(true));
|
||||||
ui->tvp_ResultMessages->updateContainer(msgs);
|
ui->tvp_ResultMessages->updateContainer(msgs);
|
||||||
}
|
}
|
||||||
@@ -276,5 +271,28 @@ namespace BlackGui
|
|||||||
if (model.getCallsign().isEmpty()) { model.setCallsign("SWIFT"); }
|
if (model.getCallsign().isEmpty()) { model.setCallsign("SWIFT"); }
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MSReturnValues CModelMatcherComponent::matchingScript(const CAircraftModel &inModel, const CAircraftMatcherSetup &setup, CStatusMessageList &msgs)
|
||||||
|
{
|
||||||
|
// Script
|
||||||
|
if (setup.doRunMsReverseLookupScript())
|
||||||
|
{
|
||||||
|
const MSReturnValues rv = CAircraftMatcher::reverseLookupScript(inModel, setup, &msgs);
|
||||||
|
if (rv.runScriptAndModified())
|
||||||
|
{
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CMatchingUtils::addLogDetailsToList(&msgs, inModel.getCallsign(), QStringLiteral("Matching script, no modification"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CMatchingUtils::addLogDetailsToList(&msgs, inModel.getCallsign(), QStringLiteral("No reverse lookup script used"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return inModel;
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
|
|
||||||
#include "blackcore/aircraftmatcher.h"
|
#include "blackcore/aircraftmatcher.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/simulation/settings/modelmatchersettings.h"
|
||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
|
#include "blackmisc/network/entityflags.h"
|
||||||
|
#include "blackmisc/settingscache.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -91,11 +93,14 @@ namespace BlackGui
|
|||||||
//! Pseudo default aircraft
|
//! Pseudo default aircraft
|
||||||
BlackMisc::Simulation::CAircraftModel defaultModel() const;
|
BlackMisc::Simulation::CAircraftModel defaultModel() const;
|
||||||
|
|
||||||
QScopedPointer<Ui::CModelMatcherComponent> ui;
|
//! Run matching script
|
||||||
|
static BlackMisc::Simulation::MSReturnValues matchingScript(const BlackMisc::Simulation::CAircraftModel &inModel, const BlackMisc::Simulation::CAircraftMatcherSetup &setup, BlackMisc::CStatusMessageList &msgs);
|
||||||
|
|
||||||
|
QScopedPointer<Ui::CModelMatcherComponent> ui;
|
||||||
QPointer<Views::CAircraftModelView> m_workbenchView; //!< an external workbenc
|
QPointer<Views::CAircraftModelView> m_workbenchView; //!< an external workbenc
|
||||||
CSettingsMatchingDialog *m_settingsDialog = nullptr; //!< matching settings as dialog
|
CSettingsMatchingDialog *m_settingsDialog = nullptr; //!< matching settings as dialog
|
||||||
BlackCore::CAircraftMatcher m_matcher { this }; //!< used matcher
|
BlackCore::CAircraftMatcher m_matcher { this }; //!< used matcher
|
||||||
|
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TModelMatching> m_matchingSettings { this }; //!< settings
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user