mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
Rotator Controller feature: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
c4b33d87be
commit
005cee925d
@ -142,7 +142,8 @@ void GS232Controller::start()
|
|||||||
m_thread->start();
|
m_thread->start();
|
||||||
m_state = StRunning;
|
m_state = StRunning;
|
||||||
|
|
||||||
GS232ControllerWorker::MsgConfigureGS232ControllerWorker *msg = GS232ControllerWorker::MsgConfigureGS232ControllerWorker::create(m_settings, true);
|
GS232ControllerWorker::MsgConfigureGS232ControllerWorker *msg =
|
||||||
|
GS232ControllerWorker::MsgConfigureGS232ControllerWorker::create(m_settings, QList<QString>(), true);
|
||||||
m_worker->getInputMessageQueue()->push(msg);
|
m_worker->getInputMessageQueue()->push(msg);
|
||||||
|
|
||||||
scanAvailableChannelsAndFeatures();
|
scanAvailableChannelsAndFeatures();
|
||||||
@ -167,7 +168,7 @@ bool GS232Controller::handleMessage(const Message& cmd)
|
|||||||
{
|
{
|
||||||
MsgConfigureGS232Controller& cfg = (MsgConfigureGS232Controller&) cmd;
|
MsgConfigureGS232Controller& cfg = (MsgConfigureGS232Controller&) cmd;
|
||||||
qDebug() << "GS232Controller::handleMessage: MsgConfigureGS232Controller";
|
qDebug() << "GS232Controller::handleMessage: MsgConfigureGS232Controller";
|
||||||
applySettings(cfg.getSettings(), cfg.getForce());
|
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -235,7 +236,7 @@ bool GS232Controller::handleMessage(const Message& cmd)
|
|||||||
SWGSDRangel::SWGTargetAzimuthElevation *swgTarget = msg.getSWGTargetAzimuthElevation();
|
SWGSDRangel::SWGTargetAzimuthElevation *swgTarget = msg.getSWGTargetAzimuthElevation();
|
||||||
m_settings.m_azimuth = swgTarget->getAzimuth();
|
m_settings.m_azimuth = swgTarget->getAzimuth();
|
||||||
m_settings.m_elevation = swgTarget->getElevation();
|
m_settings.m_elevation = swgTarget->getElevation();
|
||||||
applySettings(m_settings);
|
applySettings(m_settings, QList<QString>{"azimuth", "elevation"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -269,71 +270,28 @@ bool GS232Controller::deserialize(const QByteArray& data)
|
|||||||
{
|
{
|
||||||
if (m_settings.deserialize(data))
|
if (m_settings.deserialize(data))
|
||||||
{
|
{
|
||||||
MsgConfigureGS232Controller *msg = MsgConfigureGS232Controller::create(m_settings, true);
|
MsgConfigureGS232Controller *msg = MsgConfigureGS232Controller::create(m_settings, QList<QString>(), true);
|
||||||
m_inputMessageQueue.push(msg);
|
m_inputMessageQueue.push(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_settings.resetToDefaults();
|
m_settings.resetToDefaults();
|
||||||
MsgConfigureGS232Controller *msg = MsgConfigureGS232Controller::create(m_settings, true);
|
MsgConfigureGS232Controller *msg = MsgConfigureGS232Controller::create(m_settings, QList<QString>(), true);
|
||||||
m_inputMessageQueue.push(msg);
|
m_inputMessageQueue.push(msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232Controller::applySettings(const GS232ControllerSettings& settings, bool force)
|
void GS232Controller::applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||||
{
|
{
|
||||||
qDebug() << "GS232Controller::applySettings:"
|
qDebug() << "GS232Controller::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
|
||||||
<< " m_azimuth: " << settings.m_azimuth
|
|
||||||
<< " m_elevation: " << settings.m_elevation
|
|
||||||
<< " m_azimuthOffset: " << settings.m_azimuthOffset
|
|
||||||
<< " m_elevationOffset: " << settings.m_elevationOffset
|
|
||||||
<< " m_azimuthMin: " << settings.m_azimuthMin
|
|
||||||
<< " 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_host: " << settings.m_host
|
|
||||||
<< " m_port: " << settings.m_port
|
|
||||||
<< " m_track: " << settings.m_track
|
|
||||||
<< " m_source: " << settings.m_source
|
|
||||||
<< " m_title: " << settings.m_title
|
|
||||||
<< " m_rgbColor: " << settings.m_rgbColor
|
|
||||||
<< " m_useReverseAPI: " << settings.m_useReverseAPI
|
|
||||||
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
|
|
||||||
<< " m_reverseAPIPort: " << settings.m_reverseAPIPort
|
|
||||||
<< " m_reverseAPIFeatureSetIndex: " << settings.m_reverseAPIFeatureSetIndex
|
|
||||||
<< " m_reverseAPIFeatureIndex: " << settings.m_reverseAPIFeatureIndex
|
|
||||||
<< " force: " << force;
|
|
||||||
|
|
||||||
QList<QString> reverseAPIKeys;
|
// if ((m_settings.m_source != settings.m_source)
|
||||||
|
// || (!settings.m_source.isEmpty() && (m_selectedPipe == nullptr)) // Change in available pipes
|
||||||
|
// || force)
|
||||||
|
|
||||||
if ((m_settings.m_azimuth != settings.m_azimuth) || force) {
|
if (settingsKeys.contains("source")
|
||||||
reverseAPIKeys.append("azimuth");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_elevation != settings.m_elevation) || force) {
|
|
||||||
reverseAPIKeys.append("elevation");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_serialPort != settings.m_serialPort) || force) {
|
|
||||||
reverseAPIKeys.append("serialPort");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_baudRate != settings.m_baudRate) || force) {
|
|
||||||
reverseAPIKeys.append("baudRate");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_host != settings.m_host) || force) {
|
|
||||||
reverseAPIKeys.append("host");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_port != settings.m_port) || force) {
|
|
||||||
reverseAPIKeys.append("port");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_track != settings.m_track) || force) {
|
|
||||||
reverseAPIKeys.append("track");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_source != settings.m_source)
|
|
||||||
|| (!settings.m_source.isEmpty() && (m_selectedPipe == nullptr)) // Change in available pipes
|
|| (!settings.m_source.isEmpty() && (m_selectedPipe == nullptr)) // Change in available pipes
|
||||||
|| force)
|
|| force)
|
||||||
{
|
{
|
||||||
@ -380,55 +338,31 @@ void GS232Controller::applySettings(const GS232ControllerSettings& settings, boo
|
|||||||
{
|
{
|
||||||
m_selectedPipe = nullptr;
|
m_selectedPipe = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
reverseAPIKeys.append("source");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_azimuthOffset != settings.m_azimuthOffset) || force) {
|
|
||||||
reverseAPIKeys.append("azimuthOffset");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_elevationOffset != settings.m_elevationOffset) || force) {
|
|
||||||
reverseAPIKeys.append("elevationOffset");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_azimuthMin != settings.m_azimuthMin) || force) {
|
|
||||||
reverseAPIKeys.append("azimuthMin");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_azimuthMax != settings.m_azimuthMax) || force) {
|
|
||||||
reverseAPIKeys.append("azimuthMax");
|
|
||||||
}
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
|
|
||||||
reverseAPIKeys.append("rgbColor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GS232ControllerWorker::MsgConfigureGS232ControllerWorker *msg = GS232ControllerWorker::MsgConfigureGS232ControllerWorker::create(
|
GS232ControllerWorker::MsgConfigureGS232ControllerWorker *msg = GS232ControllerWorker::MsgConfigureGS232ControllerWorker::create(
|
||||||
settings, force
|
settings, settingsKeys, force
|
||||||
);
|
);
|
||||||
|
|
||||||
if (m_worker) {
|
if (m_worker) {
|
||||||
m_worker->getInputMessageQueue()->push(msg);
|
m_worker->getInputMessageQueue()->push(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.m_useReverseAPI)
|
if (settingsKeys.contains("useReverseAPI"))
|
||||||
{
|
{
|
||||||
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
||||||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
settingsKeys.contains("reverseAPIAddress") ||
|
||||||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
settingsKeys.contains("reverseAPIPort") ||
|
||||||
(m_settings.m_reverseAPIFeatureSetIndex != settings.m_reverseAPIFeatureSetIndex) ||
|
settingsKeys.contains("reverseAPIFeatureSetIndex") ||
|
||||||
(m_settings.m_reverseAPIFeatureIndex != settings.m_reverseAPIFeatureIndex);
|
settingsKeys.contains("m_reverseAPIFeatureIndex");
|
||||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force) {
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
} else {
|
||||||
|
m_settings.applySettings(settingsKeys, settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GS232Controller::webapiRun(bool run,
|
int GS232Controller::webapiRun(bool run,
|
||||||
@ -463,12 +397,12 @@ int GS232Controller::webapiSettingsPutPatch(
|
|||||||
GS232ControllerSettings settings = m_settings;
|
GS232ControllerSettings settings = m_settings;
|
||||||
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
|
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
|
||||||
|
|
||||||
MsgConfigureGS232Controller *msg = MsgConfigureGS232Controller::create(settings, force);
|
MsgConfigureGS232Controller *msg = MsgConfigureGS232Controller::create(settings, featureSettingsKeys, force);
|
||||||
m_inputMessageQueue.push(msg);
|
m_inputMessageQueue.push(msg);
|
||||||
|
|
||||||
if (m_guiMessageQueue) // forward to GUI if any
|
if (m_guiMessageQueue) // forward to GUI if any
|
||||||
{
|
{
|
||||||
MsgConfigureGS232Controller *msgToGUI = MsgConfigureGS232Controller::create(settings, force);
|
MsgConfigureGS232Controller *msgToGUI = MsgConfigureGS232Controller::create(settings, featureSettingsKeys, force);
|
||||||
m_guiMessageQueue->push(msgToGUI);
|
m_guiMessageQueue->push(msgToGUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,7 +585,7 @@ void GS232Controller::webapiUpdateFeatureSettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232Controller::webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const GS232ControllerSettings& settings, bool force)
|
void GS232Controller::webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const GS232ControllerSettings& settings, bool force)
|
||||||
{
|
{
|
||||||
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
|
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
|
||||||
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());
|
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());
|
||||||
|
@ -46,19 +46,22 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
const GS232ControllerSettings& getSettings() const { return m_settings; }
|
const GS232ControllerSettings& getSettings() const { return m_settings; }
|
||||||
|
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||||
bool getForce() const { return m_force; }
|
bool getForce() const { return m_force; }
|
||||||
|
|
||||||
static MsgConfigureGS232Controller* create(const GS232ControllerSettings& settings, bool force) {
|
static MsgConfigureGS232Controller* create(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||||
return new MsgConfigureGS232Controller(settings, force);
|
return new MsgConfigureGS232Controller(settings, settingsKeys, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GS232ControllerSettings m_settings;
|
GS232ControllerSettings m_settings;
|
||||||
|
QList<QString> m_settingsKeys;
|
||||||
bool m_force;
|
bool m_force;
|
||||||
|
|
||||||
MsgConfigureGS232Controller(const GS232ControllerSettings& settings, bool force) :
|
MsgConfigureGS232Controller(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||||
Message(),
|
Message(),
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
|
m_settingsKeys(settingsKeys),
|
||||||
m_force(force)
|
m_force(force)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -199,8 +202,8 @@ private:
|
|||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void applySettings(const GS232ControllerSettings& settings, bool force = false);
|
void applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
||||||
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const GS232ControllerSettings& settings, bool force);
|
void webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const GS232ControllerSettings& settings, bool force);
|
||||||
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
|
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
|
||||||
void scanAvailableChannelsAndFeatures();
|
void scanAvailableChannelsAndFeatures();
|
||||||
void notifyUpdate();
|
void notifyUpdate();
|
||||||
|
@ -77,7 +77,13 @@ bool GS232ControllerGUI::handleMessage(const Message& message)
|
|||||||
{
|
{
|
||||||
qDebug("GS232ControllerGUI::handleMessage: GS232Controller::MsgConfigureGS232Controller");
|
qDebug("GS232ControllerGUI::handleMessage: GS232Controller::MsgConfigureGS232Controller");
|
||||||
const GS232Controller::MsgConfigureGS232Controller& cfg = (GS232Controller::MsgConfigureGS232Controller&) message;
|
const GS232Controller::MsgConfigureGS232Controller& cfg = (GS232Controller::MsgConfigureGS232Controller&) message;
|
||||||
|
|
||||||
|
if (cfg.getForce()) {
|
||||||
m_settings = cfg.getSettings();
|
m_settings = cfg.getSettings();
|
||||||
|
} else {
|
||||||
|
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
|
||||||
|
}
|
||||||
|
|
||||||
blockApplySettings(true);
|
blockApplySettings(true);
|
||||||
displaySettings();
|
displaySettings();
|
||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
@ -273,6 +279,7 @@ void GS232ControllerGUI::updatePipeList(const QList<GS232ControllerSettings::Ava
|
|||||||
{
|
{
|
||||||
m_settings.m_source = "";
|
m_settings.m_source = "";
|
||||||
ui->targetName->setText("");
|
ui->targetName->setText("");
|
||||||
|
m_settingsKeys.append("source");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +334,14 @@ void GS232ControllerGUI::onMenuDialogCalled(const QPoint &p)
|
|||||||
setTitle(m_settings.m_title);
|
setTitle(m_settings.m_title);
|
||||||
setTitleColor(m_settings.m_rgbColor);
|
setTitleColor(m_settings.m_rgbColor);
|
||||||
|
|
||||||
|
m_settingsKeys.append("title");
|
||||||
|
m_settingsKeys.append("rgbColor");
|
||||||
|
m_settingsKeys.append("useReverseAPI");
|
||||||
|
m_settingsKeys.append("reverseAPIAddress");
|
||||||
|
m_settingsKeys.append("reverseAPIPort");
|
||||||
|
m_settingsKeys.append("reverseAPIFeatureSetIndex");
|
||||||
|
m_settingsKeys.append("reverseAPIFeatureIndex");
|
||||||
|
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,12 +375,14 @@ void GS232ControllerGUI::on_protocol_currentIndexChanged(int index)
|
|||||||
{
|
{
|
||||||
m_settings.m_protocol = (GS232ControllerSettings::Protocol)index;
|
m_settings.m_protocol = (GS232ControllerSettings::Protocol)index;
|
||||||
updateDecimals(m_settings.m_protocol);
|
updateDecimals(m_settings.m_protocol);
|
||||||
|
m_settingsKeys.append("protocol");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_connection_currentIndexChanged(int index)
|
void GS232ControllerGUI::on_connection_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
m_settings.m_connection = (GS232ControllerSettings::Connection)index;
|
m_settings.m_connection = (GS232ControllerSettings::Connection)index;
|
||||||
|
m_settingsKeys.append("connection");
|
||||||
applySettings();
|
applySettings();
|
||||||
updateConnectionWidgets();
|
updateConnectionWidgets();
|
||||||
}
|
}
|
||||||
@ -374,6 +391,7 @@ void GS232ControllerGUI::on_serialPort_currentIndexChanged(int index)
|
|||||||
{
|
{
|
||||||
(void) index;
|
(void) index;
|
||||||
m_settings.m_serialPort = ui->serialPort->currentText();
|
m_settings.m_serialPort = ui->serialPort->currentText();
|
||||||
|
m_settingsKeys.append("serialPort");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,18 +399,21 @@ void GS232ControllerGUI::on_baudRate_currentIndexChanged(int index)
|
|||||||
{
|
{
|
||||||
(void) index;
|
(void) index;
|
||||||
m_settings.m_baudRate = ui->baudRate->currentText().toInt();
|
m_settings.m_baudRate = ui->baudRate->currentText().toInt();
|
||||||
|
m_settingsKeys.append("baudRate");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_host_editingFinished()
|
void GS232ControllerGUI::on_host_editingFinished()
|
||||||
{
|
{
|
||||||
m_settings.m_host = ui->host->text();
|
m_settings.m_host = ui->host->text();
|
||||||
|
m_settingsKeys.append("host");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_port_valueChanged(int value)
|
void GS232ControllerGUI::on_port_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_port = value;
|
m_settings.m_port = value;
|
||||||
|
m_settingsKeys.append("port");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,6 +421,7 @@ void GS232ControllerGUI::on_azimuth_valueChanged(double value)
|
|||||||
{
|
{
|
||||||
m_settings.m_azimuth = (float)value;
|
m_settings.m_azimuth = (float)value;
|
||||||
ui->targetName->setText("");
|
ui->targetName->setText("");
|
||||||
|
m_settingsKeys.append("azimuth");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,48 +429,56 @@ void GS232ControllerGUI::on_elevation_valueChanged(double value)
|
|||||||
{
|
{
|
||||||
m_settings.m_elevation = (float)value;
|
m_settings.m_elevation = (float)value;
|
||||||
ui->targetName->setText("");
|
ui->targetName->setText("");
|
||||||
|
m_settingsKeys.append("elevation");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_azimuthOffset_valueChanged(int value)
|
void GS232ControllerGUI::on_azimuthOffset_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_azimuthOffset = value;
|
m_settings.m_azimuthOffset = value;
|
||||||
|
m_settingsKeys.append("azimuthOffset");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_elevationOffset_valueChanged(int value)
|
void GS232ControllerGUI::on_elevationOffset_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_elevationOffset = value;
|
m_settings.m_elevationOffset = value;
|
||||||
|
m_settingsKeys.append("elevationOffset");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_azimuthMin_valueChanged(int value)
|
void GS232ControllerGUI::on_azimuthMin_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_azimuthMin = value;
|
m_settings.m_azimuthMin = value;
|
||||||
|
m_settingsKeys.append("azimuthMin");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_azimuthMax_valueChanged(int value)
|
void GS232ControllerGUI::on_azimuthMax_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_azimuthMax = value;
|
m_settings.m_azimuthMax = value;
|
||||||
|
m_settingsKeys.append("azimuthMax");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_elevationMin_valueChanged(int value)
|
void GS232ControllerGUI::on_elevationMin_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_elevationMin = value;
|
m_settings.m_elevationMin = value;
|
||||||
|
m_settingsKeys.append("elevationMin");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_elevationMax_valueChanged(int value)
|
void GS232ControllerGUI::on_elevationMax_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_elevationMax = value;
|
m_settings.m_elevationMax = value;
|
||||||
|
m_settingsKeys.append("elevationMax");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::on_tolerance_valueChanged(double value)
|
void GS232ControllerGUI::on_tolerance_valueChanged(double value)
|
||||||
{
|
{
|
||||||
m_settings.m_tolerance = value;
|
m_settings.m_tolerance = value;
|
||||||
|
m_settingsKeys.append("tolerance");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +492,7 @@ void GS232ControllerGUI::on_track_stateChanged(int state)
|
|||||||
ui->targetName->setText("");
|
ui->targetName->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_settingsKeys.append("track");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,6 +501,7 @@ void GS232ControllerGUI::on_sources_currentTextChanged(const QString& text)
|
|||||||
qDebug("GS232ControllerGUI::on_sources_currentTextChanged: %s", qPrintable(text));
|
qDebug("GS232ControllerGUI::on_sources_currentTextChanged: %s", qPrintable(text));
|
||||||
m_settings.m_source = text;
|
m_settings.m_source = text;
|
||||||
ui->targetName->setText("");
|
ui->targetName->setText("");
|
||||||
|
m_settingsKeys.append("source");
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,9 +564,11 @@ void GS232ControllerGUI::applySettings(bool force)
|
|||||||
{
|
{
|
||||||
if (m_doApplySettings)
|
if (m_doApplySettings)
|
||||||
{
|
{
|
||||||
GS232Controller::MsgConfigureGS232Controller* message = GS232Controller::MsgConfigureGS232Controller::create(m_settings, force);
|
GS232Controller::MsgConfigureGS232Controller* message = GS232Controller::MsgConfigureGS232Controller::create(m_settings, m_settingsKeys, force);
|
||||||
m_gs232Controller->getInputMessageQueue()->push(message);
|
m_gs232Controller->getInputMessageQueue()->push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_settingsKeys.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerGUI::makeUIConnections()
|
void GS232ControllerGUI::makeUIConnections()
|
||||||
|
@ -55,6 +55,7 @@ private:
|
|||||||
PluginAPI* m_pluginAPI;
|
PluginAPI* m_pluginAPI;
|
||||||
FeatureUISet* m_featureUISet;
|
FeatureUISet* m_featureUISet;
|
||||||
GS232ControllerSettings m_settings;
|
GS232ControllerSettings m_settings;
|
||||||
|
QList<QString> m_settingsKeys;
|
||||||
RollupState m_rollupState;
|
RollupState m_rollupState;
|
||||||
bool m_doApplySettings;
|
bool m_doApplySettings;
|
||||||
|
|
||||||
|
@ -193,3 +193,162 @@ void GS232ControllerSettings::calcTargetAzEl(float& targetAz, float& targetEl) c
|
|||||||
targetEl = std::max(targetEl, (float)m_elevationMin);
|
targetEl = std::max(targetEl, (float)m_elevationMin);
|
||||||
targetEl = std::min(targetEl, (float)m_elevationMax);
|
targetEl = std::min(targetEl, (float)m_elevationMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GS232ControllerSettings::applySettings(const QStringList& settingsKeys, const GS232ControllerSettings& settings)
|
||||||
|
{
|
||||||
|
if (settingsKeys.contains("azimuth")) {
|
||||||
|
m_azimuth = settings.m_azimuth;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevation")) {
|
||||||
|
m_elevation = settings.m_elevation;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("serialPort")) {
|
||||||
|
m_serialPort = settings.m_serialPort;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("baudRate")) {
|
||||||
|
m_baudRate = settings.m_baudRate;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("source")) {
|
||||||
|
m_source = settings.m_source;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("title")) {
|
||||||
|
m_title = settings.m_title;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("rgbColor")) {
|
||||||
|
m_rgbColor = settings.m_rgbColor;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("useReverseAPI")) {
|
||||||
|
m_useReverseAPI = settings.m_useReverseAPI;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("reverseAPIAddress")) {
|
||||||
|
m_reverseAPIAddress = settings.m_reverseAPIAddress;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("reverseAPIPort")) {
|
||||||
|
m_reverseAPIPort = settings.m_reverseAPIPort;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("reverseAPIFeatureSetIndex")) {
|
||||||
|
m_reverseAPIFeatureSetIndex = settings.m_reverseAPIFeatureSetIndex;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("reverseAPIFeatureIndex")) {
|
||||||
|
m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("azimuthOffset")) {
|
||||||
|
m_azimuthOffset = settings.m_azimuthOffset;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevationOffset")) {
|
||||||
|
m_elevationOffset = settings.m_elevationOffset;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("azimuthMin")) {
|
||||||
|
m_azimuthMin = settings.m_azimuthMin;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("azimuthMax")) {
|
||||||
|
m_azimuthMax = settings.m_azimuthMax;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevationMin")) {
|
||||||
|
m_elevationMin = settings.m_elevationMin;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevationMax")) {
|
||||||
|
m_elevationMax = settings.m_elevationMax;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("tolerance")) {
|
||||||
|
m_tolerance = settings.m_tolerance;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("protocol")) {
|
||||||
|
m_protocol = settings.m_protocol;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("connection")) {
|
||||||
|
m_connection = settings.m_connection;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("host")) {
|
||||||
|
m_host = settings.m_host;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("port")) {
|
||||||
|
m_port = settings.m_port;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("workspaceIndex")) {
|
||||||
|
m_workspaceIndex = settings.m_workspaceIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GS232ControllerSettings::getDebugString(const QStringList& settingsKeys, bool force) const
|
||||||
|
{
|
||||||
|
std::ostringstream ostr;
|
||||||
|
|
||||||
|
if (settingsKeys.contains("azimuth") || force) {
|
||||||
|
ostr << " m_azimuth: " << m_azimuth;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevation") || force) {
|
||||||
|
ostr << " m_elevation: " << m_elevation;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("serialPort") || force) {
|
||||||
|
ostr << " m_serialPort: " << m_serialPort.toStdString();
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("baudRate") || force) {
|
||||||
|
ostr << " m_baudRate: " << m_baudRate;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("track") || force) {
|
||||||
|
ostr << " m_track: " << m_track;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("source") || force) {
|
||||||
|
ostr << " m_source: " << m_source.toStdString();
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("title") || force) {
|
||||||
|
ostr << " m_title: " << m_title.toStdString();
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("rgbColor") || force) {
|
||||||
|
ostr << " m_rgbColor: " << m_rgbColor;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("useReverseAPI") || force) {
|
||||||
|
ostr << " m_useReverseAPI: " << m_useReverseAPI;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("azimuth") || force) {
|
||||||
|
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("reverseAPIPort") || force) {
|
||||||
|
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("reverseAPIFeatureSetIndex") || force) {
|
||||||
|
ostr << " m_reverseAPIFeatureSetIndex: " << m_reverseAPIFeatureSetIndex;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("reverseAPIFeatureIndex") || force) {
|
||||||
|
ostr << " m_reverseAPIFeatureIndex: " << m_reverseAPIFeatureIndex;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("azimuthOffset") || force) {
|
||||||
|
ostr << " m_azimuthOffset: " << m_azimuthOffset;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevationOffset") || force) {
|
||||||
|
ostr << " m_elevationOffset: " << m_elevationOffset;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("azimuthMin") || force) {
|
||||||
|
ostr << " m_azimuthMin: " << m_azimuthMin;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("azimuthMax") || force) {
|
||||||
|
ostr << " m_azimuthMax: " << m_azimuthMax;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevationMin") || force) {
|
||||||
|
ostr << " m_elevationMin: " << m_elevationMin;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("elevationMax") || force) {
|
||||||
|
ostr << " m_elevationMax: " << m_elevationMax;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("tolerance") || force) {
|
||||||
|
ostr << " m_tolerance: " << m_tolerance;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("protocol") || force) {
|
||||||
|
ostr << " m_protocol: " << m_protocol;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("connection") || force) {
|
||||||
|
ostr << " m_connection: " << m_connection;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("host") || force) {
|
||||||
|
ostr << " m_host: " << m_host.toStdString();
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("port") || force) {
|
||||||
|
ostr << " m_port: " << m_port;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("workspaceIndex") || force) {
|
||||||
|
ostr << " m_workspaceIndex: " << m_workspaceIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString(ostr.str().c_str());
|
||||||
|
}
|
||||||
|
@ -77,6 +77,8 @@ struct GS232ControllerSettings
|
|||||||
bool deserialize(const QByteArray& data);
|
bool deserialize(const QByteArray& data);
|
||||||
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
|
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
|
||||||
void calcTargetAzEl(float& targetAz, float& targetEl) const;
|
void calcTargetAzEl(float& targetAz, float& targetEl) const;
|
||||||
|
void applySettings(const QStringList& settingsKeys, const GS232ControllerSettings& settings);
|
||||||
|
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
|
||||||
|
|
||||||
static const QStringList m_pipeTypes;
|
static const QStringList m_pipeTypes;
|
||||||
static const QStringList m_pipeURIs;
|
static const QStringList m_pipeURIs;
|
||||||
|
@ -102,7 +102,7 @@ bool GS232ControllerWorker::handleMessage(const Message& cmd)
|
|||||||
{
|
{
|
||||||
MsgConfigureGS232ControllerWorker& cfg = (MsgConfigureGS232ControllerWorker&) cmd;
|
MsgConfigureGS232ControllerWorker& cfg = (MsgConfigureGS232ControllerWorker&) cmd;
|
||||||
|
|
||||||
applySettings(cfg.getSettings(), cfg.getForce());
|
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -111,27 +111,11 @@ bool GS232ControllerWorker::handleMessage(const Message& cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GS232ControllerWorker::applySettings(const GS232ControllerSettings& settings, bool force)
|
void GS232ControllerWorker::applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||||
{
|
{
|
||||||
qDebug() << "GS232ControllerWorker::applySettings:"
|
qDebug() << "GS232ControllerWorker::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
|
||||||
<< " m_azimuth: " << settings.m_azimuth
|
|
||||||
<< " m_elevation: " << settings.m_elevation
|
|
||||||
<< " m_azimuthOffset: " << settings.m_azimuthOffset
|
|
||||||
<< " m_elevationOffset: " << settings.m_elevationOffset
|
|
||||||
<< " m_azimuthMin: " << settings.m_azimuthMin
|
|
||||||
<< " 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_connection: " << settings.m_connection
|
|
||||||
<< " m_serialPort: " << settings.m_serialPort
|
|
||||||
<< " m_baudRate: " << settings.m_baudRate
|
|
||||||
<< " m_host: " << settings.m_host
|
|
||||||
<< " m_port: " << settings.m_port
|
|
||||||
<< " force: " << force;
|
|
||||||
|
|
||||||
if (settings.m_connection != m_settings.m_connection)
|
if (settingsKeys.contains("connection") )
|
||||||
{
|
{
|
||||||
if (m_device && m_device->isOpen())
|
if (m_device && m_device->isOpen())
|
||||||
{
|
{
|
||||||
@ -142,15 +126,15 @@ void GS232ControllerWorker::applySettings(const GS232ControllerSettings& setting
|
|||||||
|
|
||||||
if (settings.m_connection == GS232ControllerSettings::TCP)
|
if (settings.m_connection == GS232ControllerSettings::TCP)
|
||||||
{
|
{
|
||||||
if ((settings.m_host != m_settings.m_host) || (settings.m_port != m_settings.m_port) || force) {
|
if (settingsKeys.contains("host") || settingsKeys.contains("port") || force) {
|
||||||
m_device = openSocket(settings);
|
m_device = openSocket(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((settings.m_serialPort != m_settings.m_serialPort) || force) {
|
if (settingsKeys.contains("serialPort") || force) {
|
||||||
m_device = openSerialPort(settings);
|
m_device = openSerialPort(settings);
|
||||||
} else if ((settings.m_baudRate != m_settings.m_baudRate) || force) {
|
} else if (settingsKeys.contains("baudRate") || force) {
|
||||||
m_serialPort.setBaudRate(settings.m_baudRate);
|
m_serialPort.setBaudRate(settings.m_baudRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +160,11 @@ void GS232ControllerWorker::applySettings(const GS232ControllerSettings& setting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force) {
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
} else {
|
||||||
|
m_settings.applySettings(settingsKeys, settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QIODevice *GS232ControllerWorker::openSerialPort(const GS232ControllerSettings& settings)
|
QIODevice *GS232ControllerWorker::openSerialPort(const GS232ControllerSettings& settings)
|
||||||
|
@ -38,20 +38,23 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
const GS232ControllerSettings& getSettings() const { return m_settings; }
|
const GS232ControllerSettings& getSettings() const { return m_settings; }
|
||||||
|
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||||
bool getForce() const { return m_force; }
|
bool getForce() const { return m_force; }
|
||||||
|
|
||||||
static MsgConfigureGS232ControllerWorker* create(const GS232ControllerSettings& settings, bool force)
|
static MsgConfigureGS232ControllerWorker* create(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||||
{
|
{
|
||||||
return new MsgConfigureGS232ControllerWorker(settings, force);
|
return new MsgConfigureGS232ControllerWorker(settings, settingsKeys, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GS232ControllerSettings m_settings;
|
GS232ControllerSettings m_settings;
|
||||||
|
QList<QString> m_settingsKeys;
|
||||||
bool m_force;
|
bool m_force;
|
||||||
|
|
||||||
MsgConfigureGS232ControllerWorker(const GS232ControllerSettings& settings, bool force) :
|
MsgConfigureGS232ControllerWorker(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||||
Message(),
|
Message(),
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
|
m_settingsKeys(settingsKeys),
|
||||||
m_force(force)
|
m_force(force)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -86,7 +89,7 @@ private:
|
|||||||
QString m_rotCtlDAz;
|
QString m_rotCtlDAz;
|
||||||
|
|
||||||
bool handleMessage(const Message& cmd);
|
bool handleMessage(const Message& cmd);
|
||||||
void applySettings(const GS232ControllerSettings& settings, bool force = false);
|
void applySettings(const GS232ControllerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
||||||
QIODevice *openSerialPort(const GS232ControllerSettings& settings);
|
QIODevice *openSerialPort(const GS232ControllerSettings& settings);
|
||||||
QIODevice *openSocket(const GS232ControllerSettings& settings);
|
QIODevice *openSocket(const GS232ControllerSettings& settings);
|
||||||
void setAzimuth(float azimuth);
|
void setAzimuth(float azimuth);
|
||||||
|
Loading…
Reference in New Issue
Block a user