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.
maincore.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB. //
3 // //
4 // Swagger server adapter interface //
5 // //
6 // This program is free software; you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation as version 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // This program is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License V3 for more details. //
15 // //
16 // You should have received a copy of the GNU General Public License //
17 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
19 
20 #include <QDebug>
21 #include <QSysInfo>
22 #include <QResource>
23 
24 #include "dsp/dspengine.h"
27 #include "device/deviceapi.h"
28 #include "device/deviceset.h"
30 #include "plugin/pluginmanager.h"
31 #include "loggerwithfile.h"
33 #include "webapi/webapiserver.h"
35 
36 #include "maincore.h"
37 
47 
49 
50 MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QObject *parent) :
51  QObject(parent),
52  m_settings(),
53  m_masterTabIndex(-1),
54  m_dspEngine(DSPEngine::instance()),
55  m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
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 }
84 
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 }
102 
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;
119  return true;
120  }
121  else if (MsgSavePreset::match(cmd))
122  {
123  MsgSavePreset& notif = (MsgSavePreset&) cmd;
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) {
164  } else if (notif.getDeviceType() == 0) {
166  } // TODO: for MIMO
167 
168  return true;
169  }
170  else if (MsgAddChannel::match(cmd))
171  {
172  MsgAddChannel& notif = (MsgAddChannel&) cmd;
174  return true;
175  }
176  else if (MsgDeleteChannel::match(cmd))
177  {
178  MsgDeleteChannel& notif = (MsgDeleteChannel&) cmd;
180  return true;
181  }
182  else
183  {
184  return false;
185  }
186 }
187 
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 }
199 
201 {
202  qDebug() << "MainCore::loadSettings";
203 
204  m_settings.load();
207 }
208 
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 }
257 
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 }
302 
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 }
347 
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 }
393 
394 void MainCore::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
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 }
461 
462 void MainCore::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
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 }
529 
530 void MainCore::addChannel(int deviceSetIndex, int selectedChannelIndex)
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 }
546 
547 void MainCore::deleteChannel(int deviceSetIndex, int channelIndex)
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 }
563 
564 void MainCore::loadPresetSettings(const Preset* preset, int tabIndex)
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 }
586 
587 void MainCore::savePresetSettings(Preset* preset, int tabIndex)
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 }
611 
void clearChannels()
Definition: preset.h:84
void setLoggingOptions()
Definition: maincore.cpp:209
void setHardwareId(const QString &id)
Definition: deviceapi.cpp:364
void setBuddyLeader(bool isBuddyLeader)
Definition: deviceapi.h:164
DSPEngine * m_dspEngine
Definition: maincore.h:275
const QString & getLogFileName() const
Definition: mainsettings.h:65
void setUseFileLogger(bool use)
WebAPIAdapterSrv * m_apiAdapter
Definition: maincore.h:286
int getFileSinkDeviceIndex() const
Get Tx default device.
void loadTxChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
Definition: deviceset.cpp:256
Message * pop()
Pop message from queue.
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.
WebAPIServer * m_apiServer
Definition: maincore.h:285
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.
void savePresetSettings(Preset *preset, int tabIndex)
Definition: maincore.cpp:587
DeviceSampleSource * getSampleSource()
Return pointer to the device sample source (single Rx) or nullptr.
Definition: deviceapi.cpp:213
void addSinkDevice()
Definition: maincore.cpp:258
void createOrSetFileLogger(const FileLoggerSettings &settings, const int refreshInterval=10000)
DSPDeviceSourceEngine * addDeviceSourceEngine()
Definition: dspengine.cpp:56
void loadPlugins(const QString &pluginsSubDir)
bool getMIMOSupport() const
Definition: mainparser.h:37
bool getUseLogFile() const
Definition: mainsettings.h:64
Exposes a single output stream that can be one of the streams of a physical device.
Definition: deviceapi.h:48
void handleMessages()
Definition: maincore.cpp:188
MainCore(qtwebapp::LoggerWithFile *logger, const MainParser &parser, QObject *parent=0)
Definition: maincore.cpp:50
QString hardwareId
The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
void setAdapter(WebAPIAdapterInterface *adapter)
void addSourceDevice()
Definition: maincore.cpp:303
DSPDeviceSourceEngine * m_deviceSourceEngine
Definition: deviceset.h:35
void stop()
This thread stop.
const Preset * getPreset() const
Definition: maincore.h:128
DSPDeviceSinkEngine * addDeviceSinkEngine()
Definition: dspengine.cpp:74
Preset * getPreset() const
Definition: maincore.h:102
MessageQueue m_inputMessageQueue
Definition: maincore.h:279
void start()
This thread start.
void setSamplingDeviceSequence(int sequence)
Definition: deviceapi.h:114
FileLoggerSettings getFileLoggerSettings() const
void loadSettings()
Definition: maincore.cpp:200
~MainCore()
Definition: maincore.cpp:85
DeviceSampleSink * getSampleSink()
Return pointer to the device sample sink (single Tx) or nullptr.
Definition: deviceapi.cpp:222
void sortPresets()
Exposes a single input stream that can be one of the streams of a physical device.
Definition: deviceapi.h:47
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
void setSamplingDeviceId(const QString &id)
Definition: deviceapi.h:110
void stopGeneration()
Stop generation sequence.
void setSamplingDeviceDisplayName(const QString &name)
Definition: deviceapi.h:113
void changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
Definition: maincore.cpp:462
int getChannelIndex() const
Definition: maincore.h:251
#define SDR_RX_SAMP_SZ
Definition: dsptypes.h:32
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
int getDeviceSetIndex() const
Definition: maincore.h:103
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
Definition: message.h:52
void loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
Definition: deviceset.cpp:160
AMBEEngine * getAMBEEngine()
Definition: dspengine.h:56
const QString & getSamplingDeviceId() const
Definition: deviceapi.h:120
int getDirection() const
Definition: maincore.h:163
void addRxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
Definition: deviceset.cpp:142
void saveRxChannelSettings(Preset *preset)
Definition: deviceset.cpp:238
void removeLastDevice()
Definition: maincore.cpp:348
void removeLastDeviceSinkEngine()
Definition: dspengine.cpp:81
QtMsgType getFileMinLogLevel() const
Definition: mainsettings.h:63
void saveSamplingDeviceSettings(Preset *preset)
Definition: deviceapi.cpp:569
int deviceNbItems
Number of items (or streams) in the device. >1 for composite devices.
Definition: preset.h:28
Preset * getWorkingPreset()
Definition: mainsettings.h:47
void setConsoleMinMessageLevel(const QtMsgType &msgLevel)
uint32_t getUID() const
void removeLastDeviceSourceEngine()
Definition: dspengine.cpp:63
PluginAPI * getPluginAPI()
Definition: pluginmanager.h:58
void stopAcquistion()
Stop acquisition sequence.
void setAMBEEngine(AMBEEngine *ambeEngine)
Definition: mainsettings.h:70
friend class WebAPIAdapterSrv
Definition: maincore.h:69
static bool match(const Message *message)
Definition: message.cpp:45
PluginManager * m_pluginManager
Definition: maincore.h:282
int getDeviceSetIndex() const
Definition: maincore.h:80
qtwebapp::LoggerWithFile * m_logger
Definition: maincore.h:277
DeviceAPI * m_deviceAPI
Definition: deviceset.h:34
void deletePreset(const Preset *preset)
void setSourcePreset(bool isSourcePreset)
Definition: preset.h:65
virtual DeviceSampleSink * createSampleSinkPluginInstance(const QString &sinkId, DeviceAPI *deviceAPI)
#define SDR_TX_SAMP_SZ
Definition: dsptypes.h:38
void setMIMOSupport(bool mimoSupport)
Definition: dspengine.h:85
void deleteRxChannel(int channelIndex)
Definition: deviceset.cpp:122
WebAPIRequestMapper * m_requestMapper
Definition: maincore.h:284
QString id
The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...
void logToFile(const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0)
void clearBuddiesLists()
Definition: deviceapi.cpp:740
int getDeviceSetIndex() const
Definition: maincore.h:224
int getDeviceIndex() const
Definition: maincore.h:199
QString serial
The device serial number defined by the vendor or a fake one (SDRplay)
void saveTxChannelSettings(Preset *preset)
Definition: deviceset.cpp:330
virtual void deleteSampleSinkPluginInstanceOutput(DeviceSampleSink *sink)
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
PluginInterface * getPluginInterface()
Definition: deviceapi.h:132
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
bool handleMessage(const Message &cmd)
Definition: maincore.cpp:103
QTimer m_masterTimer
Definition: maincore.h:280
const PluginInterface::SamplingDevice * getTxSamplingDevice(int deviceIndex) const
void setAudioDeviceManager(AudioDeviceManager *audioDeviceManager)
Definition: mainsettings.h:69
void start()
This thread start.
void addChannel(int deviceSetIndex, int selectedChannelIndex)
Definition: maincore.cpp:530
const QString & getHardwareId() const
Definition: deviceapi.h:119
DeviceUserArgs & getDeviceUserArgs()
Definition: mainsettings.h:66
void setSamplingDeviceSerial(const QString &serial)
Definition: deviceapi.h:112
virtual const char * getIdentifier() const
Definition: message.cpp:35
int getDeviceType() const
Definition: maincore.h:200
void save() const
const PluginInterface::SamplingDevice * getRxSamplingDevice(int deviceIndex) const
const Preset * getPreset() const
Definition: maincore.h:79
virtual void deleteSampleSourcePluginInstanceInput(DeviceSampleSource *source)
void setDeviceItemIndex(uint32_t index)
Definition: deviceapi.cpp:374
int getDeviceSetIndex() const
Definition: maincore.h:250
void setFileMinMessageLevel(const QtMsgType &msgLevel)
void resetSamplingDeviceId()
Definition: deviceapi.h:111
void loadSamplingDeviceSettings(const Preset *preset)
Definition: deviceapi.cpp:481
QtMsgType getConsoleMinLogLevel() const
Definition: mainsettings.h:62
int getFileInputDeviceIndex() const
Get Rx default device.
const QString & getDescription() const
Definition: preset.h:74
const QString & getServerAddress() const
Definition: mainparser.h:35
void setSamplingDevicePluginInterface(PluginInterface *iface)
Definition: deviceapi.cpp:379
void finished()
static DeviceEnumerator * instance()
DSPDeviceSinkEngine * m_deviceSinkEngine
Definition: deviceset.h:36
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
uint16_t getServerPort() const
Definition: mainparser.h:36
void deleteTxChannel(int channelIndex)
Definition: deviceset.cpp:132
int getDeviceSetIndex() const
Definition: maincore.h:198
const QString & getGroup() const
Definition: preset.h:72
void addTxChannel(int selectedChannelIndex, PluginAPI *pluginAPI)
Definition: deviceset.cpp:151
static MainCore * m_instance
Definition: maincore.h:272
void stop()
This thread stop.
int getChannelRegistrationIndex() const
Definition: maincore.h:225
QString findUserArgs(const QString &id, int sequence)
void deleteChannel(int deviceSetIndex, int channelIndex)
Definition: maincore.cpp:547