mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
Rotator Controller Updates
Add support for X/Y coordinates. Add coordinate precision setting. Automatically scan for serial port changes. Refactor so each protocol is implemented in a separate class. Add start of DFM protocol.
This commit is contained in:
@@ -27,11 +27,13 @@
|
||||
#include "gui/dialogpositioner.h"
|
||||
#include "mainwindow.h"
|
||||
#include "device/deviceuiset.h"
|
||||
#include "util/astronomy.h"
|
||||
|
||||
#include "ui_gs232controllergui.h"
|
||||
#include "gs232controller.h"
|
||||
#include "gs232controllergui.h"
|
||||
#include "gs232controllerreport.h"
|
||||
#include "dfmprotocol.h"
|
||||
|
||||
GS232ControllerGUI* GS232ControllerGUI::create(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature)
|
||||
{
|
||||
@@ -72,6 +74,57 @@ bool GS232ControllerGUI::deserialize(const QByteArray& data)
|
||||
}
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::azElToDisplay(float az, float el, float& coord1, float& coord2) const
|
||||
{
|
||||
AzAlt aa;
|
||||
double c1, c2;
|
||||
if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_85)
|
||||
{
|
||||
aa.az = az;
|
||||
aa.alt = el;
|
||||
Astronomy::azAltToXY85(aa, c1, c2);
|
||||
coord1 = (float)c1;
|
||||
coord2 = (float)c2;
|
||||
}
|
||||
else if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_30)
|
||||
{
|
||||
aa.az = az;
|
||||
aa.alt = el;
|
||||
Astronomy::azAltToXY30(aa, c1, c2);
|
||||
coord1 = (float)c1;
|
||||
coord2 = (float)c2;
|
||||
}
|
||||
else
|
||||
{
|
||||
coord1 = az;
|
||||
coord2 = el;
|
||||
}
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::displayToAzEl(float coord1, float coord2)
|
||||
{
|
||||
if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_85)
|
||||
{
|
||||
AzAlt aa = Astronomy::xy85ToAzAlt(coord1, coord2);
|
||||
m_settings.m_azimuth = aa.az;
|
||||
m_settings.m_elevation = aa.alt;
|
||||
}
|
||||
else if (m_settings.m_coordinates == GS232ControllerSettings::X_Y_30)
|
||||
{
|
||||
AzAlt aa = Astronomy::xy30ToAzAlt(coord1, coord2);
|
||||
m_settings.m_azimuth = aa.az;
|
||||
m_settings.m_elevation = aa.alt;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.m_azimuth = coord1;
|
||||
m_settings.m_elevation = coord2;
|
||||
}
|
||||
m_settingsKeys.append("azimuth");
|
||||
m_settingsKeys.append("elevation");
|
||||
applySettings();
|
||||
}
|
||||
|
||||
bool GS232ControllerGUI::handleMessage(const Message& message)
|
||||
{
|
||||
if (GS232Controller::MsgConfigureGS232Controller::match(message))
|
||||
@@ -101,20 +154,35 @@ bool GS232ControllerGUI::handleMessage(const Message& message)
|
||||
else if (GS232ControllerReport::MsgReportAzAl::match(message))
|
||||
{
|
||||
GS232ControllerReport::MsgReportAzAl& azAl = (GS232ControllerReport::MsgReportAzAl&) message;
|
||||
ui->azimuthCurrentText->setText(QString("%1").arg(azAl.getAzimuth()));
|
||||
ui->elevationCurrentText->setText(QString("%1").arg(azAl.getElevation()));
|
||||
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));
|
||||
return true;
|
||||
}
|
||||
else if (MainCore::MsgTargetAzimuthElevation::match(message))
|
||||
{
|
||||
MainCore::MsgTargetAzimuthElevation& msg = (MainCore::MsgTargetAzimuthElevation&) message;
|
||||
SWGSDRangel::SWGTargetAzimuthElevation *swgTarget = msg.getSWGTargetAzimuthElevation();
|
||||
|
||||
ui->azimuth->setValue(swgTarget->getAzimuth());
|
||||
ui->elevation->setValue(swgTarget->getElevation());
|
||||
float coord1, coord2;
|
||||
azElToDisplay(swgTarget->getAzimuth(), swgTarget->getElevation(), coord1, coord2);
|
||||
ui->coord1->setValue(coord1);
|
||||
ui->coord2->setValue(coord2);
|
||||
ui->targetName->setText(*swgTarget->getName());
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -147,7 +215,8 @@ GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featu
|
||||
m_featureUISet(featureUISet),
|
||||
m_doApplySettings(true),
|
||||
m_lastFeatureState(0),
|
||||
m_lastOnTarget(false)
|
||||
m_lastOnTarget(false),
|
||||
m_dfmStatusDialog()
|
||||
{
|
||||
m_feature = feature;
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
@@ -166,8 +235,9 @@ GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featu
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
m_statusTimer.start(250);
|
||||
|
||||
ui->azimuthCurrentText->setText("-");
|
||||
ui->elevationCurrentText->setText("-");
|
||||
ui->coord1CurrentText->setText("-");
|
||||
ui->coord2CurrentText->setText("-");
|
||||
setProtocol(m_settings.m_protocol); // Hide DFM buttons
|
||||
|
||||
updateSerialPortList();
|
||||
if (ui->serialPort->currentIndex() >= 0) {
|
||||
@@ -182,10 +252,13 @@ GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featu
|
||||
|
||||
// Get pre-existing pipes
|
||||
m_gs232Controller->getInputMessageQueue()->push(GS232Controller::MsgScanAvailableChannelOrFeatures::create());
|
||||
|
||||
new DialogPositioner(&m_dfmStatusDialog, true);
|
||||
}
|
||||
|
||||
GS232ControllerGUI::~GS232ControllerGUI()
|
||||
{
|
||||
m_dfmStatusDialog.close();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -206,11 +279,14 @@ void GS232ControllerGUI::displaySettings()
|
||||
setWindowTitle(m_settings.m_title);
|
||||
setTitle(m_settings.m_title);
|
||||
blockApplySettings(true);
|
||||
ui->azimuth->setValue(m_settings.m_azimuth);
|
||||
ui->elevation->setValue(m_settings.m_elevation);
|
||||
ui->precision->setValue(m_settings.m_precision); // Must set before protocol and az/el
|
||||
ui->protocol->setCurrentIndex((int)m_settings.m_protocol);
|
||||
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);
|
||||
ui->connection->setCurrentIndex((int)m_settings.m_connection);
|
||||
updateDecimals(m_settings.m_protocol);
|
||||
if (m_settings.m_serialPort.length() > 0) {
|
||||
ui->serialPort->lineEdit()->setText(m_settings.m_serialPort);
|
||||
}
|
||||
@@ -226,6 +302,10 @@ void GS232ControllerGUI::displaySettings()
|
||||
ui->elevationMin->setValue(m_settings.m_elevationMin);
|
||||
ui->elevationMax->setValue(m_settings.m_elevationMax);
|
||||
ui->tolerance->setValue(m_settings.m_tolerance);
|
||||
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);
|
||||
getRollupContents()->restoreState(m_rollupState);
|
||||
updateConnectionWidgets();
|
||||
blockApplySettings(false);
|
||||
@@ -256,6 +336,19 @@ void GS232ControllerGUI::updateSerialPortList()
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::updatePipeList(const QList<GS232ControllerSettings::AvailableChannelOrFeature>& sources)
|
||||
{
|
||||
QString currentText = ui->sources->currentText();
|
||||
@@ -359,24 +452,53 @@ void GS232ControllerGUI::on_startStop_toggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::updateDecimals(GS232ControllerSettings::Protocol protocol)
|
||||
void GS232ControllerGUI::setProtocol(GS232ControllerSettings::Protocol protocol)
|
||||
{
|
||||
if (protocol == GS232ControllerSettings::GS232)
|
||||
{
|
||||
ui->azimuth->setDecimals(0);
|
||||
ui->elevation->setDecimals(0);
|
||||
ui->precision->setValue(0);
|
||||
ui->precision->setEnabled(false);
|
||||
ui->precisionLabel->setEnabled(false);
|
||||
}
|
||||
else if (protocol == GS232ControllerSettings::SPID)
|
||||
ÿ | ||||