24 #include <QMessageBox> 28 #include <QNetworkAccessManager> 29 #include <QNetworkReply> 30 #include <QJsonParseError> 31 #include <QJsonObject> 33 #include "ui_remoteinputgui.h" 50 m_deviceUISet(deviceUISet),
54 m_streamSampleRate(0),
55 m_streamCenterFrequency(0),
56 m_lastEngineState(
DeviceAPI::StNotStarted),
57 m_framesDecodingStatus(0),
58 m_bufferLengthInSecs(0.0),
60 m_nbOriginalBlocks(128),
66 m_addressEdited(false),
67 m_dataPortEdited(false),
68 m_countUnrecoverable(0),
70 m_doApplySettings(true),
71 m_forceSettings(true),
81 ui->centerFrequency->setValueRange(7, 0, 9999999U);
84 ui->centerFrequencyHz->setValueRange(3, 0, 999U);
87 connect(startStopRightClickEnabler, SIGNAL(rightClick(
const QPoint &)),
this, SLOT(
openDeviceSettingsDialog(
const QPoint &)));
153 qDebug(
"RemoteInputGui::deserialize");
176 (void) centerFrequency;
200 qDebug() <<
"RemoteInputGui::handleMessage: RemoteInput::MsgReportRemoteInputStreamData: " 265 qDebug(
"RemoteInputGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->
getSampleRate(), notif->
getCenterFrequency());
325 int udpApiPort =
ui->apiPort->text().toInt(&ctlOk);
327 if((ctlOk) && (udpApiPort >= 1024) && (udpApiPort < 65535)) {
344 int udpDataPort =
ui->dataPort->text().toInt(&dataOk);
346 if((dataOk) && (udpDataPort >= 1024) && (udpDataPort < 65535)) {
373 int udpDataPort =
ui->dataPort->text().toInt(&dataOk);
375 if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535))
389 int udpApiPort =
ui->apiPort->text().toInt(&ctlOk);
391 if((!ctlOk) || (udpApiPort < 1024) || (udpApiPort > 65535))
431 ui->record->setStyleSheet(
"QToolButton { background-color : red; }");
433 ui->record->setStyleSheet(
"QToolButton { background:rgb(79,79,79); }");
453 ui->eventUnrecText->setText(nstr);
455 ui->eventRecText->setText(nstr);
461 QTime recordLength(0, 0, 0, 0);
462 recordLength = recordLength.addSecs(elapsedTimeMillis/1000);
463 QString s_time = recordLength.toString(
"HH:mm:ss");
464 ui->eventCountsTimeText->setText(s_time);
473 bool updateEventCounts =
false;
475 QString s_date = dt.toString(
"yyyy-MM-dd HH:mm:ss.zzz");
476 ui->absTimeText->setText(s_date);
480 ui->allFramesDecoded->setStyleSheet(
"QToolButton { background-color : green; }");
485 updateEventCounts =
true;
486 ui->allFramesDecoded->setStyleSheet(
"QToolButton { background:rgb(56,56,56); }");
491 updateEventCounts =
true;
492 ui->allFramesDecoded->setStyleSheet(
"QToolButton { background-color : red; }");
496 ui->bufferLenSecsText->setText(tr(
"%1").
arg(s));
499 ui->bufferRWBalanceText->setText(tr(
"%1").
arg(s));
505 ui->minNbBlocksText->setText(tr(
"%1").
arg(s));
508 ui->maxNbRecoveryText->setText(tr(
"%1").
arg(s));
511 QString s1 = QString(
"%1").arg(
m_nbFECBlocks, 2, 10, QChar(
'0'));
512 ui->nominalNbBlocksText->setText(tr(
"%1/%2").
arg(s).
arg(s1));
516 if (updateEventCounts)
528 qDebug() <<
"RemoteInputGui::updateHardware";
548 ui->startStop->setStyleSheet(
"QToolButton { background:rgb(79,79,79); }");
551 ui->startStop->setStyleSheet(
"QToolButton { background-color : blue; }");
554 ui->startStop->setStyleSheet(
"QToolButton { background-color : green; }");
557 ui->startStop->setStyleSheet(
"QToolButton { background-color : red; }");
567 ui->startStop->setEnabled(
true);
571 ui->startStop->setStyleSheet(
"QToolButton { background:rgb(79,79,79); }");
572 ui->startStop->setChecked(
false);
573 ui->startStop->setEnabled(
false);
581 ui->apiAddressLabel->setStyleSheet(
"QLabel { background:rgb(79,79,79); }");
582 ui->statusText->setText(reply->errorString());
586 QString answer = reply->readAll();
590 QByteArray jsonBytes(answer.toStdString().c_str());
591 QJsonParseError error;
592 QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error);
594 if (error.error == QJsonParseError::NoError)
596 ui->apiAddressLabel->setStyleSheet(
"QLabel { background-color : green; }");
597 ui->statusText->setText(QString(
"API OK"));
602 ui->apiAddressLabel->setStyleSheet(
"QLabel { background:rgb(79,79,79); }");
603 QString errorMsg = QString(
"Reply JSON error: ") + error.errorString() + QString(
" at offset ") + QString::number(error.offset);
604 ui->statusText->setText(QString(
"JSON error. See log"));
605 qInfo().noquote() <<
"RemoteInputGui::networkManagerFinished" << errorMsg;
608 catch (
const std::exception& ex)
610 ui->apiAddressLabel->setStyleSheet(
"QLabel { background:rgb(79,79,79); }");
611 QString errorMsg = QString(
"Error parsing request: ") + ex.what();
612 ui->statusText->setText(
"Error parsing request. See log for details");
613 qInfo().noquote() <<
"RemoteInputGui::networkManagerFinished" << errorMsg;
621 if (jsonObject.contains(
"version")) {
622 infoLine = jsonObject[
"version"].toString();
625 if (jsonObject.contains(
"qtVersion")) {
626 infoLine +=
" Qt" + jsonObject[
"qtVersion"].toString();
629 if (jsonObject.contains(
"architecture")) {
630 infoLine +=
" " + jsonObject[
"architecture"].toString();
633 if (jsonObject.contains(
"os")) {
634 infoLine +=
" " + jsonObject[
"os"].toString();
637 if (jsonObject.contains(
"dspRxBits") && jsonObject.contains(
"dspTxBits")) {
638 infoLine += QString(
" %1/%2b").arg(jsonObject[
"dspRxBits"].toInt()).arg(jsonObject[
"dspTxBits"].toInt());
641 if (infoLine.size() > 0) {
642 ui->infoText->setText(infoLine);
Message * pop()
Pop message from queue.
const QString & getReverseAPIAddress() const
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void setSampleRate(qint32 sampleRate)
DeviceSampleSource * getSampleSource()
Return pointer to the device sample source (single Rx) or nullptr.
void setUseReverseAPI(bool useReverseAPI)
MessageQueue * getInputMessageQueue()
uint16_t getReverseAPIDeviceIndex() const
QString errorMessage()
Last error message from the device engine.
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
GLSpectrum * getSpectrum()
Direct spectrum getter.
engine is before initialization
qint64 getCenterFrequency() const
EngineState state() const
Return the state of the device engine corresponding to the stream type.
uint16_t getReverseAPIPort() const
static bool match(const Message *message)
int getSampleRate() const
void setCenterFrequency(qint64 frequency)
void setReverseAPIAddress(const QString &address)
void setReverseAPIDeviceIndex(uint16_t deviceIndex)
void setReverseAPIPort(uint16_t port)
bool useReverseAPI() const