Initial commit of manual clock drift syncronization

This commit is contained in:
Jordan Sherer 2018-09-18 17:24:07 -04:00
parent 4e094b791c
commit d08096a934
21 changed files with 432 additions and 171 deletions

View File

@ -2,6 +2,7 @@
#include <cmath> #include <cmath>
#include "DriftingDateTime.h"
#include "varicode.h" #include "varicode.h"
const int PACKET_TIMEOUT_SECONDS = 300; const int PACKET_TIMEOUT_SECONDS = 300;
@ -209,7 +210,7 @@ void APRSISClient::enqueueThirdParty(QString theircall, QString payload){
} }
void APRSISClient::enqueueRaw(QString aprsFrame){ void APRSISClient::enqueueRaw(QString aprsFrame){
m_frameQueue.enqueue({ aprsFrame, QDateTime::currentDateTimeUtc() }); m_frameQueue.enqueue({ aprsFrame, DriftingDateTime::currentDateTimeUtc() });
} }
void APRSISClient::processQueue(bool disconnect){ void APRSISClient::processQueue(bool disconnect){
@ -263,7 +264,7 @@ void APRSISClient::processQueue(bool disconnect){
auto timestamp = pair.second; auto timestamp = pair.second;
// if the packet is older than the timeout, drop it. // if the packet is older than the timeout, drop it.
if(timestamp.secsTo(QDateTime::currentDateTimeUtc()) > PACKET_TIMEOUT_SECONDS){ if(timestamp.secsTo(DriftingDateTime::currentDateTimeUtc()) > PACKET_TIMEOUT_SECONDS){
qDebug() << "APRSISClient Packet Timeout:" << frame; qDebug() << "APRSISClient Packet Timeout:" << frame;
m_frameQueue.dequeue(); m_frameQueue.dequeue();
continue; continue;

View File

@ -278,6 +278,7 @@ set (jt9_CXXSRCS
) )
set (wsjtx_CXXSRCS set (wsjtx_CXXSRCS
DriftingDateTime.cpp
logbook/adif.cpp logbook/adif.cpp
logbook/countrydat.cpp logbook/countrydat.cpp
logbook/countriesworked.cpp logbook/countriesworked.cpp
@ -673,31 +674,31 @@ set (wsjtx_UISRCS
messagereplydialog.ui messagereplydialog.ui
) )
set (UDP_library_CXXSRCS # set (UDP_library_CXXSRCS
Radio.cpp # Radio.cpp
RadioMetaType.cpp # RadioMetaType.cpp
NetworkMessage.cpp # NetworkMessage.cpp
MessageServer.cpp # MessageServer.cpp
) # )
#
set (UDP_library_HEADERS # set (UDP_library_HEADERS
Radio.hpp # Radio.hpp
MessageServer.hpp # MessageServer.hpp
${PROJECT_BINARY_DIR}/udp_export.h # ${PROJECT_BINARY_DIR}/udp_export.h
) # )
#
set (message_aggregator_CXXSRCS # set (message_aggregator_CXXSRCS
UDPExamples/MessageAggregator.cpp # UDPExamples/MessageAggregator.cpp
UDPExamples/MessageAggregatorMainWindow.cpp # UDPExamples/MessageAggregatorMainWindow.cpp
UDPExamples/DecodesModel.cpp # UDPExamples/DecodesModel.cpp
UDPExamples/BeaconsModel.cpp # UDPExamples/BeaconsModel.cpp
UDPExamples/ClientWidget.cpp # UDPExamples/ClientWidget.cpp
MaidenheadLocatorValidator.cpp # MaidenheadLocatorValidator.cpp
) # )
#
set (message_aggregator_STYLESHEETS # set (message_aggregator_STYLESHEETS
UDPExamples/qss/default.qss # UDPExamples/qss/default.qss
) # )
set (qcp_CXXSRCS set (qcp_CXXSRCS
qcustomplot-source/qcustomplot.cpp qcustomplot-source/qcustomplot.cpp
@ -1352,45 +1353,45 @@ else ()
endif () endif ()
qt5_use_modules (ft8call SerialPort) # not sure why the interface link library syntax above doesn't work qt5_use_modules (ft8call SerialPort) # not sure why the interface link library syntax above doesn't work
# make a library for WSJT-X UDP servers ### # make a library for WSJT-X UDP servers
# add_library (wsjtx_udp SHARED ${UDP_library_CXXSRCS}) ### # add_library (wsjtx_udp SHARED ${UDP_library_CXXSRCS})
add_library (wsjtx_udp-static STATIC ${UDP_library_CXXSRCS}) ### add_library (wsjtx_udp-static STATIC ${UDP_library_CXXSRCS})
#target_include_directories (wsjtx_udp ### #target_include_directories (wsjtx_udp
# INTERFACE ### # INTERFACE
# $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsjtx> ### # $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsjtx>
# ) ### # )
target_include_directories (wsjtx_udp-static ### target_include_directories (wsjtx_udp-static
INTERFACE ### INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsjtx> ### $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/wsjtx>
) ### )
#set_target_properties (wsjtx_udp PROPERTIES ### #set_target_properties (wsjtx_udp PROPERTIES
# PUBLIC_HEADER "${UDP_library_HEADERS}" ### # PUBLIC_HEADER "${UDP_library_HEADERS}"
# ) ### # )
set_target_properties (wsjtx_udp-static PROPERTIES ### set_target_properties (wsjtx_udp-static PROPERTIES
OUTPUT_NAME wsjtx_udp ### OUTPUT_NAME wsjtx_udp
) ### )
target_compile_definitions (wsjtx_udp-static PUBLIC UDP_STATIC_DEFINE) ### target_compile_definitions (wsjtx_udp-static PUBLIC UDP_STATIC_DEFINE)
#qt5_use_modules (wsjtx_udp Network) ### #qt5_use_modules (wsjtx_udp Network)
qt5_use_modules (wsjtx_udp-static Network Gui) ### qt5_use_modules (wsjtx_udp-static Network Gui)
generate_export_header (wsjtx_udp-static BASE_NAME udp) ### generate_export_header (wsjtx_udp-static BASE_NAME udp)
###
add_executable (udp_daemon UDPExamples/UDPDaemon.cpp UDPExamples/udp_daemon.rc ${WSJTX_ICON_FILE}) ### add_executable (udp_daemon UDPExamples/UDPDaemon.cpp UDPExamples/udp_daemon.rc ${WSJTX_ICON_FILE})
target_link_libraries (udp_daemon wsjtx_udp-static) ### target_link_libraries (udp_daemon wsjtx_udp-static)
###
add_resources (message_aggregator_RESOURCES /qss ${message_aggregator_STYLESHEETS}) ### add_resources (message_aggregator_RESOURCES /qss ${message_aggregator_STYLESHEETS})
configure_file (UDPExamples/message_aggregator.qrc.in message_aggregator.qrc @ONLY) ### configure_file (UDPExamples/message_aggregator.qrc.in message_aggregator.qrc @ONLY)
qt5_add_resources (message_aggregator_RESOURCES_RCC ${CMAKE_CURRENT_BINARY_DIR}/message_aggregator.qrc) ### qt5_add_resources (message_aggregator_RESOURCES_RCC ${CMAKE_CURRENT_BINARY_DIR}/message_aggregator.qrc)
add_executable (message_aggregator ### add_executable (message_aggregator
${message_aggregator_CXXSRCS} ### ${message_aggregator_CXXSRCS}
${WSJTX_ICON_FILE} ### ${WSJTX_ICON_FILE}
UDPExamples/message_aggregator.rc ### UDPExamples/message_aggregator.rc
${message_aggregator_RESOURCES_RCC} ### ${message_aggregator_RESOURCES_RCC}
) ### )
target_link_libraries (message_aggregator Qt5::Widgets wsjtx_udp-static) ### target_link_libraries (message_aggregator Qt5::Widgets wsjtx_udp-static)
###
if (WSJT_CREATE_WINMAIN) ### if (WSJT_CREATE_WINMAIN)
set_target_properties (message_aggregator PROPERTIES WIN32_EXECUTABLE ON) ### set_target_properties (message_aggregator PROPERTIES WIN32_EXECUTABLE ON)
endif (WSJT_CREATE_WINMAIN) ### endif (WSJT_CREATE_WINMAIN)
if (UNIX) if (UNIX)
if (NOT WSJT_SKIP_MANPAGES) if (NOT WSJT_SKIP_MANPAGES)
@ -1429,10 +1430,10 @@ install (TARGETS ft8call
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wsjtx # DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wsjtx
# ) # )
install (TARGETS udp_daemon message_aggregator ### install (TARGETS udp_daemon message_aggregator
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime ### RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime ### BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
) ### )
install (TARGETS jt9 ft8code jt65code qra64code qra64sim jt9code jt4code install (TARGETS jt9 ft8code jt65code qra64code qra64sim jt9code jt4code
msk144code wsprd wspr_fsk8d fmtave fcal fmeasure msk144code wsprd wspr_fsk8d fmtave fcal fmeasure

View File

@ -6,6 +6,8 @@
#include <QThread> #include <QThread>
#include <QDateTime> #include <QDateTime>
#include "DriftingDateTime.h"
#include "NetworkServerLookup.hpp" #include "NetworkServerLookup.hpp"
#include "moc_DXLabSuiteCommanderTransceiver.cpp" #include "moc_DXLabSuiteCommanderTransceiver.cpp"
@ -151,10 +153,10 @@ void DXLabSuiteCommanderTransceiver::do_ptt (bool on)
simple_command (on ? "<command:5>CmdTX<parameters:0>" : "<command:5>CmdRX<parameters:0>"); simple_command (on ? "<command:5>CmdTX<parameters:0>" : "<command:5>CmdRX<parameters:0>");
bool tx {!on}; bool tx {!on};
auto start = QDateTime::currentMSecsSinceEpoch (); auto start = DriftingDateTime::currentMSecsSinceEpoch ();
// we must now wait for Tx on the rig, we will wait a short while // we must now wait for Tx on the rig, we will wait a short while
// before bailing out // before bailing out
while (tx != on && QDateTime::currentMSecsSinceEpoch () - start < 1000) while (tx != on && DriftingDateTime::currentMSecsSinceEpoch () - start < 1000)
{ {
auto reply = command_with_reply ("<command:9>CmdSendTx<parameters:0>"); auto reply = command_with_reply ("<command:9>CmdSendTx<parameters:0>");
if (0 == reply.indexOf ("<CmdTX:")) if (0 == reply.indexOf ("<CmdTX:"))

View File

@ -4,6 +4,8 @@
#include <QDebug> #include <QDebug>
#include "commons.h" #include "commons.h"
#include "DriftingDateTime.h"
#include "moc_Detector.cpp" #include "moc_Detector.cpp"
extern "C" { extern "C" {
@ -42,7 +44,7 @@ bool Detector::reset ()
void Detector::clear () void Detector::clear ()
{ {
// set index to roughly where we are in time (1ms resolution) // set index to roughly where we are in time (1ms resolution)
// qint64 now (QDateTime::currentMSecsSinceEpoch ()); // qint64 now (DriftingDateTime::currentMSecsSinceEpoch ());
// unsigned msInPeriod ((now % 86400000LL) % (m_period * 1000)); // unsigned msInPeriod ((now % 86400000LL) % (m_period * 1000));
// dec_data.params.kin = qMin ((msInPeriod * m_frameRate) / 1000, static_cast<unsigned> (sizeof (dec_data.d2) / sizeof (dec_data.d2[0]))); // dec_data.params.kin = qMin ((msInPeriod * m_frameRate) / 1000, static_cast<unsigned> (sizeof (dec_data.d2) / sizeof (dec_data.d2[0])));
dec_data.params.kin = 0; dec_data.params.kin = 0;
@ -125,7 +127,7 @@ unsigned Detector::secondInPeriod () const
{ {
// we take the time of the data as the following assuming no latency // we take the time of the data as the following assuming no latency
// delivering it to us (not true but close enough for us) // delivering it to us (not true but close enough for us)
qint64 now (QDateTime::currentMSecsSinceEpoch ()); qint64 now (DriftingDateTime::currentMSecsSinceEpoch ());
unsigned secondInToday ((now % 86400000LL) / 1000); unsigned secondInToday ((now % 86400000LL) / 1000);
return secondInToday % m_period; return secondInToday % m_period;

28
DriftingDateTime.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "DriftingDateTime.h"
qint64 driftms = 0;
QDateTime DriftingDateTime::currentDateTime(){
return QDateTime::currentDateTime().addMSecs(driftms);
}
QDateTime DriftingDateTime::currentDateTimeUtc(){
return QDateTime::currentDateTimeUtc().addMSecs(driftms);
}
qint64 DriftingDateTime::currentMSecsSinceEpoch(){
return QDateTime::currentMSecsSinceEpoch() + driftms;
}
qint64 DriftingDateTime::drift(){
return driftms;
}
void DriftingDateTime::setDrift(qint64 ms){
driftms = ms;
}
qint64 DriftingDateTime::incrementDrift(qint64 msdelta){
driftms += msdelta;
return driftms;
}

21
DriftingDateTime.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef DRIFTINGDATETIME_H
#define DRIFTINGDATETIME_H
#include <QDateTime>
class DriftingDateTime /*: QDateTime*/
{
public:
static QDateTime currentDateTime();
static QDateTime currentDateTimeUtc();
static qint64 currentMSecsSinceEpoch();
static qint64 drift();
static void setDrift(qint64 ms);
static qint64 incrementDrift(qint64 msdelta);
private:
};
#endif // DRIFTINGDATETIME_H

View File

@ -13,6 +13,8 @@
#include <QHostAddress> #include <QHostAddress>
#include <QColor> #include <QColor>
#include "DriftingDateTime.h"
#include "pimpl_impl.hpp" #include "pimpl_impl.hpp"
#include "moc_MessageClient.cpp" #include "moc_MessageClient.cpp"
@ -232,7 +234,7 @@ void MessageClient::impl::heartbeat ()
Message m("PING", "", QMap<QString, QVariant>{ Message m("PING", "", QMap<QString, QVariant>{
{"NAME", QVariant(QApplication::applicationName())}, {"NAME", QVariant(QApplication::applicationName())},
{"VERSION", QVariant(QApplication::applicationVersion())}, {"VERSION", QVariant(QApplication::applicationVersion())},
{"UTC", QVariant(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch())} {"UTC", QVariant(DriftingDateTime::currentDateTimeUtc().toMSecsSinceEpoch())}
}); });
writeDatagram (m.toJson(), server_, server_port_); writeDatagram (m.toJson(), server_, server_port_);
} }

View File

@ -7,6 +7,8 @@
#include "soundout.h" #include "soundout.h"
#include "commons.h" #include "commons.h"
#include "DriftingDateTime.h"
#include "moc_Modulator.cpp" #include "moc_Modulator.cpp"
extern float gran(); // Noise generator (for tests only) extern float gran(); // Noise generator (for tests only)
@ -49,7 +51,7 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol,
{ {
Q_ASSERT (stream); Q_ASSERT (stream);
// Time according to this computer which becomes our base time // Time according to this computer which becomes our base time
qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms0 = DriftingDateTime::currentMSecsSinceEpoch() % 86400000;
if (m_state != Idle) if (m_state != Idle)
{ {
@ -176,7 +178,7 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
if(m_TRperiod==3) slowCwId=false; if(m_TRperiod==3) slowCwId=false;
bool fastCwId=false; bool fastCwId=false;
static bool bCwId=false; static bool bCwId=false;
qint64 ms = QDateTime::currentMSecsSinceEpoch(); qint64 ms = DriftingDateTime::currentMSecsSinceEpoch();
float tsec=0.001*(ms % (1000*m_TRperiod)); float tsec=0.001*(ms % (1000*m_TRperiod));
if(m_bFastMode and (icw[0]>0) and (tsec>(m_TRperiod-5.0))) fastCwId=true; if(m_bFastMode and (icw[0]>0) and (tsec>(m_TRperiod-5.0))) fastCwId=true;
if(!m_bFastMode) m_nspd=2560; // 22.5 WPM if(!m_bFastMode) m_nspd=2560; // 22.5 WPM

View File

@ -16,6 +16,8 @@
#include <QDebug> #include <QDebug>
#include <QDebugStateSaver> #include <QDebugStateSaver>
#include "DriftingDateTime.h"
#include "pimpl_impl.hpp" #include "pimpl_impl.hpp"
#include "Radio.hpp" #include "Radio.hpp"
@ -631,7 +633,7 @@ bool StationList::impl::dropMimeData (QMimeData const * data, Qt::DropAction act
, [&band] (Station const& s) {return s.band_name_ == band;})) , [&band] (Station const& s) {return s.band_name_ == band;}))
{ {
// not found so add it // not found so add it
add (Station {band, 0, QDateTime::currentDateTimeUtc(), QDateTime::currentDateTimeUtc(), QString {}}); add (Station {band, 0, DriftingDateTime::currentDateTimeUtc(), DriftingDateTime::currentDateTimeUtc(), QString {}});
} }
} }
return true; return true;

View File

@ -14,6 +14,8 @@
#include "Bands.hpp" #include "Bands.hpp"
#include "FrequencyList.hpp" #include "FrequencyList.hpp"
#include "WsprTxScheduler.h" #include "WsprTxScheduler.h"
#include "DriftingDateTime.h"
#include "pimpl_impl.hpp" #include "pimpl_impl.hpp"
#include "moc_WSPRBandHopping.cpp" #include "moc_WSPRBandHopping.cpp"
@ -333,7 +335,7 @@ void WSPRBandHopping::set_tx_percent (int new_value)
// determine the parameters of the hop, if any // determine the parameters of the hop, if any
auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop
{ {
auto const& now = QDateTime::currentDateTimeUtc (); auto const& now = DriftingDateTime::currentDateTimeUtc ();
auto const& date = now.date (); auto const& date = now.date ();
auto year = date.year (); auto year = date.year ();
auto month = date.month (); auto month = date.month ();

View File

@ -8,6 +8,8 @@
#include <QMenu> #include <QMenu>
#include <QAction> #include <QAction>
#include "DriftingDateTime.h"
#include "qt_helpers.hpp" #include "qt_helpers.hpp"
#include "moc_displaytext.cpp" #include "moc_displaytext.cpp"
@ -288,13 +290,13 @@ void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 tx
t2.sprintf("%4d",txFreq); t2.sprintf("%4d",txFreq);
QString t; QString t;
if(bFastMode or modeTx=="FT8") { if(bFastMode or modeTx=="FT8") {
t = QDateTime::currentDateTimeUtc().toString("hhmmss") + \ t = DriftingDateTime::currentDateTimeUtc().toString("hhmmss") + \
" Tx " + t2 + t1 + text; " Tx " + t2 + t1 + text;
} else if(modeTx.mid(0,6)=="FT8fox") { } else if(modeTx.mid(0,6)=="FT8fox") {
t = QDateTime::currentDateTimeUtc().toString("hhmmss") + \ t = DriftingDateTime::currentDateTimeUtc().toString("hhmmss") + \
" Tx" + modeTx.mid(7) + " " + text; " Tx" + modeTx.mid(7) + " " + text;
} else { } else {
t = QDateTime::currentDateTimeUtc().toString("hhmm") + \ t = DriftingDateTime::currentDateTimeUtc().toString("hhmm") + \
" Tx " + t2 + t1 + text; " Tx " + t2 + t1 + text;
} }
appendText (t, color_ReceivedMsg); appendText (t, color_ReceivedMsg);
@ -302,7 +304,7 @@ void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 tx
void DisplayText::displayQSY(QString text) void DisplayText::displayQSY(QString text)
{ {
QString t = QDateTime::currentDateTimeUtc().toString("hhmmss") + " " + text; QString t = DriftingDateTime::currentDateTimeUtc().toString("hhmmss") + " " + text;
appendText (t, "hotpink"); appendText (t, "hotpink");
} }

View File

@ -2,6 +2,9 @@
#include "commons.h" #include "commons.h"
#include <math.h> #include <math.h>
#include <QDebug> #include <QDebug>
#include "DriftingDateTime.h"
#include "moc_fastplot.cpp" #include "moc_fastplot.cpp"
#define MAX_SCREENSIZE 2048 #define MAX_SCREENSIZE 2048
@ -166,7 +169,7 @@ void FPlotter::draw() //draw()
int is=m_UTCdisk % 100; int is=m_UTCdisk % 100;
m_t.sprintf("%2.2d:%2.2d:%2.2d",ih,im,is); m_t.sprintf("%2.2d:%2.2d:%2.2d",ih,im,is);
} else { } else {
m_t=QDateTime::currentDateTimeUtc().toString("hh:mm:ss"); m_t=DriftingDateTime::currentDateTimeUtc().toString("hh:mm:ss");
} }
if(fast_jh>0) painter1.drawText(10,95,m_t); if(fast_jh>0) painter1.drawText(10,95,m_t);
} }

View File

@ -38,6 +38,8 @@
#include "SplashScreen.hpp" #include "SplashScreen.hpp"
#include "MessageBox.hpp" // last to avoid nasty MS macro definitions #include "MessageBox.hpp" // last to avoid nasty MS macro definitions
#include "DriftingDateTime.h"
extern "C" { extern "C" {
// Fortran procedures we need // Fortran procedures we need
void four2a_(_Complex float *, int * nfft, int * ndim, int * isign, int * iform, int len); void four2a_(_Complex float *, int * nfft, int * ndim, int * isign, int * iform, int len);
@ -50,7 +52,7 @@ namespace
RNGSetup () RNGSetup ()
{ {
// one time seed of pseudo RNGs from current time // one time seed of pseudo RNGs from current time
auto seed = QDateTime::currentMSecsSinceEpoch (); auto seed = DriftingDateTime::currentMSecsSinceEpoch ();
qsrand (seed); // this is good for rand() as well qsrand (seed); // this is good for rand() as well
} }
} seeding; } seeding;
@ -74,7 +76,7 @@ namespace
if (handler) if (handler)
{ {
handler (type, context, handler (type, context,
QDateTime::currentDateTimeUtc ().toString ("yy-MM-ddTHH:mm:ss.zzzZ: ") + msg); DriftingDateTime::currentDateTimeUtc ().toString ("yy-MM-ddTHH:mm:ss.zzzZ: ") + msg);
} }
} }
static QStack<QtMessageHandler> prior_handlers_; static QStack<QtMessageHandler> prior_handlers_;

View File

@ -63,6 +63,7 @@
#include "EqualizationToolsDialog.hpp" #include "EqualizationToolsDialog.hpp"
#include "SelfDestructMessageBox.h" #include "SelfDestructMessageBox.h"
#include "messagereplydialog.h" #include "messagereplydialog.h"
#include "DriftingDateTime.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "moc_mainwindow.cpp" #include "moc_mainwindow.cpp"
@ -187,14 +188,14 @@ namespace
int ms_minute_error () int ms_minute_error ()
{ {
auto const& now = QDateTime::currentDateTime (); auto const& now = DriftingDateTime::currentDateTime ();
auto const& time = now.time (); auto const& time = now.time ();
auto second = time.second (); auto second = time.second ();
return now.msecsTo (now.addSecs (second > 30 ? 60 - second : -second)) - time.msec (); return now.msecsTo (now.addSecs (second > 30 ? 60 - second : -second)) - time.msec ();
} }
QString since(QDateTime time){ QString since(QDateTime time){
int delta = time.toUTC().secsTo(QDateTime::currentDateTimeUtc()); int delta = time.toUTC().secsTo(DriftingDateTime::currentDateTimeUtc());
if(delta < 30){ if(delta < 30){
return QString("now"); return QString("now");
} }
@ -1392,7 +1393,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
// Don't block beacon's first run... // Don't block beacon's first run...
m_lastTxTime = QDateTime::currentDateTimeUtc().addSecs(-300); m_lastTxTime = DriftingDateTime::currentDateTimeUtc().addSecs(-300);
pskSetLocal(); pskSetLocal();
aprsSetLocal(); aprsSetLocal();
@ -1461,7 +1462,7 @@ void MainWindow::initializeDummyData(){
"W0FW" "W0FW"
}; };
auto dt = QDateTime::currentDateTimeUtc().addSecs(-300); auto dt = DriftingDateTime::currentDateTimeUtc().addSecs(-300);
int i = 0; int i = 0;
foreach(auto call, calls){ foreach(auto call, calls){
@ -1485,8 +1486,8 @@ void MainWindow::initializeDummyData(){
i++; i++;
} }
displayTextForFreq("KN4CRD: ALLCALL? \u2301 ", 42, QDateTime::currentDateTimeUtc().addSecs(-315), true, true, true); displayTextForFreq("KN4CRD: ALLCALL? \u2301 ", 42, DriftingDateTime::currentDateTimeUtc().addSecs(-315), true, true, true);
displayTextForFreq("J1Y: KN4CRD SNR -05 \u2301 ", 42, QDateTime::currentDateTimeUtc().addSecs(-300), false, true, true); displayTextForFreq("J1Y: KN4CRD SNR -05 \u2301 ", 42, DriftingDateTime::currentDateTimeUtc().addSecs(-300), false, true, true);
displayActivity(true); displayActivity(true);
@ -1563,7 +1564,7 @@ void MainWindow::tryBandHop(){
}); });
// we just set the date to a known y/m/d to make the comparisons easier // we just set the date to a known y/m/d to make the comparisons easier
QDateTime d = QDateTime::currentDateTimeUtc(); QDateTime d = DriftingDateTime::currentDateTimeUtc();
d.setDate(QDate(2000, 1, 1)); d.setDate(QDate(2000, 1, 1));
QDateTime startOfDay = QDateTime(QDate(2000, 1, 1), QTime(0, 0)); QDateTime startOfDay = QDateTime(QDate(2000, 1, 1), QTime(0, 0));
@ -1626,7 +1627,7 @@ void MainWindow::tryBandHop(){
auto message = QString("Scheduled frequency switch from %1 MHz to %2 MHz"); auto message = QString("Scheduled frequency switch from %1 MHz to %2 MHz");
message = message.arg(Radio::frequency_MHz_string(dialFreq)); message = message.arg(Radio::frequency_MHz_string(dialFreq));
message = message.arg(Radio::frequency_MHz_string(station.frequency_)); message = message.arg(Radio::frequency_MHz_string(station.frequency_));
writeNoticeTextToUI(QDateTime::currentDateTimeUtc(), message); writeNoticeTextToUI(DriftingDateTime::currentDateTimeUtc(), message);
}); });
t->start(); t->start();
#endif #endif
@ -2024,7 +2025,7 @@ void MainWindow::dataSink(qint64 frames)
QString t; QString t;
t.sprintf("%3d %7.1f %7.1f %7.1f %7.1f %3d",echocom_.nsum,xlevel,sigdb, t.sprintf("%3d %7.1f %7.1f %7.1f %7.1f %3d",echocom_.nsum,xlevel,sigdb,
dfreq,width,nqual); dfreq,width,nqual);
t=QDateTime::currentDateTimeUtc().toString("hh:mm:ss ") + t; t=DriftingDateTime::currentDateTimeUtc().toString("hh:mm:ss ") + t;
if (ui) ui->decodedTextBrowser->appendText(t); if (ui) ui->decodedTextBrowser->appendText(t);
if(m_echoGraph->isVisible()) m_echoGraph->plotSpec(); if(m_echoGraph->isVisible()) m_echoGraph->plotSpec();
m_nclearave=0; m_nclearave=0;
@ -2044,7 +2045,7 @@ void MainWindow::dataSink(qint64 frames)
dec_data.params.newdat=1; dec_data.params.newdat=1;
dec_data.params.nagain=0; dec_data.params.nagain=0;
dec_data.params.nzhsym=m_hsymStop; dec_data.params.nzhsym=m_hsymStop;
QDateTime now {QDateTime::currentDateTimeUtc ()}; QDateTime now {DriftingDateTime::currentDateTimeUtc ()};
m_dateTime = now.toString ("yyyy-MMM-dd hh:mm"); m_dateTime = now.toString ("yyyy-MMM-dd hh:mm");
if(!m_mode.startsWith ("WSPR")) decode(); //Start decoder if(!m_mode.startsWith ("WSPR")) decode(); //Start decoder
@ -2155,7 +2156,7 @@ QString MainWindow::save_wave_file (QString const& name, short const * data, int
BWFFile::InfoDictionary list_info { BWFFile::InfoDictionary list_info {
{{{'I','S','R','C'}}, source.toLocal8Bit ()}, {{{'I','S','R','C'}}, source.toLocal8Bit ()},
{{{'I','S','F','T'}}, program_title (revision ()).simplified ().toLocal8Bit ()}, {{{'I','S','F','T'}}, program_title (revision ()).simplified ().toLocal8Bit ()},
{{{'I','C','R','D'}}, QDateTime::currentDateTime () {{{'I','C','R','D'}}, DriftingDateTime::currentDateTime ()
.toString ("yyyy-MM-ddTHH:mm:ss.zzzZ").toLocal8Bit ()}, .toString ("yyyy-MM-ddTHH:mm:ss.zzzZ").toLocal8Bit ()},
{{{'I','C','M','T'}}, comment.toLocal8Bit ()}, {{{'I','C','M','T'}}, comment.toLocal8Bit ()},
}; };
@ -2186,7 +2187,7 @@ void MainWindow::fastSink(qint64 frames)
m_bDecoded=false; m_bDecoded=false;
} }
QDateTime tnow=QDateTime::currentDateTimeUtc(); QDateTime tnow=DriftingDateTime::currentDateTimeUtc();
int ihr=tnow.toString("hh").toInt(); int ihr=tnow.toString("hh").toInt();
int imin=tnow.toString("mm").toInt(); int imin=tnow.toString("mm").toInt();
int isec=tnow.toString("ss").toInt(); int isec=tnow.toString("ss").toInt();
@ -2199,7 +2200,7 @@ void MainWindow::fastSink(qint64 frames)
int RxFreq=ui->RxFreqSpinBox->value (); int RxFreq=ui->RxFreqSpinBox->value ();
int nTRpDepth=m_TRperiod + 1000*(m_ndepth & 3); int nTRpDepth=m_TRperiod + 1000*(m_ndepth & 3);
qint64 ms0 = QDateTime::currentMSecsSinceEpoch(); qint64 ms0 = DriftingDateTime::currentMSecsSinceEpoch();
strncpy(dec_data.params.mycall, (m_baseCall+" ").toLatin1(),12); strncpy(dec_data.params.mycall, (m_baseCall+" ").toLatin1(),12);
QString hisCall {ui->dxCallEntry->text ()}; QString hisCall {ui->dxCallEntry->text ()};
bool bshmsg=ui->cbShMsgs->isChecked(); bool bshmsg=ui->cbShMsgs->isChecked();
@ -2267,7 +2268,7 @@ void MainWindow::fastSink(qint64 frames)
if(decodeNow or m_bFastDone) { if(decodeNow or m_bFastDone) {
if(!m_diskData) { if(!m_diskData) {
QDateTime now {QDateTime::currentDateTimeUtc()}; QDateTime now {DriftingDateTime::currentDateTimeUtc()};
int n=now.time().second() % m_TRperiod; int n=now.time().second() % m_TRperiod;
if(n<(m_TRperiod/2)) n=n+m_TRperiod; if(n<(m_TRperiod/2)) n=n+m_TRperiod;
auto const& period_start = now.addSecs (-n); auto const& period_start = now.addSecs (-n);
@ -2287,7 +2288,7 @@ void MainWindow::fastSink(qint64 frames)
} }
m_bFastDone=false; m_bFastDone=false;
} }
float tsec=0.001*(QDateTime::currentMSecsSinceEpoch() - ms0); float tsec=0.001*(DriftingDateTime::currentMSecsSinceEpoch() - ms0);
m_fCPUmskrtd=0.9*m_fCPUmskrtd + 0.1*tsec; m_fCPUmskrtd=0.9*m_fCPUmskrtd + 0.1*tsec;
} }
@ -2534,7 +2535,7 @@ void MainWindow::on_autoButton_clicked (bool checked)
} }
ui->sbTxPercent->setPalette(palette); ui->sbTxPercent->setPalette(palette);
} }
m_tAutoOn=QDateTime::currentMSecsSinceEpoch()/1000; m_tAutoOn=DriftingDateTime::currentMSecsSinceEpoch()/1000;
// stop tx, reset the ui and message queue // stop tx, reset the ui and message queue
if(!checked){ if(!checked){
@ -3286,7 +3287,7 @@ void MainWindow::msgAvgDecode2()
void MainWindow::decode() //decode() void MainWindow::decode() //decode()
{ {
QDateTime now = QDateTime::currentDateTime(); QDateTime now = DriftingDateTime::currentDateTime();
if( m_dateTimeLastTX.isValid () ) { if( m_dateTimeLastTX.isValid () ) {
qint64 isecs_since_tx = m_dateTimeLastTX.secsTo(now); qint64 isecs_since_tx = m_dateTimeLastTX.secsTo(now);
dec_data.params.lapcqonly= (isecs_since_tx > 600); dec_data.params.lapcqonly= (isecs_since_tx > 600);
@ -3299,21 +3300,21 @@ void MainWindow::decode() //decode()
dec_data.params.lapcqonly=false; dec_data.params.lapcqonly=false;
} }
m_msec0=QDateTime::currentMSecsSinceEpoch(); m_msec0=DriftingDateTime::currentMSecsSinceEpoch();
if(!m_dataAvailable or m_TRperiod==0) return; if(!m_dataAvailable or m_TRperiod==0) return;
ui->DecodeButton->setChecked (true); ui->DecodeButton->setChecked (true);
if(!dec_data.params.nagain && m_diskData && !m_bFastMode && m_mode!="FT8") { if(!dec_data.params.nagain && m_diskData && !m_bFastMode && m_mode!="FT8") {
dec_data.params.nutc=dec_data.params.nutc/100; dec_data.params.nutc=dec_data.params.nutc/100;
} }
if(dec_data.params.nagain==0 && dec_data.params.newdat==1 && (!m_diskData)) { if(dec_data.params.nagain==0 && dec_data.params.newdat==1 && (!m_diskData)) {
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = DriftingDateTime::currentMSecsSinceEpoch() % 86400000;
int imin=ms/60000; int imin=ms/60000;
int ihr=imin/60; int ihr=imin/60;
imin=imin % 60; imin=imin % 60;
if(m_TRperiod>=60) imin=imin - (imin % (m_TRperiod/60)); if(m_TRperiod>=60) imin=imin - (imin % (m_TRperiod/60));
dec_data.params.nutc=100*ihr + imin; dec_data.params.nutc=100*ihr + imin;
if(m_mode=="ISCAT" or m_mode=="MSK144" or m_bFast9 or m_mode=="FT8") { if(m_mode=="ISCAT" or m_mode=="MSK144" or m_bFast9 or m_mode=="FT8") {
QDateTime t=QDateTime::currentDateTimeUtc().addSecs(2-m_TRperiod); QDateTime t=DriftingDateTime::currentDateTimeUtc().addSecs(2-m_TRperiod);
ihr=t.toString("hh").toInt(); ihr=t.toString("hh").toInt();
imin=t.toString("mm").toInt(); imin=t.toString("mm").toInt();
int isec=t.toString("ss").toInt(); int isec=t.toString("ss").toInt();
@ -3323,7 +3324,7 @@ void MainWindow::decode() //decode()
} }
if(m_nPick==1 and !m_diskData) { if(m_nPick==1 and !m_diskData) {
QDateTime t=QDateTime::currentDateTimeUtc(); QDateTime t=DriftingDateTime::currentDateTimeUtc();
int ihr=t.toString("hh").toInt(); int ihr=t.toString("hh").toInt();
int imin=t.toString("mm").toInt(); int imin=t.toString("mm").toInt();
int isec=t.toString("ss").toInt(); int isec=t.toString("ss").toInt();
@ -3504,7 +3505,7 @@ void MainWindow::writeAllTxt(QString message)
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f); QTextStream out(&f);
if(m_RxLog==1) { if(m_RxLog==1) {
out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") out << DriftingDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss")
<< " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz "
<< m_mode << endl; << m_mode << endl;
m_RxLog=0; m_RxLog=0;
@ -3546,7 +3547,7 @@ void MainWindow::readFromStdout() //readFromStdout
m_bWarnedHound=true; m_bWarnedHound=true;
} }
} }
// qint64 ms=QDateTime::currentMSecsSinceEpoch() - m_msec0; // qint64 ms=DriftingDateTime::currentMSecsSinceEpoch() - m_msec0;
bool bAvgMsg=false; bool bAvgMsg=false;
int navg=0; int navg=0;
if(t.indexOf("<DecodeFinished>") >= 0) { if(t.indexOf("<DecodeFinished>") >= 0) {
@ -3580,7 +3581,7 @@ void MainWindow::readFromStdout() //readFromStdout
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f); QTextStream out(&f);
if(m_RxLog==1) { if(m_RxLog==1) {
out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") out << DriftingDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss")
<< " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz "
<< m_mode << endl; << m_mode << endl;
m_RxLog=0; m_RxLog=0;
@ -3597,7 +3598,7 @@ void MainWindow::readFromStdout() //readFromStdout
} }
if (m_config.insert_blank () && m_blankLine && !m_config.bFox()) { if (m_config.insert_blank () && m_blankLine && !m_config.bFox()) {
QString band; QString band;
if((QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged) > 4*m_TRperiod/4) { if((DriftingDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged) > 4*m_TRperiod/4) {
band = ' ' + m_config.bands ()->find (m_freqNominal); band = ' ' + m_config.bands ()->find (m_freqNominal);
} }
ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-'));
@ -3661,7 +3662,7 @@ void MainWindow::readFromStdout() //readFromStdout
d.bits = decodedtext.bits(); d.bits = decodedtext.bits();
d.freq = offset; d.freq = offset;
d.text = decodedtext.message(); d.text = decodedtext.message();
d.utcTimestamp = QDateTime::currentDateTimeUtc(); d.utcTimestamp = DriftingDateTime::currentDateTimeUtc();
d.snr = decodedtext.snr(); d.snr = decodedtext.snr();
d.isBuffered = false; d.isBuffered = false;
@ -3698,7 +3699,7 @@ void MainWindow::readFromStdout() //readFromStdout
cd.grid = decodedtext.extra(); // compound calls via beacons may contain grid... cd.grid = decodedtext.extra(); // compound calls via beacons may contain grid...
cd.snr = decodedtext.snr(); cd.snr = decodedtext.snr();
cd.freq = decodedtext.frequencyOffset(); cd.freq = decodedtext.frequencyOffset();
cd.utcTimestamp = QDateTime::currentDateTimeUtc(); cd.utcTimestamp = DriftingDateTime::currentDateTimeUtc();
cd.bits = decodedtext.bits(); cd.bits = decodedtext.bits();
if(decodedtext.isBeacon()){ if(decodedtext.isBeacon()){
@ -3723,7 +3724,7 @@ void MainWindow::readFromStdout() //readFromStdout
d.cmd = parts.at(2); d.cmd = parts.at(2);
d.freq = decodedtext.frequencyOffset(); d.freq = decodedtext.frequencyOffset();
d.snr = decodedtext.snr(); d.snr = decodedtext.snr();
d.utcTimestamp = QDateTime::currentDateTimeUtc(); d.utcTimestamp = DriftingDateTime::currentDateTimeUtc();
d.bits = decodedtext.bits(); d.bits = decodedtext.bits();
d.extra = parts.length() > 2 ? parts.mid(3).join(" ") : ""; d.extra = parts.length() > 2 ? parts.mid(3).join(" ") : "";
@ -3788,7 +3789,7 @@ void MainWindow::readFromStdout() //readFromStdout
d.grid = theirgrid; d.grid = theirgrid;
d.snr = decodedtext.snr(); d.snr = decodedtext.snr();
d.freq = decodedtext.frequencyOffset(); d.freq = decodedtext.frequencyOffset();
d.utcTimestamp = QDateTime::currentDateTimeUtc(); d.utcTimestamp = DriftingDateTime::currentDateTimeUtc();
m_callActivity[d.call] = d; m_callActivity[d.call] = d;
} }
} }
@ -3826,7 +3827,7 @@ void MainWindow::readFromStdout() //readFromStdout
d.grid = !grids.empty() ? grids.first() : ""; d.grid = !grids.empty() ? grids.first() : "";
d.snr = decodedtext.snr(); d.snr = decodedtext.snr();
d.freq = decodedtext.frequencyOffset(); d.freq = decodedtext.frequencyOffset();
d.utcTimestamp = QDateTime::currentDateTimeUtc(); d.utcTimestamp = DriftingDateTime::currentDateTimeUtc();
m_callActivity[Radio::base_callsign(de_callsign)] = d; m_callActivity[Radio::base_callsign(de_callsign)] = d;
} }
} }
@ -3935,7 +3936,7 @@ void MainWindow::readFromStdout() //readFromStdout
if((t==deCall or t=="") and rpt!="") m_rptRcvd=rpt; if((t==deCall or t=="") and rpt!="") m_rptRcvd=rpt;
} }
// extract details and send to PSKreporter // extract details and send to PSKreporter
int nsec=QDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged; int nsec=DriftingDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged;
bool okToPost=(nsec>(4*m_TRperiod)/5); bool okToPost=(nsec>(4*m_TRperiod)/5);
//if (stdMsg && okToPost) pskPost(decodedtext); //if (stdMsg && okToPost) pskPost(decodedtext);
@ -4068,7 +4069,7 @@ void MainWindow::pskPost (DecodedText const& decodedtext)
if(grid.contains (grid_regexp)) { if(grid.contains (grid_regexp)) {
// qDebug() << "To PSKreporter:" << deCall << grid << frequency << msgmode << snr; // qDebug() << "To PSKreporter:" << deCall << grid << frequency << msgmode << snr;
// psk_Reporter->addRemoteStation(deCall,grid,QString::number(frequency),msgmode, // psk_Reporter->addRemoteStation(deCall,grid,QString::number(frequency),msgmode,
// QString::number(snr),QString::number(QDateTime::currentDateTime().toTime_t())); // QString::number(snr),QString::number(DriftingDateTime::currentDateTime().toTime_t()));
pskLogReport(msgmode, audioFrequency, snr, deCall, grid); pskLogReport(msgmode, audioFrequency, snr, deCall, grid);
} }
#endif #endif
@ -4085,7 +4086,7 @@ void MainWindow::pskLogReport(QString mode, int offset, int snr, QString callsig
QString::number(frequency), QString::number(frequency),
mode, mode,
QString::number(snr), QString::number(snr),
QString::number(QDateTime::currentDateTime().toTime_t())); QString::number(DriftingDateTime::currentDateTime().toTime_t()));
} }
void MainWindow::aprsLogReport(int offset, int snr, QString callsign, QString grid){ void MainWindow::aprsLogReport(int offset, int snr, QString callsign, QString grid){
@ -4120,7 +4121,7 @@ void MainWindow::killFile ()
void MainWindow::on_EraseButton_clicked () void MainWindow::on_EraseButton_clicked ()
{ {
qint64 ms=QDateTime::currentMSecsSinceEpoch(); qint64 ms=DriftingDateTime::currentMSecsSinceEpoch();
ui->decodedTextBrowser2->erase (); ui->decodedTextBrowser2->erase ();
if(m_mode.startsWith ("WSPR") or m_mode=="Echo" or m_mode=="ISCAT") { if(m_mode.startsWith ("WSPR") or m_mode=="Echo" or m_mode=="ISCAT") {
ui->decodedTextBrowser->erase (); ui->decodedTextBrowser->erase ();
@ -4191,7 +4192,7 @@ void MainWindow::guiUpdate()
tx2 += m_TRperiod; tx2 += m_TRperiod;
} }
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = DriftingDateTime::currentMSecsSinceEpoch() % 86400000;
int nsec=ms/1000; int nsec=ms/1000;
double tsec=0.001*ms; double tsec=0.001*ms;
double t2p=fmod(tsec,2*m_TRperiod); double t2p=fmod(tsec,2*m_TRperiod);
@ -4236,7 +4237,7 @@ void MainWindow::guiUpdate()
if(m_tune) m_bTxTime=true; //"Tune" takes precedence if(m_tune) m_bTxTime=true; //"Tune" takes precedence
if(m_transmitting or m_auto or m_tune) { if(m_transmitting or m_auto or m_tune) {
m_dateTimeLastTX = QDateTime::currentDateTime (); m_dateTimeLastTX = DriftingDateTime::currentDateTime ();
// Check for "txboth" (testing purposes only) // Check for "txboth" (testing purposes only)
QFile f(m_appDir + "/txboth"); QFile f(m_appDir + "/txboth");
@ -4508,7 +4509,7 @@ void MainWindow::guiUpdate()
} }
} }
auto t2 = QDateTime::currentDateTimeUtc ().toString ("hhmm"); auto t2 = DriftingDateTime::currentDateTimeUtc ().toString ("hhmm");
icw[0] = 0; icw[0] = 0;
auto msg_parts = m_currentMessage.split (' ', QString::SkipEmptyParts); auto msg_parts = m_currentMessage.split (' ', QString::SkipEmptyParts);
if (msg_parts.size () > 2) { if (msg_parts.size () > 2) {
@ -4623,7 +4624,7 @@ void MainWindow::guiUpdate()
} }
// TODO: jsherer - perhaps an on_transmitting signal? // TODO: jsherer - perhaps an on_transmitting signal?
m_lastTxTime = QDateTime::currentDateTimeUtc(); m_lastTxTime = DriftingDateTime::currentDateTimeUtc();
m_transmitting = true; m_transmitting = true;
transmitDisplay (true); transmitDisplay (true);
@ -4665,7 +4666,7 @@ void MainWindow::guiUpdate()
if(m_config.bHound()) { if(m_config.bHound()) {
m_bWarnedHound=false; m_bWarnedHound=false;
qint32 tHound=QDateTime::currentMSecsSinceEpoch()/1000 - m_tAutoOn; qint32 tHound=DriftingDateTime::currentMSecsSinceEpoch()/1000 - m_tAutoOn;
//To keep calling Fox, Hound must reactivate Enable Tx at least once every 2 minutes //To keep calling Fox, Hound must reactivate Enable Tx at least once every 2 minutes
if(tHound >= 120 and m_ntx==1) auto_tx_mode(false); if(tHound >= 120 and m_ntx==1) auto_tx_mode(false);
} }
@ -4736,7 +4737,7 @@ void MainWindow::guiUpdate()
tx_status_label.setText(""); tx_status_label.setText("");
} }
QDateTime t = QDateTime::currentDateTimeUtc(); QDateTime t = DriftingDateTime::currentDateTimeUtc();
QString utc = t.date().toString("yyyy MMM dd") + "\n " + QString utc = t.date().toString("yyyy MMM dd") + "\n " +
t.time().toString() + " "; t.time().toString() + " ";
ui->labUTC->setText(utc); ui->labUTC->setText(utc);
@ -4809,7 +4810,7 @@ void MainWindow::startTx()
if (m_transmitting) m_restart=true; if (m_transmitting) m_restart=true;
// detect if we're currently in a possible transmit cycle...and if so, wait until the next one if we're more than 2 seconds in... // detect if we're currently in a possible transmit cycle...and if so, wait until the next one if we're more than 2 seconds in...
QDateTime now {QDateTime::currentDateTimeUtc()}; QDateTime now {DriftingDateTime::currentDateTimeUtc()};
int s=now.addSecs(-2).time().second(); int s=now.addSecs(-2).time().second();
int n=s % (2*m_TRperiod); int n=s % (2*m_TRperiod);
if((n <= m_TRperiod && m_txFirst) || (n > m_TRperiod && !m_txFirst)){ if((n <= m_TRperiod && m_txFirst) || (n > m_TRperiod && !m_txFirst)){
@ -4941,7 +4942,7 @@ void MainWindow::set_dateTimeQSO(int m_ntx)
return; return;
} }
else { // we also take of m_TRperiod/2 to allow for late clicks else { // we also take of m_TRperiod/2 to allow for late clicks
auto now = QDateTime::currentDateTimeUtc(); auto now = DriftingDateTime::currentDateTimeUtc();
m_dateTimeQSOOn = now.addSecs (-(m_ntx - 2) * m_TRperiod - (now.time ().second () % m_TRperiod)); m_dateTimeQSOOn = now.addSecs (-(m_ntx - 2) * m_TRperiod - (now.time ().second () % m_TRperiod));
} }
} }
@ -6178,7 +6179,7 @@ void MainWindow::addMessageText(QString text, bool clear, bool selectFirstPlaceh
void MainWindow::enqueueMessage(int priority, QString message, int freq, Callback c){ void MainWindow::enqueueMessage(int priority, QString message, int freq, Callback c){
m_txMessageQueue.enqueue( m_txMessageQueue.enqueue(
PrioritizedMessage{ PrioritizedMessage{
QDateTime::currentDateTimeUtc(), priority, message, freq, c DriftingDateTime::currentDateTimeUtc(), priority, message, freq, c
} }
); );
} }
@ -6241,7 +6242,7 @@ void MainWindow::createMessageTransmitQueue(QString const& text){
lines.append(dt.message()); lines.append(dt.message());
} }
displayTextForFreq(lines.join("") + " \u2301 ", freq, QDateTime::currentDateTimeUtc(), true, true, true); displayTextForFreq(lines.join("") + " \u2301 ", freq, DriftingDateTime::currentDateTimeUtc(), true, true, true);
// keep track of the last message text sent // keep track of the last message text sent
m_lastTxMessage = text; m_lastTxMessage = text;
@ -6658,7 +6659,7 @@ bool MainWindow::isFreqOffsetFree(int f, int bw){
} }
// if we last received on this more than 30 seconds ago, it's free // if we last received on this more than 30 seconds ago, it's free
if(d.last().utcTimestamp.secsTo(QDateTime::currentDateTimeUtc()) >= 30){ if(d.last().utcTimestamp.secsTo(DriftingDateTime::currentDateTimeUtc()) >= 30){
continue; continue;
} }
@ -6695,7 +6696,7 @@ int MainWindow::findFreeFreqOffset(int fmin, int fmax, int bw){
// scheduleBeacon // scheduleBeacon
void MainWindow::scheduleBacon(bool first){ void MainWindow::scheduleBacon(bool first){
auto timestamp = QDateTime::currentDateTimeUtc(); auto timestamp = DriftingDateTime::currentDateTimeUtc();
auto orig = timestamp; auto orig = timestamp;
// remove milliseconds // remove milliseconds
@ -6739,7 +6740,7 @@ void MainWindow::checkBacon(){
if(!ui->beaconButton->isChecked()){ if(!ui->beaconButton->isChecked()){
return; return;
} }
if(QDateTime::currentDateTimeUtc().secsTo(m_nextBeacon) > 5){ if(DriftingDateTime::currentDateTimeUtc().secsTo(m_nextBeacon) > 5){
return; return;
} }
if(m_nextBeaconQueued){ if(m_nextBeaconQueued){
@ -6784,7 +6785,7 @@ QString MainWindow::calculateDistance(QString const& value, int *pDistance)
return QString{}; return QString{};
} }
qint64 nsec = (QDateTime::currentMSecsSinceEpoch()/1000) % 86400; qint64 nsec = (DriftingDateTime::currentMSecsSinceEpoch()/1000) % 86400;
double utch=nsec/3600.0; double utch=nsec/3600.0;
int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter; int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter;
azdist_(const_cast <char *> ((m_config.my_grid () + " ").left (6).toLatin1().constData()), azdist_(const_cast <char *> ((m_config.my_grid () + " ").left (6).toLatin1().constData()),
@ -6845,7 +6846,7 @@ void MainWindow::on_dxGridEntry_textChanged (QString const& grid)
m_hisGrid = grid; m_hisGrid = grid;
statusUpdate (); statusUpdate ();
} }
qint64 nsec = (QDateTime::currentMSecsSinceEpoch()/1000) % 86400; qint64 nsec = (DriftingDateTime::currentMSecsSinceEpoch()/1000) % 86400;
double utch=nsec/3600.0; double utch=nsec/3600.0;
int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter; int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter;
azdist_(const_cast <char *> ((m_config.my_grid () + " ").left (6).toLatin1().constData()), azdist_(const_cast <char *> ((m_config.my_grid () + " ").left (6).toLatin1().constData()),
@ -6886,9 +6887,9 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button
*/ */
// m_dateTimeQSOOn should really already be set but we'll ensure it gets set to something just in case // m_dateTimeQSOOn should really already be set but we'll ensure it gets set to something just in case
if (!m_dateTimeQSOOn.isValid ()) { if (!m_dateTimeQSOOn.isValid ()) {
m_dateTimeQSOOn = QDateTime::currentDateTimeUtc(); m_dateTimeQSOOn = DriftingDateTime::currentDateTimeUtc();
} }
auto dateTimeQSOOff = QDateTime::currentDateTimeUtc(); auto dateTimeQSOOff = DriftingDateTime::currentDateTimeUtc();
if (dateTimeQSOOff < m_dateTimeQSOOn) dateTimeQSOOff = m_dateTimeQSOOn; if (dateTimeQSOOff < m_dateTimeQSOOn) dateTimeQSOOff = m_dateTimeQSOOn;
QString call=callsignSelected(); QString call=callsignSelected();
if(call == "ALLCALL"){ if(call == "ALLCALL"){
@ -7923,7 +7924,7 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){
} }
void MainWindow::buildRelayMenu(QMenu *menu){ void MainWindow::buildRelayMenu(QMenu *menu){
auto now = QDateTime::currentDateTimeUtc(); auto now = DriftingDateTime::currentDateTimeUtc();
int callsignAging = m_config.callsign_aging(); int callsignAging = m_config.callsign_aging();
foreach(auto cd, m_callActivity.values()){ foreach(auto cd, m_callActivity.values()){
if (callsignAging && cd.utcTimestamp.secsTo(now) / 60 >= callsignAging) { if (callsignAging && cd.utcTimestamp.secsTo(now) / 60 >= callsignAging) {
@ -8029,7 +8030,7 @@ void MainWindow::on_tableWidgetRXAll_cellDoubleClicked(int row, int col){
// print the history in the main window... // print the history in the main window...
int activityAging = m_config.activity_aging(); int activityAging = m_config.activity_aging();
QDateTime now = QDateTime::currentDateTimeUtc(); QDateTime now = DriftingDateTime::currentDateTimeUtc();
QDateTime firstActivity = now; QDateTime firstActivity = now;
QString activityText; QString activityText;
bool isLast = false; bool isLast = false;
@ -8091,6 +8092,62 @@ void MainWindow::on_freeTextMsg_currentTextChanged (QString const& text)
msgtype(text, ui->freeTextMsg->lineEdit ()); msgtype(text, ui->freeTextMsg->lineEdit ());
} }
void MainWindow::on_driftSpinBox_valueChanged(int n){
if(n == DriftingDateTime::drift()){
return;
}
setDrift(n);
}
void MainWindow::on_driftSyncButton_clicked(){
auto now = QDateTime::currentDateTimeUtc();
int n = 0;
int nPos = 15 - now.time().second() % m_TRperiod;
int nNeg = now.time().second() % m_TRperiod - 15;
if(abs(nNeg) < nPos){
n = nNeg;
} else {
n = nPos;
}
setDrift(n * 1000);
}
void MainWindow::on_driftSyncEndButton_clicked(){
auto now = QDateTime::currentDateTimeUtc();
int n = 0;
int nPos = 15 - now.time().second() % m_TRperiod;
int nNeg = now.time().second() % m_TRperiod - 15;
if(abs(nNeg) < nPos){
n = nNeg + 2;
} else {
n = nPos - 2;
}
setDrift(n * 1000);
}
void MainWindow::on_driftSyncResetButton_clicked(){
setDrift(0);
}
void MainWindow::setDrift(int n){
DriftingDateTime::setDrift(n);
qDebug() << qSetRealNumberPrecision(12) << "Drift milliseconds:" << n;
qDebug() << qSetRealNumberPrecision(12) << "Clock time:" << QDateTime::currentDateTimeUtc();
qDebug() << qSetRealNumberPrecision(12) << "Drifted time:" << DriftingDateTime::currentDateTimeUtc();
if(ui->driftSpinBox->value() != n){
ui->driftSpinBox->setValue(n);
}
}
void MainWindow::on_rptSpinBox_valueChanged(int n) void MainWindow::on_rptSpinBox_valueChanged(int n)
{ {
int step=ui->rptSpinBox->singleStep(); int step=ui->rptSpinBox->singleStep();
@ -8399,7 +8456,7 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const&
|| !(ui->cbCQTx->isEnabled () && ui->cbCQTx->isVisible () && ui->cbCQTx->isChecked()))) { || !(ui->cbCQTx->isEnabled () && ui->cbCQTx->isVisible () && ui->cbCQTx->isChecked()))) {
m_lastDialFreq = m_freqNominal; m_lastDialFreq = m_freqNominal;
m_secBandChanged=QDateTime::currentMSecsSinceEpoch()/1000; m_secBandChanged=DriftingDateTime::currentMSecsSinceEpoch()/1000;
if(m_freqNominal != m_bandHoppedFreq){ if(m_freqNominal != m_bandHoppedFreq){
m_bandHopped = false; m_bandHopped = false;
@ -8410,7 +8467,7 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const&
QFile f2 {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")}; QFile f2 {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")};
if (f2.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f2.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f2); QTextStream out(&f2);
out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") out << DriftingDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss")
<< " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz "
<< m_mode << endl; << m_mode << endl;
f2.close(); f2.close();
@ -9116,19 +9173,19 @@ bool MainWindow::isRecentOffset(int offset){
} }
return ( return (
m_rxRecentCache.contains(offset/10*10) && m_rxRecentCache.contains(offset/10*10) &&
m_rxRecentCache[offset/10*10]->secsTo(QDateTime::currentDateTimeUtc()) < 120 m_rxRecentCache[offset/10*10]->secsTo(DriftingDateTime::currentDateTimeUtc()) < 120
); );
} }
void MainWindow::markOffsetRecent(int offset){ void MainWindow::markOffsetRecent(int offset){
m_rxRecentCache.insert(offset/10*10, new QDateTime(QDateTime::currentDateTimeUtc()), 10); m_rxRecentCache.insert(offset/10*10, new QDateTime(DriftingDateTime::currentDateTimeUtc()), 10);
m_rxRecentCache.insert(offset/10*10+10, new QDateTime(QDateTime::currentDateTimeUtc()), 10); m_rxRecentCache.insert(offset/10*10+10, new QDateTime(DriftingDateTime::currentDateTimeUtc()), 10);
} }
bool MainWindow::isDirectedOffset(int offset, bool *pIsAllCall){ bool MainWindow::isDirectedOffset(int offset, bool *pIsAllCall){
bool isDirected = ( bool isDirected = (
m_rxDirectedCache.contains(offset/10*10) && m_rxDirectedCache.contains(offset/10*10) &&
m_rxDirectedCache[offset/10*10]->date.secsTo(QDateTime::currentDateTimeUtc()) < 300 m_rxDirectedCache[offset/10*10]->date.secsTo(DriftingDateTime::currentDateTimeUtc()) < 300
); );
if(isDirected){ if(isDirected){
@ -9139,8 +9196,8 @@ bool MainWindow::isDirectedOffset(int offset, bool *pIsAllCall){
} }
void MainWindow::markOffsetDirected(int offset, bool isAllCall){ void MainWindow::markOffsetDirected(int offset, bool isAllCall){
CachedDirectedType *d1 = new CachedDirectedType{ isAllCall, QDateTime::currentDateTimeUtc() }; CachedDirectedType *d1 = new CachedDirectedType{ isAllCall, DriftingDateTime::currentDateTimeUtc() };
CachedDirectedType *d2 = new CachedDirectedType{ isAllCall, QDateTime::currentDateTimeUtc() }; CachedDirectedType *d2 = new CachedDirectedType{ isAllCall, DriftingDateTime::currentDateTimeUtc() };
m_rxDirectedCache.insert(offset/10*10, d1, 10); m_rxDirectedCache.insert(offset/10*10, d1, 10);
m_rxDirectedCache.insert(offset/10*10+10, d2, 10); m_rxDirectedCache.insert(offset/10*10+10, d2, 10);
} }
@ -9224,12 +9281,12 @@ void MainWindow::processRxActivity() {
// TODO: jsherer - develop a better way to determine if we can display this band activity... // TODO: jsherer - develop a better way to determine if we can display this band activity...
#if 0 #if 0
if(isRecentOffset(freq) || isAllCallIncluded(d.text)){ if(isRecentOffset(freq) || isAllCallIncluded(d.text)){
m_rxRecentCache.insert(freq, new QDateTime(QDateTime::currentDateTimeUtc()), 25); m_rxRecentCache.insert(freq, new QDateTime(DriftingDateTime::currentDateTimeUtc()), 25);
shouldDisplay = true; shouldDisplay = true;
} }
if(isDirectedOffset(freq) || isMyCallIncluded(d.text)){ if(isDirectedOffset(freq) || isMyCallIncluded(d.text)){
m_rxDirectedCache.insert(freq, new QDateTime(QDateTime::currentDateTimeUtc()), 25); m_rxDirectedCache.insert(freq, new QDateTime(DriftingDateTime::currentDateTimeUtc()), 25);
shouldDisplay = true; shouldDisplay = true;
} }
#endif #endif
@ -9361,7 +9418,7 @@ void MainWindow::processBufferedActivity() {
// check to make sure we empty old buffers by getting the latest timestamp // check to make sure we empty old buffers by getting the latest timestamp
// and checking to see if it's older than one minute. // and checking to see if it's older than one minute.
auto dt = QDateTime::currentDateTimeUtc().addDays(-1); auto dt = DriftingDateTime::currentDateTimeUtc().addDays(-1);
if(buffer.cmd.utcTimestamp.isValid()){ if(buffer.cmd.utcTimestamp.isValid()){
dt = qMax(dt, buffer.cmd.utcTimestamp); dt = qMax(dt, buffer.cmd.utcTimestamp);
} }
@ -9371,7 +9428,7 @@ void MainWindow::processBufferedActivity() {
if(!buffer.msgs.isEmpty()){ if(!buffer.msgs.isEmpty()){
dt = qMax(dt, buffer.msgs.last().utcTimestamp); dt = qMax(dt, buffer.msgs.last().utcTimestamp);
} }
if(dt.secsTo(QDateTime::currentDateTimeUtc()) > 60){ if(dt.secsTo(DriftingDateTime::currentDateTimeUtc()) > 60){
m_messageBuffer.remove(freq); m_messageBuffer.remove(freq);
continue; continue;
} }
@ -9446,7 +9503,7 @@ void MainWindow::processCommandActivity() {
int f = currentFreq(); int f = currentFreq();
#endif #endif
auto now = QDateTime::currentDateTimeUtc(); auto now = DriftingDateTime::currentDateTimeUtc();
while (!m_rxCommandQueue.isEmpty()) { while (!m_rxCommandQueue.isEmpty()) {
auto d = m_rxCommandQueue.dequeue(); auto d = m_rxCommandQueue.dequeue();
@ -9680,7 +9737,7 @@ void MainWindow::processCommandActivity() {
cd.snr = -64; cd.snr = -64;
cd.freq = d.freq; cd.freq = d.freq;
cd.through = d.from; cd.through = d.from;
cd.utcTimestamp = QDateTime::currentDateTimeUtc(); cd.utcTimestamp = DriftingDateTime::currentDateTimeUtc();
logCallActivity(cd, false); logCallActivity(cd, false);
} }
@ -9878,7 +9935,7 @@ void MainWindow::processSpots() {
} }
// Is it ok to post spots to PSKReporter? // Is it ok to post spots to PSKReporter?
int nsec = QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged; int nsec = DriftingDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged;
bool okToPost = (nsec > (4 * m_TRperiod) / 5); bool okToPost = (nsec > (4 * m_TRperiod) / 5);
if (!okToPost) { if (!okToPost) {
return; return;
@ -9929,7 +9986,7 @@ void MainWindow::processTxQueue(){
} }
// and if we are a low priority message, we need to have not transmitted in the past 30 seconds... // and if we are a low priority message, we need to have not transmitted in the past 30 seconds...
if(head.priority <= PriorityLow && m_lastTxTime.secsTo(QDateTime::currentDateTimeUtc()) <= 30){ if(head.priority <= PriorityLow && m_lastTxTime.secsTo(DriftingDateTime::currentDateTimeUtc()) <= 30){
return; return;
} }
@ -9971,7 +10028,7 @@ void MainWindow::displayActivity(bool force) {
} }
void MainWindow::displayBandActivity() { void MainWindow::displayBandActivity() {
auto now = QDateTime::currentDateTimeUtc(); auto now = DriftingDateTime::currentDateTimeUtc();
ui->tableWidgetRXAll->setFont(m_config.table_font()); ui->tableWidgetRXAll->setFont(m_config.table_font());
@ -10183,7 +10240,7 @@ void MainWindow::displayBandActivity() {
} }
void MainWindow::displayCallActivity() { void MainWindow::displayCallActivity() {
auto now = QDateTime::currentDateTimeUtc(); auto now = DriftingDateTime::currentDateTimeUtc();
// Selected callsign // Selected callsign
QString selectedCall = callsignSelected(); QString selectedCall = callsignSelected();
@ -10654,7 +10711,7 @@ void MainWindow::p1ReadFromStdout() //p1readFromStdout
QString MainWindow::WSPR_hhmm(int n) QString MainWindow::WSPR_hhmm(int n)
{ {
QDateTime t=QDateTime::currentDateTimeUtc().addSecs(n); QDateTime t=DriftingDateTime::currentDateTimeUtc().addSecs(n);
int m=t.toString("hhmm").toInt()/2; int m=t.toString("hhmm").toInt()/2;
QString t1; QString t1;
t1.sprintf("%04d",2*m); t1.sprintf("%04d",2*m);
@ -10663,7 +10720,7 @@ QString MainWindow::WSPR_hhmm(int n)
void MainWindow::WSPR_history(Frequency dialFreq, int ndecodes) void MainWindow::WSPR_history(Frequency dialFreq, int ndecodes)
{ {
QDateTime t=QDateTime::currentDateTimeUtc().addSecs(-60); QDateTime t=DriftingDateTime::currentDateTimeUtc().addSecs(-60);
QString t1=t.toString("yyMMdd"); QString t1=t.toString("yyMMdd");
QString t2=WSPR_hhmm(-60); QString t2=WSPR_hhmm(-60);
QString t3; QString t3;
@ -10807,7 +10864,7 @@ void MainWindow::astroUpdate ()
// no Doppler correction while CTRL pressed allows manual tuning // no Doppler correction while CTRL pressed allows manual tuning
if (Qt::ControlModifier & QApplication::queryKeyboardModifiers ()) return; if (Qt::ControlModifier & QApplication::queryKeyboardModifiers ()) return;
auto correction = m_astroWidget->astroUpdate(QDateTime::currentDateTimeUtc (), auto correction = m_astroWidget->astroUpdate(DriftingDateTime::currentDateTimeUtc (),
m_config.my_grid(), m_hisGrid, m_config.my_grid(), m_hisGrid,
m_freqNominal, m_freqNominal,
"Echo" == m_mode, m_transmitting, "Echo" == m_mode, m_transmitting,
@ -11095,7 +11152,7 @@ void MainWindow::write_transmit_entry (QString const& file_name)
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
{ {
QTextStream out(&f); QTextStream out(&f);
auto time = QDateTime::currentDateTimeUtc (); auto time = DriftingDateTime::currentDateTimeUtc ();
time = time.addSecs (-(time.time ().second () % m_TRperiod)); time = time.addSecs (-(time.time ().second () % m_TRperiod));
auto dt = DecodedText(m_currentMessage); auto dt = DecodedText(m_currentMessage);
out << time.toString("yyyy-MM-dd hh:mm:ss") out << time.toString("yyyy-MM-dd hh:mm:ss")
@ -11410,7 +11467,7 @@ void MainWindow::foxTxSequencer()
* foxgen() to generate and accumulate the corresponding waveform. * foxgen() to generate and accumulate the corresponding waveform.
*/ */
qint64 now=QDateTime::currentMSecsSinceEpoch()/1000; qint64 now=DriftingDateTime::currentMSecsSinceEpoch()/1000;
QStringList list1; //Up to NSlots Hound calls to be sent RR73 QStringList list1; //Up to NSlots Hound calls to be sent RR73
QStringList list2; //Up to NSlots Hound calls to be sent a report QStringList list2; //Up to NSlots Hound calls to be sent a report
QString fm; //Fox message to be transmitted QString fm; //Fox message to be transmitted
@ -11526,7 +11583,7 @@ list2Done:
m_hisGrid=m_foxQSO[hc1].grid; m_hisGrid=m_foxQSO[hc1].grid;
m_rptSent=m_foxQSO[hc1].sent; m_rptSent=m_foxQSO[hc1].sent;
m_rptRcvd=m_foxQSO[hc1].rcvd; m_rptRcvd=m_foxQSO[hc1].rcvd;
QDateTime logTime {QDateTime::currentDateTimeUtc ()}; QDateTime logTime {DriftingDateTime::currentDateTimeUtc ()};
QString thc1=(m_hisCall + " ").mid(0,6); QString thc1=(m_hisCall + " ").mid(0,6);
if(m_hisCall.contains("/")) thc1=m_hisCall; if(m_hisCall.contains("/")) thc1=m_hisCall;
QString logLine=logTime.toString("yyyy-MM-dd hh:mm") + " " + thc1 + " " + QString logLine=logTime.toString("yyyy-MM-dd hh:mm") + " " + thc1 + " " +
@ -11662,7 +11719,7 @@ void MainWindow::writeFoxQSO(QString msg)
QFile f {m_config.writeable_data_dir ().absoluteFilePath ("FoxQSO.txt")}; QFile f {m_config.writeable_data_dir ().absoluteFilePath ("FoxQSO.txt")};
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f); QTextStream out(&f);
out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") out << DriftingDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss")
<< " " << fixed << qSetRealNumberPrecision (3) << (m_freqNominal/1.e6) << " " << fixed << qSetRealNumberPrecision (3) << (m_freqNominal/1.e6)
<< t << msg << endl; << t << msg << endl;
f.close(); f.close();

View File

@ -299,6 +299,11 @@ private slots:
void checkBacon(); void checkBacon();
void prepareBacon(); void prepareBacon();
QString calculateDistance(QString const& grid, int *pDistance=nullptr); QString calculateDistance(QString const& grid, int *pDistance=nullptr);
void on_driftSpinBox_valueChanged(int n);
void on_driftSyncButton_clicked();
void on_driftSyncEndButton_clicked();
void on_driftSyncResetButton_clicked();
void setDrift(int n);
void on_rptSpinBox_valueChanged(int n); void on_rptSpinBox_valueChanged(int n);
void killFile(); void killFile();
void on_tuneButton_clicked (bool); void on_tuneButton_clicked (bool);

View File

@ -1727,6 +1727,125 @@ background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #2ecc71, stop:1 #00FF
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QFrame" name="frame_7">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QSpinBox" name="driftSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="suffix">
<string> ms</string>
</property>
<property name="prefix">
<string>Time Drift </string>
</property>
<property name="minimum">
<number>-15000</number>
</property>
<property name="maximum">
<number>15000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the start of a TX cycle.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Sync Time to TX Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncEndButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the end of a TX cycle.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Sync Time to TX End</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncResetButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Reset your time drift to zero.</string>
</property>
<property name="text">
<string>Reset Drift</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>

View File

@ -6,6 +6,8 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "DriftingDateTime.h"
#define MAX_SCREENSIZE 2048 #define MAX_SCREENSIZE 2048
extern "C" { extern "C" {
@ -236,9 +238,9 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed)
if(m_line == painter1.fontMetrics ().height ()) { if(m_line == painter1.fontMetrics ().height ()) {
painter1.setPen(Qt::white); painter1.setPen(Qt::white);
QString t; QString t;
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = DriftingDateTime::currentMSecsSinceEpoch() % 86400000;
int n=(ms/1000) % m_TRperiod; int n=(ms/1000) % m_TRperiod;
QDateTime t1=QDateTime::currentDateTimeUtc().addSecs(-n); QDateTime t1=DriftingDateTime::currentDateTimeUtc().addSecs(-n);
if(m_TRperiod < 60) { if(m_TRperiod < 60) {
t=t1.toString("hh:mm:ss") + " " + m_rxBand; t=t1.toString("hh:mm:ss") + " " + m_rxBand;
} else { } else {

View File

@ -9,6 +9,7 @@
#include <QTimer> #include <QTimer>
#include "MessageClient.hpp" #include "MessageClient.hpp"
#include "DriftingDateTime.h"
#include "moc_psk_reporter.cpp" #include "moc_psk_reporter.cpp"
@ -78,7 +79,7 @@ void PSK_Reporter::sendReport()
// Header // Header
QString header_h = m_header_h; QString header_h = m_header_h;
header_h.replace("tttttttt", QString("%1").arg(QDateTime::currentDateTime().toTime_t(),8,16,QChar('0'))); header_h.replace("tttttttt", QString("%1").arg(DriftingDateTime::currentDateTime().toTime_t(),8,16,QChar('0')));
header_h.replace("ssssssss", QString("%1").arg(++m_sequenceNumber,8,16,QChar('0'))); header_h.replace("ssssssss", QString("%1").arg(++m_sequenceNumber,8,16,QChar('0')));
header_h.replace("iiiiiiii", m_randomId_h); header_h.replace("iiiiiiii", m_randomId_h);

View File

@ -6,6 +6,8 @@
#include <QSysInfo> #include <QSysInfo>
#include <QDebug> #include <QDebug>
#include "DriftingDateTime.h"
#include "moc_soundin.cpp" #include "moc_soundin.cpp"
bool SoundInput::audioError () const bool SoundInput::audioError () const
@ -102,7 +104,7 @@ void SoundInput::suspend ()
void SoundInput::resume () void SoundInput::resume ()
{ {
// qDebug() << "Resume" << fmod(0.001*QDateTime::currentMSecsSinceEpoch(),6.0); // qDebug() << "Resume" << fmod(0.001*DriftingDateTime::currentMSecsSinceEpoch(),6.0);
if (m_sink) if (m_sink)
{ {
m_sink->reset (); m_sink->reset ();

View File

@ -8,6 +8,9 @@
#include "Configuration.hpp" #include "Configuration.hpp"
#include "MessageBox.hpp" #include "MessageBox.hpp"
#include "SettingsGroup.hpp" #include "SettingsGroup.hpp"
#include "DriftingDateTime.h"
#include "moc_widegraph.cpp" #include "moc_widegraph.cpp"
namespace namespace
@ -191,7 +194,7 @@ void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dat
} }
// Time according to this computer // Time according to this computer
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = DriftingDateTime::currentMSecsSinceEpoch() % 86400000;
int ntr = (ms/1000) % m_TRperiod; int ntr = (ms/1000) % m_TRperiod;
if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && ntr<m_ntr0)) { if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && ntr<m_ntr0)) {
float flagValue=1.0e30; float flagValue=1.0e30;

View File

@ -74,7 +74,8 @@ SOURCES += \
SelfDestructMessageBox.cpp \ SelfDestructMessageBox.cpp \
APRSISClient.cpp \ APRSISClient.cpp \
messagereplydialog.cpp \ messagereplydialog.cpp \
keyeater.cpp keyeater.cpp \
DriftingDateTime.cpp
HEADERS += qt_helpers.hpp \ HEADERS += qt_helpers.hpp \
pimpl_h.hpp pimpl_impl.hpp \ pimpl_h.hpp pimpl_impl.hpp \
@ -100,7 +101,8 @@ HEADERS += qt_helpers.hpp \
SelfDestructMessageBox.h \ SelfDestructMessageBox.h \
APRSISClient.h \ APRSISClient.h \
messagereplydialog.h \ messagereplydialog.h \
keyeater.h keyeater.h \
DriftingDateTime.h
INCLUDEPATH += qmake_only INCLUDEPATH += qmake_only