diff options
99 files changed, 2230 insertions, 1040 deletions
diff --git a/Audio/tools/record_time_signal.cpp b/Audio/tools/record_time_signal.cpp new file mode 100644 index 00000000..6a78a0a2 --- /dev/null +++ b/Audio/tools/record_time_signal.cpp @@ -0,0 +1,397 @@ +#include <iostream> +#include <exception> +#include <stdexcept> +#include <string> +#include <memory> + +#include <locale.h> + +#include <QCoreApplication> +#include <QTextStream> +#include <QCommandLineParser> +#include <QCommandLineOption> +#include <QStringList> +#include <QFileInfo> +#include <QAudioFormat> +#include <QAudioDeviceInfo> +#include <QAudioInput> +#include <QAudioOutput> +#include <QTimer> +#include <QDateTime> +#include <QDebug> + +#include "revision_utils.hpp" +#include "Audio/BWFFile.hpp" + +namespace +{ + QTextStream qtout {stdout}; +} + +class Record final + : public QObject +{ + Q_OBJECT; + +public: + Record (int start, int duration, QAudioDeviceInfo const& source_device, BWFFile * output, int notify_interval, int buffer_size) + : source_ {source_device, output->format ()} + , notify_interval_ {notify_interval} + , output_ {output} + , duration_ {duration} + { + if (buffer_size) source_.setBufferSize (output_->format ().bytesForFrames (buffer_size)); + if (notify_interval_) + { + source_.setNotifyInterval (notify_interval); + connect (&source_, &QAudioInput::notify, this, &Record::notify); + } + + if (start == -1) + { + start_recording (); + } + else + { + auto now = QDateTime::currentDateTimeUtc (); + auto time = now.time (); + auto then = now; + then.setTime (QTime {time.hour (), time.minute (), start}); + auto delta_ms = (now.msecsTo (then) + (60 * 1000)) % (60 * 1000); + QTimer::singleShot (int (delta_ms), Qt::PreciseTimer, this, &Record::start_recording); + } + } + + Q_SIGNAL void done (); + +private: + Q_SLOT void start_recording () + { + qtout << "started recording at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; + source_.start (output_); + if (!notify_interval_) QTimer::singleShot (duration_ * 1000, Qt::PreciseTimer, this, &Record::stop_recording); + qtout << QString {"buffer size used is: %1"}.arg (source_.bufferSize ()) << endl; + } + + Q_SLOT void notify () + { + auto length = source_.elapsedUSecs (); + qtout << QString {"%1 μs recorded\r"}.arg (length) << flush; + if (length >= duration_ * 1000 * 1000) stop_recording (); + } + + Q_SLOT void stop_recording () + { + auto length = source_.elapsedUSecs (); + source_.stop (); + qtout << QString {"%1 μs recorded "}.arg (length) << '(' << source_.format ().framesForBytes (output_->size ()) << " frames recorded)\n"; + qtout << "stopped recording at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; + Q_EMIT done (); + } + + QAudioInput source_; + int notify_interval_; + BWFFile * output_; + int duration_; +}; + +class Playback final + : public QObject +{ + Q_OBJECT; + +public: + Playback (int start, BWFFile * input, QAudioDeviceInfo const& sink_device, int notify_interval, int buffer_size, QString const& category) + : input_ {input} + , sink_ {sink_device, input->format ()} + , notify_interval_ {notify_interval} + { + if (buffer_size) sink_.setBufferSize (input_->format ().bytesForFrames (buffer_size)); + if (category.size ()) sink_.setCategory (category); + if (notify_interval_) + { + sink_.setNotifyInterval (notify_interval); + connect (&sink_, &QAudioOutput::notify, this, &Playback::notify); + } + connect (&sink_, &QAudioOutput::stateChanged, this, &Playback::sink_state_changed); + if (start == -1) + { + start_playback (); + } + else + { + auto now = QDateTime::currentDateTimeUtc (); + auto time = now.time (); + auto then = now; + then.setTime (QTime {time.hour (), time.minute (), start}); + auto delta_ms = (now.msecsTo (then) + (60 * 1000)) % (60 * 1000); + QTimer::singleShot (int (delta_ms), Qt::PreciseTimer, this, &Playback::start_playback); + } + } + + Q_SIGNAL void done (); + +private: + Q_SLOT void start_playback () + { + qtout << "started playback at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; + sink_.start (input_); + qtout << QString {"buffer size used is: %1 (%2 frames)"}.arg (sink_.bufferSize ()).arg (sink_.format ().framesForBytes (sink_.bufferSize ())) << endl; + } + + Q_SLOT void notify () + { + auto length = sink_.elapsedUSecs (); + qtout << QString {"%1 μs rendered\r"}.arg (length) << flush; + } + + Q_SLOT void sink_state_changed (QAudio::State state) + { + switch (state) + { + case QAudio::ActiveState: + qtout << "\naudio output state changed to active\n"; + break; + case QAudio::SuspendedState: + qtout << "\naudio output state changed to suspended\n"; + break; + case QAudio::StoppedState: + qtout << "\naudio output state changed to stopped\n"; + break; + case QAudio::IdleState: + stop_playback (); + qtout << "\naudio output state changed to idle\n"; + break; +#if QT_VERSION >= QT_VERSION_CHECK (5, 10, 0) + case QAudio::InterruptedState: + qtout << "\naudio output state changed to interrupted\n"; + break; +#endif + } + } + + Q_SLOT void stop_playback () + { + auto length = sink_.elapsedUSecs (); + sink_.stop (); + qtout << QString {"%1 μs rendered "}.arg (length) << '(' << sink_.format ().framesForBytes (input_->size ()) << " frames rendered)\n"; + qtout << "stopped playback at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; + Q_EMIT done (); + } + + BWFFile * input_; + QAudioOutput sink_; + int notify_interval_; +}; + +#include "record_time_signal.moc" + +int main(int argc, char *argv[]) +{ + QCoreApplication app {argc, argv}; + try + { + ::setlocale (LC_NUMERIC, "C"); // ensure number forms are in + // consistent format, do this + // after instantiating + // QApplication so that Qt has + // correct l18n + + // Override programs executable basename as application name. + app.setApplicationName ("WSJT-X Record Time Signal"); + app.setApplicationVersion (version ()); + + QCommandLineParser parser; + parser.setApplicationDescription ( + "\nTool to determine and experiment with QAudioInput latencies\n\n" + "\tUse the -I option to list available recording device numbers\n" + ); + auto help_option = parser.addHelpOption (); + auto version_option = parser.addVersionOption (); + + parser.addOptions ({ + {{"I", "list-audio-inputs"}, + app.translate ("main", "List the available audio input devices")}, + {{"O", "list-audio-outputs"}, + app.translate ("main", "List the available audio output devices")}, + {{"s", "start-time"}, + app.translate ("main", "Record from <start-time> seconds, default start immediately"), + app.translate ("main", "start-time")}, + {{"d", "duration"}, + app.translate ("main", "Recording <duration> seconds"), + app.translate ("main", "duration")}, + {{"o", "output"}, + app.translate ("main", "Save output as <output-file>"), + app.translate ("main", "output-file")}, + {{"i", "input"}, + app.translate ("main", "Playback <input-file>"), + app.translate ("main", "input-file")}, + {{"f", "force"}, + app.translate ("main", "Overwrite existing file")}, + {{"r", "sample-rate"}, + app.translate ("main", "Record at <sample-rate>, default 48000 Hz"), + app.translate ("main", "sample-rate")}, + {{"c", "num-channels"}, + app.translate ("main", "Record <num> channels, default 2"), + app.translate ("main", "num")}, + {{"R", "recording-device-number"}, + app.translate ("main", "Record from <device-number>"), + app.translate ("main", "device-number")}, + {{"P", "playback-device-number"}, + app.translate ("main", "Playback to <device-number>"), + app.translate ("main", "device-number")}, + {{"C", "category"}, + app.translate ("main", "Playback <category-name>"), + app.translate ("main", "category-name")}, + {{"n", "notify-interval"}, + app.translate ("main", "use notify signals every <interval> milliseconds, zero to use a timer"), + app.translate ("main", "interval")}, + {{"b", "buffer-size"}, + app.translate ("main", "audio buffer size <frames>"), + app.translate ("main", "frames")}, + }); + parser.process (app); + + auto input_devices = QAudioDeviceInfo::availableDevices (QAudio::AudioInput); + if (parser.isSet ("I")) + { + int n {0}; + for (auto const& device : input_devices) + { + qtout << ++n << " - [" << device.deviceName () << ']' << endl; + } + return 0; + } + + auto output_devices = QAudioDeviceInfo::availableDevices (QAudio::AudioOutput); + if (parser.isSet ("O")) + { + int n {0}; + for (auto const& device : output_devices) + { + qtout << ++n << " - [" << device.deviceName () << ']' << endl; + } + return 0; + } + + bool ok; + int start {-1}; + if (parser.isSet ("s")) + { + start = parser.value ("s").toInt (&ok); + if (!ok) throw std::invalid_argument {"start time not a number"}; + if (0 > start || start > 59) throw std::invalid_argument {"0 > start > 59"}; + } + int sample_rate {48000}; + if (parser.isSet ("r")) + { + sample_rate = parser.value ("r").toInt (&ok); + if (!ok) throw std::invalid_argument {"sample rate not a number"}; + } + int num_channels {2}; + if (parser.isSet ("c")) + { + num_channels = parser.value ("c").toInt (&ok); + if (!ok) throw std::invalid_argument {"channel count not a number"}; + } + int notify_interval {0}; + if (parser.isSet ("n")) + { + notify_interval = parser.value ("n").toInt (&ok); + if (!ok) throw std::invalid_argument {"notify interval not a number"}; + } + int buffer_size {0}; + if (parser.isSet ("b")) + { + buffer_size = parser.value ("b").toInt (&ok); + if (!ok) throw std::invalid_argument {"buffer size not a number"}; + } + int input_device {0}; + if (parser.isSet ("R")) + { + input_device = parser.value ("R").toInt (&ok); + if (!ok || 0 >= input_device || input_device > input_devices.size ()) + { + throw std::invalid_argument {"invalid recording device"}; + } + } + int output_device {0}; + if (parser.isSet ("P")) + { + output_device = parser.value ("P").toInt (&ok); + if (!ok || 0 >= output_device || output_device > output_devices.size ()) + { + throw std::invalid_argument {"invalid playback device"}; + } + } + if (!(parser.isSet ("o") || parser.isSet ("i"))) throw std::invalid_argument {"file required"}; + if (parser.isSet ("o") && parser.isSet ("i")) throw std::invalid_argument {"specify either input or output"}; + + QAudioFormat audio_format; + if (parser.isSet ("o")) // Record + { + int duration = parser.value ("d").toInt (&ok); + if (!ok) throw std::invalid_argument {"duration not a number"}; + + QFileInfo ofi {parser.value ("o")}; + if (!ofi.suffix ().size () && ofi.fileName ()[ofi.fileName ().size () - 1] != QChar {'.'}) + { + ofi.setFile (ofi.filePath () + ".wav"); + } + if (!parser.isSet ("f") && ofi.isFile ()) + { + throw std::invalid_argument {"set the `-force' option to overwrite an existing output file"}; + } + + audio_format.setSampleRate (sample_rate); + audio_format.setChannelCount (num_channels); + audio_format.setSampleSize (16); + audio_format.setSampleType (QAudioFormat::SignedInt); + audio_format.setCodec ("audio/pcm"); + + auto source = input_device ? input_devices[input_device - 1] : QAudioDeviceInfo::defaultInputDevice (); + if (!source.isFormatSupported (audio_format)) + { + qtout << "warning, requested format not supported, using nearest" << endl; + audio_format = source.nearestFormat (audio_format); + } + BWFFile output_file {audio_format, ofi.filePath ()}; + if (!output_file.open (BWFFile::WriteOnly)) throw std::invalid_argument {QString {"cannot open output file \"%1\""}.arg (ofi.filePath ()).toStdString ()}; + + // run the application + Record record {start, duration, source, &output_file, notify_interval, buffer_size}; + QObject::connect (&record, &Record::done, &app, &QCoreApplication::quit); + return app.exec(); + } + else // Playback + { + QFileInfo ifi {parser.value ("i")}; + if (!ifi.isFile () && !ifi.suffix ().size () && ifi.fileName ()[ifi.fileName ().size () - 1] != QChar {'.'}) + { + ifi.setFile (ifi.filePath () + ".wav"); + } + BWFFile input_file {audio_format, ifi.filePath ()}; + if (!input_file.open (BWFFile::ReadOnly)) throw std::invalid_argument {QString {"cannot open input file \"%1\""}.arg (ifi.filePath ()).toStdString ()}; + auto sink = output_device ? output_devices[output_device - 1] : QAudioDeviceInfo::defaultOutputDevice (); + if (!sink.isFormatSupported (input_file.format ())) + { + throw std::invalid_argument {"audio output device does not support input file audio format"}; + } + + // run the application + Playback play {start, &input_file, sink, notify_interval, buffer_size, parser.value ("category")}; + QObject::connect (&play, &Playback::done, &app, &QCoreApplication::quit); + return app.exec(); + } + } + catch (std::exception const& e) + { + std::cerr << "Error: " << e.what () << '\n'; + } + catch (...) + { + std::cerr << "Unexpected fatal error\n"; + throw; // hoping the runtime might tell us more about the exception + } + return -1; +} diff --git a/CMake/Modules/Findhamlib.cmake b/CMake/Modules/Findhamlib.cmake index 98419bda..234083ae 100644 --- a/CMake/Modules/Findhamlib.cmake +++ b/CMake/Modules/Findhamlib.cmake @@ -19,9 +19,12 @@ find_path (__hamlib_pc_path NAMES hamlib.pc PATH_SUFFIXES lib/pkgconfig lib64/pkgconfig ) if (__hamlib_pc_path) - set (ENV{PKG_CONFIG_PATH} "${__hamlib_pc_path}" "$ENV{PKG_CONFIG_PATH}") - unset (__hamlib_pc_path CACHE) + set (__pc_path $ENV{PKG_CONFIG_PATH}) + list (APPEND __pc_path "${__hamlib_pc_path}") + set (ENV{PKG_CONFIG_PATH} "${__pc_path}") + unset (__pc_path CACHE) endif () +unset (__hamlib_pc_path CACHE) # Use pkg-config to get hints about paths, libs and, flags unset (__pkg_config_checked_hamlib CACHE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fbb879d..a2d6dd39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,10 @@ if (POLICY CMP0063) cmake_policy (SET CMP0063 NEW) # honour visibility properties for all library types endif (POLICY CMP0063) +if (POLICY CMP0071) + cmake_policy (SET CMP0071 NEW) # run automoc and autouic on generated sources +endif (POLICY CMP0071) + include (${PROJECT_SOURCE_DIR}/CMake/VersionCompute.cmake) message (STATUS "Building ${CMAKE_PROJECT_NAME}-${wsjtx_VERSION}") @@ -233,6 +237,7 @@ set (wsjt_qt_CXXSRCS models/FrequencyList.cpp models/StationList.cpp widgets/FrequencyLineEdit.cpp + widgets/FrequencyDeltaLineEdit.cpp item_delegates/CandidateKeyFilter.cpp item_delegates/ForeignKeyDelegate.cpp validators/LiveFrequencyValidator.cpp @@ -275,9 +280,12 @@ set (wsjt_qt_CXXSRCS widgets/CabrilloLogWindow.cpp item_delegates/CallsignDelegate.cpp item_delegates/MaidenheadLocatorDelegate.cpp + item_delegates/FrequencyDelegate.cpp + item_delegates/FrequencyDeltaDelegate.cpp models/CabrilloLog.cpp logbook/AD1CCty.cpp logbook/WorkedBefore.cpp + logbook/Multiplier.cpp ) set (wsjt_qtmm_CXXSRCS @@ -383,9 +391,11 @@ set (wsjt_FSRCS lib/astro0.f90 lib/avecho.f90 lib/averms.f90 + lib/ft4/averaged_mf.f90 lib/azdist.f90 lib/badmsg.f90 lib/ft8/baseline.f90 + lib/ft4/ft4_baseline.f90 lib/bpdecode40.f90 lib/bpdecode128_90.f90 lib/ft8/bpdecode174_91.f90 @@ -564,7 +574,6 @@ set (wsjt_FSRCS lib/sync64.f90 lib/sync65.f90 lib/ft4/getcandidates4.f90 - lib/ft4/syncft4.f90 lib/ft8/sync8.f90 lib/ft8/sync8d.f90 lib/ft4/sync4d.f90 @@ -1283,12 +1292,18 @@ target_link_libraries (msk144sim wsjt_fort wsjt_cxx) add_executable (ft4sim lib/ft4/ft4sim.f90 wsjtx.rc) target_link_libraries (ft4sim wsjt_fort wsjt_cxx) +add_executable (averaged_mf lib/ft4/averaged_mf.f90 wsjtx.rc) +target_link_libraries (averaged_mf wsjt_fort wsjt_cxx) + add_executable (ft4sim_mult lib/ft4/ft4sim_mult.f90 wsjtx.rc) target_link_libraries (ft4sim_mult wsjt_fort wsjt_cxx) add_executable (ft4d lib/ft4/ft4d.f90 wsjtx.rc) target_link_libraries (ft4d wsjt_fort wsjt_cxx) +add_executable (record_time_signal Audio/tools/record_time_signal.cpp) +target_link_libraries (record_time_signal wsjt_cxx wsjt_qtmm wsjt_qt) + endif(WSJT_BUILD_UTILS) # build the main application diff --git a/Configuration.cpp b/Configuration.cpp index cce8db23..b78739d1 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -167,8 +167,11 @@ #include "MetaDataRegistry.hpp" #include "SettingsGroup.hpp" #include "widgets/FrequencyLineEdit.hpp" +#include "widgets/FrequencyDeltaLineEdit.hpp" #include "item_delegates/CandidateKeyFilter.hpp" #include "item_delegates/ForeignKeyDelegate.hpp" +#include "item_delegates/FrequencyDelegate.hpp" +#include "item_delegates/FrequencyDeltaDelegate.hpp" #include "TransceiverFactory.hpp" #include "Transceiver.hpp" #include "models/Bands.hpp" @@ -564,6 +567,7 @@ private: DecodeHighlightingModel decode_highlighing_model_; DecodeHighlightingModel next_decode_highlighing_model_; bool highlight_by_mode_; + bool include_WAE_entities_; int LotW_days_since_upload_; TransceiverFactory::ParameterPack rig_params_; @@ -609,6 +613,7 @@ private: bool miles_; bool quick_call_; bool disable_TX_on_73_; + bool force_call_1st_; bool alternate_bindings_; int watchdog_; bool TX_messages_; @@ -705,6 +710,7 @@ bool Configuration::clear_DX () const {return m_->clear_DX_;} bool Configuration::miles () const {return m_->miles_;} bool Configuration::quick_call () const {return m_->quick_call_;} bool Configuration::disable_TX_on_73 () const {return m_->disable_TX_on_73_;} +bool Configuration::force_call_1st() const {return m_->force_call_1st_;} bool Configuration::alternate_bindings() const {return m_->alternate_bindings_;} int Configuration::watchdog () const {return m_->watchdog_;} bool Configuration::TX_messages () const {return m_->TX_messages_;} @@ -716,6 +722,7 @@ bool Configuration::x2ToneSpacing() const {return m_->x2ToneSpacing_;} bool Configuration::x4ToneSpacing() const {return m_->x4ToneSpacing_;} bool Configuration::split_mode () const {return m_->split_mode ();} QString Configuration::opCall() const {return m_->opCall_;} +void Configuration::opCall (QString const& call) {m_->opCall_ = call;} QString Configuration::udp_server_name () const {return m_->udp_server_name_;} auto Configuration::udp_server_port () const -> port_type {return m_->udp_server_port_;} bool Configuration::accept_udp_requests () const {return m_->accept_udp_requests_;} @@ -742,6 +749,7 @@ bool Configuration::pwrBandTuneMemory () const {return m_->pwrBandTuneMemory_;} LotWUsers const& Configuration::lotw_users () const {return m_->lotw_users_;} DecodeHighlightingModel const& Configuration::decode_highlighting () const {return m_->decode_highlighing_model_;} bool Configuration::highlight_by_mode () const {return m_->highlight_by_mode_;} +bool Configuration::include_WAE_entities () const {return m_->include_WAE_entities_;} void Configuration::set_calibration (CalibrationParams params) { @@ -947,6 +955,7 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network , station_insert_action_ {tr ("&Insert ..."), nullptr} , station_dialog_ {new StationDialog {&next_stations_, &bands_, this}} , highlight_by_mode_ {false} + , include_WAE_entities_ {false} , LotW_days_since_upload_ {0} , last_port_type_ {TransceiverFactory::Capabilities::none} , rig_is_dummy_ {false} @@ -1116,9 +1125,7 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network ui_->frequencies_table_view->setColumnHidden (FrequencyList_v2::frequency_mhz_column, true); // delegates - auto frequencies_item_delegate = new QStyledItemDelegate {this}; - frequencies_item_delegate->setItemEditorFactory (item_editor_factory ()); - ui_->frequencies_table_view->setItemDelegate (frequencies_item_delegate); + ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList_v2::frequency_column, new FrequencyDelegate {this}); ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList_v2::region_column, new ForeignKeyDelegate {®ions_, 0, this}); ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList_v2::mode_column, new ForeignKeyDelegate {&modes_, 0, this}); @@ -1157,9 +1164,7 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network ui_->stations_table_view->sortByColumn (StationList::band_column, Qt::AscendingOrder); // stations delegates - auto stations_item_delegate = new QStyledItemDelegate {this}; - stations_item_delegate->setItemEditorFactory (item_editor_factory ()); - ui_->stations_table_view->setItemDelegate (stations_item_delegate); + ui_->stations_table_view->setItemDelegateForColumn (StationList::offset_column, new FrequencyDeltaDelegate {this}); ui_->stations_table_view->setItemDelegateForColumn (StationList::band_column, new ForeignKeyDelegate {&bands_, &next_stations_, 0, StationList::band_column, this}); // stations actions @@ -1242,6 +1247,7 @@ void Configuration::impl::initialize_models () ui_->miles_check_box->setChecked (miles_); ui_->quick_call_check_box->setChecked (quick_call_); ui_->disable_TX_on_73_check_box->setChecked (disable_TX_on_73_); + ui_->force_call_1st_check_box->setChecked (force_call_1st_); ui_->alternate_bindings_check_box->setChecked (alternate_bindings_); ui_->tx_watchdog_spin_box->setValue (watchdog_); ui_->TX_messages_check_box->setChecked (TX_messages_); @@ -1315,6 +1321,7 @@ void Configuration::impl::initialize_models () next_decode_highlighing_model_.items (decode_highlighing_model_.items ()); ui_->highlight_by_mode_check_box->setChecked (highlight_by_mode_); + ui_->include_WAE_check_box->setChecked (include_WAE_entities_); ui_->LotW_days_since_upload_spin_box->setValue (LotW_days_since_upload_); set_rig_invariants (); @@ -1463,6 +1470,7 @@ void Configuration::impl::read_settings () if (!highlight_items.size ()) highlight_items = DecodeHighlightingModel::default_items (); decode_highlighing_model_.items (highlight_items); highlight_by_mode_ = settings_->value("HighlightByMode", false).toBool (); + include_WAE_entities_ = settings_->value("IncludeWAEEntities", false).toBool (); LotW_days_since_upload_ = settings_->value ("LotWDaysSinceLastUpload", 365).toInt (); lotw_users_.set_age_constraint (LotW_days_since_upload_); @@ -1496,6 +1504,7 @@ void Configuration::impl::read_settings () miles_ = settings_->value ("Miles", false).toBool (); quick_call_ = settings_->value ("QuickCall", false).toBool (); disable_TX_on_73_ = settings_->value ("73TxDisable", false).toBool (); + force_call_1st_ = settings_->value ("ForceCallFirst", false).toBool (); alternate_bindings_ = settings_->value ("AlternateBindings", false).toBool (); watchdog_ = settings_->value ("TxWatchdog", 6).toInt (); TX_messages_ = settings_->value ("Tx2QSO", true).toBool (); @@ -1574,7 +1583,7 @@ void Configuration::impl::write_settings () settings_->setValue ("FrequenciesForRegionModes", QVariant::fromValue (frequencies_.frequency_list ())); settings_->setValue ("stations", QVariant::fromValue (stations_.station_list ())); settings_->setValue ("DecodeHighlighting", QVariant::fromValue (decode_highlighing_model_.items ())); - settings_->setValue ("HighlightByMode", highlight_by_mode_); + settings_->setValue ("IncludeWAEEntities", include_WAE_entities_); settings_->setValue ("LotWDaysSinceLastUpload", LotW_days_since_upload_); settings_->setValue ("toRTTY", log_as_RTTY_); settings_->setValue ("dBtoComments", report_in_comments_); @@ -1598,6 +1607,7 @@ void Configuration::impl::write_settings () settings_->setValue ("Miles", miles_); settings_->setValue ("QuickCall", quick_call_); settings_->setValue ("73TxDisable", disable_TX_on_73_); + settings_->setValue ("ForceCallFirst", force_call_1st_); settings_->setValue ("AlternateBindings", alternate_bindings_); settings_->setValue ("TxWatchdog", watchdog_); settings_->setValue ("Tx2QSO", TX_messages_); @@ -2042,6 +2052,7 @@ void Configuration::impl::accept () miles_ = ui_->miles_check_box->isChecked (); quick_call_ = ui_->quick_call_check_box->isChecked (); disable_TX_on_73_ = ui_->disable_TX_on_73_check_box->isChecked (); + force_call_1st_ = ui_->force_call_1st_check_box->isChecked (); alternate_bindings_ = ui_->alternate_bindings_check_box->isChecked (); watchdog_ = ui_->tx_watchdog_spin_box->value (); TX_messages_ = ui_->TX_messages_check_box->isChecked (); @@ -2109,6 +2120,7 @@ void Configuration::impl::accept () Q_EMIT self_->decode_highlighting_changed (decode_highlighing_model_); } highlight_by_mode_ = ui_->highlight_by_mode_check_box->isChecked (); + include_WAE_entities_ = ui_->include_WAE_check_box->isChecked (); LotW_days_since_upload_ = ui_->LotW_days_since_upload_spin_box->value (); lotw_users_.set_age_constraint (LotW_days_since_upload_); diff --git a/Configuration.hpp b/Configuration.hpp index 991e126f..80f5a5cd 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -127,6 +127,7 @@ public: bool miles () const; bool quick_call () const; bool disable_TX_on_73 () const; + bool force_call_1st() const; bool alternate_bindings() const; int watchdog () const; bool TX_messages () const; @@ -147,6 +148,7 @@ public: bool EMEonly() const; bool post_decodes () const; QString opCall() const; + void opCall (QString const&); QString udp_server_name () const; port_type udp_server_port () const; QString n1mm_server_name () const; @@ -175,6 +177,7 @@ public: LotWUsers const& lotw_users () const; DecodeHighlightingModel const& decode_highlighting () const; bool highlight_by_mode () const; + bool include_WAE_entities () const; enum class SpecialOperatingActivity {NONE, NA_VHF, EU_VHF, FIELD_DAY, RTTY, FOX, HOUND}; SpecialOperatingActivity special_op_id () const; diff --git a/Configuration.ui b/Configuration.ui index 36a96d66..a9fe51d4 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>546</width> - <height>536</height> + <height>553</height> </rect> </property> <property name="windowTitle"> @@ -301,7 +301,14 @@ <string>Behavior</string> </property> <layout class="QGridLayout" name="gridLayout_8"> - <item row="4" column="1"> + <item row="3" column="1"> + <widget class="QCheckBox" name="decode_at_52s_check_box"> + <property name="text"> + <string>Decode after EME delay</string> + </property> + </widget> + </item> + <item row="5" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_12"> <item> <spacer name="horizontalSpacer_7"> @@ -347,10 +354,27 @@ </item> </layout> </item> - <item row="3" column="1"> - <widget class="QCheckBox" name="decode_at_52s_check_box"> + <item row="0" column="1"> + <widget class="QCheckBox" name="enable_VHF_features_check_box"> <property name="text"> - <string>Decode after EME delay</string> + <string>Enable VHF/UHF/Microwave features</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="single_decode_check_box"> + <property name="text"> + <string>Single decode</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="tx_QSY_check_box"> + <property name="toolTip"> + <string><html><head/><body><p>Some rigs are not able to process CAT commands while transmitting. This means that if you are operating in split mode you may have to uncheck this option.</p></body></html></string> + </property> + <property name="text"> + <string>Allow Tx frequency changes while transmitting</string> </property> </widget> </item> @@ -367,31 +391,35 @@ </property> </widget> </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="single_decode_check_box"> + <item row="1" column="0"> + <widget class="QCheckBox" name="monitor_last_used_check_box"> + <property name="toolTip"> + <string><html><head/><body><p>Check this if you wish to automatically return to the last monitored frequency when monitor is enabled, leave it unchecked if you wish to have the current rig frequency maintained.</p></body></html></string> + </property> <property name="text"> - <string>Single decode</string> + <string>Monitor returns to last used frequency</string> </property> </widget> </item> - <item row="0" column="1"> - <widget class="QCheckBox" name="enable_VHF_features_check_box"> + <item row="5" column="0"> + <widget class="QCheckBox" name="alternate_bindings_check_box"> <property name="text"> - <string>Enable VHF/UHF/Microwave features</string> + <string>Alternate F1-F6 bindings</string> </property> </widget> </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="tx_QSY_check_box"> + <item row="3" column="0"> + <widget class="QCheckBox" name="disable_TX_on_73_check_box"> <property name="toolTip"> - <string><html><head/><body><p>Some rigs are not able to process CAT commands while transmitting. This means that if you are operating in split mode you may have to uncheck this option.</p></body></html></string> + <string>Turns off automatic transmissions after sending a 73 or any other free +text message.</string> </property> <property name="text"> - <string>Allow Tx frequency changes while transmitting</string> + <string>Di&sable Tx after sending 73</string> </property> </widget> </item> - <item row="6" column="0" colspan="2"> + <item row="7" column="0" colspan="2"> <layout class="QHBoxLayout" name="horizontalLayout_9"> <item> <widget class="QCheckBox" name="CW_id_after_73_check_box"> @@ -444,41 +472,20 @@ quiet period when decoding is done.</string> </item> </layout> </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="monitor_last_used_check_box"> + <item row="2" column="0"> + <widget class="QCheckBox" name="quick_call_check_box"> <property name="toolTip"> - <string><html><head/><body><p>Check this if you wish to automatically return to the last monitored frequency when monitor is enabled, leave it unchecked if you wish to have the current rig frequency maintained.</p></body></html></string> + <string>Automatic transmission mode.</string> </property> <property name="text"> - <string>Monitor returns to last used frequency</string> + <string>Doubl&e-click on call sets Tx enable</string> </property> </widget> </item> <item row="4" column="0"> - <widget class="QCheckBox" name="alternate_bindings_check_box"> - <property name="text"> - <string>Alternate F1-F6 bindings</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="disable_TX_on_73_check_box"> - <property name="toolTip"> - <string>Turns off automatic transmissions after sending a 73 or any other free -text message.</string> - </property> + <widget class="QCheckBox" name="force_call_1st_check_box"> <property name="text"> - <string>Di&sable Tx after sending 73</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="quick_call_check_box"> - <property name="toolTip"> - <string>Automatic transmission mode.</string> - </property> - <property name="text"> - <string>Doubl&e-click on call sets Tx enable</string> + <string>Calling CQ forces Call 1st</string> </property> </widget> </item> @@ -1912,7 +1919,7 @@ for assessing propagation and system performance.</string> <item> <widget class="QGroupBox" name="n1mm_group_box"> <property name="title"> - <string>N1MM Logger+ Broadcasts</string> + <string>Secondary UDP Server (deprecated)</string> </property> <layout class="QFormLayout" name="formLayout_15"> <item row="0" column="0" colspan="2"> @@ -1928,7 +1935,7 @@ for assessing propagation and system performance.</string> <item row="1" column="0"> <widget class="QLabel" name="n1mm_server_name_label"> <property name="text"> - <string><html><head/><body><p>N1MM Server name or IP address:</p></body></html></string> + <string>Server name or IP address:</string> </property> <property name="buddy"> <cstring>n1mm_server_name_line_edit</cstring> @@ -1945,7 +1952,7 @@ for assessing propagation and system performance.</string> <item row="2" column="0"> <widget class="QLabel" name="n1mm_server_port_label"> <property name="text"> - <string><html><head/><body><p>N1MM Server port number:</p></body></html></string> + <string>Server port number:</string> </property> <property name="buddy"> <cstring>n1mm_server_port_spin_box</cstring> @@ -2287,6 +2294,23 @@ Right click for insert and delete options.</string> </item> </layout> </item> + <item> + <layout class="QFormLayout" name="formLayout_20"> + <item row="0" column="0"> + <widget class="QCheckBox" name="include_WAE_check_box"/> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="includeExtraWAEEntitiesLabel"> + <property name="text"> + <string>Include extra WAE entities</string> + </property> + <property name="buddy"> + <cstring>include_WAE_check_box</cstring> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> @@ -2299,35 +2323,6 @@ Right click for insert and delete options.</string> <string>Logbook of the World User Validation</string> </property> <layout class="QFormLayout" name="formLayout_18"> - <item row="2" column="0"> - <widget class="QLabel" name="label_14"> - <property name="text"> - <string>Age of last upload less than:</string> - </property> - <property name="buddy"> - <cstring>LotW_days_since_upload_spin_box</cstring> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QSpinBox" name="LotW_days_since_upload_spin_box"> - <property name="toolTip"> - <string><html><head/><body><p>Adjust this spin box to set the age threshold of LotW user's last upload date that is accepted as a current LotW user.</p></body></html></string> - </property> - <property name="suffix"> - <string> days</string> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>9999</number> - </property> - <property name="value"> - <number>365</number> - </property> - </widget> - </item> <item row="1" column="0"> <widget class="QLabel" name="label_15"> <property name="text"> @@ -2362,6 +2357,35 @@ Right click for insert and delete options.</string> </item> </layout> </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_14"> + <property name="text"> + <string>Age of last upload less than:</string> + </property> + <property name="buddy"> + <cstring>LotW_days_since_upload_spin_box</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="LotW_days_since_upload_spin_box"> + <property name="toolTip"> + <string><html><head/><body><p>Adjust this spin box to set the age threshold of LotW user's last upload date that is accepted as a current LotW user.</p></body></html></string> + </property> + <property name="suffix"> + <string> days</string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>9999</number> + </property> + <property name="value"> + <number>365</number> + </property> + </widget> + </item> </layout> </widget> </item> @@ -2469,7 +2493,7 @@ Right click for insert and delete options.</string> <item row="1" column="0" colspan="2"> <widget class="QGroupBox" name="gbSpecialOpActivity"> <property name="title"> - <string>Special operating activity: Generation of FT8 and MSK144 messages</string> + <string>Special operating activity: Generation of FT4, FT8, and MSK144 messages</string> </property> <property name="checkable"> <bool>true</bool> @@ -3078,13 +3102,13 @@ Right click for insert and delete options.</string> </connection> </connections> <buttongroups> - <buttongroup name="TX_mode_button_group"/> + <buttongroup name="special_op_activity_button_group"/> <buttongroup name="CAT_data_bits_button_group"/> - <buttongroup name="CAT_handshake_button_group"/> - <buttongroup name="PTT_method_button_group"/> <buttongroup name="split_mode_button_group"/> + <buttongroup name="TX_mode_button_group"/> + <buttongroup name="PTT_method_button_group"/> <buttongroup name="CAT_stop_bits_button_group"/> - <buttongroup name="special_op_activity_button_group"/> + <buttongroup name="CAT_handshake_button_group"/> <buttongroup name="TX_audio_source_button_group"/> </buttongroups> </ui> diff --git a/DXLabSuiteCommanderTransceiver.cpp b/DXLabSuiteCommanderTransceiver.cpp index 4e9270cf..d745ec17 100644 --- a/DXLabSuiteCommanderTransceiver.cpp +++ b/DXLabSuiteCommanderTransceiver.cpp @@ -127,7 +127,7 @@ int DXLabSuiteCommanderTransceiver::do_start () throw error {tr ("DX Lab Suite Commander didn't respond correctly reading frequency: ") + reply}; } - poll (); + do_poll (); return resolution; } @@ -247,7 +247,7 @@ void DXLabSuiteCommanderTransceiver::do_mode (MODE m) update_mode (m); } -void DXLabSuiteCommanderTransceiver::poll () +void DXLabSuiteCommanderTransceiver::do_poll () { #if WSJT_TRACE_CAT && WSJT_TRACE_CAT_POLLS bool quiet {false}; diff --git a/DXLabSuiteCommanderTransceiver.hpp b/DXLabSuiteCommanderTransceiver.hpp index b02fbef1..1196678b 100644 --- a/DXLabSuiteCommanderTransceiver.hpp +++ b/DXLabSuiteCommanderTransceiver.hpp @@ -39,7 +39,7 @@ protected: void do_mode (MODE) override; void do_ptt (bool on) override; - void poll () override; + void do_poll () override; private: MODE get_mode (bool no_debug = false); diff --git a/Detector.cpp b/Detector.cpp index 69a10f5e..05a631b1 100644 --- a/Detector.cpp +++ b/Detector.cpp @@ -2,6 +2,7 @@ #include <QDateTime> #include <QtAlgorithms> #include <QDebug> +#include <math.h> #include "commons.h" #include "moc_Detector.cpp" @@ -10,7 +11,7 @@ extern "C" { void fil4_(qint16*, qint32*, qint16*, qint32*); } -Detector::Detector (unsigned frameRate, unsigned periodLengthInSeconds, +Detector::Detector (unsigned frameRate, double periodLengthInSeconds, unsigned downSampleFactor, QObject * parent) : AudioDevice (parent) , m_frameRate (frameRate) @@ -54,12 +55,14 @@ void Detector::clear () qint64 Detector::writeData (char const * data, qint64 maxSize) { - int ns=secondInPeriod(); - if(ns < m_ns) { // When ns has wrapped around to zero, restart the buffers + static unsigned mstr0=999999; + qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000; + unsigned mstr = ms0 % int(1000.0*m_period); // ms into the nominal Tx start time + if(mstr < mstr0) { //When mstr has wrapped around to 0, restart the buffer dec_data.params.kin = 0; m_bufferPos = 0; } - m_ns=ns; + mstr0=mstr; // no torn frames Q_ASSERT (!(maxSize % static_cast<qint64> (bytesPerFrame ()))); @@ -72,7 +75,7 @@ qint64 Detector::writeData (char const * data, qint64 maxSize) if (framesAccepted < static_cast<size_t> (maxSize / bytesPerFrame ())) { qDebug () << "dropped " << maxSize / bytesPerFrame () - framesAccepted << " frames of data on the floor!" - << dec_data.params.kin << ns; + << dec_data.params.kin << mstr; } for (unsigned remaining = framesAccepted; remaining; ) { @@ -120,13 +123,3 @@ qint64 Detector::writeData (char const * data, qint64 maxSize) return maxSize; // we drop any data past the end of the buffer on // the floor until the next period starts } - -unsigned Detector::secondInPeriod () const -{ - // we take the time of the data as the following assuming no latency - // delivering it to us (not true but close enough for us) - qint64 now (QDateTime::currentMSecsSinceEpoch ()); - - unsigned secondInToday ((now % 86400000LL) / 1000); - return secondInToday % m_period; -} diff --git a/Detector.hpp b/Detector.hpp index d5e5b0a3..4d584c13 100644 --- a/Detector.hpp +++ b/Detector.hpp @@ -22,9 +22,10 @@ public: // // the samplesPerFFT argument is the number after down sampling // - Detector (unsigned frameRate, unsigned periodLengthInSeconds, unsigned downSampleFactor = 4u, QObject * parent = 0); + Detector (unsigned frameRate, double periodLengthInSeconds, unsigned downSampleFactor = 4u, + QObject * parent = 0); - void setTRPeriod(unsigned p) {m_period=p;} + void setTRPeriod(double p) {m_period=p;} bool reset () override; Q_SIGNAL void framesWritten (qint64) const; @@ -40,10 +41,9 @@ protected: private: void clear (); // discard buffer contents - unsigned secondInPeriod () const; unsigned m_frameRate; - unsigned m_period; + double m_period; unsigned m_downSampleFactor; qint32 m_samplesPerFFT; // after any down sampling qint32 m_ns; diff --git a/HRDTransceiver.cpp b/HRDTransceiver.cpp index 3b9f90e2..c4491414 100644 --- a/HRDTransceiver.cpp +++ b/HRDTransceiver.cpp @@ -885,7 +885,7 @@ bool HRDTransceiver::is_button_checked (int button_index, bool no_debug) return "1" == reply; } -void HRDTransceiver::poll () +void HRDTransceiver::do_poll () { #if WSJT_TRACE_CAT && WSJT_TRACE_CAT_POLLS bool quiet {false}; diff --git a/HRDTransceiver.hpp b/HRDTransceiver.hpp index e17134d5..6ccd72d5 100644 --- a/HRDTransceiver.hpp +++ b/HRDTransceiver.hpp @@ -48,7 +48,7 @@ protected: void do_ptt (bool on) override; // Implement the PollingTransceiver interface. - void poll () override; + void do_poll () override; private: QString send_command (QString const&, bool no_debug = false, bool prepend_context = true, bool recurse = false); diff --git a/HamlibTransceiver.cpp b/HamlibTransceiver.cpp index f2e55bb4..da0623e2 100644 --- a/HamlibTransceiver.cpp +++ b/HamlibTransceiver.cpp @@ -632,7 +632,7 @@ int HamlibTransceiver::do_start () resolution = -1; // best guess } - poll (); + do_poll (); TRACE_CAT ("HamlibTransceiver", "exit" << state () << "reversed =" << reversed_ << "resolution = " << resolution); return resolution; @@ -898,7 +898,7 @@ void HamlibTransceiver::do_mode (MODE mode) update_mode (mode); } -void HamlibTransceiver::poll () +void HamlibTransceiver::do_poll () { #if !WSJT_TRACE_CAT_POLLS #if defined (NDEBUG) diff --git a/HamlibTransceiver.hpp b/HamlibTransceiver.hpp index c8c0f74d..17f1c28d 100644 --- a/HamlibTransceiver.hpp +++ b/HamlibTransceiver.hpp @@ -40,7 +40,7 @@ class HamlibTransceiver final void do_mode (MODE) override; void do_ptt (bool) override; - void poll () override; + void do_poll () override; void error_check (int ret_code, QString const& doing) const; void set_conf (char const * item, char const * value); diff --git a/MessageClient.cpp b/MessageClient.cpp index 5bf23294..6e2ea795 100644 --- a/MessageClient.cpp +++ b/MessageClient.cpp @@ -527,7 +527,7 @@ void MessageClient::logged_ADIF (QByteArray const& ADIF_record) { QByteArray message; NetworkMessage::Builder out {&message, NetworkMessage::LoggedADIF, m_->id_, m_->schema_}; - QByteArray ADIF {"\n<adif_ver:5>3.0.7\n<programid:6>WSJT-X\n<EOH>\n" + ADIF_record + " <EOR>"}; + QByteArray ADIF {"\n<adif_ver:5>3.1.0\n<programid:6>WSJT-X\n<EOH>\n" + ADIF_record + " <EOR>"}; out << ADIF; TRACE_UDP ("ADIF:" << ADIF); m_->send_message (out, message); diff --git a/MetaDataRegistry.cpp b/MetaDataRegistry.cpp index bf2aab5d..e66a4300 100644 --- a/MetaDataRegistry.cpp +++ b/MetaDataRegistry.cpp @@ -14,16 +14,35 @@ #include "WFPalette.hpp" #include "models/IARURegions.hpp" #include "models/DecodeHighlightingModel.hpp" -#include "widgets/FrequencyLineEdit.hpp" +#include "widgets/DateTimeEdit.hpp" -QItemEditorFactory * item_editor_factory () +namespace { - static QItemEditorFactory * our_item_editor_factory = new QItemEditorFactory; - return our_item_editor_factory; + class ItemEditorFactory final + : public QItemEditorFactory + { + public: + ItemEditorFactory () + : default_factory_ {QItemEditorFactory::defaultFactory ()} + { + } + + QWidget * createEditor (int user_type, QWidget * parent) const override + { + auto editor = QItemEditorFactory::createEditor (user_type, parent); + return editor ? editor : default_factory_->createEditor (user_type, parent); + } + + private: + QItemEditorFactory const * default_factory_; + }; } void register_types () { + auto item_editor_factory = new ItemEditorFactory; + QItemEditorFactory::setDefaultFactory (item_editor_factory); + // types in Radio.hpp are registered in their own translation unit // as they are needed in the wsjtx_udp shared library too @@ -31,9 +50,7 @@ void register_types () // used as signal/slot connection arguments since the new Qt 5.5 // Q_ENUM macro only seems to register the unqualified name - item_editor_factory ()->registerEditor (qMetaTypeId<Radio::Frequency> (), new QStandardItemEditorCreator<FrequencyLineEdit> ()); - //auto frequency_delta_type_id = qRegisterMetaType<Radio::FrequencyDelta> ("FrequencyDelta"); - item_editor_factory ()->registerEditor (qMetaTypeId<Radio::FrequencyDelta> (), new QStandardItemEditorCreator<FrequencyDeltaLineEdit> ()); + item_editor_factory->registerEditor (qMetaTypeId<QDateTime> (), new QStandardItemEditorCreator<DateTimeEdit> ()); // Frequency list model qRegisterMetaTypeStreamOperators<FrequencyList_v2::Item> ("Item_v2"); diff --git a/MetaDataRegistry.hpp b/MetaDataRegistry.hpp index 43000d20..8bf3c80d 100644 --- a/MetaDataRegistry.hpp +++ b/MetaDataRegistry.hpp @@ -1,9 +1,6 @@ #ifndef META_DATA_REGISTRY_HPP__ #define META_DATA_REGISTRY_HPP__ -class QItemEditorFactory; - -QItemEditorFactory * item_editor_factory (); void register_types (); #endif diff --git a/Modulator.cpp b/Modulator.cpp index 725de9e4..4d017177 100644 --- a/Modulator.cpp +++ b/Modulator.cpp @@ -25,15 +25,15 @@ double constexpr Modulator::m_twoPi; // unsigned m_nspd=1.2*48000.0/wpm; // m_nspd=3072; //18.75 WPM -Modulator::Modulator (unsigned frameRate, unsigned periodLengthInSeconds, +Modulator::Modulator (unsigned frameRate, double periodLengthInSeconds, QObject * parent) : AudioDevice {parent} , m_quickClose {false} , m_phi {0.0} , m_toneSpacing {0.0} , m_fSpread {0.0} - , m_frameRate {frameRate} , m_period {periodLengthInSeconds} + , m_frameRate {frameRate} , m_state {Idle} , m_tuning {false} , m_cwLevel {false} @@ -45,19 +45,15 @@ Modulator::Modulator (unsigned frameRate, unsigned periodLengthInSeconds, void Modulator::start (unsigned symbolsLength, double framesPerSymbol, double frequency, double toneSpacing, SoundOutput * stream, Channel channel, - bool synchronize, bool fastMode, double dBSNR, int TRperiod) + bool synchronize, bool fastMode, double dBSNR, double TRperiod) { Q_ASSERT (stream); // Time according to this computer which becomes our base time qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000; + unsigned mstr = ms0 % int(1000.0*m_period); // ms into the nominal Tx start time -// qDebug() << "ModStart" << symbolsLength << framesPerSymbol -// << frequency << toneSpacing; - - if(m_state != Idle) stop (); - + if(m_state != Idle) stop(); m_quickClose = false; - m_symbolsLength = symbolsLength; m_isym0 = std::numeric_limits<unsigned>::max (); // big number m_frequency0 = 0.; @@ -69,37 +65,33 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol, m_toneSpacing = toneSpacing; m_bFastMode=fastMode; m_TRperiod=TRperiod; - unsigned delay_ms = 1920 == m_nsps && 15 == m_period ? 500 : 1000; + unsigned delay_ms=1000; + if(m_nsps==1920) delay_ms=500; //FT8 + if(m_nsps==576) delay_ms=300; //FT4 - // noise generator parameters +// noise generator parameters if (m_addNoise) { m_snr = qPow (10.0, 0.05 * (dBSNR - 6.0)); m_fac = 3000.0; if (m_snr > 1.0) m_fac = 3000.0 / m_snr; } - unsigned mstr = ms0 % (1000 * m_period); // ms in period - - // round up to an exact portion of a second that allows for startup - // delays +// round up to an exact portion of a second that allows for startup delays m_ic = (mstr / delay_ms) * m_frameRate * delay_ms / 1000; if(m_bFastMode) m_ic=0; m_silentFrames = 0; - // calculate number of silent frames to send, so that audio will start at - // the nominal time "delay_ms" into the Tx sequence. +// calculate number of silent frames to send, so that audio will start at +// the nominal time "delay_ms" into the Tx sequence. if (synchronize && !m_tuning && !m_bFastMode) { m_silentFrames = m_ic + m_frameRate / (1000 / delay_ms) - (mstr * (m_frameRate / 1000)); } - if(symbolsLength==105 and framesPerSymbol==512 - and (toneSpacing==12000.0/512.0 or toneSpacing==-2.0)) { -//### FT4 parameters - m_ic=0; - m_silentFrames=0; - } -// qDebug() << "Mod AA" << symbolsLength << framesPerSymbol << toneSpacing; -// qDebug() << "Mod AB" << delay_ms << mstr << m_ic << m_silentFrames; + +// qDebug() << "aa" << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.zzz") +// << m_ic << m_silentFrames << m_silentFrames/48000.0 +// << mstr << fmod(double(ms0),1000.0*m_period); + initialize (QIODevice::ReadOnly, channel); Q_EMIT stateChanged ((m_state = (synchronize && m_silentFrames) ? @@ -183,12 +175,12 @@ qint64 Modulator::readData (char * data, qint64 maxSize) if(!m_tuning) isym=m_ic/(4.0*m_nsps); // Actual fsample=48000 bool slowCwId=((isym >= m_symbolsLength) && (icw[0] > 0)) && (!m_bFastMode); - if(m_TRperiod==3) slowCwId=false; + if(m_TRperiod==3.0) slowCwId=false; bool fastCwId=false; static bool bCwId=false; qint64 ms = QDateTime::currentMSecsSinceEpoch(); - float tsec=0.001*(ms % (1000*m_TRperiod)); - if(m_bFastMode and (icw[0]>0) and (tsec>(m_TRperiod-5.0))) fastCwId=true; + float tsec=0.001*(ms % int(1000*m_TRperiod)); + if(m_bFastMode and (icw[0]>0) and (tsec > (m_TRperiod-5.0))) fastCwId=true; if(!m_bFastMode) m_nspd=2560; // 22.5 WPM // qDebug() << "Mod A" << m_ic << isym << tsec; @@ -259,7 +251,7 @@ qint64 Modulator::readData (char * data, qint64 maxSize) i1= m_symbolsLength * 4.0 * m_nsps; } if(m_bFastMode and !m_tuning) { - i1=m_TRperiod*48000 - 24000; + i1=m_TRperiod*48000.0 - 24000.0; i0=i1-816; } @@ -267,7 +259,7 @@ qint64 Modulator::readData (char * data, qint64 maxSize) for (unsigned i = 0; i < numFrames && m_ic <= i1; ++i) { isym=0; - if(!m_tuning and m_TRperiod!=3) isym=m_ic/(4.0*m_nsps); //Actual fsample=48000 + if(!m_tuning and m_TRperiod!=3.0) isym=m_ic/(4.0*m_nsps); //Actual fsample=48000 if(m_bFastMode) isym=isym%m_symbolsLength; if (isym != m_isym0 || m_frequency != m_frequency0) { if(itone[0]>=100) { diff --git a/Modulator.hpp b/Modulator.hpp index e8df7f2d..3371cbe5 100644 --- a/Modulator.hpp +++ b/Modulator.hpp @@ -23,7 +23,7 @@ class Modulator public: enum ModulatorState {Synchronizing, Active, Idle}; - Modulator (unsigned frameRate, unsigned periodLengthInSeconds, QObject * parent = nullptr); + Modulator (unsigned frameRate, double periodLengthInSeconds, QObject * parent = nullptr); void close () override; @@ -31,14 +31,14 @@ public: double frequency () const {return m_frequency;} bool isActive () const {return m_state != Idle;} void setSpread(double s) {m_fSpread=s;} - void setTRPeriod(unsigned p) {m_period=p;} + void setTRPeriod(double p) {m_period=p;} void set_nsym(int n) {m_symbolsLength=n;} void set_ms0(qint64 ms) {m_ms0=ms;} Q_SLOT void start (unsigned symbolsLength, double framesPerSymbol, double frequency, double toneSpacing, SoundOutput *, Channel = Mono, bool synchronize = true, bool fastMode = false, - double dBSNR = 99., int TRperiod=60); + double dBSNR = 99., double TRperiod=60.0); Q_SLOT void stop (bool quick = false); Q_SLOT void tune (bool newState = true); Q_SLOT void setFrequency (double newFrequency) {m_frequency = newFrequency;} @@ -72,14 +72,14 @@ private: double m_fac; double m_toneSpacing; double m_fSpread; + double m_TRperiod; + double m_period; qint64 m_silentFrames; qint64 m_ms0; - qint32 m_TRperiod; qint16 m_ramp; unsigned m_frameRate; - unsigned m_period; ModulatorState volatile m_state; bool volatile m_tuning; diff --git a/OmniRigTransceiver.cpp b/OmniRigTransceiver.cpp index 09f1e5cf..4d3bbf1f 100644 --- a/OmniRigTransceiver.cpp +++ b/OmniRigTransceiver.cpp @@ -4,6 +4,7 @@ #include <QDebug> #include <objbase.h> #include <QThread> +#include <QEventLoop> #include "qt_helpers.hpP" @@ -109,6 +110,15 @@ OmniRigTransceiver::OmniRigTransceiver (std::unique_ptr<TransceiverBase> wrapped { } +// returns false on time out +bool OmniRigTransceiver::await_notification_with_timeout (int timeout) +{ + QEventLoop el; + connect (this, &OmniRigTransceiver::notified, &el, [&el] () {el.exit (1);}); + QTimer::singleShot (timeout, Qt::CoarseTimer, &el, [&el] () {el.exit (0);}); + return 1 == el.exec (); // wait for notify or timer +} + int OmniRigTransceiver::do_start () { TRACE_CAT ("OmniRigTransceiver", "starting"); @@ -182,101 +192,97 @@ int OmniRigTransceiver::do_start () .arg (readable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0')) .arg (rig_number_).toLocal8Bit ()); - - offline_timer_.reset (new QTimer); - offline_timer_->setSingleShot (true); - offline_timer_->setInterval (5 * 1000); - connect (&*offline_timer_, &QTimer::timeout, this, &OmniRigTransceiver::timeout_check); - - for (unsigned tries {0}; tries < 10; ++tries) + if (OmniRig::ST_ONLINE != rig_->Status ()) + { + throw_qstring ("OmniRig: " + rig_->StatusStr ()); + } + await_notification_with_timeout (1000); + update_rx_frequency (rig_->GetRxFrequency ()); + qDebug () << "Initial state:" << state (); + int resolution {0}; + if (OmniRig::PM_UNKNOWN == rig_->Vfo () + && (writable_params_ & (OmniRig::PM_VFOA | OmniRig::PM_VFOB)) + == (OmniRig::PM_VFOA | OmniRig::PM_VFOB)) + { + // start with VFO A (probably MAIN) on rigs that we + // can't query VFO but can set explicitly + rig_->SetVfo (OmniRig::PM_VFOA); + } + auto f = state ().frequency (); + if (f % 10) return resolution; // 1Hz resolution + auto test_frequency = f - f % 100 + 55; + if (OmniRig::PM_FREQ & writable_params_) + { + rig_->SetFreq (test_frequency); + } + else if (reversed_ && (OmniRig::PM_FREQB & writable_params_)) + { + rig_->SetFreqB (test_frequency); + } + else if (!reversed_ && (OmniRig::PM_FREQA & writable_params_)) + { + rig_->SetFreqA (test_frequency); + } + else + { + throw_qstring (tr ("OmniRig: don't know how to set rig frequency")); + } + if (!await_notification_with_timeout (1000)) + { + TRACE_CAT ("OmniRigTransceiver", "do_start 1: wait timed out"); + throw_qstring (tr ("OmniRig: timeout waiting for update from rig")); + } + switch (rig_->GetRxFrequency () - test_frequency) + { + case -5: resolution = -1; break; // 10Hz truncated + case 5: resolution = 1; break; // 10Hz rounded + case -15: resolution = -2; break; // 20Hz truncated + case -55: resolution = -2; break; // 100Hz truncated + case 45: resolution = 2; break; // 100Hz rounded + } + if (1 == resolution) // may be 20Hz rounded { - QThread::msleep (100); // wait until OmniRig polls the rig - auto f = rig_->GetRxFrequency (); - int resolution {0}; - if (f) + test_frequency = f - f % 100 + 51; + if (OmniRig::PM_FREQ & writable_params_) { - if (OmniRig::PM_UNKNOWN == rig_->Vfo () - && (writable_params_ & (OmniRig::PM_VFOA | OmniRig::PM_VFOB)) - == (OmniRig::PM_VFOA | OmniRig::PM_VFOB)) - { - // start with VFO A (probably MAIN) on rigs that we - // can't query VFO but can set explicitly - rig_->SetVfo (OmniRig::PM_VFOA); - } - if (f % 10) return resolution; // 1Hz resolution - auto test_frequency = f - f % 100 + 55; - if (OmniRig::PM_FREQ & writable_params_) - { - rig_->SetFreq (test_frequency); - } - else if (reversed_ && (OmniRig::PM_FREQB & writable_params_)) - { - rig_->SetFreqB (test_frequency); - } - else if (!reversed_ && (OmniRig::PM_FREQA & writable_params_)) - { - rig_->SetFreqA (test_frequency); - } - else - { - throw_qstring (tr ("OmniRig: don't know how to set rig frequency")); - } - switch (rig_->GetRxFrequency () - test_frequency) - { - case -5: resolution = -1; break; // 10Hz truncated - case 5: resolution = 1; break; // 10Hz rounded - case -15: resolution = -2; break; // 20Hz truncated - case -55: resolution = -2; break; // 100Hz truncated - case 45: resolution = 2; break; // 100Hz rounded - } - if (1 == resolution) // may be 20Hz rounded - { - test_frequency = f - f % 100 + 51; - if (OmniRig::PM_FREQ & writable_params_) - { - rig_->SetFreq (test_frequency); - } - else if (reversed_ && (OmniRig::PM_FREQB & writable_params_)) - { - rig_->SetFreqB (test_frequency); - } - else if (!reversed_ && (OmniRig::PM_FREQA & writable_params_)) - { - rig_->SetFreqA (test_frequency); - } - if (9 == rig_->GetRxFrequency () - test_frequency) - { - resolution = 2; // 20Hz rounded - } - } - if (OmniRig::PM_FREQ & writable_params_) - { - rig_->SetFreq (f); - } - else if (reversed_ && (OmniRig::PM_FREQB & writable_params_)) - { - rig_->SetFreqB (f); - } - else if (!reversed_ && (OmniRig::PM_FREQA & writable_params_)) - { - rig_->SetFreqA (f); - } - update_rx_frequency (f); - return resolution; + rig_->SetFreq (test_frequency); } + else if (reversed_ && (OmniRig::PM_FREQB & writable_params_)) + { + rig_->SetFreqB (test_frequency); + } + else if (!reversed_ && (OmniRig::PM_FREQA & writable_params_)) + { + rig_->SetFreqA (test_frequency); + } + if (!await_notification_with_timeout (2000)) + { + TRACE_CAT ("OmniRigTransceiver", "do_start 2: wait timed out"); + throw_qstring (tr ("OmniRig: timeout waiting for update from rig")); + } + if (9 == rig_->GetRxFrequency () - test_frequency) + { + resolution = 2; // 20Hz rounded + } + } + if (OmniRig::PM_FREQ & writable_params_) + { + rig_->SetFreq (f); + } + else if (reversed_ && (OmniRig::PM_FREQB & writable_params_)) + { + rig_->SetFreqB (f); } - throw_qstring (tr ("OmniRig: Initialization timed out")); - return 0; // keep compiler happy + else if (!reversed_ && (OmniRig::PM_FREQA & writable_params_)) + { + rig_->SetFreqA (f); + } + update_rx_frequency (f); + return resolution; } void OmniRigTransceiver::do_stop () { - if (offline_timer_) - { - offline_timer_->stop (); - offline_timer_.reset (); - } - QThread::msleep (200); // leave some time for pending // commands at the server end if (port_) @@ -300,17 +306,6 @@ void OmniRigTransceiver::do_stop () TRACE_CAT ("OmniRigTransceiver", "stopped"); } -void OmniRigTransceiver::do_sync (bool force_signal, bool /*no_poll*/) -{ - // nothing much we can do here, we just have to let OmniRig do its - // stuff and its first poll should send us and update that will - // trigger a update signal from us. Any attempt to query OmniRig - // leads to a whole mess of trouble since its internal state is - // garbage until it has done its first rig poll. - send_update_signal_ = force_signal; - update_complete (); -} - void OmniRigTransceiver::handle_COM_exception (int code, QString source, QString desc, QString help) { TRACE_CAT ("OmniRigTransceiver", QString::number (code) + " at " + source + ": " + desc + " (" + help + ')'); @@ -319,16 +314,20 @@ void OmniRigTransceiver::handle_COM_exception (int code, QString source, QString void OmniRigTransceiver::handle_visible_change () { + if (!omni_rig_ || omni_rig_->isNull ()) return; TRACE_CAT ("OmniRigTransceiver", "visibility change: visibility =" << omni_rig_->DialogVisible ()); } void OmniRigTransceiver::handle_rig_type_change (int rig_number) { + if (!omni_rig_ || omni_rig_->isNull ()) return; + TRACE_CAT ("OmniRigTransceiver", "rig type change: rig =" << rig_number); if (rig_number_ == rig_number) { + if (!rig_ || rig_->isNull ()) return; readable_params_ = rig_->ReadableParams (); writable_params_ = rig_->WriteableParams (); - TRACE_CAT ("OmniRigTransceiver", QString {"OmniRig rig type change to: %1 readable params = 0x%2 writable params = 0x%3 for rig %4"} + TRACE_CAT ("OmniRigTransceiver", QString {"rig type change to: %1 readable params = 0x%2 writable params = 0x%3 for rig %4"} .arg (rig_->RigType ()) .arg (readable_params_, 8, 16, QChar ('0')) .arg (writable_params_, 8, 16, QChar ('0')) @@ -338,48 +337,43 @@ void OmniRigTransceiver::handle_rig_type_change (int rig_number) void OmniRigTransceiver::handle_status_change (int rig_number) { + if (!omni_rig_ || omni_rig_->isNull ()) return; + TRACE_CAT ("OmniRigTransceiver", QString {"status change for rig %1"}.arg (rig_number).toLocal8Bit ()); if (rig_number_ == rig_number) { + if (!rig_ || rig_->isNull ()) return; auto const& status = rig_->StatusStr ().toLocal8Bit (); - TRACE_CAT ("OmniRigTransceiver", QString {"OmniRig status change: new status for rig %1 = "}.arg (rig_number).toLocal8Bit () << status); + TRACE_CAT ("OmniRigTransceiver", "OmniRig status change: new status = " << status); if (OmniRig::ST_ONLINE != rig_->Status ()) { - if (!offline_timer_->isActive ()) - { - offline_timer_->start (); // give OmniRig time to recover - } - } - else - { - offline_timer_->stop (); - update_rx_frequency (rig_->GetRxFrequency ()); - update_complete (); - TRACE_CAT ("OmniRigTransceiver", "OmniRig frequency:" << state ().frequency ()); + offline ("Rig went offline"); } + // else + // { + // update_rx_frequency (rig_->GetRxFrequency ()); + // update_complete (); + // TRACE_CAT ("OmniRigTransceiver", "frequency:" << state ().frequency ()); + // } } } -void OmniRigTransceiver::timeout_check () -{ - offline ("Rig went offline"); -} - void OmniRigTransceiver::handle_params_change (int rig_number, int params) { - if (rig_number_ == rig_number) - { - TRACE_CAT ("OmniRigTransceiver", QString {"OmniRig params change: params = 0x%1 for rig %2"} + if (!omni_rig_ || omni_rig_->isNull ()) return; + TRACE_CAT ("OmniRigTransceiver", QString {"params change: params = 0x%1 for rig %2"} .arg (params, 8, 16, QChar ('0')) .arg (rig_number).toLocal8Bit () << "state before:" << state ()); + if (rig_number_ == rig_number) + { + if (!rig_ || rig_->isNull ()) return; // starting_ = false; TransceiverState old_state {state ()}; auto need_frequency = false; - // state_.online = true; // sometimes we don't get an initial - // // OmniRig::ST_ONLINE status change - // // event + if (params & OmniRig::PM_VFOAA) { + TRACE_CAT ("OmniRigTransceiver", "VFOAA"); update_split (false); reversed_ = false; update_rx_frequency (rig_->FreqA ()); @@ -387,6 +381,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) } if (params & OmniRig::PM_VFOAB) { + TRACE_CAT ("OmniRigTransceiver", "VFOAB"); update_split (true); reversed_ = false; update_rx_frequency (rig_->FreqA ()); @@ -394,6 +389,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) } if (params & OmniRig::PM_VFOBA) { + TRACE_CAT ("OmniRigTransceiver", "VFOBA"); update_split (true); reversed_ = true; update_other_frequency (rig_->FreqA ()); @@ -401,6 +397,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) } if (params & OmniRig::PM_VFOBB) { + TRACE_CAT ("OmniRigTransceiver", "VFOBB"); update_split (false); reversed_ = true; update_other_frequency (rig_->FreqA ()); @@ -408,64 +405,75 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) } if (params & OmniRig::PM_VFOA) { + TRACE_CAT ("OmniRigTransceiver", "VFOA"); reversed_ = false; need_frequency = true; } if (params & OmniRig::PM_VFOB) { + TRACE_CAT ("OmniRigTransceiver", "VFOB"); reversed_ = true; need_frequency = true; } if (params & OmniRig::PM_FREQ) { + TRACE_CAT ("OmniRigTransceiver", "FREQ"); need_frequency = true; } if (params & OmniRig::PM_FREQA) { + auto f = rig_->FreqA (); + TRACE_CAT ("OmniRigTransceiver", "FREQA = " << f); if (reversed_) { - update_other_frequency (rig_->FreqA ()); + update_other_frequency (f); } else { - update_rx_frequency (rig_->FreqA ()); + update_rx_frequency (f); } } if (params & OmniRig::PM_FREQB) { + auto f = rig_->FreqB (); + TRACE_CAT ("OmniRigTransceiver", "FREQB = " << f); if (reversed_) { - update_rx_frequency (rig_->FreqB ()); + update_rx_frequency (f); } else { - update_other_frequency (rig_->FreqB ()); + update_other_frequency (f); } } if (need_frequency) { if (readable_params_ & OmniRig::PM_FREQA) { + auto f = rig_->FreqA (); + TRACE_CAT ("OmniRigTransceiver", "FREQA = " << f); if (reversed_) { - update_other_frequency (rig_->FreqA ()); + update_other_frequency (f); } else { - update_rx_frequency (rig_->FreqA ()); + update_rx_frequency (f); } need_frequency = false; } if (readable_params_ & OmniRig::PM_FREQB) { + auto f = rig_->FreqB (); + TRACE_CAT ("OmniRigTransceiver", "FREQB = " << f); if (reversed_) { - update_rx_frequency (rig_->FreqB ()); + update_rx_frequency (f); } else { - update_other_frequency (rig_->FreqB ()); + update_other_frequency (f); } need_frequency = false; } @@ -473,89 +481,113 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) if (need_frequency && (readable_params_ & OmniRig::PM_FREQ) && !state ().ptt ()) { - update_rx_frequency (rig_->Freq ()); + auto f = rig_->Freq (); + TRACE_CAT ("OmniRigTransceiver", "FREQ = " << f); + update_rx_frequency (f); } if (params & OmniRig::PM_PITCH) { + TRACE_CAT ("OmniRigTransceiver", "PITCH"); } if (params & OmniRig::PM_RITOFFSET) { + TRACE_CAT ("OmniRigTransceiver", "RITOFFSET"); } if (params & OmniRig::PM_RIT0) { + TRACE_CAT ("OmniRigTransceiver", "RIT0"); } if (params & OmniRig::PM_VFOEQUAL) { auto f = readable_params_ & OmniRig::PM_FREQA ? rig_->FreqA () : rig_->Freq (); + auto m = map_mode (rig_->Mode ()); + TRACE_CAT ("OmniRigTransceiver", QString {"VFOEQUAL f=%1 m=%2"}.arg (f).arg (m)); update_rx_frequency (f); update_other_frequency (f); - update_mode (map_mode (rig_->Mode ())); + update_mode (m); } if (params & OmniRig::PM_VFOSWAP) { - auto temp = state ().tx_frequency (); + TRACE_CAT ("OmniRigTransceiver", "VFOSWAP"); + auto f = state ().tx_frequency (); update_other_frequency (state ().frequency ()); - update_rx_frequency (temp); + update_rx_frequency (f); update_mode (map_mode (rig_->Mode ())); } if (params & OmniRig::PM_SPLITON) { + TRACE_CAT ("OmniRigTransceiver", "SPLITON"); update_split (true); } if (params & OmniRig::PM_SPLITOFF) { + TRACE_CAT ("OmniRigTransceiver", "SPLITOFF"); update_split (false); } if (params & OmniRig::PM_RITON) { + TRACE_CAT ("OmniRigTransceiver", "RITON"); } if (params & OmniRig::PM_RITOFF) { + TRACE_CAT ("OmniRigTransceiver", "RITOFF"); } if (params & OmniRig::PM_XITON) { + TRACE_CAT ("OmniRigTransceiver", "XITON"); } if (params & OmniRig::PM_XITOFF) { + TRACE_CAT ("OmniRigTransceiver", "XITOFF"); } if (params & OmniRig::PM_RX) { + TRACE_CAT ("OmniRigTransceiver", "RX"); update_PTT (false); } if (params & OmniRig::PM_TX) { + TRACE_CAT ("OmniRigTransceiver", "TX"); update_PTT (); } if (params & OmniRig::PM_CW_U) { + TRACE_CAT ("OmniRigTransceiver", "CW-R"); update_mode (CW_R); } if (params & OmniRig::PM_CW_L) { + TRACE_CAT ("OmniRigTransceiver", "CW"); update_mode (CW); } if (params & OmniRig::PM_SSB_U) { + TRACE_CAT ("OmniRigTransceiver", "USB"); update_mode (USB); } if (params & OmniRig::PM_SSB_L) { + TRACE_CAT ("OmniRigTransceiver", "LSB"); update_mode (LSB); } if (params & OmniRig::PM_DIG_U) { + TRACE_CAT ("OmniRigTransceiver", "DATA-U"); update_mode (DIG_U); } if (params & OmniRig::PM_DIG_L) { + TRACE_CAT ("OmniRigTransceiver", "DATA-L"); update_mode (DIG_L); } if (params & OmniRig::PM_AM) { + TRACE_CAT ("OmniRigTransceiver", "AM"); update_mode (AM); } if (params & OmniRig::PM_FM) { + TRACE_CAT ("OmniRigTransceiver", "FM"); update_mode (FM); } @@ -566,6 +598,7 @@ void OmniRigTransceiver::handle_params_change (int rig_number, int params) } TRACE_CAT ("OmniRigTransceiver", "OmniRig params change: state after:" << state ()); } + Q_EMIT notified (); } void OmniRigTransceiver::handle_custom_reply (int rig_number, QVariant const& command, QVariant const& reply) @@ -573,8 +606,10 @@ void OmniRigTransceiver::handle_custom_reply (int rig_number, QVariant const& co (void)command; (void)reply; + if (!omni_rig_ || omni_rig_->isNull ()) return; if (rig_number_ == rig_number) { + if (!rig_ || rig_->isNull ()) return; TRACE_CAT ("OmniRigTransceiver", "custom command" << command.toString ().toLocal8Bit () << "with reply" << reply.toString ().toLocal8Bit () << QString ("for rig %1").arg (rig_number).toLocal8Bit ()); diff --git a/OmniRigTransceiver.hpp b/OmniRigTransceiver.hpp index c63266b6..2ba5fd4d 100644 --- a/OmniRigTransceiver.hpp +++ b/OmniRigTransceiver.hpp @@ -38,10 +38,11 @@ public: void do_tx_frequency (Frequency, MODE, bool no_ignore) override; void do_mode (MODE) override; void do_ptt (bool on) override; - void do_sync (bool force_signal, bool no_poll) override; private: - Q_SLOT void timeout_check (); + bool await_notification_with_timeout (int timeout); + Q_SIGNAL void notified () const; + // Q_SLOT void timeout_check (); Q_SLOT void handle_COM_exception (int, QString, QString, QString); Q_SLOT void handle_visible_change (); Q_SLOT void handle_rig_type_change (int rig_number); @@ -62,7 +63,7 @@ private: QString rig_type_; int readable_params_; int writable_params_; - QScopedPointer<QTimer> offline_timer_; + // QScopedPointer<QTimer> offline_timer_; bool send_update_signal_; bool reversed_; // some rigs can reverse VFOs }; diff --git a/PollingTransceiver.cpp b/PollingTransceiver.cpp index b2bbab17..ed47144a 100644 --- a/PollingTransceiver.cpp +++ b/PollingTransceiver.cpp @@ -129,52 +129,46 @@ bool PollingTransceiver::do_pre_update () return true; } -void PollingTransceiver::do_sync (bool force_signal, bool no_poll) -{ - if (!no_poll) poll (); // tell sub-classes to update our state - - // Signal new state if it is directly requested or, what we expected - // or, hasn't become what we expected after polls_to_stabilize - // polls. Unsolicited changes will be signalled immediately unless - // they intervene in a expected sequence where they will be delayed. - if (retries_) - { - --retries_; - if (force_signal || state () == next_state_ || !retries_) - { - // our client wants a signal regardless - // or the expected state has arrived - // or there are no more retries - force_signal = true; - } - } - else if (force_signal || state () != last_signalled_state_) - { - // here is the normal passive polling path either our client has - // requested a state update regardless of change or state has - // changed asynchronously - force_signal = true; - } - - if (force_signal) - { - // reset everything, record and signal the current state - retries_ = 0; - next_state_ = state (); - last_signalled_state_ = state (); - update_complete (true); - } -} - void PollingTransceiver::handle_timeout () { QString message; + bool force_signal {false}; // we must catch all exceptions here since we are called by Qt and // inform our parent of the failure via the offline() message try { - do_sync (); + do_poll (); // tell sub-classes to update our state + + // Signal new state if it what we expected or, hasn't become + // what we expected after polls_to_stabilize polls. Unsolicited + // changes will be signalled immediately unless they intervene + // in a expected sequence where they will be delayed. + if (retries_) + { + --retries_; + if (state () == next_state_ || !retries_) + { + // the expected state has arrived or there are no more + // retries + force_signal = true; + } + } + else if (state () != last_signalled_state_) + { + // here is the normal passive polling path where state has + // changed asynchronously + force_signal = true; + } + + if (force_signal) + { + // reset everything, record and signal the current state + retries_ = 0; + next_state_ = state (); + last_signalled_state_ = state (); + update_complete (true); + } } catch (std::exception const& e) { diff --git a/PollingTransceiver.hpp b/PollingTransceiver.hpp index 0945c84a..a9e639f9 100644 --- a/PollingTransceiver.hpp +++ b/PollingTransceiver.hpp @@ -39,11 +39,9 @@ protected: QObject * parent); protected: - void do_sync (bool force_signal = false, bool no_poll = false) override final; - // Sub-classes implement this and fetch what they can from the rig // in a non-intrusive manner. - virtual void poll () = 0; + virtual void do_poll () = 0; void do_post_start () override final; void do_post_stop () override final; @@ -74,14 +74,14 @@ namespace Radio } - QString frequency_MHz_string (Frequency f, QLocale const& locale) + QString frequency_MHz_string (Frequency f, int precision, QLocale const& locale) { - return locale.toString (f / MHz_factor, 'f', frequency_precsion); + return locale.toString (f / MHz_factor, 'f', precision); } - QString frequency_MHz_string (FrequencyDelta d, QLocale const& locale) + QString frequency_MHz_string (FrequencyDelta d, int precision, QLocale const& locale) { - return locale.toString (d / MHz_factor, 'f', frequency_precsion); + return locale.toString (d / MHz_factor, 'f', precision); } QString pretty_frequency_MHz_string (Frequency f, QLocale const& locale) @@ -42,8 +42,8 @@ namespace Radio // // Frequency type formatting // - QString UDP_EXPORT frequency_MHz_string (Frequency, QLocale const& = QLocale ()); - QString UDP_EXPORT frequency_MHz_string (FrequencyDelta, QLocale const& = QLocale ()); + QString UDP_EXPORT frequency_MHz_string (Frequency, int precision = 6, QLocale const& = QLocale ()); + QString UDP_EXPORT frequency_MHz_string (FrequencyDelta, int precision = 6, QLocale const& = QLocale ()); QString UDP_EXPORT pretty_frequency_MHz_string (Frequency, QLocale const& = QLocale ()); QString UDP_EXPORT pretty_frequency_MHz_string (double, int scale, QLocale const& = QLocale ()); QString UDP_EXPORT pretty_frequency_MHz_string (FrequencyDelta, QLocale const& = QLocale ()); diff --git a/Release_Notes.txt b/Release_Notes.txt index c59ffafc..60fa0aa2 100644 --- a/Release_Notes.txt +++ b/Release_Notes.txt @@ -12,6 +12,138 @@ Copyright 2001 - 2019 by Joe Taylor, K1JT. + Release: WSJT-X 2.1.0-rc6 + May 30, 2019 + ------------------------- + +Changes and bug fixes since WSJT-X 2.1.0-rc5: + +IMPORTANT CHANGES TO THE FT4 PROTOCOL, NOT BACKWARD COMPATIBLE + - T/R sequence length increased from 6.0 to 7.5 seconds + - Symbol rate decreased from 23.4375 to 20.8333 baud. + - Bandwidth decreased from 90 Hz to 80 Hz + +OTHER IMPROVEMENTS + - Allowable FT4 time offsets -1.0 < DT < +1.0 s + - Allow RRR Tx4 message in FT4 mode, if not using contest messages + - Send FT4 audio frequency to PSK Reporter + - Add a third decoding pass + - Add ordered statistics decoding + - Improved sensitivity: threshold S/N is now -17.5 dB + - Improvements to accessibility + - Updates to the User Guide (not yet complete, however) + - New user option: "Calling CQ forces Call 1st" + - In FT4 mode, Shift+F11/F12 moves Tx freq by +/- 100 Hz + - Improved S/N calculation for FT4 mode + - N1MM Logger+ now uses the standard WSJT-X UDP messages + - OK/Cancel buttons on Log QSO window maintain fixed positions + - Enhancements to the Omni-Rig CAT interface + - New setting option to include or exclude WAE entities + +BUG FIXES + - Fix generation of Tx5 message when one callsign is nonstandard + - Fix a bug that prevented use on macOS + - Fix a bug that caused mode switch from FT4 to FT8 + - Fix a bug that caused FT4 to do WSPR-style band hopping + - Fix a bug that caused a Fortran bounds error + - Repaired field editing in the Contest Log window + + + Release: WSJT-X 2.1.0-rc5 + April 29, 2019 + ------------------------- + +WSJT-X 2.1.0 fifth release candidate is a minor release including the +following. + + - Repairs a defect that stopped messages from UDP servers being accepted. + - Improved message sequencing a QSO end for CQing FT4 stations. + - "Best S+P" action times out after two minutes waiting for a candidate. + - Updated macOS Info.plist to comply with latest mic. privacy controls. + - Multi-pass decoding for FT4 inc. prior decode subtraction. + - Fast/Normal/Deep options for the FT4 decoder. + - Proposed suggested working frequencies for the new FT4 mode. + - Repair a defect in RTTY RU where sequencer fails to advance to Tx3. + - Fix a defect where the contest serial # spin box was incorrectly hidden. + - Fix defects in ALL.TXT formatting for JT65 and JT9. + - Reduce timeout for AP decoding with own call from 10 mins to 5 mins. + + + Release: WSJT-X 2.1.0-rc4 + April 10, 2019 + ------------------------- + +WSJT-X 2.1.0 fourth release candidate is a minor release including the +following. + + - New "Call Best" button for FT4 mode to select the best reply to a + CQ call based on neediness. + - Fixed UTC display on FT4 waterfall. + +This release is made by invitation only to selected testers to trial +the FT4 mode in semi-realistic contest simulations and to elicit +feedback to guide future development. + +*Note* this release is not for general public release and we request + that it is not distributed. + + + Release: WSJT-X 2.1.0-rc3 + April 5, 2019 + ------------------------- + +WSJT-X 2.1.0 third release candidate is an enhancement release to +change the implementation of the new FT4 mode to a synchronous T/R +period of 6 seconds. + +This release is made by invitation only to selected testers to trial +the FT4 mode in semi-realistic contest simulations and to elicit +feedback to guide future development. + +*Note* this release is not for general public release and we request + that it is not distributed. + + + Release: WSJT-X 2.1.0-rc2 + March 29, 2019 + ------------------------- + +WSJT-X 2.1.0 second release candidate is a bug fix release to repair +some usability issues with FT4 contest mode. The following new +features are also included. + + - Better options for QSO flow by clicking Tx# buttons to transmit + - A 64-bit package for Windows 64-bit systems + - Improved FT4 sync detection speed + +This release is made by invitation only to selected testers to trial +the FT4 mode in semi-realistic contest simulations and to elicit +feedback to guide future development. + +*Note* this release is not for general public release and we request +that it is not distributed. + + Release: WSJT-X 2.1.0-rc1 + March 25, 2019 + ------------------------- + +WSJT-X 2.1.0 first release candidate is a preview alpha quality +release containing the following new features. + + - FT4 mode, a new mode targeted at HF digital contesting + - GMSK modulation for FT4 and FT8 + - New waterfall option to select between raw sensitivity or a + filtered signal representation for best visualization of signal + quality + +This release is made by invitation only to selected testers to trial +the FT4 mode in semi-realistic contest simulations and to elicit +feedback to guide future development. + +*Note* this release is not for general public release and we request +that it is not distributed. + + Release: WSJT-X 2.0.1 February 25, 2019 --------------------- diff --git a/TransceiverBase.cpp b/TransceiverBase.cpp index ef77d51e..43a88a4e 100644 --- a/TransceiverBase.cpp +++ b/TransceiverBase.cpp @@ -19,10 +19,10 @@ void TransceiverBase::start (unsigned sequence_number) noexcept QString message; try { + last_sequence_number_ = sequence_number; may_update u {this, true}; shutdown (); startup (); - last_sequence_number_ = sequence_number; } catch (std::exception const& e) { @@ -46,6 +46,7 @@ void TransceiverBase::set (TransceiverState const& s, QString message; try { + last_sequence_number_ = sequence_number; may_update u {this, true}; bool was_online {requested_.online ()}; if (!s.online () && was_online) @@ -115,7 +116,6 @@ void TransceiverBase::set (TransceiverState const& s, // record what actually changed requested_.ptt (actual_.ptt ()); } - last_sequence_number_ = sequence_number; } catch (std::exception const& e) { @@ -133,10 +133,27 @@ void TransceiverBase::set (TransceiverState const& s, void TransceiverBase::startup () { - Q_EMIT resolution (do_start ()); - do_post_start (); - actual_.online (true); - requested_.online (true); + QString message; + try + { + actual_.online (true); + requested_.online (true); + auto res = do_start (); + do_post_start (); + Q_EMIT resolution (res); + } + catch (std::exception const& e) + { + message = e.what (); + } + catch (...) + { + message = unexpected; + } + if (!message.isEmpty ()) + { + offline (message); + } } void TransceiverBase::shutdown () @@ -163,8 +180,8 @@ void TransceiverBase::shutdown () } do_stop (); do_post_stop (); - actual_.online (false); - requested_.online (false); + actual_ = TransceiverState {}; + requested_ = TransceiverState {}; } void TransceiverBase::stop () noexcept diff --git a/TransceiverBase.hpp b/TransceiverBase.hpp index ea981d44..7d43cc32 100644 --- a/TransceiverBase.hpp +++ b/TransceiverBase.hpp @@ -112,8 +112,6 @@ protected: virtual void do_ptt (bool = true) = 0; virtual void do_post_ptt (bool = true) {} - virtual void do_sync (bool force_signal = false, bool no_poll = false) = 0; - virtual bool do_pre_update () {return true;} // sub classes report rig state changes with these methods diff --git a/Versions.cmake b/Versions.cmake index 59af3346..f0733906 100644 --- a/Versions.cmake +++ b/Versions.cmake @@ -2,5 +2,5 @@ set (WSJTX_VERSION_MAJOR 2) set (WSJTX_VERSION_MINOR 1) set (WSJTX_VERSION_PATCH 0) -set (WSJTX_RC 5) # release candidate number, comment out or zero for development versions +set (WSJTX_RC 6) # release candidate number, comment out or zero for development versions set (WSJTX_VERSION_IS_RELEASE 0) # set to 1 for final release build diff --git a/doc/common/links.adoc b/doc/common/links.adoc index 85fdb106..e886f551 100644 --- a/doc/common/links.adoc +++ b/doc/common/links.adoc @@ -92,6 +92,7 @@ d). Edit lines as needed. Keeping them in alphabetic order help see dupes. :ubuntu_sdk: https://launchpad.net/~ubuntu-sdk-team/+archive/ppa[Ubuntu SDK Notice] :win_openssl_packages: https://slproweb.com/products/Win32OpenSSL.html[Windows OpenSSL Packages] :win32_openssl: https://slproweb.com/download/Win32OpenSSL_Light-1_0_2r.exe[Win32 OpenSSL Lite Package] +:win64_openssl: https://slproweb.com/download/Win64OpenSSL_Light-1_0_2r.exe[Win64 OpenSSL Lite Package] :writelog: https://writelog.com/[Writelog] :wsjt_yahoo_group: https://groups.yahoo.com/neo/groups/wsjtgroup/info[WSJT Group] :wsjtx: http://physics.princeton.edu/pulsar/K1JT/wsjtx.html[WSJT-X] diff --git a/doc/user_guide/en/install-windows.adoc b/doc/user_guide/en/install-windows.adoc index e3f75858..5b8e0683 100644 --- a/doc/user_guide/en/install-windows.adoc +++ b/doc/user_guide/en/install-windows.adoc @@ -29,26 +29,31 @@ TIP: Your computer may be configured so that this directory is [[OPENSSL]] -* image:LoTW_TLS_error.png[_WSJT-X_ LoTW download TLS error, role="right"] - From this version onward _WSJT-X_ requires the _OpenSSL_ libraries - to be installed. Suitable libraries may already be installed on your +* image:LoTW_TLS_error.png[_WSJT-X_ LoTW download TLS error, + role="right"] _WSJT-X_ requires the _OpenSSL_ libraries to be + installed. Suitable libraries may already be installed on your system, if they are not you will see this error shortly after startup. To fix this you need to install the _OpenSSL_ libraries. ** You can download a suitable _OpenSSL_ package for from - {win_openssl_packages}, you need the latest *Win32 v1.0.2 Lite* - version (Note it is the Win32 package even if you are using a - 64-bit Windows operating system) which at the time of writing was - {win32_openssl}. + {win_openssl_packages}, you need the latest *Windows v1.0.2 Lite* + version. For the 32-bit _WSJT-X_ build use the Win32 version of the + _OpenSSL_ libraries, for the 64-bit _WSJT-X_ use the Win64 version + of the _OpenSSL_ libraries (Note it is OK to install both versions + on a 64-bit system) which at the time of writing were + {win32_openssl} and {win64_openssl} respectively. ** Install the package and accept the default options, including the - option to copy the _OpenSSL_ DLLs to the Windows system directory - (this is important). + + option to copy the _OpenSSL_ DLLs to the Windows system + directory. There is no obligation to donate to the _OpenSSL_ + project, un-check all the donation options if desired. + NOTE: If you still get the same network error after installing the _OpenSSL_ libraries then you also need to install the {msvcpp_redist} component. From the download page select - `vcredist_x86.exe` and run it to install. + `vcredist_x86.exe` for use with the 32-bit _WSJT-X_ build or + `vcredist_x64.exe` with the 64-bit build, then run it to + install. TIP: If you cannot install the _OpenSSL_ libraries or do not have an Internet connection on the computer used to run diff --git a/item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp b/item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp deleted file mode 100644 index a666ed32..00000000 --- a/item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef DATE_TIME_AS_SECS_SINCE_EPOCH_DELEGATE_HPP_ -#define DATE_TIME_AS_SECS_SINCE_EPOCH_DELEGATE_HPP_ - -#include <memory> -#include <QStyledItemDelegate> -#include <QVariant> -#include <QLocale> -#include <QDateTime> -#include <QAbstractItemModel> -#include <QDateTimeEdit> - -class DateTimeAsSecsSinceEpochDelegate final - : public QStyledItemDelegate -{ -public: - DateTimeAsSecsSinceEpochDelegate (QObject * parent = nullptr) - : QStyledItemDelegate {parent} - { - } - - static QVariant to_secs_since_epoch (QDateTime const& date_time) - { - return date_time.toMSecsSinceEpoch () / 1000ull; - } - - static QDateTime to_date_time (QModelIndex const& index, int role = Qt::DisplayRole) - { - return to_date_time (index.model ()->data (index, role)); - } - - static QDateTime to_date_time (QVariant const& value) - { - return QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC); - } - - QString displayText (QVariant const& value, QLocale const& locale) const override - { - return locale.toString (to_date_time (value), locale.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); - } - - QWidget * createEditor (QWidget * parent, QStyleOptionViewItem const& /*option*/, QModelIndex const& /*index*/) const override - { - std::unique_ptr<QDateTimeEdit> editor {new QDateTimeEdit {parent}}; - editor->setDisplayFormat (parent->locale ().dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); - editor->setTimeSpec (Qt::UTC); // needed because it ignores time - // spec of the QDateTime that it is - // set from - return editor.release (); - } - - void setEditorData (QWidget * editor, QModelIndex const& index) const override - { - static_cast<QDateTimeEdit *> (editor)->setDateTime (to_date_time (index, Qt::EditRole)); - } - - void setModelData (QWidget * editor, QAbstractItemModel * model, QModelIndex const& index) const override - { - model->setData (index, to_secs_since_epoch (static_cast<QDateTimeEdit *> (editor)->dateTime ())); - } - - void updateEditorGeometry (QWidget * editor, QStyleOptionViewItem const& option, QModelIndex const& /*index*/) const override - { - editor->setGeometry (option.rect); - } -}; - -#endif diff --git a/item_delegates/FrequencyDelegate.cpp b/item_delegates/FrequencyDelegate.cpp new file mode 100644 index 00000000..b899c056 --- /dev/null +++ b/item_delegates/FrequencyDelegate.cpp @@ -0,0 +1,27 @@ +#include "FrequencyDelegate.hpp" + +#include "widgets/FrequencyLineEdit.hpp" + +FrequencyDelegate::FrequencyDelegate (QObject * parent) + : QStyledItemDelegate {parent} +{ +} + +QWidget * FrequencyDelegate::createEditor (QWidget * parent, QStyleOptionViewItem const& + , QModelIndex const&) const +{ + auto * editor = new FrequencyLineEdit {parent}; + editor->setFrame (false); + return editor; +} + +void FrequencyDelegate::setEditorData (QWidget * editor, QModelIndex const& index) const +{ + static_cast<FrequencyLineEdit *> (editor)->frequency (index.model ()->data (index, Qt::EditRole).value<Radio::Frequency> ()); +} + +void FrequencyDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, QModelIndex const& index) const +{ + model->setData (index, static_cast<FrequencyLineEdit *> (editor)->frequency (), Qt::EditRole); +} + diff --git a/item_delegates/FrequencyDelegate.hpp b/item_delegates/FrequencyDelegate.hpp new file mode 100644 index 00000000..76fc5545 --- /dev/null +++ b/item_delegates/FrequencyDelegate.hpp @@ -0,0 +1,21 @@ +#ifndef FREQUENCY_DELEGATE_HPP_ +#define FREQUENCY_DELEGATE_HPP_ + +#include <QStyledItemDelegate> + +// +// Class FrequencyDelegate +// +// Item delegate for editing a frequency in Hertz but displayed in MHz +// +class FrequencyDelegate final + : public QStyledItemDelegate +{ +public: + explicit FrequencyDelegate (QObject * parent = nullptr); + QWidget * createEditor (QWidget * parent, QStyleOptionViewItem const&, QModelIndex const&) const override; + void setEditorData (QWidget * editor, QModelIndex const&) const override; + void setModelData (QWidget * editor, QAbstractItemModel *, QModelIndex const&) const override; +}; + +#endif diff --git a/item_delegates/FrequencyDeltaDelegate.cpp b/item_delegates/FrequencyDeltaDelegate.cpp new file mode 100644 index 00000000..40d90dc5 --- /dev/null +++ b/item_delegates/FrequencyDeltaDelegate.cpp @@ -0,0 +1,26 @@ +#include "FrequencyDeltaDelegate.hpp" + +#include "widgets/FrequencyDeltaLineEdit.hpp" + +FrequencyDeltaDelegate::FrequencyDeltaDelegate (QObject * parent) + : QStyledItemDelegate {parent} +{ +} + +QWidget * FrequencyDeltaDelegate::createEditor (QWidget * parent, QStyleOptionViewItem const& + , QModelIndex const&) const +{ + auto * editor = new FrequencyDeltaLineEdit {parent}; + editor->setFrame (false); + return editor; +} + +void FrequencyDeltaDelegate::setEditorData (QWidget * editor, QModelIndex const& index) const +{ + static_cast<FrequencyDeltaLineEdit *> (editor)->frequency_delta (index.model ()->data (index, Qt::EditRole).value<Radio::FrequencyDelta> ()); +} + +void FrequencyDeltaDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, QModelIndex const& index) const +{ + model->setData (index, static_cast<FrequencyDeltaLineEdit *> (editor)->frequency_delta (), Qt::EditRole); +} diff --git a/item_delegates/FrequencyDeltaDelegate.hpp b/item_delegates/FrequencyDeltaDelegate.hpp new file mode 100644 index 00000000..121bc3d9 --- /dev/null +++ b/item_delegates/FrequencyDeltaDelegate.hpp @@ -0,0 +1,21 @@ +#ifndef FREQUENCY_DELTA_DELEGATE_HPP_ +#define FREQUENCY_DELTA_DELEGATE_HPP_ + +#include <QStyledItemDelegate> + +// +// Class FrequencyDeltaDelegate +// +// Item delegate for editing a frequency delta in Hertz but displayed in MHz +// +class FrequencyDeltaDelegate final + : public QStyledItemDelegate +{ +public: + explicit FrequencyDeltaDelegate (QObject * parent = nullptr); + QWidget * createEditor (QWidget * parent, QStyleOptionViewItem const&, QModelIndex const&) const override; + void setEditorData (QWidget * editor, QModelIndex const&) const override; + void setModelData (QWidget * editor, QAbstractItemModel *, QModelIndex const&) const override; +}; + +#endif diff --git a/item_delegates/item_delegates.pri b/item_delegates/item_delegates.pri index 153ad427..819cb2e0 100644 --- a/item_delegates/item_delegates.pri +++ b/item_delegates/item_delegates.pri @@ -1,12 +1,13 @@ SOURCES += \ item_delegates/ForeignKeyDelegate.cpp \ - item_delegates/FrequencyItemDelegate.cpp \ + item_delegates/FrequencyDelegate.cpp \ + item_delegates/FrequencyDeltaDelegate.cpp \ item_delegates/CallsignDelegate.cpp \ item_delegates/MaidenheadLocatorItemDelegate.cpp HEADERS += \ item_delegates/ForeignKeyDelegate.hpp \ - item_delegates/FrequencyItemDelegate.hpp \ + item_delegates/FrequencyDelegate.hpp \ + item_delegates/FrequencyDeltaDelegate.hpp \ item_delegates/CallsignDelegate.hpp \ - item_delegates/MaidenheadLocatorDelegate.hpp \ - item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp + item_delegates/MaidenheadLocatorDelegate.hpp diff --git a/lib/azdist.f90 b/lib/azdist.f90 index 2fd26c3d..41a8fc5b 100644 --- a/lib/azdist.f90 +++ b/lib/azdist.f90 @@ -1,7 +1,7 @@ -subroutine azdist(grid1,grid2,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter)
+subroutine azdist(MyGrid,HisGrid,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter)
- character*(*) grid1,grid2
- character*6 MyGrid,HisGrid,mygrid0,hisgrid0
+ character(len=*) :: MyGrid,HisGrid
+ character*6 mygrid0,hisgrid0
real*8 utch,utch0
logical HotABetter,IamEast
real eltab(22),daztab(22)
@@ -12,11 +12,6 @@ subroutine azdist(grid1,grid2,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) data mygrid0/" "/,hisgrid0/" "/,utch0/-999.d0/
save
- MyGrid=grid1//' '
- HisGrid=grid2//' '
- if(ichar(MyGrid(5:5)).eq.0) MyGrid(5:6)=' '
- if(ichar(HisGrid(5:5)).eq.0) HisGrid(5:6)=' '
-
if(MyGrid.eq.HisGrid) then
naz=0
nel=0
diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 8ca7e316..d3f1153f 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -133,8 +133,8 @@ subroutine multimode_decoder(ss,id2,params,nfsample) n30fox(j)=n m=n30max-n if(len(trim(g2fox(j))).eq.4) then - call azdist(mygrid,g2fox(j),0.d0,nAz,nEl,nDmiles,nDkm, & - nHotAz,nHotABetter) + call azdist(mygrid,g2fox(j)//' ',0.d0,nAz,nEl,nDmiles, & + nDkm,nHotAz,nHotABetter) else nDkm=9999 endif @@ -152,8 +152,8 @@ subroutine multimode_decoder(ss,id2,params,nfsample) if(params%nmode.eq.5) then call timer('decft4 ',0) call my_ft4%decode(ft4_decoded,id2,params%nQSOProgress,params%nfqso, & - params%nutc,params%nfa,params%nfb,params%ndepth,ncontest, & - mycall,hiscall) + params%nutc,params%nfa,params%nfb,params%ndepth, & + logical(params%lapcqonly),ncontest,mycall,hiscall) call timer('decft4 ',1) go to 800 endif diff --git a/lib/freqcal.f90 b/lib/freqcal.f90 index 540237f6..80ce90c6 100644 --- a/lib/freqcal.f90 +++ b/lib/freqcal.f90 @@ -41,6 +41,7 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) endif
smax=0.
s=0.
+ ipk=-99
do i=ia,ib
s(i)=real(cx(i))**2 + aimag(cx(i))**2
if(s(i).gt.smax) then
@@ -48,25 +49,32 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) ipk=i
endif
enddo
-
- call peakup(s(ipk-1),s(ipk),s(ipk+1),dx)
- fpeak=df * (ipk+dx)
- ap=(fpeak/fs+1.0/(2.0*NFFT))
- an=(fpeak/fs-1.0/(2.0*NFFT))
- sp=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*ap),-sin(xi*ap)))
- sn=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*an),-sin(xi*an)))
- fpeak=fpeak+fs*(abs(sp)-abs(sn))/(abs(sp)+abs(sn))/(2*NFFT)
- xsum=0.
- nsum=0
- do i=ia,ib
- if(abs(i-ipk).gt.10) then
- xsum=xsum+s(i)
- nsum=nsum+1
- endif
- enddo
- ave=xsum/nsum
- snr=db(smax/ave)
- pave=db(ave) + 8.0
+
+ if(ipk.ge.1) then
+ call peakup(s(ipk-1),s(ipk),s(ipk+1),dx)
+ fpeak=df * (ipk+dx)
+ ap=(fpeak/fs+1.0/(2.0*NFFT))
+ an=(fpeak/fs-1.0/(2.0*NFFT))
+ sp=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*ap),-sin(xi*ap)))
+ sn=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*an),-sin(xi*an)))
+ fpeak=fpeak+fs*(abs(sp)-abs(sn))/(abs(sp)+abs(sn))/(2*NFFT)
+ xsum=0.
+ nsum=0
+ do i=ia,ib
+ if(abs(i-ipk).gt.10) then
+ xsum=xsum+s(i)
+ nsum=nsum+1
+ endif
+ enddo
+ ave=xsum/nsum
+ snr=db(smax/ave)
+ pave=db(ave) + 8.0
+ else
+ snr=-99.9
+ pave=-99.9
+ fpeak=-99.9
+ ferr=-99.9
+ endif
cflag=' '
if(snr.lt.20.0) cflag='*'
n=n+1
@@ -77,7 +85,7 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) ncal=1
ferr=fpeak-noffset
write(line,1100) nhr,nmin,nsec,nkhz,ncal,noffset,fpeak,ferr,pave, &
- snr,cflag,char(0)
+ snr,cflag,char(0)
1100 format(i2.2,':',i2.2,':',i2.2,i7,i3,i6,2f10.3,2f7.1,2x,a1,a1)
900 return
diff --git a/lib/ft4/averaged_mf.f90 b/lib/ft4/averaged_mf.f90 new file mode 100644 index 00000000..2986572b --- /dev/null +++ b/lib/ft4/averaged_mf.f90 @@ -0,0 +1,64 @@ +program averaged_mf + + parameter (nsps=32) + complex cgfsk(3*nsps,64) + complex clin(3*nsps,64) + complex cavg(3*nsps,4) + complex cavl(3*nsps,4) + real pulse(3*nsps) + real dphi(3*nsps) + + do i=1,3*NSPS + t=(i-1.5*nsps)/real(nsps) + pulse(i)=gfsk_pulse(1.0,t) + enddo + + twopi=8.0*atan(1.0) + hmod=1.0 + dphi_peak=twopi*hmod/real(nsps) + + do iwf=1,64 + i0=mod((iwf-1)/16,4) + i1=mod((iwf-1)/4,4) + i2=mod(iwf-1,4) + dphi=0.0 + dphi(1:64)=dphi_peak*pulse(33:96)*i1 + dphi(1:96)=dphi(1:96)+dphi_peak*pulse(1:96)*i0 + dphi(33:96)=dphi(33:96)+dphi_peak*pulse(1:64)*i2 + phi=0.0 + do j=1,96 + cgfsk(j,iwf)=cmplx(cos(phi),sin(phi)) + phi=mod(phi+dphi(j),twopi) + enddo + cgfsk(:,iwf)=cgfsk(:,iwf)*conjg(cgfsk(48,iwf)) + enddo + + do iwf=1,64 + i0=mod((iwf-1)/16,4) + i1=mod((iwf-1)/4,4) + i2=mod(iwf-1,4) + dphi=0.0 + dphi(1:32)=dphi_peak*i1 + dphi(33:64)=dphi_peak*i0 + dphi(65:96)=dphi_peak*i2 + phi=0.0 + do j=1,96 + clin(j,iwf)=cmplx(cos(phi),sin(phi)) + phi=mod(phi+dphi(j),twopi) + enddo + enddo + + + do i=1,4 + ib=(i-1)*16+1 + ie=ib+15 + cavg(:,i)=sum(cgfsk(:,ib:ie),2)/16.0 + cavl(:,i)=sum(clin(:,ib:ie),2)/16.0 + do j=1,96 +write(*,*) j +write(21,*) i,j,real(cavg(j,i)),imag(cavg(j,i)),real(cavl(j,i)),imag(cavl(j,i)) + enddo + enddo + +end program averaged_mf + diff --git a/lib/ft4/ft4_baseline.f90 b/lib/ft4/ft4_baseline.f90 new file mode 100644 index 00000000..85a60d9e --- /dev/null +++ b/lib/ft4/ft4_baseline.f90 @@ -0,0 +1,49 @@ +subroutine ft4_baseline(s,nfa,nfb,sbase)
+
+! Fit baseline to spectrum
+! Input: s(npts) Linear scale in power
+! Output: sbase(npts) Baseline
+
+ include 'ft4_params.f90'
+ implicit real*8 (a-h,o-z)
+ real*4 s(NH1)
+ real*4 sbase(NH1)
+ real*4 base
+ real*8 x(1000),y(1000),a(5)
+ data nseg/10/,npct/10/
+
+ df=12000.0/NFFT1 !5.21 Hz
+ ia=max(nint(200.0/df),nfa)
+ ib=min(NH1,nfb)
+ do i=ia,ib
+ s(i)=10.0*log10(s(i)) !Convert to dB scale
+ enddo
+
+ nterms=5
+ nlen=(ib-ia+1)/nseg !Length of test segment
+ i0=(ib-ia+1)/2 !Midpoint
+ k=0
+ do n=1,nseg !Loop over all segments
+ ja=ia + (n-1)*nlen
+ jb=ja+nlen-1
+ call pctile(s(ja),nlen,npct,base) !Find lowest npct of points
+ do i=ja,jb
+ if(s(i).le.base) then
+ if (k.lt.1000) k=k+1 !Save all "lower envelope" points
+ x(k)=i-i0
+ y(k)=s(i)
+ endif
+ enddo
+ enddo
+ kz=k
+ a=0.
+ call polyfit(x,y,y,kz,nterms,0,a,chisqr) !Fit a low-order polynomial
+ do i=ia,ib
+ t=i-i0
+ sbase(i)=a(1)+t*(a(2)+t*(a(3)+t*(a(4)+t*(a(5))))) + 0.65
+! write(51,3051) i*df,s(i),sbase(i)
+!3051 format(3f12.3)
+ sbase(i)=10**(sbase(i)/10.0)
+ enddo
+ return
+end subroutine ft4_baseline
diff --git a/lib/ft4/ft4_downsample.f90 b/lib/ft4/ft4_downsample.f90 index 819b10fb..ed55fb9a 100644 --- a/lib/ft4/ft4_downsample.f90 +++ b/lib/ft4/ft4_downsample.f90 @@ -4,7 +4,7 @@ subroutine ft4_downsample(dd,newdata,f0,c) ! Output: Complex data in c(), sampled at 1200 Hz include 'ft4_params.f90' - parameter (NFFT2=NMAX/16) + parameter (NFFT2=NMAX/NDOWN) real dd(NMAX) complex c(0:NMAX/NDOWN-1) complex c1(0:NFFT2-1) @@ -38,7 +38,7 @@ subroutine ft4_downsample(dd,newdata,f0,c) endif i0=nint(f0/df) c1=0. - c1(0)=cx(i0) + if(i0.ge.0 .and. i0.le.NMAX/2) c1(0)=cx(i0) do i=1,NFFT2/2 if(i0+i.le.NMAX/2) c1(i)=cx(i0+i) if(i0-i.ge.0) c1(NFFT2-i)=cx(i0-i) diff --git a/lib/ft4/ft4_params.f90 b/lib/ft4/ft4_params.f90 index 46630cc2..2914260d 100644 --- a/lib/ft4/ft4_params.f90 +++ b/lib/ft4/ft4_params.f90 @@ -6,11 +6,11 @@ parameter (ND=87) !Data symbols parameter (NS=16) !Sync symbols
parameter (NN=NS+ND) !Sync and data symbols (103)
parameter (NN2=NS+ND+2) !Total channel symbols (105)
-parameter (NSPS=512) !Samples per symbol at 12000 S/s
-parameter (NZ=NSPS*NN) !Sync and Data samples (52736)
-parameter (NZ2=NSPS*NN2) !Total samples in shaped waveform (53760)
-parameter (NMAX=18*3456) !Samples in iwave
-parameter (NFFT1=2048, NH1=NFFT1/2) !Length of FFTs for symbol spectra
+parameter (NSPS=576) !Samples per symbol at 12000 S/s
+parameter (NZ=NSPS*NN) !Sync and Data samples (59328)
+parameter (NZ2=NSPS*NN2) !Total samples in shaped waveform (60480)
+parameter (NMAX=21*3456) !Samples in iwave (72576)
+parameter (NFFT1=2304, NH1=NFFT1/2) !Length of FFTs for symbol spectra
parameter (NSTEP=NSPS) !Coarse time-sync step size
parameter (NHSYM=(NMAX-NFFT1)/NSTEP) !Number of symbol spectra (1/4-sym steps)
-parameter (NDOWN=16) !Downsample factor
+parameter (NDOWN=18) !Downsample factor
diff --git a/lib/ft4/ft4sim.f90 b/lib/ft4/ft4sim.f90 index 94ab8218..959cf423 100644 --- a/lib/ft4/ft4sim.f90 +++ b/lib/ft4/ft4sim.f90 @@ -6,7 +6,7 @@ program ft4sim use packjt77 include 'ft4_params.f90' !Set various constants parameter (NWAVE=NN*NSPS) - parameter (NZZ=18*3456) !62208 + parameter (NZZ=21*3456) !72576 type(hdr) h !Header for .wav file character arg*12,fname*17 character msg37*37,msgsent37*37 @@ -51,12 +51,11 @@ program ft4sim hmod=1.0 !Modulation index (0.5 is MSK, 1.0 is FSK) tt=NSPS*dt !Duration of symbols (s) baud=1.0/tt !Keying rate (baud) - txt=NZ*dt !Transmission length (s) + txt=NZ2*dt !Transmission length (s) bandwidth_ratio=2500.0/(fs/2.0) sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb) if(snrdb.gt.90.0) sig=1.0 - txt=NN*NSPS/12000.0 ! Source-encode, then get itone() i3=-1 @@ -111,8 +110,10 @@ program ft4sim c0((NN+1)*NSPS:(NN+2)*NSPS-1)=c0((NN+1)*NSPS:(NN+2)*NSPS-1)*(1.0+cos(twopi*(/(i,i=0,NSPS-1)/)/(2.0*NSPS) ))/2.0 c0((NN+2)*NSPS:)=0. - k=nint((xdt+0.5)/dt) + k=nint((xdt+0.5)/dt)-NSPS c0=cshift(c0,-k) + if(k.gt.0) c0(0:k-1)=0.0 + if(k.lt.0) c0(NZZ+k:NZZ-1)=0.0 do ifile=1,nfiles c=c0 diff --git a/lib/ft4/ft4sim_mult.f90 b/lib/ft4/ft4sim_mult.f90 index 31309328..d93978e5 100644 --- a/lib/ft4/ft4sim_mult.f90 +++ b/lib/ft4/ft4sim_mult.f90 @@ -6,7 +6,7 @@ program ft4sim_mult use packjt77 include 'ft4_params.f90' !FT4 protocol constants parameter (NWAVE=NN*NSPS) - parameter (NZZ=65760) !Length of .wav file (4.48+1.0)*12000 + parameter (NZZ=72576) !Length of .wav file (21*3456) type(hdr) h !Header for .wav file character arg*12,fname*17,cjunk*4 character msg37*37,msgsent37*37,c77*77 @@ -17,8 +17,6 @@ program ft4sim_mult integer itone(NN) integer*1 msgbits(77) integer*2 iwave(NZZ) !Generated full-length waveform - integer icos4(4) - data icos4/0,1,3,2/ ! Get command-line argument(s) nargs=iargc() @@ -55,8 +53,8 @@ program ft4sim_mult read(10,1003,end=100) cjunk,isnr,xdt0,ifreq,msg37 1003 format(a4,30x,i3,f5.1,i5,1x,a37) if(cjunk.eq.'File') go to 100 - if(isnr.lt.-16) isnr=-16 - f0=ifreq*93.75/50.0 + if(isnr.lt.-17) isnr=-17 + f0=ifreq*960.0/576.0 call random_number(r) xdt=r-0.5 ! Source-encode, then get itone() diff --git a/lib/ft4/gen_ft4wave.f90 b/lib/ft4/gen_ft4wave.f90 index 410e8340..82399361 100644 --- a/lib/ft4/gen_ft4wave.f90 +++ b/lib/ft4/gen_ft4wave.f90 @@ -2,8 +2,8 @@ subroutine gen_ft4wave(itone,nsym,nsps,fsample,f0,cwave,wave,icmplx,nwave) real wave(nwave) complex cwave(nwave) - real pulse(6144) !512*4*3 - real dphi(0:240000-1) + real pulse(6912) !576*4*3 + real dphi(0:250000-1) integer itone(nsym) logical first data first/.true./ @@ -13,7 +13,7 @@ subroutine gen_ft4wave(itone,nsym,nsps,fsample,f0,cwave,wave,icmplx,nwave) twopi=8.0*atan(1.0) dt=1.0/fsample hmod=1.0 -! Compute the frequency-smoothing pulse +! Compute the smoothed frequency-deviation pulse do i=1,3*nsps tt=(i-1.5*nsps)/real(nsps) pulse(i)=gfsk_pulse(1.0,tt) diff --git a/lib/ft4/getcandidates4.f90 b/lib/ft4/getcandidates4.f90 index 5d42ca74..f7cef02e 100644 --- a/lib/ft4/getcandidates4.f90 +++ b/lib/ft4/getcandidates4.f90 @@ -10,7 +10,6 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & complex cx(0:NH1)
real candidate(3,maxcand)
real dd(NMAX)
- integer indx(NH1)
integer ipk(1)
equivalence (x,cx)
logical first
@@ -26,7 +25,6 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & ! Compute symbol spectra, stepping by NSTEP steps.
savg=0.
- tstep=NSTEP/12000.0
df=12000.0/NFFT1
fac=1.0/300.0
do j=1,NHSYM
@@ -40,28 +38,21 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & enddo
savg=savg + s(1:NH1,j) !Average spectrum
enddo
+ savg=savg/NHSYM
savsm=0.
do i=8,NH1-7
savsm(i)=sum(savg(i-7:i+7))/15.
enddo
+
nfa=fa/df
- if(nfa.lt.1) nfa=1
+ if(nfa.lt.nint(200.0/df)) nfa=nint(200.0/df)
nfb=fb/df
if(nfb.gt.nint(5000.0/df)) nfb=nint(5000.0/df)
- n300=300/df
- n2500=2500/df
-! np=nfb-nfa+1
- np=n2500-n300+1
- indx=0
- call indexx(savsm(n300:n2500),np,indx)
- xn=savsm(n300+indx(nint(0.3*np)))
ncand=0
- if(xn.le.1.e-8) return
- savsm=savsm/xn
-! call ft4_baseline(savg,nfa,nfb,sbase)
-! savsm=savsm/sbase
-
- f_offset = -1.5*12000/512
+ call ft4_baseline(savg,nfa,nfb,sbase)
+ if(any(sbase(nfa:nfb).le.0)) return
+ savsm(nfa:nfb)=savsm(nfa:nfb)/sbase(nfa:nfb)
+ f_offset = -1.5*12000.0/NSPS
do i=nfa+1,nfb-1
if(savsm(i).ge.savsm(i-1) .and. savsm(i).ge.savsm(i+1) .and. &
savsm(i).ge.syncmin) then
@@ -69,6 +60,7 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & del=0.
if(den.ne.0.0) del=0.5*(savsm(i-1)-savsm(i+1))/den
fpeak=(i+del)*df+f_offset
+ if(fpeak.lt.0.0 .or. fpeak.gt.4910.0) cycle
speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del
ncand=ncand+1
if(ncand.gt.maxcand) then
diff --git a/lib/ft4/subtractft4.f90 b/lib/ft4/subtractft4.f90 index 83470d7e..ae104ddb 100644 --- a/lib/ft4/subtractft4.f90 +++ b/lib/ft4/subtractft4.f90 @@ -9,8 +9,8 @@ subroutine subtractft4(dd,itone,f0,dt) use timer_module, only: timer - parameter (NMAX=18*3456,NFRAME=(103+2)*512) - parameter (NFFT=NMAX,NFILT=1400) + parameter (NMAX=21*3456,NSPS=576,NFFT=NMAX,NFILT=1400) + parameter (NFRAME=(103+2)*NSPS) real*4 dd(NMAX), window(-NFILT/2:NFILT/2), xjunk complex cref,camp,cfilt,cw integer itone(103) @@ -19,13 +19,13 @@ subroutine subtractft4(dd,itone,f0,dt) common/heap8/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME) save first - nstart=dt*12000+1-512 + nstart=dt*12000+1-NSPS nsym=103 - nsps=512 fs=12000.0 icmplx=1 bt=1.0 - call gen_ft4wave(itone,nsym,nsps,fs,f0,cref,xjunk,icmplx,NFRAME) + nss=NSPS + call gen_ft4wave(itone,nsym,nss,fs,f0,cref,xjunk,icmplx,NFRAME) camp=0. do i=1,nframe id=nstart-1+i diff --git a/lib/ft4/sync4d.f90 b/lib/ft4/sync4d.f90 index bda7ed4a..28cb10b9 100644 --- a/lib/ft4/sync4d.f90 +++ b/lib/ft4/sync4d.f90 @@ -60,7 +60,16 @@ subroutine sync4d(cd0,i0,ctwk,itwk,sync) z4=0.
if(itwk.eq.1) csync2=ctwk*csynca !Tweak the frequency
- if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2))
+ if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) then
+ z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2))
+ elseif( i1.lt.0 ) then
+ npts=(i1+4*NSS-1)/2
+ if(npts.le.8) then
+ z1=0.
+ else
+ z1=sum(cd0(0:i1+4*NSS-1:2)*conjg(csync2(2*NSS-npts:)))
+ endif
+ endif
if(itwk.eq.1) csync2=ctwk*csyncb !Tweak the frequency
if(i2.ge.0 .and. i2+4*NSS-1.le.NP-1) z2=sum(cd0(i2:i2+4*NSS-1:2)*conjg(csync2))
@@ -69,8 +78,16 @@ subroutine sync4d(cd0,i0,ctwk,itwk,sync) if(i3.ge.0 .and. i3+4*NSS-1.le.NP-1) z3=sum(cd0(i3:i3+4*NSS-1:2)*conjg(csync2))
if(itwk.eq.1) csync2=ctwk*csyncd !Tweak the frequency
- if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2))
-
+ if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) then
+ z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2))
+ elseif( i4+4*NSS-1.gt.NP-1 ) then
+ npts=(NP-1-i4+1)/2
+ if(npts.le.8) then
+ z4=0.
+ else
+ z4=sum(cd0(i4:i4+2*npts-1:2)*conjg(csync2(1:npts)))
+ endif
+ endif
sync = p(z1) + p(z2) + p(z3) + p(z4)
return
diff --git a/lib/ft4/syncft4.f90 b/lib/ft4/syncft4.f90 deleted file mode 100644 index 4841c560..00000000 --- a/lib/ft4/syncft4.f90 +++ /dev/null @@ -1,145 +0,0 @@ -subroutine syncft4(iwave,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
- ncand,sbase)
-
- include 'ft4_params.f90'
-! Search over +/- 2.5s relative to 0.5s TX start time.
- parameter (JZ=20)
- complex cx(0:NH1)
- real s(NH1,NHSYM)
- real savg(NH1)
- real sbase(NH1)
- real x(NFFT1)
- real sync2d(NH1,-JZ:JZ)
- real red(NH1)
- real candidate0(3,maxcand)
- real candidate(3,maxcand)
- real dd(NMAX)
- integer jpeak(NH1)
- integer indx(NH1)
- integer ii(1)
- integer*2 iwave(NMAX)
- integer icos4(0:3)
- data icos4/0,1,3,2/ !Costas 4x4 tone pattern
- equivalence (x,cx)
-
- dd=iwave/1e3
-! Compute symbol spectra, stepping by NSTEP steps.
- savg=0.
- tstep=NSTEP/12000.0
- df=12000.0/NFFT1
- fac=1.0/300.0
- do j=1,NHSYM
- ia=(j-1)*NSTEP + 1
- ib=ia+NSPS-1
- x(1:NSPS)=fac*dd(ia:ib)
- x(NSPS+1:)=0.
- call four2a(x,NFFT1,1,-1,0) !r2c FFT
- do i=1,NH1
- s(i,j)=real(cx(i))**2 + aimag(cx(i))**2
- enddo
- savg=savg + s(1:NH1,j) !Average spectrum
- enddo
-
- call baseline(savg,nfa,nfb,sbase)
-
- ia=max(1,nint(nfa/df))
- ib=nint(nfb/df)
- nssy=NSPS/NSTEP ! # steps per symbol
- nfos=NFFT1/NSPS ! # frequency bin oversampling factor
- jstrt=0.25/tstep
- candidate0=0.
- k=0
-
- do i=ia,ib
- do j=-JZ,+JZ
- ta=0.
- tb=0.
- tc=0.
- t0a=0.
- t0b=0.
- t0c=0.
- do n=0,3
- m=j+jstrt+nssy*n
- if(m.ge.1.and.m.le.NHSYM) then
- ta=ta + s(i+nfos*icos4(n),m)
- t0a=t0a + sum(s(i:i+nfos*3:nfos,m))
- endif
- tb=tb + s(i+nfos*icos4(n),m+nssy*36)
- t0b=t0b + sum(s(i:i+nfos*3:nfos,m+nssy*36))
- if(m+nssy*72.le.NHSYM) then
- tc=tc + s(i+nfos*icos4(n),m+nssy*72)
- t0c=t0c + sum(s(i:i+nfos*3:nfos,m+nssy*72))
- endif
- enddo
- t=ta+tb+tc
- t0=t0a+t0b+t0c
- t0=(t0-t)/3.0
- sync_abc=t/t0
- t=tb+tc
- t0=t0b+t0c
- t0=(t0-t)/3.0
- sync_bc=t/t0
- sync2d(i,j)=max(sync_abc,sync_bc)
- enddo
- enddo
-
- red=0.
- do i=ia,ib
- ii=maxloc(sync2d(i,-JZ:JZ)) - 1 - JZ
- j0=ii(1)
- jpeak(i)=j0
- red(i)=sync2d(i,j0)
- enddo
- iz=ib-ia+1
- call indexx(red(ia:ib),iz,indx)
- ibase=indx(nint(0.40*iz)) - 1 + ia
- if(ibase.lt.1) ibase=1
- if(ibase.gt.nh1) ibase=nh1
- base=red(ibase)
- red=red/base
- do i=1,min(maxcand,iz)
- n=ia + indx(iz+1-i) - 1
- if(red(n).lt.syncmin.or.isnan(red(n)).or.k.eq.maxcand) exit
- k=k+1
-! candidate0(1,k)=n*df+37.5*1.5
- candidate0(1,k)=n*df
- candidate0(2,k)=(jpeak(n)-1)*tstep
- candidate0(3,k)=red(n)
- enddo
- ncand=k
-
-! Put nfqso at top of list, and save only the best of near-dupe freqs.
- do i=1,ncand
- if(abs(candidate0(1,i)-nfqso).lt.10.0) candidate0(1,i)=-candidate0(1,i)
- if(i.ge.2) then
- do j=1,i-1
- fdiff=abs(candidate0(1,i))-abs(candidate0(1,j))
- if(abs(fdiff).lt.4.0) then
- if(candidate0(3,i).ge.candidate0(3,j)) candidate0(3,j)=0.
- if(candidate0(3,i).lt.candidate0(3,j)) candidate0(3,i)=0.
- endif
- enddo
- endif
- enddo
-
- fac=20.0/maxval(s)
- s=fac*s
-
-! Sort by sync
-! call indexx(candidate0(3,1:ncand),ncand,indx)
-! Sort by frequency
- call indexx(candidate0(1,1:ncand),ncand,indx)
- k=1
-! do i=ncand,1,-1
- do i=1,ncand
- j=indx(i)
-! if( candidate0(3,j) .ge. syncmin .and. candidate0(2,j).ge.-1.5 ) then
- if( candidate0(3,j) .ge. syncmin ) then
- candidate(2:3,k)=candidate0(2:3,j)
- candidate(1,k)=abs(candidate0(1,j))
- k=k+1
- endif
- enddo
- ncand=k-1
- return
-end subroutine syncft4
diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90 index b217dbb2..50c9fa47 100644 --- a/lib/ft4_decode.f90 +++ b/lib/ft4_decode.f90 @@ -24,14 +24,13 @@ module ft4_decode contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso, & - nutc,nfa,nfb,ndepth,ncontest,mycall,hiscall) + nutc,nfa,nfb,ndepth,lapcqonly,ncontest,mycall,hiscall) use timer_module, only: timer use packjt77 include 'ft4/ft4_params.f90' class(ft4_decoder), intent(inout) :: this procedure(ft4_decode_callback) :: callback - parameter (NSS=NSPS/NDOWN) - parameter (NZZ=18*3456) + parameter (NSS=NSPS/NDOWN,NDMAX=NMAX/NDOWN) character message*37,msgsent*37 character c77*77 character*37 decodes(100) @@ -42,8 +41,8 @@ contains character*6 hhmmss character*4 cqstr,cqstr0 - complex cd2(0:NZZ/NDOWN-1) !Complex waveform - complex cb(0:NZZ/NDOWN-1+NN*NSS) + complex cd2(0:NDMAX-1) !Complex waveform + complex cb(0:NDMAX-1) complex cd(0:NN*NSS-1) !Complex waveform complex ctwk(2*NSS),ctwk2(2*NSS,-16:16) complex csymb(NSS) @@ -52,7 +51,7 @@ contains real bmeta(2*NN),bmetb(2*NN),bmetc(2*NN) real a(5) - real dd(NZZ) + real dd(NMAX) real llr(2*ND),llra(2*ND),llrb(2*ND),llrc(2*ND),llrd(2*ND) real s2(0:255) real candidate(3,100) @@ -61,7 +60,7 @@ contains integer apbits(2*ND) integer apmy_ru(28),aphis_fd(28) integer icos4a(0:3),icos4b(0:3),icos4c(0:3),icos4d(0:3) - integer*2 iwave(NZZ) !Raw received data + integer*2 iwave(NMAX) !Raw received data integer*1 message77(77),rvec(77),apmask(2*ND),cw(2*ND) integer*1 hbits(2*NN) integer graymap(0:3) @@ -75,7 +74,8 @@ contains logical nohiscall,unpk77_success logical one(0:255,0:7) ! 256 4-symbol sequences, 8 bits logical first, dobigfft - logical dosubtract + logical dosubtract,doosd + logical, intent(in) :: lapcqonly data icos4a/0,1,3,2/ data icos4b/1,0,2,3/ @@ -95,6 +95,9 @@ contains this%callback => callback hhmmss=cdatetime0(8:13) + dxcall13=hiscall + mycall13=mycall + if(first) then fs=12000.0/NDOWN !Sample rate after downsampling dt=1/fs !Sample interval after downsample (s) @@ -208,21 +211,33 @@ contains fb=nfb dd=iwave -! ndepth=3: 2 passes, subtract on each pass -! ndepth=2: 1 pass, no subtraction -! ndepth=1: 1 pass, no subtraction, fewer candidates +! ndepth=3: 3 passes, bp+osd +! ndepth=2: 3 passes, bp only +! ndepth=1: 1 pass, no subtraction max_iterations=40 syncmin=1.2 dosubtract=.true. - nsp=2 - if(ndepth.lt.3) then + doosd=.true. + nsp=3 + if(ndepth.eq.2) then + doosd=.false. + endif + if(ndepth.eq.1) then nsp=1 dosubtract=.false. + doosd=.false. endif - if(ndepth.eq.1) syncmin=2.0 do isp = 1,nsp + if(isp.eq.2) then + if(ndecodes.eq.0) exit + nd1=ndecodes + elseif(isp.eq.3) then + nd2=ndecodes-nd1 + if(nd2.eq.0) exit + endif + candidate=0.0 ncand=0 call timer('getcand4',0) @@ -237,23 +252,23 @@ contains call ft4_downsample(dd,dobigfft,f0,cd2) !Downsample to 32 Sam/Sym call timer('ft4_down',1) if(dobigfft) dobigfft=.false. - sum2=sum(cd2*conjg(cd2))/(real(NZZ)/real(NDOWN)) + sum2=sum(cd2*conjg(cd2))/(real(NMAX)/real(NDOWN)) if(sum2.gt.0.0) cd2=cd2/sqrt(sum2) -! Sample rate is now 12000/16 = 750 samples/second +! Sample rate is now 12000/18 = 666.67 samples/second do isync=1,2 if(isync.eq.1) then idfmin=-12 idfmax=12 idfstp=3 - ibmin=0 - ibmax=800 + ibmin=-344 + ibmax=1012 ibstp=4 else idfmin=idfbest-4 idfmax=idfbest+4 idfstp=1 - ibmin=max(0,ibest-5) - ibmax=min(ibest+5,NZZ/NDOWN-1) + ibmin=ibest-5 + ibmax=ibest+5 ibstp=1 endif ibest=-1 @@ -279,7 +294,14 @@ contains call timer('ft4down ',1) sum2=sum(abs(cb)**2)/(real(NSS)*NN) if(sum2.gt.0.0) cb=cb/sqrt(sum2) - cd=cb(ibest:ibest+NN*NSS-1) + cd=0. + if(ibest.ge.0) then + it=min(NDMAX-1,ibest+NN*NSS-1) + np=it-ibest+1 + cd(0:np-1)=cb(ibest:it) + else + cd(-ibest:ibest+NN*NSS-1)=cb(0:NN*NSS+2*ibest-1) + endif call timer('four2a ',0) do k=1,NN i1=(k-1)*NSS @@ -386,6 +408,7 @@ contains apmag=maxval(abs(llra))*1.1 npasses=3+nappasses(nQSOProgress) + if(lapcqonly) npasses=4 if(ndepth.eq.1) npasses=3 if(ncontest.ge.5) npasses=3 ! Don't support Fox and Hound do ipass=1,npasses @@ -400,6 +423,7 @@ contains if(ipass .gt. 3) then llrd=llra iaptype=naptypes(nQSOProgress,ipass-3) + if(lapcqonly) iaptype=1 ! ncontest=0 : NONE ! 1 : NA_VHF @@ -465,10 +489,22 @@ contains llr=llrd endif message77=0 + dmin=0.0 call timer('bpdec174',0) call bpdecode174_91(llr,apmask,max_iterations,message77, & cw,nharderror,niterations) call timer('bpdec174',1) + + if(doosd .and. nharderror.lt.0) then + ndeep=3 + if(abs(nfqso-f1).le.napwid) then + ndeep=4 + endif + call timer('osd174_91 ',0) + call osd174_91(llr,apmask,ndeep,message77,cw,nharderror,dmin) + call timer('osd174_91 ',1) + endif + if(sum(message77).eq.0) cycle if( nharderror.ge.0 ) then message77=mod(message77+rvec,2) ! remove rvec scrambling @@ -476,7 +512,7 @@ contains call unpack77(c77,1,message,unpk77_success) if(unpk77_success.and.dosubtract) then call get_ft4_tones_from_77bits(message77,i4tone) - dt=real(ibest)/750.0 + dt=real(ibest)/666.67 call timer('subtract',0) call subtractft4(dd,i4tone,f0,dt) call timer('subtract',1) @@ -489,12 +525,13 @@ contains ndecodes=ndecodes+1 decodes(ndecodes)=message if(snr.gt.0.0) then - xsnr=10*log10(snr)-14.0 + xsnr=10*log10(snr)-14.8 else - xsnr=-20.0 + xsnr=-21.0 endif - nsnr=nint(max(-20.0,xsnr)) - xdt=ibest/750.0 - 0.5 + nsnr=nint(max(-21.0,xsnr)) + xdt=ibest/666.67 - 0.5 +!write(21,'(i6.6,i5,2x,f4.1,i6,2x,a37,2x,f4.1,3i3,f5.1)') nutc,nsnr,xdt,nint(f0),message,sync,iaptype,ipass,isp,dmin call this%callback(sync,nsnr,xdt,f0,message,iaptype,qual) exit endif diff --git a/lib/ft8/sync8.f90 b/lib/ft8/sync8.f90 index 3924f1ba..219c6ebf 100644 --- a/lib/ft8/sync8.f90 +++ b/lib/ft8/sync8.f90 @@ -89,7 +89,12 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, & enddo
iz=ib-ia+1
call indexx(red(ia:ib),iz,indx)
- ibase=indx(nint(0.40*iz)) - 1 + ia
+ npctile=nint(0.40*iz)
+ if(npctile.lt.1) then ! something is wrong; bail out
+ ncand=0
+ return;
+ endif
+ ibase=indx(npctile) - 1 + ia
if(ibase.lt.1) ibase=1
if(ibase.gt.nh1) ibase=nh1
base=red(ibase)
diff --git a/lib/jt4_decode.f90 b/lib/jt4_decode.f90 index da0fbda6..ff0b33c4 100644 --- a/lib/jt4_decode.f90 +++ b/lib/jt4_decode.f90 @@ -156,7 +156,7 @@ contains nfreqz=nint(dfx) call timer('sync4 ',1) - nsnr=nint(snrx) + nsnr=-26 if(sync.lt.syncmin) then if (associated (this%decode_callback)) then call this%decode_callback(nsnr,dtxz,nfreqz,.false.,csync, & @@ -166,6 +166,7 @@ contains endif ! We have achieved sync + nsnr=nint(snrsync - 22.9) decoded=blank deepmsg=blank special=' ' diff --git a/lib/jt9.f90 b/lib/jt9.f90 index aff2844e..67e7ac31 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -22,7 +22,8 @@ program jt9 !### ndepth was defined as 60001. Why??? integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, & fhigh=4000,nrxfreq=1500,ntrperiod=1,ndepth=1,nexp_decode=0 - logical :: read_files = .true., tx9 = .false., display_help = .false. + logical :: read_files = .true., tx9 = .false., display_help = .false., & + bLowSidelobes = .false. type (option) :: long_options(26) = [ & option ('help', .false., 'h', 'Display this help message', ''), & option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), & @@ -156,7 +157,7 @@ program jt9 end do go to 999 endif - + iret=fftwf_init_threads() !Initialize FFTW threading ! Default to 1 thread, but use nthreads for the big ones @@ -178,6 +179,7 @@ program jt9 go to 999 endif + if(mode.eq.5) ndepth=3 allocate(shared_data) nflatten=0 @@ -224,7 +226,7 @@ program jt9 endif shared_data%id2=0 !??? Why is this necessary ??? - if(mode.eq.5) npts=62208 + if(mode.eq.5) npts=21*3456 do iblk=1,npts/kstep k=iblk*kstep if(mode.eq.8 .and. k.gt.179712) exit @@ -242,7 +244,7 @@ program jt9 ingain=0 call timer('symspec ',0) nminw=1 - call symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb, & + call symspec(shared_data,k,ntrperiod,nsps,ingain,bLowSidelobes,nminw,pxdb, & s,df3,ihsym,npts8,pxdbmax) call timer('symspec ',1) endif diff --git a/logbook/AD1CCty.cpp b/logbook/AD1CCty.cpp index 58ed375f..23d34fb4 100644 --- a/logbook/AD1CCty.cpp +++ b/logbook/AD1CCty.cpp @@ -16,6 +16,7 @@ #include <QTextStream> #include <QDebug> #include <QDebugStateSaver> +#include "Configuration.hpp" #include "Radio.hpp" #include "pimpl_impl.hpp" @@ -155,14 +156,16 @@ typedef multi_index_container< class AD1CCty::impl final { public: - explicit impl () + using entity_by_id = entities_type::index<id>::type; + + explicit impl (Configuration const * configuration) + : configuration_ {configuration} { } - Record fixup (QString call, prefix const& p) const + entity_by_id::iterator lookup_entity (QString call, prefix const& p) const { call = call.toUpper (); - using entity_by_id = entities_type::index<id>::type; entity_by_id::iterator e; // iterator into entity set // @@ -171,23 +174,26 @@ public: if (call.startsWith ("KG4") && call.size () != 5 && call.size () != 3) { // KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo - e = entities_.project<id> (entities_.get<primary_prefix> ().find ("K")); + return entities_.project<id> (entities_.get<primary_prefix> ().find ("K")); } else { - e = entities_.get<id> ().find (p.entity_id_); + return entities_.get<id> ().find (p.entity_id_); } - + } + + Record fixup (prefix const& p, entity const& e) const + { Record result; - result.continent = e->continent_; - result.CQ_zone = e->CQ_zone_; - result.ITU_zone = e->ITU_zone_; - result.entity_name = e->name_; - result.WAE_only = e->WAE_only_; - result.latitude = e->lat_; - result.longtitude = e->long_; - result.UTC_offset = e->UTC_offset_; - result.primary_prefix = e->primary_prefix_; + result.continent = e.continent_; + result.CQ_zone = e.CQ_zone_; + result.ITU_zone = e.ITU_zone_; + result.entity_name = e.name_; + result.WAE_only = e.WAE_only_; + result.latitude = e.lat_; + result.longtitude = e.long_; + result.UTC_offset = e.UTC_offset_; + result.primary_prefix = e.primary_prefix_; // check for overrides bool ok1 {true}, ok2 {true}, ok3 {true}, ok4 {true}, ok5 {true}; @@ -220,6 +226,7 @@ public: return false; } + Configuration const * configuration_; QString path_; entities_type entities_; prefixes_type prefixes_; @@ -307,8 +314,13 @@ char const * AD1CCty::continent (Continent c) } } -AD1CCty::AD1CCty () +AD1CCty::AD1CCty (Configuration const * configuration) + : m_ {configuration} { + Q_ASSERT (configuration); + // TODO: G4WJS - consider doing the following asynchronously to + // speed up startup. Not urgent as it takes less than 1s on a Core + // i7 reading BIG CTY.DAT. QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}; m_->path_ = dataPath.exists (file_name) ? dataPath.absoluteFilePath (file_name) // user override @@ -389,7 +401,7 @@ auto AD1CCty::lookup (QString const& call) const -> Record auto p = m_->prefixes_.find (exact_search); if (p != m_->prefixes_.end () && p->exact_) { - return m_->fixup (call, *p); + return m_->fixup (*p, *m_->lookup_entity (call, *p)); } } while (search_prefix.size ()) @@ -397,9 +409,11 @@ auto AD1CCty::lookup (QString const& call) const -> Record auto p = m_->prefixes_.find (search_prefix); if (p != m_->prefixes_.end ()) { - if (!p->exact_ || call.size () == search_prefix.size ()) + impl::entity_by_id::iterator e = m_->lookup_entity (call, *p); + if ((m_->configuration_->include_WAE_entities () || !e->WAE_only_) + && (!p->exact_ || call.size () == search_prefix.size ())) { - return m_->fixup (call, *p); + return m_->fixup (*p, *e); } } search_prefix = search_prefix.left (search_prefix.size () - 1); diff --git a/logbook/AD1CCty.hpp b/logbook/AD1CCty.hpp index 37cada3e..4a485afa 100644 --- a/logbook/AD1CCty.hpp +++ b/logbook/AD1CCty.hpp @@ -1,17 +1,19 @@ #ifndef AD1C_CTY_HPP_ #define AD1C_CTY_HPP_ -#include <boost/core/noncopyable.hpp> #include <QObject> +#include <QDebug> #include "pimpl_h.hpp" +class QString; +class Configuration; + // // AD1CCty - Fast access database of Jim Reisert, AD1C's, cty.dat // entity and entity override information file. // class AD1CCty final : public QObject - , private boost::noncopyable { Q_OBJECT @@ -39,7 +41,7 @@ public: QString primary_prefix; }; - explicit AD1CCty (); + explicit AD1CCty (Configuration const *); ~AD1CCty (); Record lookup (QString const& call) const; diff --git a/logbook/Multiplier.cpp b/logbook/Multiplier.cpp new file mode 100644 index 00000000..6323e4fe --- /dev/null +++ b/logbook/Multiplier.cpp @@ -0,0 +1,44 @@ +#include "Multiplier.hpp" + +#include <QSet> +#include <QString> +#include <QDebug> +#include "models/CabrilloLog.hpp" +#include "pimpl_impl.hpp" + +class Multiplier::impl +{ +public: + impl (AD1CCty const * countries) + : countries_ {countries} + { + } + + AD1CCty const * countries_; + worked_set entities_worked_; + worked_set grids_worked_; +}; + +Multiplier::Multiplier (AD1CCty const * countries) + : m_ {countries} +{ +} + +Multiplier::~Multiplier () +{ +} + +void Multiplier::reload (CabrilloLog const * log) +{ + m_->entities_worked_ = log->unique_DXCC_entities (m_->countries_); +} + +auto Multiplier::entities_worked () const -> worked_set const& +{ + return m_->entities_worked_; +} + +auto Multiplier::grids_worked () const -> worked_set const& +{ + return m_->grids_worked_; +} diff --git a/logbook/Multiplier.hpp b/logbook/Multiplier.hpp new file mode 100644 index 00000000..2271dd77 --- /dev/null +++ b/logbook/Multiplier.hpp @@ -0,0 +1,30 @@ +#ifndef MULTIPLIER_HPP_ +#define MULTIPLIER_HPP_ + +#include <boost/core/noncopyable.hpp> +#include <QSet> +#include "pimpl_h.hpp" + +class QString; +class AD1CCty; +class CabrilloLog; + +class Multiplier final + : private boost::noncopyable +{ +public: + using worked_item = QPair<QString, QString>; + using worked_set = QSet<worked_item>; + + explicit Multiplier (AD1CCty const *); + ~Multiplier (); + void reload (CabrilloLog const *); + worked_set const& entities_worked () const; + worked_set const& grids_worked () const; + +private: + class impl; + pimpl<impl> m_; +}; + +#endif diff --git a/logbook/WorkedBefore.cpp b/logbook/WorkedBefore.cpp index daaf18fc..aa65ab65 100644 --- a/logbook/WorkedBefore.cpp +++ b/logbook/WorkedBefore.cpp @@ -18,7 +18,7 @@ #include <QFileInfo> #include <QFile> #include <QTextStream> - +#include "Configuration.hpp" #include "qt_helpers.hpp" #include "pimpl_impl.hpp" @@ -332,10 +332,15 @@ namespace // will parse a record { auto const& entity = prefixes->lookup (call); + auto mode = extractField (record, "MODE").toUpper (); + if (!mode.size () || "MFSK" == mode) + { + mode = extractField (record, "SUBMODE").toUpper (); + } worked.emplace (call.toUpper () , extractField (record, "GRIDSQUARE").left (4).toUpper () // not interested in 6-digit grids , extractField (record, "BAND").toUpper () - , extractField (record, "MODE").toUpper () + , mode , entity.entity_name , entity.continent , entity.CQ_zone @@ -356,8 +361,9 @@ namespace class WorkedBefore::impl final { public: - impl () + impl (Configuration const * configuration) : path_ {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath (logFileName)} + , prefixes_ {configuration} { } @@ -374,8 +380,10 @@ public: worked_before_database_type worked_; }; -WorkedBefore::WorkedBefore () +WorkedBefore::WorkedBefore (Configuration const * configuration) + : m_ {configuration} { + Q_ASSERT (configuration); connect (&m_->loader_watcher_, &QFutureWatcher<worked_before_database_type>::finished, [this] () { QString error; size_t n {0}; @@ -407,9 +415,9 @@ QString const& WorkedBefore::path () const return m_->path_; } -AD1CCty const& WorkedBefore::countries () const +AD1CCty const * WorkedBefore::countries () const { - return m_->prefixes_; + return &m_->prefixes_; } bool WorkedBefore::add (QString const& call diff --git a/logbook/WorkedBefore.hpp b/logbook/WorkedBefore.hpp index 90a31813..1aae1aca 100644 --- a/logbook/WorkedBefore.hpp +++ b/logbook/WorkedBefore.hpp @@ -5,6 +5,7 @@ #include "AD1CCty.hpp" #include "pimpl_h.hpp" +class Configuration; class CountryDat; class QString; class QByteArray; @@ -17,7 +18,7 @@ class WorkedBefore final public: using Continent = AD1CCty::Continent; - explicit WorkedBefore (); + explicit WorkedBefore (Configuration const *); ~WorkedBefore (); Q_SLOT void reload (); @@ -28,7 +29,7 @@ public: , QByteArray const& ADIF_record); QString const& path () const; - AD1CCty const& countries () const; + AD1CCty const * countries () const; bool country_worked (QString const& call, QString const& mode, QString const& band) const; bool grid_worked (QString const& grid, QString const& mode, QString const& band) const; bool call_worked (QString const& call, QString const& mode, QString const& band) const; diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index b84b65c1..a154664d 100644 --- a/logbook/logbook.cpp +++ b/logbook/logbook.cpp @@ -3,15 +3,25 @@ #include <QDateTime> #include "Configuration.hpp" #include "AD1CCty.hpp" +#include "Multiplier.hpp" +#include "logbook/AD1CCty.hpp" +#include "models/CabrilloLog.hpp" +#include "models/FoxLog.hpp" #include "moc_logbook.cpp" LogBook::LogBook (Configuration const * configuration) : config_ {configuration} + , worked_before_ {configuration} { + Q_ASSERT (configuration); connect (&worked_before_, &WorkedBefore::finished_loading, this, &LogBook::finished_loading); } +LogBook::~LogBook () +{ +} + void LogBook::match (QString const& call, QString const& mode, QString const& grid, AD1CCty::Record const& looked_up, bool& callB4, @@ -69,7 +79,14 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q QString t; t = "<call:" + QString::number(hisCall.length()) + ">" + hisCall; t += " <gridsquare:" + QString::number(hisGrid.length()) + ">" + hisGrid; - t += " <mode:" + QString::number(mode.length()) + ">" + mode; + if (mode != "FT4") + { + t += " <mode:" + QString::number(mode.length()) + ">" + mode; + } + else + { + t += " <mode:4>MFSK <submode:" + QString::number(mode.length()) + ">" + mode; + } t += " <rst_sent:" + QString::number(rptSent.length()) + ">" + rptSent; t += " <rst_rcvd:" + QString::number(rptRcvd.length()) + ">" + rptRcvd; t += " <qso_date:8>" + dateTimeOn.date().toString("yyyyMMdd"); @@ -89,24 +106,80 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q auto words = xSent.split (' ', QString::SkipEmptyParts); if (words.size () > 1) { - bool ok; - auto sn = words.back ().toUInt (&ok); - if (ok && sn) + if (words.back ().toUInt ()) { // assume last word is a serial if there are at least // two words and if it is positive numeric - t += " <STX:" + QString::number (words.back ().size ()) + '>' + words.back (); + t += " <stx:" + QString::number (words.back ().size ()) + '>' + words.back (); + } + else + { + if (words.front ().toUInt () && words.front ().size () > 3) // EU VHF contest mode + { + auto sn_text = words.front ().mid (2); + // assume first word is report+serial if there are + // at least two words and if the first word less the + // first two characters is a positive numeric + t += " <stx:" + QString::number (sn_text.size ()) + '>' + sn_text; + } } } } if (xRcvd.size ()) { - QString t1=""; - if(xRcvd.split(" ").size()==2) t1=xRcvd.split(" ").at(1); - if(t1.toInt()>0) { - t += " <SRX:" + QString::number(t1.length()) + ">" + t1; - } else { - t += " <STATE:" + QString::number(t1.length()) + ">" + t1; - } + auto words = xRcvd.split (' ', QString::SkipEmptyParts); + if (words.size () == 2) + { + if (words.at (1).toUInt ()) + { + t += " <srx:" + QString::number (words.at (1).length ()) + ">" + words.at (1); + } + else if (words.at (0).toUInt () && words.at (0).size () > 3) // EU VHF contest exchange + { + // strip report and set SRX to serial + t += " <srx:" + QString::number (words.at (0).mid (2).length ()) + ">" + words.at (0).mid (2); + } + else + { + t += " <state:" + QString::number (words.at (1).length ()) + ">" + words.at (1); + } + } } return t.toLatin1(); } + +CabrilloLog * LogBook::contest_log () +{ + // lazy create of Cabrillo log object instance + if (!contest_log_) + { + contest_log_.reset (new CabrilloLog {config_}); + if (!multiplier_) + { + multiplier_.reset (new Multiplier {countries ()}); + } + connect (contest_log_.data (), &CabrilloLog::data_changed, [this] () { + multiplier_->reload (contest_log_.data ()); + }); + } + return contest_log_.data (); +} + +Multiplier const * LogBook::multiplier () const +{ + // lazy create of Multiplier object instance + if (!multiplier_) + { + multiplier_.reset (new Multiplier {countries ()}); + } + return multiplier_.data (); +} + +FoxLog * LogBook::fox_log () +{ + // lazy create of Fox log object instance + if (!fox_log_) + { + fox_log_.reset (new FoxLog {config_}); + } + return fox_log_.data (); +} diff --git a/logbook/logbook.h b/logbook/logbook.h index 1850aa01..c87009e4 100644 --- a/logbook/logbook.h +++ b/logbook/logbook.h @@ -8,12 +8,16 @@ #include <QObject> #include <QString> +#include <QScopedPointer> #include "WorkedBefore.hpp" class Configuration; class QByteArray; class QDateTime; +class CabrilloLog; +class Multiplier; +class FoxLog; class LogBook final : public QObject @@ -22,13 +26,14 @@ class LogBook final public: LogBook (Configuration const *); + ~LogBook (); QString const& path () const {return worked_before_.path ();} bool add (QString const& call , QString const& grid , QString const& band , QString const& mode , QByteArray const& ADIF_record); - AD1CCty const& countries () const {return worked_before_.countries ();} + AD1CCty const * countries () const {return worked_before_.countries ();} void rescan (); void match (QString const& call, QString const& mode, QString const& grid, AD1CCty::Record const&, bool& callB4, bool& countryB4, @@ -43,9 +48,16 @@ public: Q_SIGNAL void finished_loading (int worked_before_record_count, QString const& error) const; + CabrilloLog * contest_log (); + Multiplier const * multiplier () const; + FoxLog * fox_log (); + private: Configuration const * config_; WorkedBefore worked_before_; + QScopedPointer<CabrilloLog> contest_log_; + QScopedPointer<Multiplier> mutable multiplier_; + QScopedPointer<FoxLog> fox_log_; }; #endif diff --git a/logbook/logbook.pri b/logbook/logbook.pri index fcac6252..e67cdebd 100644 --- a/logbook/logbook.pri +++ b/logbook/logbook.pri @@ -2,10 +2,12 @@ SOURCES += \ logbook/countriesworked.cpp \ logbook/logbook.cpp \ logbook/AD1CCty.cpp \ - logbook/WorkedBefore.cpp + logbook/WorkedBefore.cpp \ + logbook/Multiplier.cpp HEADERS += \ logbook/WorkedBefore.hpp \ logbook/logbook.h \ logbook/countriesworked.h \ - logbook/AD1CCty.hpp + logbook/AD1CCty.hpp \ + logbook/Multiplier.hpp @@ -380,10 +380,12 @@ int main(int argc, char *argv[]) } catch (std::exception const& e) { + MessageBox::critical_message (nullptr, QApplication::translate ("main", "Fatal error"), e.what ()); std::cerr << "Error: " << e.what () << '\n'; } catch (...) { + MessageBox::critical_message (nullptr, QApplication::translate ("main", "Unexpected fatal error")); std::cerr << "Unexpected fatal error\n"; throw; // hoping the runtime might tell us more about the exception } diff --git a/models/CabrilloLog.cpp b/models/CabrilloLog.cpp index 1fee9b14..dfba3d43 100644 --- a/models/CabrilloLog.cpp +++ b/models/CabrilloLog.cpp @@ -12,6 +12,7 @@ #include <QDataStream> #include "Configuration.hpp" #include "Bands.hpp" +#include "logbook/AD1CCty.hpp" #include "qt_db_helpers.hpp" #include "pimpl_impl.hpp" @@ -19,42 +20,109 @@ class CabrilloLog::impl final : public QSqlTableModel { public: - impl (Configuration const *); + impl (CabrilloLog *, Configuration const *); + + int columnCount (QModelIndex const& /*index */) const override + { + return QSqlTableModel::columnCount () + 1; + } + + Qt::ItemFlags flags (QModelIndex const& index) const override + { + auto flags = QSqlTableModel::flags (index); + if (index.isValid () && index.column () == columnCount (index) - 1) + { + flags = Qt::ItemIsEnabled; + } + return flags; + } + + QVariant data (QModelIndex const& model_index, int role) const override + { + QVariant value; + if (model_index.isValid () && model_index.column () == columnCount (model_index) - 1) + { // derive band column + if (Qt::DisplayRole == role) + { + value = configuration_->bands ()->find (QSqlTableModel::data (index (model_index.row (), fieldIndex ("frequency"))).toULongLong ()); + } + } + else + { + value = QSqlTableModel::data (model_index, role); + if (model_index.column () == fieldIndex ("frequency") && Qt::DisplayRole == role) + { + value = Radio::frequency_MHz_string (value.value<Radio::Frequency> (), 3); // kHz precision + } + else if (model_index.column () == fieldIndex ("when") + && (Qt::DisplayRole == role || Qt::EditRole == role)) + { // adjust date/time to Qt format + auto t = QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC); + if (Qt::DisplayRole == role) + { + QLocale locale; + return locale.toString (t, locale.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); + } + value = t; + } + } + return value; + } QString cabrillo_frequency_string (Radio::Frequency frequency) const; + void create_table (); + CabrilloLog * self_; Configuration const * configuration_; QSqlQuery mutable dupe_query_; QSqlQuery mutable export_query_; + bool adding_row_; }; -CabrilloLog::impl::impl (Configuration const * configuration) - : QSqlTableModel {} +CabrilloLog::impl::impl (CabrilloLog * self, Configuration const * configuration) + : self_ {self} , configuration_ {configuration} + , adding_row_ {false} { - if (!database ().tables ().contains ("cabrillo_log")) + if (!database ().tables ().contains ("cabrillo_log_v2")) { - QSqlQuery query; - SQL_error_check (query, static_cast<bool (QSqlQuery::*) (QString const&)> (&QSqlQuery::exec), - "CREATE TABLE cabrillo_log (" - " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," - " frequency INTEGER NOT NULL," - " \"when\" DATETIME NOT NULL," - " call VARCHAR(20) NOT NULL," - " exchange_sent VARCHAR(32) NOT NULL," - " exchange_rcvd VARCHAR(32) NOT NULL," - " band VARCHAR(6) NOT NULL" - ")"); + create_table (); } + setEditStrategy (QSqlTableModel::OnFieldChange); + setTable ("cabrillo_log_v2"); + setHeaderData (fieldIndex ("frequency"), Qt::Horizontal, tr ("Freq(MHz)")); + setHeaderData (fieldIndex ("mode"), Qt::Horizontal, tr ("Mode")); + setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)")); + setHeaderData (fieldIndex ("call"), Qt::Horizontal, tr ("Call")); + setHeaderData (fieldIndex ("exchange_sent"), Qt::Horizontal, tr ("Sent")); + setHeaderData (fieldIndex ("exchange_rcvd"), Qt::Horizontal, tr ("Rcvd")); + setHeaderData (columnCount (QModelIndex {}) - 1, Qt::Horizontal, tr ("Band")); + + // This descending order by time is important, it makes the view + // place the latest row at the top, without this the model/view + // interactions are both sluggish and unhelpful. + setSort (fieldIndex ("when"), Qt::DescendingOrder); + + connect (this, &CabrilloLog::impl::modelReset, self_, &CabrilloLog::data_changed); + connect (this, &CabrilloLog::impl::dataChanged, [this] (QModelIndex const& tl, QModelIndex const& br) { + if (!adding_row_ && !(tl == br)) // ignore single cell changes + // as a another change for the + // whole row will follow + { + Q_EMIT self_->data_changed (); + } + }); + + SQL_error_check (*this, &QSqlTableModel::select); + SQL_error_check (dupe_query_, &QSqlQuery::prepare, "SELECT " - " COUNT(*) " + " frequency " " FROM " - " cabrillo_log " + " cabrillo_log_v2 " " WHERE " - " call = :call " - " AND band = :band"); + " call = :call "); SQL_error_check (export_query_, &QSqlQuery::prepare, "SELECT " @@ -64,32 +132,31 @@ CabrilloLog::impl::impl (Configuration const * configuration) " , call" " , exchange_rcvd" " FROM " - " cabrillo_log " + " cabrillo_log_v2 " " ORDER BY " " \"when\""); - - setEditStrategy (QSqlTableModel::OnFieldChange); - setTable ("cabrillo_log"); - setHeaderData (fieldIndex ("frequency"), Qt::Horizontal, tr ("Freq(kHz)")); - setHeaderData (fieldIndex ("when"), Qt::Horizontal, tr ("Date & Time(UTC)")); - setHeaderData (fieldIndex ("call"), Qt::Horizontal, tr ("Call")); - setHeaderData (fieldIndex ("exchange_sent"), Qt::Horizontal, tr ("Sent")); - setHeaderData (fieldIndex ("exchange_rcvd"), Qt::Horizontal, tr ("Rcvd")); - setHeaderData (fieldIndex ("band"), Qt::Horizontal, tr ("Band")); - - // This descending order by time is important, it makes the view - // place the latest row at the top, without this the model/view - // interactions are both sluggish and unhelpful. - setSort (fieldIndex ("when"), Qt::DescendingOrder); +} - SQL_error_check (*this, &QSqlTableModel::select); +void CabrilloLog::impl::create_table () +{ + QSqlQuery query; + SQL_error_check (query, static_cast<bool (QSqlQuery::*) (QString const&)> (&QSqlQuery::exec), + "CREATE TABLE cabrillo_log_v2 (" + " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," + " frequency INTEGER NOT NULL," + " mode VARCHAR(6) NOT NULL," + " \"when\" DATETIME NOT NULL," + " call VARCHAR(20) NOT NULL," + " exchange_sent VARCHAR(32) NOT NULL," + " exchange_rcvd VARCHAR(32) NOT NULL" + ")"); } // frequency here is in kHz QString CabrilloLog::impl::cabrillo_frequency_string (Radio::Frequency frequency) const { QString result; - auto band = configuration_->bands ()->find (frequency * 1000ull); + auto band = configuration_->bands ()->find (frequency); if ("1mm" == band) result = "LIGHT"; else if ("2mm" == band) result = "241G"; else if ("2.5mm" == band) result = "134G"; @@ -107,12 +174,15 @@ QString CabrilloLog::impl::cabrillo_frequency_string (Radio::Frequency frequency else if ("2m" == band) result = "144"; else if ("4m" == band) result = "70"; else if ("6m" == band) result = "50"; - else result = QString::number (frequency); + else result = QString::number (frequency / 1000ull); return result; } -CabrilloLog::CabrilloLog (Configuration const * configuration) - : m_ {configuration} +#include "moc_CabrilloLog.cpp" + +CabrilloLog::CabrilloLog (Configuration const * configuration, QObject * parent) + : QObject {parent} + , m_ {this, configuration} { Q_ASSERT (configuration); } @@ -141,11 +211,12 @@ namespace } } -bool CabrilloLog::add_QSO (Frequency frequency, QDateTime const& when, QString const& call +bool CabrilloLog::add_QSO (Frequency frequency, QString const& mode, QDateTime const& when, QString const& call , QString const& exchange_sent, QString const& exchange_received) { auto record = m_->record (); - record.setValue ("frequency", frequency / 1000ull); // kHz + record.setValue ("frequency", frequency); + record.setValue ("mode", mode); if (!when.isNull ()) { record.setValue ("when", when.toMSecsSinceEpoch () / 1000ull); @@ -157,15 +228,16 @@ bool CabrilloLog::add_QSO (Frequency frequency, QDateTime const& when, QString c set_value_maybe_null (record, "call", call); set_value_maybe_null (record, "exchange_sent", exchange_sent); set_value_maybe_null (record, "exchange_rcvd", exchange_received); - set_value_maybe_null (record, "band", m_->configuration_->bands ()->find (frequency)); if (m_->isDirty ()) { m_->revert (); // discard any uncommitted changes } m_->setEditStrategy (QSqlTableModel::OnManualSubmit); ConditionalTransaction transaction {*m_}; + m_->adding_row_ = true; auto ok = m_->insertRecord (-1, record); transaction.submit (); + m_->adding_row_ = false; m_->setEditStrategy (QSqlTableModel::OnFieldChange); return ok; } @@ -173,10 +245,18 @@ bool CabrilloLog::add_QSO (Frequency frequency, QDateTime const& when, QString c bool CabrilloLog::dupe (Frequency frequency, QString const& call) const { m_->dupe_query_.bindValue (":call", call); - m_->dupe_query_.bindValue (":band", m_->configuration_->bands ()->find (frequency)); SQL_error_check (m_->dupe_query_, static_cast<bool (QSqlQuery::*) ()> (&QSqlQuery::exec)); - m_->dupe_query_.next (); - return m_->dupe_query_.value (0).toInt (); + auto record = m_->dupe_query_.record (); + auto frequency_index = record.indexOf ("frequency"); + while (m_->dupe_query_.next ()) + { + if (m_->configuration_->bands ()->find (m_->dupe_query_.value (frequency_index).toULongLong ()) + == m_->configuration_->bands ()->find (frequency)) + { + return true; + } + } + return false; } void CabrilloLog::reset () @@ -191,6 +271,7 @@ void CabrilloLog::reset () transaction.submit (); m_->select (); // to refresh views m_->setEditStrategy (QSqlTableModel::OnFieldChange); + Q_EMIT data_changed (); } } @@ -199,6 +280,7 @@ void CabrilloLog::export_qsos (QTextStream& stream) const SQL_error_check (m_->export_query_, static_cast<bool (QSqlQuery::*) ()> (&QSqlQuery::exec)); auto record = m_->export_query_.record (); auto frequency_index = record.indexOf ("frequency"); + // auto mode_index = record.indexOf ("mode"); auto when_index = record.indexOf ("when"); auto call_index = record.indexOf ("call"); auto sent_index = record.indexOf ("exchange_sent"); @@ -215,3 +297,17 @@ void CabrilloLog::export_qsos (QTextStream& stream) const .arg (m_->export_query_.value (rcvd_index).toString (), -13); } } + +auto CabrilloLog::unique_DXCC_entities (AD1CCty const * countries) const -> worked_set +{ + QSqlQuery q {"SELECT DISTINCT BAND, CALL FROM cabrillo_log_v2"}; + auto band_index = q.record ().indexOf ("band"); + auto call_index = q.record ().indexOf ("call"); + worked_set entities; + while (q.next ()) + { + entities << worked_item {q.value (band_index).toString () + , countries->lookup (q.value (call_index).toString ()).primary_prefix}; + } + return entities; +} diff --git a/models/CabrilloLog.hpp b/models/CabrilloLog.hpp index 43b9e8f9..97d8f0d8 100644 --- a/models/CabrilloLog.hpp +++ b/models/CabrilloLog.hpp @@ -1,33 +1,43 @@ #ifndef CABRILLO_LOG_HPP_ #define CABRILLO_LOG_HPP_ -#include <boost/core/noncopyable.hpp> +#include <QObject> +#include <QSet> +#include <QPair> +#include <QString> #include "Radio.hpp" #include "pimpl_h.hpp" class Configuration; class QDateTime; -class QString; class QSqlTableModel; class QTextStream; +class AD1CCty; class CabrilloLog final - : private boost::noncopyable + : public QObject { + Q_OBJECT + public: using Frequency = Radio::Frequency; + using worked_item = QPair<QString, QString>; + using worked_set = QSet<worked_item>; - explicit CabrilloLog (Configuration const *); + explicit CabrilloLog (Configuration const *, QObject * parent = nullptr); ~CabrilloLog (); // returns false if insert fails - bool add_QSO (Frequency, QDateTime const&, QString const& call + bool add_QSO (Frequency, QString const& mode, QDateTime const&, QString const& call , QString const& report_sent, QString const& report_received); bool dupe (Frequency, QString const& call) const; QSqlTableModel * model (); void reset (); void export_qsos (QTextStream&) const; + worked_set unique_DXCC_entities (AD1CCty const *) const; + + Q_SIGNAL void data_changed () const; private: class impl; diff --git a/models/FoxLog.cpp b/models/FoxLog.cpp index 773a5308..debb08af 100644 --- a/models/FoxLog.cpp +++ b/models/FoxLog.cpp @@ -21,6 +21,23 @@ class FoxLog::impl final public: impl (Configuration const * configuration); + QVariant data (QModelIndex const& index, int role) const + { + auto value = QSqlTableModel::data (index, role); + if (index.column () == fieldIndex ("when") + && (Qt::DisplayRole == role || Qt::EditRole == role)) + { + auto t = QDateTime::fromMSecsSinceEpoch (value.toULongLong () * 1000ull, Qt::UTC); + if (Qt::DisplayRole == role) + { + QLocale locale; + return locale.toString (t, locale.dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); + } + value = t; + } + return value; + } + Configuration const * configuration_; QSqlQuery mutable dupe_query_; QSqlQuery mutable export_query_; diff --git a/models/FrequencyList.cpp b/models/FrequencyList.cpp index b135a512..c0170a49 100644 --- a/models/FrequencyList.cpp +++ b/models/FrequencyList.cpp @@ -127,7 +127,9 @@ namespace {7074000, Modes::FT8, IARURegions::ALL}, {7076000, Modes::JT65, IARURegions::ALL}, {7078000, Modes::JT9, IARURegions::ALL}, - {7047000, Modes::FT4, IARURegions::ALL}, // provisional + {7047500, Modes::FT4, IARURegions::ALL}, // provisional - moved + // up 500Hz to clear + // W1AW code practice QRG // Band plans (all USB dial unless stated otherwise) // diff --git a/qt_db_helpers.hpp b/qt_db_helpers.hpp index 49a082f7..dcf9d033 100644 --- a/qt_db_helpers.hpp +++ b/qt_db_helpers.hpp @@ -6,6 +6,7 @@ #include <QString> #include <QSqlError> #include <QSqlTableModel> +#include "boost/core/noncopyable.hpp" template<typename T, typename Func, typename... Args> void SQL_error_check (T&& object, Func func, Args&&... args) diff --git a/shortcuts.txt b/shortcuts.txt index 4356664c..10276a26 100644 --- a/shortcuts.txt +++ b/shortcuts.txt @@ -35,6 +35,7 @@ <tr><td><b>Alt+M </b></td><td>Monitor</td></tr> <tr><td><b>Alt+N </b></td><td>Enable Tx</td></tr> <tr><td><b>Ctrl+O </b></td><td>Open a .wav file</td></tr> + <tr><td><b>Alt+O </b></td><td>Change operator</td></tr> <tr><td><b>Alt+Q </b></td><td>Log QSO</td></tr> <tr><td><b>Alt+S </b></td><td>Stop monitoring</td></tr> <tr><td><b>Alt+T </b></td><td>Tune</td></tr> diff --git a/soundout.cpp b/soundout.cpp index b21675b3..0264ad91 100644 --- a/soundout.cpp +++ b/soundout.cpp @@ -9,11 +9,14 @@ #include "moc_soundout.cpp" +/* #if defined (WIN32) # define MS_BUFFERED 1000u #else # define MS_BUFFERED 2000u #endif +*/ +# define MS_BUFFERED 200u bool SoundOutput::audioError () const { diff --git a/widgets/CabrilloLogWindow.cpp b/widgets/CabrilloLogWindow.cpp index 44a52cc6..6fd75313 100644 --- a/widgets/CabrilloLogWindow.cpp +++ b/widgets/CabrilloLogWindow.cpp @@ -1,12 +1,13 @@ #include "CabrilloLogWindow.hpp" +#include <stdexcept> #include <QApplication> #include <QIdentityProxyModel> #include <QSqlTableModel> #include "Configuration.hpp" #include "models/Bands.hpp" +#include "item_delegates/FrequencyDelegate.hpp" #include "item_delegates/ForeignKeyDelegate.hpp" -#include "item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp" #include "item_delegates/CallsignDelegate.hpp" #include "pimpl_impl.hpp" @@ -30,7 +31,7 @@ namespace switch (index.column ()) { case 1: - case 6: + case 7: return Qt::AlignRight + Qt::AlignVCenter; default: break; @@ -64,11 +65,10 @@ CabrilloLogWindow::CabrilloLogWindow (QSettings * settings, Configuration const m_->format_model_.setSourceModel (m_->log_model_); m_->ui_.log_table_view->setModel (&m_->format_model_); set_log_view (m_->ui_.log_table_view); - m_->ui_.log_table_view->setItemDelegateForColumn (2, new DateTimeAsSecsSinceEpochDelegate {this}); - m_->ui_.log_table_view->setItemDelegateForColumn (3, new CallsignDelegate {this}); - m_->ui_.log_table_view->setItemDelegateForColumn (6, new ForeignKeyDelegate {configuration->bands (), 0, this}); + m_->ui_.log_table_view->setItemDelegateForColumn (1, new FrequencyDelegate {this}); + m_->ui_.log_table_view->setItemDelegateForColumn (4, new CallsignDelegate {this}); auto h_header = m_->ui_.log_table_view->horizontalHeader (); - h_header->moveSection (6, 1); // band to first column + h_header->moveSection (7, 1); // band to first column } CabrilloLogWindow::~CabrilloLogWindow () diff --git a/widgets/CabrilloLogWindow.ui b/widgets/CabrilloLogWindow.ui index efefe5d3..35b4d597 100644 --- a/widgets/CabrilloLogWindow.ui +++ b/widgets/CabrilloLogWindow.ui @@ -19,6 +19,9 @@ <property name="toolTip"> <string><html><head/><body><p>Right-click here for available actions.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Right-click here for available actions.</string> + </property> <attribute name="horizontalHeaderStretchLastSection"> <bool>true</bool> </attribute> diff --git a/widgets/DateTimeEdit.hpp b/widgets/DateTimeEdit.hpp new file mode 100644 index 00000000..ad767a55 --- /dev/null +++ b/widgets/DateTimeEdit.hpp @@ -0,0 +1,23 @@ +#ifndef DATE_TIME_EDIT_HPP_ +#define DATE_TIME_EDIT_HPP_ + +#include <QDateTimeEdit> + +class QWidget; + +// +// DateTimeEdit - format includes seconds +// +class DateTimeEdit final + : public QDateTimeEdit +{ +public: + explicit DateTimeEdit (QWidget * parent = nullptr) + : QDateTimeEdit {parent} + { + setDisplayFormat (locale ().dateFormat (QLocale::ShortFormat) + " hh:mm:ss"); + setTimeSpec (Qt::UTC); + } +}; + +#endif diff --git a/widgets/FoxLogWindow.cpp b/widgets/FoxLogWindow.cpp index 36f20b85..9c29a30a 100644 --- a/widgets/FoxLogWindow.cpp +++ b/widgets/FoxLogWindow.cpp @@ -13,7 +13,6 @@ #include "models/Bands.hpp" #include "models/FoxLog.hpp" #include "item_delegates/ForeignKeyDelegate.hpp" -#include "item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp" #include "item_delegates/CallsignDelegate.hpp" #include "item_delegates/MaidenheadLocatorDelegate.hpp" #include "pimpl_impl.hpp" @@ -42,7 +41,6 @@ FoxLogWindow::FoxLogWindow (QSettings * settings, Configuration const * configur m_->ui_.setupUi (this); m_->ui_.log_table_view->setModel (m_->log_->model ()); set_log_view (m_->ui_.log_table_view); - m_->ui_.log_table_view->setItemDelegateForColumn (1, new DateTimeAsSecsSinceEpochDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (2, new CallsignDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (3, new MaidenheadLocatorDelegate {this}); m_->ui_.log_table_view->setItemDelegateForColumn (6, new ForeignKeyDelegate {configuration->bands (), 0, this}); diff --git a/widgets/FrequencyDeltaLineEdit.cpp b/widgets/FrequencyDeltaLineEdit.cpp new file mode 100644 index 00000000..b7ed144b --- /dev/null +++ b/widgets/FrequencyDeltaLineEdit.cpp @@ -0,0 +1,54 @@ +#include "FrequencyDeltaLineEdit.hpp" + +#include <limits> + +#include <QDoubleValidator> +#include <QString> +#include <QLocale> + +#include "moc_FrequencyDeltaLineEdit.cpp" + +namespace +{ + class MHzValidator + : public QDoubleValidator + { + public: + MHzValidator (double bottom, double top, QObject * parent = nullptr) + : QDoubleValidator {bottom, top, 6, parent} + { + } + + State validate (QString& input, int& pos) const override + { + State result = QDoubleValidator::validate (input, pos); + if (Acceptable == result) + { + bool ok; + (void)QLocale {}.toDouble (input, &ok); + if (!ok) + { + result = Intermediate; + } + } + return result; + } + }; +} + +FrequencyDeltaLineEdit::FrequencyDeltaLineEdit (QWidget * parent) + : QLineEdit (parent) +{ + setValidator (new MHzValidator {-std::numeric_limits<FrequencyDelta>::max () / 10.e6, + std::numeric_limits<FrequencyDelta>::max () / 10.e6, this}); +} + +auto FrequencyDeltaLineEdit::frequency_delta () const -> FrequencyDelta +{ + return Radio::frequency_delta (text (), 6); +} + +void FrequencyDeltaLineEdit::frequency_delta (FrequencyDelta d) +{ + setText (Radio::frequency_MHz_string (d)); +} diff --git a/widgets/FrequencyDeltaLineEdit.hpp b/widgets/FrequencyDeltaLineEdit.hpp new file mode 100644 index 00000000..caa00ecb --- /dev/null +++ b/widgets/FrequencyDeltaLineEdit.hpp @@ -0,0 +1,29 @@ +#ifndef FREQUENCY_DELTA_LINE_EDIT_HPP_ +#define FREQUENCY_DELTA_LINE_EDIT_HPP_ + +#include <QLineEdit> + +#include "Radio.hpp" + +class QWidget; + +// +// MHz frequency delta line edit with validation +// +class FrequencyDeltaLineEdit final + : public QLineEdit +{ + Q_OBJECT; + Q_PROPERTY (FrequencyDelta frequency_delta READ frequency_delta WRITE frequency_delta USER true); + +public: + using FrequencyDelta = Radio::FrequencyDelta; + + explicit FrequencyDeltaLineEdit (QWidget * parent = nullptr); + + // Property frequency_delta implementation + FrequencyDelta frequency_delta () const; + void frequency_delta (FrequencyDelta); +}; + +#endif diff --git a/widgets/FrequencyLineEdit.cpp b/widgets/FrequencyLineEdit.cpp index 78f8b2e1..1ca2ba20 100644 --- a/widgets/FrequencyLineEdit.cpp +++ b/widgets/FrequencyLineEdit.cpp @@ -51,21 +51,3 @@ void FrequencyLineEdit::frequency (Frequency f) { setText (Radio::frequency_MHz_string (f)); } - - -FrequencyDeltaLineEdit::FrequencyDeltaLineEdit (QWidget * parent) - : QLineEdit (parent) -{ - setValidator (new MHzValidator {-std::numeric_limits<FrequencyDelta>::max () / 10.e6, - std::numeric_limits<FrequencyDelta>::max () / 10.e6, this}); -} - -auto FrequencyDeltaLineEdit::frequency_delta () const -> FrequencyDelta -{ - return Radio::frequency_delta (text (), 6); -} - -void FrequencyDeltaLineEdit::frequency_delta (FrequencyDelta d) -{ - setText (Radio::frequency_MHz_string (d)); -} diff --git a/widgets/FrequencyLineEdit.hpp b/widgets/FrequencyLineEdit.hpp index dec0feb0..7e535f5a 100644 --- a/widgets/FrequencyLineEdit.hpp +++ b/widgets/FrequencyLineEdit.hpp @@ -8,7 +8,7 @@ class QWidget; // -// MHz frequency line edits with validation +// MHz frequency line edit with validation // class FrequencyLineEdit final : public QLineEdit @@ -26,20 +26,4 @@ public: void frequency (Frequency); }; -class FrequencyDeltaLineEdit final - : public QLineEdit -{ - Q_OBJECT; - Q_PROPERTY (FrequencyDelta frequency_delta READ frequency_delta WRITE frequency_delta USER true); - -public: - using FrequencyDelta = Radio::FrequencyDelta; - - explicit FrequencyDeltaLineEdit (QWidget * parent = nullptr); - - // Property frequency_delta implementation - FrequencyDelta frequency_delta () const; - void frequency_delta (FrequencyDelta); -}; - #endif diff --git a/widgets/astro.cpp b/widgets/astro.cpp index 4ee55da4..c1eee015 100644 --- a/widgets/astro.cpp +++ b/widgets/astro.cpp @@ -11,6 +11,7 @@ #include <QDir> #include <QCloseEvent> #include <QDebug> +#include <math.h> #include "commons.h" #include "MessageBox.hpp" @@ -90,7 +91,7 @@ void Astro::write_settings () } auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const& hisgrid, Frequency freq, - bool dx_is_self, bool bTx, bool no_tx_QSY, int TR_period) -> Correction + bool dx_is_self, bool bTx, bool no_tx_QSY, double TR_period) -> Correction { Frequency freq_moon {freq}; double azsun,elsun,azmoon,elmoon,azmoondx,elmoondx; @@ -211,8 +212,8 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const // // use a base time of (secs-since-epoch + 2) so as to be sure // we do the next period if we calculate just before it starts - auto sec_since_epoch = t.toMSecsSinceEpoch () / 1000 + 2; - auto target_sec = sec_since_epoch - sec_since_epoch % TR_period + TR_period / 2; + auto sec_since_epoch = t.toMSecsSinceEpoch ()/1000 + 2; + auto target_sec = sec_since_epoch - fmod(double(sec_since_epoch),TR_period) + 0.5*TR_period; auto target_date_time = QDateTime::fromMSecsSinceEpoch (target_sec * 1000, Qt::UTC); QString date {target_date_time.date().toString("yyyy MMM dd").trimmed ()}; QString utc {target_date_time.time().toString().trimmed ()}; diff --git a/widgets/astro.h b/widgets/astro.h index 03d8c66c..4f7f71d5 100644 --- a/widgets/astro.h +++ b/widgets/astro.h @@ -44,7 +44,7 @@ public: bool dx_is_self, bool bTx, bool no_tx_QSY, - int TR_period); + double TR_period); bool doppler_tracking () const; Q_SLOT void nominal_frequency (Frequency rx, Frequency tx); diff --git a/widgets/displaytext.cpp b/widgets/displaytext.cpp index c0bcd412..53d7cd5c 100644 --- a/widgets/displaytext.cpp +++ b/widgets/displaytext.cpp @@ -271,7 +271,7 @@ QString DisplayText::appendWorkedB4 (QString message, QString call, QString cons if(call.length()<3) return message; if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message; - auto const& looked_up = logBook.countries ().lookup (call); + auto const& looked_up = logBook.countries ()->lookup (call); logBook.match (call, currentMode, grid, looked_up, callB4, countryB4, gridB4, continentB4, CQZoneB4, ITUZoneB4); logBook.match (call, currentMode, grid, looked_up, callB4onBand, countryB4onBand, gridB4onBand, continentB4onBand, CQZoneB4onBand, ITUZoneB4onBand, currentBand); diff --git a/widgets/displaytext.h b/widgets/displaytext.h index 7f308bef..8b580b8a 100644 --- a/widgets/displaytext.h +++ b/widgets/displaytext.h @@ -65,6 +65,4 @@ private: int modified_vertical_scrollbar_max_; }; - extern QHash<QString,int> m_LoTW; - #endif // DISPLAYTEXT_H diff --git a/widgets/fastgraph.cpp b/widgets/fastgraph.cpp index e599138f..9efe5fc6 100644 --- a/widgets/fastgraph.cpp +++ b/widgets/fastgraph.cpp @@ -86,9 +86,9 @@ void FastGraph::on_greenZeroSlider_valueChanged(int value) ui->fastPlot->draw(); } -void FastGraph::setTRPeriod(int n) +void FastGraph::setTRPeriod(double p) { - m_TRperiod=n; + m_TRperiod=p; ui->fastPlot->setTRperiod(m_TRperiod); } diff --git a/widgets/fastgraph.h b/widgets/fastgraph.h index 7ed32671..b5f7c0b8 100644 --- a/widgets/fastgraph.h +++ b/widgets/fastgraph.h @@ -22,7 +22,7 @@ public: void plotSpec(bool diskData, int UTCdisk); void saveSettings(); - void setTRPeriod(int n); + void setTRPeriod(double p); void setMode(QString mode); signals: @@ -40,8 +40,8 @@ protected: private: QSettings * m_settings; - float m_ave; - qint32 m_TRperiod; + float m_ave; + double m_TRperiod; QScopedPointer<Ui::FastGraph> ui; }; diff --git a/widgets/fastplot.cpp b/widgets/fastplot.cpp index 1437834d..a388f0ac 100644 --- a/widgets/fastplot.cpp +++ b/widgets/fastplot.cpp @@ -135,11 +135,11 @@ void FPlotter::setGreenZero(int n) m_bPaint2=true; } -void FPlotter::setTRperiod(int n) +void FPlotter::setTRperiod(double p) { - m_TRperiod=n; + m_TRperiod=p; m_pixPerSecond=12000.0/512.0; - if(m_TRperiod<30) m_pixPerSecond=12000.0/256.0; + if(m_TRperiod<30.0) m_pixPerSecond=12000.0/256.0; drawScale(); update(); } diff --git a/widgets/fastplot.h b/widgets/fastplot.h index b1391338..f24fcc24 100644 --- a/widgets/fastplot.h +++ b/widgets/fastplot.h @@ -37,7 +37,7 @@ public: void setPlotZero(int plotZero); void setPlotGain(int plotGain); void setGreenZero(int n); - void setTRperiod(int n); + void setTRperiod(double p); void drawScale(); void setMode(QString mode); @@ -68,6 +68,7 @@ private: QString m_mode; double m_pixPerSecond; + double m_TRperiod; qint32 m_hdivs; qint32 m_h; @@ -75,7 +76,6 @@ private: qint32 m_h2; QPixmap m_HorizPixmap; qint32 m_jh0; - qint32 m_TRperiod; bool m_bPaint2; }; diff --git a/widgets/logqso.cpp b/widgets/logqso.cpp index eae82aac..2eaedf11 100644 --- a/widgets/logqso.cpp +++ b/widgets/logqso.cpp @@ -1,12 +1,9 @@ #include "logqso.h" -#include <random> -#include <limits> #include <QString> #include <QSettings> #include <QStandardPaths> #include <QDir> -#include <QPushButton> #include "logbook/logbook.h" #include "MessageBox.hpp" @@ -18,40 +15,18 @@ #include "ui_logqso.h" #include "moc_logqso.cpp" -namespace -{ - using dist_type = std::uniform_int_distribution<int>; - std::random_device rd; - std::mt19937 twister (rd ()); - dist_type int_distribution; -} - LogQSO::LogQSO(QString const& programTitle, QSettings * settings - , Configuration const * config, QWidget *parent) + , Configuration const * config, LogBook * log, QWidget *parent) : QDialog {parent, Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint} , ui(new Ui::LogQSO) - , ok_ {new QPushButton {"OK", this}} - , cancel_ {new QPushButton {"Cancel", this}} , m_settings (settings) , m_config {config} + , m_log {log} { ui->setupUi(this); setWindowTitle(programTitle + " - Log QSO"); - ui->grid->setValidator (new MaidenheadLocatorValidator {this}); - - ok_->setAutoDefault (false); - ok_->setFocusPolicy (Qt::ClickFocus); - cancel_->setAutoDefault (false); - ui->button_layout->addStretch (); - ui->button_layout->addWidget (ok_); - ui->button_layout->addStretch (); - ui->button_layout->addWidget (cancel_); - ui->button_layout->addStretch (); - loadSettings (); - - connect (ok_, &QAbstractButton::clicked, [this] (bool) {accept ();}); - connect (cancel_, &QAbstractButton::clicked, [this] (bool) {reject ();}); + ui->grid->setValidator (new MaidenheadLocatorValidator {this}); } LogQSO::~LogQSO () @@ -83,8 +58,7 @@ void LogQSO::storeSettings () const void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, - Radio::Frequency dialFreq, bool noSuffix, QString xSent, QString xRcvd, - CabrilloLog * cabrillo_log) + Radio::Frequency dialFreq, bool noSuffix, QString xSent, QString xRcvd) { if(!isHidden()) return; ui->call->setText (hisCall); @@ -126,7 +100,6 @@ void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString ui->loggedOperator->setText(m_config->opCall()); ui->exchSent->setText (xSent); ui->exchRcvd->setText (xRcvd); - m_cabrilloLog = cabrillo_log; using SpOp = Configuration::SpecialOperatingActivity; auto special_op = m_config->special_op_id (); @@ -139,22 +112,7 @@ void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString } else { - // randomize accessible name of buttons - ok_->setAccessibleName (QString::number (int_distribution (twister))); - cancel_->setAccessibleName (QString::number (int_distribution (twister))); - // random sibling order of buttons - if (int_distribution (twister, dist_type::param_type {0, 1})) ok_->stackUnder (cancel_); else cancel_->stackUnder (ok_); - // random shuffle of layout items - for (int item = ui->button_layout->count () - 1; item > 0; --item) - { - auto other_item = int_distribution (twister, dist_type::param_type {0, item}); - if (item != other_item) - { - ui->button_layout->insertItem (other_item, ui->button_layout->takeAt (item)); - ui->button_layout->insertItem (item, ui->button_layout->takeAt (other_item + 1)); - } - } - show (); + show(); } } @@ -199,7 +157,7 @@ void LogQSO::accept() return; // without accepting } - if (!m_cabrilloLog->add_QSO (m_dialFreq, dateTimeOff, hisCall, xsent, xrcvd)) + if (!m_log->contest_log ()->add_QSO (m_dialFreq, mode, dateTimeOff, hisCall, xsent, xrcvd)) { show (); MessageBox::warning_message (this, tr ("Invalid QSO Data"), diff --git a/widgets/logqso.h b/widgets/logqso.h index 5cbb2044..739a601f 100644 --- a/widgets/logqso.h +++ b/widgets/logqso.h @@ -17,20 +17,19 @@ namespace Ui { class QSettings; class Configuration; class QByteArray; -class CabrilloLog; -class QPushButton; +class LogBook; class LogQSO : public QDialog { Q_OBJECT public: - explicit LogQSO(QString const& programTitle, QSettings *, Configuration const *, QWidget *parent = 0); + explicit LogQSO(QString const& programTitle, QSettings *, Configuration const *, LogBook *, QWidget *parent = 0); ~LogQSO(); void initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, Radio::Frequency dialFreq, - bool noSuffix, QString xSent, QString xRcvd, CabrilloLog *); + bool noSuffix, QString xSent, QString xRcvd); public slots: void accept(); @@ -53,16 +52,14 @@ private: void storeSettings () const; QScopedPointer<Ui::LogQSO> ui; - QPushButton * ok_; - QPushButton * cancel_; QSettings * m_settings; Configuration const * m_config; + LogBook * m_log; QString m_txPower; QString m_comments; Radio::Frequency m_dialFreq; QString m_myCall; QString m_myGrid; - CabrilloLog * m_cabrilloLog; }; #endif // LogQSO_H diff --git a/widgets/logqso.ui b/widgets/logqso.ui index 7d249677..a03a3028 100644 --- a/widgets/logqso.ui +++ b/widgets/logqso.ui @@ -461,7 +461,14 @@ </spacer> </item> <item> - <layout class="QHBoxLayout" name="button_layout"/> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> </item> </layout> </widget> @@ -481,5 +488,38 @@ <tabstop>cbComments</tabstop> </tabstops> <resources/> - <connections/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>LogQSO</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>LogQSO</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index b96240cb..277dbfdd 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -37,6 +37,7 @@ #include <QSplashScreen> #include <QUdpSocket> #include <QAbstractItemView> +#include <QInputDialog> #include "revision_utils.hpp" #include "qt_helpers.hpp" @@ -243,10 +244,10 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_echoGraph (new EchoGraph(m_settings)), m_fastGraph (new FastGraph(m_settings)), // no parent so that it has a taskbar icon - m_logDlg (new LogQSO (program_title (), m_settings, &m_config, nullptr)), + m_logDlg (new LogQSO (program_title (), m_settings, &m_config, &m_logBook, nullptr)), m_lastDialFreq {0}, m_dialFreqRxWSPR {0}, - m_detector {new Detector {RX_SAMPLE_RATE, NTMAX, downSampleFactor}}, + m_detector {new Detector {RX_SAMPLE_RATE, double(NTMAX), downSampleFactor}}, m_FFTSize {6192 / 2}, // conservative value to avoid buffer overruns m_soundInput {new SoundInput}, m_modulator {new Modulator {TX_SAMPLE_RATE, NTMAX}}, @@ -257,6 +258,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_freqTxNominal {0}, m_s6 {0.}, m_tRemaining {0.}, + m_TRperiod {60.0}, m_DTtol {3.0}, m_waterfallAvg {1}, m_ntx {1}, @@ -268,7 +270,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_nutc0 {999999}, m_ntr {0}, m_tx {0}, - m_TRperiod {60}, m_inGain {0}, m_secID {0}, m_idleMinutes {0}, @@ -877,7 +878,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, connect (&m_wav_future_watcher, &QFutureWatcher<void>::finished, this, &MainWindow::diskDat); connect(&watcher3, SIGNAL(finished()),this,SLOT(fast_decode_done())); -// Q_EMIT startAudioInputStream (m_config.audio_input_device (), m_framesAudioInputBuffered, &m_detector, m_downSampleFactor, m_config.audio_input_channel ()); Q_EMIT startAudioInputStream (m_config.audio_input_device (), m_framesAudioInputBuffered, m_detector, m_downSampleFactor, m_config.audio_input_channel ()); Q_EMIT initializeAudioOutputStream (m_config.audio_output_device (), AudioDevice::Mono == m_config.audio_output_channel () ? 1 : 2, m_msAudioOutputBuffered); Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value () - m_XIT); @@ -993,11 +993,17 @@ void MainWindow::not_GA_warning_message () MessageBox::critical_message (this, "<b><p align=\"center\">" "This is a pre-release version of WSJT-X 2.1.0 made " - "available for testing purposes. It will become nonfunctional " - "after June 7, 2019."); - QDateTime now=QDateTime::currentDateTime(); - QDateTime timeout=QDateTime(QDate(2019,6,7)); - if(now.daysTo(timeout) < 0) Q_EMIT finished(); + "available for testing purposes. By design it will " + "be nonfunctional during the 2019 ARRL June VHF contest " + "(June 8-10) and Field Day (June 22-23) weekends. It " + "will be permanently nonfunctional after July 21, 2019."); + auto now = QDateTime::currentDateTimeUtc (); + if ((QDateTime {{2019, 6, 8}, {18, 0}, Qt::UTC} <= now + && now < QDateTime {{2019, 6, 10}, {3, 0}, Qt::UTC}) + || now >= QDateTime {{2019, 7, 21}, {0, 0}, Qt::UTC}) + { + Q_EMIT finished (); + } } void MainWindow::initialize_fonts () @@ -1323,7 +1329,7 @@ void MainWindow::fixStop() } else if (m_mode=="FT8") { m_hsymStop=50; } else if (m_mode=="FT4") { - m_hsymStop=18; + m_hsymStop=21; } } @@ -1355,7 +1361,7 @@ void MainWindow::dataSink(qint64 frames) } // Get power, spectrum, and ihsym - int trmin=m_TRperiod/60; + int trmin=m_TRperiod/60.0; // int k (frames - 1); dec_data.params.nfa=m_wideGraph->nStartFreq(); dec_data.params.nfb=m_wideGraph->Fmax(); @@ -1452,19 +1458,20 @@ void MainWindow::dataSink(qint64 frames) if(!m_mode.startsWith ("WSPR")) decode(); //Start decoder if(!m_diskData) { //Always save; may delete later - if(m_mode=="FT8" or m_mode=="FT4") { - int n=now.time().second() % m_TRperiod; + int n=fmod(double(now.time().second()),m_TRperiod); if(n<(m_TRperiod/2)) n=n+m_TRperiod; auto const& period_start=now.addSecs(-n); m_fnameWE=m_config.save_directory().absoluteFilePath (period_start.toString("yyMMdd_hhmmss")); +// qDebug() << "datasink 2" << QDateTime::currentDateTimeUtc().toString("ss.zzz") +// << n << period_start.toString("ss.zzz"); } else { - auto const& period_start = now.addSecs (-(now.time ().minute () % (m_TRperiod / 60)) * 60); + auto const& period_start = now.addSecs (-(now.time ().minute () % (int(m_TRperiod) / 60)) * 60); m_fnameWE=m_config.save_directory ().absoluteFilePath (period_start.toString ("yyMMdd_hhmm")); } m_fileToSave.clear (); int samples=m_TRperiod*12000; - if(m_mode=="FT4") samples=18*3456; + if(m_mode=="FT4") samples=21*3456; // the following is potential a threading hazard - not a good // idea to pass pointer to be processed in another thread @@ -1589,7 +1596,7 @@ void MainWindow::fastSink(qint64 frames) int ihr=tnow.toString("hh").toInt(); int imin=tnow.toString("mm").toInt(); int isec=tnow.toString("ss").toInt(); - isec=isec - isec%m_TRperiod; + isec=isec - fmod(double(isec),m_TRperiod); int nutc0=10000*ihr + 100*imin + isec; if(m_diskData) nutc0=m_UTCdisk; char line[80]; @@ -1669,7 +1676,7 @@ void MainWindow::fastSink(qint64 frames) if(decodeNow or m_bFastDone) { if(!m_diskData) { QDateTime now {QDateTime::currentDateTimeUtc()}; - int n=now.time().second() % m_TRperiod; + int n=fmod(double(now.time().second()),m_TRperiod); if(n<(m_TRperiod/2)) n=n+m_TRperiod; auto const& period_start = now.addSecs (-n); m_fnameWE = m_config.save_directory ().absoluteFilePath (period_start.toString ("yyMMdd_hhmmss")); @@ -1679,11 +1686,11 @@ void MainWindow::fastSink(qint64 frames) // the following is potential a threading hazard - not a good // idea to pass pointer to be processed in another thread m_saveWAVWatcher.setFuture (QtConcurrent::run (std::bind (&MainWindow::save_wave_file, - this, m_fnameWE, &dec_data.d2[0], m_TRperiod*12000, m_config.my_callsign(), + this, m_fnameWE, &dec_data.d2[0], int(m_TRperiod*12000.0), m_config.my_callsign(), m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid))); } if(m_mode!="MSK144") { - killFileTimer.start (3*1000*m_TRperiod/4); //Kill 3/4 period from now + killFileTimer.start (int(750.0*m_TRperiod)); //Kill 3/4 period from now } } m_bFastDone=false; @@ -1751,7 +1758,7 @@ void MainWindow::on_actionSettings_triggered() //Setup Dialog bool b = vhf && (m_mode=="JT4" or m_mode=="JT65" or m_mode=="ISCAT" or m_mode=="JT9" or m_mode=="MSK144" or m_mode=="QRA64"); if(b) VHF_features_enabled(b); - if(m_mode=="FT4") on_actionFT8_triggered(); + if(m_mode=="FT4") on_actionFT4_triggered(); if(m_mode=="FT8") on_actionFT8_triggered(); if(m_mode=="JT4") on_actionJT4_triggered(); if(m_mode=="JT9") on_actionJT9_triggered(); @@ -1984,7 +1991,7 @@ void MainWindow::keyPressEvent (QKeyEvent * e) if(e->modifiers() & Qt::ControlModifier) n+=100; if(e->modifiers() & Qt::ShiftModifier) { int offset=60; - if(m_mode=="FT4") offset=120; + if(m_mode=="FT4") offset=100; ui->TxFreqSpinBox->setValue(ui->TxFreqSpinBox->value()-offset); } else{ bumpFqso(n); @@ -2000,7 +2007,7 @@ void MainWindow::keyPressEvent (QKeyEvent * e) if(e->modifiers() & Qt::ControlModifier) n+=100; if(e->modifiers() & Qt::ShiftModifier) { int offset=60; - if(m_mode=="FT4") offset=120; + if(m_mode=="FT4") offset=100; ui->TxFreqSpinBox->setValue(ui->TxFreqSpinBox->value()+offset); } else { bumpFqso(n); @@ -2060,6 +2067,15 @@ void MainWindow::keyPressEvent (QKeyEvent * e) on_actionOpen_triggered(); return; } + else if(e->modifiers() & Qt::AltModifier) { + bool ok; + auto call = QInputDialog::getText (this, tr ("Change Operator"), tr ("New operator:"), + QLineEdit::Normal, m_config.opCall (), &ok); + if (ok) { + m_config.opCall (call); + } + return; + } break; case Qt::Key_V: if(e->modifiers() & Qt::AltModifier) { @@ -2218,7 +2234,6 @@ void MainWindow::createStatusBar() //createStatusBar statusBar()->addPermanentWidget(&progressBar); progressBar.setMinimumSize (QSize {150, 18}); - progressBar.setFormat ("%v/%m"); statusBar ()->addPermanentWidget (&watchdog_label); update_watchdog_label (); @@ -2529,16 +2544,14 @@ void MainWindow::on_actionAstronomical_data_toggled (bool checked) void MainWindow::on_fox_log_action_triggered() { - if (!m_foxLog) m_foxLog.reset (new FoxLog {&m_config}); if (!m_foxLogWindow) { - m_foxLogWindow.reset (new FoxLogWindow {m_settings, &m_config, m_foxLog.data ()}); + m_foxLogWindow.reset (new FoxLogWindow {m_settings, &m_config, m_logBook.fox_log ()}); // Connect signals from fox log window connect (this, &MainWindow::finished, m_foxLogWindow.data (), &FoxLogWindow::close); connect (m_foxLogWindow.data (), &FoxLogWindow::reset_log_model, [this] () { - if (!m_foxLog) m_foxLog.reset (new FoxLog {&m_config}); - m_foxLog->reset (); + m_logBook.fox_log ()->reset (); }); } m_foxLogWindow->showNormal (); @@ -2548,10 +2561,9 @@ void MainWindow::on_fox_log_action_triggered() void MainWindow::on_contest_log_action_triggered() { - if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); if (!m_contestLogWindow) { - m_contestLogWindow.reset (new CabrilloLogWindow {m_settings, &m_config, m_cabrilloLog->model ()}); + m_contestLogWindow.reset (new CabrilloLogWindow {m_settings, &m_config, m_logBook.contest_log ()->model ()}); // Connect signals from contest log window connect (this, &MainWindow::finished, m_contestLogWindow.data (), &CabrilloLogWindow::close); @@ -2631,7 +2643,8 @@ void MainWindow::read_wav_file (QString const& fname) bool ok=file.open (BWFFile::ReadOnly); if(ok) { auto bytes_per_frame = file.format ().bytesPerFrame (); - qint64 max_bytes = std::min (std::size_t (m_TRperiod * RX_SAMPLE_RATE), + int nsamples=m_TRperiod * RX_SAMPLE_RATE; + qint64 max_bytes = std::min (std::size_t (nsamples), sizeof (dec_data.d2) / sizeof (dec_data.d2[0]))* bytes_per_frame; auto n = file.read (reinterpret_cast<char *> (dec_data.d2), std::min (max_bytes, file.size ())); @@ -2822,7 +2835,7 @@ void MainWindow::decode() //decode() } m_msec0=QDateTime::currentMSecsSinceEpoch(); - if(!m_dataAvailable or m_TRperiod==0) return; + if(!m_dataAvailable or m_TRperiod==0.0) return; ui->DecodeButton->setChecked (true); if(!dec_data.params.nagain && m_diskData && !m_bFastMode && m_mode!="FT8" && m_mode!="FT4") { dec_data.params.nutc=dec_data.params.nutc/100; @@ -2832,14 +2845,16 @@ void MainWindow::decode() //decode() int imin=ms/60000; int ihr=imin/60; imin=imin % 60; - if(m_TRperiod>=60) imin=imin - (imin % (m_TRperiod/60)); + if(m_TRperiod>=60) imin=imin - (imin % (int(m_TRperiod)/60)); dec_data.params.nutc=100*ihr + imin; if(m_mode=="ISCAT" or m_mode=="MSK144" or m_bFast9 or m_mode=="FT8" or m_mode=="FT4") { - QDateTime t=QDateTime::currentDateTimeUtc().addSecs(2-m_TRperiod); + qint64 ms=1000.0*(2.0-m_TRperiod); + if(m_mode=="FT4") ms=1000.0*(2.0-m_TRperiod); + QDateTime t=QDateTime::currentDateTimeUtc().addMSecs(ms); ihr=t.toString("hh").toInt(); imin=t.toString("mm").toInt(); int isec=t.toString("ss").toInt(); - isec=isec - isec%m_TRperiod; + isec=isec - fmod(double(isec),m_TRperiod); dec_data.params.nutc=10000*ihr + 100*imin + isec; } } @@ -2849,7 +2864,7 @@ void MainWindow::decode() //decode() int ihr=t.toString("hh").toInt(); int imin=t.toString("mm").toInt(); int isec=t.toString("ss").toInt(); - isec=isec - isec%m_TRperiod; + isec=isec - fmod(double(isec),m_TRperiod); dec_data.params.nutc=10000*ihr + 100*imin + isec; } if(m_nPick==2) dec_data.params.nutc=m_nutc0; @@ -2948,8 +2963,8 @@ void MainWindow::decode() //decode() } static short int d2b[360000]; narg[0]=dec_data.params.nutc; - if(m_kdone>12000*m_TRperiod) { - m_kdone=12000*m_TRperiod; + if(m_kdone>int(12000.0*m_TRperiod)) { + m_kdone=int(12000.0*m_TRperiod); } narg[1]=m_kdone; narg[2]=m_nSubMode; @@ -2968,9 +2983,10 @@ void MainWindow::decode() //decode() narg[12]=0; narg[13]=-1; narg[14]=m_config.aggressive(); + int nTRperiod=m_TRperiod; memcpy(d2b,dec_data.d2,2*360000); watcher3.setFuture (QtConcurrent::run (std::bind (fast_decode_,&d2b[0], - &narg[0],&m_TRperiod,&m_msg[0][0], + &narg[0],&nTRperiod,&m_msg[0][0], dec_data.params.mycall,dec_data.params.hiscall,8000,12,12))); } else { memcpy(to, from, qMin(mem_jt9->size(), size)); @@ -3055,7 +3071,7 @@ void MainWindow::readFromStdout() //readFromStdout if(line_read.indexOf("<DecodeFinished>") >= 0) { if(m_mode=="QRA64") m_wideGraph->drawRed(0,0); m_bDecoded = line_read.mid(20).trimmed().toInt() > 0; - int mswait=3*1000*m_TRperiod/4; + int mswait=750.0*m_TRperiod; if(!m_diskData) killFileTimer.start(mswait); //Kill in 3/4 period decodeDone (); m_startAnother=m_loopall; @@ -3065,7 +3081,7 @@ void MainWindow::readFromStdout() //readFromStdout } return; } else { - if(m_mode=="JT4" or m_mode=="JT65" or m_mode=="QRA64" or m_mode=="FT8" or m_mode=="FT4") { + if(m_mode=="JT4" or m_mode=="JT65" or m_mode=="QRA64") { int n=line_read.indexOf("f"); if(n<0) n=line_read.indexOf("d"); if(n>0) { @@ -3081,7 +3097,7 @@ void MainWindow::readFromStdout() //readFromStdout write_all("Rx",line_read.trimmed()); if (m_config.insert_blank () && m_blankLine && SpecOp::FOX != m_config.special_op_id()) { QString band; - if((QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged) > 4*m_TRperiod/4) { + if((QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged) > 4*int(m_TRperiod)/4) { band = ' ' + m_config.bands ()->find (m_freqNominal); } ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); @@ -3241,7 +3257,7 @@ void MainWindow::readFromStdout() //readFromStdout } // extract details and send to PSKreporter int nsec=QDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged; - bool okToPost=(nsec>(4*m_TRperiod)/5); + bool okToPost=(nsec > int(4*m_TRperiod)/5); if (stdMsg && okToPost) pskPost(decodedtext); if((m_mode=="JT4" or m_mode=="JT65" or m_mode=="QRA64") and m_msgAvgWidget!=NULL) { @@ -3341,7 +3357,7 @@ void MainWindow::pskPost (DecodedText const& decodedtext) QString grid; decodedtext.deCallAndGrid(/*out*/deCall,grid); int audioFrequency = decodedtext.frequencyOffset(); - if(m_mode=="FT8" or m_mode=="MSK144") { + if(m_mode=="FT8" or m_mode=="MSK144" or m_mode=="FT4") { audioFrequency=decodedtext.string().mid(16,4).toInt(); } int snr = decodedtext.snr(); @@ -3421,9 +3437,9 @@ void MainWindow::guiUpdate() double txDuration; QString rt; - if(m_TRperiod==0) m_TRperiod=60; + if(m_TRperiod==0) m_TRperiod=60.0; txDuration=0.0; - if(m_modeTx=="FT4") txDuration=0.35 + 105*512/12000.0; // FT4 + if(m_modeTx=="FT4") txDuration=1.0 + 105*576/12000.0; // FT4 if(m_modeTx=="FT8") txDuration=1.0 + 79*1920/12000.0; // FT8 if(m_modeTx=="JT4") txDuration=1.0 + 207.0*2520/11025.0; // JT4 if(m_modeTx=="JT9") txDuration=1.0 + 85.0*m_nsps/12000.0; // JT9 @@ -3451,8 +3467,8 @@ void MainWindow::guiUpdate() double tsec=0.001*ms; double t2p=fmod(tsec,2*m_TRperiod); m_s6=fmod(tsec,6.0); - m_nseq = nsec % m_TRperiod; - m_tRemaining=m_TRperiod - fmod(tsec,double(m_TRperiod)); + m_nseq = fmod(double(nsec),m_TRperiod); + m_tRemaining=m_TRperiod - fmod(tsec,m_TRperiod); if(m_mode=="Echo") { txDuration=2.4; @@ -3493,10 +3509,9 @@ void MainWindow::guiUpdate() if(m_transmitting or m_auto or m_tune) { m_dateTimeLastTX = QDateTime::currentDateTimeUtc (); -// Check for "txboth" (testing purposes only) +// Check for "txboth" (FT4 testing purposes only) QFile f(m_appDir + "/txboth"); - if(f.exists() and - fmod(tsec,m_TRperiod)<(1.0 + 85.0*m_nsps/12000.0)) m_bTxTime=true; + if(f.exists() and fmod(tsec,m_TRperiod) < (0.5 + 105.0*576.0/12000.0)) m_bTxTime=true; // Don't transmit another mode in the 30 m WSPR sub-band Frequency onAirFreq = m_freqNominal + ui->TxFreqSpinBox->value(); @@ -3539,7 +3554,7 @@ void MainWindow::guiUpdate() tx_watchdog (true); // disable transmit } - float fTR=float((ms%(1000*m_TRperiod)))/(1000*m_TRperiod); + float fTR=float((ms%int(1000.0*m_TRperiod)))/int(1000.0*m_TRperiod); QString txMsg; if(m_ntx == 1) txMsg=ui->tx1->text(); @@ -3744,7 +3759,7 @@ void MainWindow::guiUpdate() genft4_(message, &ichk, msgsent, const_cast<char *> (ft4msgbits), const_cast<int *>(itone), 37, 37); int nsym=103; - int nsps=4*512; + int nsps=4*576; float fsample=48000.0; float f0=ui->TxFreqSpinBox->value() - m_XIT; int nwave=(nsym+2)*nsps; @@ -3943,7 +3958,7 @@ void MainWindow::guiUpdate() //Once per second: if(nsec != m_sec0) { -// qDebug() << "cc onesec" << (SpecOp::RTTY == m_config.special_op_id()); +// qDebug() << "onesec" << m_config.force_call_1st(); // if((!m_msgAvgWidget or (m_msgAvgWidget and !m_msgAvgWidget->isVisible())) // and (SpecOp::NONE < m_config.special_op_id()) and (SpecOp::HOUND > m_config.special_op_id())) on_actionFox_Log_triggered(); if(m_freqNominal!=0 and m_freqNominal<50000000 and m_config.enable_VHF_features()) { @@ -3959,17 +3974,21 @@ void MainWindow::guiUpdate() if(tHound >= 120 and m_ntx==1) auto_tx_mode(false); } -// progressBar.setVisible(!(m_mode=="FT4")); progressBar.setVisible(true); + progressBar.setFormat ("%v/%m"); if(m_auto and m_mode=="Echo" and m_bEchoTxOK) { - progressBar.setMaximum(6); + progressBar.setMaximum(3); progressBar.setValue(int(m_s6)); } -// if(m_mode!="Echo" and m_mode!="FT4") { if(m_mode!="Echo") { if(m_monitoring or m_transmitting) { progressBar.setMaximum(m_TRperiod); int isec=int(fmod(tsec,m_TRperiod)); + if(m_TRperiod-int(m_TRperiod)>0.0) { + QString progBarLabel; + progBarLabel.sprintf("%d/%3.1f",isec,m_TRperiod); + progressBar.setFormat (progBarLabel); + } progressBar.setValue(isec); } else { progressBar.setValue(0); @@ -4068,6 +4087,10 @@ void MainWindow::startTx2() t=ui->tx6->text(); if(t.mid(0,1)=="#") snr=t.mid(1,5).toDouble(); if(snr>0.0 or snr < -50.0) snr=99.0; + if((m_ntx==6 or m_ntx==7) and m_config.force_call_1st()) { + ui->cbAutoSeq->setChecked(true); + ui->cbFirst->setChecked(true); + } transmit (snr); ui->signal_meter_widget->setValue(0,0); if(m_mode=="Echo" and !m_tune) m_bTransmittedEcho=true; @@ -4108,8 +4131,7 @@ void MainWindow::stopTx2() on_stopTxButton_clicked (); m_nTx73 = 0; } - if(((m_mode.startsWith("WSPR") and m_ntr==-1) or m_mode=="FT4") and - !m_tuneup) { + if((m_mode.startsWith("WSPR") and m_ntr==-1) and !m_tuneup) { m_wideGraph->setWSPRtransmitted(); WSPR_scheduling (); m_ntr=0; @@ -4153,7 +4175,8 @@ void MainWindow::set_dateTimeQSO(int m_ntx) } else { // we also take of m_TRperiod/2 to allow for late clicks auto now = QDateTime::currentDateTimeUtc(); - m_dateTimeQSOOn = now.addSecs (-(m_ntx - 2) * m_TRperiod - (now.time ().second () % m_TRperiod)); + m_dateTimeQSOOn = now.addSecs (-(m_ntx - 2) * int(m_TRperiod) - + int(fmod(double(now.time().second()),m_TRperiod))); } } @@ -4219,7 +4242,7 @@ void MainWindow::on_txrb4_doubleClicked () auto const& my_callsign = m_config.my_callsign (); auto is_compound = my_callsign != m_baseCall; m_send_RR73 = !((is_compound && !shortList (my_callsign)) || m_send_RR73); - if(m_mode=="FT4") m_send_RR73=true; + if(m_mode=="FT4" and (m_config.special_op_id()==SpecOp::RTTY)) m_send_RR73=true; genStdMsgs (m_rpt); } @@ -4406,7 +4429,7 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie } } - int nmod = message.timeInSeconds () % (2*m_TRperiod); + int nmod = fmod(double(message.timeInSeconds()),2.0*m_TRperiod); m_txFirst=(nmod!=0); if( SpecOp::HOUND == m_config.special_op_id() ) m_txFirst=false; //Hound must not transmit first if( SpecOp::FOX == m_config.special_op_id() ) m_txFirst=true; //Fox must always transmit first @@ -4599,7 +4622,6 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie logQSOTimer.start(0); m_ntx=6; ui->txrb6->setChecked(true); - ui->cbFirst->setChecked(false); } else { m_ntx=5; ui->txrb5->setChecked(true); @@ -5066,7 +5088,7 @@ void MainWindow::genStdMsgs(QString rpt, bool unconditional) msgtype(t, ui->tx4); t=t0 + "73"; - if((m_mode=="MSK144" and !m_bShMsgs) or m_mode=="FT8") { + if((m_mode=="MSK144" and !m_bShMsgs) or m_mode=="FT8" or m_mode=="FT4") { if(!bHisCall and bMyCall) t=hisCall + " <" + my_callsign + "> 73"; if(bHisCall and !bMyCall) t="<" + hisCall + "> " + my_callsign + " 73"; } @@ -5082,7 +5104,7 @@ void MainWindow::genStdMsgs(QString rpt, bool unconditional) } } - if(m_mode=="FT8" or m_mode=="MSK144") return; + if(m_mode=="FT8" or m_mode=="FT4" or m_mode=="MSK144") return; if (is_compound) { if (is_type_one) { @@ -5496,15 +5518,9 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button default: break; } - auto special_op = m_config.special_op_id (); - if (SpecOp::NONE < special_op && special_op < SpecOp::FOX) - { - if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); - } m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd, m_dateTimeQSOOn, dateTimeQSOOff, m_freqNominal + - ui->TxFreqSpinBox->value(), m_noSuffix, m_xSent, m_xRcvd, - m_cabrilloLog.data ()); + ui->TxFreqSpinBox->value(), m_noSuffix, m_xSent, m_xRcvd); m_inQSOwith=""; } @@ -5633,7 +5649,7 @@ void MainWindow::on_actionFT4_triggered() { m_mode="FT4"; m_modeTx="FT4"; - m_TRperiod=6; + m_TRperiod=7.5; bool bVHF=m_config.enable_VHF_features(); m_bFast9=false; m_bFastMode=false; @@ -5642,9 +5658,9 @@ void MainWindow::on_actionFT4_triggered() m_nsps=6912; m_FFTSize = m_nsps/2; Q_EMIT FFTSize (m_FFTSize); - m_hsymStop=18; + m_hsymStop=21; setup_status_bar (bVHF); - m_toneSpacing=12000.0/512.0; + m_toneSpacing=12000.0/576.0; ui->actionFT4->setChecked(true); m_wideGraph->setMode(m_mode); m_wideGraph->setModeTx(m_modeTx); @@ -5694,7 +5710,7 @@ void MainWindow::on_actionFT8_triggered() m_wideGraph->setModeTx(m_modeTx); VHF_features_enabled(bVHF); ui->cbAutoSeq->setChecked(true); - m_TRperiod=15; + m_TRperiod=15.0; m_fastGraph->hide(); m_wideGraph->show(); ui->decodedTextLabel2->setText(" UTC dB DT Freq Message"); @@ -5783,7 +5799,7 @@ void MainWindow::on_actionJT4_triggered() WSPR_config(false); switch_mode (Modes::JT4); m_modeTx="JT4"; - m_TRperiod=60; + m_TRperiod=60.0; m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe m_nsps=6912; //For symspec only @@ -5856,7 +5872,7 @@ void MainWindow::on_actionJT9_triggered() ui->decodedTextLabel2->setText("UTC dB T Freq Message"); } else { ui->cbAutoSeq->setChecked(false); - m_TRperiod=60; + m_TRperiod=60.0; ui->decodedTextLabel->setText("UTC dB DT Freq Message"); ui->decodedTextLabel2->setText("UTC dB DT Freq Message"); } @@ -5885,7 +5901,7 @@ void MainWindow::on_actionJT9_JT65_triggered() m_modeTx="JT9"; } m_nSubMode=0; //Dual-mode always means JT9 and JT65A - m_TRperiod=60; + m_TRperiod=60.0; m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe m_nsps=6912; @@ -5927,7 +5943,7 @@ void MainWindow::on_actionJT65_triggered() WSPR_config(false); switch_mode (Modes::JT65); if(m_modeTx!="JT65") on_pbTxMode_clicked(); - m_TRperiod=60; + m_TRperiod=60.0; m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe m_nsps=6912; //For symspec only @@ -6103,7 +6119,7 @@ void MainWindow::on_actionWSPR_triggered() WSPR_config(true); switch_mode (Modes::WSPR); m_modeTx="WSPR"; - m_TRperiod=120; + m_TRperiod=120.0; m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe m_nsps=6912; //For symspec only @@ -6131,7 +6147,7 @@ void MainWindow::on_actionWSPR_LF_triggered() m_mode="WSPR-LF"; switch_mode (Modes::WSPR); m_modeTx="WSPR-LF"; - m_TRperiod=240; + m_TRperiod=240.0; m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe m_hsymStop=813; @@ -6147,7 +6163,7 @@ void MainWindow::on_actionEcho_triggered() on_actionJT4_triggered(); m_mode="Echo"; ui->actionEcho->setChecked(true); - m_TRperiod=3; + m_TRperiod=3.0; m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe m_nsps=6912; //For symspec only @@ -6344,15 +6360,13 @@ void MainWindow::on_reset_cabrillo_log_action_triggered () "for export in your Cabrillo log."))) { if(m_config.RTTY_Exchange()!="SCC") ui->sbSerialNumber->setValue(1); - if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); - m_cabrilloLog->reset (); + m_logBook.contest_log ()->reset (); } } void MainWindow::on_actionExport_Cabrillo_log_triggered() { - if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); - if (QDialog::Accepted == ExportCabrillo {m_settings, &m_config, m_cabrilloLog.data ()}.exec()) + if (QDialog::Accepted == ExportCabrillo {m_settings, &m_config, m_logBook.contest_log ()}.exec()) { MessageBox::information_message (this, tr ("Cabrillo Log saved")); } @@ -6426,7 +6440,6 @@ void MainWindow::on_bandComboBox_activated (int index) void MainWindow::band_changed (Frequency f) { -// bool monitor_off=!m_monitoring; // Set the attenuation value if options are checked QString curBand = ui->bandComboBox->currentText(); if (m_config.pwrBandTxMemory() && !m_tune) { @@ -6462,7 +6475,6 @@ void MainWindow::band_changed (Frequency f) if(r<0.9 or r>1.1) m_bVHFwarned=false; setRig (f); setXIT (ui->TxFreqSpinBox->value ()); -// if(monitor_off) monitor(false); } } @@ -6943,7 +6955,7 @@ void MainWindow::transmit (double snr) m_dateTimeSentTx3=QDateTime::currentDateTimeUtc(); toneSpacing=-2.0; //Transmit a pre-computed, filtered waveform. Q_EMIT sendMessage (NUM_FT4_SYMBOLS, - 512.0, ui->TxFreqSpinBox->value() - m_XIT, + 576.0, ui->TxFreqSpinBox->value() - m_XIT, toneSpacing, m_soundOutput, m_config.audio_output_channel(), true, false, snr, m_TRperiod); } @@ -7246,7 +7258,7 @@ void MainWindow::on_sbSubmode_valueChanged(int n) on_cbFast9_clicked(false); ui->cbFast9->setEnabled(false); ui->sbTR->setVisible(false); - m_TRperiod=60; + m_TRperiod=60.0; } else { ui->cbFast9->setEnabled(true); } @@ -7268,9 +7280,9 @@ void MainWindow::on_cbFast9_clicked(bool b) if(b) { m_TRperiod = ui->sbTR->value (); } else { - m_TRperiod=60; + m_TRperiod=60.0; } - progressBar.setMaximum(m_TRperiod); + progressBar.setMaximum(int(m_TRperiod)); m_wideGraph->setPeriod(m_TRperiod,m_nsps); fast_config(b); statusChanged (); @@ -7550,8 +7562,8 @@ void MainWindow::p1ReadFromStdout() //p1readFromStdout if(grid!="") { double utch=0.0; int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter; - azdist_(const_cast <char *> (m_config.my_grid ().toLatin1().constData()), - const_cast <char *> (grid.toLatin1().constData()),&utch, + azdist_(const_cast <char *> ((m_config.my_grid () + " ").left (6).toLatin1 ().constData ()), + const_cast <char *> ((grid + " ").left (6).toLatin1 ().constData ()),&utch, &nAz,&nEl,&nDmiles,&nDkm,&nHotAz,&nHotABetter,6,6); QString t1; if(m_config.miles()) { @@ -7814,7 +7826,7 @@ void MainWindow::setRig (Frequency f) void MainWindow::fastPick(int x0, int x1, int y) { float pixPerSecond=12000.0/512.0; - if(m_TRperiod<30) pixPerSecond=12000.0/256.0; + if(m_TRperiod<30.0) pixPerSecond=12000.0/256.0; if(m_mode!="ISCAT" and m_mode!="MSK144") return; if(!m_decoderBusy) { dec_data.params.newdat=0; @@ -8015,7 +8027,7 @@ void MainWindow::write_transmit_entry (QString const& file_name) { QTextStream out(&f); auto time = QDateTime::currentDateTimeUtc (); - time = time.addSecs (-(time.time ().second () % m_TRperiod)); + time = time.addSecs (-fmod(double(time.time().second()),m_TRperiod)); out << time.toString("yyMMdd_hhmmss") << " Transmitting " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " << m_modeTx @@ -8255,7 +8267,7 @@ void MainWindow::houndCallers() if(!ui->textBrowser4->toPlainText().contains(paddedHoundCall)) { if(m_loggedByFox[houndCall].contains(m_lastBand)) continue; //already logged on this band if(m_foxQSO.contains(houndCall)) continue; //still in the QSO map - auto const& entity = m_logBook.countries ().lookup (houndCall); + auto const& entity = m_logBook.countries ()->lookup (houndCall); auto const& continent = AD1CCty::continent (entity.continent); //If we are using a directed CQ, ignore Hound calls that do not comply. @@ -8436,9 +8448,8 @@ list2Done: m_hisGrid=m_foxQSO[hc1].grid; m_rptSent=m_foxQSO[hc1].sent; m_rptRcvd=m_foxQSO[hc1].rcvd; - if (!m_foxLog) m_foxLog.reset (new FoxLog {&m_config}); if (!m_foxLogWindow) on_fox_log_action_triggered (); - if (m_foxLog->add_QSO (QSO_time, m_hisCall, m_hisGrid, m_rptSent, m_rptRcvd, m_lastBand)) + if (m_logBook.fox_log ()->add_QSO (QSO_time, m_hisCall, m_hisGrid, m_rptSent, m_rptRcvd, m_lastBand)) { writeFoxQSO (QString {" Log: %1 %2 %3 %4 %5"}.arg (m_hisCall).arg (m_hisGrid) .arg (m_rptSent).arg (m_rptRcvd).arg (m_lastBand)); @@ -8678,7 +8689,7 @@ void MainWindow::write_all(QString txRx, QString message) t.sprintf("%5d",ui->TxFreqSpinBox->value()); if (txRx=="Tx") msg=" 0 0.0" + t + " " + message; auto time = QDateTime::currentDateTimeUtc (); - time = time.addSecs(-(time.time().second() % m_TRperiod)); + time = time.addSecs(-fmod(double(time.time().second()),m_TRperiod)); t.sprintf("%10.3f ",m_freqNominal/1.e6); if (m_diskData) { if (m_fileDateTime.size()==11) { diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h index eada752b..03d009a7 100644 --- a/widgets/mainwindow.h +++ b/widgets/mainwindow.h @@ -72,9 +72,7 @@ class WideGraph; class LogQSO; class Transceiver; class MessageAveraging; -class FoxLog; class FoxLogWindow; -class CabrilloLog; class CabrilloLogWindow; class ColorHighlighting; class MessageClient; @@ -376,9 +374,7 @@ private: QScopedPointer<HelpTextWindow> m_prefixes; QScopedPointer<HelpTextWindow> m_mouseCmnds; QScopedPointer<MessageAveraging> m_msgAvgWidget; - QScopedPointer<FoxLog> m_foxLog; QScopedPointer<FoxLogWindow> m_foxLogWindow; - QScopedPointer<CabrilloLog> m_cabrilloLog; QScopedPointer<CabrilloLogWindow> m_contestLogWindow; QScopedPointer<ColorHighlighting> m_colorHighlighting; Transceiver::TransceiverState m_rigState; @@ -406,6 +402,7 @@ private: double m_s6; double m_tRemaining; + double m_TRperiod; float m_DTtol; float m_t0; @@ -428,7 +425,6 @@ private: qint32 m_ntr; qint32 m_tx; qint32 m_hsym; - qint32 m_TRperiod; qint32 m_nsps; qint32 m_hsymStop; qint32 m_inGain; diff --git a/widgets/mainwindow.ui b/widgets/mainwindow.ui index 0942dc75..75be401d 100644 --- a/widgets/mainwindow.ui +++ b/widgets/mainwindow.ui @@ -340,7 +340,7 @@ </size> </property> <property name="toolTip"> - <string><html><head/><body><p>Enter this QSO in log</p></body></html></string> + <string>Enter this QSO in log</string> </property> <property name="text"> <string>Log &QSO</string> @@ -372,7 +372,7 @@ </size> </property> <property name="toolTip"> - <string><html><head/><body><p>Toggle monitoring On/Off</p></body></html></string> + <string>Toggle monitoring On/Off</string> </property> <property name="styleSheet"> <string notr="true">QPushButton:checked { @@ -407,6 +407,9 @@ <property name="toolTip"> <string><html><head/><body><p>Erase right window. Double-click to erase both windows.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Erase right window. Double-click to erase both windows.</string> + </property> <property name="text"> <string>&Erase</string> </property> @@ -420,6 +423,9 @@ <property name="toolTip"> <string><html><head/><body><p>Clear the accumulating message average.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Clear the accumulating message average.</string> + </property> <property name="text"> <string>Clear Avg</string> </property> @@ -436,6 +442,9 @@ <property name="toolTip"> <string><html><head/><body><p>Decode most recent Rx period at QSO Frequency</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Decode most recent Rx period at QSO Frequency</string> + </property> <property name="styleSheet"> <string notr="true">QPushButton:checked { background-color: cyan; @@ -466,6 +475,9 @@ <property name="toolTip"> <string><html><head/><body><p>Toggle Auto-Tx On/Off</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Toggle Auto-Tx On/Off</string> + </property> <property name="styleSheet"> <string notr="true">QPushButton:checked { background-color: red; @@ -506,6 +518,9 @@ <property name="toolTip"> <string><html><head/><body><p>Toggle a pure Tx tone On/Off</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Toggle a pure Tx tone On/Off</string> + </property> <property name="styleSheet"> <string notr="true">QPushButton:checked { background-color: red; @@ -590,6 +605,15 @@ QLabel[oob="true"] { <property name="toolTip"> <string><html><head/><body><p>30dB recommended when only noise present<br/>Green when good<br/>Red when clipping may occur<br/>Yellow when too low</p></body></html></string> </property> + <property name="accessibleName"> + <string>Rx Signal</string> + </property> + <property name="accessibleDescription"> + <string>30dB recommended when only noise present +Green when good +Red when clipping may occur +Yellow when too low</string> + </property> <property name="frameShape"> <enum>QFrame::Panel</enum> </property> @@ -706,6 +730,9 @@ QLabel[oob="true"] { <property name="indent"> <number>2</number> </property> + <property name="buddy"> + <cstring>dxCallEntry</cstring> + </property> </widget> </item> <item row="0" column="1"> @@ -795,6 +822,9 @@ QLabel[oob="true"] { <property name="indent"> <number>2</number> </property> + <property name="buddy"> + <cstring>dxGridEntry</cstring> + </property> </widget> </item> <item row="1" column="0"> @@ -883,6 +913,9 @@ QLabel[oob="true"] { <property name="toolTip"> <string><html><head/><body><p>If orange or red there has been a rig control failure, click to reset and read the dial frequency. S implies split mode.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>If orange or red there has been a rig control failure, click to reset and read the dial frequency. S implies split mode.</string> + </property> <property name="styleSheet"> <string notr="true">QPushButton { font-family: helvetica; @@ -947,6 +980,12 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</p></body></html></string> </property> + <property name="accessibleName"> + <string>Frequncy entry</string> + </property> + <property name="accessibleDescription"> + <string>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</string> + </property> <property name="editable"> <bool>true</bool> </property> @@ -1038,6 +1077,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check to keep Tx frequency fixed when double-clicking on decoded text.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check to keep Tx frequency fixed when double-clicking on decoded text.</string> + </property> <property name="text"> <string>Hold Tx Freq</string> </property> @@ -1155,6 +1197,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Synchronizing threshold. Lower numbers accept weaker sync signals.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Synchronizing threshold. Lower numbers accept weaker sync signals.</string> + </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> @@ -1179,6 +1224,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check to use short-format messages.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check to use short-format messages.</string> + </property> <property name="text"> <string>Sh</string> </property> @@ -1189,6 +1237,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check to enable JT9 fast modes</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check to enable JT9 fast modes</string> + </property> <property name="text"> <string>Fast</string> </property> @@ -1199,6 +1250,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check to enable automatic sequencing of Tx messages based on received messages.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check to enable automatic sequencing of Tx messages based on received messages.</string> + </property> <property name="text"> <string>Auto Seq</string> </property> @@ -1209,6 +1263,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check to call the first decoded responder to my CQ.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check to call the first decoded responder to my CQ.</string> + </property> <property name="text"> <string>Call 1st</string> </property> @@ -1234,6 +1291,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check to Tx in even-numbered minutes or sequences, starting at 0; uncheck for odd sequences.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check to Tx in even-numbered minutes or sequences, starting at 0; uncheck for odd sequences.</string> + </property> <property name="text"> <string>Tx even/1st</string> </property> @@ -1249,6 +1309,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Frequency to call CQ on in kHz above the current MHz</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Frequency to call CQ on in kHz above the current MHz</string> + </property> <property name="prefix"> <string>Tx CQ </string> </property> @@ -1271,6 +1334,10 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check this to call CQ on the &quot;Tx CQ&quot; frequency. Rx will be on the current frequency and the CQ message wiill include the current Rx frequency so callers know which frequency to reply on.</p><p>Not available to nonstandard callsign holders.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check this to call CQ on the "Tx CQ" frequency. Rx will be on the current frequency and the CQ message wiill include the current Rx frequency so callers know which frequency to reply on. +Not available to nonstandard callsign holders.</string> + </property> <property name="text"> <string/> </property> @@ -1290,6 +1357,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Submode determines tone spacing; A is narrowest.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Submode determines tone spacing; A is narrowest.</string> + </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> @@ -1333,6 +1403,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check to monitor Sh messages.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check to monitor Sh messages.</string> + </property> <property name="text"> <string>SWL</string> </property> @@ -1364,6 +1437,11 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Check this to start recording calibration data.<br/>While measuring calibration correction is disabled.<br/>When not checked you can view the calibration results.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Check this to start recording calibration data. +While measuring calibration correction is disabled. +When not checked you can view the calibration results.</string> + </property> <property name="text"> <string>Measure</string> </property> @@ -1376,6 +1454,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Signal report: Signal-to-noise ratio in 2500 Hz reference bandwidth (dB).</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Signal report: Signal-to-noise ratio in 2500 Hz reference bandwidth (dB).</string> + </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> @@ -1398,6 +1479,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Tx/Rx or Frequency calibration sequence length</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Tx/Rx or Frequency calibration sequence length</string> + </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> @@ -1496,6 +1580,9 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Double-click on another caller to queue that call for your next QSO.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Double-click on another caller to queue that call for your next QSO.</string> + </property> <property name="text"> <string>Next Call</string> </property> @@ -1551,6 +1638,10 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Send this message in next Tx interval</p><p>Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compound call holders)</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Send this message in next Tx interval +Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compound call holders)</string> + </property> <property name="styleSheet"> <string notr="true">margin-left: 10%; margin-right: 0%</string> </property> @@ -1586,6 +1677,10 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Switch to this Tx message NOW</p><p>Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compound call holders)</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Switch to this Tx message NOW +Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compound call holders)</string> + </property> <property name="layoutDirection"> <enum>Qt::LeftToRight</enum> </property> @@ -1627,6 +1722,10 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Send this message in next Tx interval</p><p>Double-click to reset to the standard 73 message</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Send this message in next Tx interval +Double-click to reset to the standard 73 message</string> + </property> <property name="styleSheet"> <string notr="true">margin-left: 10%; margin-right: 0%</string> </property> @@ -1675,6 +1774,11 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Send this message in next Tx interval</p><p>Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type 2 compound call holders)</p><p>RR73 messages should only be used when you are reasonably confident that no message repetitions will be required</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Send this message in next Tx interval +Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type 2 compound call holders) +RR73 messages should only be used when you are reasonably confident that no message repetitions will be required</string> + </property> <property name="styleSheet"> <string notr="true">margin-left: 10%; margin-right: 0%</string> </property> @@ -1691,6 +1795,11 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Switch to this Tx message NOW</p><p>Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type2 compound call holders)</p><p>RR73 messages should only be used when you are reasonably confident that no message repetitions will be required</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Switch to this Tx message NOW +Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type2 compound call holders) +RR73 messages should only be used when you are reasonably confident that no message repetitions will be required</string> + </property> <property name="styleSheet"> <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> </property> @@ -1707,6 +1816,10 @@ QPushButton[state="ok"] { <property name="toolTip"> <string><html><head/><body><p>Switch to this Tx message NOW</p><p>Double-click to reset to the standard 73 message</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>Switch to this Tx message NOW +Double-click to reset to the standard 73 message</string> + </property> <property name="styleSheet"> <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> </property> @@ -2524,6 +2637,9 @@ list. The list can be maintained in Settings (F2).</string> <property name="toolTip"> <string><html><head/><body><p>6 digit locators cause 2 different mesages to be sent, the second contains the full locator but only a hashed callsign, other stations must have decoded the first once before they can decode your call in the second. Check this option to only send 4 digit locators if it will avoid the two message protocol.</p></body></html></string> </property> + <property name="accessibleDescription"> + <string>6 digit locators cause 2 different mesages to be sent, the second contains the full locator but only a hashed callsign, other stations must have decoded the first once before they can decode your call in the second. Check this option to only send 4 digit locators if it will avoid the two message protocol.</string> + </property> <property name="text"> <string>Prefer type 1 messages</string> </property> @@ -3306,14 +3422,6 @@ list. The list can be maintained in Settings (F2).</string> <string>Fox log</string> </property> </action> - <action name="reset_fox_log_action"> - <property name="text"> - <string>Reset Fox log ...</string> - </property> - <property name="toolTip"> - <string><html><head/><body><p>Ths will erase the file FoxQSO.txt and delete the Fox log file which is used for dupe detection.</p></body></html></string> - </property> - </action> <action name="actionFT8_DXpedition_Mode_User_Guide"> <property name="text"> <string>FT8 DXpedition Mode User Guide</string> diff --git a/widgets/plotter.cpp b/widgets/plotter.cpp index 98c1af16..badeff57 100644 --- a/widgets/plotter.cpp +++ b/widgets/plotter.cpp @@ -241,9 +241,9 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed) painter1.setPen(Qt::white); QString t; qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; - int n=(ms/1000) % m_TRperiod; + int n = fmod(0.001*ms,m_TRperiod); QDateTime t1=QDateTime::currentDateTimeUtc().addSecs(-n); - if(m_TRperiod < 60 or m_mode=="FT4") { + if(m_TRperiod<60.0) { t=t1.toString("hh:mm:ss") + " " + m_rxBand; } else { t=t1.toString("hh:mm") + " " + m_rxBand; @@ -411,7 +411,7 @@ void CPlotter::DrawOverlay() //DrawOverlay() } float bw=9.0*12000.0/m_nsps; //JT9 - if(m_mode=="FT4") bw=3*12000.0/512.0; //FT4 ### (3x, or 4x???) ### + if(m_mode=="FT4") bw=3*12000.0/576.0; //FT4 ### (3x, or 4x???) ### if(m_mode=="FT8") bw=7*12000.0/1920.0; //FT8 if(m_mode=="JT4") { //JT4 @@ -721,9 +721,9 @@ void CPlotter::mouseDoubleClickEvent (QMouseEvent * event) } } -void CPlotter::setNsps(int ntrperiod, int nsps) //setNsps +void CPlotter::setNsps(double trperiod, int nsps) //setNsps { - m_TRperiod=ntrperiod; + m_TRperiod=trperiod; m_nsps=nsps; m_fftBinWidth=1500.0/2048.0; if(m_nsps==15360) m_fftBinWidth=1500.0/2048.0; diff --git a/widgets/plotter.h b/widgets/plotter.h index e243c177..2cbfd202 100644 --- a/widgets/plotter.h +++ b/widgets/plotter.h @@ -56,7 +56,7 @@ public: void DrawOverlay(); int rxFreq(); void setFsample(int n); - void setNsps(int ntrperiod, int nsps); + void setNsps(double trperiod, int nsps); void setTxFreq(int n); void setMode(QString mode); void setSubMode(int n); @@ -145,6 +145,7 @@ private: double m_fftBinWidth; double m_dialFreq; double m_xOffset; + double m_TRperiod; float m_sum[2048]; @@ -161,7 +162,6 @@ private: qint32 m_h; qint32 m_h1; qint32 m_h2; - qint32 m_TRperiod; qint32 m_rxFreq; qint32 m_txFreq; qint32 m_fMin; diff --git a/widgets/widegraph.cpp b/widgets/widegraph.cpp index 1f3110ce..6234f731 100644 --- a/widgets/widegraph.cpp +++ b/widgets/widegraph.cpp @@ -5,6 +5,7 @@ #include <QSettings> #include <QDateTime> #include <QKeyEvent> +#include <math.h> #include "ui_widegraph.h" #include "commons.h" #include "Configuration.hpp" @@ -23,7 +24,7 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) : ui(new Ui::WideGraph), m_settings (settings), m_palettes_path {":/Palettes"}, - m_ntr0 {0}, + m_tr0 {0.0}, m_n {0}, m_bHaveTransmitted {false} { @@ -186,9 +187,8 @@ void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dat // Time according to this computer qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; - int ntr = (ms/1000) % m_TRperiod; - if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && - (ntr<m_ntr0 || (m_mode=="FT4" and m_bHaveTransmitted)))) { + double tr = fmod(0.001*ms,m_TRperiod); + if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && (tr<m_tr0))) { float flagValue=1.0e30; if(m_bHaveTransmitted) flagValue=2.0e30; for(int i=0; i<MAX_SCREENSIZE; i++) { @@ -199,7 +199,7 @@ void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dat } m_bHaveTransmitted=false; } - m_ntr0=ntr; + m_tr0=tr; ui->widePlot->draw(swide,true,false); } } @@ -278,11 +278,11 @@ int WideGraph::fSpan() return ui->widePlot->fSpan (); } -void WideGraph::setPeriod(int ntrperiod, int nsps) //SetPeriod +void WideGraph::setPeriod(double trperiod, int nsps) //SetPeriod { - m_TRperiod=ntrperiod; + m_TRperiod=trperiod; m_nsps=nsps; - ui->widePlot->setNsps(ntrperiod, nsps); + ui->widePlot->setNsps(trperiod, nsps); } void WideGraph::setTxFreq(int n) //setTxFreq diff --git a/widgets/widegraph.h b/widgets/widegraph.h index 2b172ef7..c87bab05 100644 --- a/widgets/widegraph.h +++ b/widgets/widegraph.h @@ -35,7 +35,7 @@ public: int fSpan(); void saveSettings(); void setFsample(int n); - void setPeriod(int ntrperiod, int nsps); + void setPeriod(double trperiod, int nsps); void setTxFreq(int n); void setMode(QString mode); void setSubMode(int n); @@ -95,10 +95,11 @@ private: WFPalette m_userPalette; QHash<QString, QVariant> m_fMinPerBand; + double m_tr0; + double m_TRperiod; + qint32 m_waterfallAvg; - qint32 m_TRperiod; qint32 m_nsps; - qint32 m_ntr0; qint32 m_fMax; qint32 m_nSubMode; qint32 m_nsmo; diff --git a/widgets/widgets.pri b/widgets/widgets.pri index 24ddd5a3..3c2cb244 100644 --- a/widgets/widgets.pri +++ b/widgets/widgets.pri @@ -8,18 +8,20 @@ SOURCES += \ widgets/fastplot.cpp widgets/MessageBox.cpp \ widgets/colorhighlighting.cpp widgets/ExportCabrillo.cpp \ widgets/AbstractLogWindow.cpp \ + widgets/FrequencyLineEdit.cpp widgets/FrequencyDeltaLineEdit.cpp \ widgets/FoxLogWindow.cpp widgets/CabrilloLogWindow.cpp HEADERS += \ widgets/mainwindow.h widgets/plotter.h \ widgets/about.h widgets/widegraph.h \ widgets/displaytext.h widgets/logqso.h widgets/LettersSpinBox.hpp \ - widgets/FrequencyLineEdit.hpp widgets/signalmeter.h \ + widgets/FrequencyLineEdit.hpp widgets/FrequencyDeltaLineEdit.hpp widgets/signalmeter.h \ widgets/meterwidget.h widgets/messageaveraging.h \ widgets/echoplot.h widgets/echograph.h widgets/fastgraph.h \ widgets/fastplot.h widgets/MessageBox.hpp widgets/colorhighlighting.h \ widgets/ExportCabrillo.h widgets/AbstractLogWindow.hpp \ - widgets/FoxLogWindow.hpp widgets/CabrilloLogWindow.hpp + widgets/FoxLogWindow.hpp widgets/CabrilloLogWindow.hpp \ + widgets/DateTimeEdit.hpp FORMS += \ widgets/mainwindow.ui widgets/about.ui \ |
