AFC: UI changes and fixes

pull/676/head
f4exb 2020-10-24 10:35:07 +02:00
rodzic d2b50353da
commit b69ab47e90
7 zmienionych plików z 259 dodań i 113 usunięć

Wyświetl plik

@ -37,6 +37,8 @@
MESSAGE_CLASS_DEFINITION(AFC::MsgConfigureAFC, Message)
MESSAGE_CLASS_DEFINITION(AFC::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(AFC::MsgDeviceTrack, Message)
MESSAGE_CLASS_DEFINITION(AFC::MsgDevicesApply, Message)
const QString AFC::m_featureIdURI = "sdrangel.feature.afc";
const QString AFC::m_featureId = "AFC";
@ -125,6 +127,26 @@ bool AFC::handleMessage(const Message& cmd)
return true;
}
}
else if (MsgDeviceTrack::match(cmd))
{
if (m_worker->isRunning())
{
AFCWorker::MsgDeviceTrack *msg = AFCWorker::MsgDeviceTrack::create();
m_worker->getInputMessageQueue()->push(msg);
}
return true;
}
else if (MsgDevicesApply::match(cmd))
{
if (m_worker->isRunning())
{
AFCWorker::MsgDevicesApply *msg = AFCWorker::MsgDevicesApply::create();
m_worker->getInputMessageQueue()->push(msg);
}
return true;
}
return false;
}

Wyświetl plik

@ -81,6 +81,32 @@ public:
{ }
};
class MsgDeviceTrack : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgDeviceTrack* create() {
return new MsgDeviceTrack();
}
protected:
MsgDeviceTrack() :
Message()
{ }
};
class MsgDevicesApply : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgDevicesApply* create() {
return new MsgDevicesApply();
}
protected:
MsgDevicesApply() :
Message()
{ }
};
AFC(WebAPIAdapterInterface *webAPIAdapterInterface);
virtual ~AFC();
virtual void destroy() { delete this; }

Wyświetl plik

@ -303,12 +303,6 @@ void AFCGUI::on_startStop_toggled(bool checked)
}
}
void AFCGUI::on_devicesRefresh_clicked()
{
updateDeviceSetLists();
displaySettings();
}
void AFCGUI::on_hasTargetFrequency_toggled(bool checked)
{
m_settings.m_hasTargetFrequency = checked;
@ -327,6 +321,25 @@ void AFCGUI::on_transverterTarget_toggled(bool checked)
applySettings();
}
void AFCGUI::on_toleranceFrequency_changed(quint64 value)
{
m_settings.m_freqTolerance = value;
applySettings();
}
void AFCGUI::on_deviceTrack_clicked()
{
AFC::MsgDeviceTrack *msg = AFC::MsgDeviceTrack::create();
m_afc->getInputMessageQueue()->push(msg);
}
void AFCGUI::on_devicesRefresh_clicked()
{
updateDeviceSetLists();
displaySettings();
}
void AFCGUI::on_trackerDevice_currentIndexChanged(int index)
{
if (index >= 0)
@ -345,11 +358,9 @@ void AFCGUI::on_trackedDevice_currentIndexChanged(int index)
}
}
void AFCGUI::on_toleranceFrequency_changed(quint64 value)
void AFCGUI::on_devicesApply_clicked()
{
m_settings.m_freqTolerance = value;
applySettings();
}
void AFCGUI::updateStatus()

Wyświetl plik

@ -75,12 +75,14 @@ private slots:
void handleInputMessages();
void on_startStop_toggled(bool checked);
void on_hasTargetFrequency_toggled(bool checked);
void on_devicesRefresh_clicked();
void on_transverterTarget_toggled(bool checked);
void on_targetFrequency_changed(quint64 value);
void on_transverterTarget_toggled(bool checked);
void on_toleranceFrequency_changed(quint64 value);
void on_deviceTrack_clicked();
void on_devicesRefresh_clicked();
void on_trackerDevice_currentIndexChanged(int index);
void on_trackedDevice_currentIndexChanged(int index);
void on_toleranceFrequency_changed(quint64 value);
void on_devicesApply_clicked();
void updateStatus();
};

Wyświetl plik

@ -137,96 +137,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="devicesLayout">
<item>
<widget class="QPushButton" name="devicesRefresh">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Refresh indexes of available device sets</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="trackerLabel">
<property name="text">
<string>Tracker</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="trackerDevice">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Tracker deviceset index</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="trackedLabel">
<property name="text">
<string>Tracked</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="trackedDevice">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Tracked deviceset index</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="DelaysLayout">
<layout class="QHBoxLayout" name="toleranceLayout">
<item>
<widget class="QLabel" name="toleranceLabel">
<property name="toolTip">
@ -275,6 +186,26 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deviceTrack">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Force device tracking update</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/arrow_left.png</normaloff>:/arrow_left.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
@ -315,6 +246,115 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="devicesLayout">
<item>
<widget class="QPushButton" name="devicesRefresh">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Refresh indexes of available device sets</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="trackerLabel">
<property name="text">
<string>Tracker</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="trackerDevice">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Tracker deviceset index</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="trackedLabel">
<property name="text">
<string>Tracked</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="trackedDevice">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Tracked deviceset index</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="devicesApply">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Reinitialization of device data</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/arrow_left.png</normaloff>:/arrow_left.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>

Wyświetl plik

@ -36,6 +36,8 @@
MESSAGE_CLASS_DEFINITION(AFCWorker::MsgConfigureAFCWorker, Message)
MESSAGE_CLASS_DEFINITION(AFCWorker::MsgTrackedDeviceChange, Message)
MESSAGE_CLASS_DEFINITION(AFCWorker::MsgDeviceTrack, Message)
MESSAGE_CLASS_DEFINITION(AFCWorker::MsgDevicesApply, Message)
AFCWorker::AFCWorker(WebAPIAdapterInterface *webAPIAdapterInterface) :
m_webAPIAdapterInterface(webAPIAdapterInterface),
@ -101,15 +103,28 @@ bool AFCWorker::handleMessage(const Message& cmd)
}
else if (Feature::MsgChannelSettings::match(cmd))
{
qDebug() << "AFCWorker::handleMessage: Feature::MsgChannelSettings";
QMutexLocker mutexLocker(&m_mutex);
Feature::MsgChannelSettings& cfg = (Feature::MsgChannelSettings&) cmd;
SWGSDRangel::SWGChannelSettings *swgChannelSettings = cfg.getSWGSettings();
qDebug() << "AFCWorker::handleMessage: Feature::MsgChannelSettings:" << *swgChannelSettings->getChannelType();
processChannelSettings(cfg.getChannelAPI(), cfg.getChannelSettingsKeys(), swgChannelSettings);
delete swgChannelSettings;
return true;
}
else if (MsgDeviceTrack::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
updateTarget();
return true;
}
else if (MsgDevicesApply::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
initTrackerDeviceSet(m_settings.m_trackerDeviceSetIndex);
initTrackedDeviceSet(m_settings.m_trackedDeviceSetIndex);
return true;
}
else
{
return false;
@ -286,7 +301,7 @@ void AFCWorker::processChannelSettings(
}
}
bool AFCWorker::updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset)
bool AFCWorker::updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset, unsigned int blockCount)
{
SWGSDRangel::SWGChannelSettings swgChannelSettings;
SWGSDRangel::SWGErrorResponse errorResponse;
@ -306,6 +321,7 @@ bool AFCWorker::updateChannelOffset(ChannelAPI *channelAPI, int direction, int o
.arg(jsonSettingsStr);
swgChannelSettings.fromJson(jsonStr);
channelAPI->setFeatureSettingsFeedbackBlockCount(1);
int httpRC = m_webAPIAdapterInterface->devicesetChannelSettingsPutPatch(
m_trackedDeviceSet->getIndex(),
channelAPI->getIndexInDeviceSet(),
@ -344,20 +360,20 @@ void AFCWorker::updateTarget()
}
else
{
qDebug() << "AFCWorker::initTrackerDeviceSet: cannot find device frequency";
qDebug() << "AFCWorker::updateTarget: cannot find device frequency";
return;
}
}
else
{
qDebug() << "AFCWorker::initTrackerDeviceSet: devicesetDeviceSettingsGet error" << rc << ":" << *error.getMessage();
qDebug() << "AFCWorker::updateTarget: devicesetDeviceSettingsGet error" << rc << ":" << *error.getMessage();
return;
}
int64_t trackerFrequency = m_trackerDeviceFrequency + m_trackerChannelOffset;
int64_t correction = m_settings.m_targetFrequency - trackerFrequency;
int64_t tolerance = m_settings.m_freqTolerance;
qDebug() << "AFCWorker::initTrackerDeviceSet: correction:" << correction << "tolerance:" << tolerance;
qDebug() << "AFCWorker::updateTarget: correction:" << correction << "tolerance:" << tolerance;
if ((correction > -tolerance) && (correction < tolerance)) {
return;
@ -376,12 +392,12 @@ void AFCWorker::updateTarget()
}
else
{
qDebug() << "AFCWorker::initTrackerDeviceSet: cannot find device transverter frequency";
qDebug() << "AFCWorker::updateTarget: cannot find device transverter frequency";
return;
}
// adjust tracker offset
if (updateChannelOffset(m_freqTracker, 0, m_trackerChannelOffset + correction)) {
if (updateChannelOffset(m_freqTracker, 0, m_trackerChannelOffset + correction, 1)) {
m_trackerChannelOffset += correction;
}
}
@ -397,7 +413,7 @@ void AFCWorker::updateTarget()
}
else
{
qDebug() << "AFCWorker::initTrackerDeviceSet: cannot find device transverter frequency";
qDebug() << "AFCWorker::updateTarget: cannot find device transverter frequency";
return;
}
}
@ -415,6 +431,10 @@ bool AFCWorker::updateDeviceFrequency(DeviceSet *deviceSet, const QString& key,
QString jsonSettingsStr = tr("\"%1\":%2").arg(key).arg(frequency);
QString deviceSettingsKey;
getDeviceSettingsKey(deviceAPI, deviceSettingsKey);
qDebug() << "AFCWorker::updateDeviceFrequency:"
<< deviceAPI->getHardwareId()
<< ":" << key
<< ":" << frequency;
QString jsonStr = tr("{ \"deviceHwType\": \"%1\", \"direction\": \"%2\", \"%3\": {%4}}")
.arg(deviceAPI->getHardwareId())
@ -422,7 +442,6 @@ bool AFCWorker::updateDeviceFrequency(DeviceSet *deviceSet, const QString& key,
.arg(deviceSettingsKey)
.arg(jsonSettingsStr);
swgDeviceSettings.fromJson(jsonStr);
qDebug() << "AFCWorker::updateDeviceFrequency:" << jsonStr;
int httpRC = m_webAPIAdapterInterface->devicesetDeviceSettingsPutPatch
(

Wyświetl plik

@ -78,6 +78,32 @@ public:
{ }
};
class MsgDeviceTrack : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgDeviceTrack* create() {
return new MsgDeviceTrack();
}
protected:
MsgDeviceTrack() :
Message()
{ }
};
class MsgDevicesApply : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgDevicesApply* create() {
return new MsgDevicesApply();
}
protected:
MsgDevicesApply() :
Message()
{ }
};
AFCWorker(WebAPIAdapterInterface *webAPIAdapterInterface);
~AFCWorker();
void reset();
@ -136,7 +162,7 @@ private:
const QList<QString> &channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings
);
bool updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset);
bool updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset, unsigned int blockCount = 0);
void updateTarget();
bool updateDeviceFrequency(DeviceSet *deviceSet, const QString& key, int64_t frequency);
int getDeviceDirection(DeviceAPI *deviceAPI);