mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-25 03:24:18 -04:00
REST API device and channel actions: extension of record action: implementation
This commit is contained in:
@@ -287,6 +287,23 @@ bool KiwiSDRGui::handleMessage(const Message& message)
|
||||
m_statusColors[status] + "; border-radius: 7px; }");
|
||||
return true;
|
||||
}
|
||||
else if (KiwiSDRInput::MsgFileRecord::match(message)) // API action "record" feedback
|
||||
{
|
||||
const KiwiSDRInput::MsgFileRecord& notif = (const KiwiSDRInput::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;
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
#include "SWGDeviceReport.h"
|
||||
#include "SWGDeviceActions.h"
|
||||
#include "SWGKiwiSDRReport.h"
|
||||
#include "SWGKiwiSDRActions.h"
|
||||
|
||||
#include "kiwisdrinput.h"
|
||||
#include "device/deviceapi.h"
|
||||
@@ -444,6 +446,37 @@ int KiwiSDRInput::webapiReportGet(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int KiwiSDRInput::webapiActionsPost(
|
||||
const QStringList& deviceActionsKeys,
|
||||
SWGSDRangel::SWGDeviceActions& query,
|
||||
QString& errorMessage)
|
||||
{
|
||||
SWGSDRangel::SWGKiwiSDRActions *swgKiwiSDRActions = query.getKiwiSdrActions();
|
||||
|
||||
if (swgKiwiSDRActions)
|
||||
{
|
||||
if (deviceActionsKeys.contains("record"))
|
||||
{
|
||||
bool record = swgKiwiSDRActions->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 KiwiSDRInputActions in query";
|
||||
return 400;
|
||||
}
|
||||
}
|
||||
|
||||
void KiwiSDRInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const KiwiSDRSettings& settings)
|
||||
{
|
||||
response.getKiwiSdrSettings()->setGain(settings.m_gain);
|
||||
|
||||
@@ -160,6 +160,11 @@ public:
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiActionsPost(
|
||||
const QStringList& deviceActionsKeys,
|
||||
SWGSDRangel::SWGDeviceActions& actions,
|
||||
QString& errorMessage);
|
||||
|
||||
static void webapiFormatDeviceSettings(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const KiwiSDRSettings& settings);
|
||||
|
||||
Reference in New Issue
Block a user