22 #include <QNetworkReply> 23 #include <QNetworkAccessManager> 42 m_deviceAPI(deviceAPI),
44 m_testSourceThread(0),
45 m_deviceDescription(),
47 m_masterTimer(deviceAPI->getMasterTimer())
49 m_fileSink =
new FileRecord(QString(
"test_%1.sdriq").
arg(m_deviceAPI->getDeviceUID()));
50 m_deviceAPI->setNbSourceStreams(1);
51 m_deviceAPI->addAncillarySink(m_fileSink);
53 if (!m_sampleFifo.setSize(96000 * 4)) {
54 qCritical(
"TestSourceInput::TestSourceInput: Could not allocate SampleFifo");
57 m_networkManager =
new QNetworkAccessManager();
58 connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(networkManagerFinished(QNetworkReply*)));
86 QMutexLocker mutexLocker(&
m_mutex);
104 QMutexLocker mutexLocker(&
m_mutex);
178 qDebug() <<
"TestSourceInput::handleMessage: MsgConfigureTestSource";
184 qDebug(
"TestSourceInput::handleMessage: config error");
192 qDebug() <<
"TestSourceInput::handleMessage: MsgFileRecord: " << conf.
getStartStop();
214 qDebug() <<
"TestSourceInput::handleMessage: MsgStartStop: " << (cmd.
getStartStop() ?
"start" :
"stop");
242 QList<QString> reverseAPIKeys;
246 reverseAPIKeys.append(
"autoCorrOptions");
265 reverseAPIKeys.append(
"sampleRate");
270 qDebug(
"TestSourceInput::applySettings: sample rate set to %d", settings.
m_sampleRate);
276 reverseAPIKeys.append(
"log2Decim");
281 qDebug() <<
"TestSourceInput::applySettings: set decimation to " << (1<<settings.
m_log2Decim);
291 reverseAPIKeys.append(
"centerFrequency");
292 reverseAPIKeys.append(
"fcPos");
293 reverseAPIKeys.append(
"frequencyShift");
301 DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
320 qDebug() <<
"TestSourceInput::applySettings:" 322 <<
" device center freq: " << deviceCenterFrequency <<
" Hz" 323 <<
" device sample rate: " << devSampleRate <<
"Hz" 331 reverseAPIKeys.append(
"amplitudeBits");
340 reverseAPIKeys.append(
"dcFactor");
349 reverseAPIKeys.append(
"iFactor");
358 reverseAPIKeys.append(
"qFactor");
367 reverseAPIKeys.append(
"phaseImbalance");
376 reverseAPIKeys.append(
"sampleSizeIndex");
396 reverseAPIKeys.append(
"modulationTone");
405 reverseAPIKeys.append(
"modulation");
423 reverseAPIKeys.append(
"amModulation");
432 reverseAPIKeys.append(
"fmDeviation");
441 qDebug(
"TestSourceInput::applySettings: call webapiReverseSendSettings");
455 QString& errorMessage)
465 QString& errorMessage)
483 QString& errorMessage)
494 const QStringList& deviceSettingsKeys,
496 QString& errorMessage)
501 if (deviceSettingsKeys.contains(
"centerFrequency")) {
504 if (deviceSettingsKeys.contains(
"frequencyShift")) {
507 if (deviceSettingsKeys.contains(
"sampleRate")) {
510 if (deviceSettingsKeys.contains(
"log2Decim")) {
513 if (deviceSettingsKeys.contains(
"fcPos")) {
515 fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos;
518 if (deviceSettingsKeys.contains(
"sampleSizeIndex")) {
520 sampleSizeIndex = sampleSizeIndex < 0 ? 0 : sampleSizeIndex > 1 ? 2 : sampleSizeIndex;
523 if (deviceSettingsKeys.contains(
"amplitudeBits")) {
526 if (deviceSettingsKeys.contains(
"autoCorrOptions")) {
531 if (deviceSettingsKeys.contains(
"modulation")) {
536 if (deviceSettingsKeys.contains(
"modulationTone")) {
539 if (deviceSettingsKeys.contains(
"amModulation")) {
542 if (deviceSettingsKeys.contains(
"fmDeviation")) {
545 if (deviceSettingsKeys.contains(
"dcFactor")) {
548 if (deviceSettingsKeys.contains(
"iFactor")) {
551 if (deviceSettingsKeys.contains(
"qFactor")) {
554 if (deviceSettingsKeys.contains(
"phaseImbalance")) {
557 if (deviceSettingsKeys.contains(
"fileRecordName")) {
560 if (deviceSettingsKeys.contains(
"useReverseAPI")) {
563 if (deviceSettingsKeys.contains(
"reverseAPIAddress")) {
566 if (deviceSettingsKeys.contains(
"reverseAPIPort")) {
569 if (deviceSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
634 if (deviceSettingsKeys.contains(
"centerFrequency") || force) {
637 if (deviceSettingsKeys.contains(
"frequencyShift") || force) {
640 if (deviceSettingsKeys.contains(
"sampleRate") || force) {
643 if (deviceSettingsKeys.contains(
"log2Decim") || force) {
646 if (deviceSettingsKeys.contains(
"fcPos") || force) {
649 if (deviceSettingsKeys.contains(
"sampleSizeIndex") || force) {
652 if (deviceSettingsKeys.contains(
"amplitudeBits") || force) {
655 if (deviceSettingsKeys.contains(
"autoCorrOptions") || force) {
658 if (deviceSettingsKeys.contains(
"modulation") || force) {
661 if (deviceSettingsKeys.contains(
"modulationTone")) {
664 if (deviceSettingsKeys.contains(
"amModulation") || force) {
667 if (deviceSettingsKeys.contains(
"fmDeviation") || force) {
670 if (deviceSettingsKeys.contains(
"dcFactor") || force) {
673 if (deviceSettingsKeys.contains(
"iFactor") || force) {
676 if (deviceSettingsKeys.contains(
"qFactor") || force) {
679 if (deviceSettingsKeys.contains(
"phaseImbalance") || force) {
682 if (deviceSettingsKeys.contains(
"fileRecordName") || force) {
686 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/settings")
691 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
693 QBuffer *buffer=
new QBuffer();
694 buffer->open((QBuffer::ReadWrite));
695 buffer->write(swgDeviceSettings->
asJson().toUtf8());
703 delete swgDeviceSettings;
713 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/run")
718 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
720 QBuffer *buffer=
new QBuffer();
721 buffer->open((QBuffer::ReadWrite));
722 buffer->write(swgDeviceSettings->
asJson().toUtf8());
731 delete swgDeviceSettings;
736 QNetworkReply::NetworkError replyError = reply->error();
740 qWarning() <<
"TestSourceInput::networkManagerFinished:" 741 <<
" error(" << (int) replyError
742 <<
"): " << replyError
743 <<
": " << reply->errorString();
747 QString answer = reply->readAll();
749 qDebug(
"TestSourceInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
void setModulation(qint32 modulation)
void setFcPos(qint32 fc_pos)
static qint32 calculateFrequencyShift(int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme)
static qint64 calculateDeviceCenterFrequency(quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
quint32 m_sampleSizeIndex
void setIFactor(float i_factor)
void setFileName(const QString &filename)
uint getDeviceUID() const
Return the current device engine unique ID.
QString m_reverseAPIAddress
bool deserialize(const QByteArray &data)
SWGTestSourceSettings * getTestSourceSettings()
void setFmDeviation(qint32 fm_deviation)
void setPhaseImbalance(float phaseImbalance)
void setSamplerate(int samplerate)
void setFileRecordName(QString *file_record_name)
MessageQueue m_inputMessageQueue
Input queue to the source.
void setIFactor(float iFactor)
virtual QString asJson() override
void setLog2Decimation(unsigned int log2_decim)
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
void setReverseApiPort(qint32 reverse_api_port)
void startStop(bool start)
void setAMModulation(float amModulation)
void setBitSize(uint32_t bitSizeIndex)
float m_qFactor
-1.0 < x < 1.0
QString * getReverseApiAddress()
void setUseReverseApi(qint32 use_reverse_api)
float m_phaseImbalance
-1.0 < x < 1.0
QByteArray serialize() const
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
AutoCorrOptions m_autoCorrOptions
void setModulation(TestSourceSettings::Modulation modulation)
void setOriginatorIndex(qint32 originator_index)
qint32 getAutoCorrOptions()
SampleSinkFifo m_sampleFifo
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
void setQFactor(float q_factor)
void setToneFrequency(int toneFrequency)
void setFrequencyShift(int shift)
void setSampleSizeIndex(qint32 sample_size_index)
int getDeviceSetIndex() const
float m_iFactor
-1.0 < x < 1.0
QString * getFileRecordName()
qint32 getSampleSizeIndex()
uint16_t m_reverseAPIPort
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void genUniqueFileName(uint deviceUID, int istream=-1)
qint32 getFrequencyShift()
qint32 getUseReverseApi()
void setReverseApiAddress(QString *reverse_api_address)
qint32 getAmplitudeBits()
void setAutoCorrOptions(qint32 auto_corr_options)
uint16_t m_reverseAPIDeviceIndex
void setLog2Decim(qint32 log2_decim)
void setAmplitudeBits(qint32 amplitude_bits)
void setModulationTone(qint32 modulation_tone)
void setTestSourceSettings(SWGTestSourceSettings *test_source_settings)
void setAmplitudeBits(int32_t amplitudeBits)
static bool match(const Message *message)
qint32 getReverseApiDeviceIndex()
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
float getPhaseImbalance()
void setPhaseImbalance(float phase_imbalance)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void setCenterFrequency(qint32 center_frequency)
qint32 getModulationTone()
qint32 getReverseApiPort()
void setFMDeviation(float deviation)
void getDeviceEngineStateStr(QString &state)
void setDCFactor(float iFactor)
void setAmModulation(qint32 am_modulation)
void setSampleRate(qint32 sample_rate)
int m_modulationTone
10'Hz
quint64 m_centerFrequency
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
qint32 getCenterFrequency()
void setFrequencyShift(qint32 frequency_shift)
void setQFactor(float qFactor)
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
int m_fmDeviation
100'Hz
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
void setDcFactor(float dc_factor)
int m_amModulation
percent
float m_dcFactor
-1.0 < x < 1.0