Fix cluster spots

creator-widgets
Phil Taylor 2024-01-28 13:14:47 +00:00
rodzic d25dc81d66
commit c9c129ffe3
7 zmienionych plików z 43 dodań i 44 usunięć

Wyświetl plik

@ -263,9 +263,10 @@ void dxClusterClient::tcpDisconnected() {
// Need to start a timer and attempt reconnect.
}
void dxClusterClient::freqRange(bool sub, double low, double high)
void dxClusterClient::freqRange(uchar vfo, double low, double high)
{
if (sub) {
freqRanges[vfo] = {low,high};
if (vfo) {
lowSubFreq = low;
highSubFreq = high;
} else {
@ -293,47 +294,28 @@ void dxClusterClient::updateSpots()
spots.append(s);
}
#else
QMap<QString, spotData*>::iterator mainSpot = allSpots.begin();;
while (mainSpot != allSpots.end()) {
if (mainSpot.value()->frequency > lowMainFreq && mainSpot.value()->frequency < highMainFreq)
QMap<uchar, rangeValues>::iterator range = freqRanges.begin();
while (range != freqRanges.end())
{
spots.clear();
QMap<QString, spotData*>::iterator mainSpot = allSpots.begin();
while (mainSpot != allSpots.end())
{
spots.append(**mainSpot);
if (mainSpot.value()->frequency >= range->low && mainSpot.value()->frequency <= range->high)
{
spots.append(**mainSpot);
}
++mainSpot;
}
++mainSpot;
if (!spots.empty()) {
emit sendSpots(range.key(),spots);
//qInfo(logCluster()) << "Sending" << spots.size() << "DX spots to vfo" << range.key();
}
++range;
}
#endif
if (!spots.empty())
emit sendMainSpots(spots);
spots.clear();
#ifdef USESQL
// Set the required frequency range.
QString queryText = QString("SELECT * FROM spots WHERE frequency > %1 AND frequency < %2").arg(lowFreq).arg(highFreq);
//QString queryText = QString("SELECT * FROM spots");
database db;
auto query = db.query(queryText);
while (query.next()) {
// Step through all current spots within range
spotData s = spotData();
s.dxcall = query.value(query.record().indexOf("dxcall")).toString();
s.frequency = query.value(query.record().indexOf("frequency")).toDouble();
spots.append(s);
}
#else
QMap<QString, spotData*>::iterator subSpot = allSpots.begin();;
while (subSpot != allSpots.end()) {
if (subSpot.value()->frequency > lowSubFreq && subSpot.value()->frequency < highSubFreq)
{
spots.append(**subSpot);
}
++subSpot;
}
#endif
if (!spots.empty())
emit sendSubSpots(spots);
}
void dxClusterClient::enableSkimmerSpots(bool enable)

Wyświetl plik

@ -43,6 +43,13 @@ struct clusterSettings {
bool isdefault;
};
struct rangeValues {
rangeValues() {};
rangeValues(double low, double high): low(low), high(high) {};
double low;
double high;
};
class dxClusterClient : public QObject
{
Q_OBJECT
@ -56,7 +63,7 @@ signals:
void deleteSpot(QString dxcall);
void deleteOldSpots(int minutes);
void sendOutput(QString text);
void sendMainSpots(QList<spotData> spots);
void sendSpots(uchar vfo, QList<spotData> spots);
void sendSubSpots(QList<spotData> spots);
public slots:
@ -72,7 +79,7 @@ public slots:
void setTcpPassword(QString s) { tcpPassword = s; }
void setTcpTimeout(int p) { tcpTimeout = p; }
void tcpCleanup();
void freqRange(bool sub, double low, double high);
void freqRange(uchar vfo, double low, double high);
void enableSkimmerSpots(bool enable);
private:
@ -102,6 +109,7 @@ private:
double highMainFreq;
double lowSubFreq;
double highSubFreq;
QMap<uchar,rangeValues> freqRanges;
QMap<QString,spotData*> allSpots;
bool skimmerSpots = false;
};

Wyświetl plik

@ -71,6 +71,12 @@ void loggingWindow::acceptLogText(QPair<QtMsgType,QString> text)
} else if (text.first == QtCriticalMsg || text.first == QtFatalMsg)
{
colour = "red";
} else if (text.first == QtInfoMsg) {
colour = "white";
}
else
{
colour = "green";
}
ui->logTextDisplay->appendHtml(QString("<p><span style='color:%0'>%1</span></p>").arg(colour).arg(text.second));
if(vertLogScroll->value() == vertLogScroll->maximum())

Wyświetl plik

@ -1423,7 +1423,7 @@ void rigCommander::determineRigCaps()
for (int c = 0; c < numAttenuators; c++)
{
settings->setArrayIndex(c);
qInfo(logRig()) << "** GOT ATTENUATOR" << settings->value("dB", 0).toString().toUInt();
//qInfo(logRig()) << "** GOT ATTENUATOR" << settings->value("dB", 0).toString().toUInt();
rigCaps.attenuators.push_back((unsigned char)settings->value("dB", 0).toString().toUInt());
}
settings->endArray();

Wyświetl plik

@ -1533,8 +1533,11 @@ void spectrumScope::setSpeed(uchar s)
}
void spectrumScope::receiveSpots(QList<spotData> spots)
void spectrumScope::receiveSpots(uchar vfo, QList<spotData> spots)
{
if (vfo != this->vfo) {
return;
}
//QElapsedTimer timer;
//timer.start();
bool current = false;
@ -1620,7 +1623,6 @@ void spectrumScope::receiveSpots(QList<spotData> spots)
}
//qDebug(logCluster()) << "Processing took" << timer.nsecsElapsed() / 1000 << "us";
}
void spectrumScope::configPressed()

Wyświetl plik

@ -100,7 +100,7 @@ public:
public slots: // Can be called directly or updated via signal/slot
void selectScopeMode(spectrumMode_t m);
void selectSpan(centerSpanData s);
void receiveSpots(QList<spotData> spots);
void receiveSpots(uchar vfo, QList<spotData> spots);
signals:
void frequencyRange(uchar vfo, double start, double end);

Wyświetl plik

@ -1003,7 +1003,8 @@ void wfmain::configureVFOs()
ui->vfoLayout->addWidget(vfos.last());
connect(vfos.last(), SIGNAL(frequencyRange(uchar, double, double)), cluster, SLOT(freqRange(uchar, double, double)));
connect(cluster, SIGNAL(sendMainSpots(QList<spotData>)), vfos.last(), SLOT(receiveSpots(QList<spotData>)));
connect(cluster, SIGNAL(sendSpots(uchar, QList<spotData>)), vfos.last(), SLOT(receiveSpots(uchar, QList<spotData>)));
connect(cluster, SIGNAL(sendOutput(QString)), this, SLOT(receiveClusterOutput(QString)));
connect(vfos.last(), SIGNAL(updateSettings(uchar,int,quint16,int,int)), this, SLOT(receiveScopeSettings(uchar,int,quint16,int,int)));