2020-10-27 16:22:10 +00:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
|
|
|
|
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
|
|
|
|
// //
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
|
// (at your option) any later version. //
|
|
|
|
|
// //
|
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
|
// //
|
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2020-10-27 17:03:54 +00:00
|
|
|
|
#include <cmath>
|
2020-10-27 16:22:10 +00:00
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QSerialPortInfo>
|
|
|
|
|
|
2021-01-13 19:44:53 +00:00
|
|
|
|
#include "SWGTargetAzimuthElevation.h"
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
#include "feature/featureuiset.h"
|
|
|
|
|
#include "gui/basicfeaturesettingsdialog.h"
|
2022-12-20 10:31:15 +00:00
|
|
|
|
#include "gui/dialogpositioner.h"
|
2020-10-27 16:22:10 +00:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "device/deviceuiset.h"
|
2023-04-03 15:47:13 +00:00
|
|
|
|
#include "util/astronomy.h"
|
2020-10-27 16:22:10 +00:00
|
|
|
|
|
|
|
|
|
#include "ui_gs232controllergui.h"
|
|
|
|
|
#include "gs232controller.h"
|
|
|
|
|
#include "gs232controllergui.h"
|
|
|
|
|
#include "gs232controllerreport.h"
|
2023-04-03 15:47:13 +00:00
|
|
|
|
#include "dfmprotocol.h"
|
2020-10-27 16:22:10 +00:00
|
|
|
|
|
|
|
|
|
GS232ControllerGUI* GS232ControllerGUI::create(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature)
|
|
|
|
|
{
|
|
|
|
|
GS232ControllerGUI* gui = new GS232ControllerGUI(pluginAPI, featureUISet, feature);
|
|
|
|
|
return gui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::destroy()
|
|
|
|
|
{
|
|
|
|
|
delete this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::resetToDefaults()
|
|
|
|
|
{
|
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
|
displaySettings();
|
|
|
|
|
applySettings(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray GS232ControllerGUI::serialize() const
|
|
|
|
|
{
|
|
|
|
|
return m_settings.serialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GS232ControllerGUI::deserialize(const QByteArray& data)
|
|
|
|
|
{
|
|
|
|
|
if (m_settings.deserialize(data))
|
|
|
|
|
{
|
2022-05-13 20:24:48 +00:00
|
|
|
|
m_feature->setWorkspaceIndex(m_settings.m_workspaceIndex);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
displaySettings();
|
|
|
|
|
applySettings(true);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
resetToDefaults();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 15:47:13 +00:00
|
|
|
|
void GS232ControllerGUI::azElToDisplay(float az, float el, float& coord1, float& coord2) const
|
|
|
|
|
{
|
|
|
|
|
AzAlt aa;
|
|
|
|
|
double c1, c2;
|
|
|
|
|
if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_85)
|
|
|
|
|
{
|
|
|
|
|
aa.az = az;
|
|
|
|
|
aa.alt = el;
|
|
|
|
|
Astronomy::azAltToXY85(aa, c1, c2);
|
|
|
|
|
coord1 = (float)c1;
|
|
|
|
|
coord2 = (float)c2;
|
|
|
|
|
}
|
|
|
|
|
else if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_30)
|
|
|
|
|
{
|
|
|
|
|
aa.az = az;
|
|
|
|
|
aa.alt = el;
|
|
|
|
|
Astronomy::azAltToXY30(aa, c1, c2);
|
|
|
|
|
coord1 = (float)c1;
|
|
|
|
|
coord2 = (float)c2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
coord1 = az;
|
|
|
|
|
coord2 = el;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::displayToAzEl(float coord1, float coord2)
|
|
|
|
|
{
|
|
|
|
|
if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_85)
|
|
|
|
|
{
|
|
|
|
|
AzAlt aa = Astronomy::xy85ToAzAlt(coord1, coord2);
|
|
|
|
|
m_settings.m_azimuth = aa.az;
|
|
|
|
|
m_settings.m_elevation = aa.alt;
|
|
|
|
|
}
|
|
|
|
|
else if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_30)
|
|
|
|
|
{
|
|
|
|
|
AzAlt aa = Astronomy::xy30ToAzAlt(coord1, coord2);
|
|
|
|
|
m_settings.m_azimuth = aa.az;
|
|
|
|
|
m_settings.m_elevation = aa.alt;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_settings.m_azimuth = coord1;
|
|
|
|
|
m_settings.m_elevation = coord2;
|
|
|
|
|
}
|
|
|
|
|
m_settingsKeys.append("azimuth");
|
|
|
|
|
m_settingsKeys.append("elevation");
|
|
|
|
|
applySettings();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
bool GS232ControllerGUI::handleMessage(const Message& message)
|
|
|
|
|
{
|
|
|
|
|
if (GS232Controller::MsgConfigureGS232Controller::match(message))
|
|
|
|
|
{
|
|
|
|
|
qDebug("GS232ControllerGUI::handleMessage: GS232Controller::MsgConfigureGS232Controller");
|
|
|
|
|
const GS232Controller::MsgConfigureGS232Controller& cfg = (GS232Controller::MsgConfigureGS232Controller&) message;
|
2022-11-24 15:40:36 +00:00
|
|
|
|
|
|
|
|
|
if (cfg.getForce()) {
|
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
|
} else {
|
|
|
|
|
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
displaySettings();
|
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-03-28 18:12:25 +00:00
|
|
|
|
else if (GS232Controller::MsgReportAvailableChannelOrFeatures::match(message))
|
2020-10-27 16:22:10 +00:00
|
|
|
|
{
|
2022-03-28 18:12:25 +00:00
|
|
|
|
GS232Controller::MsgReportAvailableChannelOrFeatures& report =
|
|
|
|
|
(GS232Controller::MsgReportAvailableChannelOrFeatures&) message;
|
|
|
|
|
updatePipeList(report.getItems());
|
2020-10-27 16:22:10 +00:00
|
|
|
|
return true;
|
2021-01-13 19:44:53 +00:00
|
|
|
|
}
|
|
|
|
|
else if (GS232ControllerReport::MsgReportAzAl::match(message))
|
2020-10-27 16:22:10 +00:00
|
|
|
|
{
|
|
|
|
|
GS232ControllerReport::MsgReportAzAl& azAl = (GS232ControllerReport::MsgReportAzAl&) message;
|
2023-04-03 15:47:13 +00:00
|
|
|
|
float coord1, coord2;
|
|
|
|
|
azElToDisplay(azAl.getAzimuth(), azAl.getElevation(), coord1, coord2);
|
|
|
|
|
ui->coord1CurrentText->setText(QString::number(coord1, 'f', m_settings.m_precision));
|
|
|
|
|
ui->coord2CurrentText->setText(QString::number(coord2, 'f', m_settings.m_precision));
|
2021-01-13 19:44:53 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (MainCore::MsgTargetAzimuthElevation::match(message))
|
|
|
|
|
{
|
|
|
|
|
MainCore::MsgTargetAzimuthElevation& msg = (MainCore::MsgTargetAzimuthElevation&) message;
|
|
|
|
|
SWGSDRangel::SWGTargetAzimuthElevation *swgTarget = msg.getSWGTargetAzimuthElevation();
|
2023-04-03 15:47:13 +00:00
|
|
|
|
float coord1, coord2;
|
|
|
|
|
azElToDisplay(swgTarget->getAzimuth(), swgTarget->getElevation(), coord1, coord2);
|
|
|
|
|
ui->coord1->setValue(coord1);
|
|
|
|
|
ui->coord2->setValue(coord2);
|
2021-01-13 19:44:53 +00:00
|
|
|
|
ui->targetName->setText(*swgTarget->getName());
|
2020-10-27 16:22:10 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-04-03 15:47:13 +00:00
|
|
|
|
else if (GS232Controller::MsgReportSerialPorts::match(message))
|
|
|
|
|
{
|
|
|
|
|
GS232Controller::MsgReportSerialPorts& msg = (GS232Controller::MsgReportSerialPorts&) message;
|
|
|
|
|
updateSerialPortList(msg.getSerialPorts());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (DFMProtocol::MsgReportDFMStatus::match(message))
|
|
|
|
|
{
|
|
|
|
|
DFMProtocol::MsgReportDFMStatus& report = (DFMProtocol::MsgReportDFMStatus&) message;
|
|
|
|
|
m_dfmStatusDialog.displayStatus(report.getDFMStatus());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-10-27 16:22:10 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::handleInputMessages()
|
|
|
|
|
{
|
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()))
|
|
|
|
|
{
|
|
|
|
|
if (handleMessage(*message)) {
|
|
|
|
|
delete message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
|
{
|
|
|
|
|
(void) widget;
|
|
|
|
|
(void) rollDown;
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 12:24:27 +00:00
|
|
|
|
|
2022-04-04 08:23:52 +00:00
|
|
|
|
getRollupContents()->saveState(m_rollupState);
|
2021-11-23 12:13:24 +00:00
|
|
|
|
applySettings();
|
2020-10-27 16:22:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent) :
|
|
|
|
|
FeatureGUI(parent),
|
|
|
|
|
ui(new Ui::GS232ControllerGUI),
|
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
|
m_featureUISet(featureUISet),
|
|
|
|
|
m_doApplySettings(true),
|
2021-10-05 13:03:31 +00:00
|
|
|
|
m_lastFeatureState(0),
|
2023-04-03 15:47:13 +00:00
|
|
|
|
m_lastOnTarget(false),
|
|
|
|
|
m_dfmStatusDialog()
|
2020-10-27 16:22:10 +00:00
|
|
|
|
{
|
2022-05-13 20:24:48 +00:00
|
|
|
|
m_feature = feature;
|
2020-10-27 16:22:10 +00:00
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2022-04-24 17:34:48 +00:00
|
|
|
|
m_helpURL = "plugins/feature/gs232controller/readme.md";
|
|
|
|
|
RollupContents *rollupContents = getRollupContents();
|
|
|
|
|
ui->setupUi(rollupContents);
|
|
|
|
|
rollupContents->arrangeRollups();
|
|
|
|
|
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
m_gs232Controller = reinterpret_cast<GS232Controller*>(feature);
|
|
|
|
|
m_gs232Controller->setMessageQueueToGUI(&m_inputMessageQueue);
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
|
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
|
|
|
|
|
|
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
2021-10-05 13:03:31 +00:00
|
|
|
|
m_statusTimer.start(250);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
|
2023-04-03 15:47:13 +00:00
|
|
|
|
ui->coord1CurrentText->setText("-");
|
|
|
|
|
ui->coord2CurrentText->setText("-");
|
|
|
|
|
setProtocol(m_settings.m_protocol); // Hide DFM buttons
|
2021-05-30 11:38:07 +00:00
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
updateSerialPortList();
|
2022-11-18 10:55:15 +00:00
|
|
|
|
if (ui->serialPort->currentIndex() >= 0) {
|
|
|
|
|
on_serialPort_currentIndexChanged(ui->serialPort->currentIndex());
|
|
|
|
|
}
|
2022-01-09 04:27:12 +00:00
|
|
|
|
|
|
|
|
|
m_settings.setRollupState(&m_rollupState);
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
displaySettings();
|
|
|
|
|
applySettings(true);
|
2022-04-04 08:23:52 +00:00
|
|
|
|
makeUIConnections();
|
2022-10-27 18:15:46 +00:00
|
|
|
|
|
|
|
|
|
// Get pre-existing pipes
|
|
|
|
|
m_gs232Controller->getInputMessageQueue()->push(GS232Controller::MsgScanAvailableChannelOrFeatures::create());
|
2023-04-03 15:47:13 +00:00
|
|
|
|
|
|
|
|
|
new DialogPositioner(&m_dfmStatusDialog, true);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GS232ControllerGUI::~GS232ControllerGUI()
|
|
|
|
|
{
|
2023-04-03 15:47:13 +00:00
|
|
|
|
m_dfmStatusDialog.close();
|
2020-10-27 16:22:10 +00:00
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-13 20:24:48 +00:00
|
|
|
|
void GS232ControllerGUI::setWorkspaceIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
m_settings.m_workspaceIndex = index;
|
|
|
|
|
m_feature->setWorkspaceIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
void GS232ControllerGUI::blockApplySettings(bool block)
|
|
|
|
|
{
|
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::displaySettings()
|
|
|
|
|
{
|
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
|
setWindowTitle(m_settings.m_title);
|
2022-04-04 08:23:52 +00:00
|
|
|
|
setTitle(m_settings.m_title);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
blockApplySettings(true);
|
2023-04-03 15:47:13 +00:00
|
|
|
|
ui->precision->setValue(m_settings.m_precision); // Must set before protocol and az/el
|
2021-05-30 11:38:07 +00:00
|
|
|
|
ui->protocol->setCurrentIndex((int)m_settings.m_protocol);
|
2023-04-03 15:47:13 +00:00
|
|
|
|
ui->coordinates->setCurrentIndex((int)m_settings.m_coordinates);
|
|
|
|
|
float coord1, coord2;
|
|
|
|
|
azElToDisplay(m_settings.m_azimuth, m_settings.m_elevation, coord1, coord2);
|
|
|
|
|
ui->coord1->setValue(coord1);
|
|
|
|
|
ui->coord2->setValue(coord2);
|
2021-11-23 12:13:24 +00:00
|
|
|
|
ui->connection->setCurrentIndex((int)m_settings.m_connection);
|
|
|
|
|
if (m_settings.m_serialPort.length() > 0) {
|
2020-10-27 16:22:10 +00:00
|
|
|
|
ui->serialPort->lineEdit()->setText(m_settings.m_serialPort);
|
2021-11-23 12:13:24 +00:00
|
|
|
|
}
|
2020-10-27 16:22:10 +00:00
|
|
|
|
ui->baudRate->setCurrentText(QString("%1").arg(m_settings.m_baudRate));
|
2021-11-23 12:13:24 +00:00
|
|
|
|
ui->host->setText(m_settings.m_host);
|
|
|
|
|
ui->port->setValue(m_settings.m_port);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
ui->track->setChecked(m_settings.m_track);
|
2021-10-03 21:15:15 +00:00
|
|
|
|
ui->sources->setCurrentIndex(ui->sources->findText(m_settings.m_source));
|
2021-01-13 19:44:53 +00:00
|
|
|
|
ui->azimuthOffset->setValue(m_settings.m_azimuthOffset);
|
|
|
|
|
ui->elevationOffset->setValue(m_settings.m_elevationOffset);
|
2021-02-26 20:27:35 +00:00
|
|
|
|
ui->azimuthMin->setValue(m_settings.m_azimuthMin);
|
|
|
|
|
ui->azimuthMax->setValue(m_settings.m_azimuthMax);
|
|
|
|
|
ui->elevationMin->setValue(m_settings.m_elevationMin);
|
|
|
|
|
ui->elevationMax->setValue(m_settings.m_elevationMax);
|
2021-10-05 13:03:31 +00:00
|
|
|
|
ui->tolerance->setValue(m_settings.m_tolerance);
|
2023-04-03 15:47:13 +00:00
|
|
|
|
ui->dfmTrack->setChecked(m_settings.m_dfmTrackOn);
|
|
|
|
|
ui->dfmLubePumps->setChecked(m_settings.m_dfmLubePumpsOn);
|
|
|
|
|
ui->dfmBrakes->setChecked(m_settings.m_dfmBrakesOn);
|
|
|
|
|
ui->dfmDrives->setChecked(m_settings.m_dfmDrivesOn);
|
2022-04-04 08:23:52 +00:00
|
|
|
|
getRollupContents()->restoreState(m_rollupState);
|
2021-11-23 12:13:24 +00:00
|
|
|
|
updateConnectionWidgets();
|
2020-10-27 16:22:10 +00:00
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 12:13:24 +00:00
|
|
|
|
void GS232ControllerGUI::updateConnectionWidgets()
|
|
|
|
|
{
|
|
|
|
|
bool serial = m_settings.m_connection == GS232ControllerSettings::SERIAL;
|
|
|
|
|
ui->serialPortLabel->setVisible(serial);
|
|
|
|
|
ui->serialPort->setVisible(serial);
|
|
|
|
|
ui->baudRateLabel->setVisible(serial);
|
|
|
|
|
ui->baudRate->setVisible(serial);
|
|
|
|
|
ui->hostLabel->setVisible(!serial);
|
|
|
|
|
ui->host->setVisible(!serial);
|
|
|
|
|
ui->portLabel->setVisible(!serial);
|
|
|
|
|
ui->port->setVisible(!serial);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
void GS232ControllerGUI::updateSerialPortList()
|
|
|
|
|
{
|
|
|
|
|
ui->serialPort->clear();
|
|
|
|
|
QList<QSerialPortInfo> serialPorts = QSerialPortInfo::availablePorts();
|
|
|
|
|
QListIterator<QSerialPortInfo> i(serialPorts);
|
|
|
|
|
while (i.hasNext())
|
|
|
|
|
{
|
|
|
|
|
QSerialPortInfo info = i.next();
|
|
|
|
|
ui->serialPort->addItem(info.portName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 15:47:13 +00:00
|
|
|
|
void GS232ControllerGUI::updateSerialPortList(const QStringList& serialPorts)
|
|
|
|
|
{
|
|
|
|
|
ui->serialPort->blockSignals(true);
|
|
|
|
|
ui->serialPort->clear();
|
|
|
|
|
for (const auto& serialPort : serialPorts) {
|
|
|
|
|
ui->serialPort->addItem(serialPort);
|
|
|
|
|
}
|
|
|
|
|
if (!m_settings.m_serialPort.isEmpty()) {
|
|
|
|
|
ui->serialPort->setCurrentText(m_settings.m_serialPort);
|
|
|
|
|
}
|
|
|
|
|
ui->serialPort->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 18:12:25 +00:00
|
|
|
|
void GS232ControllerGUI::updatePipeList(const QList<GS232ControllerSettings::AvailableChannelOrFeature>& sources)
|
2020-10-27 16:22:10 +00:00
|
|
|
|
{
|
2021-10-03 21:15:15 +00:00
|
|
|
|
QString currentText = ui->sources->currentText();
|
2022-03-28 18:12:25 +00:00
|
|
|
|
QString newText;
|
2021-10-03 21:15:15 +00:00
|
|
|
|
ui->sources->blockSignals(true);
|
|
|
|
|
ui->sources->clear();
|
2020-10-27 16:22:10 +00:00
|
|
|
|
|
2022-03-28 18:12:25 +00:00
|
|
|
|
for (const auto& source : sources)
|
2020-10-27 16:22:10 +00:00
|
|
|
|
{
|
2022-03-28 18:12:25 +00:00
|
|
|
|
QString name = tr("%1%2:%3 %4")
|
|
|
|
|
.arg(source.m_kind)
|
|
|
|
|
.arg(source.m_superIndex)
|
|
|
|
|
.arg(source.m_index)
|
|
|
|
|
.arg(source.m_type);
|
|
|
|
|
ui->sources->addItem(name);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 18:12:25 +00:00
|
|
|
|
int index = ui->sources->findText(m_settings.m_source);
|
|
|
|
|
ui->sources->setCurrentIndex(index);
|
|
|
|
|
|
|
|
|
|
if (index < 0) // current source is not found
|
2021-10-03 21:15:15 +00:00
|
|
|
|
{
|
2022-03-28 18:12:25 +00:00
|
|
|
|
m_settings.m_source = "";
|
|
|
|
|
ui->targetName->setText("");
|
2022-11-24 15:40:36 +00:00
|
|
|
|
m_settingsKeys.append("source");
|
2022-03-28 18:12:25 +00:00
|
|
|
|
applySettings();
|
2021-10-03 21:15:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 18:12:25 +00:00
|
|
|
|
// if (currentText.isEmpty())
|
|
|
|
|
// {
|
|
|
|
|
// // Source feature may be loaded after this, so may not have existed when
|
|
|
|
|
// // displaySettings was called
|
|
|
|
|
// if (sources.size() > 0) {
|
|
|
|
|
// ui->sources->setCurrentIndex(ui->sources->findText(m_settings.m_source));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// ui->sources->setCurrentIndex(ui->sources->findText(currentText));
|
|
|
|
|
// }
|
|
|
|
|
|
2021-10-03 21:15:15 +00:00
|
|
|
|
ui->sources->blockSignals(false);
|
|
|
|
|
|
2022-03-28 18:12:25 +00:00
|
|
|
|
// QString newText = ui->sources->currentText();
|
2020-10-27 16:22:10 +00:00
|
|
|
|
|
2022-03-28 18:12:25 +00:00
|
|
|
|
// if (currentText != newText)
|
|
|
|
|
// {
|
|
|
|
|
// m_settings.m_source = newText;
|
|
|
|
|
// ui->targetName->setText("");
|
|
|
|
|
// applySettings();
|
|
|
|
|
// }
|
2020-10-27 16:22:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::onMenuDialogCalled(const QPoint &p)
|
|
|
|
|
{
|
|
|
|
|
if (m_contextMenuType == ContextMenuChannelSettings)
|
|
|
|
|
{
|
|
|
|
|
BasicFeatureSettingsDialog dialog(this);
|
|
|
|
|
dialog.setTitle(m_settings.m_title);
|
|
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
|
|
|
|
dialog.setReverseAPIFeatureSetIndex(m_settings.m_reverseAPIFeatureSetIndex);
|
|
|
|
|
dialog.setReverseAPIFeatureIndex(m_settings.m_reverseAPIFeatureIndex);
|
2022-04-18 10:08:33 +00:00
|
|
|
|
dialog.setDefaultTitle(m_displayedName);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
|
|
|
|
|
dialog.move(p);
|
2022-12-20 10:31:15 +00:00
|
|
|
|
new DialogPositioner(&dialog, false);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
|
|
m_settings.m_title = dialog.getTitle();
|
|
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
|
|
|
|
m_settings.m_reverseAPIFeatureSetIndex = dialog.getReverseAPIFeatureSetIndex();
|
|
|
|
|
m_settings.m_reverseAPIFeatureIndex = dialog.getReverseAPIFeatureIndex();
|
|
|
|
|
|
2022-04-18 10:08:33 +00:00
|
|
|
|
setTitle(m_settings.m_title);
|
2020-10-27 16:22:10 +00:00
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
|
|
2022-11-24 15:40:36 +00:00
|
|
|
|
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");
|
|
|
|
|
|
2020-10-27 16:22:10 +00:00
|
|
|
|
applySettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetContextMenuType();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GS232ControllerGUI::on_startStop_toggled(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (m_doApplySettings)
|
|
|
|
|
{
|
|
|
|
|
GS232Controller::MsgStartStop *message = GS232Controller::MsgStartStop::create(checked);
|
|
|
|
|
m_gs232Controller->getInputMessageQueue()->push(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 15:47:13 +00:00
|
|
|
|
void GS232ControllerGUI::setProtocol(GS232ControllerSettings::Protocol protocol)
|
2021-05-30 11:38:07 +00:00
|
|
|
|
{
|
|
|
|
|
if (protocol == GS232ControllerSettings::GS232)
|
|
|
|
|
{
|
2023-04-03 15:47:13 +00:00
|
|
|
|
ui->precision->setValue(0);
|
|
|
|
|
ui->precision->setEnabled(false);
|
|
|
|
|
ui->precisionLabel->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
else if (protocol == GS232ControllerSettings::SPID)
|
|
|
|
|
<EFBFBD> |