Skip to content

Commit

Permalink
Merge pull request #914 from srcejon/gs232_spid_and_tolerance
Browse files Browse the repository at this point in the history
GS-232 controller updates
  • Loading branch information
f4exb committed May 30, 2021
2 parents 56ebd6f + 51c240f commit ae11010
Show file tree
Hide file tree
Showing 15 changed files with 533 additions and 236 deletions.
Binary file modified doc/img/GS232Controller_plugin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions plugins/feature/gs232controller/gs232controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ void GS232Controller::applySettings(const GS232ControllerSettings& settings, boo
<< " m_azimuthMax: " << settings.m_azimuthMax
<< " m_elevationMin: " << settings.m_elevationMin
<< " m_elevationMax: " << settings.m_elevationMax
<< " m_tolerance: " << settings.m_tolerance
<< " m_protocol: " << settings.m_protocol
<< " m_serialPort: " << settings.m_serialPort
<< " m_baudRate: " << settings.m_baudRate
<< " m_track: " << settings.m_track
Expand Down Expand Up @@ -274,6 +276,12 @@ void GS232Controller::applySettings(const GS232ControllerSettings& settings, boo
if ((m_settings.m_elevationMin != settings.m_elevationMin) || force) {
reverseAPIKeys.append("elevationMin");
}
if ((m_settings.m_tolerance != settings.m_tolerance) || force) {
reverseAPIKeys.append("tolerance");
}
if ((m_settings.m_protocol != settings.m_protocol) || force) {
reverseAPIKeys.append("m_protocol");
}
if ((m_settings.m_title != settings.m_title) || force) {
reverseAPIKeys.append("title");
}
Expand Down Expand Up @@ -360,6 +368,8 @@ void GS232Controller::webapiFormatFeatureSettings(
response.getGs232ControllerSettings()->setAzimuthMax(settings.m_azimuthMax);
response.getGs232ControllerSettings()->setElevationMin(settings.m_elevationMin);
response.getGs232ControllerSettings()->setElevationMax(settings.m_elevationMax);
response.getGs232ControllerSettings()->setTolerance(settings.m_tolerance);
response.getGs232ControllerSettings()->setProtocol(settings.m_protocol);

if (response.getGs232ControllerSettings()->getTitle()) {
*response.getGs232ControllerSettings()->getTitle() = settings.m_title;
Expand Down Expand Up @@ -420,6 +430,12 @@ void GS232Controller::webapiUpdateFeatureSettings(
if (featureSettingsKeys.contains("elevationMax")) {
settings.m_elevationMax = response.getGs232ControllerSettings()->getElevationMax();
}
if (featureSettingsKeys.contains("tolerance")) {
settings.m_tolerance = response.getGs232ControllerSettings()->getTolerance();
}
if (featureSettingsKeys.contains("protocol")) {
settings.m_protocol = (GS232ControllerSettings::Protocol)response.getGs232ControllerSettings()->getProtocol();
}
if (featureSettingsKeys.contains("title")) {
settings.m_title = *response.getGs232ControllerSettings()->getTitle();
}
Expand Down Expand Up @@ -484,6 +500,12 @@ void GS232Controller::webapiReverseSendSettings(QList<QString>& featureSettingsK
if (featureSettingsKeys.contains("elevationMax") || force) {
swgGS232ControllerSettings->setElevationMax(settings.m_elevationMax);
}
if (featureSettingsKeys.contains("tolerance") || force) {
swgGS232ControllerSettings->setTolerance(settings.m_tolerance);
}
if (featureSettingsKeys.contains("protocol") || force) {
swgGS232ControllerSettings->setProtocol((int)settings.m_protocol);
}
if (featureSettingsKeys.contains("title") || force) {
swgGS232ControllerSettings->setTitle(new QString(settings.m_title));
}
Expand Down
44 changes: 38 additions & 6 deletions plugins/feature/gs232controller/gs232controllergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ bool GS232ControllerGUI::handleMessage(const Message& message)
else if (GS232ControllerReport::MsgReportAzAl::match(message))
{
GS232ControllerReport::MsgReportAzAl& azAl = (GS232ControllerReport::MsgReportAzAl&) message;
ui->azimuthCurrentText->setText(QString("%1").arg(round(azAl.getAzimuth())));
ui->elevationCurrentText->setText(QString("%1").arg(round(azAl.getElevation())));
ui->azimuthCurrentText->setText(QString("%1").arg(azAl.getAzimuth()));
ui->elevationCurrentText->setText(QString("%1").arg(azAl.getElevation()));
return true;
}
else if (MainCore::MsgTargetAzimuthElevation::match(message))
Expand Down Expand Up @@ -153,6 +153,9 @@ GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featu
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(1000);

ui->azimuthCurrentText->setText("-");
ui->elevationCurrentText->setText("-");

updateSerialPortList();
displaySettings();
applySettings(true);
Expand All @@ -175,6 +178,8 @@ void GS232ControllerGUI::displaySettings()
blockApplySettings(true);
ui->azimuth->setValue(m_settings.m_azimuth);
ui->elevation->setValue(m_settings.m_elevation);
ui->protocol->setCurrentIndex((int)m_settings.m_protocol);
updateDecimals(m_settings.m_protocol);
if (m_settings.m_serialPort.length() > 0)
ui->serialPort->lineEdit()->setText(m_settings.m_serialPort);
ui->baudRate->setCurrentText(QString("%1").arg(m_settings.m_baudRate));
Expand Down Expand Up @@ -281,6 +286,27 @@ void GS232ControllerGUI::on_startStop_toggled(bool checked)
}
}

void GS232ControllerGUI::updateDecimals(GS232ControllerSettings::Protocol protocol)
{
if (protocol == GS232ControllerSettings::GS232)
{
ui->azimuth->setDecimals(0);
ui->elevation->setDecimals(0);
}
else
{
ui->azimuth->setDecimals(1);
ui->elevation->setDecimals(1);
}
}

void GS232ControllerGUI::on_protocol_currentIndexChanged(int index)
{
m_settings.m_protocol = (GS232ControllerSettings::Protocol)index;
updateDecimals(m_settings.m_protocol);
applySettings();
}

void GS232ControllerGUI::on_serialPort_currentIndexChanged(int index)
{
(void) index;
Expand All @@ -295,16 +321,16 @@ void GS232ControllerGUI::on_baudRate_currentIndexChanged(int index)
applySettings();
}

void GS232ControllerGUI::on_azimuth_valueChanged(int value)
void GS232ControllerGUI::on_azimuth_valueChanged(double value)
{
m_settings.m_azimuth = value;
m_settings.m_azimuth = (float)value;
ui->targetName->setText("");
applySettings();
}

void GS232ControllerGUI::on_elevation_valueChanged(int value)
void GS232ControllerGUI::on_elevation_valueChanged(double value)
{
m_settings.m_elevation = value;
m_settings.m_elevation = (float)value;
ui->targetName->setText("");
applySettings();
}
Expand Down Expand Up @@ -345,6 +371,12 @@ void GS232ControllerGUI::on_elevationMax_valueChanged(int value)
applySettings();
}

void GS232ControllerGUI::on_tolerance_valueChanged(int value)
{
m_settings.m_tolerance = value;
applySettings();
}

void GS232ControllerGUI::on_track_stateChanged(int state)
{
m_settings.m_track = state == Qt::Checked;
Expand Down
8 changes: 5 additions & 3 deletions plugins/feature/gs232controller/gs232controllergui.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class GS232ControllerGUI : public FeatureGUI {
void blockApplySettings(bool block);
void applySettings(bool force = false);
void displaySettings();
void updateDecimals(GS232ControllerSettings::Protocol protocol);
void updatePipeList();
void updateSerialPortList();
bool handleMessage(const Message& message);
Expand All @@ -76,20 +77,21 @@ private slots:
void onWidgetRolled(QWidget* widget, bool rollDown);
void handleInputMessages();
void on_startStop_toggled(bool checked);
void on_protocol_currentIndexChanged(int index);
void on_serialPort_currentIndexChanged(int index);
void on_baudRate_currentIndexChanged(int index);
void on_track_stateChanged(int state);
void on_azimuth_valueChanged(int value);
void on_elevation_valueChanged(int value);
void on_azimuth_valueChanged(double value);
void on_elevation_valueChanged(double value);
void on_targets_currentTextChanged(const QString& text);
void on_azimuthOffset_valueChanged(int value);
void on_elevationOffset_valueChanged(int value);
void on_azimuthMin_valueChanged(int value);
void on_azimuthMax_valueChanged(int value);
void on_elevationMin_valueChanged(int value);
void on_elevationMax_valueChanged(int value);
void on_tolerance_valueChanged(int value);
void updateStatus();
};


#endif // INCLUDE_FEATURE_GS232CONTROLLERGUI_H_

0 comments on commit ae11010

Please sign in to comment.