diff --git a/plugins/channelrx/radioastronomy/radioastronomy.cpp b/plugins/channelrx/radioastronomy/radioastronomy.cpp index a530e3e71..53346461b 100644 --- a/plugins/channelrx/radioastronomy/radioastronomy.cpp +++ b/plugins/channelrx/radioastronomy/radioastronomy.cpp @@ -40,6 +40,7 @@ #include "device/deviceapi.h" #include "feature/feature.h" #include "channel/channelwebapiutils.h" +#include "feature/featureset.h" #include "util/astronomy.h" #include "util/db.h" #include "maincore.h" @@ -58,6 +59,7 @@ MESSAGE_CLASS_DEFINITION(RadioAstronomy::MsgStartSweep, Message) MESSAGE_CLASS_DEFINITION(RadioAstronomy::MsgStopSweep, Message) MESSAGE_CLASS_DEFINITION(RadioAstronomy::MsgSweepComplete, Message) MESSAGE_CLASS_DEFINITION(RadioAstronomy::MsgSweepStatus, Message) +MESSAGE_CLASS_DEFINITION(RadioAstronomy::MsgReportAvailableFeatures, Message) const char * const RadioAstronomy::m_channelIdURI = "sdrangel.channel.radioastronomy"; const char * const RadioAstronomy::m_channelId = "RadioAstronomy"; @@ -68,6 +70,7 @@ RadioAstronomy::RadioAstronomy(DeviceAPI *deviceAPI) : m_basebandSampleRate(0), m_sweeping(false) { + qDebug("RadioAstronomy::RadioAstronomy"); setObjectName(m_channelId); m_basebandSink = new RadioAstronomyBaseband(this); @@ -85,8 +88,6 @@ RadioAstronomy::RadioAstronomy(DeviceAPI *deviceAPI) : m_deviceAPI->addChannelSinkAPI(this); m_selectedPipe = nullptr; - connect(&m_updatePipesTimer, SIGNAL(timeout()), this, SLOT(updatePipes())); - m_updatePipesTimer.start(1000); m_networkManager = new QNetworkAccessManager(); QObject::connect( @@ -101,6 +102,12 @@ RadioAstronomy::RadioAstronomy(DeviceAPI *deviceAPI) : this, &RadioAstronomy::handleIndexInDeviceSetChanged ); + QObject::connect( + MainCore::instance(), + &MainCore::featureAdded, + this, + &RadioAstronomy::handleFeatureAdded + ); m_sweepTimer.setSingleShot(true); } @@ -108,6 +115,12 @@ RadioAstronomy::RadioAstronomy(DeviceAPI *deviceAPI) : RadioAstronomy::~RadioAstronomy() { qDebug("RadioAstronomy::~RadioAstronomy"); + QObject::disconnect( + MainCore::instance(), + &MainCore::featureAdded, + this, + &RadioAstronomy::handleFeatureAdded + ); QObject::disconnect( m_networkManager, &QNetworkAccessManager::finished, @@ -153,10 +166,10 @@ void RadioAstronomy::start() m_workerThread.start(); m_basebandSink->getInputMessageQueue()->push(new DSPSignalNotification(m_basebandSampleRate, m_centerFrequency)); - m_basebandSink->getInputMessageQueue()->push(RadioAstronomyBaseband::MsgConfigureRadioAstronomyBaseband::create(m_settings, true)); - m_worker->getInputMessageQueue()->push(RadioAstronomyWorker::MsgConfigureRadioAstronomyWorker::create(m_settings, true)); + + scanAvailableFeatures(); } void RadioAstronomy::stop() @@ -631,23 +644,6 @@ void RadioAstronomy::sweepComplete() } } -void RadioAstronomy::updatePipes() -{ - QList availablePipes = updateAvailablePipeSources("startracker.target", RadioAstronomySettings::m_pipeTypes, RadioAstronomySettings::m_pipeURIs, this); - - if (availablePipes != m_availablePipes) - { - m_availablePipes = availablePipes; - if (getMessageQueueToGUI()) - { - MsgReportPipes *msgToGUI = MsgReportPipes::create(); - QList& msgAvailablePipes = msgToGUI->getAvailablePipes(); - msgAvailablePipes.append(availablePipes); - getMessageQueueToGUI()->push(msgToGUI); - } - } -} - void RadioAstronomy::applySettings(const RadioAstronomySettings& settings, bool force) { qDebug() << "RadioAstronomy::applySettings:" @@ -733,8 +729,22 @@ void RadioAstronomy::applySettings(const RadioAstronomySettings& settings, bool { if (!settings.m_starTracker.isEmpty()) { - m_selectedPipe = getPipeEndPoint(settings.m_starTracker, m_availablePipes); - if (m_selectedPipe == nullptr) { + Feature *feature = nullptr; + + for (const auto& fval : m_availableFeatures) + { + QString starTrackerText = tr("F1:%2 %3").arg(fval.m_deviceSetIndex).arg(fval.m_featureIndex).arg(fval.m_type); + + if (settings.m_starTracker == starTrackerText) + { + feature = m_availableFeatures.key(fval); + break; + } + } + + if (feature) { + m_selectedPipe = feature; + } else { qDebug() << "RadioAstronomy::applySettings: No plugin corresponding to target " << settings.m_starTracker; } } @@ -1200,3 +1210,109 @@ void RadioAstronomy::handleIndexInDeviceSetChanged(int index) .arg(index); m_basebandSink->setFifoLabel(fifoLabel); } + +void RadioAstronomy::scanAvailableFeatures() +{ + qDebug("RadioAstronomy::scanAvailableFeatures"); + MainCore *mainCore = MainCore::instance(); + MessagePipes& messagePipes = mainCore->getMessagePipes(); + std::vector& featureSets = mainCore->getFeatureeSets(); + m_availableFeatures.clear(); + + for (const auto& featureSet : featureSets) + { + for (int fei = 0; fei < featureSet->getNumberOfFeatures(); fei++) + { + Feature *feature = featureSet->getFeatureAt(fei); + + if (RadioAstronomySettings::m_pipeURIs.contains(feature->getURI()) && !m_availableFeatures.contains(feature)) + { + qDebug("RadioAstronomy::scanAvailableFeatures: register %d:%d %s (%p)", + featureSet->getIndex(), fei, qPrintable(feature->getURI()), feature); + ObjectPipe *pipe = messagePipes.registerProducerToConsumer(feature, this, "startracker.target"); + MessageQueue *messageQueue = qobject_cast(pipe->m_element); + QObject::connect( + messageQueue, + &MessageQueue::messageEnqueued, + this, + [=](){ this->handleFeatureMessageQueue(messageQueue); }, + Qt::QueuedConnection + ); + connect(pipe, SIGNAL(toBeDeleted(int, QObject*)), this, SLOT(handleMessagePipeToBeDeleted(int, QObject*))); + RadioAstronomySettings::AvailableFeature availableFeature = + RadioAstronomySettings::AvailableFeature{featureSet->getIndex(), fei, feature->getIdentifier()}; + m_availableFeatures[feature] = availableFeature; + } + } + } + + notifyUpdateFeatures(); +} + +void RadioAstronomy::notifyUpdateFeatures() +{ + if (getMessageQueueToGUI()) + { + MsgReportAvailableFeatures *msg = MsgReportAvailableFeatures::create(); + msg->getFeatures() = m_availableFeatures.values(); + getMessageQueueToGUI()->push(msg); + } +} + +void RadioAstronomy::handleFeatureAdded(int featureSetIndex, Feature *feature) +{ + qDebug("RadioAstronomy::handleFeatureAdded: featureSetIndex: %d:%d feature: %s (%p)", + featureSetIndex, feature->getIndexInFeatureSet(), qPrintable(feature->getURI()), feature); + FeatureSet *featureSet = MainCore::instance()->getFeatureeSets()[featureSetIndex]; + + if (RadioAstronomySettings::m_pipeURIs.contains(feature->getURI())) + { + int fei = feature->getIndexInFeatureSet(); + + if (!m_availableFeatures.contains(feature)) + { + MessagePipes& messagePipes = MainCore::instance()->getMessagePipes(); + ObjectPipe *pipe = messagePipes.registerProducerToConsumer(feature, this, "startracker.target"); + MessageQueue *messageQueue = qobject_cast(pipe->m_element); + QObject::connect( + messageQueue, + &MessageQueue::messageEnqueued, + this, + [=](){ this->handleFeatureMessageQueue(messageQueue); }, + Qt::QueuedConnection + ); + connect(pipe, SIGNAL(toBeDeleted(int, QObject*)), this, SLOT(handleMessagePipeToBeDeleted(int, QObject*))); + } + + RadioAstronomySettings::AvailableFeature availableFeature = + RadioAstronomySettings::AvailableFeature{featureSet->getIndex(), fei, feature->getIdentifier()}; + m_availableFeatures[feature] = availableFeature; + + notifyUpdateFeatures(); + } +} + +void RadioAstronomy::handleMessagePipeToBeDeleted(int reason, QObject* object) +{ + if (reason == 0) // producer (channel) + { + if (m_availableFeatures.contains((Feature*) object)) + { + qDebug("RadioAstronomy::handleMessagePipeToBeDeleted: removing feature at (%p)", object); + m_availableFeatures.remove((Feature*) object); + notifyUpdateFeatures(); + } + } +} + +void RadioAstronomy::handleFeatureMessageQueue(MessageQueue* messageQueue) +{ + Message* message; + + while ((message = messageQueue->pop()) != nullptr) + { + if (handleMessage(*message)) { + delete message; + } + } +} diff --git a/plugins/channelrx/radioastronomy/radioastronomy.h b/plugins/channelrx/radioastronomy/radioastronomy.h index efe0225d3..4151b9008 100644 --- a/plugins/channelrx/radioastronomy/radioastronomy.h +++ b/plugins/channelrx/radioastronomy/radioastronomy.h @@ -25,12 +25,12 @@ #include #include #include +#include #include #include "dsp/basebandsamplesink.h" #include "channel/channelapi.h" #include "util/message.h" -#include "pipes/pipeendpoint.h" #include "radioastronomybaseband.h" #include "radioastronomysettings.h" @@ -306,6 +306,23 @@ public: } }; + class MsgReportAvailableFeatures : public Message { + MESSAGE_CLASS_DECLARATION + + public: + QList& getFeatures() { return m_availableFeatures; } + + static MsgReportAvailableFeatures* create() { + return new MsgReportAvailableFeatures(); + } + + private: + QList m_availableFeatures; + + MsgReportAvailableFeatures() : + Message() + {} + }; RadioAstronomy(DeviceAPI *deviceAPI); virtual ~RadioAstronomy(); @@ -387,9 +404,8 @@ private: int m_basebandSampleRate; //!< stored from device message used when starting baseband sink qint64 m_centerFrequency; - QList m_availablePipes; - PipeEndPoint *m_selectedPipe; - QTimer m_updatePipesTimer; + QHash m_availableFeatures; + QObject *m_selectedPipe; QNetworkAccessManager *m_networkManager; QNetworkRequest m_networkRequest; @@ -422,10 +438,11 @@ private: void sweepStart(); void startCal(bool hot); void calComplete(MsgCalComplete* report); + void scanAvailableFeatures(); + void notifyUpdateFeatures(); private slots: void networkManagerFinished(QNetworkReply *reply); - void updatePipes(); void startMeasurement(); void sweepStartMeasurement(); void sweep1(); @@ -434,6 +451,9 @@ private slots: void sweepNext(); void sweepComplete(); void handleIndexInDeviceSetChanged(int index); + void handleFeatureAdded(int deviceSetIndex, Feature *feature); + void handleMessagePipeToBeDeleted(int reason, QObject* object); + void handleFeatureMessageQueue(MessageQueue* messageQueue); }; #endif // INCLUDE_RADIOASTRONOMY_H diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.cpp b/plugins/channelrx/radioastronomy/radioastronomygui.cpp index 72f3d3c1f..352639ada 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.cpp +++ b/plugins/channelrx/radioastronomy/radioastronomygui.cpp @@ -935,20 +935,19 @@ bool RadioAstronomyGUI::deserialize(const QByteArray& data) } } -void RadioAstronomyGUI::updatePipeList() +void RadioAstronomyGUI::updateAvailableFeatures() { QString currentText = ui->starTracker->currentText(); ui->starTracker->blockSignals(true); ui->starTracker->clear(); - QList::const_iterator it = m_availablePipes.begin(); - for (int i = 0; it != m_availablePipes.end(); ++it, i++) { - ui->starTracker->addItem(it->getName()); + for (const auto& feature : m_availableFeatures) { + ui->starTracker->addItem(tr("F%1:%2 %3").arg(feature.m_deviceSetIndex).arg(feature.m_featureIndex).arg(feature.m_type)); } if (currentText.isEmpty()) { - if (m_availablePipes.size() > 0) { + if (m_availableFeatures.size() > 0) { ui->starTracker->setCurrentIndex(0); } } @@ -956,9 +955,10 @@ void RadioAstronomyGUI::updatePipeList() { ui->starTracker->setCurrentIndex(ui->starTracker->findText(currentText)); } - ui->starTracker->blockSignals(false); + ui->starTracker->blockSignals(false); QString newText = ui->starTracker->currentText(); + if (currentText != newText) { m_settings.m_starTracker = newText; @@ -979,11 +979,12 @@ bool RadioAstronomyGUI::handleMessage(const Message& message) updateTSys0(); return true; } - else if (PipeEndPoint::MsgReportPipes::match(message)) + else if (RadioAstronomy::MsgReportAvailableFeatures::match(message)) { - PipeEndPoint::MsgReportPipes& report = (PipeEndPoint::MsgReportPipes&) message; - m_availablePipes = report.getAvailablePipes(); - updatePipeList(); + qDebug("RadioAstronomyGUI::handleMessage: MsgReportAvailableFeatures"); + RadioAstronomy::MsgReportAvailableFeatures& report = (RadioAstronomy::MsgReportAvailableFeatures&) message; + m_availableFeatures = report.getFeatures(); + updateAvailableFeatures(); return true; } else if (MainCore::MsgStarTrackerTarget::match(message)) @@ -1908,22 +1909,19 @@ void RadioAstronomyGUI::on_powerTable_cellDoubleClicked(int row, int column) if ((column >= POWER_COL_RA) && (column >= POWER_COL_EL)) { // Display target in Star Tracker - MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy(); - QList *messageQueues = messagePipes.getMessageQueues(m_radioAstronomy, "startracker.display"); - if (messageQueues) - { - QList::iterator it = messageQueues->begin(); + QList starTrackerPipes; + MainCore::instance()->getMessagePipes().getMessagePipes(this, "startracker.display", starTrackerPipes); - for (; it != messageQueues->end(); ++it) - { - SWGSDRangel::SWGStarTrackerDisplaySettings *swgSettings = new SWGSDRangel::SWGStarTrackerDisplaySettings(); - QDateTime dt(ui->powerTable->item(row, POWER_COL_DATE)->data(Qt::DisplayRole).toDate(), - ui->powerTable->item(row, POWER_COL_TIME)->data(Qt::DisplayRole).toTime()); - swgSettings->setDateTime(new QString(dt.toString(Qt::ISODateWithMs))); - swgSettings->setAzimuth(ui->powerTable->item(row, POWER_COL_AZ)->data(Qt::DisplayRole).toFloat()); - swgSettings->setElevation(ui->powerTable->item(row, POWER_COL_EL)->data(Qt::DisplayRole).toFloat()); - (*it)->push(MainCore::MsgStarTrackerDisplaySettings::create(m_radioAstronomy, swgSettings)); - } + for (const auto& pipe : starTrackerPipes) + { + MessageQueue *messageQueue = qobject_cast(pipe->m_element); + SWGSDRangel::SWGStarTrackerDisplaySettings *swgSettings = new SWGSDRangel::SWGStarTrackerDisplaySettings(); + QDateTime dt(ui->powerTable->item(row, POWER_COL_DATE)->data(Qt::DisplayRole).toDate(), + ui->powerTable->item(row, POWER_COL_TIME)->data(Qt::DisplayRole).toTime()); + swgSettings->setDateTime(new QString(dt.toString(Qt::ISODateWithMs))); + swgSettings->setAzimuth(ui->powerTable->item(row, POWER_COL_AZ)->data(Qt::DisplayRole).toFloat()); + swgSettings->setElevation(ui->powerTable->item(row, POWER_COL_EL)->data(Qt::DisplayRole).toFloat()); + messageQueue->push(MainCore::MsgStarTrackerDisplaySettings::create(m_radioAstronomy, swgSettings)); } } else @@ -2047,6 +2045,7 @@ RadioAstronomyGUI::RadioAstronomyGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUI m_bLAB(0.0f), m_downloadingLAB(false) { + qDebug("RadioAstronomyGUI::RadioAstronomyGUI"); ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); @@ -4281,21 +4280,18 @@ void RadioAstronomyGUI::showLoSMarker(int row) void RadioAstronomyGUI::updateLoSMarker(const QString& name, float l, float b, float d) { // Send to Star Tracker - MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy(); - QList *messageQueues = messagePipes.getMessageQueues(m_radioAstronomy, "startracker.display"); - if (messageQueues) - { - QList::iterator it = messageQueues->begin(); + QList starTrackerPipes; + MainCore::instance()->getMessagePipes().getMessagePipes(this, "startracker.display", starTrackerPipes); - for (; it != messageQueues->end(); ++it) - { - SWGSDRangel::SWGStarTrackerDisplayLoSSettings *swgSettings = new SWGSDRangel::SWGStarTrackerDisplayLoSSettings(); - swgSettings->setName(new QString(name)); - swgSettings->setL(l); - swgSettings->setB(b); - swgSettings->setD(d); - (*it)->push(MainCore::MsgStarTrackerDisplayLoSSettings::create(m_radioAstronomy, swgSettings)); - } + for (const auto& pipe : starTrackerPipes) + { + MessageQueue *messageQueue = qobject_cast(pipe->m_element); + SWGSDRangel::SWGStarTrackerDisplayLoSSettings *swgSettings = new SWGSDRangel::SWGStarTrackerDisplayLoSSettings(); + swgSettings->setName(new QString(name)); + swgSettings->setL(l); + swgSettings->setB(b); + swgSettings->setD(d); + messageQueue->push(MainCore::MsgStarTrackerDisplayLoSSettings::create(m_radioAstronomy, swgSettings)); } } @@ -4682,21 +4678,19 @@ void RadioAstronomyGUI::on_spectrumIndex_valueChanged(int value) ui->powerTable->selectRow(value); ui->powerTable->scrollTo(ui->powerTable->model()->index(value, 0)); ui->spectrumDateTime->setDateTime(m_fftMeasurements[value]->m_dateTime); - // Display target in Star Tracker - MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy(); - QList *messageQueues = messagePipes.getMessageQueues(m_radioAstronomy, "startracker.display"); - if (messageQueues) - { - QList::iterator it = messageQueues->begin(); - for (; it != messageQueues->end(); ++it) - { - SWGSDRangel::SWGStarTrackerDisplaySettings *swgSettings = new SWGSDRangel::SWGStarTrackerDisplaySettings(); - swgSettings->setDateTime(new QString(m_fftMeasurements[value]->m_dateTime.toString(Qt::ISODateWithMs))); - swgSettings->setAzimuth(m_fftMeasurements[value]->m_azimuth); - swgSettings->setElevation(m_fftMeasurements[value]->m_elevation); - (*it)->push(MainCore::MsgStarTrackerDisplaySettings::create(m_radioAstronomy, swgSettings)); - } + // Display target in Star Tracker + QList starTrackerPipes; + MainCore::instance()->getMessagePipes().getMessagePipes(this, "startracker.display", starTrackerPipes); + + for (const auto& pipe : starTrackerPipes) + { + MessageQueue *messageQueue = qobject_cast(pipe->m_element); + SWGSDRangel::SWGStarTrackerDisplaySettings *swgSettings = new SWGSDRangel::SWGStarTrackerDisplaySettings(); + swgSettings->setDateTime(new QString(m_fftMeasurements[value]->m_dateTime.toString(Qt::ISODateWithMs))); + swgSettings->setAzimuth(m_fftMeasurements[value]->m_azimuth); + swgSettings->setElevation(m_fftMeasurements[value]->m_elevation); + messageQueue->push(MainCore::MsgStarTrackerDisplaySettings::create(m_radioAstronomy, swgSettings)); } } } diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.h b/plugins/channelrx/radioastronomy/radioastronomygui.h index 8ace48613..f246a8efa 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.h +++ b/plugins/channelrx/radioastronomy/radioastronomygui.h @@ -34,7 +34,6 @@ #include "util/messagequeue.h" #include "util/httpdownloadmanager.h" #include "settings/rollupstate.h" -#include "pipes/pipeendpoint.h" #include "radioastronomysettings.h" #include "radioastronomy.h" @@ -212,7 +211,7 @@ private: RollupState m_rollupState; RadioAstronomySettings m_settings; bool m_doApplySettings; - QList m_availablePipes; + QList m_availableFeatures; int m_basebandSampleRate; quint64 m_centerFrequency; @@ -322,7 +321,7 @@ private: void displayStreamIndex(); void displaySpectrumLineFrequency(); void displayRunModeSettings(); - void updatePipeList(); + void updateAvailableFeatures(); void updateRotatorList(); bool handleMessage(const Message& message); double degreesToSteradian(double deg) const; diff --git a/plugins/channelrx/radioastronomy/radioastronomysettings.h b/plugins/channelrx/radioastronomy/radioastronomysettings.h index a3363ea2f..46c9cee93 100644 --- a/plugins/channelrx/radioastronomy/radioastronomysettings.h +++ b/plugins/channelrx/radioastronomy/radioastronomysettings.h @@ -35,6 +35,20 @@ class Serializable; struct RadioAstronomySettings { + struct AvailableFeature + { + int m_deviceSetIndex; + int m_featureIndex; + QString m_type; + + AvailableFeature() = default; + AvailableFeature(const AvailableFeature&) = default; + AvailableFeature& operator=(const AvailableFeature&) = default; + bool operator==(const AvailableFeature& a) const { + return (m_deviceSetIndex == a.m_deviceSetIndex) && (m_featureIndex == a.m_featureIndex) && (m_type == a.m_type); + } + }; + int m_inputFrequencyOffset; int m_sampleRate; int m_rfBandwidth; diff --git a/plugins/feature/startracker/startracker.h b/plugins/feature/startracker/startracker.h index 30130d929..a6783fdc9 100644 --- a/plugins/feature/startracker/startracker.h +++ b/plugins/feature/startracker/startracker.h @@ -21,6 +21,7 @@ #include #include +#include #include "feature/feature.h" #include "util/message.h" @@ -160,6 +161,7 @@ private: QNetworkAccessManager *m_networkManager; QNetworkRequest m_networkRequest; + QSet m_availableChannels; Weather *m_weather; float m_solarFlux; @@ -172,10 +174,14 @@ private: void webapiReverseSendSettings(QList& featureSettingsKeys, const StarTrackerSettings& settings, bool force); void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response); double applyBeam(const FITS *fits, double beamwidth, double ra, double dec, int& imgX, int& imgY) const; + void scanAvailableChannels(); private slots: void networkManagerFinished(QNetworkReply *reply); void weatherUpdated(float temperature, float pressure, float humidity); + void handleChannelAdded(int deviceSetIndex, ChannelAPI *channel); + void handleMessagePipeToBeDeleted(int reason, QObject* object); + void handleChannelMessageQueue(MessageQueue* messageQueue); }; #endif // INCLUDE_FEATURE_STARTRACKER_H_ diff --git a/plugins/feature/startracker/startrackerworker.cpp b/plugins/feature/startracker/startrackerworker.cpp index a1f40c82b..a4238b1bb 100644 --- a/plugins/feature/startracker/startrackerworker.cpp +++ b/plugins/feature/startracker/startrackerworker.cpp @@ -607,36 +607,34 @@ void StarTrackerWorker::update() // Unless we're receiving settings to display from a Radio Astronomy plugins if (!m_settings.m_link) { - messageQueues = messagePipes.getMessageQueues(m_starTracker, "startracker.target"); - if (messageQueues) - { - QList::iterator it = messageQueues->begin(); + QList starTrackerPipes; + MainCore::instance()->getMessagePipes().getMessagePipes(this, "startracker.target", starTrackerPipes); - for (; it != messageQueues->end(); ++it) - { - SWGSDRangel::SWGStarTrackerTarget *swgTarget = new SWGSDRangel::SWGStarTrackerTarget(); - swgTarget->setName(new QString(m_settings.m_target)); - swgTarget->setAzimuth(aa.az); - swgTarget->setElevation(aa.alt); - swgTarget->setRa(rd.ra); - swgTarget->setDec(rd.dec); - swgTarget->setB(b); - swgTarget->setL(l); - swgTarget->setSolarFlux(m_solarFlux); - swgTarget->setAirTemperature(m_settings.m_temperature); - double temp; - m_starTracker->calcSkyTemperature(m_settings.m_frequency, m_settings.m_beamwidth, rd.ra, rd.dec, temp); - swgTarget->setSkyTemperature(temp); - swgTarget->setHpbw(m_settings.m_beamwidth); - // Calculate velocities - double vRot = Astronomy::earthRotationVelocity(rd, m_settings.m_latitude, m_settings.m_longitude, dt); - swgTarget->setEarthRotationVelocity(vRot); - double vOrbit = Astronomy::earthOrbitVelocityBCRS(rd,dt); - swgTarget->setEarthOrbitVelocityBcrs(vOrbit); - double vLSRK = Astronomy::sunVelocityLSRK(rd); - swgTarget->setSunVelocityLsr(vLSRK); - (*it)->push(MainCore::MsgStarTrackerTarget::create(m_starTracker, swgTarget)); - } + for (const auto& pipe : starTrackerPipes) + { + MessageQueue *messageQueue = qobject_cast(pipe->m_element); + SWGSDRangel::SWGStarTrackerTarget *swgTarget = new SWGSDRangel::SWGStarTrackerTarget(); + swgTarget->setName(new QString(m_settings.m_target)); + swgTarget->setAzimuth(aa.az); + swgTarget->setElevation(aa.alt); + swgTarget->setRa(rd.ra); + swgTarget->setDec(rd.dec); + swgTarget->setB(b); + swgTarget->setL(l); + swgTarget->setSolarFlux(m_solarFlux); + swgTarget->setAirTemperature(m_settings.m_temperature); + double temp; + m_starTracker->calcSkyTemperature(m_settings.m_frequency, m_settings.m_beamwidth, rd.ra, rd.dec, temp); + swgTarget->setSkyTemperature(temp); + swgTarget->setHpbw(m_settings.m_beamwidth); + // Calculate velocities + double vRot = Astronomy::earthRotationVelocity(rd, m_settings.m_latitude, m_settings.m_longitude, dt); + swgTarget->setEarthRotationVelocity(vRot); + double vOrbit = Astronomy::earthOrbitVelocityBCRS(rd,dt); + swgTarget->setEarthOrbitVelocityBcrs(vOrbit); + double vLSRK = Astronomy::sunVelocityLSRK(rd); + swgTarget->setSunVelocityLsr(vLSRK); + messageQueue->push(MainCore::MsgStarTrackerTarget::create(m_starTracker, swgTarget)); } } diff --git a/sdrbase/maincore.h b/sdrbase/maincore.h index 941808cb6..26fd38678 100644 --- a/sdrbase/maincore.h +++ b/sdrbase/maincore.h @@ -635,19 +635,19 @@ public: MESSAGE_CLASS_DECLARATION public: - const PipeEndPoint *getPipeSource() const { return m_pipeSource; } + const QObject *getPipeSource() const { return m_pipeSource; } SWGSDRangel::SWGStarTrackerTarget *getSWGStarTrackerTarget() const { return m_swgStarTrackerTarget; } - static MsgStarTrackerTarget* create(const PipeEndPoint *pipeSource, SWGSDRangel::SWGStarTrackerTarget *swgStarTrackerTarget) + static MsgStarTrackerTarget* create(const QObject *pipeSource, SWGSDRangel::SWGStarTrackerTarget *swgStarTrackerTarget) { return new MsgStarTrackerTarget(pipeSource, swgStarTrackerTarget); } private: - const PipeEndPoint *m_pipeSource; + const QObject *m_pipeSource; SWGSDRangel::SWGStarTrackerTarget *m_swgStarTrackerTarget; - MsgStarTrackerTarget(const PipeEndPoint *pipeSource, SWGSDRangel::SWGStarTrackerTarget *swgStarTrackerTarget) : + MsgStarTrackerTarget(const QObject *pipeSource, SWGSDRangel::SWGStarTrackerTarget *swgStarTrackerTarget) : Message(), m_pipeSource(pipeSource), m_swgStarTrackerTarget(swgStarTrackerTarget)