1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Web API: file source settings getter (1)

This commit is contained in:
f4exb 2017-12-06 19:23:42 +01:00
parent d6b156a8d3
commit fc4627f82e
17 changed files with 2648 additions and 2965 deletions

View File

@ -21,6 +21,7 @@ set(filesource_FORMS
include_directories( include_directories(
. .
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
) )
#include(${QT_USE_FILE}) #include(${QT_USE_FILE})
@ -41,6 +42,7 @@ target_link_libraries(inputfilesource
${QT_LIBRARIES} ${QT_LIBRARIES}
sdrbase sdrbase
sdrgui sdrgui
swagger
) )
qt5_use_modules(inputfilesource Core Widgets) qt5_use_modules(inputfilesource Core Widgets)

View File

@ -20,6 +20,7 @@ QMAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
INCLUDEPATH += ../../../sdrbase INCLUDEPATH += ../../../sdrbase
INCLUDEPATH += ../../../sdrgui INCLUDEPATH += ../../../sdrgui
INCLUDEPATH += ../../../swagger/sdrangel/code/qt5/client
CONFIG(Release):build_subdir = release CONFIG(Release):build_subdir = release
CONFIG(Debug):build_subdir = debug CONFIG(Debug):build_subdir = debug
@ -38,5 +39,6 @@ FORMS += filesourcegui.ui
LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase
LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui
LIBS += -L../../../swagger/$${build_subdir} -lswagger
RESOURCES = ../../../sdrgui/resources/res.qrc RESOURCES = ../../../sdrgui/resources/res.qrc

View File

@ -1,292 +1,304 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB // // Copyright (C) 2015 Edouard Griffiths, F4EXB //
// // // //
// This program is free software; you can redistribute it and/or modify // // This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by // // it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or // // the Free Software Foundation as version 3 of the License, or //
// // // //
// This program is distributed in the hope that it will be useful, // // This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of // // but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. // // GNU General Public License V3 for more details. //
// // // //
// You should have received a copy of the GNU General Public License // // You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <QDebug> #include <QDebug>
#include "util/simpleserializer.h" #include "SWGDeviceSettings.h"
#include "dsp/dspcommands.h" #include "SWGFileSourceSettings.h"
#include "dsp/dspengine.h"
#include "dsp/filerecord.h" #include "util/simpleserializer.h"
#include "device/devicesourceapi.h" #include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "filesourcegui.h" #include "dsp/filerecord.h"
#include "filesourceinput.h" #include "device/devicesourceapi.h"
#include "filesourcethread.h"
#include "filesourcegui.h"
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSource, Message) #include "filesourceinput.h"
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceName, Message) #include "filesourcethread.h"
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceWork, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceSeek, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSource, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceStreamTiming, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceName, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceWork, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceSeek, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceStreamTiming, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Message)
FileSourceInput::Settings::Settings() : MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message)
m_fileName("./test.sdriq") MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message)
{
} FileSourceInput::Settings::Settings() :
m_fileName("./test.sdriq")
void FileSourceInput::Settings::resetToDefaults() {
{ }
m_fileName = "./test.sdriq";
} void FileSourceInput::Settings::resetToDefaults()
{
QByteArray FileSourceInput::Settings::serialize() const m_fileName = "./test.sdriq";
{ }
SimpleSerializer s(1);
s.writeString(1, m_fileName); QByteArray FileSourceInput::Settings::serialize() const
return s.final(); {
} SimpleSerializer s(1);
s.writeString(1, m_fileName);
bool FileSourceInput::Settings::deserialize(const QByteArray& data) return s.final();
{ }
SimpleDeserializer d(data);
bool FileSourceInput::Settings::deserialize(const QByteArray& data)
if(!d.isValid()) { {
resetToDefaults(); SimpleDeserializer d(data);
return false;
} if(!d.isValid()) {
resetToDefaults();
if(d.getVersion() == 1) { return false;
d.readString(1, &m_fileName, "./test.sdriq"); }
return true;
} else { if(d.getVersion() == 1) {
resetToDefaults(); d.readString(1, &m_fileName, "./test.sdriq");
return false; return true;
} } else {
} resetToDefaults();
return false;
FileSourceInput::FileSourceInput(DeviceSourceAPI *deviceAPI) : }
m_deviceAPI(deviceAPI), }
m_settings(),
m_fileSourceThread(NULL), FileSourceInput::FileSourceInput(DeviceSourceAPI *deviceAPI) :
m_deviceDescription(), m_deviceAPI(deviceAPI),
m_fileName("..."), m_settings(),
m_sampleRate(0), m_fileSourceThread(NULL),
m_centerFrequency(0), m_deviceDescription(),
m_recordLength(0), m_fileName("..."),
m_startingTimeStamp(0), m_sampleRate(0),
m_masterTimer(deviceAPI->getMasterTimer()) m_centerFrequency(0),
{ m_recordLength(0),
} m_startingTimeStamp(0),
m_masterTimer(deviceAPI->getMasterTimer())
FileSourceInput::~FileSourceInput() {
{ }
stop();
} FileSourceInput::~FileSourceInput()
{
void FileSourceInput::destroy() stop();
{ }
delete this;
} void FileSourceInput::destroy()
{
void FileSourceInput::openFileStream() delete this;
{ }
//stopInput();
void FileSourceInput::openFileStream()
if (m_ifstream.is_open()) { {
m_ifstream.close(); //stopInput();
}
if (m_ifstream.is_open()) {
m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate); m_ifstream.close();
quint64 fileSize = m_ifstream.tellg(); }
m_ifstream.seekg(0,std::ios_base::beg);
FileRecord::Header header; m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
FileRecord::readHeader(m_ifstream, header); quint64 fileSize = m_ifstream.tellg();
m_ifstream.seekg(0,std::ios_base::beg);
m_sampleRate = header.sampleRate; FileRecord::Header header;
m_centerFrequency = header.centerFrequency; FileRecord::readHeader(m_ifstream, header);
m_startingTimeStamp = header.startTimeStamp;
m_sampleRate = header.sampleRate;
if (fileSize > sizeof(FileRecord::Header)) { m_centerFrequency = header.centerFrequency;
m_recordLength = (fileSize - sizeof(FileRecord::Header)) / (4 * m_sampleRate); m_startingTimeStamp = header.startTimeStamp;
} else {
m_recordLength = 0; if (fileSize > sizeof(FileRecord::Header)) {
} m_recordLength = (fileSize - sizeof(FileRecord::Header)) / (4 * m_sampleRate);
} else {
qDebug() << "FileSourceInput::openFileStream: " << m_fileName.toStdString().c_str() m_recordLength = 0;
<< " fileSize: " << fileSize << "bytes" }
<< " length: " << m_recordLength << " seconds";
qDebug() << "FileSourceInput::openFileStream: " << m_fileName.toStdString().c_str()
MsgReportFileSourceStreamData *report = MsgReportFileSourceStreamData::create(m_sampleRate, << " fileSize: " << fileSize << "bytes"
m_centerFrequency, << " length: " << m_recordLength << " seconds";
m_startingTimeStamp,
m_recordLength); // file stream data MsgReportFileSourceStreamData *report = MsgReportFileSourceStreamData::create(m_sampleRate,
m_centerFrequency,
if (getMessageQueueToGUI()) { m_startingTimeStamp,
getMessageQueueToGUI()->push(report); m_recordLength); // file stream data
}
} if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(report);
void FileSourceInput::seekFileStream(int seekPercentage) }
{ }
QMutexLocker mutexLocker(&m_mutex);
void FileSourceInput::seekFileStream(int seekPercentage)
if ((m_ifstream.is_open()) && !m_fileSourceThread->isRunning()) {
{ QMutexLocker mutexLocker(&m_mutex);
int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
m_fileSourceThread->setSamplesCount(seekPoint); if ((m_ifstream.is_open()) && !m_fileSourceThread->isRunning())
seekPoint *= 4; // + sizeof(FileSink::Header) {
m_ifstream.clear(); int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg); m_fileSourceThread->setSamplesCount(seekPoint);
} seekPoint *= 4; // + sizeof(FileSink::Header)
} m_ifstream.clear();
m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg);
bool FileSourceInput::start() }
{ }
QMutexLocker mutexLocker(&m_mutex);
qDebug() << "FileSourceInput::start"; bool FileSourceInput::start()
{
if (m_ifstream.tellg() != 0) { QMutexLocker mutexLocker(&m_mutex);
m_ifstream.clear(); qDebug() << "FileSourceInput::start";
m_ifstream.seekg(sizeof(FileRecord::Header), std::ios::beg);
} if (m_ifstream.tellg() != 0) {
m_ifstream.clear();
if(!m_sampleFifo.setSize(m_sampleRate * 4)) { m_ifstream.seekg(sizeof(FileRecord::Header), std::ios::beg);
qCritical("Could not allocate SampleFifo"); }
return false;
} if(!m_sampleFifo.setSize(m_sampleRate * 4)) {
qCritical("Could not allocate SampleFifo");
//openFileStream(); return false;
}
if((m_fileSourceThread = new FileSourceThread(&m_ifstream, &m_sampleFifo)) == NULL) {
qFatal("out of memory"); //openFileStream();
stop();
return false; if((m_fileSourceThread = new FileSourceThread(&m_ifstream, &m_sampleFifo)) == NULL) {
} qFatal("out of memory");
stop();
m_fileSourceThread->setSamplerate(m_sampleRate); return false;
m_fileSourceThread->connectTimer(m_masterTimer); }
m_fileSourceThread->startWork();
m_deviceDescription = "FileSource"; m_fileSourceThread->setSamplerate(m_sampleRate);
m_fileSourceThread->connectTimer(m_masterTimer);
mutexLocker.unlock(); m_fileSourceThread->startWork();
//applySettings(m_generalSettings, m_settings, true); m_deviceDescription = "FileSource";
qDebug("FileSourceInput::startInput: started");
mutexLocker.unlock();
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(true); // acquisition on //applySettings(m_generalSettings, m_settings, true);
qDebug("FileSourceInput::startInput: started");
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(report); MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(true); // acquisition on
}
if (getMessageQueueToGUI()) {
return true; getMessageQueueToGUI()->push(report);
} }
void FileSourceInput::stop() return true;
{ }
qDebug() << "FileSourceInput::stop";
QMutexLocker mutexLocker(&m_mutex); void FileSourceInput::stop()
{
if(m_fileSourceThread != 0) qDebug() << "FileSourceInput::stop";
{ QMutexLocker mutexLocker(&m_mutex);
m_fileSourceThread->stopWork();
delete m_fileSourceThread; if(m_fileSourceThread != 0)
m_fileSourceThread = 0; {
} m_fileSourceThread->stopWork();
delete m_fileSourceThread;
m_deviceDescription.clear(); m_fileSourceThread = 0;
}
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(false); // acquisition off
m_deviceDescription.clear();
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(report); MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(false); // acquisition off
}
} if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(report);
const QString& FileSourceInput::getDeviceDescription() const }
{ }
return m_deviceDescription;
} const QString& FileSourceInput::getDeviceDescription() const
{
int FileSourceInput::getSampleRate() const return m_deviceDescription;
{ }
return m_sampleRate;
} int FileSourceInput::getSampleRate() const
{
quint64 FileSourceInput::getCenterFrequency() const return m_sampleRate;
{ }
return m_centerFrequency;
} quint64 FileSourceInput::getCenterFrequency() const
{
std::time_t FileSourceInput::getStartingTimeStamp() const return m_centerFrequency;
{ }
return m_startingTimeStamp;
} std::time_t FileSourceInput::getStartingTimeStamp() const
{
bool FileSourceInput::handleMessage(const Message& message) return m_startingTimeStamp;
{ }
if (MsgConfigureFileSourceName::match(message))
{ bool FileSourceInput::handleMessage(const Message& message)
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) message; {
m_fileName = conf.getFileName(); if (MsgConfigureFileSourceName::match(message))
openFileStream(); {
return true; MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) message;
} m_fileName = conf.getFileName();
else if (MsgConfigureFileSourceWork::match(message)) openFileStream();
{ return true;
MsgConfigureFileSourceWork& conf = (MsgConfigureFileSourceWork&) message; }
bool working = conf.isWorking(); else if (MsgConfigureFileSourceWork::match(message))
{
if (m_fileSourceThread != 0) MsgConfigureFileSourceWork& conf = (MsgConfigureFileSourceWork&) message;
{ bool working = conf.isWorking();
if (working)
{ if (m_fileSourceThread != 0)
m_fileSourceThread->startWork(); {
/* if (working)
MsgReportFileSourceStreamTiming *report = {
MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount()); m_fileSourceThread->startWork();
getOutputMessageQueueToGUI()->push(report);*/ /*
} MsgReportFileSourceStreamTiming *report =
else MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount());
{ getOutputMessageQueueToGUI()->push(report);*/
m_fileSourceThread->stopWork(); }
} else
} {
m_fileSourceThread->stopWork();
return true; }
} }
else if (MsgConfigureFileSourceSeek::match(message))
{ return true;
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) message; }
int seekPercentage = conf.getPercentage(); else if (MsgConfigureFileSourceSeek::match(message))
seekFileStream(seekPercentage); {
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) message;
return true; int seekPercentage = conf.getPercentage();
} seekFileStream(seekPercentage);
else if (MsgConfigureFileSourceStreamTiming::match(message))
{ return true;
MsgReportFileSourceStreamTiming *report; }
else if (MsgConfigureFileSourceStreamTiming::match(message))
if (m_fileSourceThread != 0) {
{ MsgReportFileSourceStreamTiming *report;
report = MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount());
if (m_fileSourceThread != 0)
if (getMessageQueueToGUI()) { {
getMessageQueueToGUI()->push(report); report = MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount());
}
} if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(report);
return true; }
} }
else
{ return true;
return false; }
} else
} {
return false;
}
}
int FileSourceInput::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage __attribute__((unused)))
{
response.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
*response.getFileSourceSettings()->getFileName() = m_settings.m_fileName;
return 200;
}

View File

@ -1,245 +1,249 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB // // Copyright (C) 2015 Edouard Griffiths, F4EXB //
// // // //
// This program is free software; you can redistribute it and/or modify // // This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by // // it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or // // the Free Software Foundation as version 3 of the License, or //
// // // //
// This program is distributed in the hope that it will be useful, // // This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of // // but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. // // GNU General Public License V3 for more details. //
// // // //
// You should have received a copy of the GNU General Public License // // You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FILESOURCEINPUT_H #ifndef INCLUDE_FILESOURCEINPUT_H
#define INCLUDE_FILESOURCEINPUT_H #define INCLUDE_FILESOURCEINPUT_H
#include <dsp/devicesamplesource.h> #include <dsp/devicesamplesource.h>
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
#include <ctime> #include <ctime>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
class FileSourceThread; class FileSourceThread;
class DeviceSourceAPI; class DeviceSourceAPI;
class FileSourceInput : public DeviceSampleSource { class FileSourceInput : public DeviceSampleSource {
public: public:
struct Settings { struct Settings {
QString m_fileName; QString m_fileName;
Settings(); Settings();
void resetToDefaults(); void resetToDefaults();
QByteArray serialize() const; QByteArray serialize() const;
bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data);
}; };
class MsgConfigureFileSource : public Message { class MsgConfigureFileSource : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
const Settings& getSettings() const { return m_settings; } const Settings& getSettings() const { return m_settings; }
static MsgConfigureFileSource* create(const Settings& settings) static MsgConfigureFileSource* create(const Settings& settings)
{ {
return new MsgConfigureFileSource(settings); return new MsgConfigureFileSource(settings);
} }
private: private:
Settings m_settings; Settings m_settings;
MsgConfigureFileSource(const Settings& settings) : MsgConfigureFileSource(const Settings& settings) :
Message(), Message(),
m_settings(settings) m_settings(settings)
{ } { }
}; };
class MsgConfigureFileSourceName : public Message { class MsgConfigureFileSourceName : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
const QString& getFileName() const { return m_fileName; } const QString& getFileName() const { return m_fileName; }
static MsgConfigureFileSourceName* create(const QString& fileName) static MsgConfigureFileSourceName* create(const QString& fileName)
{ {
return new MsgConfigureFileSourceName(fileName); return new MsgConfigureFileSourceName(fileName);
} }
private: private:
QString m_fileName; QString m_fileName;
MsgConfigureFileSourceName(const QString& fileName) : MsgConfigureFileSourceName(const QString& fileName) :
Message(), Message(),
m_fileName(fileName) m_fileName(fileName)
{ } { }
}; };
class MsgConfigureFileSourceWork : public Message { class MsgConfigureFileSourceWork : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
bool isWorking() const { return m_working; } bool isWorking() const { return m_working; }
static MsgConfigureFileSourceWork* create(bool working) static MsgConfigureFileSourceWork* create(bool working)
{ {
return new MsgConfigureFileSourceWork(working); return new MsgConfigureFileSourceWork(working);
} }
private: private:
bool m_working; bool m_working;
MsgConfigureFileSourceWork(bool working) : MsgConfigureFileSourceWork(bool working) :
Message(), Message(),
m_working(working) m_working(working)
{ } { }
}; };
class MsgConfigureFileSourceStreamTiming : public Message { class MsgConfigureFileSourceStreamTiming : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
static MsgConfigureFileSourceStreamTiming* create() static MsgConfigureFileSourceStreamTiming* create()
{ {
return new MsgConfigureFileSourceStreamTiming(); return new MsgConfigureFileSourceStreamTiming();
} }
private: private:
MsgConfigureFileSourceStreamTiming() : MsgConfigureFileSourceStreamTiming() :
Message() Message()
{ } { }
}; };
class MsgConfigureFileSourceSeek : public Message { class MsgConfigureFileSourceSeek : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
int getPercentage() const { return m_seekPercentage; } int getPercentage() const { return m_seekPercentage; }
static MsgConfigureFileSourceSeek* create(int seekPercentage) static MsgConfigureFileSourceSeek* create(int seekPercentage)
{ {
return new MsgConfigureFileSourceSeek(seekPercentage); return new MsgConfigureFileSourceSeek(seekPercentage);
} }
protected: protected:
int m_seekPercentage; //!< percentage of seek position from the beginning 0..100 int m_seekPercentage; //!< percentage of seek position from the beginning 0..100
MsgConfigureFileSourceSeek(int seekPercentage) : MsgConfigureFileSourceSeek(int seekPercentage) :
Message(), Message(),
m_seekPercentage(seekPercentage) m_seekPercentage(seekPercentage)
{ } { }
}; };
class MsgReportFileSourceAcquisition : public Message { class MsgReportFileSourceAcquisition : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
bool getAcquisition() const { return m_acquisition; } bool getAcquisition() const { return m_acquisition; }
static MsgReportFileSourceAcquisition* create(bool acquisition) static MsgReportFileSourceAcquisition* create(bool acquisition)
{ {
return new MsgReportFileSourceAcquisition(acquisition); return new MsgReportFileSourceAcquisition(acquisition);
} }
protected: protected:
bool m_acquisition; bool m_acquisition;
MsgReportFileSourceAcquisition(bool acquisition) : MsgReportFileSourceAcquisition(bool acquisition) :
Message(), Message(),
m_acquisition(acquisition) m_acquisition(acquisition)
{ } { }
}; };
class MsgReportFileSourceStreamData : public Message { class MsgReportFileSourceStreamData : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
int getSampleRate() const { return m_sampleRate; } int getSampleRate() const { return m_sampleRate; }
quint64 getCenterFrequency() const { return m_centerFrequency; } quint64 getCenterFrequency() const { return m_centerFrequency; }
std::time_t getStartingTimeStamp() const { return m_startingTimeStamp; } std::time_t getStartingTimeStamp() const { return m_startingTimeStamp; }
quint32 getRecordLength() const { return m_recordLength; } quint32 getRecordLength() const { return m_recordLength; }
static MsgReportFileSourceStreamData* create(int sampleRate, static MsgReportFileSourceStreamData* create(int sampleRate,
quint64 centerFrequency, quint64 centerFrequency,
std::time_t startingTimeStamp, std::time_t startingTimeStamp,
quint32 recordLength) quint32 recordLength)
{ {
return new MsgReportFileSourceStreamData(sampleRate, centerFrequency, startingTimeStamp, recordLength); return new MsgReportFileSourceStreamData(sampleRate, centerFrequency, startingTimeStamp, recordLength);
} }
protected: protected:
int m_sampleRate; int m_sampleRate;
quint64 m_centerFrequency; quint64 m_centerFrequency;
std::time_t m_startingTimeStamp; std::time_t m_startingTimeStamp;
quint32 m_recordLength; quint32 m_recordLength;
MsgReportFileSourceStreamData(int sampleRate, MsgReportFileSourceStreamData(int sampleRate,
quint64 centerFrequency, quint64 centerFrequency,
std::time_t startingTimeStamp, std::time_t startingTimeStamp,
quint32 recordLength) : quint32 recordLength) :
Message(), Message(),
m_sampleRate(sampleRate), m_sampleRate(sampleRate),
m_centerFrequency(centerFrequency), m_centerFrequency(centerFrequency),
m_startingTimeStamp(startingTimeStamp), m_startingTimeStamp(startingTimeStamp),
m_recordLength(recordLength) m_recordLength(recordLength)
{ } { }
}; };
class MsgReportFileSourceStreamTiming : public Message { class MsgReportFileSourceStreamTiming : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
public: public:
std::size_t getSamplesCount() const { return m_samplesCount; } std::size_t getSamplesCount() const { return m_samplesCount; }
static MsgReportFileSourceStreamTiming* create(std::size_t samplesCount) static MsgReportFileSourceStreamTiming* create(std::size_t samplesCount)
{ {
return new MsgReportFileSourceStreamTiming(samplesCount); return new MsgReportFileSourceStreamTiming(samplesCount);
} }
protected: protected:
std::size_t m_samplesCount; std::size_t m_samplesCount;
MsgReportFileSourceStreamTiming(std::size_t samplesCount) : MsgReportFileSourceStreamTiming(std::size_t samplesCount) :
Message(), Message(),
m_samplesCount(samplesCount) m_samplesCount(samplesCount)
{ } { }
}; };
FileSourceInput(DeviceSourceAPI *deviceAPI); FileSourceInput(DeviceSourceAPI *deviceAPI);
virtual ~FileSourceInput(); virtual ~FileSourceInput();
virtual void destroy(); virtual void destroy();
virtual bool start(); virtual bool start();
virtual void stop(); virtual void stop();
virtual const QString& getDeviceDescription() const; virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const; virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const; virtual quint64 getCenterFrequency() const;
std::time_t getStartingTimeStamp() const; std::time_t getStartingTimeStamp() const;
virtual bool handleMessage(const Message& message); virtual bool handleMessage(const Message& message);
private: virtual int webapiSettingsGet(
DeviceSourceAPI *m_deviceAPI; SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
QMutex m_mutex; QString& errorMessage);
Settings m_settings;
std::ifstream m_ifstream; private:
FileSourceThread* m_fileSourceThread; DeviceSourceAPI *m_deviceAPI;
QString m_deviceDescription; QMutex m_mutex;
QString m_fileName; Settings m_settings;
int m_sampleRate; std::ifstream m_ifstream;
quint64 m_centerFrequency; FileSourceThread* m_fileSourceThread;
quint32 m_recordLength; //!< record length in seconds computed from file size QString m_deviceDescription;
std::time_t m_startingTimeStamp; QString m_fileName;
const QTimer& m_masterTimer; int m_sampleRate;
quint64 m_centerFrequency;
void openFileStream(); quint32 m_recordLength; //!< record length in seconds computed from file size
void seekFileStream(int seekPercentage); std::time_t m_startingTimeStamp;
}; const QTimer& m_masterTimer;
#endif // INCLUDE_FILESOURCEINPUT_H void openFileStream();
void seekFileStream(int seekPercentage);
};
#endif // INCLUDE_FILESOURCEINPUT_H

View File

@ -27,7 +27,7 @@
namespace SWGSDRangel namespace SWGSDRangel
{ {
class SWGObject; class SWGDeviceSettings;
} }
class SDRANGEL_API DeviceSampleSink : public QObject { class SDRANGEL_API DeviceSampleSink : public QObject {
@ -47,7 +47,7 @@ public:
virtual bool handleMessage(const Message& message) = 0; virtual bool handleMessage(const Message& message) = 0;
virtual int webapiSettingsGet( virtual int webapiSettingsGet(
SWGSDRangel::SWGObject *response __attribute__((unused)), SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
QString& errorMessage) QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; } { errorMessage = "Not implemented"; return 501; }

View File

@ -27,7 +27,7 @@
namespace SWGSDRangel namespace SWGSDRangel
{ {
class SWGObject; class SWGDeviceSettings;
} }
class SDRANGEL_API DeviceSampleSource : public QObject { class SDRANGEL_API DeviceSampleSource : public QObject {
@ -47,7 +47,7 @@ public:
virtual bool handleMessage(const Message& message) = 0; virtual bool handleMessage(const Message& message) = 0;
virtual int webapiSettingsGet( virtual int webapiSettingsGet(
SWGSDRangel::SWGObject *response __attribute__((unused)), SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
QString& errorMessage) QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; } { errorMessage = "Not implemented"; return 501; }

File diff suppressed because it is too large Load Diff

View File

@ -604,6 +604,11 @@ void WebAPIRequestMapper::devicesetDeviceService(const std::string& indexStr, qt
else if (request.getMethod() == "GET") else if (request.getMethod() == "GET")
{ {
SWGSDRangel::SWGDeviceSettings normalResponse; SWGSDRangel::SWGDeviceSettings normalResponse;
normalResponse.cleanup();
normalResponse.setFileSourceSettings(0);
normalResponse.setRtlSdrSettings(0);
normalResponse.setLimeSdrInputSettings(0);
normalResponse.setLimeSdrOutputSettings(0);
int status = m_adapter->devicesetDeviceGet(deviceSetIndex, normalResponse, errorResponse); int status = m_adapter->devicesetDeviceGet(deviceSetIndex, normalResponse, errorResponse);
response.setStatus(status); response.setStatus(status);

View File

@ -705,13 +705,17 @@ int WebAPIAdapterGUI::devicesetDeviceGet(
if (deviceSet->m_deviceSourceEngine) // Rx if (deviceSet->m_deviceSourceEngine) // Rx
{ {
response.setDeviceHwType(new QString(deviceSet->m_deviceSourceAPI->getHardwareId()));
response.setTx(0);
DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource(); DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource();
return source->webapiSettingsGet(response.getData(), *error.getMessage()); return source->webapiSettingsGet(response, *error.getMessage());
} }
else if (deviceSet->m_deviceSinkEngine) // Tx else if (deviceSet->m_deviceSinkEngine) // Tx
{ {
response.setDeviceHwType(new QString(deviceSet->m_deviceSinkAPI->getHardwareId()));
response.setTx(1);
DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink(); DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink();
return sink->webapiSettingsGet(response.getData(), *error.getMessage()); return sink->webapiSettingsGet(response, *error.getMessage());
} }
else else
{ {

View File

@ -938,23 +938,22 @@ definitions:
$ref: "#/definitions/PresetIdentifier" $ref: "#/definitions/PresetIdentifier"
DeviceSettings: DeviceSettings:
description: Base device settings description: Base device settings
discriminator: deviceType discriminator: deviceHwType
required: required:
- deviceType - deviceHwType
- tx
properties: properties:
deviceType: deviceHwType:
description: Device hardware type code
type: string type: string
data: tx:
type: object description: Not zero if it is a tx device else it is a rx device
DeviceSettingsImpl: type: integer
description: dummy structure to handle all devices settings fileSourceSettings:
properties:
fileSource:
$ref: "http://localhost:8081/FileSource.yaml#/FileSourceSettings" $ref: "http://localhost:8081/FileSource.yaml#/FileSourceSettings"
rtlsdr: rtlSdrSettings:
$ref: "http://localhost:8081/RtlSdr.yaml#/RtlSdrSettings" $ref: "http://localhost:8081/RtlSdr.yaml#/RtlSdrSettings"
limesdrInput: limeSdrInputSettings:
$ref: "http://localhost:8081/LimeSdr.yaml#/LimeSdrInputSettings" $ref: "http://localhost:8081/LimeSdr.yaml#/LimeSdrInputSettings"
limesdrOutput: limeSdrOutputSettings:
$ref: "http://localhost:8081/LimeSdr.yaml#/LimeSdrOutputSettings" $ref: "http://localhost:8081/LimeSdr.yaml#/LimeSdrOutputSettings"

View File

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

File diff suppressed because it is too large Load Diff

View File

@ -37,19 +37,36 @@ SWGDeviceSettings::~SWGDeviceSettings() {
void void
SWGDeviceSettings::init() { SWGDeviceSettings::init() {
device_type = new QString(""); device_hw_type = new QString("");
data = NULL; tx = 0;
file_source_settings = new SWGFileSourceSettings();
rtl_sdr_settings = new SWGRtlSdrSettings();
lime_sdr_input_settings = new SWGLimeSdrInputSettings();
lime_sdr_output_settings = new SWGLimeSdrOutputSettings();
} }
void void
SWGDeviceSettings::cleanup() { SWGDeviceSettings::cleanup() {
if(device_type != nullptr) { if(device_hw_type != nullptr) {
delete device_type; delete device_hw_type;
} }
if(data != nullptr) {
delete data; if(file_source_settings != nullptr) {
delete file_source_settings;
}
if(rtl_sdr_settings != nullptr) {
delete rtl_sdr_settings;
}
if(lime_sdr_input_settings != nullptr) {
delete lime_sdr_input_settings;
}
if(lime_sdr_output_settings != nullptr) {
delete lime_sdr_output_settings;
} }
} }
@ -64,8 +81,12 @@ SWGDeviceSettings::fromJson(QString &json) {
void void
SWGDeviceSettings::fromJsonObject(QJsonObject &pJson) { SWGDeviceSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&device_type, pJson["deviceType"], "QString", "QString"); ::SWGSDRangel::setValue(&device_hw_type, pJson["deviceHwType"], "QString", "QString");
::SWGSDRangel::setValue(&data, pJson["data"], "SWGObject", "SWGObject"); ::SWGSDRangel::setValue(&tx, pJson["tx"], "qint32", "");
::SWGSDRangel::setValue(&file_source_settings, pJson["fileSourceSettings"], "SWGFileSourceSettings", "SWGFileSourceSettings");
::SWGSDRangel::setValue(&rtl_sdr_settings, pJson["rtlSdrSettings"], "SWGRtlSdrSettings", "SWGRtlSdrSettings");
::SWGSDRangel::setValue(&lime_sdr_input_settings, pJson["limeSdrInputSettings"], "SWGLimeSdrInputSettings", "SWGLimeSdrInputSettings");
::SWGSDRangel::setValue(&lime_sdr_output_settings, pJson["limeSdrOutputSettings"], "SWGLimeSdrOutputSettings", "SWGLimeSdrOutputSettings");
} }
QString QString
@ -82,29 +103,73 @@ QJsonObject*
SWGDeviceSettings::asJsonObject() { SWGDeviceSettings::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
toJsonValue(QString("deviceType"), device_type, obj, QString("QString")); toJsonValue(QString("deviceHwType"), device_hw_type, obj, QString("QString"));
toJsonValue(QString("data"), data, obj, QString("SWGObject")); obj->insert("tx", QJsonValue(tx));
toJsonValue(QString("fileSourceSettings"), file_source_settings, obj, QString("SWGFileSourceSettings"));
toJsonValue(QString("rtlSdrSettings"), rtl_sdr_settings, obj, QString("SWGRtlSdrSettings"));
toJsonValue(QString("limeSdrInputSettings"), lime_sdr_input_settings, obj, QString("SWGLimeSdrInputSettings"));
toJsonValue(QString("limeSdrOutputSettings"), lime_sdr_output_settings, obj, QString("SWGLimeSdrOutputSettings"));
return obj; return obj;
} }
QString* QString*
SWGDeviceSettings::getDeviceType() { SWGDeviceSettings::getDeviceHwType() {
return device_type; return device_hw_type;
} }
void void
SWGDeviceSettings::setDeviceType(QString* device_type) { SWGDeviceSettings::setDeviceHwType(QString* device_hw_type) {
this->device_type = device_type; this->device_hw_type = device_hw_type;
} }
SWGObject* qint32
SWGDeviceSettings::getData() { SWGDeviceSettings::getTx() {
return data; return tx;
} }
void void
SWGDeviceSettings::setData(SWGObject* data) { SWGDeviceSettings::setTx(qint32 tx) {
this->data = data; this->tx = tx;
}
SWGFileSourceSettings*
SWGDeviceSettings::getFileSourceSettings() {
return file_source_settings;
}
void
SWGDeviceSettings::setFileSourceSettings(SWGFileSourceSettings* file_source_settings) {
this->file_source_settings = file_source_settings;
}
SWGRtlSdrSettings*
SWGDeviceSettings::getRtlSdrSettings() {
return rtl_sdr_settings;
}
void
SWGDeviceSettings::setRtlSdrSettings(SWGRtlSdrSettings* rtl_sdr_settings) {
this->rtl_sdr_settings = rtl_sdr_settings;
}
SWGLimeSdrInputSettings*
SWGDeviceSettings::getLimeSdrInputSettings() {
return lime_sdr_input_settings;
}
void
SWGDeviceSettings::setLimeSdrInputSettings(SWGLimeSdrInputSettings* lime_sdr_input_settings) {
this->lime_sdr_input_settings = lime_sdr_input_settings;
}
SWGLimeSdrOutputSettings*
SWGDeviceSettings::getLimeSdrOutputSettings() {
return lime_sdr_output_settings;
}
void
SWGDeviceSettings::setLimeSdrOutputSettings(SWGLimeSdrOutputSettings* lime_sdr_output_settings) {
this->lime_sdr_output_settings = lime_sdr_output_settings;
} }

View File

@ -22,7 +22,10 @@
#include <QJsonObject> #include <QJsonObject>
#include "SWGObject.h" #include "SWGFileSourceSettings.h"
#include "SWGLimeSdrInputSettings.h"
#include "SWGLimeSdrOutputSettings.h"
#include "SWGRtlSdrSettings.h"
#include <QString> #include <QString>
#include "SWGObject.h" #include "SWGObject.h"
@ -43,16 +46,32 @@ public:
void fromJsonObject(QJsonObject &json); void fromJsonObject(QJsonObject &json);
SWGDeviceSettings* fromJson(QString &jsonString); SWGDeviceSettings* fromJson(QString &jsonString);
QString* getDeviceType(); QString* getDeviceHwType();
void setDeviceType(QString* device_type); void setDeviceHwType(QString* device_hw_type);
SWGObject* getData(); qint32 getTx();
void setData(SWGObject* data); void setTx(qint32 tx);
SWGFileSourceSettings* getFileSourceSettings();
void setFileSourceSettings(SWGFileSourceSettings* file_source_settings);
SWGRtlSdrSettings* getRtlSdrSettings();
void setRtlSdrSettings(SWGRtlSdrSettings* rtl_sdr_settings);
SWGLimeSdrInputSettings* getLimeSdrInputSettings();
void setLimeSdrInputSettings(SWGLimeSdrInputSettings* lime_sdr_input_settings);
SWGLimeSdrOutputSettings* getLimeSdrOutputSettings();
void setLimeSdrOutputSettings(SWGLimeSdrOutputSettings* lime_sdr_output_settings);
private: private:
QString* device_type; QString* device_hw_type;
SWGObject* data; qint32 tx;
SWGFileSourceSettings* file_source_settings;
SWGRtlSdrSettings* rtl_sdr_settings;
SWGLimeSdrInputSettings* lime_sdr_input_settings;
SWGLimeSdrOutputSettings* lime_sdr_output_settings;
}; };
} }

View File

@ -1,146 +0,0 @@
/**
* SDRangel
* This is the web API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube
*
* OpenAPI spec version: 4.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "SWGDeviceSettingsImpl.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGDeviceSettingsImpl::SWGDeviceSettingsImpl(QString* json) {
init();
this->fromJson(*json);
}
SWGDeviceSettingsImpl::SWGDeviceSettingsImpl() {
init();
}
SWGDeviceSettingsImpl::~SWGDeviceSettingsImpl() {
this->cleanup();
}
void
SWGDeviceSettingsImpl::init() {
file_source = new SWGFileSourceSettings();
rtlsdr = new SWGRtlSdrSettings();
limesdr_input = new SWGLimeSdrInputSettings();
limesdr_output = new SWGLimeSdrOutputSettings();
}
void
SWGDeviceSettingsImpl::cleanup() {
if(file_source != nullptr) {
delete file_source;
}
if(rtlsdr != nullptr) {
delete rtlsdr;
}
if(limesdr_input != nullptr) {
delete limesdr_input;
}
if(limesdr_output != nullptr) {
delete limesdr_output;
}
}
SWGDeviceSettingsImpl*
SWGDeviceSettingsImpl::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGDeviceSettingsImpl::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&file_source, pJson["fileSource"], "SWGFileSourceSettings", "SWGFileSourceSettings");
::SWGSDRangel::setValue(&rtlsdr, pJson["rtlsdr"], "SWGRtlSdrSettings", "SWGRtlSdrSettings");
::SWGSDRangel::setValue(&limesdr_input, pJson["limesdrInput"], "SWGLimeSdrInputSettings", "SWGLimeSdrInputSettings");
::SWGSDRangel::setValue(&limesdr_output, pJson["limesdrOutput"], "SWGLimeSdrOutputSettings", "SWGLimeSdrOutputSettings");
}
QString
SWGDeviceSettingsImpl::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
return QString(bytes);
}
QJsonObject*
SWGDeviceSettingsImpl::asJsonObject() {
QJsonObject* obj = new QJsonObject();
toJsonValue(QString("fileSource"), file_source, obj, QString("SWGFileSourceSettings"));
toJsonValue(QString("rtlsdr"), rtlsdr, obj, QString("SWGRtlSdrSettings"));
toJsonValue(QString("limesdrInput"), limesdr_input, obj, QString("SWGLimeSdrInputSettings"));
toJsonValue(QString("limesdrOutput"), limesdr_output, obj, QString("SWGLimeSdrOutputSettings"));
return obj;
}
SWGFileSourceSettings*
SWGDeviceSettingsImpl::getFileSource() {
return file_source;
}
void
SWGDeviceSettingsImpl::setFileSource(SWGFileSourceSettings* file_source) {
this->file_source = file_source;
}
SWGRtlSdrSettings*
SWGDeviceSettingsImpl::getRtlsdr() {
return rtlsdr;
}
void
SWGDeviceSettingsImpl::setRtlsdr(SWGRtlSdrSettings* rtlsdr) {
this->rtlsdr = rtlsdr;
}
SWGLimeSdrInputSettings*
SWGDeviceSettingsImpl::getLimesdrInput() {
return limesdr_input;
}
void
SWGDeviceSettingsImpl::setLimesdrInput(SWGLimeSdrInputSettings* limesdr_input) {
this->limesdr_input = limesdr_input;
}
SWGLimeSdrOutputSettings*
SWGDeviceSettingsImpl::getLimesdrOutput() {
return limesdr_output;
}
void
SWGDeviceSettingsImpl::setLimesdrOutput(SWGLimeSdrOutputSettings* limesdr_output) {
this->limesdr_output = limesdr_output;
}
}

View File

@ -1,70 +0,0 @@
/**
* SDRangel
* This is the web API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube
*
* OpenAPI spec version: 4.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/*
* SWGDeviceSettingsImpl.h
*
* dummy structure to handle all devices settings
*/
#ifndef SWGDeviceSettingsImpl_H_
#define SWGDeviceSettingsImpl_H_
#include <QJsonObject>
#include "SWGFileSourceSettings.h"
#include "SWGLimeSdrInputSettings.h"
#include "SWGLimeSdrOutputSettings.h"
#include "SWGRtlSdrSettings.h"
#include "SWGObject.h"
namespace SWGSDRangel {
class SWGDeviceSettingsImpl: public SWGObject {
public:
SWGDeviceSettingsImpl();
SWGDeviceSettingsImpl(QString* json);
virtual ~SWGDeviceSettingsImpl();
void init();
void cleanup();
QString asJson ();
QJsonObject* asJsonObject();
void fromJsonObject(QJsonObject &json);
SWGDeviceSettingsImpl* fromJson(QString &jsonString);
SWGFileSourceSettings* getFileSource();
void setFileSource(SWGFileSourceSettings* file_source);
SWGRtlSdrSettings* getRtlsdr();
void setRtlsdr(SWGRtlSdrSettings* rtlsdr);
SWGLimeSdrInputSettings* getLimesdrInput();
void setLimesdrInput(SWGLimeSdrInputSettings* limesdr_input);
SWGLimeSdrOutputSettings* getLimesdrOutput();
void setLimesdrOutput(SWGLimeSdrOutputSettings* limesdr_output);
private:
SWGFileSourceSettings* file_source;
SWGRtlSdrSettings* rtlsdr;
SWGLimeSdrInputSettings* limesdr_input;
SWGLimeSdrOutputSettings* limesdr_output;
};
}
#endif /* SWGDeviceSettingsImpl_H_ */

View File

@ -25,7 +25,6 @@
#include "SWGDeviceSet.h" #include "SWGDeviceSet.h"
#include "SWGDeviceSetList.h" #include "SWGDeviceSetList.h"
#include "SWGDeviceSettings.h" #include "SWGDeviceSettings.h"
#include "SWGDeviceSettingsImpl.h"
#include "SWGErrorResponse.h" #include "SWGErrorResponse.h"
#include "SWGFileSourceSettings.h" #include "SWGFileSourceSettings.h"
#include "SWGInstanceChannelsResponse.h" #include "SWGInstanceChannelsResponse.h"
@ -80,9 +79,6 @@ namespace SWGSDRangel {
if(QString("SWGDeviceSettings").compare(type) == 0) { if(QString("SWGDeviceSettings").compare(type) == 0) {
return new SWGDeviceSettings(); return new SWGDeviceSettings();
} }
if(QString("SWGDeviceSettingsImpl").compare(type) == 0) {
return new SWGDeviceSettingsImpl();
}
if(QString("SWGErrorResponse").compare(type) == 0) { if(QString("SWGErrorResponse").compare(type) == 0) {
return new SWGErrorResponse(); return new SWGErrorResponse();
} }