mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
RigCtrl plugin: Removed QMainWindow dependency in plugin interface. Get API URI from MainWindow. Cosmetic changes
This commit is contained in:
parent
40bd691a45
commit
d9ec9f2787
@ -45,7 +45,7 @@ target_link_libraries(${TARGET_NAME}
|
|||||||
Qt5::Core
|
Qt5::Core
|
||||||
${TARGET_LIB}
|
${TARGET_LIB}
|
||||||
sdrbase
|
sdrbase
|
||||||
${TARGET_LIB_GUI}
|
${TARGET_LIB_GUI}
|
||||||
swagger
|
swagger
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
|
||||||
// Length of buffers
|
// Length of buffers
|
||||||
#define CMD_LENGTH 1024
|
const unsigned int RigCtrl::m_CmdLength = 1024;
|
||||||
#define URL_LENGTH 1024
|
const unsigned int RigCtrl::m_UrlLength = 1024;
|
||||||
#define RESPONSE_LENGTH 1024
|
const unsigned int RigCtrl::m_ResponseLength = 1024;
|
||||||
#define DATA_LENGTH 1024
|
const unsigned int RigCtrl::m_DataLength = 1024;
|
||||||
|
|
||||||
// Hamlib rigctrl error codes
|
// Hamlib rigctrl error codes
|
||||||
enum rig_errcode_e {
|
enum rig_errcode_e {
|
||||||
@ -194,9 +194,9 @@ void RigCtrl::acceptConnection()
|
|||||||
// Get rigctrl command and start processing it
|
// Get rigctrl command and start processing it
|
||||||
void RigCtrl::getCommand()
|
void RigCtrl::getCommand()
|
||||||
{
|
{
|
||||||
char cmd[CMD_LENGTH];
|
char cmd[m_CmdLength];
|
||||||
char url[URL_LENGTH];
|
char url[m_UrlLength];
|
||||||
char response[RESPONSE_LENGTH];
|
char response[m_ResponseLength];
|
||||||
qint64 len;
|
qint64 len;
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
char *p;
|
char *p;
|
||||||
@ -211,13 +211,13 @@ void RigCtrl::getCommand()
|
|||||||
// Set frequency
|
// Set frequency
|
||||||
m_targetFrequency = atof(cmd[0] == 'F' ? &cmd[2] : &cmd[9]);
|
m_targetFrequency = atof(cmd[0] == 'F' ? &cmd[2] : &cmd[9]);
|
||||||
// Get current centre frequency
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->get(request);
|
m_netman->get(request);
|
||||||
m_state = set_freq;
|
m_state = set_freq;
|
||||||
} else if (!strncmp(cmd, "f", 1) || !strncmp(cmd, "get_freq", 8)) {
|
} else if (!strncmp(cmd, "f", 1) || !strncmp(cmd, "get_freq", 8)) {
|
||||||
// Get frequency - need to add centerFrequency and inputFrequencyOffset
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->get(request);
|
m_netman->get(request);
|
||||||
m_state = get_freq_center;
|
m_state = get_freq_center;
|
||||||
@ -253,7 +253,7 @@ void RigCtrl::getCommand()
|
|||||||
}
|
}
|
||||||
if (mode_map[i].modem != nullptr) {
|
if (mode_map[i].modem != nullptr) {
|
||||||
// Delete current modem
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->sendCustomRequest(request, "DELETE");
|
m_netman->sendCustomRequest(request, "DELETE");
|
||||||
m_state = set_mode_mod;
|
m_state = set_mode_mod;
|
||||||
@ -263,19 +263,19 @@ void RigCtrl::getCommand()
|
|||||||
}
|
}
|
||||||
} else if (!strncmp(cmd, "set_powerstat 0", 15)) {
|
} else if (!strncmp(cmd, "set_powerstat 0", 15)) {
|
||||||
// Power off radio
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->sendCustomRequest(request, "DELETE");
|
m_netman->sendCustomRequest(request, "DELETE");
|
||||||
m_state = set_power_off;
|
m_state = set_power_off;
|
||||||
} else if (!strncmp(cmd, "set_powerstat 1", 15)) {
|
} else if (!strncmp(cmd, "set_powerstat 1", 15)) {
|
||||||
// Power on radio
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->post(request, "");
|
m_netman->post(request, "");
|
||||||
m_state = set_power_on;
|
m_state = set_power_on;
|
||||||
} else if (!strncmp(cmd, "get_powerstat", 13)) {
|
} else if (!strncmp(cmd, "get_powerstat", 13)) {
|
||||||
// Return if powered on or off
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->get(request);
|
m_netman->get(request);
|
||||||
m_state = get_power;
|
m_state = get_power;
|
||||||
@ -292,9 +292,9 @@ void RigCtrl::getCommand()
|
|||||||
void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
double freq;
|
double freq;
|
||||||
char response[RESPONSE_LENGTH];
|
char response[m_ResponseLength];
|
||||||
char url[URL_LENGTH];
|
char url[m_UrlLength];
|
||||||
char data[DATA_LENGTH];
|
char data[m_DataLength];
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
@ -311,7 +311,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
freq = getSubObjectDouble(jsonObj, "centerFrequency");
|
freq = getSubObjectDouble(jsonObj, "centerFrequency");
|
||||||
if (freq >= 0.0) {
|
if (freq >= 0.0) {
|
||||||
m_targetFrequency = freq;
|
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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->get(request);
|
m_netman->get(request);
|
||||||
} else {
|
} else {
|
||||||
@ -333,7 +333,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
if (fabs(freq - m_targetFrequency) > m_settings.m_maxFrequencyOffset) {
|
if (fabs(freq - m_targetFrequency) > m_settings.m_maxFrequencyOffset) {
|
||||||
// Update centerFrequency
|
// Update centerFrequency
|
||||||
setSubObjectDouble(jsonObj, "centerFrequency", m_targetFrequency);
|
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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
|
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
|
||||||
m_state = set_freq_center;
|
m_state = set_freq_center;
|
||||||
@ -341,7 +341,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
// In range, so update inputFrequencyOffset
|
// In range, so update inputFrequencyOffset
|
||||||
m_targetOffset = m_targetFrequency - freq;
|
m_targetOffset = m_targetFrequency - freq;
|
||||||
// Get settings containg inputFrequencyOffset, so we can patch them
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->get(request);
|
m_netman->get(request);
|
||||||
m_state = set_freq_set_offset;
|
m_state = set_freq_set_offset;
|
||||||
@ -351,7 +351,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
case set_freq_no_offset:
|
case set_freq_no_offset:
|
||||||
// Update centerFrequency, without trying to set offset
|
// Update centerFrequency, without trying to set offset
|
||||||
setSubObjectDouble(jsonObj, "centerFrequency", m_targetFrequency);
|
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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
|
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
|
||||||
m_state = set_freq_center_no_offset;
|
m_state = set_freq_center_no_offset;
|
||||||
@ -363,7 +363,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
if (freq == m_targetFrequency) {
|
if (freq == m_targetFrequency) {
|
||||||
// Set inputFrequencyOffset to 0
|
// Set inputFrequencyOffset to 0
|
||||||
m_targetOffset = 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->get(request);
|
m_netman->get(request);
|
||||||
m_state = set_freq_set_offset;
|
m_state = set_freq_set_offset;
|
||||||
@ -389,7 +389,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
case set_freq_set_offset:
|
case set_freq_set_offset:
|
||||||
// Patch inputFrequencyOffset
|
// Patch inputFrequencyOffset
|
||||||
if (setSubObjectDouble(jsonObj, "inputFrequencyOffset", m_targetOffset)) {
|
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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
|
m_netman->sendCustomRequest(request, "PATCH", QJsonDocument(jsonObj).toJson());
|
||||||
m_state = set_freq_offset;
|
m_state = set_freq_offset;
|
||||||
@ -414,7 +414,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
|
|
||||||
case set_mode_mod:
|
case set_mode_mod:
|
||||||
// Create new modem
|
// 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);
|
sprintf(data, "{ \"channelType\": \"%s\", \"direction\": 0, \"originatorDeviceSetIndex\": %d}\n", m_targetModem, m_settings.m_deviceIndex);
|
||||||
request.setUrl(QUrl(url));
|
request.setUrl(QUrl(url));
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
|
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
|
||||||
@ -428,7 +428,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
|
|
||||||
case set_mode_settings:
|
case set_mode_settings:
|
||||||
// Set modem bandwidth
|
// 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);
|
sprintf(data, "{ \"channelType\": \"%s\", \"%sSettings\": {\"rfBandwidth\":%d}}\n", m_targetModem, m_targetModem, m_targetBW);
|
||||||
request.setUrl(QUrl(url));
|
request.setUrl(QUrl(url));
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
|
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
|
||||||
@ -476,7 +476,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
case set_freq_set_offset:
|
case set_freq_set_offset:
|
||||||
// Probably no demodulator enabled on the specified channel
|
// Probably no demodulator enabled on the specified channel
|
||||||
// Just set as center frequency
|
// 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));
|
request.setUrl(QUrl(url));
|
||||||
m_netman->get(request);
|
m_netman->get(request);
|
||||||
m_state = set_freq_no_offset;
|
m_state = set_freq_no_offset;
|
||||||
@ -484,7 +484,7 @@ void RigCtrl::processAPIResponse(QNetworkReply *reply)
|
|||||||
|
|
||||||
case set_mode_mod:
|
case set_mode_mod:
|
||||||
// Probably no modem on channel to delete, so continue to try to create one
|
// 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);
|
sprintf(data, "{ \"channelType\": \"%s\", \"direction\": 0, \"originatorDeviceSetIndex\": %d}\n", m_targetModem, m_settings.m_deviceIndex);
|
||||||
request.setUrl(QUrl(url));
|
request.setUrl(QUrl(url));
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
|
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
~RigCtrl();
|
~RigCtrl();
|
||||||
void getSettings(RigCtrlSettings *settings);
|
void getSettings(RigCtrlSettings *settings);
|
||||||
void setSettings(RigCtrlSettings *settings);
|
void setSettings(RigCtrlSettings *settings);
|
||||||
|
void setAPIBaseURI(const QString& apiBaseURI) { m_APIBaseURI = apiBaseURI; }
|
||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
bool deserialize(const QByteArray& data);
|
bool deserialize(const QByteArray& data);
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ private slots:
|
|||||||
void getCommand();
|
void getCommand();
|
||||||
void processAPIResponse(QNetworkReply *reply);
|
void processAPIResponse(QNetworkReply *reply);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
QTcpServer *m_tcpServer;
|
QTcpServer *m_tcpServer;
|
||||||
QTcpSocket *m_clientConnection;
|
QTcpSocket *m_clientConnection;
|
||||||
QNetworkAccessManager *m_netman;
|
QNetworkAccessManager *m_netman;
|
||||||
@ -60,8 +61,14 @@ protected:
|
|||||||
double m_targetOffset;
|
double m_targetOffset;
|
||||||
const char *m_targetModem;
|
const char *m_targetModem;
|
||||||
int m_targetBW;
|
int m_targetBW;
|
||||||
|
QString m_APIBaseURI; //!< Base URI of own API
|
||||||
|
|
||||||
RigCtrlSettings m_settings;
|
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
|
#endif // INCLUDE_RIGCTRL_H
|
||||||
|
@ -27,7 +27,6 @@ RigCtrlGUI::RigCtrlGUI(RigCtrl *rigCtrl, QWidget* parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
m_rigCtrl->getSettings(&m_settings);
|
m_rigCtrl->getSettings(&m_settings);
|
||||||
ui->enable->setChecked(m_settings.m_enabled);
|
ui->enable->setChecked(m_settings.m_enabled);
|
||||||
ui->api->setText(QString(m_settings.m_APIAddress));
|
|
||||||
ui->rigCtrlPort->setValue(m_settings.m_rigCtrlPort);
|
ui->rigCtrlPort->setValue(m_settings.m_rigCtrlPort);
|
||||||
ui->maxFrequencyOffset->setValue(m_settings.m_maxFrequencyOffset);
|
ui->maxFrequencyOffset->setValue(m_settings.m_maxFrequencyOffset);
|
||||||
ui->deviceIndex->setValue(m_settings.m_deviceIndex);
|
ui->deviceIndex->setValue(m_settings.m_deviceIndex);
|
||||||
@ -42,7 +41,6 @@ RigCtrlGUI::~RigCtrlGUI()
|
|||||||
void RigCtrlGUI::accept()
|
void RigCtrlGUI::accept()
|
||||||
{
|
{
|
||||||
m_settings.m_enabled = ui->enable->isChecked();
|
m_settings.m_enabled = ui->enable->isChecked();
|
||||||
m_settings.m_APIAddress = ui->api->text();
|
|
||||||
m_settings.m_rigCtrlPort = ui->rigCtrlPort->value();
|
m_settings.m_rigCtrlPort = ui->rigCtrlPort->value();
|
||||||
m_settings.m_maxFrequencyOffset = ui->maxFrequencyOffset->value();
|
m_settings.m_maxFrequencyOffset = ui->maxFrequencyOffset->value();
|
||||||
m_settings.m_deviceIndex = ui->deviceIndex->value();
|
m_settings.m_deviceIndex = ui->deviceIndex->value();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>351</width>
|
<width>351</width>
|
||||||
<height>235</height>
|
<height>261</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
@ -33,69 +33,35 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="rigCtrlPortLabel">
|
<widget class="QLabel" name="rigCtrlPortLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>rigctrl Port</string>
|
<string>rigctrl Port</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="api">
|
<widget class="QSpinBox" name="rigCtrlPort">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>URL of SDRangel API server to control.
|
<string>TCP port to listen for rigctrl commands on.
|
||||||
Default is http://127.0.0.1:8091/sdrangel</string>
|
Default is 4532.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="minimum">
|
||||||
<string>http://127.0.0.1:8091/sdrangel</string>
|
<number>1024</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>65536</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="maxFrequencyOffsetLabel">
|
<widget class="QLabel" name="maxFrequencyOffsetLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Max Frequency Offset</string>
|
<string>Max Frequency Offset</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="maxFrequencyOffset">
|
<widget class="QSpinBox" name="maxFrequencyOffset">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Controls whether the center frequency or frequency offset is adjusted when a new frequency is received via a rigctrl command.
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="0">
|
||||||
<widget class="QSpinBox" name="rigCtrlPort">
|
<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">
|
<property name="toolTip">
|
||||||
<string>TCP port to listen for rigctrl commands on.
|
<string>Index of the device that should be controlled by rigctrl commands.
|
||||||
Default is 4532.</string>
|
Default is 0.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
</widget>
|
||||||
<number>1024</number>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="channelIndexLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Channel Index</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
</widget>
|
||||||
<number>65536</number>
|
</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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <QtWidgets/QMainWindow>
|
#include <QtWidgets/QMainWindow>
|
||||||
#include <QtWidgets/QMenu>
|
#include <QtWidgets/QMenu>
|
||||||
#include <QtWidgets/QMenuBar>
|
#include <QtWidgets/QMenuBar>
|
||||||
|
#include "mainwindow.h"
|
||||||
#include "rigctrlgui.h"
|
#include "rigctrlgui.h"
|
||||||
#endif
|
#endif
|
||||||
#include "rigctrlplugin.h"
|
#include "rigctrlplugin.h"
|
||||||
@ -62,10 +63,8 @@ void RigCtrlPlugin::initPlugin(PluginAPI* pluginAPI)
|
|||||||
|
|
||||||
#ifdef SERVER_MODE
|
#ifdef SERVER_MODE
|
||||||
bool RigCtrlPlugin::createTopLevelGUI(
|
bool RigCtrlPlugin::createTopLevelGUI(
|
||||||
QMainWindow* mainWindow
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(void) mainWindow;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,12 +73,11 @@ void RigCtrlPlugin::showRigCtrlUI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
bool RigCtrlPlugin::createTopLevelGUI(
|
bool RigCtrlPlugin::createTopLevelGUI()
|
||||||
QMainWindow* mainWindow
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
m_mainWindow = mainWindow;
|
m_mainWindow = MainWindow::getInstance();
|
||||||
QMenuBar *menuBar = mainWindow->menuBar();
|
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);
|
QMenu *prefMenu = menuBar->findChild<QMenu *>("menuPreferences", Qt::FindDirectChildrenOnly);
|
||||||
if (prefMenu == nullptr) {
|
if (prefMenu == nullptr) {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "rigctrl.h"
|
#include "rigctrl.h"
|
||||||
|
|
||||||
class PluginAPI;
|
class PluginAPI;
|
||||||
class QMainWindow;
|
class MainWindow;
|
||||||
|
|
||||||
#define RIGCTRL_DEVICE_TYPE_ID "sdrangel.misc.rigctrl"
|
#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)
|
Q_PLUGIN_METADATA(IID RIGCTRL_DEVICE_TYPE_ID)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RigCtrlPlugin(RigCtrl *rigCtrl = NULL, QObject* parent = NULL);
|
explicit RigCtrlPlugin(RigCtrl *rigCtrl = nullptr, QObject* parent = nullptr);
|
||||||
|
|
||||||
const PluginDescriptor& getPluginDescriptor() const;
|
const PluginDescriptor& getPluginDescriptor() const;
|
||||||
void initPlugin(PluginAPI* pluginAPI);
|
void initPlugin(PluginAPI* pluginAPI);
|
||||||
|
|
||||||
virtual bool createTopLevelGUI(QMainWindow* mainWindow);
|
virtual bool createTopLevelGUI();
|
||||||
virtual QByteArray serializeGlobalSettings() const;
|
virtual QByteArray serializeGlobalSettings() const;
|
||||||
virtual bool deserializeGlobalSettings(const QByteArray& data);
|
virtual bool deserializeGlobalSettings(const QByteArray& data);
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static const PluginDescriptor m_pluginDescriptor;
|
static const PluginDescriptor m_pluginDescriptor;
|
||||||
QMainWindow* m_mainWindow;
|
MainWindow* m_mainWindow;
|
||||||
RigCtrl *m_rigCtrl;
|
RigCtrl *m_rigCtrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,21 +21,20 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
|
|
||||||
#define ENABLED_DEFAULT false
|
const bool RigCtrlSettings::m_EnabledDefault = false;
|
||||||
#define API_ADDRESS_DEFAULT "http://127.0.0.1:8091/sdrangel"
|
const int RigCtrlSettings::m_RigCtrlPortDefault = 4532;
|
||||||
#define RIG_CTRL_PORT_DEFAULT 4532
|
const int RigCtrlSettings::m_MaxFrequencyOffsetDefault = 10000;
|
||||||
#define MAX_FREQUENCY_OFFSET_DEFAULT 10000
|
const int RigCtrlSettings::m_DeviceIndexDefault = 0;
|
||||||
#define DEVICE_INDEX_DEFAULT 0
|
const int RigCtrlSettings::m_ChannelIndexDefault = 0;
|
||||||
#define CHANNEL_INDEX_DEFAULT 0
|
|
||||||
|
|
||||||
void RigCtrlSettings::resetToDefaults()
|
void RigCtrlSettings::resetToDefaults()
|
||||||
{
|
{
|
||||||
m_enabled = ENABLED_DEFAULT;
|
m_enabled = m_EnabledDefault;
|
||||||
m_APIAddress = API_ADDRESS_DEFAULT;
|
m_rigCtrlPort = m_RigCtrlPortDefault;
|
||||||
m_rigCtrlPort = RIG_CTRL_PORT_DEFAULT;
|
m_maxFrequencyOffset = m_MaxFrequencyOffsetDefault;
|
||||||
m_maxFrequencyOffset = MAX_FREQUENCY_OFFSET_DEFAULT;
|
m_deviceIndex = m_DeviceIndexDefault;
|
||||||
m_deviceIndex = DEVICE_INDEX_DEFAULT;
|
m_channelIndex = m_ChannelIndexDefault;
|
||||||
m_channelIndex = CHANNEL_INDEX_DEFAULT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RigCtrlSettings::serialize() const
|
QByteArray RigCtrlSettings::serialize() const
|
||||||
@ -43,7 +42,6 @@ QByteArray RigCtrlSettings::serialize() const
|
|||||||
SimpleSerializer s(1);
|
SimpleSerializer s(1);
|
||||||
|
|
||||||
s.writeBool(1, m_enabled);
|
s.writeBool(1, m_enabled);
|
||||||
s.writeString(2, m_APIAddress);
|
|
||||||
s.writeS32(3, m_rigCtrlPort);
|
s.writeS32(3, m_rigCtrlPort);
|
||||||
s.writeS32(4, m_maxFrequencyOffset);
|
s.writeS32(4, m_maxFrequencyOffset);
|
||||||
s.writeS32(5, m_deviceIndex);
|
s.writeS32(5, m_deviceIndex);
|
||||||
@ -64,28 +62,27 @@ bool RigCtrlSettings::deserialize(const QByteArray& data)
|
|||||||
|
|
||||||
if (d.getVersion() == 1)
|
if (d.getVersion() == 1)
|
||||||
{
|
{
|
||||||
d.readBool(1, &m_enabled, ENABLED_DEFAULT);
|
d.readBool(1, &m_enabled, m_EnabledDefault);
|
||||||
d.readString(2, &m_APIAddress, API_ADDRESS_DEFAULT);
|
d.readS32(3, &m_rigCtrlPort, m_RigCtrlPortDefault);
|
||||||
d.readS32(3, &m_rigCtrlPort, RIG_CTRL_PORT_DEFAULT);
|
d.readS32(4, &m_maxFrequencyOffset, m_MaxFrequencyOffsetDefault);
|
||||||
d.readS32(4, &m_maxFrequencyOffset, MAX_FREQUENCY_OFFSET_DEFAULT);
|
d.readS32(5, &m_deviceIndex, m_DeviceIndexDefault);
|
||||||
d.readS32(5, &m_deviceIndex, DEVICE_INDEX_DEFAULT);
|
d.readS32(6, &m_channelIndex, m_ChannelIndexDefault);
|
||||||
d.readS32(6, &m_channelIndex, CHANNEL_INDEX_DEFAULT);
|
|
||||||
|
|
||||||
if (!((m_rigCtrlPort > 1023) && (m_rigCtrlPort < 65536))) {
|
if (!((m_rigCtrlPort > 1023) && (m_rigCtrlPort < 65536))) {
|
||||||
qDebug() << "RigCtrlSettings::deserialize invalid port number ignored";
|
qDebug() << "RigCtrlSettings::deserialize invalid port number ignored";
|
||||||
m_rigCtrlPort = RIG_CTRL_PORT_DEFAULT;
|
m_rigCtrlPort = m_RigCtrlPortDefault;
|
||||||
}
|
}
|
||||||
if (m_maxFrequencyOffset < 0) {
|
if (m_maxFrequencyOffset < 0) {
|
||||||
qDebug() << "RigCtrlSettings::deserialize invalid max frequency offset ignored";
|
qDebug() << "RigCtrlSettings::deserialize invalid max frequency offset ignored";
|
||||||
m_maxFrequencyOffset = MAX_FREQUENCY_OFFSET_DEFAULT;
|
m_maxFrequencyOffset = m_MaxFrequencyOffsetDefault;
|
||||||
}
|
}
|
||||||
if (m_deviceIndex < 0) {
|
if (m_deviceIndex < 0) {
|
||||||
qDebug() << "RigCtrlSettings::deserialize invalid device index ignored";
|
qDebug() << "RigCtrlSettings::deserialize invalid device index ignored";
|
||||||
m_deviceIndex = DEVICE_INDEX_DEFAULT;
|
m_deviceIndex = m_DeviceIndexDefault;
|
||||||
}
|
}
|
||||||
if (m_channelIndex < 0) {
|
if (m_channelIndex < 0) {
|
||||||
qDebug() << "RigCtrlSettings::deserialize invalid channel index ignored";
|
qDebug() << "RigCtrlSettings::deserialize invalid channel index ignored";
|
||||||
m_deviceIndex = CHANNEL_INDEX_DEFAULT;
|
m_deviceIndex = m_ChannelIndexDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
struct RigCtrlSettings {
|
struct RigCtrlSettings {
|
||||||
|
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
QString m_APIAddress;
|
|
||||||
int m_rigCtrlPort;
|
int m_rigCtrlPort;
|
||||||
int m_maxFrequencyOffset;
|
int m_maxFrequencyOffset;
|
||||||
int m_deviceIndex;
|
int m_deviceIndex;
|
||||||
@ -37,6 +36,13 @@ struct RigCtrlSettings {
|
|||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
bool deserialize(const QByteArray& data);
|
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 */
|
#endif /* INCLUDE_RIGCTRLSETTINGS_H */
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
|
|
||||||
class QMainWindow;
|
|
||||||
|
|
||||||
struct SDRBASE_API PluginDescriptor {
|
struct SDRBASE_API PluginDescriptor {
|
||||||
const QString hardwareId;
|
const QString hardwareId;
|
||||||
// general plugin description
|
// general plugin description
|
||||||
@ -314,7 +312,7 @@ public:
|
|||||||
virtual void deleteSampleMIMOPluginInstanceMIMO(DeviceSampleMIMO *mimo);
|
virtual void deleteSampleMIMOPluginInstanceMIMO(DeviceSampleMIMO *mimo);
|
||||||
|
|
||||||
// Callback to allow plugin to add elements to top-level GUI (such as menu items)
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
|
|||||||
PluginAPI::MiscPluginRegistrations *miscPluginRegistrations = m_pluginManager->getMiscPluginRegistrations();
|
PluginAPI::MiscPluginRegistrations *miscPluginRegistrations = m_pluginManager->getMiscPluginRegistrations();
|
||||||
for (int i = 0; i < miscPluginRegistrations->count(); i++)
|
for (int i = 0; i < miscPluginRegistrations->count(); i++)
|
||||||
{
|
{
|
||||||
(*miscPluginRegistrations)[i].m_plugin->createTopLevelGUI(this);
|
(*miscPluginRegistrations)[i].m_plugin->createTopLevelGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: end";
|
qDebug() << "MainWindow::MainWindow: end";
|
||||||
|
@ -103,6 +103,8 @@ public:
|
|||||||
std::vector<DeviceUISet*>& getDeviceUISets() { return m_deviceUIs; }
|
std::vector<DeviceUISet*>& getDeviceUISets() { return m_deviceUIs; }
|
||||||
void commandKeysConnect(QObject *object, const char *slot);
|
void commandKeysConnect(QObject *object, const char *slot);
|
||||||
void commandKeysDisconnect(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;
|
friend class WebAPIAdapterGUI;
|
||||||
|
|
||||||
|
@ -82,6 +82,8 @@ MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, Q
|
|||||||
m_apiAdapter = new WebAPIAdapterSrv(*this);
|
m_apiAdapter = new WebAPIAdapterSrv(*this);
|
||||||
m_requestMapper = new WebAPIRequestMapper(this);
|
m_requestMapper = new WebAPIRequestMapper(this);
|
||||||
m_requestMapper->setAdapter(m_apiAdapter);
|
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 = new WebAPIServer(parser.getServerAddress(), parser.getServerPort(), m_requestMapper);
|
||||||
m_apiServer->start();
|
m_apiServer->start();
|
||||||
|
|
||||||
|
@ -68,6 +68,9 @@ public:
|
|||||||
void addChannel(int deviceSetIndex, int selectedChannelIndex);
|
void addChannel(int deviceSetIndex, int selectedChannelIndex);
|
||||||
void deleteChannel(int deviceSetIndex, int channelIndex);
|
void deleteChannel(int deviceSetIndex, int channelIndex);
|
||||||
|
|
||||||
|
const QString& getAPIHost() const { return m_apiHost; }
|
||||||
|
int getAPIPort() const { return m_apiPort; }
|
||||||
|
|
||||||
friend class WebAPIAdapterSrv;
|
friend class WebAPIAdapterSrv;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -288,6 +291,8 @@ private:
|
|||||||
DSPEngine* m_dspEngine;
|
DSPEngine* m_dspEngine;
|
||||||
int m_lastEngineState;
|
int m_lastEngineState;
|
||||||
qtwebapp::LoggerWithFile *m_logger;
|
qtwebapp::LoggerWithFile *m_logger;
|
||||||
|
QString m_apiHost;
|
||||||
|
int m_apiPort;
|
||||||
|
|
||||||
MessageQueue m_inputMessageQueue;
|
MessageQueue m_inputMessageQueue;
|
||||||
QTimer m_masterTimer;
|
QTimer m_masterTimer;
|
||||||
|
Loading…
Reference in New Issue
Block a user