From 4756299ad93e9d6863faf2d294f58febf20f4365 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 16 May 2016 01:12:55 +0200 Subject: [PATCH] Multi device support: migrate device specific stuff outside plugin classes (added files) --- sdrbase/device/deviceapi.cpp | 102 +++++++++++++++++++++++++++++++++++ sdrbase/device/deviceapi.h | 69 ++++++++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 sdrbase/device/deviceapi.cpp create mode 100644 sdrbase/device/deviceapi.h diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp new file mode 100644 index 000000000..d4ace4b75 --- /dev/null +++ b/sdrbase/device/deviceapi.cpp @@ -0,0 +1,102 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2016 Edouard Griffiths, F4EXB // +// // +// 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 // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "device/deviceapi.h" + +DeviceAPI::DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum) : + m_deviceEngine(deviceEngine), + m_spectrum(glSpectrum) +{ +} + +DeviceAPI::~DeviceAPI() +{ +} + +void DeviceAPI::addSink(SampleSink *sink) +{ + m_deviceEngine->addSink(sink); +} + +void DeviceAPI::removeSink(SampleSink* sink) +{ + m_deviceEngine->removeSink(sink); +} + +void DeviceAPI::addThreadedSink(ThreadedSampleSink* sink) +{ + m_deviceEngine->addThreadedSink(sink); +} + +void DeviceAPI::removeThreadedSink(ThreadedSampleSink* sink) +{ + m_deviceEngine->removeThreadedSink(sink); +} + +void DeviceAPI::setSource(SampleSource* source) +{ + m_deviceEngine->setSource(source); +} + +bool DeviceAPI::initAcquisition() +{ + return m_deviceEngine->initAcquisition(); +} + +bool DeviceAPI::startAcquisition() +{ + return m_deviceEngine->startAcquisition(); +} + +void DeviceAPI::stopAcquisition() +{ + m_deviceEngine->stopAcquistion(); +} + +DSPDeviceEngine::State DeviceAPI::state() const +{ + return m_deviceEngine->state(); +} + +QString DeviceAPI::errorMessage() +{ + return m_deviceEngine->errorMessage(); +} + +uint DeviceAPI::getDeviceUID() const +{ + return m_deviceEngine->getUID(); +} + +MessageQueue *DeviceAPI::getDeviceInputMessageQueue() +{ + return m_deviceEngine->getInputMessageQueue(); +} + +MessageQueue *DeviceAPI::getDeviceOutputMessageQueue() +{ + return m_deviceEngine->getOutputMessageQueue(); +} + +void DeviceAPI::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection) +{ + m_deviceEngine->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection); +} + +GLSpectrum *DeviceAPI::getSpectrum() +{ + return m_spectrum; +} diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h new file mode 100644 index 000000000..2198ae568 --- /dev/null +++ b/sdrbase/device/deviceapi.h @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2016 Edouard Griffiths, F4EXB // +// // +// 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 // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_DEVICE_DEVICEAPI_H_ +#define SDRBASE_DEVICE_DEVICEAPI_H_ + +#include +#include + + +#include "util/export.h" +#include "dsp/dspdeviceengine.h" + +class MainWindow; +class DSPDeviceEngine; +class GLSpectrum; +class SampleSink; +class ThreadedSampleSink; +class SampleSource; +class MessageQueue; + +class SDRANGEL_API DeviceAPI : public QObject { + Q_OBJECT + +public: + // Device engine stuff + void addSink(SampleSink* sink); //!< Add a sample sink to device engine + void removeSink(SampleSink* sink); //!< Remove a sample sink from device engine + void addThreadedSink(ThreadedSampleSink* sink); //!< Add a sample sink that will run on its own thread to device engine + void removeThreadedSink(ThreadedSampleSink* sink); //!< Remove a sample sink that runs on its own thread from device engine + void setSource(SampleSource* source); //!< Set device engine sample source type + bool initAcquisition(); //!< Initialize device engine acquisition sequence + bool startAcquisition(); //!< Start device engine acquisition sequence + void stopAcquisition(); //!< Stop device engine acquisition sequence + DSPDeviceEngine::State state() const; //!< device engine state + QString errorMessage(); //!< Return the current device engine error message + uint getDeviceUID() const; //!< Return the current device engine unique ID + MessageQueue *getDeviceInputMessageQueue(); + MessageQueue *getDeviceOutputMessageQueue(); + void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections + + // device related stuff + GLSpectrum *getSpectrum(); + +protected: + DeviceAPI(DSPDeviceEngine *deviceEngine, GLSpectrum *glSpectrum); + ~DeviceAPI(); + + DSPDeviceEngine *m_deviceEngine; + GLSpectrum *m_spectrum; + + friend class MainWindow; +}; + + +#endif /* SDRBASE_DEVICE_DEVICEAPI_H_ */