Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network freq udp #456

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions core/NetworkNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ void NetworkNotification::saveNotifSpotAlertAddrs(const QString &addresses)

}

QString NetworkNotification::getNotifFreqAlertAddrs()
{
FCT_IDENTIFICATION;

QSettings settings;

return settings.value(NetworkNotification::CONFIG_NOTIF_FREQ_ADDRS_KEY).toString();
}

void NetworkNotification::saveNotifFreqAlertAddrs(const QString &addresses)
{
FCT_IDENTIFICATION;

QSettings settings;

settings.setValue(NetworkNotification::CONFIG_NOTIF_FREQ_ADDRS_KEY, addresses);

}

void NetworkNotification::QSOInserted(const QSqlRecord &record)
{
FCT_IDENTIFICATION;
Expand Down Expand Up @@ -240,6 +259,7 @@ QString NetworkNotification::CONFIG_NOTIF_QSO_ADI_ADDRS_KEY = "network/notificat
QString NetworkNotification::CONFIG_NOTIF_DXSPOT_ADDRS_KEY = "network/notification/dxspot/addrs";
QString NetworkNotification::CONFIG_NOTIF_WSJTXCQSPOT_ADDRS_KEY = "network/notification/wsjtx/cqspot/addrs";
QString NetworkNotification::CONFIG_NOTIF_SPOTALERT_ADDRS_KEY = "network/notification/alerts/spot/addrs";
QString NetworkNotification::CONFIG_NOTIF_FREQ_ADDRS_KEY = "network/notification/alerts/freq/addrs";

GenericNotificationMsg::GenericNotificationMsg(QObject *parent) :
QObject(parent)
Expand Down Expand Up @@ -469,3 +489,30 @@ ToAllSpotNotificationMsg::ToAllSpotNotificationMsg(const ToAllSpot &spot, QObjec
msg["msgtype"] = "toallspot";
msg["data"] = spotData;
}

void NetworkNotification::updateFrequency(VFOID, double vfoFreq, double ritFreq, double xitFreq)
{
FCT_IDENTIFICATION;

qCDebug(function_parameters) << vfoFreq << ritFreq << xitFreq;

HostsPortString destList(getNotifFreqAlertAddrs());

if ( destList.getAddrList().size() > 0 )
{
FreqNotificationMsg freqAlertMsg(vfoFreq);
send(freqAlertMsg.getJson(), destList);
}
}

FreqNotificationMsg::FreqNotificationMsg(const double &vfo_freq, QObject *parent) :
GenericNotificationMsg(parent)
{
FCT_IDENTIFICATION;

QJsonObject freqData;
freqData["Frequency"] = vfo_freq;

msg["msgtype"] = "freq";
msg["data"] = freqData;
}
13 changes: 13 additions & 0 deletions core/NetworkNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "data/WCYSpot.h"
#include "data/WWVSpot.h"
#include "data/ToAllSpot.h"
#include "rig/rig.h"

class GenericNotificationMsg : public QObject
{
Expand Down Expand Up @@ -116,6 +117,14 @@ class ToAllSpotNotificationMsg : public GenericNotificationMsg

};

class FreqNotificationMsg : public GenericNotificationMsg
{

public:
explicit FreqNotificationMsg(const double&, QObject *parent = nullptr);

};

class NetworkNotification : public QObject
{
Q_OBJECT
Expand All @@ -130,6 +139,8 @@ class NetworkNotification : public QObject
static void saveNotifWSJTXCQSpotAddrs(const QString &);
static QString getNotifSpotAlertAddrs();
static void saveNotifSpotAlertAddrs(const QString &);
static QString getNotifFreqAlertAddrs();
static void saveNotifFreqAlertAddrs(const QString &);

public slots:
void QSOInserted(const QSqlRecord &);
Expand All @@ -141,6 +152,7 @@ public slots:
void toAllSpot(const ToAllSpot&);
void WSJTXCQSpot(const WsjtxEntry&);
void spotAlert(const SpotAlert&);
void updateFrequency(VFOID, double, double, double);

private:

Expand All @@ -150,6 +162,7 @@ public slots:
static QString CONFIG_NOTIF_DXSPOT_ADDRS_KEY;
static QString CONFIG_NOTIF_WSJTXCQSPOT_ADDRS_KEY;
static QString CONFIG_NOTIF_SPOTALERT_ADDRS_KEY;
static QString CONFIG_NOTIF_FREQ_ADDRS_KEY;

};

Expand Down
1 change: 1 addition & 0 deletions ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ MainWindow::MainWindow(QWidget* parent) :
connect(Rig::instance(), &Rig::frequencyChanged, ui->onlineMapWidget, &OnlineMapWidget::setIBPBand);
connect(Rig::instance(), &Rig::frequencyChanged, ui->bandmapWidget , &BandmapWidget::updateTunedFrequency);
connect(Rig::instance(), &Rig::modeChanged, ui->bandmapWidget, &BandmapWidget::updateMode);
connect(Rig::instance(), &Rig::frequencyChanged, &networknotification, &NetworkNotification::updateFrequency);

connect(Rotator::instance(), &Rotator::rotErrorPresent, this, &MainWindow::rotErrorHandler);
connect(Rotator::instance(), &Rotator::positionChanged, ui->onlineMapWidget, &OnlineMapWidget::antPositionChanged);
Expand Down
2 changes: 2 additions & 0 deletions ui/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,7 @@ void SettingsDialog::readSettings() {
ui->notifDXSpotsEdit->setText(NetworkNotification::getNotifDXSpotAddrs());
ui->notifWSJTXCQSpotsEdit->setText(NetworkNotification::getNotifWSJTXCQSpotAddrs());
ui->notifSpotAlertEdit->setText(NetworkNotification::getNotifSpotAlertAddrs());
ui->notifFreqEdit->setText(NetworkNotification::getNotifFreqAlertAddrs());

/******************/
/* END OF Reading */
Expand Down Expand Up @@ -2430,6 +2431,7 @@ void SettingsDialog::writeSettings() {
NetworkNotification::saveNotifDXSpotAddrs(ui->notifDXSpotsEdit->text());
NetworkNotification::saveNotifWSJTXCQSpotAddrs(ui->notifWSJTXCQSpotsEdit->text());
NetworkNotification::saveNotifSpotAlertAddrs(ui->notifSpotAlertEdit->text());
NetworkNotification::saveNotifFreqAlertAddrs(ui->notifFreqEdit->text());
}

/* this function is called when user modify rig progile
Expand Down
Loading
Loading