summaryrefslogtreecommitdiff
path: root/map65/mainwindow.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
commit69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch)
treeebc98370a697a9bbd6b973a14fa5113c475c6db7 /map65/mainwindow.cpp
parent3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff)
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg' with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'map65/mainwindow.cpp')
-rw-r--r--map65/mainwindow.cpp489
1 files changed, 342 insertions, 147 deletions
diff --git a/map65/mainwindow.cpp b/map65/mainwindow.cpp
index 7a47d5b6..3cb1e760 100644
--- a/map65/mainwindow.cpp
+++ b/map65/mainwindow.cpp
@@ -30,6 +30,7 @@
#include <QApplication>
#include <QDebug>
#include <QDateTime>
+#include <QTime>
#include <QFile>
#include <QTextStream>
#include <QString>
@@ -47,6 +48,8 @@
#include "stdout_channel.h"
#include "fortran_mutex.hpp"
+#include "pskreporter_settings.h"
+#include "runtime_paths.h"
#if !defined(Q_OS_WIN)
extern "C" {
@@ -66,51 +69,13 @@ extern "C" void ptt_close(void);
#undef MessageBox
#endif
-#define NFFT 32768
-
-
QByteArray g_TxTuneGeometry;
-namespace {
-struct Map65TxWaveStorage { short int samples[2*60*12000]; };
-struct Map65RxSamplesStorage { qint16 samples[4*60*96000]; };
-
-QString writableMap65DataDir()
-{
- QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
- if (dataDir.isEmpty()) {
- dataDir = QDir::home().absoluteFilePath(".map65");
- }
-
- if (!QDir{}.mkpath(dataDir)) {
- qWarning() << "Unable to create MAP65 data directory:" << dataDir;
- }
-
- QDir dir {dataDir};
- if (!dir.mkpath("save")) {
- qWarning() << "Unable to create MAP65 save directory:" << dir.absoluteFilePath("save");
- }
- return dataDir;
-}
-
-QString map65SettingsFile(QString const& appDir, QString const& dataDir)
-{
- QString settingsFile = QDir {dataDir}.absoluteFilePath("map65.ini");
- QString legacySettingsFile = QDir {appDir}.absoluteFilePath("map65.ini");
- if (!QFile::exists(settingsFile) && QFile::exists(legacySettingsFile)) {
- if (QFile::copy(legacySettingsFile, settingsFile)) {
- QFile::setPermissions(settingsFile, QFile::ReadOwner | QFile::WriteOwner
- | QFile::ReadGroup | QFile::ReadOther);
- } else {
- qWarning() << "Unable to migrate MAP65 settings from" << legacySettingsFile
- << "to" << settingsFile;
- }
- }
- return settingsFile;
-}
-} // namespace
+int g_sampleRate = 96000;
+int active_nfft;
+std::vector<qint16> id;
-short int (&iwave)[2*60*12000] = (new Map65TxWaveStorage{})->samples; //Wave file for Tx audio
+short int iwave[2*60*12000]; //Wave file for Tx audio
int nwave; //Length of Tx waveform
bool btxok; //True if OK to transmit
bool bTune;
@@ -119,14 +84,10 @@ double outputLatency; //Latency in seconds
int txPower;
int iqAmp;
int iqPhase;
-qint16 (&id)[4*60*96000] = (new Map65RxSamplesStorage{})->samples;
int pipefd[2]; // pipefd[0] = read end, pipefd[1] = write end
TxTune* g_pTxTune = NULL;
-extern const int RxDataFrequency = 96000;
-extern const int TxDataFrequency = 11025;
-
std::atomic<bool> stop_m65{false};
QString guiDate; //liveCQ
@@ -134,8 +95,6 @@ QStringList allDecodes; //liveCQ
QStringList allDecodes2; //liveCQ
QString m_otherUrl;
bool m_w3szUrl;
-bool m_spot_to_psk_reporter;
-bool m_psk_reporter_tcpip;
struct MainWindow::DecoderContext
{
@@ -149,7 +108,7 @@ MainWindow::DecoderContext::DecoderContext()
stdoutChan = new StdoutChannel(
L"MAP65_STDOUT_MAPPING",
L"MAP65_STDOUT_EVENT",
- 64 * 1024
+ 1024 * 1024
);
}
@@ -158,12 +117,43 @@ MainWindow::DecoderContext::~DecoderContext()
delete stdoutChan;
}
+// TEMP diagnostic 2026-09-10 for the "decode reaches map65_rx.log but not the
+// Messages window, only on the first decode cycle after MAP65 starts" report.
+// Writes to its own separate log file rather than the shared w3sz_debug.log
+// Fortran's dbg() uses -- the two processes/threads have no lock between
+// them, and sharing a file produces torn, interleaved lines. Timestamps use
+// the same sec_midn()-style local h*3600+m*60+s+ms/1000 format as the
+// Fortran log, so the two can still be correlated by eye. Strip both files'
+// worth of logging before merge.
+//
+// Mirrors run_m65.f90's dbg_enabled flag -- flip to true to re-enable this
+// log without touching any of the cppDbg(...) call sites scattered through
+// this file.
+static bool const cppDbgEnabled = false;
+
+static void cppDbg(const QString &msg)
+{
+ if (!cppDbgEnabled) return;
+ double const t = [] {
+ QTime const now = QTime::currentTime();
+ return now.hour() * 3600.0 + now.minute() * 60.0 + now.second() + now.msec() / 1000.0;
+ }();
+ QFile f("w3sz_debug_cpp.log");
+ if (f.open(QIODevice::Append | QIODevice::Text)) {
+ QTextStream out(&f);
+ out << "mainwindow: " << msg << " at t=" << QString::number(t, 'f', 3) << "\n";
+ }
+}
+
//-------------------------------------------------- MainWindow constructor
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_appDir {QApplication::applicationDirPath ()},
+ m_installedDataDir {installed_data_directory ().absolutePath ()},
m_dataDir {writableMap65DataDir ()},
+ m_eclipseFile {map65RuntimeSourceFile (m_appDir, m_installedDataDir, m_dataDir,
+ "eclipse.txt")},
m_settings_filename {map65SettingsFile (m_appDir, m_dataDir)},
m_astro_window {new Astro {m_settings_filename}},
m_band_map_window {new BandMap {m_settings_filename}},
@@ -171,13 +161,15 @@ MainWindow::MainWindow(QWidget *parent) :
m_wide_graph_window {new WideGraph {m_settings_filename}},
m_gui_timer {new QTimer {this}}
{
- qDebug() << "IN MainWindow Constructor NFFT IS: " << NFFT;
- // Legacy C++ and Fortran paths still use relative opens for runtime files.
+ qDebug() << "IN MainWindow Constructor active_nfft IS: " << active_nfft;
if (!QDir::setCurrent(m_dataDir)) {
qWarning() << "Unable to set MAP65 working directory:" << m_dataDir;
}
+ QByteArray dataDirBytes = m_dataDir.toLocal8Bit();
+ set_wsjtx_dir_(dataDirBytes.constData(), dataDirBytes.size());
+ ensureMap65RuntimeFile(m_appDir, m_installedDataDir, m_dataDir, "CALL3.TXT");
constexpr int baseSeconds = 56;
- constexpr int sampleRate = 96000;
+ const int sampleRate = g_sampleRate;
constexpr int channels = 4; // dd(1..4, t)
decoderCtx = new DecoderContext();
@@ -192,17 +184,28 @@ MainWindow::MainWindow(QWidget *parent) :
// Tell Fortran about the maximum shape (channels × pairsWorst)
set_dd_ptr(dd, channels, pairsWorst);
+ qDebug() << "g_sampleRate:" << g_sampleRate
+ << "sampleRate:" << sampleRate
+ << "id.size():" << id.size()
+ << "bytes:" << id.size() * sizeof(id[0]);
+
std::cout << "dd pointer set to: " << dd
<< " size: " << ddSize
<< " (channels=" << channels
<< ", pairsWorst=" << pairsWorst << ")\n";
- ss = new float[4 * 322 * NFFT];
- savg = new float[4 * NFFT];
- set_ss_ptr(ss, 4, 322, NFFT);
+ ss = new float[4 * 322 * active_nfft];
+ savg = new float[4 * active_nfft];
+ set_ss_ptr(ss, 4, 322, active_nfft);
std::cout << "ss pointer set to: " << ss << std::endl;
- set_savg_ptr(savg, 4, NFFT);
+ set_savg_ptr(savg, 4, active_nfft);
std::cout << "savg pointer set to: " << savg << std::endl;
+ dd_old = new float[ddSize];
+ set_dd_old_ptr(dd_old, channels, pairsWorst);
+ ss_old = new float[4 * 322 * active_nfft];
+ savg_old = new float[4 * active_nfft];
+ set_ss_old_ptr(ss_old, 4, 322, active_nfft);
+ set_savg_old_ptr(savg_old, 4, active_nfft);
qDebug() << "MAINWINDOW created dd ss savg ";
@@ -243,6 +246,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionNo_Deep_Search->setActionGroup(DepthGroup);
ui->actionNormal_Deep_Search->setActionGroup(DepthGroup);
ui->actionAggressive_Deep_Search->setActionGroup(DepthGroup);
+ ui->actionFull_Deep_Search->setActionGroup(DepthGroup);
QButtonGroup* txMsgButtonGroup = new QButtonGroup;
txMsgButtonGroup->addButton(ui->txrb1,1);
@@ -343,7 +347,7 @@ MainWindow::MainWindow(QWidget *parent) :
wg, [wg]{ wg->setDecodeLabelPosition(DecodeLabelPosition::Bottom); });
}
- setWindowTitle (program_title ());
+ setWindowTitle (branded_program_title ());
qDebug() << "MAINWINDOW about to start soundInThread SIGNAL/SLOT connections";
connect(&soundInThread, SIGNAL(readyForFFT(int)),
@@ -388,7 +392,7 @@ MainWindow::MainWindow(QWidget *parent) :
m_NB=false;
m_mode="JT65B";
m_mode65=2;
- m_fs96000=true;
+ m_fs96000=1;
m_udpPort=50004;
m_adjustIQ=0;
m_applyIQcal=0;
@@ -411,11 +415,34 @@ MainWindow::MainWindow(QWidget *parent) :
fftwf_import_wisdom_from_filename (QDir {m_dataDir}.absoluteFilePath ("map65_wisdom.dat").toLocal8Bit ());
readSettings(); //Restore user's setup params
+
+ // Push mycall/mygrid/hiscall/hisgrid/neme to the Fortran side here, right
+ // after settings load, instead of waiting for the first
+ // MainWindow::decode() call to do it (decode() still pushes these on
+ // every cycle further down; this just makes the values available
+ // sooner). run_m65.f90 builds the deep65 CALL3.TXT candidate list eagerly
+ // before its decode loop starts (build_call3_candidates() in deep65.f90);
+ // without this, that eager build ran against Fortran's still-default/
+ // blank mycall/hiscall, and decode0.f90's genuine mycall-changed check
+ // then forced a second, redundant rebuild on the first real decode.
+ {
+ QString mcall = (m_myCall + " ").mid(0, 12);
+ QString mgrid = (m_myGrid + " ").mid(0, 6);
+ QString hcall = (ui->dxCallEntry->text() + " ").mid(0, 12);
+ QString hgrid = (ui->dxGridEntry->text() + " ").mid(0, 6);
+ setMyCall(mcall);
+ setMyGrid(mgrid);
+ setHisCall(hcall);
+ setHisGrid(hgrid);
+ setNeme(0);
+ if (ui->actionOnly_EME_calls->isChecked()) setNeme(1);
+ }
+
PaError paerr=Pa_Initialize(); //Initialize Portaudio
if(paerr!=paNoError) {
msgBox("Unable to initialize PortAudio.");
}
- QFile quitFile(QDir {m_dataDir}.absoluteFilePath (".quit"));
+ QFile quitFile(m_appDir + "/.quit");
quitFile.remove();
m_pbdecoding_style1="QPushButton{background-color: cyan; \
@@ -460,8 +487,9 @@ MainWindow::MainWindow(QWidget *parent) :
// Assign input device and start input thread
soundInThread.setInputDevice(m_paInDevice);
- if(m_fs96000) soundInThread.setRate(96000.0);
- if(!m_fs96000) soundInThread.setRate(95238.1);
+ if(m_fs96000 == 1) soundInThread.setRate(96000.0);
+ else if(m_fs96000 ==0) soundInThread.setRate(95238.1);
+ else if(m_fs96000 ==2) soundInThread.setRate(192000.0);
soundInThread.setBufSize(10*7056);
soundInThread.setNetwork(m_network);
soundInThread.setPort(m_udpPort);
@@ -473,11 +501,11 @@ MainWindow::MainWindow(QWidget *parent) :
soundOutThread.setOutputDevice(m_paOutDevice);
m_monitoring=true; // Start with Monitoring ON
+ qDebug() << "m_monitoring set to" << m_monitoring << "at" << Q_FUNC_INFO;
+
soundInThread.setMonitoring(m_monitoring);
m_diskData=false;
m_wide_graph_window->setFcal(m_fCal);
- if(m_fs96000) m_wide_graph_window->setFsample(96000);
- if(!m_fs96000) m_wide_graph_window->setFsample(95238);
m_wide_graph_window->m_mult570=m_mult570;
m_wide_graph_window->m_mult570Tx=m_mult570Tx;
m_wide_graph_window->m_cal570=m_cal570;
@@ -509,7 +537,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect (m_wide_graph_window.get (), &WideGraph::f11f12, this, &MainWindow::bumpDF);
QTimer::singleShot (0, this,[this]() {
- m_messages_window = new Messages(m_settings_filename);
+ m_messages_window = new Messages(m_settings_filename, m_eclipseFile);
m_messages_window->show();
on_actionMessages_triggered();
connect (m_messages_window, &Messages::click2OnCallsign, this, &MainWindow::doubleClickOnMessages);
@@ -570,32 +598,33 @@ void MainWindow::startDecoder()
{
qDebug() << "MAINWINDOW calling run_m65_ ";
- QByteArray runtimeDir = QDir::toNativeSeparators(m_dataDir).toLocal8Bit();
- set_wsjtx_dir_(runtimeDir.constData(), runtimeDir.size());
-
QFutureWatcher<void>* watcher_m65 = new QFutureWatcher<void>(this);
connect(watcher_m65, &QFutureWatcher<void>::finished,
this, &MainWindow::onRunM65Finished);
watcher_m65->setFuture(QtConcurrent::run([=]() {
- // Hook up shared stdout channel for Fortran
- StdoutSharedRegion* region =
- decoderCtx->stdoutChan->shared.getRegion();
- void* bufPtr = static_cast<void*>(region->buffer);
- void* hdrPtr = static_cast<void*>(&region->header);
- int bufSize = static_cast<int>(decoderCtx->stdoutChan->shared.getBufferSize());
- intptr_t eventH = reinterpret_cast<intptr_t>(decoderCtx->stdoutChan->eventHandle);
+ qDebug() << "DECODE: starting run_m65_() with m_fs96000=" << m_fs96000;
+
+ // Hook up shared stdout channel for Fortran
+ StdoutSharedRegion* region =
+ decoderCtx->stdoutChan->shared.getRegion();
- set_stdout_channel(bufPtr, hdrPtr, bufSize, eventH);
+ void* bufPtr = static_cast<void*>(region->buffer);
+ void* hdrPtr = static_cast<void*>(&region->header);
+ int bufSize = static_cast<int>(decoderCtx->stdoutChan->shared.getBufferSize());
+ intptr_t eventH = reinterpret_cast<intptr_t>(decoderCtx->stdoutChan->eventHandle);
- // Now run the decoder
- std::lock_guard<std::mutex> lock(g_fortran_decode_mutex);
- int xpol_flag = m_xpol ? 1 : 0;
- int rate_flag = m_fs96000 ? 1 : 0;
- run_m65_(&xpol_flag, &rate_flag);
+ set_stdout_channel(bufPtr, hdrPtr, bufSize, eventH);
+ // Now run the decoder
+ std::lock_guard<std::mutex> lock(g_fortran_decode_mutex);
+ int xpol_flag = m_xpol ? 1 : 0;
+ run_m65_(&xpol_flag, &m_fs96000);
+
+ qDebug() << "DECODE: run_m65_() returned";
}));
+
}
void MainWindow::startSharedMemoryStdoutReader(DecoderContext* ctx)
@@ -619,6 +648,17 @@ void MainWindow::startSharedMemoryStdoutReader(DecoderContext* ctx)
std::uint32_t readIndex = h0.writeIndex;
if (readIndex >= bufSize)
readIndex = 0;
+ region->header.readIndex = readIndex;
+
+ // TEMP diagnostic 2026-09-10: h0.writeIndex should always be 0 here --
+ // StdoutSharedMemory's constructor unconditionally zeroes writeIndex/
+ // readIndex right after mapping (see stdout_shared_memory.cpp), and
+ // that happens synchronously on the main thread before this reader
+ // thread is even spawned. If this ever logs a nonzero value, that
+ // assumption is wrong and this "start from current writeIndex" line
+ // is silently skipping over real data written before this point.
+ cppDbg(QString("stdout reader INIT readIndex=%1 (h0.writeIndex=%2) bufSize=%3")
+ .arg(readIndex).arg(h0.writeIndex).arg(bufSize));
std::string lineBuffer;
@@ -652,16 +692,43 @@ void MainWindow::startSharedMemoryStdoutReader(DecoderContext* ctx)
);
}
}
+
+ // Publish how far we've drained so the Fortran writer can
+ // compute free space and wait for room instead of wrapping
+ // around and overwriting data we haven't read yet.
+ region->header.readIndex = readIndex;
}
});
}
void MainWindow::processStdOut(QString t)
-{
-
+{
+
// qDebug().noquote() << QDateTime::currentMSecsSinceEpoch() << "PROCESS STDOUT:" << t;
+ // TEMP diagnostic 2026-09-10: confirms whether a decode line that made it
+ // into map65_rx.log (written Fortran-side, independent of this whole
+ // path) ever actually arrived here on the GUI thread. If a "!"-prefixed
+ // line is missing from this log around the time of a report-vs-rx.log
+ // mismatch, the loss is upstream (shared-memory ring buffer / reader
+ // thread); if it IS here but never appended to the Messages window, the
+ // loss is in handleControlLine/shouldDisplay below.
+ cppDbg(QString("processStdOut RECV \"%1\"").arg(t.trimmed()));
+
+ if (m_decodeDisplayFilter.handleControlLine(t)) return;
+
+ if (t.startsWith("<DecodeSkipped>")) {
+ bool validRequestId = false;
+ auto requestId = t.trimmed().section(' ', -1).toLongLong(&validRequestId);
+ if (validRequestId && is_current_decode_request(requestId)) {
+ m_decodeDisplayFilter.completeCycle();
+ decodeBusy(false);
+ ui->DecodeButton->setStyleSheet("");
+ }
+ return;
+ }
+
//qDebug() << "in processStdOut STDOUT:" << t;
if (t.indexOf("<QuickDecodeDone>") >= 0) {
@@ -677,6 +744,17 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
// --- <EarlyFinished> / <DecodeFinished> ---
if (t.indexOf("<EarlyFinished>") >= 0 || t.indexOf("<DecodeFinished>") >= 0) {
+ if (t.indexOf("<DecodeFinished>") >= 0) {
+ bool validRequestId = false;
+ auto requestId = t.trimmed().section(' ', -1).toLongLong(&validRequestId);
+ if (!validRequestId || !is_current_decode_request(requestId)) return;
+ }
+
+ if (t.indexOf("<EarlyFinished>") >= 0)
+ m_decodeDisplayFilter.completeEarlyPass();
+ if (t.indexOf("<DecodeFinished>") >= 0)
+ m_decodeDisplayFilter.completeCycle();
+
if (m_widebandDecode) {
if (m_messages_window)
m_messages_window->setText(m_messagesText, m_bandmapText);
@@ -687,16 +765,21 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
if (t.indexOf("<DecodeFinished>") >= 0) {
++m_decodeFinishedCount;
- decodeBusy(false);
+ decodeBusy(false);
// qDebug().noquote() << QDateTime::currentMSecsSinceEpoch() << "decodeBusy(false)";
if (m_diskData) onDiskDecodeFinished();
int ndecodes = t.mid(40,5).toInt();
- lab5->setText(QString::number(ndecodes));
- m_map65RxLog = 0;
+ lab8->setText(QString::number(ndecodes));
+ m_map65RxLog = 0;
+
+ // Only clear the button's "busy" styling on <DecodeFinished>, not
+ // <EarlyFinished> -- decodeBusy(false) is likewise gated on
+ // <DecodeFinished> alone, and the final pass can legitimately take
+ // many seconds longer than the early pass, during which the button
+ // must keep showing busy while more decodes are still arriving.
+ ui->DecodeButton->setStyleSheet("");
}
-
- ui->DecodeButton->setStyleSheet("");
return;
}
@@ -710,11 +793,23 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
#ifdef WIN32
m = 3;
#endif
- const QString decode_line = t.mid(1, n - m);
-
- // Suppress *second* narrowband GUI entry, but keep everything else
- if (m_RxState != 2 || m_diskData) {
- if (n >= 30 || t.indexOf("Best-fit") >= 0)
+ // The m=2/m=3 trim above assumes a normal decode line's fixed
+ // layout, whose last field is disposable padding/polarization --
+ // Find Delta Phi's "!Best-fit Dphi = NNN deg" summary line ends on
+ // real content instead (the "g" of "deg"), so the same trim chops
+ // it to "...de". Just trim the line terminator for this one case.
+ const QString decode_line = (t.indexOf("Best-fit") >= 0)
+ ? t.mid(1).trimmed()
+ : t.mid(1, n - m);
+
+ if (n >= 30 || t.indexOf("Best-fit") >= 0) {
+ bool const display = m_decodeDisplayFilter.shouldDisplay(decode_line);
+ // TEMP diagnostic 2026-09-10 -- see the matching note at the top
+ // of processStdOut(). If display=false here for a line that has
+ // no legitimate earlier-pass duplicate, the display filter itself
+ // (map65_decode_display_filter.cpp) is the culprit.
+ cppDbg(QString("shouldDisplay=%1 for \"%2\"").arg(display ? "true" : "false").arg(decode_line));
+ if (display)
ui->decodedTextBrowser->append(decode_line);
}
@@ -857,12 +952,13 @@ if (t.indexOf("<QuickDecodeDone>") >= 0) {
void MainWindow::onRunM65Finished() {
// Do something when run_m65 finishes
+ // qDebug() << "DECODE: onRunM65Finished()";
}
void MainWindow::onDiskDecodeFinished()
{
if (!m_path.isEmpty())
- setWindowTitle("MAP65 - " + QFileInfo(m_path).fileName());
+ setWindowTitle("MAP65™ - " + QFileInfo(m_path).fileName());
if (m_loopall)
on_actionOpen_next_in_directory_triggered();
@@ -901,7 +997,7 @@ void MainWindow::writeSettings()
settings.setValue("Fcal",m_fCal);
settings.setValue("Fadd",m_fAdd);
settings.setValue("NetworkInput", m_network);
- settings.setValue("FSam96000", m_fs96000);
+ settings.setValue("FSam96000", QString::number(m_pendingFs96000 >= 0 ? m_pendingFs96000 : m_fs96000));
settings.setValue("SoundInIndex",m_nDevIn);
settings.setValue("paInDevice",m_paInDevice);
settings.setValue("SoundOutIndex",m_nDevOut);
@@ -958,12 +1054,13 @@ void MainWindow::writeSettings()
void MainWindow::readSettings()
{
QSettings settings(m_settings_filename, QSettings::IniFormat);
+ auto const pskReporterSettings = readMap65PSKReporterSettings(settings);
{
SettingsGroup g {&settings, "MainWindow"};
restoreGeometry(settings.value("geometry").toByteArray());
ui->dxCallEntry->setText(settings.value("DXcall","").toString());
ui->dxGridEntry->setText(settings.value("DXgrid","").toString());
- m_path = settings.value("MRUdir", QDir {m_dataDir}.absoluteFilePath("save")).toString();
+ m_path = settings.value("MRUdir", m_appDir + "/save").toString();
m_txFirst = settings.value("TxFirst",false).toBool();
ui->txFirstCheckBox->setChecked(m_txFirst);
}
@@ -984,6 +1081,19 @@ void MainWindow::readSettings()
m_xpolx=settings.value("XpolX",false).toBool();
m_saveDir=settings.value("SaveDir",QDir {m_dataDir}.absoluteFilePath("save")).toString();
m_azelDir=settings.value("AzElDir",m_dataDir).toString();
+ if (!settings.value("AzElDirMigratedToDataDir",false).toBool()) {
+ // One-time migration: earlier versions defaulted AzElDir to the
+ // application/bin directory instead of the user data directory, and
+ // that default got persisted the first time settings were saved. An
+ // exact-match check against the *current* m_appDir can't catch this,
+ // since the saved value may point at some older build's bin directory
+ // that no longer matches this run's m_appDir at all. So instead: force
+ // everyone onto the new default exactly once, unconditionally, then
+ // remember it's done so a deliberate later customization (via the
+ // Setup dialog's AzEl Directory field) is never overwritten again.
+ m_azelDir = m_dataDir;
+ settings.setValue("AzElDirMigratedToDataDir",true);
+ }
m_editorCommand=settings.value("Editor","notepad").toString();
m_dxccPfx=settings.value("DXCCpfx","").toString();
m_timeout=settings.value("Timeout",20).toInt();
@@ -994,7 +1104,8 @@ void MainWindow::readSettings()
m_fAdd=settings.value("Fadd",0).toDouble();
soundInThread.setFadd(m_fAdd);
m_network = settings.value("NetworkInput",true).toBool();
- m_fs96000 = settings.value("FSam96000",true).toBool();
+ m_fs96000 = readFSam96000(settings,1);
+ qDebug() << "In MainWindow::readSettings FSam96000 is read as:" << m_fs96000;
m_nDevIn = settings.value("SoundInIndex", 0).toInt();
m_paInDevice = settings.value("paInDevice",0).toInt();
m_nDevOut = settings.value("SoundOutIndex", 0).toInt();
@@ -1060,10 +1171,11 @@ void MainWindow::readSettings()
if(m_ndepth==0) ui->actionNo_Deep_Search->setChecked(true);
if(m_ndepth==1) ui->actionNormal_Deep_Search->setChecked(true);
if(m_ndepth==2) ui->actionAggressive_Deep_Search->setChecked(true);
+ if(m_ndepth==3) ui->actionFull_Deep_Search->setChecked(true);
m_w3szUrl=settings.value("w3szUrl",true).toBool();
m_otherUrl=settings.value("otherUrl","").toString();
- m_spot_to_psk_reporter=settings.value("spotPSK",true).toBool();
- m_psk_reporter_tcpip=settings.value("PSKReporterTCPIP",false).toBool();
+ m_spot_to_psk_reporter = pskReporterSettings.enabled;
+ m_psk_reporter_tcpip = pskReporterSettings.use_tcpip;
m_tol=settings.value("FTol",500).toInt();
m_wide_graph_window->setTol(m_tol);
@@ -1072,7 +1184,7 @@ void MainWindow::readSettings()
if(m_tol==50) i=2;
if(m_tol==100) i=3;
if(m_tol==200) i=4;
-// if(m_tol==500) i=5;
+ if(m_tol==500) i=5;
if(m_tol==1000) i=6;
ui->labTol1->setText(QString::number(m_tol));
ui->tolSpinBox->setValue(i);
@@ -1099,13 +1211,20 @@ void MainWindow::readSettings()
//-------------------------------------------------------------- dataSink()
void MainWindow::dataSink(int k)
{
- static float s[NFFT],splot[NFFT];
+ static float* s = nullptr;
+ static float* splot = nullptr;
+ if (!s) {
+ s = new float[active_nfft];
+ splot = new float[active_nfft];
+ }
static int n=0;
static int ihsym=0;
static int nzap=0;
static int ntrz=0;
static int nkhz;
- int nfsample= m_fs96000 ? 96000 : 95238;
+ int nfsample = 96000;
+ if (m_fs96000 == 0) nfsample = 95238;
+ else if(m_fs96000 == 2) nfsample = 192000;
setNfsample(nfsample);
int nxpol= m_xpol ? 1 : 0;
setNxpol(nxpol);
@@ -1115,7 +1234,8 @@ void MainWindow::dataSink(int k)
static int nb;
static int nadj=0;
static float px=0.0,py=0.0;
- static uchar lstrong[1024];
+ constexpr int lstrongSize = 1024;
+ static uchar lstrong[lstrongSize];
static float rejectx;
static float rejecty;
static float slimit;
@@ -1133,15 +1253,13 @@ void MainWindow::dataSink(int k)
// Get x and y power, polarized spectrum, nkhz, and ihsym
nb=0;
if(m_NB) nb=1;
- nfsample=96000;
- if(!m_fs96000) nfsample=95238;
nxpol=0;
if(m_xpol) nxpol=1;
nadj++;
if(m_adjustIQ==0) nadj=0;
-
+
symspec_(&k, &nxpol, &ndiskdat, &nb, &m_NBslider, &m_dPhi,
- &nfsample, &m_adjustIQ, &m_applyIQcal,
+ &m_adjustIQ, &m_applyIQcal,
&m_gainx, &m_gainy, &m_phasex, &m_phasey, &rejectx, &rejecty,
&px, &py, s, &nkhz, &ihsym, &nzap, &slimit, lstrong);
@@ -1176,8 +1294,9 @@ void MainWindow::dataSink(int k)
}
xSignalMeter->setValue(px); // Update the signal meters
ySignalMeter->setValue(py);
+
if(m_monitoring || m_diskData) {
- m_wide_graph_window->dataSink2(s,nkhz,ihsym,m_diskData,lstrong);
+ m_wide_graph_window->dataSink2(s,nkhz,ihsym,m_diskData,lstrong,lstrongSize);
}
if(nadj == 10) {
@@ -1201,16 +1320,16 @@ void MainWindow::dataSink(int k)
//Average over specified number of spectra
if (n==0) {
- for (int i=0; i<NFFT; i++)
+ for (int i=0; i<active_nfft; i++)
splot[i]=s[i];
} else {
- for (int i=0; i<NFFT; i++)
+ for (int i=0; i<active_nfft; i++)
splot[i] += s[i];
}
n++;
if (n>=m_waterfallAvg) {
- for (int i=0; i<NFFT; i++) {
+ for (int i=0; i<active_nfft; i++) {
splot[i] /= n; //Normalize the average
}
@@ -1218,7 +1337,7 @@ void MainWindow::dataSink(int k)
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
int ntr1 = (ms/1000) % m_TRperiod;
if((m_diskData && ihsym <= m_waterfallAvg) || (!m_diskData && ntr1<ntrz)) {
- for (int i=0; i<NFFT; i++) {
+ for (int i=0; i<active_nfft; i++) {
splot[i] = 1.e30;
}
}
@@ -1233,7 +1352,7 @@ void MainWindow::dataSink(int k)
setDecoderReady(0);
setNewdat(1);
setNagain(0);
- setNhsym(ihsym);
+ setNhsym(280);
QDateTime t = QDateTime::currentDateTimeUtc();
m_dateTime=t.toString("yyyy-MMM-dd hh:mm");
decode(); //Start the decoder
@@ -1245,7 +1364,7 @@ void MainWindow::dataSink(int k)
setDecoderReady(0);
setNewdat(1);
setNagain(0);
- setNhsym(ihsym);
+ setNhsym(302);
QDateTime t = QDateTime::currentDateTimeUtc();
m_dateTime=t.toString("yyyy-MMM-dd hh:mm");
decode(); //Start the decoder
@@ -1262,7 +1381,7 @@ void MainWindow::dataSink(int k)
watcher2->setFuture(*future2);
}
}
- soundInThread.m_dataSinkBusy=false;
+ soundInThread.m_dataSinkBusy.store (false, std::memory_order_release);
}
/* Generate gaussian random float with mean=0 and std_dev=1 */
@@ -1298,7 +1417,7 @@ float* MainWindow::getDd() const
void MainWindow::savetf2(QString fname, bool xpol)
{
- int npts=2*56*96000;
+ int npts=2*56*g_sampleRate;
if(xpol) npts=2*npts;
FILE* fp = fopen(fname.toUtf8().constData(), "wb");
@@ -1334,15 +1453,15 @@ void MainWindow::savetf2(QString fname, bool xpol)
void MainWindow::getfile(QString fname, bool xpol, int dbDgrd)
{
- setDecoderReady(0);
- int npts = 2 * 56 * 96000;
+ cancel_pending_decode_requests();
+ int npts = 2 * 56 * g_sampleRate;
if (xpol) npts = 2 * npts;
// j indexes dd[], which has 4 channels per pair
int j = 0;
// Clear id[] properly
- memset(id, 0, npts * sizeof(id[0]));
+ memset(id.data(), 0, npts * sizeof(id[0]));
// Open file
FILE* fp = fopen(fname.toUtf8().constData(), "rb");
@@ -1351,6 +1470,11 @@ void MainWindow::getfile(QString fname, bool xpol, int dbDgrd)
return;
}
+ qDebug().noquote() << QString("NEWFILE: nfsample=%1 nrate_active=%2")
+ .arg(active_nfft)
+ .arg(g_sampleRate);
+
+
// Read fcenter
double fcenter = 0.0;
if (fread(&fcenter, sizeof(fcenter), 1, fp) != 1) {
@@ -1360,16 +1484,20 @@ void MainWindow::getfile(QString fname, bool xpol, int dbDgrd)
setFcenter(fcenter);
- // Skip the 8-byte zero padding
- uint64_t pad = 0;
- if (fread(&pad, sizeof(pad), 1, fp) != 1) {
- fclose(fp);
- return;
- }
+ qint64 sampleBytes = static_cast<qint64>(npts) * static_cast<qint64>(sizeof(id[0]));
+ qint64 expectedPaddedSize = static_cast<qint64>(sizeof(fcenter)) +
+ static_cast<qint64>(sizeof(uint64_t)) + sampleBytes;
+ if (QFileInfo {fname}.size() == expectedPaddedSize) {
+ uint64_t pad = 0;
+ if (fread(&pad, sizeof(pad), 1, fp) != 1) {
+ fclose(fp);
+ return;
+ }
+ }
// Read raw samples
- size_t nRead = fread(id, sizeof(id[0]), npts, fp);
+ size_t nRead = fread(id.data(), sizeof(id[0]), npts, fp);
qDebug() << "fread read" << nRead << "samples, expected" << npts;
fclose(fp);
@@ -1424,10 +1552,25 @@ void MainWindow::showStatusMessage(const QString& statusMsg)
void MainWindow::on_actionDeviceSetup_triggered()
{
DevSetup dlg(this);
+
+ connect(&dlg, &DevSetup::sampleRateChanged,
+ this, &MainWindow::onSampleRateChanged);
+
dlg.initDlg();
if (dlg.exec() == QDialog::Accepted)
{
+ if (dlg.m_restartRequired)
+ {
+ m_pendingFs96000 = dlg.m_pendingFs96000;
+ writeSettings();
+ if (m_messages_window) {
+ m_messages_window->setPSKReportingEnabled(m_spot_to_psk_reporter);
+ }
+ return;
+ }
+ m_pendingFs96000 = -1;
+
//
// Apply runtime effects for SoundIn
//
@@ -1439,7 +1582,9 @@ void MainWindow::on_actionDeviceSetup_triggered()
soundInThread.setInputDevice(m_paInDevice);
soundInThread.setNetwork(m_network);
soundInThread.setFadd(m_fAdd);
- soundInThread.setRate(m_fs96000 ? 96000.0 : 95238.1);
+ if (m_fs96000 == 1) soundInThread.setRate(96000.0);
+ else if (m_fs96000 == 0) soundInThread.setRate(95238.1);
+ else if (m_fs96000 == 2) soundInThread.setRate(192000.0);
soundInThread.setSwapIQ(m_IQswap);
soundInThread.setScale(m_dB);
soundInThread.setPort(m_udpPort);
@@ -1483,15 +1628,33 @@ void MainWindow::on_actionDeviceSetup_triggered()
// Save to disk
//
writeSettings();
+ if (m_messages_window) {
+ m_messages_window->setPSKReportingEnabled(m_spot_to_psk_reporter);
+ }
}
}
+void MainWindow::onSampleRateChanged(int newRate)
+{
+ if (!m_wide_graph_window)
+ return;
+
+ if (newRate == 96000 || newRate == 95238)
+ m_wide_graph_window->setFreqSpanLimits(60, 90);
+ else
+ m_wide_graph_window->setFreqSpanLimits(60, 190);
+
+ m_wide_graph_window->updateSpanFromSpinbox();
+}
+
void MainWindow::on_monitorButton_clicked() //Monitor
{
m_monitoring=true;
+ qDebug() << "m_monitoring set to" << m_monitoring << "at" << Q_FUNC_INFO;
soundInThread.setMonitoring(true);
m_diskData=false;
+
}
void MainWindow::on_actionLinrad_triggered() //Linrad palette
{
@@ -1662,6 +1825,12 @@ void MainWindow::createStatusBar() //createStatusBar
lab7->setMinimumSize(QSize(50,10));
lab7->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addWidget(lab7);
+
+ lab8 = new QLabel("QSOs: 0");
+ lab8->setAlignment(Qt::AlignHCenter);
+ lab8->setMinimumSize(QSize(50,10));
+ lab8->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+ statusBar()->addWidget(lab8);
}
void MainWindow::on_tolSpinBox_valueChanged(int i) //tolSpinBox
@@ -1683,7 +1852,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
if (m_gui_timer) m_gui_timer->stop();
m_wide_graph_window->saveSettings();
- QFile quitFile(QDir {m_dataDir}.absoluteFilePath (".quit"));
+ QFile quitFile(m_appDir + "/.quit");
(void)quitFile.open(QFileDevice::ReadWrite);
setQuitID(quitFile.handle());
@@ -1713,6 +1882,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
void MainWindow::on_stopButton_clicked() //stopButton
{
m_monitoring=false;
+ qDebug() << "m_monitoring set to" << m_monitoring << "at" << Q_FUNC_INFO;
soundInThread.setMonitoring(m_monitoring);
m_loopall=false;
}
@@ -1757,6 +1927,16 @@ void MainWindow::on_actionQ65_Sensitivity_in_MAP65_3_0_triggered()
QDesktopServices::openUrl (QUrl {"https://wsjt.sourceforge.io/Q65_Sensitivity_in_MAP65.pdf"});
}
+void MainWindow::on_actionCopyright_Notice_triggered()
+{
+ MessageBox::warning_message (this, copyright_notice_text ());
+}
+
+void MainWindow::on_actionTrademark_Policy_triggered()
+{
+ QDesktopServices::openUrl (QUrl {"https://wsjtx.github.io/wsjtx/trademark.html"});
+}
+
void MainWindow::on_actionAstro_Data_triggered() //Display Astro
{
if (m_astro_window ) m_astro_window->show();
@@ -1780,6 +1960,8 @@ void MainWindow::on_actionMessages_triggered() //Display Messages
void MainWindow::on_actionOpen_triggered() //Open File
{
m_monitoring=false;
+ qDebug() << "m_monitoring set to" << m_monitoring << "at" << Q_FUNC_INFO;
+
soundInThread.setMonitoring(m_monitoring);
// Wipe waterfall callsign overlay so stale labels from the previous
// file (or live capture) don't linger over the new decode.
@@ -1851,7 +2033,7 @@ void MainWindow::on_actionOpen_next_in_directory_triggered() //Open Next
*future1 = QtConcurrent::run([this](QString fname, bool xpol, int dbDgrd) {
this->getfile(fname, xpol, dbDgrd);
}, fname, m_xpol, dbDgrd);
- // qDebug() << "MainWindow::on_actionOpen_next_in_directory_triggered Reading wav file: " << m_path;
+ qDebug() << "MainWindow::on_actionOpen_next_in_directory_triggered Reading wav file: " << m_path;
watcher1->setFuture(*future1);
return;
}
@@ -1874,8 +2056,9 @@ void MainWindow::diskDat() //diskDat()
setFcenter(m_wide_graph_window->m_dForceCenterFreq);
}
- if(m_fs96000) hsym=2048.0*96000.0/11025.0; //Samples per JT65 half-symbol
- if(!m_fs96000) hsym=2048.0*95238.1/11025.0;
+ hsym=2048.0*96000.0/11025.0; //Samples per JT65 half-symbol if SR = 96000
+ if(m_fs96000 == 0) hsym=2048.0*95238.1/11025.0; // Samples per JT65 half-symbol if SR = 95238.1
+ else if(m_fs96000 == 2) hsym=2048.0*192000.0/11025.0; //Samples per JT65 half-symbol if SR = 192000
for(int i=0; i<304; i++) { // Do the half-symbol FFTs
int k = i*hsym + 2048.5;
dataSink(k);
@@ -1915,6 +2098,14 @@ void MainWindow::on_actionErase_Band_Map_and_Messages_triggered()
{
m_band_map_window->setText("");
m_messages_window->setText("","");
+ // m_messagesText/m_bandmapText accumulate across decode cycles and are
+ // only reset when a "!" line arrives (processStdOut). Without clearing
+ // them here too, the next <EarlyFinished>/<DecodeFinished> redisplay
+ // (or a cycle with no fresh decodes) repaints the stale pre-erase text
+ // right back into the windows.
+ m_messagesText.clear();
+ m_bandmapText.clear();
+ m_widebandDecode = false;
m_map65RxLog |= 4;
}
@@ -1954,6 +2145,11 @@ void MainWindow::on_actionAggressive_Deep_Search_triggered() //Aggressive DS
m_ndepth=2;
}
+void MainWindow::on_actionFull_Deep_Search_triggered() //Full DS
+{
+ m_ndepth=3;
+}
+
void MainWindow::on_actionNone_triggered() //Save None
{
m_saveAll=false;
@@ -2005,6 +2201,7 @@ void MainWindow::freezeDecode(int n) //freezeDecode()
if(!m_decoderBusy) {
setNagain(1);
setNewdat(0);
+ set_manual_decode_flag(1);
decode();
}
}
@@ -2035,7 +2232,6 @@ void MainWindow::decode() //decode()
if(m_diskData) {
if(m_myGrid.trimmed().length()>=6) {
setNdiskdat(1);
- setNagain(0);
int i0=m_path.indexOf(".tf2");
if(i0<0) i0=m_path.indexOf(".iq");
if(i0>0) {
@@ -2087,8 +2283,10 @@ void MainWindow::decode() //decode()
if(getNutc() < m_nutc0) m_map65RxLog |= 1; //Date and Time to map65_rx.log
m_nutc0=getNutc();
setMap65RxLog(m_map65RxLog);
- setNfsample(96000);
- if(!m_fs96000) setNfsample(95238);
+ if(m_fs96000 == 1) setNfsample(96000);
+ if(m_fs96000 == 0) setNfsample(95238);
+ else if(m_fs96000 == 2) setNfsample(192000);
+ // qDebug() << "MainWindow::decode setting nfsample to " << m_fs96000;
setNxpol(0);
if(m_xpol) setNxpol(1);
setNmode(10*m_modeQ65 + m_modeJT65);
@@ -2110,9 +2308,8 @@ QString hgrid = (ui->dxGridEntry->text() + " ").mid(0, 6);
setJunk1(1234);
setJunk2(5678);
- setNagain(0); //added 12-30-25 to agree with legacy
if (!m_diskData) setNdiskdat(0); //added 12-30-25 to agree with legacy
- setDecoderReady(1);
+ publish_decode_request();
m_map65RxLog=0;
m_call3Modified=false;
// qDebug() << QDateTime::currentMSecsSinceEpoch() << "finished MainWindow::decode()";
@@ -2240,6 +2437,8 @@ void MainWindow::guiUpdate()
if(bTune0 and !bTune) {
btxok=false;
m_monitoring=bMonitoring0;
+ // qDebug() << "m_monitoring set to" << m_monitoring << "at" << Q_FUNC_INFO;
+
soundInThread.setMonitoring(m_monitoring);
}
if(bTune and !bTune0) bMonitoring0=m_monitoring;
@@ -2292,7 +2491,7 @@ void MainWindow::guiUpdate()
int mode65=m_mode65;
int ntxFreq=1000;
double samfac=1.0;
- qDebug() << mode65 << samfac;
+ // qDebug() << mode65 << samfac;
if(m_modeTx=="JT65") {
gen65_(message,&mode65,&samfac,&nsendingsh,msgsent,iwave,
&nwave,len1,len1);
@@ -2330,6 +2529,8 @@ void MainWindow::guiUpdate()
xSignalMeter->setValue(0);
ySignalMeter->setValue(0);
m_monitoring=false;
+ // qDebug() << "m_monitoring set to" << m_monitoring << "at" << Q_FUNC_INFO;
+
soundInThread.setMonitoring(false);
btxok=true;
m_transmitting=true;
@@ -2369,6 +2570,8 @@ void MainWindow::guiUpdate()
m_wide_graph_window->enableSetRxHardware(true);
if(m_auto) {
m_monitoring=true;
+ // qDebug() << "m_monitoring set to" << m_monitoring << "at" << Q_FUNC_INFO;
+
soundInThread.setMonitoring(m_monitoring);
}
}
@@ -2653,14 +2856,7 @@ void MainWindow::genStdMsgs(QString rpt) //genStdMsgs()
QString MainWindow::call3Path() const
{
- QString writablePath = QDir {m_dataDir}.absoluteFilePath("CALL3.TXT");
- if (!QFile::exists(writablePath)) {
- QString bundledPath = QDir {m_appDir}.absoluteFilePath("CALL3.TXT");
- if (QFile::exists(bundledPath)) {
- QFile::copy(bundledPath, writablePath);
- }
- }
- return writablePath;
+ return ensureMap65RuntimeFile(m_appDir, m_installedDataDir, m_dataDir, "CALL3.TXT");
}
void MainWindow::lookup() //lookup()
@@ -3075,8 +3271,7 @@ void MainWindow::on_actionFUNcube_Dongle_triggered()
void MainWindow::on_actionEdit_wsjt_log_triggered()
{
- proc_editor.start (QDir::toNativeSeparators (m_editorCommand),
- {QDir::toNativeSeparators (QDir {m_dataDir}.absoluteFilePath ("wsjt.log")), });
+ proc_editor.start (QDir::toNativeSeparators (m_editorCommand), {QDir::toNativeSeparators (m_appDir + "/wsjt.log"), });
}
void MainWindow::on_actionTx_Tune_triggered()
@@ -3121,7 +3316,7 @@ void MainWindow::read_log()
// Update "m_worked" by reading wsjtx.log
m_worked.clear(); //Start from scratch
QFile f("wsjtx.log");
-// qDebug() << "MainWindow::read_log File open result:" << f.open(QFileDevice::ReadOnly);
+ qDebug() << "MainWindow::read_log File open result:" << f.open(QFileDevice::ReadOnly);
if(f.isOpen()) {
QTextStream in(&f);
QString line,callsign;