1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 05:11:49 -05:00

Send AOS to features. Support AOS/LOS in local time on map.

This commit is contained in:
Jon Beniston 2021-04-07 21:23:02 +01:00
parent 2aab4cc2cb
commit 8ac583f36c
3 changed files with 71 additions and 5 deletions

View File

@ -36,6 +36,7 @@
#include "device/deviceset.h" #include "device/deviceset.h"
#include "device/deviceapi.h" #include "device/deviceapi.h"
#include "channel/channelwebapiutils.h" #include "channel/channelwebapiutils.h"
#include "feature/featurewebapiutils.h"
#include "maincore.h" #include "maincore.h"
#include "satellitetracker.h" #include "satellitetracker.h"
@ -460,10 +461,22 @@ void SatelliteTrackerWorker::update()
text = text.append("\nSatellite is visible"); text = text.append("\nSatellite is visible");
else else
text = text.append("\nAOS in: %1 mins").arg((int)round((satWorkerState->m_satState.m_passes[0]->m_aos.toSecsSinceEpoch() - qdt.toSecsSinceEpoch())/60.0)); text = text.append("\nAOS in: %1 mins").arg((int)round((satWorkerState->m_satState.m_passes[0]->m_aos.toSecsSinceEpoch() - qdt.toSecsSinceEpoch())/60.0));
QString aosDateTime;
QString losDateTime;
if (m_settings.m_utc)
{
aosDateTime = satWorkerState->m_satState.m_passes[0]->m_aos.toString(m_settings.m_dateFormat + " hh:mm");
losDateTime = satWorkerState->m_satState.m_passes[0]->m_los.toString(m_settings.m_dateFormat + " hh:mm");
}
else
{
aosDateTime = satWorkerState->m_satState.m_passes[0]->m_aos.toLocalTime().toString(m_settings.m_dateFormat + " hh:mm");
losDateTime = satWorkerState->m_satState.m_passes[0]->m_los.toLocalTime().toString(m_settings.m_dateFormat + " hh:mm");
}
text = QString("%1\nAOS: %2\nLOS: %3\nMax El: %4%5") text = QString("%1\nAOS: %2\nLOS: %3\nMax El: %4%5")
.arg(text) .arg(text)
.arg(satWorkerState->m_satState.m_passes[0]->m_aos.toString(m_settings.m_dateFormat + " hh:mm")) .arg(aosDateTime)
.arg(satWorkerState->m_satState.m_passes[0]->m_los.toString(m_settings.m_dateFormat + " hh:mm")) .arg(losDateTime)
.arg((int)round(satWorkerState->m_satState.m_passes[0]->m_maxElevation)) .arg((int)round(satWorkerState->m_satState.m_passes[0]->m_maxElevation))
.arg(QChar(0xb0)); .arg(QChar(0xb0));
} }
@ -631,9 +644,10 @@ void SatelliteTrackerWorker::applyDeviceAOSSettings(const QString& name)
} }
} }
// Send AOS message to channels // Send AOS message to channels/features
SatWorkerState *satWorkerState = m_workerState.value(name); SatWorkerState *satWorkerState = m_workerState.value(name);
ChannelWebAPIUtils::satelliteAOS(name, satWorkerState->m_satState.m_passes[0]->m_northToSouth); ChannelWebAPIUtils::satelliteAOS(name, satWorkerState->m_satState.m_passes[0]->m_northToSouth);
FeatureWebAPIUtils::satelliteAOS(name, satWorkerState->m_aos, satWorkerState->m_los);
// Start Doppler correction, if needed // Start Doppler correction, if needed
satWorkerState->m_initFrequencyOffset.clear(); satWorkerState->m_initFrequencyOffset.clear();
@ -690,9 +704,10 @@ void SatelliteTrackerWorker::applyDeviceAOSSettings(const QString& name)
} }
else else
{ {
// Send AOS message to channels // Send AOS message to channels/features
SatWorkerState *satWorkerState = m_workerState.value(name); SatWorkerState *satWorkerState = m_workerState.value(name);
ChannelWebAPIUtils::satelliteAOS(name, satWorkerState->m_satState.m_passes[0]->m_northToSouth); ChannelWebAPIUtils::satelliteAOS(name, satWorkerState->m_satState.m_passes[0]->m_northToSouth);
FeatureWebAPIUtils::satelliteAOS(name, satWorkerState->m_aos, satWorkerState->m_los);
} }
} }
@ -775,8 +790,9 @@ void SatelliteTrackerWorker::los(SatWorkerState *satWorkerState)
} }
} }
// Send LOS message to channels // Send LOS message to channels/features
ChannelWebAPIUtils::satelliteLOS(satWorkerState->m_name); ChannelWebAPIUtils::satelliteLOS(satWorkerState->m_name);
FeatureWebAPIUtils::satelliteLOS(satWorkerState->m_name);
// Stop acquisition // Stop acquisition
for (int i = 0; i < m_deviceSettingsList->size(); i++) for (int i = 0; i < m_deviceSettingsList->size(); i++)

View File

@ -19,6 +19,7 @@
#include "SWGFeatureActions.h" #include "SWGFeatureActions.h"
#include "SWGMapActions.h" #include "SWGMapActions.h"
#include "SWGPERTesterActions.h"
#include "maincore.h" #include "maincore.h"
#include "feature/featureset.h" #include "feature/featureset.h"
@ -99,3 +100,48 @@ Feature* FeatureWebAPIUtils::getFeature(int featureSetIndex, int featureIndex, c
return nullptr; return nullptr;
} }
} }
// Send AOS actions to all features that support it
bool FeatureWebAPIUtils::satelliteAOS(const QString name, const QDateTime aos, const QDateTime los)
{
std::vector<FeatureSet*>& featureSets = MainCore::instance()->getFeatureeSets();
for (std::vector<FeatureSet*>::const_iterator it = featureSets.begin(); it != featureSets.end(); ++it)
{
for (int fi = 0; fi < (*it)->getNumberOfFeatures(); fi++)
{
Feature *feature = (*it)->getFeatureAt(fi);
if (feature->getURI() == "sdrangel.feature.pertester")
{
QStringList featureActionKeys = {"aos"};
SWGSDRangel::SWGFeatureActions featureActions;
SWGSDRangel::SWGPERTesterActions *perTesterFeatureAction = new SWGSDRangel::SWGPERTesterActions();
SWGSDRangel::SWGPERTesterActions_aos *aosAction = new SWGSDRangel::SWGPERTesterActions_aos();
QString errorResponse;
int httpRC;
aosAction->setSatelliteName(new QString(name));
aosAction->setAosTime(new QString(aos.toString(Qt::ISODate)));
aosAction->setLosTime(new QString(los.toString(Qt::ISODate)));
perTesterFeatureAction->setAos(aosAction);
featureActions.setPerTesterActions(perTesterFeatureAction);
httpRC = feature->webapiActionsPost(featureActionKeys, featureActions, errorResponse);
if (httpRC/100 != 2)
{
qWarning("FeatureWebAPIUtils::satelliteAOS: webapiActionsPost error %d: %s",
httpRC, qPrintable(errorResponse));
return false;
}
}
}
}
return true;
}
// Send LOS actions to all features that support it
bool FeatureWebAPIUtils::satelliteLOS(const QString name)
{
// Not currently required by any features
return true;
}

View File

@ -18,6 +18,8 @@
#ifndef SDRBASE_FEATURE_FEATUREWEBAPIUTILS_H_ #ifndef SDRBASE_FEATURE_FEATUREWEBAPIUTILS_H_
#define SDRBASE_FEATURE_FEATUREWEBAPIUTILS_H_ #define SDRBASE_FEATURE_FEATUREWEBAPIUTILS_H_
#include <QDateTime>
#include "export.h" #include "export.h"
class Feature; class Feature;
@ -27,6 +29,8 @@ class SDRBASE_API FeatureWebAPIUtils
public: public:
static bool mapFind(const QString& target, int featureSetIndex=-1, int featureIndex=-1); static bool mapFind(const QString& target, int featureSetIndex=-1, int featureIndex=-1);
static Feature *getFeature(int featureSetIndex, int featureIndex, const QString& uri); static Feature *getFeature(int featureSetIndex, int featureIndex, const QString& uri);
static bool satelliteAOS(const QString name, const QDateTime aos, const QDateTime los);
static bool satelliteLOS(const QString name);
}; };
#endif // SDRBASE_FEATURE_FEATUREWEBAPIUTILS_H_ #endif // SDRBASE_FEATURE_FEATUREWEBAPIUTILS_H_