VOR Loclizer feature: Make settings assignments atomic. Part of #1329

This commit is contained in:
f4exb 2022-11-30 22:00:26 +01:00
parent c61bc00260
commit 8ccdcb7e30
14 changed files with 359 additions and 74 deletions

View File

@ -127,7 +127,7 @@ void VORLocalizer::start()
m_state = StRunning; m_state = StRunning;
m_thread->start(); m_thread->start();
VorLocalizerWorker::MsgConfigureVORLocalizerWorker *msg = VorLocalizerWorker::MsgConfigureVORLocalizerWorker::create(m_settings, true); VorLocalizerWorker::MsgConfigureVORLocalizerWorker *msg = VorLocalizerWorker::MsgConfigureVORLocalizerWorker::create(m_settings, QList<QString>(), true);
m_worker->getInputMessageQueue()->push(msg); m_worker->getInputMessageQueue()->push(msg);
m_running = true; m_running = true;
@ -155,7 +155,7 @@ bool VORLocalizer::handleMessage(const Message& cmd)
{ {
MsgConfigureVORLocalizer& cfg = (MsgConfigureVORLocalizer&) cmd; MsgConfigureVORLocalizer& cfg = (MsgConfigureVORLocalizer&) cmd;
qDebug() << "VORLocalizer::handleMessage: MsgConfigureVORLocalizer"; qDebug() << "VORLocalizer::handleMessage: MsgConfigureVORLocalizer";
applySettings(cfg.getSettings(), cfg.getForce()); applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
return true; return true;
} }
@ -323,66 +323,39 @@ bool VORLocalizer::deserialize(const QByteArray& data)
{ {
if (m_settings.deserialize(data)) if (m_settings.deserialize(data))
{ {
MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(m_settings, true); MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
return true; return true;
} }
else else
{ {
m_settings.resetToDefaults(); m_settings.resetToDefaults();
MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(m_settings, true); MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
return false; return false;
} }
} }
void VORLocalizer::applySettings(const VORLocalizerSettings& settings, bool force) void VORLocalizer::applySettings(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force)
{ {
qDebug() << "VORLocalizer::applySettings:" qDebug() << "VORLocalizer::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
<< " m_title: " << settings.m_title
<< " m_rgbColor: " << settings.m_rgbColor
<< " m_magDecAdjust: " << settings.m_magDecAdjust
<< " m_rrTime: " << settings.m_rrTime
<< " m_centerShift: " << settings.m_centerShift
<< " force: " << force;
QList<QString> reverseAPIKeys;
if ((m_settings.m_title != settings.m_title) || force) {
reverseAPIKeys.append("title");
}
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
reverseAPIKeys.append("rgbColor");
}
if ((m_settings.m_magDecAdjust != settings.m_magDecAdjust) || force) {
reverseAPIKeys.append("magDecAdjust");
}
if ((m_settings.m_rrTime != settings.m_rrTime) || force) {
reverseAPIKeys.append("rrTime");
}
if ((m_settings.m_forceRRAveraging != settings.m_forceRRAveraging) || force) {
reverseAPIKeys.append("forceRRAveraging");
}
if ((m_settings.m_centerShift != settings.m_centerShift) || force) {
reverseAPIKeys.append("centerShift");
}
if (m_running) if (m_running)
{ {
VorLocalizerWorker::MsgConfigureVORLocalizerWorker *msg = VorLocalizerWorker::MsgConfigureVORLocalizerWorker::create( VorLocalizerWorker::MsgConfigureVORLocalizerWorker *msg = VorLocalizerWorker::MsgConfigureVORLocalizerWorker::create(
settings, force settings, settingsKeys, force
); );
m_worker->getInputMessageQueue()->push(msg); m_worker->getInputMessageQueue()->push(msg);
} }
if (settings.m_useReverseAPI) if (settingsKeys.contains("useReverseAPI"))
{ {
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) || bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) || settingsKeys.contains("reverseAPIAddress") ||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) || settingsKeys.contains("reverseAPIPort") ||
(m_settings.m_reverseAPIFeatureSetIndex != settings.m_reverseAPIFeatureSetIndex) || settingsKeys.contains("reverseAPIFeatureSetIndex") ||
(m_settings.m_reverseAPIFeatureIndex != settings.m_reverseAPIFeatureIndex); settingsKeys.contains("m_reverseAPIFeatureIndex");
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
} }
m_settings = settings; m_settings = settings;
@ -468,13 +441,13 @@ int VORLocalizer::webapiSettingsPutPatch(
VORLocalizerSettings settings = m_settings; VORLocalizerSettings settings = m_settings;
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response); webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(settings, force); MsgConfigureVORLocalizer *msg = MsgConfigureVORLocalizer::create(settings, featureSettingsKeys, force);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
qDebug("VORLocalizer::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue); qDebug("VORLocalizer::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
if (m_guiMessageQueue) // forward to GUI if any if (m_guiMessageQueue) // forward to GUI if any
{ {
MsgConfigureVORLocalizer *msgToGUI = MsgConfigureVORLocalizer::create(settings, force); MsgConfigureVORLocalizer *msgToGUI = MsgConfigureVORLocalizer::create(settings, featureSettingsKeys, force);
m_guiMessageQueue->push(msgToGUI); m_guiMessageQueue->push(msgToGUI);
} }
@ -569,6 +542,26 @@ void VORLocalizer::webapiFormatFeatureSettings(
response.getVorLocalizerSettings()->setRollupState(swgRollupState); response.getVorLocalizerSettings()->setRollupState(swgRollupState);
} }
} }
if (!response.getVorLocalizerSettings()->getColumnIndexes()) {
response.getVorLocalizerSettings()->setColumnIndexes(new QList<int>());
}
response.getVorLocalizerSettings()->getColumnIndexes()->clear();
for (int i = 0; i < VORLocalizerSettings::VORDEMOD_COLUMNS; i++) {
response.getVorLocalizerSettings()->getColumnIndexes()->push_back(settings.m_columnIndexes[i]);
}
if (!response.getVorLocalizerSettings()->getColumnSizes()) {
response.getVorLocalizerSettings()->setColumnSizes(new QList<int>());
}
response.getVorLocalizerSettings()->getColumnSizes()->clear();
for (int i = 0; i < VORLocalizerSettings::VORDEMOD_COLUMNS; i++) {
response.getVorLocalizerSettings()->getColumnSizes()->push_back(settings.m_columnSizes[i]);
}
} }
void VORLocalizer::webapiUpdateFeatureSettings( void VORLocalizer::webapiUpdateFeatureSettings(
@ -612,9 +605,27 @@ void VORLocalizer::webapiUpdateFeatureSettings(
if (settings.m_rollupState && featureSettingsKeys.contains("rollupState")) { if (settings.m_rollupState && featureSettingsKeys.contains("rollupState")) {
settings.m_rollupState->updateFrom(featureSettingsKeys, response.getVorLocalizerSettings()->getRollupState()); settings.m_rollupState->updateFrom(featureSettingsKeys, response.getVorLocalizerSettings()->getRollupState());
} }
if (featureSettingsKeys.contains("columnIndexes"))
{
const QList<int> *indexes = response.getVorLocalizerSettings()->getColumnIndexes();
for (int i = 0; i < VORLocalizerSettings::VORDEMOD_COLUMNS; i++) {
settings.m_columnIndexes[i] = (*indexes)[i];
}
}
if (featureSettingsKeys.contains("columnSizes"))
{
const QList<int> *indexes = response.getVorLocalizerSettings()->getColumnSizes();
for (int i = 0; i < VORLocalizerSettings::VORDEMOD_COLUMNS; i++) {
settings.m_columnSizes[i] = (*indexes)[i];
}
}
} }
void VORLocalizer::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const VORLocalizerSettings& settings, bool force) void VORLocalizer::webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const VORLocalizerSettings& settings, bool force)
{ {
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings(); SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet()); // swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());

View File

@ -46,19 +46,22 @@ public:
public: public:
const VORLocalizerSettings& getSettings() const { return m_settings; } const VORLocalizerSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; } bool getForce() const { return m_force; }
static MsgConfigureVORLocalizer* create(const VORLocalizerSettings& settings, bool force) { static MsgConfigureVORLocalizer* create(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force) {
return new MsgConfigureVORLocalizer(settings, force); return new MsgConfigureVORLocalizer(settings, settingsKeys, force);
} }
private: private:
VORLocalizerSettings m_settings; VORLocalizerSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force; bool m_force;
MsgConfigureVORLocalizer(const VORLocalizerSettings& settings, bool force) : MsgConfigureVORLocalizer(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(), Message(),
m_settings(settings), m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force) m_force(force)
{ } { }
}; };
@ -214,10 +217,10 @@ private:
void start(); void start();
void stop(); void stop();
void applySettings(const VORLocalizerSettings& settings, bool force = false); void applySettings(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
void updateChannels(); void updateChannels();
void notifyUpdateChannels(); void notifyUpdateChannels();
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const VORLocalizerSettings& settings, bool force); void webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const VORLocalizerSettings& settings, bool force);
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response); void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
private slots: private slots:

View File

@ -375,6 +375,8 @@ void VORLocalizerGUI::vorData_sectionMoved(int logicalIndex, int oldVisualIndex,
{ {
(void) oldVisualIndex; (void) oldVisualIndex;
m_settings.m_columnIndexes[logicalIndex] = newVisualIndex; m_settings.m_columnIndexes[logicalIndex] = newVisualIndex;
m_settingsKeys.append("columnIndexes");
applySettings();
} }
// Column in table resized (when hidden size is 0) // Column in table resized (when hidden size is 0)
@ -382,6 +384,8 @@ void VORLocalizerGUI::vorData_sectionResized(int logicalIndex, int oldSize, int
{ {
(void) oldSize; (void) oldSize;
m_settings.m_columnSizes[logicalIndex] = newSize; m_settings.m_columnSizes[logicalIndex] = newSize;
m_settingsKeys.append("columnSizes");
applySettings();
} }
// Right click in table header - show column select menu // Right click in table header - show column select menu
@ -534,7 +538,13 @@ bool VORLocalizerGUI::handleMessage(const Message& message)
{ {
qDebug("VORLocalizerGUI::handleMessage: VORLocalizer::MsgConfigureVORLocalizer"); qDebug("VORLocalizerGUI::handleMessage: VORLocalizer::MsgConfigureVORLocalizer");
const VORLocalizer::MsgConfigureVORLocalizer& cfg = (VORLocalizer::MsgConfigureVORLocalizer&) message; const VORLocalizer::MsgConfigureVORLocalizer& cfg = (VORLocalizer::MsgConfigureVORLocalizer&) message;
m_settings = cfg.getSettings();
if (cfg.getForce()) {
m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}
blockApplySettings(true); blockApplySettings(true);
displaySettings(); displaySettings();
blockApplySettings(false); blockApplySettings(false);
@ -598,8 +608,8 @@ bool VORLocalizerGUI::handleMessage(const Message& message)
{ {
VORLocalizerReport::MsgReportIdent& report = (VORLocalizerReport::MsgReportIdent&) message; VORLocalizerReport::MsgReportIdent& report = (VORLocalizerReport::MsgReportIdent&) message;
int subChannelId = report.getSubChannelId(); int subChannelId = report.getSubChannelId();
VORGUI *vorGUI = m_selectedVORs.value(subChannelId); VORGUI *vorGUI = m_selectedVORs.value(subChannelId);
if (vorGUI) if (vorGUI)
{ {
@ -608,6 +618,7 @@ bool VORLocalizerGUI::handleMessage(const Message& message)
QString identString = Morse::toString(ident); QString identString = Morse::toString(ident);
// Idents should only be two or three characters, so filter anything else // Idents should only be two or three characters, so filter anything else
// other than TEST which indicates a VOR is under maintainance (may also be TST) // other than TEST which indicates a VOR is under maintainance (may also be TST)
if (((identString.size() >= 2) && (identString.size() <= 3)) || (identString == "TEST")) if (((identString.size() >= 2) && (identString.size() <= 3)) || (identString == "TEST"))
{ {
vorGUI->m_rxIdentItem->setText(identString); vorGUI->m_rxIdentItem->setText(identString);
@ -741,6 +752,7 @@ void VORLocalizerGUI::downloadingURL(const QString& url)
void VORLocalizerGUI::downloadError(const QString& error) void VORLocalizerGUI::downloadError(const QString& error)
{ {
QMessageBox::critical(this, "VOR Localizer", error); QMessageBox::critical(this, "VOR Localizer", error);
if (m_progressDialog) if (m_progressDialog)
{ {
m_progressDialog->close(); m_progressDialog->close();
@ -754,7 +766,9 @@ void VORLocalizerGUI::downloadNavAidsFinished()
if (m_progressDialog) { if (m_progressDialog) {
m_progressDialog->setLabelText("Reading NAVAIDs."); m_progressDialog->setLabelText("Reading NAVAIDs.");
} }
readNavAids(); readNavAids();
if (m_progressDialog) if (m_progressDialog)
{ {
m_progressDialog->close(); m_progressDialog->close();
@ -767,6 +781,7 @@ void VORLocalizerGUI::on_magDecAdjust_toggled(bool checked)
{ {
m_settings.m_magDecAdjust = checked; m_settings.m_magDecAdjust = checked;
m_vorModel.allVORUpdated(); m_vorModel.allVORUpdated();
m_settingsKeys.append("magDecAdjust");
applySettings(); applySettings();
} }
@ -774,6 +789,7 @@ void VORLocalizerGUI::on_rrTime_valueChanged(int value)
{ {
m_settings.m_rrTime = value; m_settings.m_rrTime = value;
ui->rrTimeText->setText(tr("%1s").arg(m_settings.m_rrTime)); ui->rrTimeText->setText(tr("%1s").arg(m_settings.m_rrTime));
m_settingsKeys.append("rrTime");
applySettings(); applySettings();
} }
@ -781,6 +797,7 @@ void VORLocalizerGUI::on_centerShift_valueChanged(int value)
{ {
m_settings.m_centerShift = value * 1000; m_settings.m_centerShift = value * 1000;
ui->centerShiftText->setText(tr("%1k").arg(value)); ui->centerShiftText->setText(tr("%1k").arg(value));
m_settingsKeys.append("centerShift");
applySettings(); applySettings();
} }
@ -799,9 +816,7 @@ void VORLocalizerGUI::onWidgetRolled(QWidget* widget, bool rollDown)
(void) rollDown; (void) rollDown;
RollupContents *rollupContents = getRollupContents(); RollupContents *rollupContents = getRollupContents();
rollupContents->saveState(m_rollupState); rollupContents->saveState(m_rollupState);
applySettings();
} }
void VORLocalizerGUI::onMenuDialogCalled(const QPoint &p) void VORLocalizerGUI::onMenuDialogCalled(const QPoint &p)
@ -830,6 +845,14 @@ void VORLocalizerGUI::onMenuDialogCalled(const QPoint &p)
setTitle(m_settings.m_title); setTitle(m_settings.m_title);
setTitleColor(m_settings.m_rgbColor); setTitleColor(m_settings.m_rgbColor);
m_settingsKeys.append("title");
m_settingsKeys.append("rgbColor");
m_settingsKeys.append("useReverseAPI");
m_settingsKeys.append("reverseAPIAddress");
m_settingsKeys.append("reverseAPIPort");
m_settingsKeys.append("reverseAPIFeatureSetIndex");
m_settingsKeys.append("reverseAPIFeatureIndex");
applySettings(); applySettings();
} }
@ -849,6 +872,7 @@ void VORLocalizerGUI::applyMapSettings()
QObject *object = item->findChild<QObject*>("map"); QObject *object = item->findChild<QObject*>("map");
QGeoCoordinate coords; QGeoCoordinate coords;
double zoom; double zoom;
if (object != nullptr) if (object != nullptr)
{ {
// Save existing position of map // Save existing position of map
@ -876,14 +900,21 @@ void VORLocalizerGUI::applyMapSettings()
} }
QVariant retVal; QVariant retVal;
if (!QMetaObject::invokeMethod(item, "createMap", Qt::DirectConnection,
Q_RETURN_ARG(QVariant, retVal), if (!QMetaObject::invokeMethod(
Q_ARG(QVariant, QVariant::fromValue(parameters)), item,
Q_ARG(QVariant, mapType), "createMap",
Q_ARG(QVariant, QVariant::fromValue(this)))) Qt::DirectConnection,
Q_RETURN_ARG(QVariant, retVal),
Q_ARG(QVariant, QVariant::fromValue(parameters)),
Q_ARG(QVariant, mapType),
Q_ARG(QVariant, QVariant::fromValue(this))
)
)
{ {
qCritical() << "VORLocalizerGUI::applyMapSettings - Failed to invoke createMap"; qCritical() << "VORLocalizerGUI::applyMapSettings - Failed to invoke createMap";
} }
QObject *newMap = retVal.value<QObject *>(); QObject *newMap = retVal.value<QObject *>();
// Restore position of map // Restore position of map
@ -902,6 +933,7 @@ void VORLocalizerGUI::applyMapSettings()
// Move antenna icon to My Position // Move antenna icon to My Position
QObject *stationObject = newMap->findChild<QObject*>("station"); QObject *stationObject = newMap->findChild<QObject*>("station");
if(stationObject != NULL) if(stationObject != NULL)
{ {
QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>(); QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>();
@ -1035,9 +1067,11 @@ void VORLocalizerGUI::applySettings(bool force)
{ {
if (m_doApplySettings) if (m_doApplySettings)
{ {
VORLocalizer::MsgConfigureVORLocalizer* message = VORLocalizer::MsgConfigureVORLocalizer::create( m_settings, force); VORLocalizer::MsgConfigureVORLocalizer* message = VORLocalizer::MsgConfigureVORLocalizer::create( m_settings, m_settingsKeys, force);
m_vorLocalizer->getInputMessageQueue()->push(message); m_vorLocalizer->getInputMessageQueue()->push(message);
} }
m_settingsKeys.clear();
} }
void VORLocalizerGUI::displaySettings() void VORLocalizerGUI::displaySettings()
@ -1116,7 +1150,7 @@ void VORLocalizerGUI::tick()
QQuickItem *item = ui->map->rootObject(); QQuickItem *item = ui->map->rootObject();
QObject *stationObject = item->findChild<QObject*>("station"); QObject *stationObject = item->findChild<QObject*>("station");
if(stationObject != NULL) if (stationObject != NULL)
{ {
QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>(); QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>();
coords.setLatitude(lat); coords.setLatitude(lat);
@ -1155,9 +1189,11 @@ void VORLocalizerGUI::preferenceChanged(int elementType)
// Update icon position on Map // Update icon position on Map
QQuickItem *item = ui->map->rootObject(); QQuickItem *item = ui->map->rootObject();
QObject *map = item->findChild<QObject*>("map"); QObject *map = item->findChild<QObject*>("map");
if (map != nullptr) if (map != nullptr)
{ {
QObject *stationObject = map->findChild<QObject*>("station"); QObject *stationObject = map->findChild<QObject*>("station");
if(stationObject != NULL) if(stationObject != NULL)
{ {
QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>(); QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>();
@ -1169,14 +1205,17 @@ void VORLocalizerGUI::preferenceChanged(int elementType)
} }
} }
} }
if (pref == Preferences::StationName) if (pref == Preferences::StationName)
{ {
// Update icon label on Map // Update icon label on Map
QQuickItem *item = ui->map->rootObject(); QQuickItem *item = ui->map->rootObject();
QObject *map = item->findChild<QObject*>("map"); QObject *map = item->findChild<QObject*>("map");
if (map != nullptr) if (map != nullptr)
{ {
QObject *stationObject = map->findChild<QObject*>("station"); QObject *stationObject = map->findChild<QObject*>("station");
if(stationObject != NULL) { if(stationObject != NULL) {
stationObject->setProperty("stationName", QVariant::fromValue(MainCore::instance()->getSettings().getStationName())); stationObject->setProperty("stationName", QVariant::fromValue(MainCore::instance()->getSettings().getStationName()));
} }
@ -1189,9 +1228,11 @@ void VORLocalizerGUI::redrawMap()
// An awful workaround for https://bugreports.qt.io/browse/QTBUG-100333 // An awful workaround for https://bugreports.qt.io/browse/QTBUG-100333
// Also used in ADS-B demod // Also used in ADS-B demod
QQuickItem *item = ui->map->rootObject(); QQuickItem *item = ui->map->rootObject();
if (item) if (item)
{ {
QObject *object = item->findChild<QObject*>("map"); QObject *object = item->findChild<QObject*>("map");
if (object) if (object)
{ {
double zoom = object->property("zoomLevel").value<double>(); double zoom = object->property("zoomLevel").value<double>();
@ -1222,11 +1263,13 @@ bool VORLocalizerGUI::eventFilter(QObject *obj, QEvent *event)
QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event); QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);
QSize oldSize = resizeEvent->oldSize(); QSize oldSize = resizeEvent->oldSize();
QSize size = resizeEvent->size(); QSize size = resizeEvent->size();
if (oldSize.height() != size.height()) { if (oldSize.height() != size.height()) {
redrawMap(); redrawMap();
} }
} }
} }
return false; return false;
} }

View File

@ -226,6 +226,7 @@ private:
PluginAPI* m_pluginAPI; PluginAPI* m_pluginAPI;
FeatureUISet* m_featureUISet; FeatureUISet* m_featureUISet;
VORLocalizerSettings m_settings; VORLocalizerSettings m_settings;
QList<QString> m_settingsKeys;
RollupState m_rollupState; RollupState m_rollupState;
bool m_doApplySettings; bool m_doApplySettings;

View File

@ -168,3 +168,119 @@ bool VORLocalizerSettings::VORChannel::operator<(const VORChannel& other) const
return false; return false;
} }
void VORLocalizerSettings::applySettings(const QStringList& settingsKeys, const VORLocalizerSettings& settings)
{
if (settingsKeys.contains("rgbColor")) {
m_rgbColor = settings.m_rgbColor;
}
if (settingsKeys.contains("title")) {
m_title = settings.m_title;
}
if (settingsKeys.contains("magDecAdjust")) {
m_magDecAdjust = settings.m_magDecAdjust;
}
if (settingsKeys.contains("rrTime")) {
m_rrTime = settings.m_rrTime;
}
if (settingsKeys.contains("centerShift")) {
m_centerShift = settings.m_centerShift;
}
if (settingsKeys.contains("useReverseAPI")) {
m_useReverseAPI = settings.m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress")) {
m_reverseAPIAddress = settings.m_reverseAPIAddress;
}
if (settingsKeys.contains("reverseAPIPort")) {
m_reverseAPIPort = settings.m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIFeatureSetIndex")) {
m_reverseAPIFeatureSetIndex = settings.m_reverseAPIFeatureSetIndex;
}
if (settingsKeys.contains("reverseAPIFeatureIndex")) {
m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex;
}
if (settingsKeys.contains("workspaceIndex")) {
m_workspaceIndex = settings.m_workspaceIndex;
}
if (settingsKeys.contains("mapProvider")) {
m_mapProvider = settings.m_mapProvider;
}
if (settingsKeys.contains("columnIndexes"))
{
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
m_columnIndexes[i] = settings.m_columnIndexes[i];
}
}
if (settingsKeys.contains("columnSizes"))
{
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
m_columnSizes[i] = settings.m_columnSizes[i];
}
}
}
QString VORLocalizerSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("rgbColor") || force) {
ostr << " m_rgbColor: " << m_rgbColor;
}
if (settingsKeys.contains("title") || force) {
ostr << " m_title: " << m_title.toStdString();
}
if (settingsKeys.contains("magDecAdjust") || force) {
ostr << " m_magDecAdjust: " << m_magDecAdjust;
}
if (settingsKeys.contains("rrTime") || force) {
ostr << " m_rrTime: " << m_rrTime;
}
if (settingsKeys.contains("centerShift") || force) {
ostr << " m_centerShift: " << m_centerShift;
}
if (settingsKeys.contains("useReverseAPI") || force) {
ostr << " m_useReverseAPI: " << m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress") || force) {
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
}
if (settingsKeys.contains("reverseAPIPort") || force) {
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIFeatureSetIndex") || force) {
ostr << " m_reverseAPIFeatureSetIndex: " << m_reverseAPIFeatureSetIndex;
}
if (settingsKeys.contains("reverseAPIFeatureIndex") || force) {
ostr << " m_reverseAPIFeatureIndex: " << m_reverseAPIFeatureIndex;
}
if (settingsKeys.contains("workspaceIndex") || force) {
ostr << " m_workspaceIndex: " << m_workspaceIndex;
}
if (settingsKeys.contains("mapProvider") || force) {
ostr << " m_mapProvider: " << m_mapProvider.toStdString();
}
if (settingsKeys.contains("columnIndexes"))
{
ostr << "m_columnIndexes:";
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
ostr << " " << m_columnIndexes[i];
}
}
if (settingsKeys.contains("columnSizes"))
{
ostr << "m_columnSizes:";
for (int i = 0; i < VORDEMOD_COLUMNS; i++) {
ostr << " " << m_columnSizes[i];
}
}
return QString(ostr.str().c_str());
}

View File

@ -100,6 +100,8 @@ struct VORLocalizerSettings
QByteArray serialize() const; QByteArray serialize() const;
bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data);
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; } void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
void applySettings(const QStringList& settingsKeys, const VORLocalizerSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
}; };
#endif /* INCLUDE_VORLOCALIZERSETTINGS_H */ #endif /* INCLUDE_VORLOCALIZERSETTINGS_H */

View File

@ -112,7 +112,7 @@ bool VorLocalizerWorker::handleMessage(const Message& cmd)
MsgConfigureVORLocalizerWorker& cfg = (MsgConfigureVORLocalizerWorker&) cmd; MsgConfigureVORLocalizerWorker& cfg = (MsgConfigureVORLocalizerWorker&) cmd;
qDebug() << "VorLocalizerWorker::handleMessage: MsgConfigureVORLocalizerWorker"; qDebug() << "VorLocalizerWorker::handleMessage: MsgConfigureVORLocalizerWorker";
applySettings(cfg.getSettings(), cfg.getForce()); applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
return true; return true;
} }
@ -129,12 +129,9 @@ bool VorLocalizerWorker::handleMessage(const Message& cmd)
} }
} }
void VorLocalizerWorker::applySettings(const VORLocalizerSettings& settings, bool force) void VorLocalizerWorker::applySettings(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force)
{ {
qDebug() << "VorLocalizerWorker::applySettings:" qDebug() << "VorLocalizerWorker::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
<< " m_title: " << settings.m_title
<< " m_rgbColor: " << settings.m_rgbColor
<< " force: " << force;
// Remove sub-channels no longer needed // Remove sub-channels no longer needed
for (int i = 0; i < m_vorChannels.size(); i++) for (int i = 0; i < m_vorChannels.size(); i++)
@ -190,11 +187,15 @@ void VorLocalizerWorker::applySettings(const VORLocalizerSettings& settings, boo
} }
} }
if ((settings.m_rrTime != m_settings.m_rrTime) || force) { if (settingsKeys.contains("rrTime") || force) {
m_rrTimer.start(settings.m_rrTime * 1000); m_rrTimer.start(settings.m_rrTime * 1000);
} }
m_settings = settings; if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
} }
void VorLocalizerWorker::updateHardware() void VorLocalizerWorker::updateHardware()

View File

@ -39,20 +39,23 @@ public:
public: public:
const VORLocalizerSettings& getSettings() const { return m_settings; } const VORLocalizerSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; } bool getForce() const { return m_force; }
static MsgConfigureVORLocalizerWorker* create(const VORLocalizerSettings& settings, bool force) static MsgConfigureVORLocalizerWorker* create(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force)
{ {
return new MsgConfigureVORLocalizerWorker(settings, force); return new MsgConfigureVORLocalizerWorker(settings, settingsKeys, force);
} }
private: private:
VORLocalizerSettings m_settings; VORLocalizerSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force; bool m_force;
MsgConfigureVORLocalizerWorker(const VORLocalizerSettings& settings, bool force) : MsgConfigureVORLocalizerWorker(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(), Message(),
m_settings(settings), m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force) m_force(force)
{ } { }
}; };
@ -152,7 +155,7 @@ private:
std::vector<int> m_rrTurnCounters; //!< Round robin turn count for each device std::vector<int> m_rrTurnCounters; //!< Round robin turn count for each device
bool handleMessage(const Message& cmd); bool handleMessage(const Message& cmd);
void applySettings(const VORLocalizerSettings& settings, bool force = false); void applySettings(const VORLocalizerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
void removeVORChannel(int navId); void removeVORChannel(int navId);
void addVORChannel(const VORLocalizerSubChannelSettings& subChannelSettings); void addVORChannel(const VORLocalizerSubChannelSettings& subChannelSettings);
void updateChannels(); //!< (re)allocate channels to service VORs void updateChannels(); //!< (re)allocate channels to service VORs

View File

@ -14691,6 +14691,18 @@ margin-bottom: 20px;
}, },
"rollupState" : { "rollupState" : {
"$ref" : "#/definitions/RollupState" "$ref" : "#/definitions/RollupState"
},
"columnIndexes" : {
"type" : "array",
"items" : {
"type" : "integer"
}
},
"columnSizes" : {
"type" : "array",
"items" : {
"type" : "integer"
}
} }
}, },
"description" : "VORLocalizer" "description" : "VORLocalizer"
@ -56725,7 +56737,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2022-11-27T10:57:52.904+01:00 Generated 2022-11-30T21:42:22.227+01:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -33,6 +33,14 @@ VORLocalizerSettings:
type: integer type: integer
rollupState: rollupState:
$ref: "/doc/swagger/include/RollupState.yaml#/RollupState" $ref: "/doc/swagger/include/RollupState.yaml#/RollupState"
columnIndexes:
type: array
items:
type: integer
columnSizes:
type: array
items:
type: integer
VORLocalizerReport: VORLocalizerReport:
description: VORLocalizers description: VORLocalizers

View File

@ -33,6 +33,14 @@ VORLocalizerSettings:
type: integer type: integer
rollupState: rollupState:
$ref: "http://swgserver:8081/api/swagger/include/RollupState.yaml#/RollupState" $ref: "http://swgserver:8081/api/swagger/include/RollupState.yaml#/RollupState"
columnIndexes:
type: array
items:
type: integer
columnSizes:
type: array
items:
type: integer
VORLocalizerReport: VORLocalizerReport:
description: VORLocalizers description: VORLocalizers

View File

@ -14691,6 +14691,18 @@ margin-bottom: 20px;
}, },
"rollupState" : { "rollupState" : {
"$ref" : "#/definitions/RollupState" "$ref" : "#/definitions/RollupState"
},
"columnIndexes" : {
"type" : "array",
"items" : {
"type" : "integer"
}
},
"columnSizes" : {
"type" : "array",
"items" : {
"type" : "integer"
}
} }
}, },
"description" : "VORLocalizer" "description" : "VORLocalizer"
@ -56725,7 +56737,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2022-11-27T10:57:52.904+01:00 Generated 2022-11-30T21:42:22.227+01:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -52,6 +52,10 @@ SWGVORLocalizerSettings::SWGVORLocalizerSettings() {
m_center_shift_isSet = false; m_center_shift_isSet = false;
rollup_state = nullptr; rollup_state = nullptr;
m_rollup_state_isSet = false; m_rollup_state_isSet = false;
column_indexes = new QList<qint32>();
m_column_indexes_isSet = false;
column_sizes = new QList<qint32>();
m_column_sizes_isSet = false;
} }
SWGVORLocalizerSettings::~SWGVORLocalizerSettings() { SWGVORLocalizerSettings::~SWGVORLocalizerSettings() {
@ -84,6 +88,10 @@ SWGVORLocalizerSettings::init() {
m_center_shift_isSet = false; m_center_shift_isSet = false;
rollup_state = new SWGRollupState(); rollup_state = new SWGRollupState();
m_rollup_state_isSet = false; m_rollup_state_isSet = false;
column_indexes = new QList<qint32>();
m_column_indexes_isSet = false;
column_sizes = new QList<qint32>();
m_column_sizes_isSet = false;
} }
void void
@ -106,6 +114,8 @@ SWGVORLocalizerSettings::cleanup() {
if(rollup_state != nullptr) { if(rollup_state != nullptr) {
delete rollup_state; delete rollup_state;
} }
} }
SWGVORLocalizerSettings* SWGVORLocalizerSettings*
@ -143,6 +153,10 @@ SWGVORLocalizerSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&rollup_state, pJson["rollupState"], "SWGRollupState", "SWGRollupState"); ::SWGSDRangel::setValue(&rollup_state, pJson["rollupState"], "SWGRollupState", "SWGRollupState");
::SWGSDRangel::setValue(&column_indexes, pJson["columnIndexes"], "QList", "qint32");
::SWGSDRangel::setValue(&column_sizes, pJson["columnSizes"], "QList", "qint32");
} }
QString QString
@ -195,6 +209,12 @@ SWGVORLocalizerSettings::asJsonObject() {
if((rollup_state != nullptr) && (rollup_state->isSet())){ if((rollup_state != nullptr) && (rollup_state->isSet())){
toJsonValue(QString("rollupState"), rollup_state, obj, QString("SWGRollupState")); toJsonValue(QString("rollupState"), rollup_state, obj, QString("SWGRollupState"));
} }
if(column_indexes && column_indexes->size() > 0){
toJsonArray((QList<void*>*)column_indexes, obj, "columnIndexes", "");
}
if(column_sizes && column_sizes->size() > 0){
toJsonArray((QList<void*>*)column_sizes, obj, "columnSizes", "");
}
return obj; return obj;
} }
@ -319,6 +339,26 @@ SWGVORLocalizerSettings::setRollupState(SWGRollupState* rollup_state) {
this->m_rollup_state_isSet = true; this->m_rollup_state_isSet = true;
} }
QList<qint32>*
SWGVORLocalizerSettings::getColumnIndexes() {
return column_indexes;
}
void
SWGVORLocalizerSettings::setColumnIndexes(QList<qint32>* column_indexes) {
this->column_indexes = column_indexes;
this->m_column_indexes_isSet = true;
}
QList<qint32>*
SWGVORLocalizerSettings::getColumnSizes() {
return column_sizes;
}
void
SWGVORLocalizerSettings::setColumnSizes(QList<qint32>* column_sizes) {
this->column_sizes = column_sizes;
this->m_column_sizes_isSet = true;
}
bool bool
SWGVORLocalizerSettings::isSet(){ SWGVORLocalizerSettings::isSet(){
@ -360,6 +400,18 @@ SWGVORLocalizerSettings::isSet(){
if(rollup_state && rollup_state->isSet()){ if(rollup_state && rollup_state->isSet()){
isObjectUpdated = true; break; isObjectUpdated = true; break;
} }
if(m_column_indexes_isSet){
isObjectUpdated = true; break;
}
if(column_indexes && (column_indexes->size() > 0)){
isObjectUpdated = true; break;
}
if(m_column_sizes_isSet){
isObjectUpdated = true; break;
}
if(column_sizes && (column_sizes->size() > 0)){
isObjectUpdated = true; break;
}
}while(false); }while(false);
return isObjectUpdated; return isObjectUpdated;
} }

View File

@ -23,6 +23,7 @@
#include "SWGRollupState.h" #include "SWGRollupState.h"
#include <QList>
#include <QString> #include <QString>
#include "SWGObject.h" #include "SWGObject.h"
@ -79,6 +80,12 @@ public:
SWGRollupState* getRollupState(); SWGRollupState* getRollupState();
void setRollupState(SWGRollupState* rollup_state); void setRollupState(SWGRollupState* rollup_state);
QList<qint32>* getColumnIndexes();
void setColumnIndexes(QList<qint32>* column_indexes);
QList<qint32>* getColumnSizes();
void setColumnSizes(QList<qint32>* column_sizes);
virtual bool isSet() override; virtual bool isSet() override;
@ -119,6 +126,12 @@ private:
SWGRollupState* rollup_state; SWGRollupState* rollup_state;
bool m_rollup_state_isSet; bool m_rollup_state_isSet;
QList<qint32>* column_indexes;
bool m_column_indexes_isSet;
QList<qint32>* column_sizes;
bool m_column_sizes_isSet;
}; };
} }