RigCtrl plugin: Removed QMainWindow dependency in plugin interface. Get API URI from MainWindow. Cosmetic changes

pull/638/head
f4exb 2020-09-10 02:43:28 +02:00
rodzic 40bd691a45
commit d9ec9f2787
14 zmienionych plików z 119 dodań i 124 usunięć

Wyświetl plik

@ -45,7 +45,7 @@ target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}
sdrbase
${TARGET_LIB_GUI}
${TARGET_LIB_GUI}
swagger
)

Wyświetl plik

@ -22,10 +22,10 @@
#include <QtNetwork>
// Length of buffers
#define CMD_LENGTH 1024
#define URL_LENGTH 1024
#define RESPONSE_LENGTH 1024
#define DATA_LENGTH 1024
const unsigned int RigCtrl::m_CmdLength = 1024;
const unsigned int RigCtrl::m_UrlLength = 1024;
const unsigned int RigCtrl::m_ResponseLength = 1024;
const unsigned int RigCtrl::m_DataLength = 1024;
// Hamlib rigctrl error codes
enum rig_errcode_e {
@ -103,7 +103,7 @@ RigCtrl::RigCtrl() :
m_state(idle),
m_tcpServer(nullptr),
m_clientConnection(nullptr)
{
{
m_netman = new QNetworkAccessManager(this);
connect(m_netman, &QNetworkAccessManager::finished, this, &RigCtrl::processAPIResponse);
@ -194,9 +194,9 @@ void RigCtrl::acceptConnection()
// Get rigctrl command and start processing it
void RigCtrl::getCommand()
{
char cmd[CMD_LENGTH];
char url[URL_LENGTH];
char response[RESPONSE_LENGTH];
char cmd[m_CmdLength];
char url[m_UrlLength];
char response[m_ResponseLength];
qint64 len;
QNetworkRequest request;
char *p;
@ -211,13 +211,13 @@ void RigCtrl::getCommand()
// Set frequency
m_targetFrequency = atof(cmd[0] == 'F' ? &cmd[2] : &cmd[9]);
// Get current centre frequency
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->get(request);
m_state = set_freq;
} else if (!strncmp(cmd, "f", 1) || !strncmp(cmd, "get_freq", 8)) {
// Get frequency - need to add centerFrequency and inputFrequencyOffset
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->get(request);
m_state = get_freq_center;
@ -253,7 +253,7 @@ void RigCtrl::getCommand()
}
if (mode_map[i].modem != nullptr) {
// Delete current modem
sprintf(url, "%s/deviceset/%d/channel/%d", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex, m_settings.m_channelIndex);
sprintf(url, "%s/deviceset/%d/channel/%d", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex, m_settings.m_channelIndex);
request.setUrl(QUrl(url));
m_netman->sendCustomRequest(request, "DELETE");
m_state = set_mode_mod;
@ -263,19 +263,19 @@ void RigCtrl::getCommand()
}
} else if (!strncmp(cmd, "set_powerstat 0", 15)) {
// Power off radio
sprintf(url, "%s/deviceset/%d/device/run", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/run", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->sendCustomRequest(request, "DELETE");
m_state = set_power_off;
} else if (!strncmp(cmd, "set_powerstat 1", 15)) {
// Power on radio
sprintf(url, "%s/deviceset/%d/device/run", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/run", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->post(request, "");
m_state = set_power_on;
} else if (!strncmp(cmd, "get_powerstat", 13)) {
// Return if powered on or off
sprintf(url, "%s/deviceset/%d/device/run", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/run", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->get(request);
m_state = get_power;
@ -292,9 +292,9 @@ void RigCtrl::getCommand()
void RigCtrl::processAPIResponse(QNetworkReply *reply)
{
double freq;
char response[RESPONSE_LENGTH];
char url[URL_LENGTH];
char data[DATA_LENGTH];
char response[m_ResponseLength];
char url[m_UrlLength];
char data[m_DataLength];
QNetworkRequest request;
if (reply->error() == QNetworkReply::NoError) {
@ -311,7 +311,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
freq = getSubObjectDouble(jsonObj, "centerFrequency");
if (freq >= 0.0) {
m_targetFrequency = freq;
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex, m_settings.m_channelIndex);
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex, m_settings.m_channelIndex);
request.setUrl(QUrl(url));
m_netman->get(request);
} else {
@ -333,7 +333,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
if (fabs(freq - m_targetFrequency) > m_settings.m_maxFrequencyOffset) {
// Update centerFrequency
setSubObjectDouble(jsonObj, "centerFrequency", m_targetFrequency);
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
m_state = set_freq_center;
@ -341,7 +341,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
// In range, so update inputFrequencyOffset
m_targetOffset = m_targetFrequency - freq;
// Get settings containg inputFrequencyOffset, so we can patch them
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex, m_settings.m_channelIndex);
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex, m_settings.m_channelIndex);
request.setUrl(QUrl(url));
m_netman->get(request);
m_state = set_freq_set_offset;
@ -351,7 +351,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
case set_freq_no_offset:
// Update centerFrequency, without trying to set offset
setSubObjectDouble(jsonObj, "centerFrequency", m_targetFrequency);
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
m_state = set_freq_center_no_offset;
@ -363,7 +363,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
if (freq == m_targetFrequency) {
// Set inputFrequencyOffset to 0
m_targetOffset = 0;
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex, m_settings.m_channelIndex);
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex, m_settings.m_channelIndex);
request.setUrl(QUrl(url));
m_netman->get(request);
m_state = set_freq_set_offset;
@ -389,7 +389,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
case set_freq_set_offset:
// Patch inputFrequencyOffset
if (setSubObjectDouble(jsonObj, "inputFrequencyOffset", m_targetOffset)) {
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex, m_settings.m_channelIndex);
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex, m_settings.m_channelIndex);
request.setUrl(QUrl(url));
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
m_state = set_freq_offset;
@ -414,7 +414,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
case set_mode_mod:
// Create new modem
sprintf(url, "%s/deviceset/%d/channel", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/channel", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
sprintf(data, "{ \"channelType\": \"%s\", \"direction\": 0, \"originatorDeviceSetIndex\": %d}\n", m_targetModem, m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
@ -428,7 +428,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
case set_mode_settings:
// Set modem bandwidth
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex, m_settings.m_channelIndex);
sprintf(url, "%s/deviceset/%d/channel/%d/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex, m_settings.m_channelIndex);
sprintf(data, "{ \"channelType\": \"%s\", \"%sSettings\": {\"rfBandwidth\":%d}}\n", m_targetModem, m_targetModem, m_targetBW);
request.setUrl(QUrl(url));
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
@ -476,7 +476,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
case set_freq_set_offset:
// Probably no demodulator enabled on the specified channel
// Just set as center frequency
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/device/settings", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
m_netman->get(request);
m_state = set_freq_no_offset;
@ -484,7 +484,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
case set_mode_mod:
// Probably no modem on channel to delete, so continue to try to create one
sprintf(url, "%s/deviceset/%d/channel", qUtf8Printable(m_settings.m_APIAddress), m_settings.m_deviceIndex);
sprintf(url, "%s/deviceset/%d/channel", qUtf8Printable(m_APIBaseURI), m_settings.m_deviceIndex);
sprintf(data, "{ \"channelType\": \"%s\", \"direction\": 0, \"originatorDeviceSetIndex\": %d}\n", m_targetModem, m_settings.m_deviceIndex);
request.setUrl(QUrl(url));
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");

Wyświetl plik

@ -32,6 +32,7 @@ public:
~RigCtrl();
void getSettings(RigCtrlSettings *settings);
void setSettings(RigCtrlSettings *settings);
void setAPIBaseURI(const QString& apiBaseURI) { m_APIBaseURI = apiBaseURI; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
@ -40,7 +41,7 @@ private slots:
void getCommand();
void processAPIResponse(QNetworkReply *reply);
protected:
private:
QTcpServer *m_tcpServer;
QTcpSocket *m_clientConnection;
QNetworkAccessManager *m_netman;
@ -60,8 +61,14 @@ protected:
double m_targetOffset;
const char *m_targetModem;
int m_targetBW;
QString m_APIBaseURI; //!< Base URI of own API
RigCtrlSettings m_settings;
static const unsigned int m_CmdLength;
static const unsigned int m_UrlLength;
static const unsigned int m_ResponseLength;
static const unsigned int m_DataLength;
};
#endif // INCLUDE_RIGCTRL_H

Wyświetl plik

@ -27,7 +27,6 @@ RigCtrlGUI::RigCtrlGUI(RigCtrl *rigCtrl, QWidget* parent) :
ui->setupUi(this);
m_rigCtrl->getSettings(&m_settings);
ui->enable->setChecked(m_settings.m_enabled);
ui->api->setText(QString(m_settings.m_APIAddress));
ui->rigCtrlPort->setValue(m_settings.m_rigCtrlPort);
ui->maxFrequencyOffset->setValue(m_settings.m_maxFrequencyOffset);
ui->deviceIndex->setValue(m_settings.m_deviceIndex);
@ -42,7 +41,6 @@ RigCtrlGUI::~RigCtrlGUI()
void RigCtrlGUI::accept()
{
m_settings.m_enabled = ui->enable->isChecked();
m_settings.m_APIAddress = ui->api->text();
m_settings.m_rigCtrlPort = ui->rigCtrlPort->value();
m_settings.m_maxFrequencyOffset = ui->maxFrequencyOffset->value();
m_settings.m_deviceIndex = ui->deviceIndex->value();

Wyświetl plik

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>351</width>
<height>235</height>
<height>261</height>
</rect>
</property>
<property name="font">
@ -33,69 +33,35 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QLabel" name="rigCtrlPortLabel">
<property name="text">
<string>rigctrl Port</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="deviceIndexLabel">
<property name="text">
<string>Device Index</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="deviceIndex">
<property name="toolTip">
<string>Index of the device that should be controlled by rigctrl commands.
Default is 0.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="channelIndex">
<property name="toolTip">
<string>Index of the channel that is to be controlled by rigctrl commands.
Default is 0.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="channelIndexLabel">
<property name="text">
<string>Channel Index</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="apiLabel">
<property name="text">
<string>API Address</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="api">
<widget class="QSpinBox" name="rigCtrlPort">
<property name="toolTip">
<string>URL of SDRangel API server to control.
Default is http://127.0.0.1:8091/sdrangel</string>
<string>TCP port to listen for rigctrl commands on.
Default is 4532.</string>
</property>
<property name="text">
<string>http://127.0.0.1:8091/sdrangel</string>
<property name="minimum">
<number>1024</number>
</property>
<property name="maximum">
<number>65536</number>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="maxFrequencyOffsetLabel">
<property name="text">
<string>Max Frequency Offset</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<widget class="QSpinBox" name="maxFrequencyOffset">
<property name="toolTip">
<string>Controls whether the center frequency or frequency offset is adjusted when a new frequency is received via a rigctrl command.
@ -108,17 +74,33 @@ Default is 10000.</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="rigCtrlPort">
<item row="3" column="0">
<widget class="QLabel" name="deviceIndexLabel">
<property name="text">
<string>Device Index</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="deviceIndex">
<property name="toolTip">
<string>TCP port to listen for rigctrl commands on.
Default is 4532.</string>
<string>Index of the device that should be controlled by rigctrl commands.
Default is 0.</string>
</property>
<property name="minimum">
<number>1024</number>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="channelIndexLabel">
<property name="text">
<string>Channel Index</string>
</property>
<property name="maximum">
<number>65536</number>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="channelIndex">
<property name="toolTip">
<string>Index of the channel that is to be controlled by rigctrl commands.
Default is 0.</string>
</property>
</widget>
</item>

Wyświetl plik

@ -28,6 +28,7 @@
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include "mainwindow.h"
#include "rigctrlgui.h"
#endif
#include "rigctrlplugin.h"
@ -62,10 +63,8 @@ void RigCtrlPlugin::initPlugin(PluginAPI* pluginAPI)
#ifdef SERVER_MODE
bool RigCtrlPlugin::createTopLevelGUI(
QMainWindow* mainWindow
)
{
(void) mainWindow;
return true;
}
@ -74,12 +73,11 @@ void RigCtrlPlugin::showRigCtrlUI()
}
#else
bool RigCtrlPlugin::createTopLevelGUI(
QMainWindow* mainWindow
)
bool RigCtrlPlugin::createTopLevelGUI()
{
m_mainWindow = mainWindow;
QMenuBar *menuBar = mainWindow->menuBar();
m_mainWindow = MainWindow::getInstance();
m_rigCtrl->setAPIBaseURI(QString("http://%1:%2/sdrangel").arg(m_mainWindow->getAPIHost()).arg(m_mainWindow->getAPIPort()));
QMenuBar *menuBar = m_mainWindow->menuBar();
QMenu *prefMenu = menuBar->findChild<QMenu *>("menuPreferences", Qt::FindDirectChildrenOnly);
if (prefMenu == nullptr) {

Wyświetl plik

@ -23,7 +23,7 @@
#include "rigctrl.h"
class PluginAPI;
class QMainWindow;
class MainWindow;
#define RIGCTRL_DEVICE_TYPE_ID "sdrangel.misc.rigctrl"
@ -33,12 +33,12 @@ class RigCtrlPlugin : public QObject, public PluginInterface {
Q_PLUGIN_METADATA(IID RIGCTRL_DEVICE_TYPE_ID)
public:
explicit RigCtrlPlugin(RigCtrl *rigCtrl = NULL, QObject* parent = NULL);
explicit RigCtrlPlugin(RigCtrl *rigCtrl = nullptr, QObject* parent = nullptr);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
virtual bool createTopLevelGUI(QMainWindow* mainWindow);
virtual bool createTopLevelGUI();
virtual QByteArray serializeGlobalSettings() const;
virtual bool deserializeGlobalSettings(const QByteArray& data);
@ -47,7 +47,7 @@ private slots:
private:
static const PluginDescriptor m_pluginDescriptor;
QMainWindow* m_mainWindow;
MainWindow* m_mainWindow;
RigCtrl *m_rigCtrl;
};

Wyświetl plik

@ -21,21 +21,20 @@
#include <QtDebug>
#include "util/simpleserializer.h"
#define ENABLED_DEFAULT false
#define API_ADDRESS_DEFAULT "http://127.0.0.1:8091/sdrangel"
#define RIG_CTRL_PORT_DEFAULT 4532
#define MAX_FREQUENCY_OFFSET_DEFAULT 10000
#define DEVICE_INDEX_DEFAULT 0
#define CHANNEL_INDEX_DEFAULT 0
const bool RigCtrlSettings::m_EnabledDefault = false;
const int RigCtrlSettings::m_RigCtrlPortDefault = 4532;
const int RigCtrlSettings::m_MaxFrequencyOffsetDefault = 10000;
const int RigCtrlSettings::m_DeviceIndexDefault = 0;
const int RigCtrlSettings::m_ChannelIndexDefault = 0;
void RigCtrlSettings::resetToDefaults()
{
m_enabled = ENABLED_DEFAULT;
m_APIAddress = API_ADDRESS_DEFAULT;
m_rigCtrlPort = RIG_CTRL_PORT_DEFAULT;
m_maxFrequencyOffset = MAX_FREQUENCY_OFFSET_DEFAULT;
m_deviceIndex = DEVICE_INDEX_DEFAULT;
m_channelIndex = CHANNEL_INDEX_DEFAULT;
m_enabled = m_EnabledDefault;
m_rigCtrlPort = m_RigCtrlPortDefault;
m_maxFrequencyOffset = m_MaxFrequencyOffsetDefault;
m_deviceIndex = m_DeviceIndexDefault;
m_channelIndex = m_ChannelIndexDefault;
}
QByteArray RigCtrlSettings::serialize() const
@ -43,7 +42,6 @@ QByteArray RigCtrlSettings::serialize() const
SimpleSerializer s(1);
s.writeBool(1, m_enabled);
s.writeString(2, m_APIAddress);
s.writeS32(3, m_rigCtrlPort);
s.writeS32(4, m_maxFrequencyOffset);
s.writeS32(5, m_deviceIndex);
@ -64,28 +62,27 @@ bool RigCtrlSettings::deserialize(const QByteArray& data)
if (d.getVersion() == 1)
{
d.readBool(1, &m_enabled, ENABLED_DEFAULT);
d.readString(2, &m_APIAddress, API_ADDRESS_DEFAULT);
d.readS32(3, &m_rigCtrlPort, RIG_CTRL_PORT_DEFAULT);
d.readS32(4, &m_maxFrequencyOffset, MAX_FREQUENCY_OFFSET_DEFAULT);
d.readS32(5, &m_deviceIndex, DEVICE_INDEX_DEFAULT);
d.readS32(6, &m_channelIndex, CHANNEL_INDEX_DEFAULT);
d.readBool(1, &m_enabled, m_EnabledDefault);
d.readS32(3, &m_rigCtrlPort, m_RigCtrlPortDefault);
d.readS32(4, &m_maxFrequencyOffset, m_MaxFrequencyOffsetDefault);
d.readS32(5, &m_deviceIndex, m_DeviceIndexDefault);
d.readS32(6, &m_channelIndex, m_ChannelIndexDefault);
if (!((m_rigCtrlPort > 1023) && (m_rigCtrlPort < 65536))) {
qDebug() << "RigCtrlSettings::deserialize invalid port number ignored";
m_rigCtrlPort = RIG_CTRL_PORT_DEFAULT;
m_rigCtrlPort = m_RigCtrlPortDefault;
}
if (m_maxFrequencyOffset < 0) {
qDebug() << "RigCtrlSettings::deserialize invalid max frequency offset ignored";
m_maxFrequencyOffset = MAX_FREQUENCY_OFFSET_DEFAULT;
m_maxFrequencyOffset = m_MaxFrequencyOffsetDefault;
}
if (m_deviceIndex < 0) {
qDebug() << "RigCtrlSettings::deserialize invalid device index ignored";
m_deviceIndex = DEVICE_INDEX_DEFAULT;
m_deviceIndex = m_DeviceIndexDefault;
}
if (m_channelIndex < 0) {
qDebug() << "RigCtrlSettings::deserialize invalid channel index ignored";
m_deviceIndex = CHANNEL_INDEX_DEFAULT;
m_deviceIndex = m_ChannelIndexDefault;
}
return true;

Wyświetl plik

@ -24,7 +24,6 @@
struct RigCtrlSettings {
bool m_enabled;
QString m_APIAddress;
int m_rigCtrlPort;
int m_maxFrequencyOffset;
int m_deviceIndex;
@ -37,6 +36,13 @@ struct RigCtrlSettings {
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
private:
static const bool m_EnabledDefault;
static const int m_RigCtrlPortDefault;
static const int m_MaxFrequencyOffsetDefault;
static const int m_DeviceIndexDefault;
static const int m_ChannelIndexDefault;
};
#endif /* INCLUDE_RIGCTRLSETTINGS_H */

Wyświetl plik

@ -6,8 +6,6 @@
#include "export.h"
class QMainWindow;
struct SDRBASE_API PluginDescriptor {
const QString hardwareId;
// general plugin description
@ -314,7 +312,7 @@ public:
virtual void deleteSampleMIMOPluginInstanceMIMO(DeviceSampleMIMO *mimo);
// Callback to allow plugin to add elements to top-level GUI (such as menu items)
virtual bool createTopLevelGUI(QMainWindow* mainWindow)
virtual bool createTopLevelGUI()
{
return true;
}

Wyświetl plik

@ -266,7 +266,7 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
PluginAPI::MiscPluginRegistrations *miscPluginRegistrations = m_pluginManager->getMiscPluginRegistrations();
for (int i = 0; i < miscPluginRegistrations->count(); i++)
{
(*miscPluginRegistrations)[i].m_plugin->createTopLevelGUI(this);
(*miscPluginRegistrations)[i].m_plugin->createTopLevelGUI();
}
qDebug() << "MainWindow::MainWindow: end";

Wyświetl plik

@ -103,6 +103,8 @@ public:
std::vector<DeviceUISet*>& getDeviceUISets() { return m_deviceUIs; }
void commandKeysConnect(QObject *object, const char *slot);
void commandKeysDisconnect(QObject *object, const char *slot);
const QString& getAPIHost() const { return m_apiHost; }
int getAPIPort() const { return m_apiPort; }
friend class WebAPIAdapterGUI;

Wyświetl plik

@ -82,6 +82,8 @@ MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, Q
m_apiAdapter = new WebAPIAdapterSrv(*this);
m_requestMapper = new WebAPIRequestMapper(this);
m_requestMapper->setAdapter(m_apiAdapter);
m_apiHost = parser.getServerAddress();
m_apiPort = parser.getServerPort();
m_apiServer = new WebAPIServer(parser.getServerAddress(), parser.getServerPort(), m_requestMapper);
m_apiServer->start();

Wyświetl plik

@ -68,6 +68,9 @@ public:
void addChannel(int deviceSetIndex, int selectedChannelIndex);
void deleteChannel(int deviceSetIndex, int channelIndex);
const QString& getAPIHost() const { return m_apiHost; }
int getAPIPort() const { return m_apiPort; }
friend class WebAPIAdapterSrv;
signals:
@ -288,6 +291,8 @@ private:
DSPEngine* m_dspEngine;
int m_lastEngineState;
qtwebapp::LoggerWithFile *m_logger;
QString m_apiHost;
int m_apiPort;
MessageQueue m_inputMessageQueue;
QTimer m_masterTimer;