Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotator Controller: Use floats for az/el offsets. #1744

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions plugins/feature/gs232controller/gs232controllergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ void GS232ControllerGUI::setPrecision()
ui->coord1->setDecimals(m_settings.m_precision);
ui->coord2->setDecimals(m_settings.m_precision);
ui->tolerance->setDecimals(m_settings.m_precision);
ui->azimuthOffset->setDecimals(m_settings.m_precision);
ui->elevationOffset->setDecimals(m_settings.m_precision);
}

void GS232ControllerGUI::on_protocol_currentIndexChanged(int index)
Expand Down Expand Up @@ -699,22 +701,22 @@ void GS232ControllerGUI::on_coord2_valueChanged(double value)
ui->targetName->setText("");
}

void GS232ControllerGUI::on_azimuthOffset_valueChanged(int value)
void GS232ControllerGUI::on_azimuthOffset_valueChanged(double value)
{
if (!m_inputUpdate) {
m_inputAzOffset = value;
}
m_settings.m_azimuthOffset = value;
m_settings.m_azimuthOffset = (float) value;
m_settingsKeys.append("azimuthOffset");
applySettings();
}

void GS232ControllerGUI::on_elevationOffset_valueChanged(int value)
void GS232ControllerGUI::on_elevationOffset_valueChanged(double value)
{
if (!m_inputUpdate) {
m_inputElOffset = value;
}
m_settings.m_elevationOffset = value;
m_settings.m_elevationOffset = (float) value;
m_settingsKeys.append("elevationOffset");
applySettings();
}
Expand Down Expand Up @@ -948,8 +950,8 @@ void GS232ControllerGUI::makeUIConnections()
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);
QObject::connect(ui->sources, &QComboBox::currentTextChanged, this, &GS232ControllerGUI::on_sources_currentTextChanged);
QObject::connect(ui->azimuthOffset, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_azimuthOffset_valueChanged);
QObject::connect(ui->elevationOffset, qOverload<int>(&QSpinBox::valueChanged), this, &GS232ControllerGUI::on_elevationOffset_valueChanged);
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);
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);
Expand Down
4 changes: 2 additions & 2 deletions plugins/feature/gs232controller/gs232controllergui.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ private slots:
void on_coord1_valueChanged(double value);
void on_coord2_valueChanged(double value);
void on_sources_currentTextChanged(const QString& text);
void on_azimuthOffset_valueChanged(int value);
void on_elevationOffset_valueChanged(int value);
void on_azimuthOffset_valueChanged(double value);
void on_elevationOffset_valueChanged(double value);
void on_azimuthMin_valueChanged(int value);
void on_azimuthMax_valueChanged(int value);
void on_elevationMin_valueChanged(int value);
Expand Down
61 changes: 32 additions & 29 deletions plugins/feature/gs232controller/gs232controllergui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -406,22 +406,6 @@
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QSpinBox" name="elevationOffset">
<property name="toolTip">
<string>Specify an offset angle in degrees that will be added to the target elevation to correct for misalignment</string>
</property>
<property name="minimum">
<number>-180</number>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="protocol">
<property name="toolTip">
Expand Down Expand Up @@ -628,19 +612,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="azimuthOffset">
<property name="toolTip">
<string>Specify an offset angel in degrees that will be added to the target azimuth to correct for misalignment</string>
</property>
<property name="minimum">
<number>-360</number>
</property>
<property name="maximum">
<number>360</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="tolerance">
<property name="toolTip">
Expand Down Expand Up @@ -759,6 +730,38 @@
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="azimuthOffset">
<property name="toolTip">
<string>Specify an offset angle in degrees that will be added to the target azimuth to correct for misalignment</string>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="minimum">
<double>-360.000000000000000</double>
</property>
<property name="maximum">
<double>360.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QDoubleSpinBox" name="elevationOffset">
<property name="toolTip">
<string>Specify an offset angle in degrees that will be added to the target elevation to correct for misalignment</string>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
12 changes: 6 additions & 6 deletions plugins/feature/gs232controller/gs232controllersettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void GS232ControllerSettings::resetToDefaults()
m_port = 4533;
m_track = false;
m_source = "";
m_azimuthOffset = 0;
m_elevationOffset = 0;
m_azimuthOffset = 0.0f;
m_elevationOffset = 0.0f;
m_azimuthMin = 0;
m_azimuthMax = 450;
m_elevationMin = 0;
Expand Down Expand Up @@ -97,8 +97,8 @@ QByteArray GS232ControllerSettings::serialize() const
s.writeU32(12, m_reverseAPIPort);
s.writeU32(13, m_reverseAPIFeatureSetIndex);
s.writeU32(14, m_reverseAPIFeatureIndex);
s.writeS32(15, m_azimuthOffset);
s.writeS32(16, m_elevationOffset);
s.writeFloat(15, m_azimuthOffset);
s.writeFloat(16, m_elevationOffset);
s.writeS32(17, m_azimuthMin);
s.writeS32(18, m_azimuthMax);
s.writeS32(19, m_elevationMin);
Expand Down Expand Up @@ -165,8 +165,8 @@ bool GS232ControllerSettings::deserialize(const QByteArray& data)
m_reverseAPIFeatureSetIndex = utmp > 99 ? 99 : utmp;
d.readU32(14, &utmp, 0);
m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp;
d.readS32(15, &m_azimuthOffset, 0);
d.readS32(16, &m_elevationOffset, 0);
d.readFloat(15, &m_azimuthOffset, 0.0f);
d.readFloat(16, &m_elevationOffset, 0.0f);
d.readS32(17, &m_azimuthMin, 0);
d.readS32(18, &m_azimuthMax, 450);
d.readS32(19, &m_elevationMin, 0);
Expand Down
4 changes: 2 additions & 2 deletions plugins/feature/gs232controller/gs232controllersettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ struct GS232ControllerSettings
int m_port;
bool m_track;
QString m_source; // Plugin to get az/el from. E.g: "R0:0 ADSBDemod". Use a string, so can be set via WebAPI
int m_azimuthOffset;
int m_elevationOffset;
float m_azimuthOffset;
float m_elevationOffset;
int m_azimuthMin;
int m_azimuthMax;
int m_elevationMin;
Expand Down
6 changes: 4 additions & 2 deletions swagger/sdrangel/api/swagger/include/GS232Controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ GS232ControllerSettings:
type: string
azimuthOffset:
description: Azimuth offset in degrees
type: integer
type: number
format: float
elevationOffset:
description: Elevation offset in degrees
type: integer
type: number
format: float
azimuthMin:
description: Minimum azimuth the controller will output
type: integer
Expand Down
20 changes: 10 additions & 10 deletions swagger/sdrangel/code/qt5/client/SWGGS232ControllerSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ SWGGS232ControllerSettings::SWGGS232ControllerSettings() {
m_track_isSet = false;
source = nullptr;
m_source_isSet = false;
azimuth_offset = 0;
azimuth_offset = 0.0f;
m_azimuth_offset_isSet = false;
elevation_offset = 0;
elevation_offset = 0.0f;
m_elevation_offset_isSet = false;
azimuth_min = 0;
m_azimuth_min_isSet = false;
Expand Down Expand Up @@ -108,9 +108,9 @@ SWGGS232ControllerSettings::init() {
m_track_isSet = false;
source = new QString("");
m_source_isSet = false;
azimuth_offset = 0;
azimuth_offset = 0.0f;
m_azimuth_offset_isSet = false;
elevation_offset = 0;
elevation_offset = 0.0f;
m_elevation_offset_isSet = false;
azimuth_min = 0;
m_azimuth_min_isSet = false;
Expand Down Expand Up @@ -223,9 +223,9 @@ SWGGS232ControllerSettings::fromJsonObject(QJsonObject &pJson) {

::SWGSDRangel::setValue(&source, pJson["source"], "QString", "QString");

::SWGSDRangel::setValue(&azimuth_offset, pJson["azimuthOffset"], "qint32", "");
::SWGSDRangel::setValue(&azimuth_offset, pJson["azimuthOffset"], "float", "");

::SWGSDRangel::setValue(&elevation_offset, pJson["elevationOffset"], "qint32", "");
::SWGSDRangel::setValue(&elevation_offset, pJson["elevationOffset"], "float", "");

::SWGSDRangel::setValue(&azimuth_min, pJson["azimuthMin"], "qint32", "");

Expand Down Expand Up @@ -447,22 +447,22 @@ SWGGS232ControllerSettings::setSource(QString* source) {
this->m_source_isSet = true;
}

qint32
float
SWGGS232ControllerSettings::getAzimuthOffset() {
return azimuth_offset;
}
void
SWGGS232ControllerSettings::setAzimuthOffset(qint32 azimuth_offset) {
SWGGS232ControllerSettings::setAzimuthOffset(float azimuth_offset) {
this->azimuth_offset = azimuth_offset;
this->m_azimuth_offset_isSet = true;
}

qint32
float
SWGGS232ControllerSettings::getElevationOffset() {
return elevation_offset;
}
void
SWGGS232ControllerSettings::setElevationOffset(qint32 elevation_offset) {
SWGGS232ControllerSettings::setElevationOffset(float elevation_offset) {
this->elevation_offset = elevation_offset;
this->m_elevation_offset_isSet = true;
}
Expand Down
12 changes: 6 additions & 6 deletions swagger/sdrangel/code/qt5/client/SWGGS232ControllerSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ class SWG_API SWGGS232ControllerSettings: public SWGObject {
QString* getSource();
void setSource(QString* source);

qint32 getAzimuthOffset();
void setAzimuthOffset(qint32 azimuth_offset);
float getAzimuthOffset();
void setAzimuthOffset(float azimuth_offset);

qint32 getElevationOffset();
void setElevationOffset(qint32 elevation_offset);
float getElevationOffset();
void setElevationOffset(float elevation_offset);

qint32 getAzimuthMin();
void setAzimuthMin(qint32 azimuth_min);
Expand Down Expand Up @@ -155,10 +155,10 @@ class SWG_API SWGGS232ControllerSettings: public SWGObject {
QString* source;
bool m_source_isSet;

qint32 azimuth_offset;
float azimuth_offset;
bool m_azimuth_offset_isSet;

qint32 elevation_offset;
float elevation_offset;
bool m_elevation_offset_isSet;

qint32 azimuth_min;
Expand Down