| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 13:12:18 +01:00
										 |  |  | // Copyright (C) 2020-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							|  |  |  | // Copyright (C) 2020-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>          //
 | 
					
						
							|  |  |  | // Copyright (C) 2023 Lamar Owen <lamar.owen@gmail.com>                          //
 | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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"
 | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01: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 16:47:13 +01:00
										 |  |  | #include "dfmprotocol.h"
 | 
					
						
							| 
									
										
										
										
											2024-04-20 11:51:29 +02:00
										 |  |  | #include "maincore.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(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applyAllSettings(); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray GS232ControllerGUI::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_settings.serialize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GS232ControllerGUI::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_settings.deserialize(data)) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  |         m_feature->setWorkspaceIndex(m_settings.m_workspaceIndex); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |         displaySettings(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |         applyAllSettings(); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01: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; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySettings({"azimuth", "elevation"}); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 16:40:36 +01: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 20:12:25 +02:00
										 |  |  |     else if (GS232Controller::MsgReportAvailableChannelOrFeatures::match(message)) | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-28 20:12:25 +02:00
										 |  |  |         GS232Controller::MsgReportAvailableChannelOrFeatures& report = | 
					
						
							|  |  |  |             (GS232Controller::MsgReportAvailableChannelOrFeatures&) message; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |         updatePipeList(report.getItems(), report.getRenameFrom(), report.getRenameTo()); | 
					
						
							| 
									
										
										
										
											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 16:47:13 +01: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 16:47:13 +01: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 16:47:13 +01: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 10:23:52 +02:00
										 |  |  |     getRollupContents()->saveState(m_rollupState); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("rollupState"); | 
					
						
							| 
									
										
										
										
											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 14:03:31 +01:00
										 |  |  |     m_lastFeatureState(0), | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     m_lastOnTarget(false), | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     m_dfmStatusDialog(), | 
					
						
							|  |  |  |     m_inputController(nullptr), | 
					
						
							|  |  |  |     m_inputCoord1(0.0), | 
					
						
							|  |  |  |     m_inputCoord2(0.0), | 
					
						
							|  |  |  |     m_inputAzOffset(0.0), | 
					
						
							|  |  |  |     m_inputElOffset(0.0), | 
					
						
							|  |  |  |     m_inputUpdate(false) | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  |     m_feature = feature; | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     setAttribute(Qt::WA_DeleteOnClose, true); | 
					
						
							| 
									
										
										
										
											2022-04-24 19:34:48 +02: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 14:03:31 +01:00
										 |  |  |     m_statusTimer.start(250); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     ui->coord1CurrentText->setText("-"); | 
					
						
							|  |  |  |     ui->coord2CurrentText->setText("-"); | 
					
						
							|  |  |  |     setProtocol(m_settings.m_protocol); // Hide DFM buttons
 | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01: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 05:27:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_settings.setRollupState(&m_rollupState); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |     //ui->inputConfigure->setVisible(false);
 | 
					
						
							|  |  |  |     ui->inputConfigure->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     updateInputControllerList(); | 
					
						
							|  |  |  |     connect(InputControllerManager::instance(), &InputControllerManager::controllersChanged, this, &GS232ControllerGUI::updateInputControllerList); | 
					
						
							|  |  |  |     connect(&m_inputTimer, &QTimer::timeout, this, &GS232ControllerGUI::checkInputController); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applyAllSettings(); | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  |     makeUIConnections(); | 
					
						
							| 
									
										
										
										
											2022-10-27 19:15:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Get pre-existing pipes
 | 
					
						
							|  |  |  |     m_gs232Controller->getInputMessageQueue()->push(GS232Controller::MsgScanAvailableChannelOrFeatures::create()); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     new DialogPositioner(&m_dfmStatusDialog, true); | 
					
						
							| 
									
										
										
										
											2023-11-13 20:51:03 +00:00
										 |  |  |     m_resizer.enableChildMouseTracking(); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  | void GS232ControllerGUI::updateInputControllerList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->inputController->blockSignals(true); | 
					
						
							|  |  |  |     ui->inputController->clear(); | 
					
						
							|  |  |  |     ui->inputController->addItem("None"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QStringList controllers = InputControllerManager::getAllControllers(); | 
					
						
							|  |  |  |     for (const auto& controller : controllers) { | 
					
						
							|  |  |  |         ui->inputController->addItem(controller); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->inputController->blockSignals(false); | 
					
						
							|  |  |  |     int index = ui->inputController->findText(m_settings.m_inputController); | 
					
						
							|  |  |  |     ui->inputController->setCurrentIndex(index); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::updateInputController() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete m_inputController; | 
					
						
							|  |  |  |     m_inputController = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool enabled = false; | 
					
						
							|  |  |  |     if (m_settings.m_inputController != "None") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_inputController = InputControllerManager::open(m_settings.m_inputController); | 
					
						
							|  |  |  |         if (m_inputController) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |             connect(m_inputController, &InputController::buttonChanged, this, &GS232ControllerGUI::buttonChanged); | 
					
						
							|  |  |  |             connect(m_inputController, &InputController::configurationComplete, this, &GS232ControllerGUI::inputConfigurationComplete); | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |             m_inputTimer.start(20); | 
					
						
							|  |  |  |             enabled = true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_inputTimer.stop(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-04-24 11:38:52 +01:00
										 |  |  |     ui->inputConfigure->setEnabled(enabled); | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::buttonChanged(int button, bool released) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!released) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch (button) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         case INPUTCONTROLLER_BUTTON_RIGHT_TOP: | 
					
						
							|  |  |  |             ui->startStop->doToggle(!ui->startStop->isChecked()); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case INPUTCONTROLLER_BUTTON_RIGHT_BOTTOM: | 
					
						
							|  |  |  |             ui->track->click(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case INPUTCONTROLLER_BUTTON_RIGHT_RIGHT: | 
					
						
							|  |  |  |             ui->enableTargetControl->click(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case INPUTCONTROLLER_BUTTON_RIGHT_LEFT: | 
					
						
							|  |  |  |             ui->enableOffsetControl->click(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case INPUTCONTROLLER_BUTTON_R1: | 
					
						
							|  |  |  |             ui->highSensitivity->click(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::checkInputController() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_inputController) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // If our input device has two sticks (four axes), we use one for target and one for offset
 | 
					
						
							|  |  |  |         // If only one stick (two axes), it's used both for target when not tracking and offset, when tracking
 | 
					
						
							|  |  |  |         // Use separate variables rather than values in UI, to allow for higher precision
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!m_settings.m_track) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |             if (m_settings.m_targetControlEnabled) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 m_inputCoord1 += m_extraSensitivity * m_inputController->getAxisCalibratedValue(0, &m_settings.m_inputControllerSettings, m_settings.m_highSensitivity); | 
					
						
							|  |  |  |                 m_inputCoord2 += m_extraSensitivity * -m_inputController->getAxisCalibratedValue(1, &m_settings.m_inputControllerSettings, m_settings.m_highSensitivity); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (m_settings.m_coordinates == GS232ControllerSettings::AZ_EL) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 m_inputCoord1 = std::max(m_inputCoord1, (double) m_settings.m_azimuthMin); | 
					
						
							|  |  |  |                 m_inputCoord1 = std::min(m_inputCoord1, (double) m_settings.m_azimuthMax); | 
					
						
							|  |  |  |                 m_inputCoord2 = std::max(m_inputCoord2, (double) m_settings.m_elevationMin); | 
					
						
							|  |  |  |                 m_inputCoord2 = std::min(m_inputCoord2, (double) m_settings.m_elevationMax); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 m_inputCoord1 = std::max(m_inputCoord1, -90.0); | 
					
						
							|  |  |  |                 m_inputCoord1 = std::min(m_inputCoord1, 90.0); | 
					
						
							|  |  |  |                 m_inputCoord2 = std::max(m_inputCoord2, -90.0); | 
					
						
							|  |  |  |                 m_inputCoord2 = std::min(m_inputCoord2, 90.0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ((m_inputController->getNumberOfAxes() < 4) && m_settings.m_track) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |             if (m_settings.m_offsetControlEnabled) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 m_inputAzOffset += m_extraSensitivity * m_inputController->getAxisCalibratedValue(0, &m_settings.m_inputControllerSettings, m_settings.m_highSensitivity); | 
					
						
							|  |  |  |                 m_inputElOffset += m_extraSensitivity * -m_inputController->getAxisCalibratedValue(1, &m_settings.m_inputControllerSettings, m_settings.m_highSensitivity); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         else if (m_inputController->getNumberOfAxes() >= 4) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |             if (m_settings.m_offsetControlEnabled) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 m_inputAzOffset += m_extraSensitivity * m_inputController->getAxisCalibratedValue(2, &m_settings.m_inputControllerSettings, m_settings.m_highSensitivity); | 
					
						
							|  |  |  |                 m_inputElOffset += m_extraSensitivity * -m_inputController->getAxisCalibratedValue(3, &m_settings.m_inputControllerSettings, m_settings.m_highSensitivity); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         m_inputAzOffset = std::max(m_inputAzOffset, -360.0); | 
					
						
							|  |  |  |         m_inputAzOffset = std::min(m_inputAzOffset, 360.0); | 
					
						
							|  |  |  |         m_inputElOffset = std::max(m_inputElOffset, -180.0); | 
					
						
							|  |  |  |         m_inputElOffset = std::min(m_inputElOffset, 180.0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_inputUpdate = true; | 
					
						
							|  |  |  |         if (!m_settings.m_track) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ui->coord1->setValue(m_inputCoord1); | 
					
						
							|  |  |  |             ui->coord2->setValue(m_inputCoord2); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (((m_inputController->getNumberOfAxes() < 4) && m_settings.m_track) || (m_inputController->getNumberOfAxes() >= 4)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ui->azimuthOffset->setValue(m_inputAzOffset); | 
					
						
							|  |  |  |             ui->elevationOffset->setValue(m_inputElOffset); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         m_inputUpdate = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_inputController_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // Don't update settings if set to -1
 | 
					
						
							|  |  |  |     if (index >= 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_inputController = ui->inputController->currentText(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |         applySetting("inputController"); | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |         updateInputController(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  | void GS232ControllerGUI::on_inputConfigure_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_inputController) { | 
					
						
							|  |  |  |         m_inputController->configure(&m_settings.m_inputControllerSettings); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_highSensitivity_clicked(bool checked) | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |     m_settings.m_highSensitivity = checked; | 
					
						
							|  |  |  |     ui->highSensitivity->setText(checked ? "H" : "L"); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("highSensitivity"); | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  | void GS232ControllerGUI::on_enableTargetControl_clicked(bool checked) | 
					
						
							| 
									
										
										
										
											2023-04-24 11:38:52 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |     m_settings.m_targetControlEnabled = checked; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("targetControlEnabled"); | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_enableOffsetControl_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_offsetControlEnabled  = checked; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("offsetControlEnabled"); | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::inputConfigurationComplete() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("inputControllerSettings"); | 
					
						
							| 
									
										
										
										
											2023-04-24 11:38:52 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | GS232ControllerGUI::~GS232ControllerGUI() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     m_dfmStatusDialog.close(); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02: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 10:23:52 +02:00
										 |  |  |     setTitle(m_settings.m_title); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     blockApplySettings(true); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     ui->precision->setValue(m_settings.m_precision); // Must set before protocol and az/el
 | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  |     ui->protocol->setCurrentIndex((int)m_settings.m_protocol); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01: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 23:15:15 +02: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 14:03:31 +01:00
										 |  |  |     ui->tolerance->setValue(m_settings.m_tolerance); | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     ui->inputController->setCurrentText(m_settings.m_inputController); | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |     ui->highSensitivity->setChecked(m_settings.m_highSensitivity); | 
					
						
							|  |  |  |     ui->enableTargetControl->setChecked(m_settings.m_targetControlEnabled); | 
					
						
							|  |  |  |     ui->enableOffsetControl->setChecked(m_settings.m_offsetControlEnabled); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01: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 10:23:52 +02: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 16:47:13 +01: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); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | void GS232ControllerGUI::updatePipeList(const AvailableChannelOrFeatureList& sources, const QStringList& renameFrom, const QStringList& renameTo) | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     // Update source settting if it has been renamed
 | 
					
						
							|  |  |  |     if (renameFrom.contains(m_settings.m_source)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_source = renameTo[renameFrom.indexOf(m_settings.m_source)]; | 
					
						
							|  |  |  |         applySetting("source"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int prevIdx = ui->sources->currentIndex(); | 
					
						
							| 
									
										
										
										
											2021-10-03 23:15:15 +02:00
										 |  |  |     ui->sources->blockSignals(true); | 
					
						
							|  |  |  |     ui->sources->clear(); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-14 15:36:22 +00:00
										 |  |  |     for (const auto& source : sources) { | 
					
						
							|  |  |  |         ui->sources->addItem(source.getLongId()); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     // Select current setting, if it exists
 | 
					
						
							|  |  |  |     // If not, and no prior setting, make sure nothing selected, as channel/feature may be created later on
 | 
					
						
							|  |  |  |     // If not found and something was previously selected, clear the setting, as probably deleted
 | 
					
						
							|  |  |  |     int idx = ui->sources->findText(m_settings.m_source); | 
					
						
							|  |  |  |     if (idx >= 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->sources->setCurrentIndex(idx); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (prevIdx == -1) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->sources->setCurrentIndex(-1); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2021-10-03 23:15:15 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-28 20:12:25 +02:00
										 |  |  |         m_settings.m_source = ""; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |         applySetting("source"); | 
					
						
							| 
									
										
										
										
											2022-03-28 20:12:25 +02:00
										 |  |  |         ui->targetName->setText(""); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-03-28 20:12:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-03 23:15:15 +02:00
										 |  |  |     ui->sources->blockSignals(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     // If no current settting, select first available
 | 
					
						
							|  |  |  |     if (m_settings.m_source.isEmpty() && (ui->sources->count() > 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->sources->setCurrentIndex(0); | 
					
						
							|  |  |  |         on_sources_currentTextChanged(ui->sources->currentText()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											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 12:08:33 +02: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 12:08:33 +02:00
										 |  |  |         setTitle(m_settings.m_title); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |         setTitleColor(m_settings.m_rgbColor); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |         QList<QString> settingsKeys({ | 
					
						
							|  |  |  |             "rgbColor", | 
					
						
							|  |  |  |             "title", | 
					
						
							|  |  |  |             "useReverseAPI", | 
					
						
							|  |  |  |             "reverseAPIAddress", | 
					
						
							|  |  |  |             "reverseAPIPort", | 
					
						
							|  |  |  |             "reverseAPIDeviceIndex", | 
					
						
							|  |  |  |             "reverseAPIChannelIndex" | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2022-11-24 16:40:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |         applySettings(settingsKeys); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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 16:47:13 +01:00
										 |  |  | void GS232ControllerGUI::setProtocol(GS232ControllerSettings::Protocol protocol) | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (protocol == GS232ControllerSettings::GS232) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |         ui->precision->setValue(0); | 
					
						
							|  |  |  |         ui->precision->setEnabled(false); | 
					
						
							|  |  |  |         ui->precisionLabel->setEnabled(false); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (protocol == GS232ControllerSettings::SPID) | 
					
						
							| 
									
										
										
										
											2023-04-03 17:14:01 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |         ui->precision->setValue(1); | 
					
						
							|  |  |  |         ui->precision->setEnabled(false); | 
					
						
							|  |  |  |         ui->precisionLabel->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |         ui->precision->setEnabled(true); | 
					
						
							|  |  |  |         ui->precisionLabel->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     bool dfm = protocol == GS232ControllerSettings::DFM; | 
					
						
							|  |  |  |     ui->dfmLine->setVisible(dfm); | 
					
						
							|  |  |  |     ui->dfmTrack->setVisible(dfm); | 
					
						
							|  |  |  |     ui->dfmLubePumps->setVisible(dfm); | 
					
						
							|  |  |  |     ui->dfmBrakes->setVisible(dfm); | 
					
						
							|  |  |  |     ui->dfmDrives->setVisible(dfm); | 
					
						
							|  |  |  |     ui->dfmShowStatus->setVisible(dfm); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // See RemoteControlGUI::createGUI() for additional weirdness in trying
 | 
					
						
							|  |  |  |     // to resize a window after widgets are changed
 | 
					
						
							|  |  |  |     getRollupContents()->arrangeRollups(); | 
					
						
							|  |  |  |     layout()->activate(); // Recalculate sizeHint
 | 
					
						
							|  |  |  |     setMinimumSize(sizeHint()); | 
					
						
							|  |  |  |     setMaximumSize(sizeHint()); | 
					
						
							|  |  |  |     resize(sizeHint()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::setPrecision() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->coord1->setDecimals(m_settings.m_precision); | 
					
						
							|  |  |  |     ui->coord2->setDecimals(m_settings.m_precision); | 
					
						
							|  |  |  |     ui->tolerance->setDecimals(m_settings.m_precision); | 
					
						
							| 
									
										
										
										
											2023-07-27 14:57:57 +01:00
										 |  |  |     ui->azimuthOffset->setDecimals(m_settings.m_precision); | 
					
						
							|  |  |  |     ui->elevationOffset->setDecimals(m_settings.m_precision); | 
					
						
							| 
									
										
										
										
											2023-08-09 12:18:37 -04:00
										 |  |  |     double step = pow(10.0, -m_settings.m_precision); | 
					
						
							|  |  |  |     ui->coord1->setSingleStep(step); | 
					
						
							|  |  |  |     ui->coord2->setSingleStep(step); | 
					
						
							|  |  |  |     ui->tolerance->setSingleStep(step); | 
					
						
							|  |  |  |     ui->azimuthOffset->setSingleStep(step); | 
					
						
							|  |  |  |     ui->elevationOffset->setSingleStep(step); | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_protocol_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_protocol = (GS232ControllerSettings::Protocol)index; | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     setProtocol(m_settings.m_protocol); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("protocol"); | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-23 12:13:24 +00:00
										 |  |  | void GS232ControllerGUI::on_connection_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_connection = (GS232ControllerSettings::Connection)index; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("connection"); | 
					
						
							| 
									
										
										
										
											2021-11-23 12:13:24 +00:00
										 |  |  |     updateConnectionWidgets(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | void GS232ControllerGUI::on_serialPort_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-14 11:13:32 +01:00
										 |  |  |     (void) index; | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     m_settings.m_serialPort = ui->serialPort->currentText(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("serialPort"); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_baudRate_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-14 11:13:32 +01:00
										 |  |  |     (void) index; | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     m_settings.m_baudRate = ui->baudRate->currentText().toInt(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("baudRate"); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-23 12:13:24 +00:00
										 |  |  | void GS232ControllerGUI::on_host_editingFinished() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_host = ui->host->text(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("host"); | 
					
						
							| 
									
										
										
										
											2021-11-23 12:13:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_port_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_port = value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("port"); | 
					
						
							| 
									
										
										
										
											2021-11-23 12:13:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | void GS232ControllerGUI::on_coord1_valueChanged(double value) | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     if (!m_inputUpdate) { | 
					
						
							|  |  |  |         m_inputCoord1 = value; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     displayToAzEl(value, ui->coord2->value()); | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  |     ui->targetName->setText(""); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | void GS232ControllerGUI::on_coord2_valueChanged(double value) | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     if (!m_inputUpdate) { | 
					
						
							|  |  |  |         m_inputCoord2 = value; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     displayToAzEl(ui->coord1->value(), value); | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  |     ui->targetName->setText(""); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-27 14:57:57 +01:00
										 |  |  | void GS232ControllerGUI::on_azimuthOffset_valueChanged(double value) | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     if (!m_inputUpdate) { | 
					
						
							|  |  |  |         m_inputAzOffset = value; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-07-27 14:57:57 +01:00
										 |  |  |     m_settings.m_azimuthOffset = (float) value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("azimuthOffset"); | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-27 14:57:57 +01:00
										 |  |  | void GS232ControllerGUI::on_elevationOffset_valueChanged(double value) | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     if (!m_inputUpdate) { | 
					
						
							|  |  |  |         m_inputElOffset = value; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-07-27 14:57:57 +01:00
										 |  |  |     m_settings.m_elevationOffset = (float) value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("elevationOffset"); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-26 20:27:35 +00:00
										 |  |  | void GS232ControllerGUI::on_azimuthMin_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_azimuthMin = value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("azimuthMin"); | 
					
						
							| 
									
										
										
										
											2021-02-26 20:27:35 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_azimuthMax_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_azimuthMax = value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("azimuthMax"); | 
					
						
							| 
									
										
										
										
											2021-02-26 20:27:35 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_elevationMin_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_elevationMin = value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("elevationMin"); | 
					
						
							| 
									
										
										
										
											2021-02-26 20:27:35 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_elevationMax_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_elevationMax = value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("elevationMax"); | 
					
						
							| 
									
										
										
										
											2021-02-26 20:27:35 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-05 14:03:31 +01:00
										 |  |  | void GS232ControllerGUI::on_tolerance_valueChanged(double value) | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     m_settings.m_tolerance = value; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("tolerance"); | 
					
						
							| 
									
										
										
										
											2021-05-30 12:38:07 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | void GS232ControllerGUI::on_precision_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_precision = value; | 
					
						
							|  |  |  |     setPrecision(); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("precision"); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_coordinates_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_coordinates = (GS232ControllerSettings::Coordinates)index; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("coordinates"); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     float coord1, coord2; | 
					
						
							|  |  |  |     azElToDisplay(m_settings.m_azimuth, m_settings.m_elevation, coord1, coord2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->coord1->blockSignals(true); | 
					
						
							|  |  |  |     if (m_settings.m_coordinates == GS232ControllerSettings::AZ_EL) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->coord1->setMinimum(0.0); | 
					
						
							|  |  |  |         ui->coord1->setMaximum(450.0); | 
					
						
							|  |  |  |         ui->coord1->setToolTip("Target azimuth in degrees"); | 
					
						
							|  |  |  |         ui->coord1Label->setText("Azimuth"); | 
					
						
							|  |  |  |         ui->coord1CurrentText->setToolTip("Current azimuth in degrees"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->coord1->setMinimum(-90.0); | 
					
						
							|  |  |  |         ui->coord1->setMaximum(90.0); | 
					
						
							|  |  |  |         ui->coord1->setToolTip("Target X in degrees"); | 
					
						
							|  |  |  |         ui->coord1Label->setText("X"); | 
					
						
							|  |  |  |         ui->coord1CurrentText->setToolTip("Current X coordinate in degrees"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->coord1->setValue(coord1); | 
					
						
							|  |  |  |     ui->coord1->blockSignals(false); | 
					
						
							|  |  |  |     ui->coord2->blockSignals(true); | 
					
						
							|  |  |  |     if (m_settings.m_coordinates == GS232ControllerSettings::AZ_EL) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->coord2->setMinimum(0.0); | 
					
						
							|  |  |  |         ui->coord2->setMaximum(180.0); | 
					
						
							|  |  |  |         ui->coord2->setToolTip("Target elevation in degrees"); | 
					
						
							|  |  |  |         ui->coord2Label->setText("Elevation"); | 
					
						
							|  |  |  |         ui->coord2CurrentText->setToolTip("Current elevation in degrees"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->coord2->setMinimum(-90.0); | 
					
						
							|  |  |  |         ui->coord2->setMaximum(90.0); | 
					
						
							|  |  |  |         ui->coord2->setToolTip("Target Y in degrees"); | 
					
						
							|  |  |  |         ui->coord2Label->setText("Y"); | 
					
						
							|  |  |  |         ui->coord2CurrentText->setToolTip("Current Y coordinate in degrees"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->coord2->setValue(coord2); | 
					
						
							|  |  |  |     ui->coord2->blockSignals(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | void GS232ControllerGUI::on_track_stateChanged(int state) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_track = state == Qt::Checked; | 
					
						
							| 
									
										
										
										
											2021-11-23 12:13:24 +00:00
										 |  |  |     ui->targetName->setEnabled(m_settings.m_track); | 
					
						
							| 
									
										
										
										
											2021-10-03 23:15:15 +02:00
										 |  |  |     ui->sources->setEnabled(m_settings.m_track); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!m_settings.m_track) { | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  |         ui->targetName->setText(""); | 
					
						
							| 
									
										
										
										
											2021-10-03 23:15:15 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("track"); | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-03 23:15:15 +02:00
										 |  |  | void GS232ControllerGUI::on_sources_currentTextChanged(const QString& text) | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-10-03 23:15:15 +02:00
										 |  |  |     qDebug("GS232ControllerGUI::on_sources_currentTextChanged: %s", qPrintable(text)); | 
					
						
							|  |  |  |     m_settings.m_source = text; | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  |     ui->targetName->setText(""); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("source"); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | void GS232ControllerGUI::on_dfmTrack_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_dfmTrackOn = checked; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("dfmTrackOn"); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_dfmLubePumps_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_dfmLubePumpsOn = checked; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("dfmLubePumpsOn"); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_dfmBrakes_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_dfmBrakesOn = checked; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("dfmBrakesOn"); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_dfmDrives_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_dfmDrivesOn = checked; | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySetting("dfmDrivesOn"); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::on_dfmShowStatus_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_dfmStatusDialog.show(); | 
					
						
							|  |  |  |     m_dfmStatusDialog.raise(); | 
					
						
							|  |  |  |     m_dfmStatusDialog.activateWindow(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | void GS232ControllerGUI::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int state = m_gs232Controller->getState(); | 
					
						
							| 
									
										
										
										
											2021-10-05 14:03:31 +01:00
										 |  |  |     bool onTarget = m_gs232Controller->getOnTarget(); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (m_lastFeatureState != state) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  |         // We set checked state of start/stop button, in case it was changed via API
 | 
					
						
							|  |  |  |         bool oldState; | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |         switch (state) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             case Feature::StNotStarted: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case Feature::StIdle: | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  |                 oldState = ui->startStop->blockSignals(true); | 
					
						
							|  |  |  |                 ui->startStop->setChecked(false); | 
					
						
							|  |  |  |                 ui->startStop->blockSignals(oldState); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case Feature::StRunning: | 
					
						
							| 
									
										
										
										
											2021-01-13 19:44:53 +00:00
										 |  |  |                 oldState = ui->startStop->blockSignals(true); | 
					
						
							|  |  |  |                 ui->startStop->setChecked(true); | 
					
						
							|  |  |  |                 ui->startStop->blockSignals(oldState); | 
					
						
							| 
									
										
										
										
											2021-10-05 14:03:31 +01:00
										 |  |  |                 if (onTarget) { | 
					
						
							|  |  |  |                     ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     ui->startStop->setStyleSheet("QToolButton { background-color : yellow; }"); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 m_lastOnTarget = onTarget; | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case Feature::StError: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							| 
									
										
										
										
											2021-11-23 12:13:24 +00:00
										 |  |  |                 QMessageBox::critical(this, m_settings.m_title, m_gs232Controller->getErrorMessage()); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_lastFeatureState = state; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-10-05 14:03:31 +01:00
										 |  |  |     else if (state == Feature::StRunning) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (onTarget != m_lastOnTarget) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (onTarget) { | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : yellow; }"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         m_lastOnTarget = onTarget; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | void GS232ControllerGUI::applySetting(const QString& settingsKey) | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     applySettings({settingsKey}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GS232ControllerGUI::applySettings(const QStringList& settingsKeys, bool force) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settingsKeys.append(settingsKeys); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-11-24 16:40:36 +01:00
										 |  |  |         GS232Controller::MsgConfigureGS232Controller* message = GS232Controller::MsgConfigureGS232Controller::create(m_settings, m_settingsKeys, force); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |         m_gs232Controller->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |         m_settingsKeys.clear(); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-11-24 16:40:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | void GS232ControllerGUI::applyAllSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     applySettings(QStringList(), true); | 
					
						
							| 
									
										
										
										
											2020-10-27 16:22:10 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  | void GS232ControllerGUI::makeUIConnections() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &GS232ControllerGUI::on_startStop_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->protocol, qOverload<int>(&QComboBox::currentIndexChanged), this, &GS232ControllerGUI::on_protocol_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->connection, qOverload<int>(&QComboBox::currentIndexChanged), this, &GS232ControllerGUI::on_connection_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->serialPort, qOverload<int>(&QComboBox::currentIndexChanged), this, &GS232ControllerGUI::on_serialPort_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->host, &QLineEdit::editingFinished, this, &GS232ControllerGUI::on_host_editingFinished); | 
					
						
							|  |  |  |     QObject::connect(ui->port, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_port_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->baudRate, qOverload<int>(&QComboBox::currentIndexChanged), this, &GS232ControllerGUI::on_baudRate_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->track, &QCheckBox::stateChanged, this, &GS232ControllerGUI::on_track_stateChanged); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     QObject::connect(ui->coord1, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &GS232ControllerGUI::on_coord1_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->coord2, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &GS232ControllerGUI::on_coord2_valueChanged); | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  |     QObject::connect(ui->sources, &QComboBox::currentTextChanged, this, &GS232ControllerGUI::on_sources_currentTextChanged); | 
					
						
							| 
									
										
										
										
											2023-07-27 14:57:57 +01:00
										 |  |  |     QObject::connect(ui->azimuthOffset, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &GS232ControllerGUI::on_azimuthOffset_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->elevationOffset, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &GS232ControllerGUI::on_elevationOffset_valueChanged); | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  |     QObject::connect(ui->azimuthMin, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_azimuthMin_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->azimuthMax, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_azimuthMax_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->elevationMin, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_elevationMin_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->elevationMax, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_elevationMax_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->tolerance, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &GS232ControllerGUI::on_tolerance_valueChanged); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     QObject::connect(ui->precision, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_precision_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->coordinates, qOverload<int>(&QComboBox::currentIndexChanged), this, &GS232ControllerGUI::on_coordinates_currentIndexChanged); | 
					
						
							| 
									
										
										
										
											2023-04-23 19:52:02 +01:00
										 |  |  |     QObject::connect(ui->inputController, qOverload<int>(&QComboBox::currentIndexChanged), this, &GS232ControllerGUI::on_inputController_currentIndexChanged); | 
					
						
							| 
									
										
										
										
											2023-04-24 11:38:52 +01:00
										 |  |  |     QObject::connect(ui->inputConfigure, &QToolButton::clicked, this, &GS232ControllerGUI::on_inputConfigure_clicked); | 
					
						
							| 
									
										
										
										
											2023-08-05 12:33:01 +01:00
										 |  |  |     QObject::connect(ui->highSensitivity, &QToolButton::clicked, this, &GS232ControllerGUI::on_highSensitivity_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->enableTargetControl, &QToolButton::clicked, this, &GS232ControllerGUI::on_enableTargetControl_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->enableOffsetControl, &QToolButton::clicked, this, &GS232ControllerGUI::on_enableOffsetControl_clicked); | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  |     QObject::connect(ui->dfmTrack, &QToolButton::toggled, this, &GS232ControllerGUI::on_dfmTrack_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->dfmLubePumps, &QToolButton::toggled, this, &GS232ControllerGUI::on_dfmLubePumps_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->dfmBrakes, &QToolButton::toggled, this, &GS232ControllerGUI::on_dfmBrakes_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->dfmDrives, &QToolButton::toggled, this, &GS232ControllerGUI::on_dfmDrives_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->dfmShowStatus, &QToolButton::clicked, this, &GS232ControllerGUI::on_dfmShowStatus_clicked); | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2023-04-03 16:47:13 +01:00
										 |  |  | 
 |