1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 14:04:46 -04:00

REST API device and channel actions: extension of record action: implementation

This commit is contained in:
f4exb
2020-03-10 05:23:19 +01:00
parent beee7a7a78
commit 18aa9ffbc2
49 changed files with 995 additions and 3 deletions
@@ -29,7 +29,9 @@
#include "SWGLimeSdrInputSettings.h"
#include "SWGDeviceState.h"
#include "SWGDeviceReport.h"
#include "SWGDeviceActions.h"
#include "SWGLimeSdrInputReport.h"
#include "SWGLimeSdrInputActions.h"
#include "device/deviceapi.h"
#include "dsp/dspcommands.h"
@@ -1631,6 +1633,37 @@ int LimeSDRInput::webapiRun(
return 200;
}
int LimeSDRInput::webapiActionsPost(
const QStringList& deviceActionsKeys,
SWGSDRangel::SWGDeviceActions& query,
QString& errorMessage)
{
SWGSDRangel::SWGLimeSdrInputActions *swgLimeSdrInputActions = query.getLimeSdrInputActions();
if (swgLimeSdrInputActions)
{
if (deviceActionsKeys.contains("record"))
{
bool record = swgLimeSdrInputActions->getRecord() != 0;
MsgFileRecord *msg = MsgFileRecord::create(record);
getInputMessageQueue()->push(msg);
if (getMessageQueueToGUI())
{
MsgFileRecord *msgToGUI = MsgFileRecord::create(record);
getMessageQueueToGUI()->push(msgToGUI);
}
}
return 202;
}
else
{
errorMessage = "Missing LimeSdrInputActions in query";
return 400;
}
}
void LimeSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
{
bool success = false;
@@ -247,6 +247,11 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
virtual int webapiActionsPost(
const QStringList& deviceActionsKeys,
SWGSDRangel::SWGDeviceActions& actions,
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const LimeSDRInputSettings& settings);
@@ -256,6 +256,23 @@ bool LimeSDRInputGUI::handleMessage(const Message& message)
return true;
}
else if (LimeSDRInput::MsgFileRecord::match(message)) // API action "record" feedback
{
const LimeSDRInput::MsgFileRecord& notif = (const LimeSDRInput::MsgFileRecord&) message;
bool record = notif.getStartStop();
ui->record->blockSignals(true);
ui->record->setChecked(record);
if (record) {
ui->record->setStyleSheet("QToolButton { background-color : red; }");
} else {
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
ui->record->blockSignals(false);
return true;
}
else
{
return false;