mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 04:11:16 -05:00
New IPC trial: use shmem instead of .start .stop .quit files.
This commit is contained in:
parent
523e9a1a07
commit
649a79dfc1
40
lib/jt9a.f90
40
lib/jt9a.f90
@ -20,7 +20,6 @@ subroutine jt9a()
|
||||
integer size_jt9
|
||||
! Multiple instances:
|
||||
character*80 mykey
|
||||
integer :: lun, stat
|
||||
type(dec_data), pointer :: shared_data
|
||||
type(params_block) :: local_params
|
||||
volatile shared_data
|
||||
@ -38,23 +37,19 @@ subroutine jt9a()
|
||||
i0 = len(mykey)
|
||||
i0=setkey_jt9(trim(mykey))
|
||||
i1=attach_jt9()
|
||||
msdelay=100
|
||||
msdelay=30
|
||||
call c_f_pointer(address_jt9(),shared_data)
|
||||
|
||||
! Wait here until the .start file is created by GUI
|
||||
10 open(newunit=lun,file=trim(temp_dir)//'/.start',iostat=stat,status='old')
|
||||
if(stat.ne.0) then
|
||||
call sleep_msec(msdelay)
|
||||
go to 10
|
||||
endif
|
||||
close(unit=lun,status='delete')
|
||||
|
||||
open(newunit=lun,file=trim(temp_dir)//'/.quit',iostat=stat,status='old')
|
||||
if(stat.eq.0) then
|
||||
close(unit=lun,status='delete')
|
||||
! Wait here until GUI has set ss(2,1) to 1.0
|
||||
10 if(shared_data%ss(2,1).eq.999.0) then
|
||||
i1=detach_jt9()
|
||||
go to 999
|
||||
endif
|
||||
if(i1.eq.999999) stop !Silence compiler warning
|
||||
if(shared_data%ss(2,1).ne.1.0) then
|
||||
call sleep_msec(msdelay)
|
||||
go to 10
|
||||
endif
|
||||
shared_data%ss(2,1)=0.0
|
||||
|
||||
nbytes=size_jt9()
|
||||
if(nbytes.le.0) then
|
||||
@ -62,7 +57,6 @@ subroutine jt9a()
|
||||
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
|
||||
go to 999
|
||||
endif
|
||||
call c_f_pointer(address_jt9(),shared_data)
|
||||
local_params=shared_data%params !save a copy because wsjtx carries on accessing
|
||||
call flush(6)
|
||||
call timer('decoder ',0)
|
||||
@ -84,15 +78,15 @@ subroutine jt9a()
|
||||
call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000)
|
||||
call timer('decoder ',1)
|
||||
|
||||
! Wait here until GUI routine decodeDone() has re-created the .start file
|
||||
100 open(newunit=lun,file=trim(temp_dir)//'/.stop',iostat=stat,status='old')
|
||||
if(stat.eq.0) then
|
||||
close(unit=lun,status='delete')
|
||||
go to 10
|
||||
endif
|
||||
call sleep_msec(msdelay)
|
||||
go to 100
|
||||
|
||||
! Wait here until GUI routine decodeDone() has set ss(3,1) to 1.0
|
||||
100 if(shared_data%ss(3,1).ne.1.0) then
|
||||
call sleep_msec(msdelay)
|
||||
go to 100
|
||||
endif
|
||||
shared_data%ss(3,1)=0.
|
||||
go to 10
|
||||
|
||||
999 call timer('decoder ',101)
|
||||
|
||||
return
|
||||
|
@ -845,7 +845,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
||||
}
|
||||
}
|
||||
|
||||
pause_jt9 ();
|
||||
// pause_jt9 ();
|
||||
to_jt9(0,0,0); //initialize
|
||||
|
||||
QStringList jt9_args {
|
||||
"-s", QApplication::applicationName () // shared memory key,
|
||||
@ -1039,65 +1040,6 @@ void MainWindow::on_the_minute ()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::pause_jt9 ()
|
||||
{
|
||||
// Create .stop so jt9 will wait
|
||||
QFile l {m_config.temp_dir ().absoluteFilePath (".stop")};
|
||||
if (!l.open(QFile::ReadWrite))
|
||||
{
|
||||
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::release_jt9 ()
|
||||
{
|
||||
// Create .start so jt9 will continue
|
||||
QFile l {m_config.temp_dir ().absoluteFilePath (".start")};
|
||||
if (!l.open(QFile::ReadWrite))
|
||||
{
|
||||
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::stop_jt9 ()
|
||||
{
|
||||
// Create .quit so jt9 will exit
|
||||
QFile q {m_config.temp_dir ().absoluteFilePath (".quit")};
|
||||
while (!q.exists ())
|
||||
{
|
||||
if (!q.open (QFile::ReadWrite))
|
||||
{
|
||||
if (MessageBox::Cancel == MessageBox::query_message (this
|
||||
, tr ("IPC Error")
|
||||
, tr ("Error creating \"%1\" - %2").arg (q.fileName ()).arg (q.errorString ())
|
||||
, QString {}
|
||||
, MessageBox::Retry | MessageBox::Cancel))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
release_jt9 ();
|
||||
if (!proc_jt9.waitForFinished(1000))
|
||||
{
|
||||
proc_jt9.close();
|
||||
}
|
||||
while (q.exists ())
|
||||
{
|
||||
if (!q.remove ())
|
||||
{
|
||||
if (MessageBox::Cancel == MessageBox::query_message (this
|
||||
, tr ("IPC Error")
|
||||
, tr ("Error removing \"%1\" - %2").arg (q.fileName ()).arg (q.errorString ())
|
||||
, QString {}
|
||||
, MessageBox::Retry | MessageBox::Cancel))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------- MainWindow destructor
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
@ -1470,7 +1412,7 @@ void MainWindow::dataSink(qint64 frames)
|
||||
}
|
||||
|
||||
if(m_mode=="FT8") {
|
||||
to_jt9(m_ihsym); //Allow jt9 to bail out early, if necessary
|
||||
to_jt9(m_ihsym,-1,-1); //Allow jt9 to bail out early, if necessary
|
||||
if(m_ihsym==40 and m_decoderBusy) {
|
||||
qDebug() << "ff Clearing hung decoder status";
|
||||
decodeDone(); //Clear a hung decoder status
|
||||
@ -2424,8 +2366,9 @@ void MainWindow::closeEvent(QCloseEvent * e)
|
||||
int nh=100;
|
||||
int irow=-99;
|
||||
plotsave_(&sw,&nw,&nh,&irow);
|
||||
to_jt9(m_ihsym,999,-1); //Tell jt9 to terminate
|
||||
if (!proc_jt9.waitForFinished(1000)) proc_jt9.close();
|
||||
mem_jt9->detach();
|
||||
stop_jt9 ();
|
||||
Q_EMIT finished ();
|
||||
QMainWindow::closeEvent (e);
|
||||
}
|
||||
@ -3069,10 +3012,6 @@ void MainWindow::decode() //decode()
|
||||
dec_data.params.mycall,dec_data.params.hiscall,8000,12,12)));
|
||||
} else {
|
||||
memcpy(to, from, qMin(mem_jt9->size(), size));
|
||||
if(m_mode=="FT8") {
|
||||
to_jt9(m_ihsym); //Send m_ihsym to jt9[.exe]
|
||||
}
|
||||
release_jt9 ();
|
||||
|
||||
auto now = QDateTime::currentDateTimeUtc();
|
||||
double tsec = fmod(double(now.toMSecsSinceEpoch()),86400000.0)/1000.0;
|
||||
@ -3082,6 +3021,7 @@ void MainWindow::decode() //decode()
|
||||
QString t="";
|
||||
t.sprintf("aa release_jt9 %11.3f %5d %5d %7.3f ",tsec,m_ihsym,m_ihsym,tseq);
|
||||
qDebug().noquote() << t << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.zzz");
|
||||
to_jt9(m_ihsym,1,-1); //Send m_ihsym to jt9[.exe] and start decoding
|
||||
decodeBusy(true);
|
||||
}
|
||||
}
|
||||
@ -3129,16 +3069,14 @@ void::MainWindow::fast_decode_done()
|
||||
m_bFastDone=false;
|
||||
}
|
||||
|
||||
void MainWindow::to_jt9(qint32 n)
|
||||
void MainWindow::to_jt9(qint32 n, qint32 istart, qint32 idone)
|
||||
{
|
||||
float ss0=n;
|
||||
memcpy((char*)mem_jt9->data(),&ss0,4);
|
||||
}
|
||||
qint32 MainWindow::from_jt9()
|
||||
{
|
||||
float ss0;
|
||||
memcpy(&ss0,(char*)mem_jt9->data(),4);
|
||||
return int(ss0);
|
||||
float ss0[3];
|
||||
memcpy(ss0,(char*)mem_jt9->data(),12);
|
||||
ss0[0]=n;
|
||||
if(istart>=0) ss0[1]=istart;
|
||||
if(idone>=0) ss0[2]=idone;
|
||||
memcpy((char*)mem_jt9->data(),ss0,12);
|
||||
}
|
||||
|
||||
void MainWindow::decodeDone ()
|
||||
@ -3146,7 +3084,7 @@ void MainWindow::decodeDone ()
|
||||
dec_data.params.nagain=0;
|
||||
dec_data.params.ndiskdat=0;
|
||||
m_nclearave=0;
|
||||
pause_jt9 ();
|
||||
// pause_jt9 ();
|
||||
ui->DecodeButton->setChecked (false);
|
||||
decodeBusy(false);
|
||||
m_RxLog=0;
|
||||
@ -3163,8 +3101,8 @@ void MainWindow::decodeDone ()
|
||||
if(tseq < 0.5*m_TRperiod) tseq+= m_TRperiod;
|
||||
QString t="";
|
||||
t.sprintf("ee decodeDone %11.3f %5d %5d %7.3f ",tsec,m_ihsym,m_ihsym,tseq);
|
||||
|
||||
qDebug().noquote() << t << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.zzz");
|
||||
to_jt9(m_ihsym,-1,1); //Tell jt9 we know it has finished
|
||||
}
|
||||
|
||||
void MainWindow::readFromStdout() //readFromStdout
|
||||
@ -8177,8 +8115,8 @@ void MainWindow::on_cbMenus_toggled(bool b)
|
||||
}
|
||||
|
||||
void MainWindow::on_cbCQonly_toggled(bool)
|
||||
{
|
||||
release_jt9 ();
|
||||
{ //Fix this -- no decode here?
|
||||
to_jt9(m_ihsym,1,-1); //Send m_ihsym to jt9[.exe] and start decoding
|
||||
decodeBusy(true);
|
||||
}
|
||||
|
||||
|
@ -769,11 +769,7 @@ private:
|
||||
void foxTxSequencer();
|
||||
void foxGenWaveform(int i,QString fm);
|
||||
void writeFoxQSO (QString const& msg);
|
||||
void to_jt9(qint32 n);
|
||||
qint32 from_jt9();
|
||||
void pause_jt9 ();
|
||||
void release_jt9 ();
|
||||
void stop_jt9 ();
|
||||
void to_jt9(qint32 n, qint32 istart, qint32 idone);
|
||||
};
|
||||
|
||||
extern int killbyname(const char* progName);
|
||||
|
Loading…
Reference in New Issue
Block a user