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.
deviceapi.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
19 #include "plugin/plugininterface.h"
23 #include "dsp/dspengine.h"
24 #include "dsp/devicesamplesource.h"
25 #include "dsp/devicesamplesink.h"
26 #include "dsp/devicesamplemimo.h"
27 #include "settings/preset.h"
28 #include "channel/channelapi.h"
29 
30 #include "deviceapi.h"
31 
33  StreamType streamType,
34  int deviceTabIndex,
35  DSPDeviceSourceEngine *deviceSourceEngine,
36  DSPDeviceSinkEngine *deviceSinkEngine,
37  DSPDeviceMIMOEngine *deviceMIMOEngine
38 ) :
39  m_streamType(streamType),
40  m_deviceTabIndex(deviceTabIndex),
41  m_deviceNbItems(1),
42  m_deviceItemIndex(0),
43  m_nbSourceStreams(0),
44  m_nbSinkStreams(0),
45  m_pluginInterface(nullptr),
46  m_masterTimer(DSPEngine::instance()->getMasterTimer()),
47  m_samplingDeviceSequence(0),
48  m_samplingDevicePluginInstanceUI(0),
49  m_buddySharedPtr(nullptr),
50  m_isBuddyLeader(false),
51  m_deviceSourceEngine(deviceSourceEngine),
52  m_deviceSinkEngine(deviceSinkEngine),
53  m_deviceMIMOEngine(deviceMIMOEngine)
54 {
55 }
56 
58 {
59 }
60 
61 void DeviceAPI::addSourceStream(bool connect)
62 {
63  if (m_deviceMIMOEngine) {
65  }
66 }
67 
69 {
70  if (m_deviceMIMOEngine) {
72  }
73 }
74 
75 void DeviceAPI::addSinkStream(bool connect)
76 {
77  if (m_deviceMIMOEngine) {
79  }
80 }
81 
83 {
84  if (m_deviceMIMOEngine) {
86  }
87 }
88 
89 void DeviceAPI::addAncillarySink(BasebandSampleSink *sink, unsigned int index)
90 {
93  } else if (m_deviceSinkEngine) {
95  } else if (m_deviceMIMOEngine) {
97  }
98 }
99 
100 void DeviceAPI::removeAncillarySink(BasebandSampleSink* sink, unsigned int index)
101 {
102  if (m_deviceSourceEngine) {
104  } else if (m_deviceSinkEngine) {
106  } else if (m_deviceMIMOEngine) {
108  }
109 }
110 
111 void DeviceAPI::setSpectrumSinkInput(bool sourceElseSink, unsigned int index)
112 {
113  if (m_deviceMIMOEngine) { // In practice this is only used in the MIMO case
114  m_deviceMIMOEngine->setSpectrumSinkInput(sourceElseSink, index);
115  }
116 }
117 
119 {
120  if (m_deviceSourceEngine) {
122  } else if (m_deviceMIMOEngine) {
123  m_deviceMIMOEngine->addChannelSink(sink, streamIndex);
124  }
125 }
126 
128 {
129  (void) streamIndex;
130 
131  if (m_deviceSourceEngine) {
133  } else if (m_deviceMIMOEngine) {
134  m_deviceMIMOEngine->removeChannelSink(sink, streamIndex);
135  }
136 }
137 
139 {
140  (void) streamIndex;
141 
142  if (m_deviceSinkEngine) {
144  }
145 }
146 
148 {
149  (void) streamIndex;
150 
151  if (m_deviceSinkEngine) {
153  }
154 }
155 
156 void DeviceAPI::addChannelSinkAPI(ChannelAPI* channelAPI, int streamIndex)
157 {
158  (void) streamIndex;
159  m_channelSinkAPIs.append(channelAPI);
161 }
162 
163 void DeviceAPI::removeChannelSinkAPI(ChannelAPI* channelAPI, int streamIndex)
164 {
165  (void) streamIndex;
166 
167  if (m_channelSinkAPIs.removeOne(channelAPI)) {
169  }
170 
171  channelAPI->setIndexInDeviceSet(-1);
172 }
173 
174 void DeviceAPI::addChannelSourceAPI(ChannelAPI* channelAPI, int streamIndex)
175 {
176  (void) streamIndex;
177  m_channelSourceAPIs.append(channelAPI);
179 }
180 
181 void DeviceAPI::removeChannelSourceAPI(ChannelAPI* channelAPI, int streamIndex)
182 {
183  (void) streamIndex;
184 
185  if (m_channelSourceAPIs.removeOne(channelAPI)) {
187  }
188 
189  channelAPI->setIndexInDeviceSet(-1);
190 }
191 
193 {
194  if (m_deviceSourceEngine) {
196  }
197 }
198 
200 {
201  if (m_deviceSinkEngine) {
203  }
204 }
205 
207 {
208  if (m_deviceMIMOEngine) {
210  }
211 }
212 
214 {
215  if (m_deviceSourceEngine) {
217  } else {
218  return nullptr;
219  }
220 }
221 
223 {
224  if (m_deviceSinkEngine) {
225  return m_deviceSinkEngine->getSink();
226  } else {
227  return nullptr;
228  }
229 }
230 
232 {
233  if (m_deviceMIMOEngine) {
234  return m_deviceMIMOEngine->getMIMO();
235  } else {
236  return nullptr;
237  }
238 }
239 
241 {
242  if (m_deviceSourceEngine) {
244  } else if (m_deviceSinkEngine) {
246  } else if (m_deviceMIMOEngine) {
248  } else {
249  return false;
250  }
251 }
252 
254 {
255  if (m_deviceSourceEngine) {
257  } else if (m_deviceSinkEngine) {
259  } else if (m_deviceMIMOEngine) {
261  } else {
262  return false;
263  }
264 }
265 
267 {
268  if (m_deviceSourceEngine) {
270  } else if (m_deviceSinkEngine) {
272  } else if (m_deviceMIMOEngine) {
274  }
275 }
276 
278 {
279  if (m_deviceSourceEngine) {
281  } else if (m_deviceSinkEngine) {
283  } else if (m_deviceMIMOEngine) {
285  } else {
286  return StError;
287  }
288 }
289 
291 {
292  if (m_deviceSourceEngine) {
294  } else if (m_deviceSinkEngine) {
296  } else if (m_deviceMIMOEngine) {
298  } else {
299  return "Not implemented";
300  }
301 }
302 
304 {
305  if (m_deviceSourceEngine) {
306  return m_deviceSourceEngine->getUID();
307  } else if (m_deviceSinkEngine) {
308  return m_deviceSinkEngine->getUID();
309  } else if (m_deviceMIMOEngine) {
310  return m_deviceMIMOEngine->getUID();
311  } else {
312  return 0;
313  }
314 }
315 
317 {
318  if (m_deviceSourceEngine) {
320  } else if (m_deviceSinkEngine) {
322  } else if (m_deviceMIMOEngine) {
324  } else {
325  return nullptr;
326  }
327 }
328 
330 {
331  if (m_deviceSourceEngine) {
333  } else if (m_deviceSinkEngine) {
335  } else if (m_deviceMIMOEngine) {
337  } else {
338  return nullptr;
339  }
340 }
341 
343 {
344  if (m_deviceSourceEngine) {
346  } else if (m_deviceSinkEngine) {
348  } else if (m_deviceMIMOEngine) {
350  } else {
351  return nullptr;
352  }
353 }
354 
355 void DeviceAPI::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex)
356 {
357  if (m_deviceSourceEngine) {
358  m_deviceSourceEngine->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection);
359  } else if (m_deviceMIMOEngine) {
360  m_deviceMIMOEngine->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection, streamIndex);
361  }
362 }
363 
364 void DeviceAPI::setHardwareId(const QString& id)
365 {
366  m_hardwareId = id;
367 }
368 
370 {
371  m_deviceNbItems = nbItems;
372 }
373 
375 {
376  m_deviceItemIndex = index;
377 }
378 
380 {
381  m_pluginInterface = iface;
382 }
383 
385 {
387 }
388 
390 {
392  {
393  switch(m_deviceSourceEngine->state())
394  {
396  state = "notStarted";
397  break;
399  state = "idle";
400  break;
402  state = "ready";
403  break;
405  state = "running";
406  break;
408  state = "error";
409  break;
410  default:
411  state = "notStarted";
412  break;
413  }
414  }
415  else if (m_deviceSinkEngine)
416  {
417  switch(m_deviceSinkEngine->state())
418  {
420  state = "notStarted";
421  break;
423  state = "idle";
424  break;
426  state = "ready";
427  break;
429  state = "running";
430  break;
432  state = "error";
433  break;
434  default:
435  state = "notStarted";
436  break;
437  }
438  }
439  else
440  {
441  state = "notStarted";
442  }
443 }
444 
445 ChannelAPI *DeviceAPI::getChanelSinkAPIAt(int index, int streamIndex)
446 {
447  (void) streamIndex;
448 
450  {
451  if (index < m_channelSinkAPIs.size()) {
452  return m_channelSinkAPIs.at(index);
453  } else {
454  return nullptr;
455  }
456  }
457  else // TODO: not implemented
458  {
459  return nullptr;
460  }
461 }
462 
463 ChannelAPI *DeviceAPI::getChanelSourceAPIAt(int index, int streamIndex)
464 {
465  (void) streamIndex;
466 
468  {
469  if (index < m_channelSourceAPIs.size()) {
470  return m_channelSourceAPIs.at(index);
471  } else {
472  return nullptr;
473  }
474  }
475  else // TODO: not implemented
476  {
477  return nullptr;
478  }
479 }
480 
482 {
483  if (m_deviceSourceEngine && (preset->isSourcePreset()))
484  {
485  qDebug("DeviceAPI::loadSamplingDeviceSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
486 
488  qint64 centerFrequency = preset->getCenterFrequency();
489  qDebug("DeviceAPI::loadSamplingDeviceSettings: center frequency: %llu Hz", centerFrequency);
490 
491  if (sourceConfig != 0)
492  {
493  qDebug("DeviceAPI::loadSamplingDeviceSettings: deserializing source %s[%d]: %s",
495 
496  if (m_samplingDevicePluginInstanceUI != 0) // GUI flavor
497  {
499  }
500  else if (m_deviceSourceEngine->getSource() != 0) // Server flavor
501  {
502  m_deviceSourceEngine->getSource()->deserialize(*sourceConfig);
503  }
504  else
505  {
506  qDebug("DeviceAPI::loadSamplingDeviceSettings: deserializing no source");
507  }
508  }
509  else
510  {
511  qDebug("DeviceAPI::loadSamplingDeviceSettings: source %s[%d]: %s not found",
513  }
514 
515  // set center frequency anyway
516  if (m_samplingDevicePluginInstanceUI != 0) // GUI flavor
517  {
519  }
520  else if (m_deviceSourceEngine->getSource() != 0) // Server flavor
521  {
523  }
524  else
525  {
526  qDebug("DeviceAPI::loadSamplingDeviceSettings: no source");
527  }
528  }
529  else if (m_deviceSinkEngine && (!preset->isSourcePreset())) // TODO: refine preset stream type
530  {
531  qDebug("DeviceAPI::loadSamplingDeviceSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
532 
534  qint64 centerFrequency = preset->getCenterFrequency();
535  qDebug("DeviceAPI::loadSamplingDeviceSettings: center frequency: %llu Hz", centerFrequency);
536 
537  if (sinkConfig != 0)
538  {
539  qDebug("DeviceAPI::loadSamplingDeviceSettings: deserializing sink %s[%d]: %s",
541 
542  if (m_samplingDevicePluginInstanceUI != 0) // GUI flavor
543  {
546  }
547  else if (m_deviceSinkEngine->getSink() != 0) // Server flavor
548  {
549  m_deviceSinkEngine->getSink()->deserialize(*sinkConfig);
550  m_deviceSinkEngine->getSink()->setCenterFrequency(centerFrequency);
551  }
552  else
553  {
554  qDebug("DeviceAPI::loadSamplingDeviceSettings: no sink");
555  }
556  }
557  else
558  {
559  qDebug("DeviceAPI::loadSamplingDeviceSettings: sink %s[%d]: %s not found",
561  }
562  }
563  else
564  {
565  qDebug("DeviceAPI::loadSamplingDeviceSettings: Loading preset [%s | %s] is not a suitable preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
566  }
567 }
568 
570 {
571  if (m_deviceSourceEngine && (preset->isSourcePreset()))
572  {
573  qDebug("DeviceAPI::saveSamplingDeviceSettings: serializing source %s[%d]: %s",
575 
577  {
580  }
581  else if (m_deviceSourceEngine->getSource() != 0)
582  {
585  }
586  else
587  {
588  qDebug("DeviceAPI::saveSamplingDeviceSettings: no source");
589  }
590  }
591  else if (m_deviceSinkEngine && (!preset->isSourcePreset())) // TODO: refine preset stream type
592  {
593  qDebug("DeviceAPI::saveSamplingDeviceSettings: serializing sink %s[%d]: %s",
595 
596  if (m_samplingDevicePluginInstanceUI != 0) // GUI flavor
597  {
600  }
601  else if (m_deviceSinkEngine->getSink() != 0) // Server flavor
602  {
605  }
606  else
607  {
608  qDebug("DeviceAPI::saveSamplingDeviceSettings: no sink");
609  }
610  }
611  else
612  {
613  qDebug("DeviceAPI::saveSamplingDeviceSettings: not a suitable preset");
614  }
615 }
616 
618 {
619  if (buddy->m_streamType != StreamSingleRx)
620  {
621  qDebug("DeviceAPI::addSourceBuddy: buddy %s(%s) is not of single Rx type",
622  qPrintable(buddy->getHardwareId()),
623  qPrintable(buddy->getSamplingDeviceSerial()));
624  return;
625  }
626 
627  m_sourceBuddies.push_back(buddy);
628 
629  if (m_streamType == StreamSingleRx) {
630  buddy->m_sourceBuddies.push_back(this); // this is a source
631  } else if (m_streamType == StreamSingleTx) {
632  buddy->m_sinkBuddies.push_back(this); // this is a sink
633  } else {
634  qDebug("DeviceAPI::addSourceBuddy: not relevant if this is not a single Rx or Tx");
635  return;
636  }
637 
638  qDebug("DeviceAPI::addSourceBuddy: added buddy %s(%s) [%llu] <-> [%llu]",
639  qPrintable(buddy->getHardwareId()),
640  qPrintable(buddy->getSamplingDeviceSerial()),
641  (quint64) buddy,
642  (quint64) this);
643 }
644 
645 
647 {
648  if (buddy->m_streamType != StreamSingleTx)
649  {
650  qDebug("DeviceAPI::addSinkBuddy: buddy %s(%s) is not of single Tx type",
651  qPrintable(buddy->getHardwareId()),
652  qPrintable(buddy->getSamplingDeviceSerial()));
653  return;
654  }
655 
656  m_sinkBuddies.push_back(buddy);
657 
658  if (m_streamType == StreamSingleRx) {
659  buddy->m_sourceBuddies.push_back(this); // this is a source
660  } else if (m_streamType == StreamSingleTx) {
661  buddy->m_sinkBuddies.push_back(this); // this is a sink
662  } else {
663  qDebug("DeviceAPI::addSinkBuddy: not relevant if this is not a single Rx or Tx");
664  return;
665  }
666 
667  qDebug("DeviceAPI::addSinkBuddy: added buddy %s(%s) [%llu] <-> [%llu]",
668  qPrintable(buddy->getHardwareId()),
669  qPrintable(buddy->getSamplingDeviceSerial()),
670  (quint64) buddy,
671  (quint64) this);
672 }
673 
675 {
676  if (buddy->m_streamType != StreamSingleRx)
677  {
678  qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) is not of single Rx type",
679  qPrintable(buddy->getHardwareId()),
680  qPrintable(buddy->getSamplingDeviceSerial()));
681  return;
682  }
683 
684  std::vector<DeviceAPI*>::iterator it = m_sourceBuddies.begin();
685 
686  for (;it != m_sourceBuddies.end(); ++it)
687  {
688  if (*it == buddy)
689  {
690  qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]",
691  qPrintable(buddy->getHardwareId()),
692  qPrintable(buddy->getSamplingDeviceSerial()),
693  (quint64) (*it),
694  (quint64) this);
695  m_sourceBuddies.erase(it);
696  return;
697  }
698  }
699 
700  qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]",
701  qPrintable(buddy->getHardwareId()),
702  qPrintable(buddy->getSamplingDeviceSerial()),
703  (quint64) buddy,
704  (quint64) this);
705 }
706 
708 {
709  if (buddy->m_streamType != StreamSingleTx)
710  {
711  qDebug("DeviceAPI::removeSinkBuddy: buddy %s(%s) is not of single Tx type",
712  qPrintable(buddy->getHardwareId()),
713  qPrintable(buddy->getSamplingDeviceSerial()));
714  return;
715  }
716 
717  std::vector<DeviceAPI*>::iterator it = m_sinkBuddies.begin();
718 
719  for (;it != m_sinkBuddies.end(); ++it)
720  {
721  if (*it == buddy)
722  {
723  qDebug("DeviceAPI::removeSinkBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]",
724  qPrintable(buddy->getHardwareId()),
725  qPrintable(buddy->getSamplingDeviceSerial()),
726  (quint64) (*it),
727  (quint64) this);
728  m_sinkBuddies.erase(it);
729  return;
730  }
731  }
732 
733  qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]",
734  qPrintable(buddy->getHardwareId()),
735  qPrintable(buddy->getSamplingDeviceSerial()),
736  (quint64) buddy,
737  (quint64) this);
738 }
739 
741 {
742  std::vector<DeviceAPI*>::iterator itSource = m_sourceBuddies.begin();
743  std::vector<DeviceAPI*>::iterator itSink = m_sinkBuddies.begin();
744  bool leaderElected = false;
745 
746  for (;itSource != m_sourceBuddies.end(); ++itSource)
747  {
748  if (isBuddyLeader() && !leaderElected)
749  {
750  (*itSource)->setBuddyLeader(true);
751  leaderElected = true;
752  }
753 
754  (*itSource)->removeSinkBuddy(this);
755  }
756 
757  m_sourceBuddies.clear();
758 
759  for (;itSink != m_sinkBuddies.end(); ++itSink)
760  {
761  if (isBuddyLeader() && !leaderElected)
762  {
763  (*itSink)->setBuddyLeader(true);
764  leaderElected = true;
765  }
766 
767  (*itSink)->removeSinkBuddy(this);
768  }
769 
770  m_sinkBuddies.clear();
771 }
772 
774 {
776  {
777  for (int i = 0; i < m_channelSinkAPIs.size(); ++i)
778  {
779  m_channelSinkAPIs.at(i)->setIndexInDeviceSet(i);
780  m_channelSinkAPIs.at(i)->setDeviceSetIndex(m_deviceTabIndex);
781  m_channelSinkAPIs.at(i)->setDeviceAPI(this);
782  }
783  }
784  else if (m_streamType == StreamSingleTx)
785  {
786  for (int i = 0; i < m_channelSourceAPIs.size(); ++i)
787  {
788  m_channelSourceAPIs.at(i)->setIndexInDeviceSet(i);
789  m_channelSourceAPIs.at(i)->setDeviceSetIndex(m_deviceTabIndex);
790  m_channelSourceAPIs.at(i)->setDeviceAPI(this);
791  }
792  }
793 }
void setSampleMIMO(DeviceSampleMIMO *mimo)
Set the device sample MIMO.
Definition: deviceapi.cpp:206
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
void setHardwareId(const QString &id)
Definition: deviceapi.cpp:364
void setCenterFrequency(const quint64 centerFrequency)
Definition: preset.h:75
void setSink(DeviceSampleSink *sink)
Set the sample sink type.
void addSinkStream(bool connect)
Definition: deviceapi.cpp:75
DeviceSampleSink * getSink()
engine is before initialization
engine is ready to run
void setMIMO(DeviceSampleMIMO *mimo)
Set the sample MIMO type.
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
virtual QByteArray serialize() const =0
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
void removeChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:181
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void removeSinkBuddy(DeviceAPI *buddy)
Definition: deviceapi.cpp:707
engine is before initialization
State state() const
Return DSP engine current state.
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
QString m_samplingDeviceId
The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...
Definition: deviceapi.h:187
void setSamplingDevicePluginInstanceGUI(PluginInstanceGUI *gui)
Definition: deviceapi.cpp:384
uint32_t m_deviceNbItems
Number of items in the physical device either Rx or Tx. Can be >1 for NxM devices (i...
Definition: deviceapi.h:181
QString errorMessage()
Return the current error message.
ChannelAPI * getChanelSinkAPIAt(int index, int streamIndex=0)
Definition: deviceapi.cpp:445
bool isBuddyLeader() const
Definition: deviceapi.h:163
MessageQueue * getInputMessageQueue()
DeviceSampleSource * getSampleSource()
Return pointer to the device sample source (single Rx) or nullptr.
Definition: deviceapi.cpp:213
void removeChannelSink(ThreadedBasebandSampleSink *sink, int index=0)
Remove a channel sink that runs on its own thread.
const QByteArray * findBestDeviceConfig(const QString &deviceId, const QString &deviceSerial, int deviceSequence) const
Definition: preset.cpp:215
QString errorMessage()
Return the current error message.
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection)
Configure DSP corrections.
quint64 getCenterFrequency() const
Definition: preset.h:76
DeviceSampleMIMO * getMIMO()
MessageQueue * getInputMessageQueue()
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
void removeChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Remove a channel source (Tx)
Definition: deviceapi.cpp:147
DeviceSampleSource * getSource()
Exposes a single output stream that can be one of the streams of a physical device.
Definition: deviceapi.h:48
DSPDeviceSinkEngine * m_deviceSinkEngine
Definition: deviceapi.h:208
virtual qint64 getCenterFrequency() const =0
void removeSpectrumSink(BasebandSampleSink *spectrumSink)
Add a spectrum vis baseband sample sink.
void removeSink(BasebandSampleSink *sink)
Remove a sample sink.
virtual void setCenterFrequency(qint64 centerFrequency)=0
void setSpectrumSinkInput(bool sourceElseSink=true, unsigned int index=0)
Used in the MIMO case to select which stream is used as input to main spectrum.
Definition: deviceapi.cpp:111
void addOrUpdateDeviceConfig(const QString &deviceId, const QString &deviceSerial, int deviceSequence, const QByteArray &config)
Definition: preset.cpp:177
int m_deviceTabIndex
This is the tab index in the GUI and also the device set index.
Definition: deviceapi.h:179
bool isSourcePreset() const
Definition: preset.h:66
PluginInstanceGUI * m_samplingDevicePluginInstanceUI
Definition: deviceapi.h:192
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
uint32_t m_deviceItemIndex
The item index inb the Rx or Tx side of the physical device. Can be >0 for NxM devices (i...
Definition: deviceapi.h:182
void stopProcess()
Stop process sequence.
virtual void setCenterFrequency(qint64 centerFrequency)=0
QString errorMessage()
Last error message from the device engine.
Definition: deviceapi.cpp:290
void addChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Add a channel source (Tx)
Definition: deviceapi.cpp:138
bool initProcess()
Initialize process sequence.
DeviceSampleSink * getSampleSink()
Return pointer to the device sample sink (single Tx) or nullptr.
Definition: deviceapi.cpp:222
PluginInterface * m_pluginInterface
Definition: deviceapi.h:185
Exposes a single input stream that can be one of the streams of a physical device.
Definition: deviceapi.h:47
MessageQueue * getMessageQueueToGUI()
unsigned int uint32_t
Definition: rtptypes_win.h:46
bool initGeneration()
Initialize generation sequence.
DSPDeviceSourceEngine * m_deviceSourceEngine
Definition: deviceapi.h:203
void stopGeneration()
Stop generation sequence.
QList< ChannelAPI * > m_channelSourceAPIs
Definition: deviceapi.h:209
void addSourceStream(bool connect)
Definition: deviceapi.cpp:61
EngineState state() const
Return the state of the device engine corresponding to the stream type.
Definition: deviceapi.cpp:277
MessageQueue * getInputMessageQueue()
void setIndexInDeviceSet(int indexInDeviceSet)
Definition: channelapi.h:88
void removeSourceBuddy(DeviceAPI *buddy)
Definition: deviceapi.cpp:674
MessageQueue * getInputMessageQueue()
void removeThreadedSource(ThreadedBasebandSampleSource *source)
Remove a baseband sample source that runs on its own thread.
void setSource(DeviceSampleSource *source)
Set the sample source type.
void setSpectrumSinkInput(bool sourceElseSink, int index)
virtual quint64 getCenterFrequency() const =0
Center frequency exposed by the sink.
void addAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Adds a sink to receive full baseband and that is not a channel (e.g. spectrum)
Definition: deviceapi.cpp:89
void addThreadedSource(ThreadedBasebandSampleSource *source)
Add a baseband sample source that will run on its own thread.
virtual bool deserialize(const QByteArray &data)=0
virtual bool deserialize(const QByteArray &data)=0
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int isource)
Configure source DSP corrections.
bool initAcquisition()
Initialize acquisition sequence.
void saveSamplingDeviceSettings(Preset *preset)
Definition: deviceapi.cpp:569
QString m_samplingDeviceSerial
The device serial number defined by the vendor or a fake one (SDRplay)
Definition: deviceapi.h:188
Definition: preset.h:28
QString m_hardwareId
The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
Definition: deviceapi.h:180
DeviceAPI(StreamType streamType, int deviceTabIndex, DSPDeviceSourceEngine *deviceSourceEngine, DSPDeviceSinkEngine *deviceSinkEngine, DSPDeviceMIMOEngine *deviceMIMOEngine)
Definition: deviceapi.cpp:32
uint32_t getUID() const
State state() const
Return DSP engine current state.
void removeAncillarySink(BasebandSampleSink *sink, int index=0)
Remove an ancillary sample sink.
int32_t i
Definition: decimators.h:244
void stopAcquistion()
Stop acquisition sequence.
MessageQueue * getSamplingDeviceInputMessageQueue()
Sampling device (ex: single Rx) input message queue.
Definition: deviceapi.cpp:329
virtual QByteArray serialize() const =0
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
Definition: deviceapi.cpp:100
void addSinkBuddy(DeviceAPI *buddy)
Definition: deviceapi.cpp:646
MessageQueue * getInputMessageQueue()
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
void addSink(BasebandSampleSink *sink)
Add a sample sink.
ChannelAPI * getChanelSourceAPIAt(int index, int streamIndex=0)
Definition: deviceapi.cpp:463
virtual void setCenterFrequency(qint64 centerFrequency)=0
DSPDeviceMIMOEngine * m_deviceMIMOEngine
Definition: deviceapi.h:213
StreamType
< This is the same enum as in PluginInterface
Definition: deviceapi.h:45
QString errorMessage()
Return the current error message.
void clearBuddiesLists()
Definition: deviceapi.cpp:740
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
std::vector< DeviceAPI * > m_sourceBuddies
Device source APIs referencing the same physical device.
Definition: deviceapi.h:196
void addSpectrumSink(BasebandSampleSink *spectrumSink)
Add a spectrum vis baseband sample sink.
void addAncillarySink(BasebandSampleSink *sink, int index=0)
Add an ancillary sink like a I/Q recorder.
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
StreamType m_streamType
Definition: deviceapi.h:178
void removeThreadedSink(ThreadedBasebandSampleSink *sink)
Remove a sample sink that runs on its own thread.
MessageQueue * getMessageQueueToGUI()
State state() const
Return DSP engine current state.
const QString & getHardwareId() const
Definition: deviceapi.h:119
bool startAcquisition()
Start acquisition sequence.
void addSourceBuddy(DeviceAPI *buddy)
Definition: deviceapi.cpp:617
void addChannelSink(ThreadedBasebandSampleSink *sink, int index=0)
Add a channel sink that will run on its own thread.
virtual bool deserialize(const QByteArray &data)=0
void removeLastSinkStream()
Definition: deviceapi.cpp:82
void addSourceStream(bool connect)
void setDeviceItemIndex(uint32_t index)
Definition: deviceapi.cpp:374
void addChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:174
void addThreadedSink(ThreadedBasebandSampleSink *sink)
Add a sample sink that will run on its own thread.
std::vector< DeviceAPI * > m_sinkBuddies
Device sink APIs referencing the same physical device.
Definition: deviceapi.h:197
void loadSamplingDeviceSettings(const Preset *preset)
Definition: deviceapi.cpp:481
virtual QByteArray serialize() const =0
uint32_t m_samplingDeviceSequence
The device sequence. >0 when more than one device of the same type is connected.
Definition: deviceapi.h:190
const QString & getDescription() const
Definition: preset.h:74
void setSamplingDevicePluginInterface(PluginInterface *iface)
Definition: deviceapi.cpp:379
virtual quint64 getCenterFrequency() const =0
Center frequency exposed by the source.
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
Definition: deviceapi.cpp:355
MessageQueue * getMessageQueueToGUI()
void removeLastSourceStream()
Definition: deviceapi.cpp:68
DeviceSampleMIMO * getSampleMIMO()
Return pointer to the device sample MIMO or nullptr.
Definition: deviceapi.cpp:231
void setDeviceNbItems(uint32_t nbItems)
Definition: deviceapi.cpp:369
void setSampleSink(DeviceSampleSink *sink)
Set the device sample sink (single Tx)
Definition: deviceapi.cpp:199
bool startGeneration()
Start generation sequence.
const QString & getGroup() const
Definition: preset.h:72
engine is in error
Definition: deviceapi.h:57
void renumerateChannels()
Definition: deviceapi.cpp:773
QList< ChannelAPI * > m_channelSinkAPIs
Definition: deviceapi.h:204
MessageQueue * getInputMessageQueue()
void addSinkStream(bool connect)
MessageQueue * getSamplingDeviceGUIMessageQueue()
Sampling device (ex: single Tx) GUI input message queue.
Definition: deviceapi.cpp:342
bool startProcess()
Start process sequence.