mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-04 02:28:33 -04:00
Satellite Tracker - Get time from Map or File Input device.
This commit is contained in:
parent
29b2941951
commit
81157696f7
@ -127,7 +127,14 @@ Specifies the longitude in decimal degrees (East positive) of the antenna locati
|
||||
|
||||
<h3>11: Time</h3>
|
||||
|
||||
Select the date and time at which the position of the satellite should be calculated. Select either Now, for the current time, or Custom to manually enter a date and time.
|
||||
Select the date and time at which the position of the satellite should be calculated. Select either:
|
||||
|
||||
* Now, for the current time based on the computers clock,
|
||||
* Custom to manually enter a date and time,
|
||||
* Map to get the time from the 3D map or
|
||||
* File to get the time from a File Input device.
|
||||
|
||||
When Map or File are selected, a combo box is displayed that allows choosing which Map feature or File Input device, should there be several.
|
||||
|
||||
<h3>12: Target</h3>
|
||||
|
||||
|
@ -80,12 +80,11 @@ void SatelliteTracker::start()
|
||||
{
|
||||
qDebug("SatelliteTracker::start");
|
||||
|
||||
if (m_settings.m_replayEnabled)
|
||||
{
|
||||
if (m_settings.m_replayEnabled) {
|
||||
m_startedDateTime = QDateTime::currentDateTimeUtc();
|
||||
if (m_settings.m_sendTimeToMap) {
|
||||
FeatureWebAPIUtils::mapSetDateTime(currentDateTime());
|
||||
}
|
||||
}
|
||||
if (m_settings.m_sendTimeToMap) {
|
||||
FeatureWebAPIUtils::mapSetDateTime(currentDateTime());
|
||||
}
|
||||
|
||||
m_worker->reset();
|
||||
@ -1139,26 +1138,50 @@ void SatelliteTracker::updateSatData()
|
||||
/// Redirect requests for current time via these methods, for replays
|
||||
QDateTime SatelliteTracker::currentDateTimeUtc()
|
||||
{
|
||||
if (m_settings.m_replayEnabled)
|
||||
if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::FROM_FILE)
|
||||
{
|
||||
if (m_settings.m_useFileInputTime)
|
||||
QString dateTimeStr;
|
||||
int deviceIdx = 0;
|
||||
if (m_settings.m_fileInputDevice.size() >= 2) {
|
||||
deviceIdx = m_settings.m_fileInputDevice.mid(1).toInt();
|
||||
}
|
||||
if (ChannelWebAPIUtils::getDeviceReportValue(deviceIdx, "absoluteTime", dateTimeStr))
|
||||
{
|
||||
QString dateTimeStr;
|
||||
if (ChannelWebAPIUtils::getDeviceReportValue(0, "absoluteTime", dateTimeStr))
|
||||
{
|
||||
return QDateTime::fromString(dateTimeStr, Qt::ISODateWithMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
return QDateTime::fromString(dateTimeStr, Qt::ISODateWithMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
QDateTime now = QDateTime::currentDateTimeUtc();
|
||||
return m_settings.m_replayStartDateTime.addSecs(m_startedDateTime.secsTo(now));
|
||||
return QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
}
|
||||
else if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::FROM_MAP)
|
||||
{
|
||||
QString dateTimeStr;
|
||||
int featureSet = 0;
|
||||
int featureIdx = 0;
|
||||
if (m_settings.m_mapFeature.size() >= 4)
|
||||
{
|
||||
QStringList numbers = m_settings.m_mapFeature.mid(1).split(":");
|
||||
if (numbers.size() == 2)
|
||||
{
|
||||
featureSet = numbers[0].toInt();
|
||||
featureIdx = numbers[1].toInt();
|
||||
}
|
||||
}
|
||||
if (ChannelWebAPIUtils::getFeatureReportValue(featureSet, featureIdx, "dateTime", dateTimeStr))
|
||||
{
|
||||
return QDateTime::fromString(dateTimeStr, Qt::ISODateWithMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
}
|
||||
else if (m_settings.m_replayEnabled)
|
||||
{
|
||||
QDateTime now = QDateTime::currentDateTimeUtc();
|
||||
return m_settings.m_replayStartDateTime.addSecs(m_startedDateTime.secsTo(now));
|
||||
}
|
||||
else
|
||||
{
|
||||
return QDateTime::currentDateTimeUtc();
|
||||
@ -1167,9 +1190,9 @@ QDateTime SatelliteTracker::currentDateTimeUtc()
|
||||
|
||||
QDateTime SatelliteTracker::currentDateTime()
|
||||
{
|
||||
if (m_settings.m_replayEnabled) {
|
||||
return currentDateTimeUtc().toLocalTime();
|
||||
} else {
|
||||
if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::NOW) {
|
||||
return QDateTime::currentDateTime();
|
||||
} else {
|
||||
return currentDateTimeUtc().toLocalTime();
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include <QtCharts/QDateTimeAxis>
|
||||
#include <QtCharts/QValueAxis>
|
||||
|
||||
#include "device/deviceapi.h"
|
||||
#include "device/deviceset.h"
|
||||
#include "feature/featureset.h"
|
||||
#include "feature/featureuiset.h"
|
||||
#include "feature/featurewebapiutils.h"
|
||||
#include "gui/basicfeaturesettingsdialog.h"
|
||||
@ -269,6 +272,7 @@ SatelliteTrackerGUI::SatelliteTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *fea
|
||||
ui->passChart->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
ui->dateTime->setDateTime(m_satelliteTracker->currentDateTime());
|
||||
ui->deviceFeatureSelect->setVisible(false);
|
||||
|
||||
// Use My Position from preferences, if none set
|
||||
if ((m_settings.m_latitude == 0.0) && (m_settings.m_longitude == 0.0)) {
|
||||
@ -328,17 +332,9 @@ void SatelliteTrackerGUI::displaySettings()
|
||||
}
|
||||
|
||||
ui->target->setCurrentIndex(ui->target->findText(m_settings.m_target));
|
||||
if (m_settings.m_dateTime == "")
|
||||
{
|
||||
ui->dateTimeSelect->setCurrentIndex(0);
|
||||
ui->dateTime->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->dateTime->setDateTime(QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs));
|
||||
ui->dateTime->setVisible(true);
|
||||
ui->dateTimeSelect->setCurrentIndex(1);
|
||||
}
|
||||
ui->dateTimeSelect->setCurrentIndex((int)m_settings.m_dateTimeSelect);
|
||||
ui->dateTime->setVisible(m_settings.m_dateTimeSelect == SatelliteTrackerSettings::CUSTOM);
|
||||
ui->dateTime->setDateTime(QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs));
|
||||
ui->autoTarget->setChecked(m_settings.m_autoTarget);
|
||||
ui->darkTheme->setChecked(m_settings.m_chartsDarkTheme);
|
||||
restoreState(m_rollupState);
|
||||
@ -485,9 +481,10 @@ void SatelliteTrackerGUI::on_displaySettings_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void SatelliteTrackerGUI::on_dateTimeSelect_currentTextChanged(const QString &text)
|
||||
void SatelliteTrackerGUI::on_dateTimeSelect_currentIndexChanged(int index)
|
||||
{
|
||||
if (text == "Now")
|
||||
m_settings.m_dateTimeSelect = (SatelliteTrackerSettings::DateTimeSelect)index;
|
||||
if (m_settings.m_dateTimeSelect != SatelliteTrackerSettings::CUSTOM)
|
||||
{
|
||||
m_settings.m_dateTime = "";
|
||||
ui->dateTime->setVisible(false);
|
||||
@ -497,6 +494,9 @@ void SatelliteTrackerGUI::on_dateTimeSelect_currentTextChanged(const QString &te
|
||||
m_settings.m_dateTime = ui->dateTime->dateTime().toString(Qt::ISODateWithMs);
|
||||
ui->dateTime->setVisible(true);
|
||||
}
|
||||
ui->deviceFeatureSelect->setVisible(m_settings.m_dateTimeSelect >= SatelliteTrackerSettings::FROM_MAP);
|
||||
updateDeviceFeatureCombo();
|
||||
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -595,6 +595,8 @@ void SatelliteTrackerGUI::updateStatus()
|
||||
}
|
||||
|
||||
updateTimeToAOS();
|
||||
|
||||
updateDeviceFeatureCombo();
|
||||
}
|
||||
|
||||
// Update time to AOS
|
||||
@ -1234,3 +1236,80 @@ QAction *SatelliteTrackerGUI::createCheckableItem(QString &text, int idx, bool c
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(columnSelectMenuChecked()));
|
||||
return action;
|
||||
}
|
||||
|
||||
void SatelliteTrackerGUI::updateDeviceFeatureCombo()
|
||||
{
|
||||
if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::FROM_MAP) {
|
||||
updateMapList();
|
||||
} else if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::FROM_FILE) {
|
||||
updateFileInputList();
|
||||
}
|
||||
}
|
||||
|
||||
void SatelliteTrackerGUI::updateDeviceFeatureCombo(const QStringList &items, const QString &selected)
|
||||
{
|
||||
// Remove items no longer in list
|
||||
int i = 0;
|
||||
while (i < ui->deviceFeatureSelect->count())
|
||||
{
|
||||
if (!items.contains(ui->deviceFeatureSelect->itemText(i))) {
|
||||
ui->deviceFeatureSelect->removeItem(i);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// Add new items to list
|
||||
for (auto item : items)
|
||||
{
|
||||
int idx = ui->deviceFeatureSelect->findText(item);
|
||||
if (idx == -1) {
|
||||
ui->deviceFeatureSelect->addItem(item);
|
||||
}
|
||||
}
|
||||
ui->deviceFeatureSelect->setCurrentIndex(ui->deviceFeatureSelect->findText(selected));
|
||||
}
|
||||
|
||||
void SatelliteTrackerGUI::updateFileInputList()
|
||||
{
|
||||
// Create list of File Input devices
|
||||
std::vector<DeviceSet*>& deviceSets = MainCore::instance()->getDeviceSets();
|
||||
int deviceIndex = 0;
|
||||
QStringList items;
|
||||
for (std::vector<DeviceSet*>::const_iterator it = deviceSets.begin(); it != deviceSets.end(); ++it, deviceIndex++)
|
||||
{
|
||||
if ((*it)->m_deviceAPI && (*it)->m_deviceAPI->getHardwareId() == "FileInput") {
|
||||
items.append(QString("R%1").arg(deviceIndex));
|
||||
}
|
||||
}
|
||||
updateDeviceFeatureCombo(items, m_settings.m_fileInputDevice);
|
||||
}
|
||||
|
||||
void SatelliteTrackerGUI::updateMapList()
|
||||
{
|
||||
// Create list of Map features
|
||||
std::vector<FeatureSet*>& featureSets = MainCore::instance()->getFeatureeSets();
|
||||
int featureIndex = 0;
|
||||
QStringList items;
|
||||
for (std::vector<FeatureSet*>::const_iterator it = featureSets.begin(); it != featureSets.end(); ++it, featureIndex++)
|
||||
{
|
||||
for (int fi = 0; fi < (*it)->getNumberOfFeatures(); fi++)
|
||||
{
|
||||
Feature *feature = (*it)->getFeatureAt(fi);
|
||||
if (feature->getURI() == "sdrangel.feature.map") {
|
||||
items.append(QString("F%1:%2").arg(featureIndex).arg(fi));
|
||||
}
|
||||
}
|
||||
}
|
||||
updateDeviceFeatureCombo(items, m_settings.m_mapFeature);
|
||||
}
|
||||
|
||||
void SatelliteTrackerGUI::on_deviceFeatureSelect_currentIndexChanged(int index)
|
||||
{
|
||||
(int) index;
|
||||
if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::FROM_MAP) {
|
||||
m_settings.m_mapFeature = ui->deviceFeatureSelect->currentText();
|
||||
} else {
|
||||
m_settings.m_fileInputDevice = ui->deviceFeatureSelect->currentText();
|
||||
}
|
||||
applySettings();
|
||||
}
|
||||
|
@ -126,6 +126,10 @@ private:
|
||||
void updateTimeToAOS();
|
||||
QString formatDaysTime(qint64 days, QDateTime dateTime);
|
||||
QString formatSecondsHHMM(qint64 seconds);
|
||||
void updateDeviceFeatureCombo();
|
||||
void updateDeviceFeatureCombo(const QStringList &items, const QString &selected);
|
||||
void updateFileInputList();
|
||||
void updateMapList();
|
||||
|
||||
void leaveEvent(QEvent*);
|
||||
void enterEvent(QEvent*);
|
||||
@ -141,7 +145,7 @@ private slots:
|
||||
void on_target_currentTextChanged(const QString &text);
|
||||
void on_displaySettings_clicked();
|
||||
void on_radioControl_clicked();
|
||||
void on_dateTimeSelect_currentTextChanged(const QString &text);
|
||||
void on_dateTimeSelect_currentIndexChanged(int index);
|
||||
void on_dateTime_dateTimeChanged(const QDateTime &datetime);
|
||||
void updateStatus();
|
||||
void on_viewOnMap_clicked();
|
||||
@ -157,6 +161,7 @@ private slots:
|
||||
void satTable_sectionResized(int logicalIndex, int oldSize, int newSize);
|
||||
void columnSelectMenu(QPoint pos);
|
||||
void columnSelectMenuChecked(bool checked = false);
|
||||
void on_deviceFeatureSelect_currentIndexChanged(int index);
|
||||
};
|
||||
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Liberation Sans</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
@ -96,6 +95,16 @@
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>From map</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>From file</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
@ -349,19 +358,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3" colspan="2">
|
||||
<widget class="WrappingDateTimeEdit" name="dateTime">
|
||||
<property name="toolTip">
|
||||
<string>Date and time to use when calculating satellite's position</string>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>dd/MM/yyyy HH:mm:ss</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLabel" name="aosLabel">
|
||||
<property name="text">
|
||||
@ -369,6 +365,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3" colspan="2">
|
||||
<layout class="QHBoxLayout" name="timeLayout">
|
||||
<item>
|
||||
<widget class="WrappingDateTimeEdit" name="dateTime">
|
||||
<property name="toolTip">
|
||||
<string>Date and time to use when calculating satellite's position</string>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>dd/MM/yyyy HH:mm:ss</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="deviceFeatureSelect"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -736,6 +752,7 @@
|
||||
<tabstop>longitude</tabstop>
|
||||
<tabstop>dateTimeSelect</tabstop>
|
||||
<tabstop>dateTime</tabstop>
|
||||
<tabstop>deviceFeatureSelect</tabstop>
|
||||
<tabstop>target</tabstop>
|
||||
<tabstop>aos</tabstop>
|
||||
<tabstop>azimuth</tabstop>
|
||||
@ -743,6 +760,7 @@
|
||||
<tabstop>chartSelect</tabstop>
|
||||
<tabstop>prevPass</tabstop>
|
||||
<tabstop>nextPass</tabstop>
|
||||
<tabstop>darkTheme</tabstop>
|
||||
<tabstop>passChart</tabstop>
|
||||
<tabstop>satTable</tabstop>
|
||||
</tabstops>
|
||||
|
@ -74,8 +74,10 @@ void SatelliteTrackerSettings::resetToDefaults()
|
||||
m_reverseAPIFeatureIndex = 0;
|
||||
m_chartsDarkTheme = true;
|
||||
m_replayEnabled = false;
|
||||
m_useFileInputTime = true;
|
||||
m_sendTimeToMap = true;
|
||||
m_dateTimeSelect = NOW;
|
||||
m_mapFeature = "";
|
||||
m_fileInputDevice = "";
|
||||
for (int i = 0; i < SAT_COL_COLUMNS; i++)
|
||||
{
|
||||
m_columnIndexes[i] = i;
|
||||
@ -128,8 +130,10 @@ QByteArray SatelliteTrackerSettings::serialize() const
|
||||
}
|
||||
s.writeBool(38, m_replayEnabled);
|
||||
s.writeString(39, m_replayStartDateTime.toString(Qt::ISODate));
|
||||
s.writeBool(40, m_useFileInputTime);
|
||||
s.writeBool(41, m_sendTimeToMap);
|
||||
s.writeS32(42, (int)m_dateTimeSelect);
|
||||
s.writeString(43, m_mapFeature);
|
||||
s.writeString(44, m_fileInputDevice);
|
||||
|
||||
for (int i = 0; i < SAT_COL_COLUMNS; i++) {
|
||||
s.writeS32(100 + i, m_columnIndexes[i]);
|
||||
@ -217,8 +221,10 @@ bool SatelliteTrackerSettings::deserialize(const QByteArray& data)
|
||||
d.readBool(38, &m_replayEnabled, false);
|
||||
d.readString(39, &strtmp);
|
||||
m_replayStartDateTime = QDateTime::fromString(strtmp, Qt::ISODate);
|
||||
d.readBool(40, &m_useFileInputTime, true);
|
||||
d.readBool(41, &m_sendTimeToMap, true);
|
||||
d.readS32(42, (int *)&m_dateTimeSelect, (int)NOW);
|
||||
d.readString(43, &m_mapFeature, "");
|
||||
d.readString(44, &m_fileInputDevice, "");
|
||||
|
||||
for (int i = 0; i < SAT_COL_COLUMNS; i++) {
|
||||
d.readS32(100 + i, &m_columnIndexes[i], i);
|
||||
|
@ -78,8 +78,10 @@ struct SatelliteTrackerSettings
|
||||
QHash<QString, QList<SatelliteDeviceSettings *> *> m_deviceSettings; //!< Settings for each device set for each satellite
|
||||
bool m_replayEnabled; //!< Replay a pass in the past, by setting date and time to m_replayStartDateTime
|
||||
QDateTime m_replayStartDateTime; //!< Time to start the replay at
|
||||
bool m_useFileInputTime; //!< Get time from FileInput device
|
||||
bool m_sendTimeToMap; //!< Send time to map when start pressed
|
||||
enum DateTimeSelect {NOW, CUSTOM, FROM_MAP, FROM_FILE} m_dateTimeSelect;
|
||||
QString m_mapFeature; //!< Which feature when FROM_MAP
|
||||
QString m_fileInputDevice; //!< Which device when FROM_FILE
|
||||
|
||||
int m_columnIndexes[SAT_COL_COLUMNS];//!< How the columns are ordered in the table
|
||||
int m_columnSizes[SAT_COL_COLUMNS]; //!< Size of the coumns in the table
|
||||
|
@ -53,7 +53,6 @@ SatelliteTrackerSettingsDialog::SatelliteTrackerSettingsDialog(SatelliteTrackerS
|
||||
}
|
||||
ui->replayEnabled->setChecked(settings->m_replayEnabled);
|
||||
ui->replayDateTime->setDateTime(settings->m_replayStartDateTime);
|
||||
ui->useFileInputTime->setChecked(settings->m_useFileInputTime);
|
||||
ui->sendTimeToMap->setChecked(settings->m_sendTimeToMap);
|
||||
}
|
||||
|
||||
@ -104,7 +103,6 @@ void SatelliteTrackerSettingsDialog::accept()
|
||||
}
|
||||
m_settings->m_replayEnabled = ui->replayEnabled->isChecked();
|
||||
m_settings->m_replayStartDateTime = ui->replayDateTime->dateTime();
|
||||
m_settings->m_useFileInputTime = ui->useFileInputTime->isChecked();
|
||||
m_settings->m_sendTimeToMap = ui->sendTimeToMap->isChecked();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
@ -517,30 +517,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="useFileInputTimeLabel">
|
||||
<property name="text">
|
||||
<string>Get time from FileInput device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="useFileInputTime">
|
||||
<property name="toolTip">
|
||||
<string>Get the time from the FileInput device</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="replayDateTimeLabel">
|
||||
<property name="text">
|
||||
<string>Start date and time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QDateTimeEdit" name="replayDateTime">
|
||||
<property name="toolTip">
|
||||
<string>Set date and time to the displayed value when Satellite Tracker's start button is pressed</string>
|
||||
@ -560,14 +543,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="sendTimeToMapLabel">
|
||||
<property name="text">
|
||||
<string>Send time to map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="sendTimeToMap">
|
||||
<property name="toolTip">
|
||||
<string>Send time to Map feature when Satellite Tracker's start button is pressed</string>
|
||||
|
@ -134,6 +134,44 @@ bool ChannelWebAPIUtils::getFeatureSettings(unsigned int featureSetIndex, unsign
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChannelWebAPIUtils::getFeatureReport(unsigned int featureSetIndex, unsigned int featureIndex, SWGSDRangel::SWGFeatureReport &featureReport)
|
||||
{
|
||||
QString errorResponse;
|
||||
int httpRC;
|
||||
FeatureSet *featureSet;
|
||||
Feature *feature;
|
||||
|
||||
// Get feature report
|
||||
std::vector<FeatureSet*> featureSets = MainCore::instance()->getFeatureeSets();
|
||||
if (featureSetIndex < featureSets.size())
|
||||
{
|
||||
featureSet = featureSets[featureSetIndex];
|
||||
if (featureIndex < (unsigned int)featureSet->getNumberOfFeatures())
|
||||
{
|
||||
feature = featureSet->getFeatureAt(featureIndex);
|
||||
httpRC = feature->webapiReportGet(featureReport, errorResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "ChannelWebAPIUtils::getFeatureReport: no feature " << featureSetIndex << ":" << featureIndex;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "ChannelWebAPIUtils::getFeatureReport: no feature set " << featureSetIndex;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (httpRC/100 != 2)
|
||||
{
|
||||
qWarning("ChannelWebAPIUtils::getFeatureReport: get feature settings error %d: %s",
|
||||
httpRC, qPrintable(errorResponse));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get device center frequency
|
||||
bool ChannelWebAPIUtils::getCenterFrequency(unsigned int deviceIndex, double &frequencyInHz)
|
||||
@ -711,50 +749,43 @@ bool ChannelWebAPIUtils::patchFeatureSetting(unsigned int featureSetIndex, unsig
|
||||
bool ChannelWebAPIUtils::getFeatureReportValue(unsigned int featureSetIndex, unsigned int featureIndex, const QString &key, int &value)
|
||||
{
|
||||
SWGSDRangel::SWGFeatureReport featureReport;
|
||||
QString errorResponse;
|
||||
int httpRC;
|
||||
FeatureSet *featureSet;
|
||||
Feature *feature;
|
||||
|
||||
// Get feature report
|
||||
std::vector<FeatureSet*> featureSets = MainCore::instance()->getFeatureeSets();
|
||||
if (featureSetIndex < featureSets.size())
|
||||
if (getFeatureReport(featureSetIndex, featureIndex, featureReport))
|
||||
{
|
||||
featureSet = featureSets[featureSetIndex];
|
||||
if (featureIndex < (unsigned int)featureSet->getNumberOfFeatures())
|
||||
// Get value of requested key
|
||||
QJsonObject *jsonObj = featureReport.asJsonObject();
|
||||
if (WebAPIUtils::getSubObjectInt(*jsonObj, key, value))
|
||||
{
|
||||
feature = featureSet->getFeatureAt(featureIndex);
|
||||
httpRC = feature->webapiReportGet(featureReport, errorResponse);
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "ChannelWebAPIUtils::getFeatureReportValue: no feature " << featureSetIndex << ":" << featureIndex;
|
||||
qWarning("ChannelWebAPIUtils::getFeatureReportValue: no key %s in feature report", qPrintable(key));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "ChannelWebAPIUtils::getFeatureReportValue: no feature set " << featureSetIndex;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (httpRC/100 != 2)
|
||||
{
|
||||
qWarning("ChannelWebAPIUtils::getFeatureReportValue: get feature report error %d: %s",
|
||||
httpRC, qPrintable(errorResponse));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get value of requested key
|
||||
QJsonObject *jsonObj = featureReport.asJsonObject();
|
||||
if (WebAPIUtils::getSubObjectInt(*jsonObj, key, value))
|
||||
{
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("ChannelWebAPIUtils::getFeatureReportValue: no key %s in feature report", qPrintable(key));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChannelWebAPIUtils::getFeatureReportValue(unsigned int featureSetIndex, unsigned int featureIndex, const QString &key, QString &value)
|
||||
{
|
||||
SWGSDRangel::SWGFeatureReport featureReport;
|
||||
|
||||
if (getFeatureReport(featureSetIndex, featureIndex, featureReport))
|
||||
{
|
||||
// Get value of requested key
|
||||
QJsonObject *jsonObj = featureReport.asJsonObject();
|
||||
if (WebAPIUtils::getSubObjectString(*jsonObj, key, value))
|
||||
{
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("ChannelWebAPIUtils::getFeatureReportValue: no key %s in feature report", qPrintable(key));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGFeatureSettings.h"
|
||||
#include "SWGFeatureReport.h"
|
||||
|
||||
#include "export.h"
|
||||
|
||||
@ -46,9 +47,11 @@ public:
|
||||
static bool patchFeatureSetting(unsigned int featureSetIndex, unsigned int featureIndex, const QString &setting, const QString &value);
|
||||
static bool patchFeatureSetting(unsigned int featureSetIndex, unsigned int featureIndex, const QString &setting, double value);
|
||||
static bool getFeatureReportValue(unsigned int featureSetIndex, unsigned int featureIndex, const QString &key, int &value);
|
||||
static bool getFeatureReportValue(unsigned int featureSetIndex, unsigned int featureIndex, const QString &key, QString &value);
|
||||
protected:
|
||||
static bool getDeviceSettings(unsigned int deviceIndex, SWGSDRangel::SWGDeviceSettings &deviceSettingsResponse, DeviceSet *&deviceSet);
|
||||
static bool getFeatureSettings(unsigned int featureSetIndex, unsigned int featureIndex, SWGSDRangel::SWGFeatureSettings &featureSettingsResponse, Feature *&feature);
|
||||
static bool getFeatureReport(unsigned int featureSetIndex, unsigned int featureIndex, SWGSDRangel::SWGFeatureReport &featureReport);
|
||||
};
|
||||
|
||||
#endif // SDRBASE_CHANNEL_CHANNELWEBAPIUTILS_H_
|
||||
|
Loading…
Reference in New Issue
Block a user