19 #include <QNetworkReply> 41 m_deviceAPI(deviceAPI),
46 m_perseusDescriptor(0)
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 m_networkManager =
new QNetworkAccessManager();
54 connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(networkManagerFinished(QNetworkReply*)));
83 qDebug(
"PerseusInput::start: thread created");
172 qDebug() <<
"PerseusInput::handleMessage: MsgConfigurePerseus";
177 qDebug(
"MsgConfigurePerseus::handleMessage: Perseus config error");
185 qDebug() <<
"PerseusInput::handleMessage: MsgStartStop: " << (cmd.
getStartStop() ?
"start" :
"stop");
208 qDebug() <<
"PerseusInput::handleMessage: MsgFileRecord: " << conf.
getStartStop();
241 qCritical(
"PerseusInput::start: could not allocate SampleFifo");
250 qCritical(
"PerseusInput::openDevice: cannot open device: %s", perseus_errorstr());
259 qCritical(
"PerseusInput::openDevice: cannot get sampling rates: %s", perseus_errorstr());
265 for (
int i = 0; (
i < 32) && (buf[
i] != 0);
i++)
267 qDebug(
"PerseusInput::openDevice: sample rate: %d", buf[
i]);
286 qint64 df = ((qint64)freq_hz * settings.
m_LOppmTenths) / 10000000LL;
293 qWarning(
"PerseusInput::setDeviceCenterFrequency: could not set frequency to %llu Hz: %s", freq_hz, perseus_errorstr());
295 qDebug(
"PerseusInput::setDeviceCenterFrequency: frequency set to %llu Hz", freq_hz);
301 bool forwardChange =
false;
303 QList<QString> reverseAPIKeys;
307 reverseAPIKeys.append(
"devSampleRateIndex");
308 forwardChange =
true;
319 for (
int i = 0;
i < 2;
i++)
324 qCritical(
"PerseusInput::applySettings: could not set sample rate index %u (%d S/s): %s",
330 qDebug(
"PerseusInput::applySettings: sample rate set to index #%d: %u (%d S/s)",
339 reverseAPIKeys.append(
"log2Decim");
340 forwardChange =
true;
345 qDebug(
"PerseusInput: set decimation to %d", (1<<settings.
m_log2Decim));
350 reverseAPIKeys.append(
"centerFrequency");
353 reverseAPIKeys.append(
"LOppmTenths");
356 reverseAPIKeys.append(
"wideBand");
359 reverseAPIKeys.append(
"transverterMode");
362 reverseAPIKeys.append(
"transverterDeltaFrequency");
374 deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
379 qDebug(
"PerseusInput::applySettings: center freq: %llu Hz", settings.
m_centerFrequency);
382 forwardChange =
true;
387 reverseAPIKeys.append(
"attenuator");
391 qWarning(
"PerseusInput::applySettings: cannot set attenuator to %d dB: %s", (
int) settings.
m_attenuator*10, perseus_errorstr());
393 qDebug(
"PerseusInput::applySettings: attenuator set to %d dB", (
int) settings.
m_attenuator*10);
398 reverseAPIKeys.append(
"adcDither");
401 reverseAPIKeys.append(
"adcPreamp");
410 qWarning(
"PerseusInput::applySettings: cannot set ADC to dither %s and preamp %s: %s",
413 qDebug(
"PerseusInput::applySettings: ADC set to dither %s and preamp %s",
438 qDebug() <<
"PerseusInput::applySettings: " 454 QString& errorMessage)
464 QString& errorMessage)
482 QString& errorMessage)
493 const QStringList& deviceSettingsKeys,
495 QString& errorMessage)
500 if (deviceSettingsKeys.contains(
"centerFrequency")) {
503 if (deviceSettingsKeys.contains(
"LOppmTenths")) {
506 if (deviceSettingsKeys.contains(
"devSampleRateIndex")) {
509 if (deviceSettingsKeys.contains(
"log2Decim")) {
512 if (deviceSettingsKeys.contains(
"adcDither")) {
515 if (deviceSettingsKeys.contains(
"adcPreamp")) {
518 if (deviceSettingsKeys.contains(
"wideBand")) {
521 if (deviceSettingsKeys.contains(
"attenuator")) {
523 attenuator = attenuator < 0 ? 0 : attenuator > 3 ? 3 : attenuator;
526 if (deviceSettingsKeys.contains(
"transverterDeltaFrequency")) {
529 if (deviceSettingsKeys.contains(
"transverterMode")) {
532 if (deviceSettingsKeys.contains(
"fileRecordName")) {
535 if (deviceSettingsKeys.contains(
"useReverseAPI")) {
538 if (deviceSettingsKeys.contains(
"reverseAPIAddress")) {
541 if (deviceSettingsKeys.contains(
"reverseAPIPort")) {
544 if (deviceSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
563 QString& errorMessage)
625 if (deviceSettingsKeys.contains(
"centerFrequency") || force) {
628 if (deviceSettingsKeys.contains(
"LOppmTenths") || force) {
631 if (deviceSettingsKeys.contains(
"devSampleRateIndex") || force) {
634 if (deviceSettingsKeys.contains(
"log2Decim") || force) {
637 if (deviceSettingsKeys.contains(
"adcDither") || force) {
640 if (deviceSettingsKeys.contains(
"adcPreamp") || force) {
643 if (deviceSettingsKeys.contains(
"wideBand") || force) {
646 if (deviceSettingsKeys.contains(
"attenuator") || force) {
649 if (deviceSettingsKeys.contains(
"transverterDeltaFrequency") || force) {
652 if (deviceSettingsKeys.contains(
"transverterMode") || force) {
655 if (deviceSettingsKeys.contains(
"fileRecordName") || force) {
659 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/settings")
664 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
666 QBuffer *buffer=
new QBuffer();
667 buffer->open((QBuffer::ReadWrite));
668 buffer->write(swgDeviceSettings->
asJson().toUtf8());
674 delete swgDeviceSettings;
684 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/run")
689 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
691 QBuffer *buffer=
new QBuffer();
692 buffer->open((QBuffer::ReadWrite));
693 buffer->write(swgDeviceSettings->
asJson().toUtf8());
702 delete swgDeviceSettings;
707 QNetworkReply::NetworkError replyError = reply->error();
711 qWarning() <<
"PerseusInput::networkManagerFinished:" 712 <<
" error(" << (int) replyError
713 <<
"): " << replyError
714 <<
": " << reply->errorString();
718 QString answer = reply->readAll();
720 qDebug(
"PerseusInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
qint64 m_transverterDeltaFrequency
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
void setLOppmTenths(qint32 l_oppm_tenths)
void setWideBand(qint32 wide_band)
static DevicePerseus & instance()
qint32 getUseReverseApi()
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
void setPerseusReport(SWGPerseusReport *perseus_report)
quint32 m_devSampleRateIndex
void setFileName(const QString &filename)
uint getDeviceUID() const
Return the current device engine unique ID.
void setTransverterMode(qint32 transverter_mode)
void setUseReverseApi(qint32 use_reverse_api)
SWGPerseusReport * getPerseusReport()
void setReverseApiPort(qint32 reverse_api_port)
MessageQueue m_inputMessageQueue
Input queue to the source.
void setAdcPreamp(qint32 adc_preamp)
virtual QString asJson() override
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
uint16_t m_reverseAPIDeviceIndex
int getSequenceFromSerial(const std::string &serial) const
SWGPerseusSettings * getPerseusSettings()
qint32 getReverseApiPort()
void setPerseusSettings(SWGPerseusSettings *perseus_settings)
void setDevSampleRateIndex(qint32 dev_sample_rate_index)
void setReverseApiAddress(QString *reverse_api_address)
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
void setSampleRates(QList< SWGSampleRate *> *sample_rates)
void setLog2Decimation(unsigned int log2_decim)
void setOriginatorIndex(qint32 originator_index)
qint64 getTransverterDeltaFrequency()
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.
quint64 m_centerFrequency
void setAdcDither(qint32 adc_dither)
int getDeviceSetIndex() const
QString * getReverseApiAddress()
QByteArray serialize() const
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
qint32 getTransverterMode()
void genUniqueFileName(uint deviceUID, int istream=-1)
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
QString m_reverseAPIAddress
QString * getFileRecordName()
qint32 getDevSampleRateIndex()
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
static bool match(const Message *message)
QList< SWGSampleRate * > * getSampleRates()
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
bool deserialize(const QByteArray &data)
void getDeviceEngineStateStr(QString &state)
const QString & getSamplingDeviceSerial() const
void setCenterFrequency(qint64 center_frequency)
qint64 getCenterFrequency()
uint16_t m_reverseAPIPort
void setFileRecordName(QString *file_record_name)
void setLog2Decim(qint32 log2_decim)
#define PERSEUS_NBSAMPLES
void setAttenuator(qint32 attenuator)
qint32 getReverseApiDeviceIndex()
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)