SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Signals | Public Member Functions | Static Public Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
MainCore Class Reference

#include <maincore.h>

Inherits QObject.

+ Collaboration diagram for MainCore:

Classes

class  MsgAddChannel
 
class  MsgAddDeviceSet
 
class  MsgDeleteChannel
 
class  MsgDeleteInstance
 
class  MsgDeletePreset
 
class  MsgLoadPreset
 
class  MsgRemoveLastDeviceSet
 
class  MsgSavePreset
 
class  MsgSetDevice
 

Signals

void finished ()
 

Public Member Functions

 MainCore (qtwebapp::LoggerWithFile *logger, const MainParser &parser, QObject *parent=0)
 
 ~MainCore ()
 
MessageQueuegetInputMessageQueue ()
 
const QTimer & getMasterTimer () const
 
const MainSettingsgetMainSettings () const
 
void addSourceDevice ()
 
void addSinkDevice ()
 
void removeLastDevice ()
 
void changeSampleSource (int deviceSetIndex, int selectedDeviceIndex)
 
void changeSampleSink (int deviceSetIndex, int selectedDeviceIndex)
 
void addChannel (int deviceSetIndex, int selectedChannelIndex)
 
void deleteChannel (int deviceSetIndex, int channelIndex)
 

Static Public Member Functions

static MainCoregetInstance ()
 

Private Slots

void handleMessages ()
 

Private Member Functions

void loadSettings ()
 
void loadPresetSettings (const Preset *preset, int tabIndex)
 
void savePresetSettings (Preset *preset, int tabIndex)
 
void setLoggingOptions ()
 
bool handleMessage (const Message &cmd)
 

Private Attributes

MainSettings m_settings
 
int m_masterTabIndex
 
DSPEnginem_dspEngine
 
int m_lastEngineState
 
qtwebapp::LoggerWithFilem_logger
 
MessageQueue m_inputMessageQueue
 
QTimer m_masterTimer
 
std::vector< DeviceSet * > m_deviceSets
 
PluginManagerm_pluginManager
 
WebAPIRequestMapperm_requestMapper
 
WebAPIServerm_apiServer
 
WebAPIAdapterSrvm_apiAdapter
 

Static Private Attributes

static MainCorem_instance = 0
 

Friends

class WebAPIAdapterSrv
 

Detailed Description

Definition at line 48 of file maincore.h.

Constructor & Destructor Documentation

◆ MainCore()

MainCore::MainCore ( qtwebapp::LoggerWithFile logger,
const MainParser parser,
QObject *  parent = 0 
)
explicit

Definition at line 50 of file maincore.cpp.

References DSPEngine::getAMBEEngine(), DSPEngine::getAudioDeviceManager(), MainParser::getMIMOSupport(), MainParser::getServerAddress(), MainParser::getServerPort(), handleMessages(), PluginManager::loadPlugins(), loadSettings(), m_apiAdapter, m_apiServer, m_dspEngine, m_inputMessageQueue, m_instance, m_masterTimer, m_pluginManager, m_requestMapper, m_settings, WebAPIRequestMapper::setAdapter(), MainSettings::setAMBEEngine(), MainSettings::setAudioDeviceManager(), DSPEngine::setMIMOSupport(), WebAPIServer::start(), and WebAPIAdapterSrv.

50  :
51  QObject(parent),
52  m_settings(),
53  m_masterTabIndex(-1),
56  m_logger(logger)
57 {
58  qDebug() << "MainCore::MainCore: start";
59 
60  m_instance = this;
63 
64  m_pluginManager = new PluginManager(this);
65  m_pluginManager->loadPlugins(QString("pluginssrv"));
66 
67  connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
68  m_masterTimer.start(50);
69 
70  loadSettings();
71 
72  QString applicationDirPath = QCoreApplication::instance()->applicationDirPath();
73 
74  m_apiAdapter = new WebAPIAdapterSrv(*this);
78  m_apiServer->start();
79 
81 
82  qDebug() << "MainCore::MainCore: end";
83 }
DSPEngine * m_dspEngine
Definition: maincore.h:275
int m_masterTabIndex
Definition: maincore.h:274
WebAPIAdapterSrv * m_apiAdapter
Definition: maincore.h:286
WebAPIServer * m_apiServer
Definition: maincore.h:285
engine is before initialization
void loadPlugins(const QString &pluginsSubDir)
bool getMIMOSupport() const
Definition: mainparser.h:37
void handleMessages()
Definition: maincore.cpp:188
void setAdapter(WebAPIAdapterInterface *adapter)
MessageQueue m_inputMessageQueue
Definition: maincore.h:279
void loadSettings()
Definition: maincore.cpp:200
MainSettings m_settings
Definition: maincore.h:273
AMBEEngine * getAMBEEngine()
Definition: dspengine.h:56
static DSPEngine * instance()
Definition: dspengine.cpp:51
void setAMBEEngine(AMBEEngine *ambeEngine)
Definition: mainsettings.h:70
friend class WebAPIAdapterSrv
Definition: maincore.h:69
PluginManager * m_pluginManager
Definition: maincore.h:282
qtwebapp::LoggerWithFile * m_logger
Definition: maincore.h:277
void setMIMOSupport(bool mimoSupport)
Definition: dspengine.h:85
WebAPIRequestMapper * m_requestMapper
Definition: maincore.h:284
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
int m_lastEngineState
Definition: maincore.h:276
QTimer m_masterTimer
Definition: maincore.h:280
void setAudioDeviceManager(AudioDeviceManager *audioDeviceManager)
Definition: mainsettings.h:69
const QString & getServerAddress() const
Definition: mainparser.h:35
uint16_t getServerPort() const
Definition: mainparser.h:36
static MainCore * m_instance
Definition: maincore.h:272
+ Here is the call graph for this function:

◆ ~MainCore()

MainCore::~MainCore ( )

Definition at line 85 of file maincore.cpp.

References m_apiAdapter, m_apiServer, m_deviceSets, m_logger, m_pluginManager, m_requestMapper, m_settings, removeLastDevice(), MainSettings::save(), and WebAPIServer::stop().

86 {
87  while (m_deviceSets.size() > 0) {
89  }
90 
91  m_apiServer->stop();
92  m_settings.save();
93  delete m_apiServer;
94  delete m_requestMapper;
95  delete m_apiAdapter;
96 
97  delete m_pluginManager;
98 
99  qDebug() << "MainCore::~MainCore: end";
100  delete m_logger;
101 }
WebAPIAdapterSrv * m_apiAdapter
Definition: maincore.h:286
WebAPIServer * m_apiServer
Definition: maincore.h:285
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
MainSettings m_settings
Definition: maincore.h:273
void removeLastDevice()
Definition: maincore.cpp:348
PluginManager * m_pluginManager
Definition: maincore.h:282
qtwebapp::LoggerWithFile * m_logger
Definition: maincore.h:277
WebAPIRequestMapper * m_requestMapper
Definition: maincore.h:284
void save() const
+ Here is the call graph for this function:

Member Function Documentation

◆ addChannel()

void MainCore::addChannel ( int  deviceSetIndex,
int  selectedChannelIndex 
)

Definition at line 530 of file maincore.cpp.

References DeviceSet::addRxChannel(), DeviceSet::addTxChannel(), PluginManager::getPluginAPI(), m_deviceSets, DeviceSet::m_deviceSinkEngine, DeviceSet::m_deviceSourceEngine, and m_pluginManager.

Referenced by handleMessage().

531 {
532  if (deviceSetIndex >= 0)
533  {
534  DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
535 
536  if (deviceSet->m_deviceSourceEngine) // source device => Rx channels
537  {
538  deviceSet->addRxChannel(selectedChannelIndex, m_pluginManager->getPluginAPI());
539  }
540  else if (deviceSet->m_deviceSinkEngine) // sink device => Tx channels
541  {
542  deviceSet->addTxChannel(selectedChannelIndex, m_pluginManager->getPluginAPI());
543  }
544  }
545 }
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
DSPDeviceSourceEngine * m_deviceSourceEngine
Definition: deviceset.h:35
void addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
Definition: deviceset.cpp:142
PluginAPI * getPluginAPI()
Definition: pluginmanager.h:58
PluginManager * m_pluginManager
Definition: maincore.h:282
DSPDeviceSinkEngine * m_deviceSinkEngine
Definition: deviceset.h:36
void addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
Definition: deviceset.cpp:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSinkDevice()

void MainCore::addSinkDevice ( )

Definition at line 258 of file maincore.cpp.

References DSPEngine::addDeviceSinkEngine(), PluginInterface::SamplingDevice::deviceItemIndex, PluginInterface::SamplingDevice::deviceNbItems, PluginInterface::SamplingDevice::displayedName, DeviceUserArgs::findUserArgs(), MainSettings::getDeviceUserArgs(), DeviceEnumerator::getFileSinkDeviceIndex(), DeviceEnumerator::getTxSamplingDevice(), DSPDeviceSinkEngine::getUID(), PluginInterface::SamplingDevice::hardwareId, PluginInterface::SamplingDevice::id, DeviceEnumerator::instance(), m_deviceSets, m_dspEngine, m_settings, PluginInterface::SamplingDevice::sequence, PluginInterface::SamplingDevice::serial, DSPDeviceSinkEngine::start(), and DeviceAPI::StreamSingleTx.

Referenced by handleMessage().

259 {
260  DSPDeviceSinkEngine *dspDeviceSinkEngine = m_dspEngine->addDeviceSinkEngine();
261  dspDeviceSinkEngine->start();
262 
263  uint dspDeviceSinkEngineUID = dspDeviceSinkEngine->getUID();
264  char uidCStr[16];
265  sprintf(uidCStr, "UID:%d", dspDeviceSinkEngineUID);
266 
267  int deviceTabIndex = m_deviceSets.size();
268  m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
269  m_deviceSets.back()->m_deviceSourceEngine = 0;
270  m_deviceSets.back()->m_deviceMIMOEngine = 0;
271 
272  char tabNameCStr[16];
273  sprintf(tabNameCStr, "T%d", deviceTabIndex);
274 
275  DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleTx, deviceTabIndex, nullptr, dspDeviceSinkEngine, nullptr);
276 
277  m_deviceSets.back()->m_deviceAPI = deviceAPI;
278  QList<QString> channelNames;
279 
280  // create a file sink by default
281  int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex();
282  const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
283  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
284  m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
285  m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
286  m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
287  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
288  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
289  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
290  m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
291 
292  QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
293 
294  if (userArgs.size() > 0) {
295  m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
296  }
297 
298  DeviceSampleSink *sink = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
299  m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
300  m_deviceSets.back()->m_deviceAPI->setSampleSink(sink);
301 }
DSPEngine * m_dspEngine
Definition: maincore.h:275
int getFileSinkDeviceIndex() const
Get Tx default device.
int sequence
The device sequence. >0 when more than one device of the same type is connected.
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
QString displayedName
The human readable name.
Exposes a single output stream that can be one of the streams of a physical device.
Definition: deviceapi.h:48
QString hardwareId
The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
DSPDeviceSinkEngine * addDeviceSinkEngine()
Definition: dspengine.cpp:74
void start()
This thread start.
MainSettings m_settings
Definition: maincore.h:273
int deviceNbItems
Number of items (or streams) in the device. >1 for composite devices.
uint32_t getUID() const
QString id
The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...
QString serial
The device serial number defined by the vendor or a fake one (SDRplay)
const PluginInterface::SamplingDevice * getTxSamplingDevice(int deviceIndex) const
DeviceUserArgs & getDeviceUserArgs()
Definition: mainsettings.h:66
static DeviceEnumerator * instance()
int deviceItemIndex
For composite devices this is the Rx or Tx stream index. -1 if not initialized.
QString findUserArgs(const QString &id, int sequence)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSourceDevice()

void MainCore::addSourceDevice ( )

Definition at line 303 of file maincore.cpp.

References DSPEngine::addDeviceSourceEngine(), PluginInterface::SamplingDevice::deviceItemIndex, PluginInterface::SamplingDevice::deviceNbItems, PluginInterface::SamplingDevice::displayedName, DeviceUserArgs::findUserArgs(), MainSettings::getDeviceUserArgs(), DeviceEnumerator::getFileInputDeviceIndex(), DeviceEnumerator::getRxSamplingDevice(), DSPDeviceSourceEngine::getUID(), PluginInterface::SamplingDevice::hardwareId, PluginInterface::SamplingDevice::id, DeviceEnumerator::instance(), m_deviceSets, m_dspEngine, m_settings, PluginInterface::SamplingDevice::sequence, PluginInterface::SamplingDevice::serial, DSPDeviceSourceEngine::start(), and DeviceAPI::StreamSingleRx.

Referenced by handleMessage().

304 {
305  DSPDeviceSourceEngine *dspDeviceSourceEngine = m_dspEngine->addDeviceSourceEngine();
306  dspDeviceSourceEngine->start();
307 
308  uint dspDeviceSourceEngineUID = dspDeviceSourceEngine->getUID();
309  char uidCStr[16];
310  sprintf(uidCStr, "UID:%d", dspDeviceSourceEngineUID);
311 
312  int deviceTabIndex = m_deviceSets.size();
313  m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
314  m_deviceSets.back()->m_deviceSourceEngine = dspDeviceSourceEngine;
315  m_deviceSets.back()->m_deviceSinkEngine = 0;
316  m_deviceSets.back()->m_deviceMIMOEngine = 0;
317 
318  char tabNameCStr[16];
319  sprintf(tabNameCStr, "R%d", deviceTabIndex);
320 
321  DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleRx, deviceTabIndex, dspDeviceSourceEngine, nullptr, nullptr);
322 
323  m_deviceSets.back()->m_deviceAPI = deviceAPI;
324 
325  // Create a file source instance by default
326  int fileSourceDeviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
327  const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileSourceDeviceIndex);
328  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
329  m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
330  m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
331  m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
332  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
333  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
334  m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
335  m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex));
336 
337  QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
338 
339  if (userArgs.size() > 0) {
340  m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
341  }
342 
343  DeviceSampleSource *source = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
344  m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
345  m_deviceSets.back()->m_deviceAPI->setSampleSource(source);
346 }
DSPEngine * m_dspEngine
Definition: maincore.h:275
int sequence
The device sequence. >0 when more than one device of the same type is connected.
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
QString displayedName
The human readable name.
DSPDeviceSourceEngine * addDeviceSourceEngine()
Definition: dspengine.cpp:56
QString hardwareId
The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
Exposes a single input stream that can be one of the streams of a physical device.
Definition: deviceapi.h:47
MainSettings m_settings
Definition: maincore.h:273
int deviceNbItems
Number of items (or streams) in the device. >1 for composite devices.
QString id
The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...
QString serial
The device serial number defined by the vendor or a fake one (SDRplay)
void start()
This thread start.
DeviceUserArgs & getDeviceUserArgs()
Definition: mainsettings.h:66
const PluginInterface::SamplingDevice * getRxSamplingDevice(int deviceIndex) const
int getFileInputDeviceIndex() const
Get Rx default device.
static DeviceEnumerator * instance()
int deviceItemIndex
For composite devices this is the Rx or Tx stream index. -1 if not initialized.
QString findUserArgs(const QString &id, int sequence)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ changeSampleSink()

void MainCore::changeSampleSink ( int  deviceSetIndex,
int  selectedDeviceIndex 
)

Definition at line 462 of file maincore.cpp.

References DeviceAPI::clearBuddiesLists(), PluginInterface::createSampleSinkPluginInstance(), PluginInterface::deleteSampleSinkPluginInstanceOutput(), PluginInterface::SamplingDevice::deviceItemIndex, PluginInterface::SamplingDevice::deviceNbItems, PluginInterface::SamplingDevice::displayedName, DeviceAPI::getHardwareId(), DeviceAPI::getPluginInterface(), DeviceAPI::getSampleSink(), DeviceAPI::getSamplingDeviceId(), DeviceAPI::getSamplingDeviceSerial(), DeviceEnumerator::getTxSamplingDevice(), MainSettings::getWorkingPreset(), PluginInterface::SamplingDevice::hardwareId, PluginInterface::SamplingDevice::id, DeviceEnumerator::instance(), DeviceAPI::loadSamplingDeviceSettings(), DeviceSet::m_deviceAPI, m_deviceSets, m_settings, DeviceAPI::resetSamplingDeviceId(), DeviceAPI::saveSamplingDeviceSettings(), PluginInterface::SamplingDevice::sequence, PluginInterface::SamplingDevice::serial, DeviceAPI::setBuddyLeader(), DeviceAPI::setDeviceItemIndex(), DeviceAPI::setDeviceNbItems(), DeviceAPI::setHardwareId(), DeviceAPI::setSampleSink(), DeviceAPI::setSamplingDeviceDisplayName(), DeviceAPI::setSamplingDeviceId(), DeviceAPI::setSamplingDevicePluginInterface(), DeviceAPI::setSamplingDeviceSequence(), DeviceAPI::setSamplingDeviceSerial(), and DeviceAPI::stopDeviceEngine().

Referenced by handleMessage().

463 {
464  if (deviceSetIndex >= 0)
465  {
466  qDebug("MainCore::changeSampleSink: device set at %d", deviceSetIndex);
467  DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
468  deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
469  deviceSet->m_deviceAPI->stopDeviceEngine();
470 
471  // deletes old UI and output object
472  deviceSet->m_deviceAPI->resetSamplingDeviceId();
474  deviceSet->m_deviceAPI->getSampleSink());
475  deviceSet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
476 
477  const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(selectedDeviceIndex);
478  deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
479  deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
480  deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
481  deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
482  deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
483  deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
484  deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
485  deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(selectedDeviceIndex));
486 
487  // add to buddies list
488  std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
489  int nbOfBuddies = 0;
490 
491  for (; it != m_deviceSets.end(); ++it)
492  {
493  if (*it != deviceSet) // do not add to itself
494  {
495  if ((*it)->m_deviceSourceEngine) // it is a source device
496  {
497  if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
498  (deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
499  {
500  (*it)->m_deviceAPI->addSinkBuddy(deviceSet->m_deviceAPI);
501  nbOfBuddies++;
502  }
503  }
504 
505  if ((*it)->m_deviceSinkEngine) // it is a sink device
506  {
507  if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
508  (deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
509  {
510  (*it)->m_deviceAPI->addSinkBuddy(deviceSet->m_deviceAPI);
511  nbOfBuddies++;
512  }
513  }
514  }
515  }
516 
517  if (nbOfBuddies == 0) {
518  deviceSet->m_deviceAPI->setBuddyLeader(true);
519  }
520 
521  // constructs new GUI and output object
523  deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
524  deviceSet->m_deviceAPI->setSampleSink(sink);
525 
526  deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
527  }
528 }
void setHardwareId(const QString &id)
Definition: deviceapi.cpp:364
void setBuddyLeader(bool isBuddyLeader)
Definition: deviceapi.h:164
int sequence
The device sequence. >0 when more than one device of the same type is connected.
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
QString displayedName
The human readable name.
QString hardwareId
The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
void setSamplingDeviceSequence(int sequence)
Definition: deviceapi.h:114
DeviceSampleSink * getSampleSink()
Return pointer to the device sample sink (single Tx) or nullptr.
Definition: deviceapi.cpp:222
void setSamplingDeviceId(const QString &id)
Definition: deviceapi.h:110
void setSamplingDeviceDisplayName(const QString &name)
Definition: deviceapi.h:113
MainSettings m_settings
Definition: maincore.h:273
const QString & getSamplingDeviceId() const
Definition: deviceapi.h:120
void saveSamplingDeviceSettings(Preset *preset)
Definition: deviceapi.cpp:569
int deviceNbItems
Number of items (or streams) in the device. >1 for composite devices.
Preset * getWorkingPreset()
Definition: mainsettings.h:47
DeviceAPI * m_deviceAPI
Definition: deviceset.h:34
virtual DeviceSampleSink * createSampleSinkPluginInstance(const QString &sinkId, DeviceAPI *deviceAPI)
QString id
The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...
void clearBuddiesLists()
Definition: deviceapi.cpp:740
QString serial
The device serial number defined by the vendor or a fake one (SDRplay)
virtual void deleteSampleSinkPluginInstanceOutput(DeviceSampleSink *sink)
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
PluginInterface * getPluginInterface()
Definition: deviceapi.h:132
const PluginInterface::SamplingDevice * getTxSamplingDevice(int deviceIndex) const
const QString & getHardwareId() const
Definition: deviceapi.h:119
void setSamplingDeviceSerial(const QString &serial)
Definition: deviceapi.h:112
void setDeviceItemIndex(uint32_t index)
Definition: deviceapi.cpp:374
void resetSamplingDeviceId()
Definition: deviceapi.h:111
void loadSamplingDeviceSettings(const Preset *preset)
Definition: deviceapi.cpp:481
void setSamplingDevicePluginInterface(PluginInterface *iface)
Definition: deviceapi.cpp:379
static DeviceEnumerator * instance()
int deviceItemIndex
For composite devices this is the Rx or Tx stream index. -1 if not initialized.
void setDeviceNbItems(uint32_t nbItems)
Definition: deviceapi.cpp:369
void setSampleSink(DeviceSampleSink *sink)
Set the device sample sink (single Tx)
Definition: deviceapi.cpp:199
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ changeSampleSource()

void MainCore::changeSampleSource ( int  deviceSetIndex,
int  selectedDeviceIndex 
)

Definition at line 394 of file maincore.cpp.

References DeviceAPI::clearBuddiesLists(), PluginInterface::createSampleSourcePluginInstance(), PluginInterface::deleteSampleSourcePluginInstanceInput(), PluginInterface::SamplingDevice::deviceItemIndex, PluginInterface::SamplingDevice::deviceNbItems, PluginInterface::SamplingDevice::displayedName, DeviceAPI::getHardwareId(), DeviceAPI::getPluginInterface(), DeviceEnumerator::getRxSamplingDevice(), DeviceAPI::getSampleSource(), DeviceAPI::getSamplingDeviceId(), DeviceAPI::getSamplingDeviceSerial(), MainSettings::getWorkingPreset(), PluginInterface::SamplingDevice::hardwareId, PluginInterface::SamplingDevice::id, DeviceEnumerator::instance(), DeviceAPI::loadSamplingDeviceSettings(), DeviceSet::m_deviceAPI, m_deviceSets, m_settings, DeviceAPI::resetSamplingDeviceId(), DeviceAPI::saveSamplingDeviceSettings(), PluginInterface::SamplingDevice::sequence, PluginInterface::SamplingDevice::serial, DeviceAPI::setBuddyLeader(), DeviceAPI::setDeviceItemIndex(), DeviceAPI::setDeviceNbItems(), DeviceAPI::setHardwareId(), DeviceAPI::setSampleSource(), DeviceAPI::setSamplingDeviceDisplayName(), DeviceAPI::setSamplingDeviceId(), DeviceAPI::setSamplingDevicePluginInterface(), DeviceAPI::setSamplingDeviceSequence(), DeviceAPI::setSamplingDeviceSerial(), and DeviceAPI::stopDeviceEngine().

Referenced by handleMessage().

395 {
396  if (deviceSetIndex >= 0)
397  {
398  qDebug("MainCore::changeSampleSource: deviceSet at %d", deviceSetIndex);
399  DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
400  deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
401  deviceSet->m_deviceAPI->stopDeviceEngine();
402 
403  // deletes old UI and input object
404  deviceSet->m_deviceAPI->resetSamplingDeviceId();
406  deviceSet->m_deviceAPI->getSampleSource());
407  deviceSet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
408 
409  const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
410  deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
411  deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
412  deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
413  deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
414  deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
415  deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
416  deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
417  deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(selectedDeviceIndex));
418 
419  // add to buddies list
420  std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
421  int nbOfBuddies = 0;
422 
423  for (; it != m_deviceSets.end(); ++it)
424  {
425  if (*it != deviceSet) // do not add to itself
426  {
427  if ((*it)->m_deviceSourceEngine) // it is a source device
428  {
429  if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
430  (deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
431  {
432  (*it)->m_deviceAPI->addSourceBuddy(deviceSet->m_deviceAPI);
433  nbOfBuddies++;
434  }
435  }
436 
437  if ((*it)->m_deviceSinkEngine) // it is a sink device
438  {
439  if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
440  (deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
441  {
442  (*it)->m_deviceAPI->addSourceBuddy(deviceSet->m_deviceAPI);
443  nbOfBuddies++;
444  }
445  }
446  }
447  }
448 
449  if (nbOfBuddies == 0) {
450  deviceSet->m_deviceAPI->setBuddyLeader(true);
451  }
452 
453  // constructs new GUI and input object
455  deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
456  deviceSet->m_deviceAPI->setSampleSource(source);
457 
458  deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
459  }
460 }
void setHardwareId(const QString &id)
Definition: deviceapi.cpp:364
void setBuddyLeader(bool isBuddyLeader)
Definition: deviceapi.h:164
virtual DeviceSampleSource * createSampleSourcePluginInstance(const QString &sourceId, DeviceAPI *deviceAPI)
int sequence
The device sequence. >0 when more than one device of the same type is connected.
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
void setSampleSource(DeviceSampleSource *source)
Set the device sample source (single Rx)
Definition: deviceapi.cpp:192
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
QString displayedName
The human readable name.
DeviceSampleSource * getSampleSource()
Return pointer to the device sample source (single Rx) or nullptr.
Definition: deviceapi.cpp:213
QString hardwareId
The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
void setSamplingDeviceSequence(int sequence)
Definition: deviceapi.h:114
void setSamplingDeviceId(const QString &id)
Definition: deviceapi.h:110
void setSamplingDeviceDisplayName(const QString &name)
Definition: deviceapi.h:113
MainSettings m_settings
Definition: maincore.h:273
const QString & getSamplingDeviceId() const
Definition: deviceapi.h:120
void saveSamplingDeviceSettings(Preset *preset)
Definition: deviceapi.cpp:569
int deviceNbItems
Number of items (or streams) in the device. >1 for composite devices.
Preset * getWorkingPreset()
Definition: mainsettings.h:47
DeviceAPI * m_deviceAPI
Definition: deviceset.h:34
QString id
The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...
void clearBuddiesLists()
Definition: deviceapi.cpp:740
QString serial
The device serial number defined by the vendor or a fake one (SDRplay)
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
PluginInterface * getPluginInterface()
Definition: deviceapi.h:132
const QString & getHardwareId() const
Definition: deviceapi.h:119
void setSamplingDeviceSerial(const QString &serial)
Definition: deviceapi.h:112
const PluginInterface::SamplingDevice * getRxSamplingDevice(int deviceIndex) const
virtual void deleteSampleSourcePluginInstanceInput(DeviceSampleSource *source)
void setDeviceItemIndex(uint32_t index)
Definition: deviceapi.cpp:374
void resetSamplingDeviceId()
Definition: deviceapi.h:111
void loadSamplingDeviceSettings(const Preset *preset)
Definition: deviceapi.cpp:481
void setSamplingDevicePluginInterface(PluginInterface *iface)
Definition: deviceapi.cpp:379
static DeviceEnumerator * instance()
int deviceItemIndex
For composite devices this is the Rx or Tx stream index. -1 if not initialized.
void setDeviceNbItems(uint32_t nbItems)
Definition: deviceapi.cpp:369
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteChannel()

void MainCore::deleteChannel ( int  deviceSetIndex,
int  channelIndex 
)

Definition at line 547 of file maincore.cpp.

References DeviceSet::deleteRxChannel(), DeviceSet::deleteTxChannel(), m_deviceSets, DeviceSet::m_deviceSinkEngine, and DeviceSet::m_deviceSourceEngine.

Referenced by handleMessage().

548 {
549  if (deviceSetIndex >= 0)
550  {
551  DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
552 
553  if (deviceSet->m_deviceSourceEngine) // source device => Rx channels
554  {
555  deviceSet->deleteRxChannel(channelIndex);
556  }
557  else if (deviceSet->m_deviceSinkEngine) // sink device => Tx channels
558  {
559  deviceSet->deleteTxChannel(channelIndex);
560  }
561  }
562 }
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
DSPDeviceSourceEngine * m_deviceSourceEngine
Definition: deviceset.h:35
void deleteRxChannel(int channelIndex)
Definition: deviceset.cpp:122
DSPDeviceSinkEngine * m_deviceSinkEngine
Definition: deviceset.h:36
void deleteTxChannel(int channelIndex)
Definition: deviceset.cpp:132
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ finished

void MainCore::finished ( )
signal

Referenced by handleMessage().

+ Here is the caller graph for this function:

◆ getInputMessageQueue()

MessageQueue* MainCore::getInputMessageQueue ( )
inline

Definition at line 56 of file maincore.h.

Referenced by WebAPIAdapterSrv::instanceDelete().

56 { return &m_inputMessageQueue; }
MessageQueue m_inputMessageQueue
Definition: maincore.h:279
+ Here is the caller graph for this function:

◆ getInstance()

static MainCore* MainCore::getInstance ( )
inlinestatic

Definition at line 54 of file maincore.h.

54 { return m_instance; } // Main Core is de facto a singleton so this just returns its reference
static MainCore * m_instance
Definition: maincore.h:272

◆ getMainSettings()

const MainSettings& MainCore::getMainSettings ( ) const
inline

Definition at line 59 of file maincore.h.

Referenced by WebAPIAdapterSrv::instanceConfigGet().

59 { return m_settings; }
MainSettings m_settings
Definition: maincore.h:273
+ Here is the caller graph for this function:

◆ getMasterTimer()

const QTimer& MainCore::getMasterTimer ( ) const
inline

Definition at line 58 of file maincore.h.

58 { return m_masterTimer; }
QTimer m_masterTimer
Definition: maincore.h:280

◆ handleMessage()

bool MainCore::handleMessage ( const Message cmd)
private

Definition at line 103 of file maincore.cpp.

References addChannel(), addSinkDevice(), addSourceDevice(), changeSampleSink(), changeSampleSource(), deleteChannel(), MainSettings::deletePreset(), finished(), MainCore::MsgDeleteChannel::getChannelIndex(), MainCore::MsgAddChannel::getChannelRegistrationIndex(), MainCore::MsgSetDevice::getDeviceIndex(), MainCore::MsgLoadPreset::getDeviceSetIndex(), MainCore::MsgSavePreset::getDeviceSetIndex(), MainCore::MsgSetDevice::getDeviceSetIndex(), MainCore::MsgAddChannel::getDeviceSetIndex(), MainCore::MsgDeleteChannel::getDeviceSetIndex(), MainCore::MsgSetDevice::getDeviceType(), MainCore::MsgAddDeviceSet::getDirection(), MainCore::MsgLoadPreset::getPreset(), MainCore::MsgSavePreset::getPreset(), MainCore::MsgDeletePreset::getPreset(), loadPresetSettings(), m_deviceSets, m_settings, Message::match(), removeLastDevice(), MainSettings::save(), savePresetSettings(), and MainSettings::sortPresets().

Referenced by handleMessages().

104 {
105  if (MsgDeleteInstance::match(cmd))
106  {
107  while (m_deviceSets.size() > 0)
108  {
110  }
111 
112  emit finished();
113  return true;
114  }
115  else if (MsgLoadPreset::match(cmd))
116  {
117  MsgLoadPreset& notif = (MsgLoadPreset&) cmd;
118  loadPresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
119  return true;
120  }
121  else if (MsgSavePreset::match(cmd))
122  {
123  MsgSavePreset& notif = (MsgSavePreset&) cmd;
124  savePresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
126  m_settings.save();
127  return true;
128  }
129  else if (MsgDeletePreset::match(cmd))
130  {
131  MsgDeletePreset& notif = (MsgDeletePreset&) cmd;
132  const Preset *presetToDelete = notif.getPreset();
133  // remove preset from settings
134  m_settings.deletePreset(presetToDelete);
135  return true;
136  }
137  else if (MsgAddDeviceSet::match(cmd))
138  {
139  MsgAddDeviceSet& notif = (MsgAddDeviceSet&) cmd;
140  int direction = notif.getDirection();
141 
142  if (direction == 1) { // Single stream Tx
143  addSinkDevice();
144  } else if (direction == 0) { // Single stream Rx
145  addSourceDevice();
146  } // device type not (yet) supported
147 
148  return true;
149  }
150  else if (MsgRemoveLastDeviceSet::match(cmd))
151  {
152  if (m_deviceSets.size() > 0) {
154  }
155 
156  return true;
157  }
158  else if (MsgSetDevice::match(cmd))
159  {
160  MsgSetDevice& notif = (MsgSetDevice&) cmd;
161 
162  if (notif.getDeviceType() == 1) {
163  changeSampleSink(notif.getDeviceSetIndex(), notif.getDeviceIndex());
164  } else if (notif.getDeviceType() == 0) {
165  changeSampleSource(notif.getDeviceSetIndex(), notif.getDeviceIndex());
166  } // TODO: for MIMO
167 
168  return true;
169  }
170  else if (MsgAddChannel::match(cmd))
171  {
172  MsgAddChannel& notif = (MsgAddChannel&) cmd;
173  addChannel(notif.getDeviceSetIndex(), notif.getChannelRegistrationIndex());
174  return true;
175  }
176  else if (MsgDeleteChannel::match(cmd))
177  {
178  MsgDeleteChannel& notif = (MsgDeleteChannel&) cmd;
179  deleteChannel(notif.getDeviceSetIndex(), notif.getChannelIndex());
180  return true;
181  }
182  else
183  {
184  return false;
185  }
186 }
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
void savePresetSettings(Preset *preset, int tabIndex)
Definition: maincore.cpp:587
void addSinkDevice()
Definition: maincore.cpp:258
void addSourceDevice()
Definition: maincore.cpp:303
void sortPresets()
void changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
Definition: maincore.cpp:462
void loadPresetSettings(const Preset *preset, int tabIndex)
Definition: maincore.cpp:564
void changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
Definition: maincore.cpp:394
MainSettings m_settings
Definition: maincore.h:273
void removeLastDevice()
Definition: maincore.cpp:348
Definition: preset.h:28
static bool match(const Message *message)
Definition: message.cpp:45
void deletePreset(const Preset *preset)
void addChannel(int deviceSetIndex, int selectedChannelIndex)
Definition: maincore.cpp:530
void save() const
void finished()
void deleteChannel(int deviceSetIndex, int channelIndex)
Definition: maincore.cpp:547
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleMessages

void MainCore::handleMessages ( )
privateslot

Definition at line 188 of file maincore.cpp.

References Message::getIdentifier(), handleMessage(), m_inputMessageQueue, and MessageQueue::pop().

Referenced by MainCore().

189 {
190  Message* message;
191 
192  while ((message = m_inputMessageQueue.pop()) != 0)
193  {
194  qDebug("MainCore::handleMessages: message: %s", message->getIdentifier());
195  handleMessage(*message);
196  delete message;
197  }
198 }
Message * pop()
Pop message from queue.
MessageQueue m_inputMessageQueue
Definition: maincore.h:279
bool handleMessage(const Message &cmd)
Definition: maincore.cpp:103
virtual const char * getIdentifier() const
Definition: message.cpp:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadPresetSettings()

void MainCore::loadPresetSettings ( const Preset preset,
int  tabIndex 
)
private

Definition at line 564 of file maincore.cpp.

References Preset::getDescription(), Preset::getGroup(), PluginManager::getPluginAPI(), DeviceSet::loadRxChannelSettings(), DeviceAPI::loadSamplingDeviceSettings(), DeviceSet::loadTxChannelSettings(), DeviceSet::m_deviceAPI, m_deviceSets, DeviceSet::m_deviceSinkEngine, DeviceSet::m_deviceSourceEngine, and m_pluginManager.

Referenced by handleMessage().

565 {
566  qDebug("MainCore::loadPresetSettings: preset [%s | %s]",
567  qPrintable(preset->getGroup()),
568  qPrintable(preset->getDescription()));
569 
570  if (tabIndex >= 0)
571  {
572  DeviceSet *deviceSet = m_deviceSets[tabIndex];
573 
574  if (deviceSet->m_deviceSourceEngine) // source device
575  {
576  deviceSet->m_deviceAPI->loadSamplingDeviceSettings(preset);
577  deviceSet->loadRxChannelSettings(preset, m_pluginManager->getPluginAPI());
578  }
579  else if (deviceSet->m_deviceSinkEngine) // sink device
580  {
581  deviceSet->m_deviceAPI->loadSamplingDeviceSettings(preset);
582  deviceSet->loadTxChannelSettings(preset, m_pluginManager->getPluginAPI());
583  }
584  }
585 }
void loadTxChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
Definition: deviceset.cpp:256
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
DSPDeviceSourceEngine * m_deviceSourceEngine
Definition: deviceset.h:35
void loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
Definition: deviceset.cpp:160
PluginAPI * getPluginAPI()
Definition: pluginmanager.h:58
PluginManager * m_pluginManager
Definition: maincore.h:282
DeviceAPI * m_deviceAPI
Definition: deviceset.h:34
void loadSamplingDeviceSettings(const Preset *preset)
Definition: deviceapi.cpp:481
const QString & getDescription() const
Definition: preset.h:74
DSPDeviceSinkEngine * m_deviceSinkEngine
Definition: deviceset.h:36
const QString & getGroup() const
Definition: preset.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadSettings()

void MainCore::loadSettings ( )
private

Definition at line 200 of file maincore.cpp.

References MainSettings::load(), m_settings, setLoggingOptions(), and MainSettings::sortPresets().

Referenced by MainCore().

201 {
202  qDebug() << "MainCore::loadSettings";
203 
204  m_settings.load();
207 }
void setLoggingOptions()
Definition: maincore.cpp:209
void sortPresets()
MainSettings m_settings
Definition: maincore.h:273
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeLastDevice()

void MainCore::removeLastDevice ( )

Definition at line 348 of file maincore.cpp.

References m_deviceSets, m_dspEngine, DSPEngine::removeLastDeviceSinkEngine(), DSPEngine::removeLastDeviceSourceEngine(), DSPDeviceSourceEngine::stop(), DSPDeviceSinkEngine::stop(), DSPDeviceSourceEngine::stopAcquistion(), and DSPDeviceSinkEngine::stopGeneration().

Referenced by handleMessage(), and ~MainCore().

349 {
350  if (m_deviceSets.back()->m_deviceSourceEngine) // source set
351  {
352  DSPDeviceSourceEngine *lastDeviceEngine = m_deviceSets.back()->m_deviceSourceEngine;
353  lastDeviceEngine->stopAcquistion();
354 
355  // deletes old UI and input object
356  m_deviceSets.back()->freeRxChannels(); // destroys the channel instances
357  m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
358  m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
359  m_deviceSets.back()->m_deviceAPI->getSampleSource());
360  m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
361 
362  DeviceAPI *sourceAPI = m_deviceSets.back()->m_deviceAPI;
363  delete m_deviceSets.back();
364 
365  lastDeviceEngine->stop();
367 
368  delete sourceAPI;
369  }
370  else if (m_deviceSets.back()->m_deviceSinkEngine) // sink set
371  {
372  DSPDeviceSinkEngine *lastDeviceEngine = m_deviceSets.back()->m_deviceSinkEngine;
373  lastDeviceEngine->stopGeneration();
374 
375  // deletes old UI and output object
376  m_deviceSets.back()->freeTxChannels();
377  m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
378  m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
379  m_deviceSets.back()->m_deviceAPI->getSampleSink());
380  m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
381 
382  DeviceAPI *sinkAPI = m_deviceSets.back()->m_deviceAPI;
383  delete m_deviceSets.back();
384 
385  lastDeviceEngine->stop();
387 
388  delete sinkAPI;
389  }
390 
391  m_deviceSets.pop_back();
392 }
DSPEngine * m_dspEngine
Definition: maincore.h:275
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
void stop()
This thread stop.
void stopGeneration()
Stop generation sequence.
void removeLastDeviceSinkEngine()
Definition: dspengine.cpp:81
void removeLastDeviceSourceEngine()
Definition: dspengine.cpp:63
void stopAcquistion()
Stop acquisition sequence.
void stop()
This thread stop.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePresetSettings()

void MainCore::savePresetSettings ( Preset preset,
int  tabIndex 
)
private

Definition at line 587 of file maincore.cpp.

References Preset::clearChannels(), Preset::getDescription(), Preset::getGroup(), DeviceSet::m_deviceAPI, m_deviceSets, DeviceSet::m_deviceSinkEngine, DeviceSet::m_deviceSourceEngine, DeviceSet::saveRxChannelSettings(), DeviceAPI::saveSamplingDeviceSettings(), DeviceSet::saveTxChannelSettings(), and Preset::setSourcePreset().

Referenced by handleMessage().

588 {
589  qDebug("MainCore::savePresetSettings: preset [%s | %s]",
590  qPrintable(preset->getGroup()),
591  qPrintable(preset->getDescription()));
592 
593  // Save from currently selected source tab
594  //int currentSourceTabIndex = ui->tabInputsView->currentIndex();
595  DeviceSet *deviceSet = m_deviceSets[tabIndex];
596 
597  if (deviceSet->m_deviceSourceEngine) // source device
598  {
599  preset->clearChannels();
600  deviceSet->saveRxChannelSettings(preset);
601  deviceSet->m_deviceAPI->saveSamplingDeviceSettings(preset);
602  }
603  else if (deviceSet->m_deviceSinkEngine) // sink device
604  {
605  preset->clearChannels();
606  preset->setSourcePreset(false);
607  deviceSet->saveTxChannelSettings(preset);
608  deviceSet->m_deviceAPI->saveSamplingDeviceSettings(preset);
609  }
610 }
void clearChannels()
Definition: preset.h:84
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
DSPDeviceSourceEngine * m_deviceSourceEngine
Definition: deviceset.h:35
void saveRxChannelSettings(Preset *preset)
Definition: deviceset.cpp:238
void saveSamplingDeviceSettings(Preset *preset)
Definition: deviceapi.cpp:569
DeviceAPI * m_deviceAPI
Definition: deviceset.h:34
void setSourcePreset(bool isSourcePreset)
Definition: preset.h:65
void saveTxChannelSettings(Preset *preset)
Definition: deviceset.cpp:330
const QString & getDescription() const
Definition: preset.h:74
DSPDeviceSinkEngine * m_deviceSinkEngine
Definition: deviceset.h:36
const QString & getGroup() const
Definition: preset.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLoggingOptions()

void MainCore::setLoggingOptions ( )
private

Definition at line 209 of file maincore.cpp.

References arg(), qtwebapp::LoggerWithFile::createOrSetFileLogger(), qtwebapp::FileLoggerSettings::fileName, MainSettings::getConsoleMinLogLevel(), qtwebapp::LoggerWithFile::getFileLoggerSettings(), MainSettings::getFileMinLogLevel(), MainSettings::getLogFileName(), MainSettings::getUseLogFile(), qtwebapp::LoggerWithFile::hasFileLogger(), qtwebapp::LoggerWithFile::logToFile(), m_logger, m_settings, SDR_RX_SAMP_SZ, SDR_TX_SAMP_SZ, qtwebapp::LoggerWithFile::setConsoleMinMessageLevel(), qtwebapp::LoggerWithFile::setFileMinMessageLevel(), and qtwebapp::LoggerWithFile::setUseFileLogger().

Referenced by WebAPIAdapterSrv::instanceLoggingPut(), and loadSettings().

210 {
212 
214  {
215  qtwebapp::FileLoggerSettings fileLoggerSettings; // default values
216 
217  if (m_logger->hasFileLogger()) {
218  fileLoggerSettings = m_logger->getFileLoggerSettings(); // values from file logger if it exists
219  }
220 
221  fileLoggerSettings.fileName = m_settings.getLogFileName(); // put new values
222  m_logger->createOrSetFileLogger(fileLoggerSettings, 2000); // create file logger if it does not exist and apply settings in any case
223  }
224 
225  if (m_logger->hasFileLogger()) {
227  }
228 
230 
232  {
233 #if QT_VERSION >= 0x050400
234  QString appInfoStr(tr("%1 %2 Qt %3 %4b %5 %6 DSP Rx:%7b Tx:%8b PID %9")
235  .arg(QCoreApplication::applicationName())
236  .arg(QCoreApplication::applicationVersion())
237  .arg(QT_VERSION_STR)
238  .arg(QT_POINTER_SIZE*8)
239  .arg(QSysInfo::currentCpuArchitecture())
240  .arg(QSysInfo::prettyProductName())
243  .arg(QCoreApplication::applicationPid()));
244 #else
245  QString appInfoStr(tr("%1 %2 Qt %3 %4b DSP Rx:%5b Tx:%6b PID %7")
246  .arg(QCoreApplication::applicationName())
247  .arg(QCoreApplication::applicationVersion())
248  .arg(QT_VERSION_STR)
249  .arg(QT_POINTER_SIZE*8)
252  .arg(QCoreApplication::applicationPid());
253  #endif
254  m_logger->logToFile(QtInfoMsg, appInfoStr);
255  }
256 }
const QString & getLogFileName() const
Definition: mainsettings.h:65
void setUseFileLogger(bool use)
void createOrSetFileLogger(const FileLoggerSettings &settings, const int refreshInterval=10000)
bool getUseLogFile() const
Definition: mainsettings.h:64
FileLoggerSettings getFileLoggerSettings() const
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
#define SDR_RX_SAMP_SZ
Definition: dsptypes.h:32
MainSettings m_settings
Definition: maincore.h:273
QtMsgType getFileMinLogLevel() const
Definition: mainsettings.h:63
void setConsoleMinMessageLevel(const QtMsgType &msgLevel)
qtwebapp::LoggerWithFile * m_logger
Definition: maincore.h:277
#define SDR_TX_SAMP_SZ
Definition: dsptypes.h:38
void logToFile(const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
void setFileMinMessageLevel(const QtMsgType &msgLevel)
QtMsgType getConsoleMinLogLevel() const
Definition: mainsettings.h:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WebAPIAdapterSrv

friend class WebAPIAdapterSrv
friend

Definition at line 69 of file maincore.h.

Referenced by MainCore().

Member Data Documentation

◆ m_apiAdapter

WebAPIAdapterSrv* MainCore::m_apiAdapter
private

Definition at line 286 of file maincore.h.

Referenced by MainCore(), and ~MainCore().

◆ m_apiServer

WebAPIServer* MainCore::m_apiServer
private

Definition at line 285 of file maincore.h.

Referenced by MainCore(), and ~MainCore().

◆ m_deviceSets

std::vector<DeviceSet*> MainCore::m_deviceSets
private

◆ m_dspEngine

DSPEngine* MainCore::m_dspEngine
private

◆ m_inputMessageQueue

MessageQueue MainCore::m_inputMessageQueue
private

◆ m_instance

MainCore * MainCore::m_instance = 0
staticprivate

Definition at line 272 of file maincore.h.

Referenced by MainCore().

◆ m_lastEngineState

int MainCore::m_lastEngineState
private

Definition at line 276 of file maincore.h.

◆ m_logger

qtwebapp::LoggerWithFile* MainCore::m_logger
private

◆ m_masterTabIndex

int MainCore::m_masterTabIndex
private

Definition at line 274 of file maincore.h.

◆ m_masterTimer

QTimer MainCore::m_masterTimer
private

Definition at line 280 of file maincore.h.

Referenced by MainCore().

◆ m_pluginManager

PluginManager* MainCore::m_pluginManager
private

◆ m_requestMapper

WebAPIRequestMapper* MainCore::m_requestMapper
private

Definition at line 284 of file maincore.h.

Referenced by MainCore(), and ~MainCore().

◆ m_settings

MainSettings MainCore::m_settings
private

The documentation for this class was generated from the following files: