Merge branch 'feat-ft2' of bitbucket.org:k1jt/wsjtx into feat-ft2

This commit is contained in:
Steve Franke 2019-02-21 15:48:08 -06:00
commit 9425bd4d37
5 changed files with 75 additions and 32 deletions

View File

@ -51,6 +51,9 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol,
// Time according to this computer which becomes our base time
qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000;
// qDebug() << "ModStart" << symbolsLength << framesPerSymbol
// << frequency << toneSpacing;
if(m_state != Idle) stop ();
m_quickClose = false;
@ -90,7 +93,7 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol,
m_silentFrames = m_ic + m_frameRate / (1000 / delay_ms) - (mstr * (m_frameRate / 1000));
}
if((symbolsLength==103 or symbolsLength==105) and framesPerSymbol==512
and toneSpacing==12000.0/512.0) {
and (toneSpacing==12000.0/512.0 or toneSpacing==-2.0)) {
//### FT4 parameters
delay_ms=100;
mstr=5000;
@ -300,8 +303,9 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
//Here's where we transmit from a precomputed wave[] array:
if(m_toneSpacing < 0) sample=qRound(m_amp*foxcom_.wave[m_ic]);
// if(m_ic < 100) qDebug() << "Mod C" << m_ic << m_amp << foxcom_.wave[m_ic] << sample;
// if(m_ic < 10) qDebug() << "Mod Tx" << m_ic << m_amp
// << foxcom_.wave[m_ic] << sample
// << m_toneSpacing;
samples = load(postProcessSample(sample), samples);
++framesGenerated;

View File

@ -186,7 +186,7 @@ subroutine ft4_decode(cdatetime0,tbuf,nfa,nfb,nQSOProgress,ncontest,nfqso, &
idfmax=12
idfstp=3
ibmin=0
ibmax=215
ibmax=216 !Max DT = 216/750 = 0.288 s
ibstp=4
else
idfmin=idfbest-4
@ -474,7 +474,7 @@ subroutine ft4_decode(cdatetime0,tbuf,nfa,nfb,nQSOProgress,ncontest,nfqso, &
1002 format(a17,i4,f5.1,i5,' Rx ',a37,5i5)
close(24)
linex(ndecodes)=line
if(ibest.ge.210) msg0=message !Possible dupe candidate
if(ibest.ge.ibmax-15) msg0=message !Possible dupe candidate
!### Temporary: assume most recent decoded message conveys "hiscall". ###
i0=index(message,' ')

View File

@ -60,12 +60,13 @@ program ft4d
close(10)
cdatetime=infile(1:13)//'.000'
nsteps=(npts-60000)/3456 + 1
istep=3456
nsteps=(npts-52800)/istep + 1
do n=1,nsteps
i0=(n-1)*3456 + 1
i0=(n-1)*istep + 1
tbuf=(i0-1)/12000.0
call ft4_decode(cdatetime,tbuf,nfa,nfb,nQSOProgress,ncontest, &
nfqso,iwave(i0),ndecodes,mycall,hiscall,nrx,line,data_dir)
nfqso,iwave(i0),ndecodes,mycall,hiscall,nrx,line,data_dir)
do idecode=1,ndecodes
call get_ft4msg(idecode,nrx,line)
write(*,'(a61)') line

View File

@ -102,6 +102,9 @@ extern "C" {
void genft4_(char* msg, int* ichk, char* msgsent, int itone[],
fortran_charlen_t, fortran_charlen_t);
void gen_ft4wave_(int itone[], int* nsym, int* nsps, float* fsample, float* f0,
float wave[], int* nwave);
void gen4_(char* msg, int* ichk, char* msgsent, int itone[],
int* itext, fortran_charlen_t, fortran_charlen_t);
@ -1460,7 +1463,7 @@ void MainWindow::dataSink(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, m_config.my_callsign(),
this, m_fnameWE, &dec_data.d2[0], m_TRperiod*12000, m_config.my_callsign(),
m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid)));
if (m_mode=="WSPR") {
QString c2name_string {m_fnameWE + ".c2"};
@ -1519,7 +1522,7 @@ void MainWindow::startP1()
p1.start(m_cmndP1);
}
QString MainWindow::save_wave_file (QString const& name, short const * data, int seconds,
QString MainWindow::save_wave_file (QString const& name, short const * data, int samples,
QString const& my_callsign, QString const& my_grid, QString const& mode, qint32 sub_mode,
Frequency frequency, QString const& his_call, QString const& his_grid) const
{
@ -1555,7 +1558,7 @@ QString MainWindow::save_wave_file (QString const& name, short const * data, int
BWFFile wav {format, file_name, list_info};
if (!wav.open (BWFFile::WriteOnly)
|| 0 > wav.write (reinterpret_cast<char const *> (data)
, sizeof (short) * seconds * format.sampleRate ()))
, sizeof (short) * samples))
{
return file_name + ": " + wav.errorString ();
}
@ -1670,7 +1673,7 @@ 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, m_config.my_callsign(),
this, m_fnameWE, &dec_data.d2[0], m_TRperiod*12000, m_config.my_callsign(),
m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid)));
}
if(m_mode!="MSK144") {
@ -2005,7 +2008,7 @@ void MainWindow::keyPressEvent (QKeyEvent * e)
return;
case Qt::Key_X:
if(e->modifiers() & Qt::AltModifier) {
foxTest();
// foxTest();
return;
}
case Qt::Key_E:
@ -4767,8 +4770,12 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie
return;
}
if(m_mode=="FT4" and ui->cbAutoSeq->isChecked()) {
if((m_ntx==4 or m_ntx==5) and !m_diskData) logQSOTimer.start(0); // Log the QSO
if((m_ntx==4 or m_ntx==5) and !m_diskData) {
save_FT4();
logQSOTimer.start(0); // Log the QSO
}
if((m_ntx==3 and ui->cbFirst->isChecked()) or m_ntx==4 or m_bDoubleClicked) {
QThread::msleep(600); //Wait a bit. ### Is this a good idea??? ###
ft4_tx(m_ntx);
}
}
@ -6865,8 +6872,8 @@ void MainWindow::transmit (double snr)
}
if (m_modeTx == "FT4") {
toneSpacing=12000.0/512.0;
// if(SpecOp::FOX==m_config.special_op_id() and !m_tune) toneSpacing=-1;
// toneSpacing=12000.0/512.0; //Generate Tx waveform from itone[] array
toneSpacing=-2.0; //Transmit a pre-computed, filtered waveform.
Q_EMIT sendMessage (NUM_FT4_SYMBOLS,
512.0, ui->TxFreqSpinBox->value() - m_XIT,
toneSpacing, m_soundOutput, m_config.audio_output_channel (),
@ -8367,7 +8374,7 @@ list2Done:
{
writeFoxQSO (QString {" Log: %1 %2 %3 %4 %5"}.arg (m_hisCall).arg (m_hisGrid)
.arg (m_rptSent).arg (m_rptRcvd).arg (m_lastBand));
logQSOTimer.start(0);
on_logQSOButton_clicked();
m_foxRateQueue.enqueue (now); //Add present time in seconds
//to Rate queue.
}
@ -8612,14 +8619,22 @@ void MainWindow::write_all(QString txRx, QString message)
void MainWindow::ft4Data(int k)
{
static int nhsec0=-1;
static bool wrapped=false;
short id[60000];
const int istep=3456;
if(k<60000 and !wrapped) return;
if(k<m_kin0) m_kin0=0;
int nhsec=k/istep;
if(nhsec0>nhsec) nhsec0=-1;
if(nhsec==nhsec0) return;
//Process FT4 data at 0.288 s intervals
int j=k/3456;
j=3456*j-60000;
// if(k<60000 and !wrapped) return;
if(k<52800 and !wrapped) return;
//Process FT4 data at intervals of istep/12000.0 seconds
int j=k/istep;
j=istep*j-52800;
if(j<0) j+=NRING;
float tbuf=j/12000.0;
for(int i=0; i<60000; i++) {
@ -8631,9 +8646,10 @@ void MainWindow::ft4Data(int k)
}
}
if(j>60000) wrapped=false;
if(((k-m_kin0)/12000.0 > 15.0) and !m_diskData) save_FT4();
if(k>=NRING) {
if(m_saveAll) save_FT4();
if(m_saveAll and !m_diskData) save_FT4();
//Wrap the ring buffer pointer
k=k-NRING;
dec_data.params.kin=k;
@ -8669,7 +8685,6 @@ void MainWindow::ft4Data(int k)
ft4_decode_(cdatetime,&tbuf,&nfa,&nfb,&nQSOProgress,&nContest,&nfqso,id,&ndecodes,&mycall[0],&hiscall[0],
&nrx,&line[0],&ddir[0],17,12,12,61,512);
line[60]=0;
// if(ndecodes>0) {
for (int idecode=1; idecode<=ndecodes; idecode++) {
get_ft4msg_(&idecode,&nrx,&line[0],61);
line[60]=0;
@ -8703,7 +8718,8 @@ void MainWindow::ft4Data(int k)
}
//###
}
if(m_diskData and (k > (dec_data.params.kin-3456))) m_startAnother=m_loopall;
nhsec0=nhsec;
if(m_diskData and (k > (dec_data.params.kin-istep))) m_startAnother=m_loopall;
if(m_bNoMoreFiles) {
MessageBox::information_message(this, tr("Just one more file to open."));
m_bNoMoreFiles=false;
@ -8739,17 +8755,24 @@ void MainWindow::ft4_tx(int ntx)
int n=t.size();
m_xSent=t.at(n-2) + " " + t.at(n-1);
}
auto_tx_mode(true); //Enable Tx
icw[0]=0;
g_iptt = 1;
setRig ();
setXIT (ui->TxFreqSpinBox->value ());
int nsym=103;
int nsps=4*512;
float fsample=48000.0;
float f0=ui->TxFreqSpinBox->value() - m_XIT;
int nwave=(nsym+2)*nsps;
gen_ft4wave_(const_cast<int *>(itone),&nsym,&nsps,&fsample,&f0,foxcom_.wave,&nwave);
Q_EMIT m_config.transceiver_ptt (true); //Assert the PTT
m_tx_when_ready = true;
qint64 ms=QDateTime::currentMSecsSinceEpoch();
m_modulator->set_ms0(ms);
FT4_TxTimer.start(5000); //Slightly more than FT4 transmission length
FT4_TxTimer.start(4600); //Slightly more than FT4 transmission length
if (g_iptt == 1 && m_iptt0 == 0) {
auto const& current_message = QString::fromLatin1 (msgsent);
@ -8775,7 +8798,7 @@ void MainWindow::ft4_tx(int ntx)
}
m_dateTimeQSOOn=QDateTime::currentDateTimeUtc();
if(!m_btxok && m_btxok0 && g_iptt==1) stopTx();
if(m_saveAll) save_FT4();
if(m_saveAll and !m_diskData) save_FT4();
}
void MainWindow::FT4_writeTx()
@ -8785,14 +8808,19 @@ void MainWindow::FT4_writeTx()
void MainWindow::save_FT4()
{
int nsec=(dec_data.params.kin + 3456)/12000;
if(nsec<5) return; //Saved data must be at least 5 seconds long.
double tsec=(dec_data.params.kin - m_kin0)/12000.0;
if(tsec<4.4) return; //Saved data must be at least 4.4 seconds long.
auto time = QDateTime::currentDateTimeUtc ();
QString t=time.toString("yyMMdd_hhmmss");
m_fnameWE=m_config.save_directory().absoluteFilePath(t);
// The following is potential a threading hazard - not a good
// idea to pass pointer to be processed in another thread
int nsamples=dec_data.params.kin - m_kin0 + 1;
m_saveWAVWatcher.setFuture (QtConcurrent::run (std::bind (&MainWindow::save_wave_file,
this, m_fnameWE, &dec_data.d2[0], nsec, m_config.my_callsign(),
m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid)));
this, m_fnameWE, &dec_data.d2[m_kin0], nsamples, m_config.my_callsign(),
m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall,
m_hisGrid)));
m_kin0=dec_data.params.kin;
}

View File

@ -466,6 +466,7 @@ private:
qint32 m_tFoxTxSinceCQ=999; //Fox Tx cycles since most recent CQ
qint32 m_nFoxFreq; //Audio freq at which Hound received a call from Fox
qint32 m_nSentFoxRrpt=0; //Serial number for next R+rpt Hound will send to Fox
qint32 m_kin0=0;
bool m_btxok; //True if OK to transmit
bool m_diskData;
@ -634,6 +635,15 @@ private:
QMap<QString,FoxQSO> m_foxQSO; //Key = HoundCall, value = parameters for QSO in progress
QMap<QString,QString> m_loggedByFox; //Key = HoundCall, value = logged band
struct FixupQSO //Info for fixing Fox's log from file "FoxQSO.txt"
{
QString grid; //Hound's declared locator
QString sent; //Report sent to Hound
QString rcvd; //Report received from Hound
QDateTime QSO_time;
};
QMap<QString,FixupQSO> m_fixupQSO; //Key = HoundCall, value = info for QSO in progress
QQueue<QString> m_houndQueue; //Selected Hounds available for starting a QSO
QQueue<QString> m_foxQSOinProgress; //QSOs in progress: Fox has sent a report
QQueue<qint64> m_foxRateQueue;
@ -716,7 +726,7 @@ private:
QString save_wave_file (QString const& name
, short const * data
, int seconds
, int samples
, QString const& my_callsign
, QString const& my_grid
, QString const& mode