mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
Map feature and dependent plugins: implement new message pipes. Part of #1154
This commit is contained in:
parent
10ae0f3efc
commit
35f1c2aacc
@ -712,22 +712,24 @@ bool ADSBDemodGUI::updateLocalPosition(Aircraft *aircraft, double latitude, doub
|
||||
void ADSBDemodGUI::sendToMap(Aircraft *aircraft, QList<SWGSDRangel::SWGMapAnimation *> *animations)
|
||||
{
|
||||
// Send to Map feature
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_adsbDemod, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
QList<ObjectPipe*> mapPipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_adsbDemod, "mapitems", mapPipes);
|
||||
|
||||
if (mapPipes.size() > 0)
|
||||
{
|
||||
// Adjust altitude by airfield barometric elevation, so aircraft appears to
|
||||
// take-off/land at correct point on runway
|
||||
int altitudeFt = aircraft->m_altitude;
|
||||
|
||||
if (!aircraft->m_onSurface && !aircraft->m_altitudeGNSS) {
|
||||
altitudeFt -= m_settings.m_airfieldElevation;
|
||||
}
|
||||
|
||||
float altitudeM = Units::feetToMetres(altitudeFt);
|
||||
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
for (const auto& pipe : mapPipes)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(aircraft->m_icaoHex));
|
||||
swgMapItem->setLatitude(aircraft->m_latitude);
|
||||
@ -738,12 +740,15 @@ void ADSBDemodGUI::sendToMap(Aircraft *aircraft, QList<SWGSDRangel::SWGMapAnimat
|
||||
swgMapItem->setImage(new QString(QString("qrc:///map/%1").arg(aircraft->getImage())));
|
||||
swgMapItem->setImageRotation(aircraft->m_heading);
|
||||
swgMapItem->setText(new QString(aircraft->getText(true)));
|
||||
|
||||
if (!aircraft->m_aircraft3DModel.isEmpty()) {
|
||||
swgMapItem->setModel(new QString(aircraft->m_aircraft3DModel));
|
||||
} else {
|
||||
swgMapItem->setModel(new QString(aircraft->m_aircraftCat3DModel));
|
||||
}
|
||||
|
||||
swgMapItem->setLabel(new QString(aircraft->m_callsign));
|
||||
|
||||
if (aircraft->m_headingValid)
|
||||
{
|
||||
swgMapItem->setOrientation(1);
|
||||
@ -757,13 +762,14 @@ void ADSBDemodGUI::sendToMap(Aircraft *aircraft, QList<SWGSDRangel::SWGMapAnimat
|
||||
// Orient aircraft based on velocity calculated from position
|
||||
swgMapItem->setOrientation(0);
|
||||
}
|
||||
|
||||
swgMapItem->setModelAltitudeOffset(aircraft->m_modelAltitudeOffset);
|
||||
swgMapItem->setLabelAltitudeOffset(aircraft->m_labelAltitudeOffset);
|
||||
swgMapItem->setAltitudeReference(3); // CLIP_TO_GROUND so aircraft don't go under runway
|
||||
swgMapItem->setAnimations(animations); // Does this need to be duplicated?
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_adsbDemod, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4037,10 +4043,12 @@ void ADSBDemodGUI::tick()
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
qint64 nowSecs = now.toSecsSinceEpoch();
|
||||
QHash<int, Aircraft *>::iterator i = m_aircraft.begin();
|
||||
|
||||
while (i != m_aircraft.end())
|
||||
{
|
||||
Aircraft *aircraft = i.value();
|
||||
qint64 secondsSinceLastFrame = nowSecs - aircraft->m_time.toSecsSinceEpoch();
|
||||
|
||||
if (secondsSinceLastFrame >= m_settings.m_removeTimeout)
|
||||
{
|
||||
// Don't try to track it anymore
|
||||
@ -4049,6 +4057,7 @@ void ADSBDemodGUI::tick()
|
||||
m_adsbDemod->clearTarget();
|
||||
m_trackAircraft = nullptr;
|
||||
}
|
||||
|
||||
// Remove map model
|
||||
m_aircraftModel.removeAircraft(aircraft);
|
||||
// Remove row from table
|
||||
@ -4056,25 +4065,26 @@ void ADSBDemodGUI::tick()
|
||||
// Remove aircraft from hash
|
||||
i = m_aircraft.erase(i);
|
||||
// Remove from map feature
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_adsbDemod, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
QList<ObjectPipe*> mapPipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(this, "mapitems", mapPipes);
|
||||
|
||||
for (const auto& pipe : mapPipes)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
{
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(QString("%1").arg(aircraft->m_icao, 0, 16)));
|
||||
swgMapItem->setImage(new QString(""));
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_adsbDemod, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
}
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(QString("%1").arg(aircraft->m_icao, 0, 16)));
|
||||
swgMapItem->setImage(new QString(""));
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_adsbDemod, swgMapItem);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
|
||||
// And finally free its memory
|
||||
delete aircraft;
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -867,20 +867,18 @@ void APTDemodGUI::on_deleteImageFromMap_clicked()
|
||||
|
||||
void APTDemodGUI::deleteImageFromMap(const QString &name)
|
||||
{
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_aptDemod, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
{
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setImage(new QString()); // Set image to "" to delete it
|
||||
swgMapItem->setType(1);
|
||||
QList<ObjectPipe*> mapPipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_aptDemod, "mapitems", mapPipes);
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_aptDemod, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
}
|
||||
for (const auto& pipe : mapPipes)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setImage(new QString()); // Set image to "" to delete it
|
||||
swgMapItem->setType(1);
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_aptDemod, swgMapItem);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
|
@ -661,9 +661,10 @@ void APTDemodImageWorker::makeTransparent(QImage &image)
|
||||
void APTDemodImageWorker::sendImageToMap(QImage image)
|
||||
{
|
||||
// Send to Map feature
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_aptDemod, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
QList<ObjectPipe*> mapPipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_aptDemod, "mapitems", mapPipes);
|
||||
|
||||
if (mapPipes.size() > 0)
|
||||
{
|
||||
// Only display one channel on map
|
||||
QImage selectedChannel;
|
||||
@ -695,9 +696,9 @@ void APTDemodImageWorker::sendImageToMap(QImage image)
|
||||
// Send name to GUI
|
||||
m_messageQueueToGUI->push(APTDemod::MsgMapImageName::create(name));
|
||||
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
for (const auto& pipe : mapPipes)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setImage(new QString(data));
|
||||
@ -709,7 +710,7 @@ void APTDemodImageWorker::sendImageToMap(QImage image)
|
||||
swgMapItem->setImageTileSouth(m_tileSouth);
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_aptDemod, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -416,46 +416,44 @@ void AISGUI::sendToMap(const QString &name, const QString &label,
|
||||
float heading
|
||||
)
|
||||
{
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_ais, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
QList<ObjectPipe*> mapPipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_ais, "mapitems", mapPipes);
|
||||
|
||||
for (const auto& pipe : mapPipes)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setLatitude(latitude);
|
||||
swgMapItem->setLongitude(longitude);
|
||||
swgMapItem->setAltitude(0);
|
||||
swgMapItem->setAltitudeReference(1); // CLAMP_TO_GROUND
|
||||
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
{
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setLatitude(latitude);
|
||||
swgMapItem->setLongitude(longitude);
|
||||
swgMapItem->setAltitude(0);
|
||||
swgMapItem->setAltitudeReference(1); // CLAMP_TO_GROUND
|
||||
|
||||
if (positionDateTime.isValid()) {
|
||||
swgMapItem->setPositionDateTime(new QString(positionDateTime.toString(Qt::ISODateWithMs)));
|
||||
}
|
||||
|
||||
swgMapItem->setImageRotation(heading);
|
||||
swgMapItem->setText(new QString(text));
|
||||
|
||||
if (image.isEmpty()) {
|
||||
swgMapItem->setImage(new QString(""));
|
||||
} else {
|
||||
swgMapItem->setImage(new QString(QString("qrc:///ais/map/%1").arg(image)));
|
||||
}
|
||||
swgMapItem->setModel(new QString(model));
|
||||
swgMapItem->setModelAltitudeOffset(modelOffset);
|
||||
swgMapItem->setLabel(new QString(label));
|
||||
swgMapItem->setLabelAltitudeOffset(labelOffset);
|
||||
swgMapItem->setFixedPosition(false);
|
||||
swgMapItem->setOrientation(1);
|
||||
swgMapItem->setHeading(heading);
|
||||
swgMapItem->setPitch(0.0);
|
||||
swgMapItem->setRoll(0.0);
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_ais, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
if (positionDateTime.isValid()) {
|
||||
swgMapItem->setPositionDateTime(new QString(positionDateTime.toString(Qt::ISODateWithMs)));
|
||||
}
|
||||
|
||||
swgMapItem->setImageRotation(heading);
|
||||
swgMapItem->setText(new QString(text));
|
||||
|
||||
if (image.isEmpty()) {
|
||||
swgMapItem->setImage(new QString(""));
|
||||
} else {
|
||||
swgMapItem->setImage(new QString(QString("qrc:///ais/map/%1").arg(image)));
|
||||
}
|
||||
|
||||
swgMapItem->setModel(new QString(model));
|
||||
swgMapItem->setModelAltitudeOffset(modelOffset);
|
||||
swgMapItem->setLabel(new QString(label));
|
||||
swgMapItem->setLabelAltitudeOffset(labelOffset);
|
||||
swgMapItem->setFixedPosition(false);
|
||||
swgMapItem->setOrientation(1);
|
||||
swgMapItem->setHeading(heading);
|
||||
swgMapItem->setPitch(0.0);
|
||||
swgMapItem->setRoll(0.0);
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_ais, swgMapItem);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,46 +337,52 @@ bool APRSGUI::handleMessage(const Message& message)
|
||||
}
|
||||
|
||||
// Forward to map
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_aprs, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
if (aprs->m_hasPosition && (aprs->m_from != ""))
|
||||
{
|
||||
if (aprs->m_hasPosition && (aprs->m_from != ""))
|
||||
QList<ObjectPipe*> mapPipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_aprs, "mapitems", mapPipes);
|
||||
|
||||
for (const auto& pipe : mapPipes)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
{
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
if (!aprs->m_objectName.isEmpty())
|
||||
swgMapItem->setName(new QString(aprs->m_objectName));
|
||||
else
|
||||
swgMapItem->setName(new QString(aprs->m_from));
|
||||
swgMapItem->setLatitude(aprs->m_latitude);
|
||||
swgMapItem->setLongitude(aprs->m_longitude);
|
||||
swgMapItem->setAltitude(aprs->m_hasAltitude ? Units::feetToMetres(aprs->m_altitudeFt) : 0);
|
||||
swgMapItem->setAltitudeReference(1); // CLAMP_TO_GROUND
|
||||
if (aprs->m_objectKilled)
|
||||
{
|
||||
swgMapItem->setImage(new QString(""));
|
||||
swgMapItem->setText(new QString(""));
|
||||
}
|
||||
else
|
||||
{
|
||||
swgMapItem->setImage(new QString(QString("qrc:///%1").arg(aprs->m_symbolImage)));
|
||||
swgMapItem->setText(new QString(aprs->toText(true, false, '\n',
|
||||
m_settings.m_altitudeUnits == APRSSettings::METRES,
|
||||
(int)m_settings.m_speedUnits,
|
||||
m_settings.m_temperatureUnits == APRSSettings::CELSIUS,
|
||||
m_settings.m_rainfallUnits == APRSSettings::MILLIMETRE)));
|
||||
}
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_aprs, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
if (!aprs->m_objectName.isEmpty()) {
|
||||
swgMapItem->setName(new QString(aprs->m_objectName));
|
||||
} else {
|
||||
swgMapItem->setName(new QString(aprs->m_from));
|
||||
}
|
||||
|
||||
swgMapItem->setLatitude(aprs->m_latitude);
|
||||
swgMapItem->setLongitude(aprs->m_longitude);
|
||||
swgMapItem->setAltitude(aprs->m_hasAltitude ? Units::feetToMetres(aprs->m_altitudeFt) : 0);
|
||||
swgMapItem->setAltitudeReference(1); // CLAMP_TO_GROUND
|
||||
|
||||
if (aprs->m_objectKilled)
|
||||
{
|
||||
swgMapItem->setImage(new QString(""));
|
||||
swgMapItem->setText(new QString(""));
|
||||
}
|
||||
else
|
||||
{
|
||||
swgMapItem->setImage(new QString(QString("qrc:///%1").arg(aprs->m_symbolImage)));
|
||||
swgMapItem->setText(new QString(
|
||||
aprs->toText(
|
||||
true,
|
||||
false,
|
||||
'\n',
|
||||
m_settings.m_altitudeUnits == APRSSettings::METRES,
|
||||
(int)m_settings.m_speedUnits,
|
||||
m_settings.m_temperatureUnits == APRSSettings::CELSIUS,
|
||||
m_settings.m_rainfallUnits == APRSSettings::MILLIMETRE
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_aprs, swgMapItem);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -385,7 +391,10 @@ bool APRSGUI::handleMessage(const Message& message)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "APRSGUI::handleMessage: Failed to decode as AX.25";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QBuffer>
|
||||
#include <QTimer>
|
||||
|
||||
#include "SWGFeatureSettings.h"
|
||||
#include "SWGFeatureReport.h"
|
||||
@ -38,6 +39,7 @@
|
||||
MESSAGE_CLASS_DEFINITION(Map::MsgConfigureMap, Message)
|
||||
MESSAGE_CLASS_DEFINITION(Map::MsgFind, Message)
|
||||
MESSAGE_CLASS_DEFINITION(Map::MsgSetDateTime, Message)
|
||||
MESSAGE_CLASS_DEFINITION(Map::MsgReportAvailableChannelOrFeatures, Message)
|
||||
|
||||
const char* const Map::m_featureIdURI = "sdrangel.feature.map";
|
||||
const char* const Map::m_featureId = "Map";
|
||||
@ -51,8 +53,6 @@ Map::Map(WebAPIAdapterInterface *webAPIAdapterInterface) :
|
||||
setObjectName(m_featureId);
|
||||
m_state = StIdle;
|
||||
m_errorMessage = "Map error";
|
||||
connect(&m_updatePipesTimer, SIGNAL(timeout()), this, SLOT(updatePipes()));
|
||||
m_updatePipesTimer.start(1000);
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
QObject::connect(
|
||||
m_networkManager,
|
||||
@ -60,10 +60,35 @@ Map::Map(WebAPIAdapterInterface *webAPIAdapterInterface) :
|
||||
this,
|
||||
&Map::networkManagerFinished
|
||||
);
|
||||
QObject::connect(
|
||||
MainCore::instance(),
|
||||
&MainCore::featureAdded,
|
||||
this,
|
||||
&Map::handleFeatureAdded
|
||||
);
|
||||
QObject::connect(
|
||||
MainCore::instance(),
|
||||
&MainCore::channelAdded,
|
||||
this,
|
||||
&Map::handleChannelAdded
|
||||
);
|
||||
QTimer::singleShot(2000, this, SLOT(scanAvailableChannelsAndFeatures()));
|
||||
}
|
||||
|
||||
Map::~Map()
|
||||
{
|
||||
QObject::disconnect(
|
||||
MainCore::instance(),
|
||||
&MainCore::featureAdded,
|
||||
this,
|
||||
&Map::handleFeatureAdded
|
||||
);
|
||||
QObject::disconnect(
|
||||
MainCore::instance(),
|
||||
&MainCore::channelAdded,
|
||||
this,
|
||||
&Map::handleChannelAdded
|
||||
);
|
||||
QObject::disconnect(
|
||||
m_networkManager,
|
||||
&QNetworkAccessManager::finished,
|
||||
@ -85,6 +110,7 @@ bool Map::handleMessage(const Message& cmd)
|
||||
}
|
||||
else if (MainCore::MsgMapItem::match(cmd))
|
||||
{
|
||||
qDebug() << "Map::handleMessage: MsgMapItem";
|
||||
MainCore::MsgMapItem& msgMapItem = (MainCore::MsgMapItem&) cmd;
|
||||
MainCore::MsgMapItem *copy = new MainCore::MsgMapItem(msgMapItem);
|
||||
getMessageQueueToGUI()->push(copy);
|
||||
@ -96,23 +122,6 @@ bool Map::handleMessage(const Message& cmd)
|
||||
}
|
||||
}
|
||||
|
||||
void Map::updatePipes()
|
||||
{
|
||||
QList<AvailablePipeSource> availablePipes = updateAvailablePipeSources("mapitems", MapSettings::m_pipeTypes, MapSettings::m_pipeURIs, this);
|
||||
|
||||
if (availablePipes != m_availablePipes)
|
||||
{
|
||||
m_availablePipes = availablePipes;
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportPipes *msgToGUI = MsgReportPipes::create();
|
||||
QList<AvailablePipeSource>& msgAvailablePipes = msgToGUI->getAvailablePipes();
|
||||
msgAvailablePipes.append(availablePipes);
|
||||
getMessageQueueToGUI()->push(msgToGUI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray Map::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
@ -435,3 +444,164 @@ QDateTime Map::getMapDateTime()
|
||||
return m_mapDateTime.addMSecs(diffMsecs * m_multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::scanAvailableChannelsAndFeatures()
|
||||
{
|
||||
qDebug("Map::scanAvailableChannelsAndFeatures");
|
||||
std::vector<FeatureSet*>& featureSets = MainCore::instance()->getFeatureeSets();
|
||||
m_availableChannelOrFeatures.clear();
|
||||
|
||||
for (const auto& featureSet : featureSets)
|
||||
{
|
||||
for (int fei = 0; fei < featureSet->getNumberOfFeatures(); fei++)
|
||||
{
|
||||
Feature *feature = featureSet->getFeatureAt(fei);
|
||||
|
||||
if (MapSettings::m_pipeURIs.contains(feature->getURI()) && !m_availableChannelOrFeatures.contains(feature))
|
||||
{
|
||||
qDebug("Map::scanAvailableChannelsAndFeatures: store feature %d:%d %s (%p)",
|
||||
featureSet->getIndex(), fei, qPrintable(feature->getURI()), feature);
|
||||
registerPipe(feature);
|
||||
MapSettings::AvailableChannelOrFeature availableItem =
|
||||
MapSettings::AvailableChannelOrFeature{
|
||||
"F",
|
||||
featureSet->getIndex(),
|
||||
fei,
|
||||
feature->getIdentifier(),
|
||||
feature
|
||||
};
|
||||
m_availableChannelOrFeatures[feature] = availableItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<DeviceSet*>& deviceSets = MainCore::instance()->getDeviceSets();
|
||||
|
||||
for (const auto& deviceSet : deviceSets)
|
||||
{
|
||||
DSPDeviceSourceEngine *deviceSourceEngine = deviceSet->m_deviceSourceEngine;
|
||||
|
||||
if (deviceSourceEngine)
|
||||
{
|
||||
for (int chi = 0; chi < deviceSet->getNumberOfChannels(); chi++)
|
||||
{
|
||||
ChannelAPI *channel = deviceSet->getChannelAt(chi);
|
||||
|
||||
if (MapSettings::m_pipeURIs.contains(channel->getURI()) && !m_availableChannelOrFeatures.contains(channel))
|
||||
{
|
||||
qDebug("Map::scanAvailableChannelsAndFeatures: store channel %d:%d %s (%p)",
|
||||
deviceSet->getIndex(), chi, qPrintable(channel->getURI()), channel);
|
||||
registerPipe(channel);
|
||||
MapSettings::AvailableChannelOrFeature availableItem =
|
||||
MapSettings::AvailableChannelOrFeature{
|
||||
"R",
|
||||
deviceSet->getIndex(),
|
||||
chi,
|
||||
channel->getIdentifier(),
|
||||
channel};
|
||||
m_availableChannelOrFeatures[channel] = availableItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
void Map::handleFeatureAdded(int featureSetIndex, Feature *feature)
|
||||
{
|
||||
FeatureSet *featureSet = MainCore::instance()->getFeatureeSets()[featureSetIndex];
|
||||
|
||||
if (MapSettings::m_pipeURIs.contains(feature->getURI()))
|
||||
{
|
||||
qDebug("Map::handleFeatureAdded: featureSetIndex: %d:%d feature: %s (%p)",
|
||||
featureSetIndex, feature->getIndexInFeatureSet(), qPrintable(feature->getURI()), feature);
|
||||
registerPipe(feature);
|
||||
MapSettings::AvailableChannelOrFeature availableItem =
|
||||
MapSettings::AvailableChannelOrFeature{
|
||||
"F",
|
||||
featureSet->getIndex(),
|
||||
feature->getIndexInFeatureSet(),
|
||||
feature->getIdentifier(),
|
||||
feature
|
||||
};
|
||||
m_availableChannelOrFeatures[feature] = availableItem;
|
||||
notifyUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void Map::handleChannelAdded(int deviceSetIndex, ChannelAPI *channel)
|
||||
{
|
||||
DeviceSet *deviceSet = MainCore::instance()->getDeviceSets()[deviceSetIndex];
|
||||
DSPDeviceSourceEngine *deviceSourceEngine = deviceSet->m_deviceSourceEngine;
|
||||
|
||||
if (deviceSourceEngine && MapSettings::m_pipeURIs.contains(channel->getURI()))
|
||||
{
|
||||
qDebug("Map::handleChannelAdded: deviceSetIndex: %d:%d channel: %s (%p)",
|
||||
deviceSetIndex, channel->getIndexInDeviceSet(), qPrintable(channel->getURI()), channel);
|
||||
registerPipe(channel);
|
||||
MapSettings::AvailableChannelOrFeature availableItem =
|
||||
MapSettings::AvailableChannelOrFeature{
|
||||
"R",
|
||||
deviceSet->getIndex(),
|
||||
channel->getIndexInDeviceSet(),
|
||||
channel->getIdentifier(),
|
||||
channel
|
||||
};
|
||||
m_availableChannelOrFeatures[channel] = availableItem;
|
||||
notifyUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void Map::registerPipe(QObject *object)
|
||||
{
|
||||
qDebug("Map::registerPipe: register %s (%p)", qPrintable(object->objectName()), object);
|
||||
MessagePipes& messagePipes = MainCore::instance()->getMessagePipes();
|
||||
ObjectPipe *pipe = messagePipes.registerProducerToConsumer(object, this, "mapitems");
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
QObject::connect(
|
||||
messageQueue,
|
||||
&MessageQueue::messageEnqueued,
|
||||
this,
|
||||
[=](){ this->handlePipeMessageQueue(messageQueue); },
|
||||
Qt::QueuedConnection
|
||||
);
|
||||
QObject::connect(
|
||||
pipe,
|
||||
&ObjectPipe::toBeDeleted,
|
||||
this,
|
||||
&Map::handleMessagePipeToBeDeleted
|
||||
);
|
||||
}
|
||||
|
||||
void Map::notifyUpdate()
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportAvailableChannelOrFeatures *msg = MsgReportAvailableChannelOrFeatures::create();
|
||||
msg->getItems() = m_availableChannelOrFeatures.values();
|
||||
getMessageQueueToGUI()->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::handleMessagePipeToBeDeleted(int reason, QObject* object)
|
||||
{
|
||||
if ((reason == 0) && m_availableChannelOrFeatures.contains(object)) // producer
|
||||
{
|
||||
qDebug("Map::handleMessagePipeToBeDeleted: removing channel or feature at (%p)", object);
|
||||
m_availableChannelOrFeatures.remove(object);
|
||||
notifyUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void Map::handlePipeMessageQueue(MessageQueue* messageQueue)
|
||||
{
|
||||
Message* message;
|
||||
|
||||
while ((message = messageQueue->pop()) != nullptr)
|
||||
{
|
||||
if (handleMessage(*message)) {
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <QThread>
|
||||
#include <QHash>
|
||||
#include <QNetworkRequest>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
|
||||
@ -103,6 +102,24 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
class MsgReportAvailableChannelOrFeatures : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
QList<MapSettings::AvailableChannelOrFeature>& getItems() { return m_availableChannelOrFeatures; }
|
||||
|
||||
static MsgReportAvailableChannelOrFeatures* create() {
|
||||
return new MsgReportAvailableChannelOrFeatures();
|
||||
}
|
||||
|
||||
private:
|
||||
QList<MapSettings::AvailableChannelOrFeature> m_availableChannelOrFeatures;
|
||||
|
||||
MsgReportAvailableChannelOrFeatures() :
|
||||
Message()
|
||||
{}
|
||||
};
|
||||
|
||||
Map(WebAPIAdapterInterface *webAPIAdapterInterface);
|
||||
virtual ~Map();
|
||||
virtual void destroy() { delete this; }
|
||||
@ -156,8 +173,7 @@ public:
|
||||
private:
|
||||
QThread m_thread;
|
||||
MapSettings m_settings;
|
||||
QList<AvailablePipeSource> m_availablePipes;
|
||||
QTimer m_updatePipesTimer;
|
||||
QHash<QObject*, MapSettings::AvailableChannelOrFeature> m_availableChannelOrFeatures;
|
||||
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
@ -165,6 +181,8 @@ private:
|
||||
void applySettings(const MapSettings& settings, bool force = false);
|
||||
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const MapSettings& settings, bool force);
|
||||
void registerPipe(QObject *object);
|
||||
void notifyUpdate();
|
||||
|
||||
QDateTime m_mapDateTime;
|
||||
QDateTime m_systemDateTime;
|
||||
@ -172,8 +190,12 @@ private:
|
||||
QMutex m_dateTimeMutex;
|
||||
|
||||
private slots:
|
||||
void updatePipes();
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
void scanAvailableChannelsAndFeatures();
|
||||
void handleFeatureAdded(int featureSetIndex, Feature *feature);
|
||||
void handleChannelAdded(int deviceSetIndex, ChannelAPI *channel);
|
||||
void handleMessagePipeToBeDeleted(int reason, QObject* object);
|
||||
void handlePipeMessageQueue(MessageQueue* messageQueue);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FEATURE_MAP_H_
|
||||
|
@ -96,10 +96,10 @@ bool MapGUI::handleMessage(const Message& message)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (PipeEndPoint::MsgReportPipes::match(message))
|
||||
else if (Map::MsgReportAvailableChannelOrFeatures::match(message))
|
||||
{
|
||||
PipeEndPoint::MsgReportPipes& report = (PipeEndPoint::MsgReportPipes&) message;
|
||||
m_availablePipes = report.getAvailablePipes();
|
||||
Map::MsgReportAvailableChannelOrFeatures& report = (Map::MsgReportAvailableChannelOrFeatures&) message;
|
||||
m_availableChannelOrFeatures = report.getItems();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -124,18 +124,20 @@ bool MapGUI::handleMessage(const Message& message)
|
||||
|
||||
// TODO: Could have this in SWGMapItem so plugins can create additional groups
|
||||
QString group;
|
||||
for (int i = 0; i < m_availablePipes.size(); i++)
|
||||
|
||||
for (int i = 0; i < m_availableChannelOrFeatures.size(); i++)
|
||||
{
|
||||
if (m_availablePipes[i].m_source == msgMapItem.getPipeSource())
|
||||
if (m_availableChannelOrFeatures[i].m_source == msgMapItem.getPipeSource())
|
||||
{
|
||||
for (int j = 0; j < MapSettings::m_pipeTypes.size(); j++)
|
||||
{
|
||||
if (m_availablePipes[i].m_id == MapSettings::m_pipeTypes[j]) {
|
||||
group = m_availablePipes[i].m_id;
|
||||
if (m_availableChannelOrFeatures[i].m_type == MapSettings::m_pipeTypes[j]) {
|
||||
group = m_availableChannelOrFeatures[i].m_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update(msgMapItem.getPipeSource(), swgMapItem, group);
|
||||
return true;
|
||||
}
|
||||
@ -288,7 +290,7 @@ MapGUI::~MapGUI()
|
||||
}
|
||||
|
||||
// Update a map item or image
|
||||
void MapGUI::update(const PipeEndPoint *source, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group)
|
||||
void MapGUI::update(const QObject *source, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group)
|
||||
{
|
||||
if (swgMapItem->getType() == 0)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ private:
|
||||
MapSettings m_settings;
|
||||
RollupState m_rollupState;
|
||||
bool m_doApplySettings;
|
||||
QList<PipeEndPoint::AvailablePipeSource> m_availablePipes;
|
||||
QList<MapSettings::AvailableChannelOrFeature> m_availableChannelOrFeatures;
|
||||
|
||||
Map* m_map;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
@ -119,7 +119,7 @@ private:
|
||||
explicit MapGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent = nullptr);
|
||||
virtual ~MapGUI();
|
||||
|
||||
void update(const PipeEndPoint *source, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group);
|
||||
void update(const QObject *source, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group);
|
||||
void blockApplySettings(bool block);
|
||||
void applySettings(bool force = false);
|
||||
void applyMap2DSettings(bool reloadMap);
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "SWGTargetAzimuthElevation.h"
|
||||
|
||||
MapItem::MapItem(const PipeEndPoint *sourcePipe, const QString &group, MapSettings::MapItemSettings *itemSettings, SWGSDRangel::SWGMapItem *mapItem) :
|
||||
MapItem::MapItem(const QObject *sourcePipe, const QString &group, MapSettings::MapItemSettings *itemSettings, SWGSDRangel::SWGMapItem *mapItem) :
|
||||
m_altitude(0.0)
|
||||
{
|
||||
m_sourcePipe = sourcePipe;
|
||||
@ -216,7 +216,7 @@ Q_INVOKABLE void MapModel::add(MapItem *item)
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void MapModel::update(const PipeEndPoint *sourcePipe, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group)
|
||||
void MapModel::update(const QObject *sourcePipe, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group)
|
||||
{
|
||||
QString name = *swgMapItem->getName();
|
||||
// Add, update or delete and item
|
||||
@ -440,7 +440,7 @@ Q_INVOKABLE void MapModel::moveToBack(int oldRow)
|
||||
}
|
||||
}
|
||||
|
||||
MapItem *MapModel::findMapItem(const PipeEndPoint *source, const QString& name)
|
||||
MapItem *MapModel::findMapItem(const QObject *source, const QString& name)
|
||||
{
|
||||
// FIXME: Should consider adding a QHash for this
|
||||
QListIterator<MapItem *> i(m_items);
|
||||
|
@ -31,13 +31,12 @@
|
||||
class MapModel;
|
||||
class MapGUI;
|
||||
class CZML;
|
||||
class PipeEndPoint;
|
||||
|
||||
// Information required about each item displayed on the map
|
||||
class MapItem {
|
||||
|
||||
public:
|
||||
MapItem(const PipeEndPoint *sourcePipe, const QString &group, MapSettings::MapItemSettings *itemSettings, SWGSDRangel::SWGMapItem *mapItem);
|
||||
MapItem(const QObject *sourcePipe, const QString &group, MapSettings::MapItemSettings *itemSettings, SWGSDRangel::SWGMapItem *mapItem);
|
||||
void update(SWGSDRangel::SWGMapItem *mapItem);
|
||||
QGeoCoordinate getCoordinates();
|
||||
|
||||
@ -50,7 +49,7 @@ private:
|
||||
friend CZML;
|
||||
QString m_group;
|
||||
MapSettings::MapItemSettings *m_itemSettings;
|
||||
const PipeEndPoint *m_sourcePipe; // Channel/feature that created the item
|
||||
const QObject *m_sourcePipe; // Channel/feature that created the item
|
||||
QString m_name;
|
||||
QString m_label;
|
||||
float m_latitude;
|
||||
@ -127,7 +126,7 @@ public:
|
||||
void playAnimations(MapItem *item);
|
||||
|
||||
Q_INVOKABLE void add(MapItem *item);
|
||||
void update(const PipeEndPoint *source, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group="");
|
||||
void update(const QObject *source, SWGSDRangel::SWGMapItem *swgMapItem, const QString &group="");
|
||||
void update(MapItem *item);
|
||||
void remove(MapItem *item);
|
||||
void allUpdated();
|
||||
@ -141,7 +140,7 @@ public:
|
||||
Q_INVOKABLE void moveToFront(int oldRow);
|
||||
Q_INVOKABLE void moveToBack(int oldRow);
|
||||
|
||||
MapItem *findMapItem(const PipeEndPoint *source, const QString& name);
|
||||
MapItem *findMapItem(const QObject *source, const QString& name);
|
||||
MapItem *findMapItem(const QString& name);
|
||||
QModelIndex findMapItemIndex(const QString& name);
|
||||
|
||||
|
@ -51,6 +51,26 @@ struct MapSettings
|
||||
bool deserialize(const QByteArray& data);
|
||||
};
|
||||
|
||||
struct AvailableChannelOrFeature
|
||||
{
|
||||
QString m_kind; //!< "R" for channel, "F" for feature
|
||||
int m_superIndex;
|
||||
int m_index;
|
||||
QString m_type;
|
||||
QObject *m_source;
|
||||
|
||||
AvailableChannelOrFeature() = default;
|
||||
AvailableChannelOrFeature(const AvailableChannelOrFeature&) = default;
|
||||
AvailableChannelOrFeature& operator=(const AvailableChannelOrFeature&) = default;
|
||||
bool operator==(const AvailableChannelOrFeature& a) const {
|
||||
return (m_kind == a.m_kind)
|
||||
&& (m_superIndex == a.m_superIndex)
|
||||
&& (m_index == a.m_index)
|
||||
&& (m_type == a.m_type)
|
||||
&& (m_source == a.m_source);
|
||||
}
|
||||
};
|
||||
|
||||
bool m_displayNames;
|
||||
QString m_mapProvider;
|
||||
QString m_thunderforestAPIKey;
|
||||
|
@ -353,46 +353,44 @@ void RadiosondeGUI::sendToMap(const QString &name, const QString &label,
|
||||
float heading
|
||||
)
|
||||
{
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_radiosonde, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
QList<ObjectPipe*> mapPipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_radiosonde, "mapitems", mapPipes);
|
||||
|
||||
for (const auto& pipe : mapPipes)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setLatitude(latitude);
|
||||
swgMapItem->setLongitude(longitude);
|
||||
swgMapItem->setAltitude(altitude);
|
||||
swgMapItem->setAltitudeReference(0); // ABSOLUTE
|
||||
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
{
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setLatitude(latitude);
|
||||
swgMapItem->setLongitude(longitude);
|
||||
swgMapItem->setAltitude(altitude);
|
||||
swgMapItem->setAltitudeReference(0); // ABSOLUTE
|
||||
|
||||
if (positionDateTime.isValid()) {
|
||||
swgMapItem->setPositionDateTime(new QString(positionDateTime.toString(Qt::ISODateWithMs)));
|
||||
}
|
||||
|
||||
swgMapItem->setImageRotation(heading);
|
||||
swgMapItem->setText(new QString(text));
|
||||
|
||||
if (image.isEmpty()) {
|
||||
swgMapItem->setImage(new QString(""));
|
||||
} else {
|
||||
swgMapItem->setImage(new QString(QString("qrc:///radiosonde/map/%1").arg(image)));
|
||||
}
|
||||
swgMapItem->setModel(new QString(model));
|
||||
swgMapItem->setModelAltitudeOffset(0.0f);
|
||||
swgMapItem->setLabel(new QString(label));
|
||||
swgMapItem->setLabelAltitudeOffset(labelOffset);
|
||||
swgMapItem->setFixedPosition(false);
|
||||
swgMapItem->setOrientation(1);
|
||||
swgMapItem->setHeading(heading);
|
||||
swgMapItem->setPitch(0.0);
|
||||
swgMapItem->setRoll(0.0);
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_radiosonde, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
if (positionDateTime.isValid()) {
|
||||
swgMapItem->setPositionDateTime(new QString(positionDateTime.toString(Qt::ISODateWithMs)));
|
||||
}
|
||||
|
||||
swgMapItem->setImageRotation(heading);
|
||||
swgMapItem->setText(new QString(text));
|
||||
|
||||
if (image.isEmpty()) {
|
||||
swgMapItem->setImage(new QString(""));
|
||||
} else {
|
||||
swgMapItem->setImage(new QString(QString("qrc:///radiosonde/map/%1").arg(image)));
|
||||
}
|
||||
|
||||
swgMapItem->setModel(new QString(model));
|
||||
swgMapItem->setModelAltitudeOffset(0.0f);
|
||||
swgMapItem->setLabel(new QString(label));
|
||||
swgMapItem->setLabelAltitudeOffset(labelOffset);
|
||||
swgMapItem->setFixedPosition(false);
|
||||
swgMapItem->setOrientation(1);
|
||||
swgMapItem->setHeading(heading);
|
||||
swgMapItem->setPitch(0.0);
|
||||
swgMapItem->setRoll(0.0);
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_radiosonde, swgMapItem);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,25 +234,34 @@ void SatelliteTrackerWorker::applySettings(const SatelliteTrackerSettings& setti
|
||||
|
||||
void SatelliteTrackerWorker::removeFromMap(QString id)
|
||||
{
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_satelliteTracker, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
sendToMap(mapMessageQueues, id, "", "", "", 0.0f, 0.0, 0.0, 0.0, 0.0, nullptr, nullptr, nullptr, nullptr);
|
||||
QList<ObjectPipe*> mapMessagePipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_satelliteTracker, "mapitems", mapMessagePipes);
|
||||
|
||||
if (mapMessagePipes.size() > 0) {
|
||||
sendToMap(mapMessagePipes, id, "", "", "", 0.0f, 0.0, 0.0, 0.0, 0.0, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void SatelliteTrackerWorker::sendToMap(QList<MessageQueue*> *mapMessageQueues,
|
||||
QString name, QString image, QString model, QString text,
|
||||
float labelOffset,
|
||||
double lat, double lon, double altitude, double rotation,
|
||||
QList<QGeoCoordinate *> *track,
|
||||
QList<QDateTime *> *trackDateTime,
|
||||
QList<QGeoCoordinate *> *predictedTrack,
|
||||
QList<QDateTime *> *predictedTrackDateTime)
|
||||
void SatelliteTrackerWorker::sendToMap(
|
||||
const QList<ObjectPipe*>& mapMessagePipes,
|
||||
QString name,
|
||||
QString image,
|
||||
QString model,
|
||||
QString text,
|
||||
float labelOffset,
|
||||
double lat,
|
||||
double lon,
|
||||
double altitude,
|
||||
double rotation,
|
||||
QList<QGeoCoordinate *> *track,
|
||||
QList<QDateTime *> *trackDateTime,
|
||||
QList<QGeoCoordinate *> *predictedTrack,
|
||||
QList<QDateTime *> *predictedTrackDateTime
|
||||
)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
for (const auto& pipe : mapMessagePipes)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setLatitude(lat);
|
||||
@ -298,7 +307,7 @@ void SatelliteTrackerWorker::sendToMap(QList<MessageQueue*> *mapMessageQueues,
|
||||
}
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_satelliteTracker, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,9 +432,10 @@ void SatelliteTrackerWorker::update()
|
||||
// Send to Map
|
||||
if (m_settings.m_drawOnMap)
|
||||
{
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_satelliteTracker, "mapitems");
|
||||
if (mapMessageQueues)
|
||||
QList<ObjectPipe*> mapMessagePipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_satelliteTracker, "mapitems", mapMessagePipes);
|
||||
|
||||
if (mapMessagePipes.size() > 0)
|
||||
{
|
||||
const QStringList cubeSats({"AISAT-1", "FOX-1B", "FOX-1C", "FOX-1D", "FOX-1E", "FUNCUBE-1", "NO-84"});
|
||||
QString image;
|
||||
@ -484,11 +494,18 @@ void SatelliteTrackerWorker::update()
|
||||
.arg(QChar(0xb0));
|
||||
}
|
||||
|
||||
sendToMap(mapMessageQueues, sat->m_name, image, model, text, labelOffset,
|
||||
satWorkerState->m_satState.m_latitude, satWorkerState->m_satState.m_longitude,
|
||||
satWorkerState->m_satState.m_altitude * 1000.0, 0,
|
||||
&satWorkerState->m_satState.m_groundTrack, &satWorkerState->m_satState.m_groundTrackDateTime,
|
||||
&satWorkerState->m_satState.m_predictedGroundTrack, &satWorkerState->m_satState.m_predictedGroundTrackDateTime);
|
||||
sendToMap(
|
||||
mapMessagePipes,
|
||||
sat->m_name,
|
||||
image,
|
||||
model,
|
||||
text,
|
||||
labelOffset,
|
||||
satWorkerState->m_satState.m_latitude, satWorkerState->m_satState.m_longitude,
|
||||
satWorkerState->m_satState.m_altitude * 1000.0, 0,
|
||||
&satWorkerState->m_satState.m_groundTrack, &satWorkerState->m_satState.m_groundTrackDateTime,
|
||||
&satWorkerState->m_satState.m_predictedGroundTrack, &satWorkerState->m_satState.m_predictedGroundTrackDateTime
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ class SatelliteTracker;
|
||||
class SatelliteTrackerWorker;
|
||||
class QDateTime;
|
||||
class QGeoCoordinate;
|
||||
class ObjectPipe;
|
||||
|
||||
class SatWorkerState
|
||||
{
|
||||
@ -122,13 +123,22 @@ private:
|
||||
void applySettings(const SatelliteTrackerSettings& settings, bool force = false);
|
||||
MessageQueue *getMessageQueueToGUI() { return m_msgQueueToGUI; }
|
||||
void removeFromMap(QString id);
|
||||
void sendToMap(QList<MessageQueue*> *mapMessageQueues, QString id, QString image, QString model, QString text,
|
||||
float labelOffset,
|
||||
double lat, double lon, double altitude, double rotation,
|
||||
QList<QGeoCoordinate *> *track = nullptr,
|
||||
QList<QDateTime *> *trackDateTime = nullptr,
|
||||
QList<QGeoCoordinate *> *predictedTrack = nullptr,
|
||||
QList<QDateTime *> *predictedTrackDateTime = nullptr);
|
||||
void sendToMap(
|
||||
const QList<ObjectPipe*>& mapMessagePipes,
|
||||
QString id,
|
||||
QString image,
|
||||
QString model,
|
||||
QString text,
|
||||
float labelOffset,
|
||||
double lat,
|
||||
double lon,
|
||||
double altitude,
|
||||
double rotation,
|
||||
QList<QGeoCoordinate *> *track = nullptr,
|
||||
QList<QDateTime *> *trackDateTime = nullptr,
|
||||
QList<QGeoCoordinate *> *predictedTrack = nullptr,
|
||||
QList<QDateTime *> *predictedTrackDateTime = nullptr
|
||||
);
|
||||
void applyDeviceAOSSettings(const QString& name);
|
||||
void startStopSinks(bool start);
|
||||
void calculateRotation(SatWorkerState *satWorkerState);
|
||||
|
@ -407,19 +407,27 @@ void StarTrackerWorker::updateRaDec(RADec rd, QDateTime dt, bool lbTarget)
|
||||
|
||||
void StarTrackerWorker::removeFromMap(QString id)
|
||||
{
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*> *mapMessageQueues = messagePipes.getMessageQueues(m_starTracker, "mapitems");
|
||||
if (mapMessageQueues) {
|
||||
sendToMap(mapMessageQueues, id, "", "", 0.0, 0.0);
|
||||
QList<ObjectPipe*> mapMessagePipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_starTracker, "mapitems", mapMessagePipes);
|
||||
|
||||
if (mapMessagePipes.size() > 0) {
|
||||
sendToMap(mapMessagePipes, id, "", "", 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
void StarTrackerWorker::sendToMap(QList<MessageQueue*> *mapMessageQueues, QString name, QString image, QString text, double lat, double lon, double rotation)
|
||||
void StarTrackerWorker::sendToMap(
|
||||
const QList<ObjectPipe*>& mapMessagePipes,
|
||||
QString name,
|
||||
QString image,
|
||||
QString text,
|
||||
double lat,
|
||||
double lon,
|
||||
double rotation
|
||||
)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = mapMessageQueues->begin();
|
||||
|
||||
for (; it != mapMessageQueues->end(); ++it)
|
||||
for (const auto& pipe : mapMessagePipes)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
SWGSDRangel::SWGMapItem *swgMapItem = new SWGSDRangel::SWGMapItem();
|
||||
swgMapItem->setName(new QString(name));
|
||||
swgMapItem->setLatitude(lat);
|
||||
@ -429,7 +437,7 @@ void StarTrackerWorker::sendToMap(QList<MessageQueue*> *mapMessageQueues, QStrin
|
||||
swgMapItem->setText(new QString(text));
|
||||
|
||||
MainCore::MsgMapItem *msg = MainCore::MsgMapItem::create(m_starTracker, swgMapItem);
|
||||
(*it)->push(msg);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,11 +644,10 @@ void StarTrackerWorker::update()
|
||||
// Send to Map
|
||||
if (m_settings.m_drawSunOnMap || m_settings.m_drawMoonOnMap || m_settings.m_drawStarOnMap)
|
||||
{
|
||||
MessagePipesLegacy& messagePipes = MainCore::instance()->getMessagePipesLegacy();
|
||||
QList<MessageQueue*>* messageQueues;
|
||||
messageQueues = messagePipes.getMessageQueues(m_starTracker, "mapitems");
|
||||
QList<ObjectPipe*> mapMessagePipes;
|
||||
MainCore::instance()->getMessagePipes().getMessagePipes(m_starTracker, "mapitems", mapMessagePipes);
|
||||
|
||||
if (messageQueues)
|
||||
if (mapMessagePipes.size() > 0)
|
||||
{
|
||||
// Different between GMST(Lst at Greenwich) and RA
|
||||
double lst = Astronomy::localSiderealTime(dt, 0.0);
|
||||
@ -651,7 +658,7 @@ void StarTrackerWorker::update()
|
||||
{
|
||||
sunLongitude = Astronomy::lstAndRAToLongitude(lst, sunRD.ra);
|
||||
sunLatitude = sunRD.dec;
|
||||
sendToMap(messageQueues, "Sun", "qrc:///startracker/startracker/sun-40.png", "Sun", sunLatitude, sunLongitude);
|
||||
sendToMap(mapMessagePipes, "Sun", "qrc:///startracker/startracker/sun-40.png", "Sun", sunLatitude, sunLongitude);
|
||||
}
|
||||
if (m_settings.m_drawMoonOnMap)
|
||||
{
|
||||
@ -659,7 +666,7 @@ void StarTrackerWorker::update()
|
||||
double moonLatitude = moonRD.dec;
|
||||
double moonRotation;
|
||||
QString phase = moonPhase(sunLongitude, moonLongitude, m_settings.m_latitude, moonRotation);
|
||||
sendToMap(messageQueues, "Moon", QString("qrc:///startracker/startracker/moon-%1-32").arg(phase), "Moon",
|
||||
sendToMap(mapMessagePipes, "Moon", QString("qrc:///startracker/startracker/moon-%1-32").arg(phase), "Moon",
|
||||
moonLatitude, moonLongitude, moonRotation);
|
||||
}
|
||||
if ((m_settings.m_drawStarOnMap) && (m_settings.m_target != "Sun") && (m_settings.m_target != "Moon"))
|
||||
@ -667,7 +674,7 @@ void StarTrackerWorker::update()
|
||||
double starLongitude = Astronomy::lstAndRAToLongitude(lst, rd.ra);
|
||||
double starLatitude = rd.dec;
|
||||
QString text = m_settings.m_target.startsWith("Custom") ? "Star" : m_settings.m_target;
|
||||
sendToMap(messageQueues, "Star", "qrc:///startracker/startracker/pulsar-32.png", text, starLatitude, starLongitude);
|
||||
sendToMap(mapMessagePipes, "Star", "qrc:///startracker/startracker/pulsar-32.png", text, starLatitude, starLongitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class QTcpServer;
|
||||
class QTcpSocket;
|
||||
class StarTracker;
|
||||
class QDateTime;
|
||||
class ObjectPipe;
|
||||
|
||||
class StarTrackerWorker : public QObject
|
||||
{
|
||||
@ -94,7 +95,15 @@ private:
|
||||
void updateRaDec(RADec rd, QDateTime dt, bool lbTarget);
|
||||
void writeStellariumTarget(double ra, double dec);
|
||||
void removeFromMap(QString id);
|
||||
void sendToMap(QList<MessageQueue*> *mapMessageQueues, QString id, QString image, QString text, double lat, double lon, double rotation=0.0);
|
||||
void sendToMap(
|
||||
const QList<ObjectPipe*>& mapMessagePipes,
|
||||
QString id,
|
||||
QString image,
|
||||
QString text,
|
||||
double lat,
|
||||
double lon,
|
||||
double rotation = 0.0
|
||||
);
|
||||
|
||||
private slots:
|
||||
void started();
|
||||
|
@ -553,19 +553,19 @@ public:
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const PipeEndPoint *getPipeSource() const { return m_pipeSource; }
|
||||
const QObject *getPipeSource() const { return m_pipeSource; }
|
||||
SWGSDRangel::SWGMapItem *getSWGMapItem() const { return m_swgMapItem; }
|
||||
|
||||
static MsgMapItem* create(const PipeEndPoint *pipeSource, SWGSDRangel::SWGMapItem *swgMapItem)
|
||||
static MsgMapItem* create(const QObject *pipeSource, SWGSDRangel::SWGMapItem *swgMapItem)
|
||||
{
|
||||
return new MsgMapItem(pipeSource, swgMapItem);
|
||||
}
|
||||
|
||||
private:
|
||||
const PipeEndPoint *m_pipeSource;
|
||||
const QObject *m_pipeSource;
|
||||
SWGSDRangel::SWGMapItem *m_swgMapItem;
|
||||
|
||||
MsgMapItem(const PipeEndPoint *pipeSource, SWGSDRangel::SWGMapItem *swgMapItem) :
|
||||
MsgMapItem(const QObject *pipeSource, SWGSDRangel::SWGMapItem *swgMapItem) :
|
||||
Message(),
|
||||
m_pipeSource(pipeSource),
|
||||
m_swgMapItem(swgMapItem)
|
||||
|
Loading…
Reference in New Issue
Block a user