mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-09-02 13:17:49 -04:00
New IPC trial: use shmem instead of .start .stop .quit files.
This commit is contained in:
parent
523e9a1a07
commit
649a79dfc1
38
lib/jt9a.f90
38
lib/jt9a.f90
@ -20,7 +20,6 @@ subroutine jt9a()
|
|||||||
integer size_jt9
|
integer size_jt9
|
||||||
! Multiple instances:
|
! Multiple instances:
|
||||||
character*80 mykey
|
character*80 mykey
|
||||||
integer :: lun, stat
|
|
||||||
type(dec_data), pointer :: shared_data
|
type(dec_data), pointer :: shared_data
|
||||||
type(params_block) :: local_params
|
type(params_block) :: local_params
|
||||||
volatile shared_data
|
volatile shared_data
|
||||||
@ -38,23 +37,19 @@ subroutine jt9a()
|
|||||||
i0 = len(mykey)
|
i0 = len(mykey)
|
||||||
i0=setkey_jt9(trim(mykey))
|
i0=setkey_jt9(trim(mykey))
|
||||||
i1=attach_jt9()
|
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
|
! Wait here until GUI has set ss(2,1) to 1.0
|
||||||
10 open(newunit=lun,file=trim(temp_dir)//'/.start',iostat=stat,status='old')
|
10 if(shared_data%ss(2,1).eq.999.0) then
|
||||||
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')
|
|
||||||
i1=detach_jt9()
|
i1=detach_jt9()
|
||||||
go to 999
|
go to 999
|
||||||
endif
|
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()
|
nbytes=size_jt9()
|
||||||
if(nbytes.le.0) then
|
if(nbytes.le.0) then
|
||||||
@ -62,7 +57,6 @@ subroutine jt9a()
|
|||||||
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
|
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
|
||||||
go to 999
|
go to 999
|
||||||
endif
|
endif
|
||||||
call c_f_pointer(address_jt9(),shared_data)
|
|
||||||
local_params=shared_data%params !save a copy because wsjtx carries on accessing
|
local_params=shared_data%params !save a copy because wsjtx carries on accessing
|
||||||
call flush(6)
|
call flush(6)
|
||||||
call timer('decoder ',0)
|
call timer('decoder ',0)
|
||||||
@ -84,14 +78,14 @@ subroutine jt9a()
|
|||||||
call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000)
|
call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000)
|
||||||
call timer('decoder ',1)
|
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')
|
! Wait here until GUI routine decodeDone() has set ss(3,1) to 1.0
|
||||||
if(stat.eq.0) then
|
100 if(shared_data%ss(3,1).ne.1.0) then
|
||||||
close(unit=lun,status='delete')
|
call sleep_msec(msdelay)
|
||||||
go to 10
|
go to 100
|
||||||
endif
|
endif
|
||||||
call sleep_msec(msdelay)
|
shared_data%ss(3,1)=0.
|
||||||
go to 100
|
go to 10
|
||||||
|
|
||||||
999 call timer('decoder ',101)
|
999 call timer('decoder ',101)
|
||||||
|
|
||||||
|
@ -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 {
|
QStringList jt9_args {
|
||||||
"-s", QApplication::applicationName () // shared memory key,
|
"-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 destructor
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
@ -1470,7 +1412,7 @@ void MainWindow::dataSink(qint64 frames)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(m_mode=="FT8") {
|
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) {
|
if(m_ihsym==40 and m_decoderBusy) {
|
||||||
qDebug() << "ff Clearing hung decoder status";
|
qDebug() << "ff Clearing hung decoder status";
|
||||||
decodeDone(); //Clear a hung decoder status
|
decodeDone(); //Clear a hung decoder status
|
||||||
@ -2424,8 +2366,9 @@ void MainWindow::closeEvent(QCloseEvent * e)
|
|||||||
int nh=100;
|
int nh=100;
|
||||||
int irow=-99;
|
int irow=-99;
|
||||||
plotsave_(&sw,&nw,&nh,&irow);
|
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();
|
mem_jt9->detach();
|
||||||
stop_jt9 ();
|
|
||||||
Q_EMIT finished ();
|
Q_EMIT finished ();
|
||||||
QMainWindow::closeEvent (e);
|
QMainWindow::closeEvent (e);
|
||||||
}
|
}
|
||||||
@ -3069,10 +3012,6 @@ void MainWindow::decode() //decode()
|
|||||||
dec_data.params.mycall,dec_data.params.hiscall,8000,12,12)));
|
dec_data.params.mycall,dec_data.params.hiscall,8000,12,12)));
|
||||||
} else {
|
} else {
|
||||||
memcpy(to, from, qMin(mem_jt9->size(), size));
|
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();
|
auto now = QDateTime::currentDateTimeUtc();
|
||||||
double tsec = fmod(double(now.toMSecsSinceEpoch()),86400000.0)/1000.0;
|
double tsec = fmod(double(now.toMSecsSinceEpoch()),86400000.0)/1000.0;
|
||||||
@ -3082,6 +3021,7 @@ void MainWindow::decode() //decode()
|
|||||||
QString t="";
|
QString t="";
|
||||||
t.sprintf("aa release_jt9 %11.3f %5d %5d %7.3f ",tsec,m_ihsym,m_ihsym,tseq);
|
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");
|
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);
|
decodeBusy(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3129,16 +3069,14 @@ void::MainWindow::fast_decode_done()
|
|||||||
m_bFastDone=false;
|
m_bFastDone=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::to_jt9(qint32 n)
|
void MainWindow::to_jt9(qint32 n, qint32 istart, qint32 idone)
|
||||||
{
|
{
|
||||||
float ss0=n;
|
float ss0[3];
|
||||||
memcpy((char*)mem_jt9->data(),&ss0,4);
|
memcpy(ss0,(char*)mem_jt9->data(),12);
|
||||||
}
|
ss0[0]=n;
|
||||||
qint32 MainWindow::from_jt9()
|
if(istart>=0) ss0[1]=istart;
|
||||||
{
|
if(idone>=0) ss0[2]=idone;
|
||||||
float ss0;
|
memcpy((char*)mem_jt9->data(),ss0,12);
|
||||||
memcpy(&ss0,(char*)mem_jt9->data(),4);
|
|
||||||
return int(ss0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::decodeDone ()
|
void MainWindow::decodeDone ()
|
||||||
@ -3146,7 +3084,7 @@ void MainWindow::decodeDone ()
|
|||||||
dec_data.params.nagain=0;
|
dec_data.params.nagain=0;
|
||||||
dec_data.params.ndiskdat=0;
|
dec_data.params.ndiskdat=0;
|
||||||
m_nclearave=0;
|
m_nclearave=0;
|
||||||
pause_jt9 ();
|
// pause_jt9 ();
|
||||||
ui->DecodeButton->setChecked (false);
|
ui->DecodeButton->setChecked (false);
|
||||||
decodeBusy(false);
|
decodeBusy(false);
|
||||||
m_RxLog=0;
|
m_RxLog=0;
|
||||||
@ -3163,8 +3101,8 @@ void MainWindow::decodeDone ()
|
|||||||
if(tseq < 0.5*m_TRperiod) tseq+= m_TRperiod;
|
if(tseq < 0.5*m_TRperiod) tseq+= m_TRperiod;
|
||||||
QString t="";
|
QString t="";
|
||||||
t.sprintf("ee decodeDone %11.3f %5d %5d %7.3f ",tsec,m_ihsym,m_ihsym,tseq);
|
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");
|
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
|
void MainWindow::readFromStdout() //readFromStdout
|
||||||
@ -8177,8 +8115,8 @@ void MainWindow::on_cbMenus_toggled(bool b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_cbCQonly_toggled(bool)
|
void MainWindow::on_cbCQonly_toggled(bool)
|
||||||
{
|
{ //Fix this -- no decode here?
|
||||||
release_jt9 ();
|
to_jt9(m_ihsym,1,-1); //Send m_ihsym to jt9[.exe] and start decoding
|
||||||
decodeBusy(true);
|
decodeBusy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,11 +769,7 @@ private:
|
|||||||
void foxTxSequencer();
|
void foxTxSequencer();
|
||||||
void foxGenWaveform(int i,QString fm);
|
void foxGenWaveform(int i,QString fm);
|
||||||
void writeFoxQSO (QString const& msg);
|
void writeFoxQSO (QString const& msg);
|
||||||
void to_jt9(qint32 n);
|
void to_jt9(qint32 n, qint32 istart, qint32 idone);
|
||||||
qint32 from_jt9();
|
|
||||||
void pause_jt9 ();
|
|
||||||
void release_jt9 ();
|
|
||||||
void stop_jt9 ();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int killbyname(const char* progName);
|
extern int killbyname(const char* progName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user