mirror of https://github.com/saitohirga/WSJT-X.git
Full activation of "Multiple Instances", thanks to some code by
Josh Rovero, KK1D. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3495 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
0110ab88dd
commit
fb7948a836
|
@ -2,6 +2,7 @@
|
||||||
#include <qsharedmemory.h>
|
#include <qsharedmemory.h>
|
||||||
#include <QSystemSemaphore>
|
#include <QSystemSemaphore>
|
||||||
|
|
||||||
|
// Multiple instances: KK1D, 17 Jul 2013
|
||||||
QSharedMemory mem_jt9("mem_jt9");
|
QSharedMemory mem_jt9("mem_jt9");
|
||||||
QSystemSemaphore sem_jt9("sem_jt9", 1, QSystemSemaphore::Open);
|
QSystemSemaphore sem_jt9("sem_jt9", 1, QSystemSemaphore::Open);
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,16 @@ program jt9
|
||||||
print*,'Usage: jt9 TRperiod ndepth rxfreq file1 [file2 ...]'
|
print*,'Usage: jt9 TRperiod ndepth rxfreq file1 [file2 ...]'
|
||||||
print*,' Reads data from *.wav files.'
|
print*,' Reads data from *.wav files.'
|
||||||
print*,''
|
print*,''
|
||||||
print*,' jt9 -s'
|
print*,' jt9 -s <key>'
|
||||||
print*,' Gets data from shared memory region.'
|
print*,' Gets data from shared memory region with key==<key>'
|
||||||
go to 999
|
go to 999
|
||||||
endif
|
endif
|
||||||
call getarg(1,arg)
|
call getarg(1,arg)
|
||||||
if(arg(1:2).eq.'-s') then
|
if(arg(1:2).eq.'-s') then
|
||||||
call jt9a
|
! Multiple instances:
|
||||||
|
call getarg(2,arg)
|
||||||
|
i0=len(trim(arg))
|
||||||
|
call jt9a(trim(arg))
|
||||||
go to 999
|
go to 999
|
||||||
endif
|
endif
|
||||||
read(arg,*) ntrperiod
|
read(arg,*) ntrperiod
|
||||||
|
|
18
lib/jt9a.f90
18
lib/jt9a.f90
|
@ -1,7 +1,8 @@
|
||||||
subroutine jt9a
|
subroutine jt9a(thekey)
|
||||||
|
|
||||||
|
character(len=*), intent(in):: thekey
|
||||||
|
|
||||||
! These routines connect the shared memory region to the decoder.
|
! These routines connect the shared memory region to the decoder.
|
||||||
|
|
||||||
interface
|
interface
|
||||||
function address_jt9()
|
function address_jt9()
|
||||||
integer*1, pointer :: address_jt9
|
integer*1, pointer :: address_jt9
|
||||||
|
@ -13,15 +14,26 @@ subroutine jt9a
|
||||||
integer size_jt9
|
integer size_jt9
|
||||||
integer*1, pointer :: p_jt9
|
integer*1, pointer :: p_jt9
|
||||||
character*80 cwd
|
character*80 cwd
|
||||||
|
! Multiple instances:
|
||||||
|
character*80 mykey
|
||||||
logical fileExists
|
logical fileExists
|
||||||
common/tracer/limtrace,lu
|
common/tracer/limtrace,lu
|
||||||
|
|
||||||
|
! Multiple instances:
|
||||||
|
i0 = len(trim(thekey))
|
||||||
|
|
||||||
call getcwd(cwd)
|
call getcwd(cwd)
|
||||||
open(12,file='timer.out',status='unknown')
|
open(12,file='timer.out',status='unknown')
|
||||||
|
|
||||||
limtrace=0
|
limtrace=0
|
||||||
! limtrace=-1 !Disable all calls to timer()
|
! limtrace=-1 !Disable all calls to timer()
|
||||||
lu=12
|
lu=12
|
||||||
|
|
||||||
|
! Multiple instances: set the shared memory key before attaching
|
||||||
|
mykey=trim(repeat(thekey,1))
|
||||||
|
i0 = len(mykey)
|
||||||
|
i0=setkey_jt9(trim(mykey))
|
||||||
|
|
||||||
i1=attach_jt9()
|
i1=attach_jt9()
|
||||||
|
|
||||||
10 inquire(file=trim(cwd)//'/.lock',exist=fileExists)
|
10 inquire(file=trim(cwd)//'/.lock',exist=fileExists)
|
||||||
|
@ -41,7 +53,7 @@ subroutine jt9a
|
||||||
nbytes=size_jt9()
|
nbytes=size_jt9()
|
||||||
if(nbytes.le.0) then
|
if(nbytes.le.0) then
|
||||||
print*,'jt9a: Shared memory mem_jt9 does not exist.'
|
print*,'jt9a: Shared memory mem_jt9 does not exist.'
|
||||||
print*,"Must start 'jt9 -s' from within WSJT-X."
|
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
|
||||||
go to 999
|
go to 999
|
||||||
endif
|
endif
|
||||||
p_jt9=>address_jt9()
|
p_jt9=>address_jt9()
|
||||||
|
|
13
main.cpp
13
main.cpp
|
@ -7,7 +7,10 @@
|
||||||
#include <portaudio.h>
|
#include <portaudio.h>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
QSharedMemory mem_jt9("mem_jt9");
|
// Multiple instances:
|
||||||
|
QSharedMemory mem_jt9;
|
||||||
|
QUuid my_uuid;
|
||||||
|
QString my_key;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -26,6 +29,11 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and initialize shared memory segment
|
// Create and initialize shared memory segment
|
||||||
|
// Multiple instances: generate shared memory keys with UUID
|
||||||
|
my_uuid = QUuid::createUuid();
|
||||||
|
my_key = my_uuid.toString();
|
||||||
|
mem_jt9.setKey(my_key);
|
||||||
|
|
||||||
if(!mem_jt9.attach()) {
|
if(!mem_jt9.attach()) {
|
||||||
if (!mem_jt9.create(sizeof(jt9com_))) {
|
if (!mem_jt9.create(sizeof(jt9com_))) {
|
||||||
QMessageBox::critical( 0, "Error", "Unable to create shared memory segment.");
|
QMessageBox::critical( 0, "Error", "Unable to create shared memory segment.");
|
||||||
|
@ -45,7 +53,8 @@ int main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow w(&mem_jt9);
|
// Multiple instances: Call MainWindow() with the UUID key
|
||||||
|
MainWindow w(&mem_jt9, &my_key);
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,8 @@ QString Program_Title_Version=" WSJT-X v1.1, r" + rev.mid(6,4) +
|
||||||
" by K1JT";
|
" by K1JT";
|
||||||
|
|
||||||
//-------------------------------------------------- MainWindow constructor
|
//-------------------------------------------------- MainWindow constructor
|
||||||
MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) :
|
// Multiple instances: new arg *thekey
|
||||||
|
MainWindow::MainWindow(QSharedMemory *shdmem, QString *thekey, QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
|
@ -200,6 +201,8 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) :
|
||||||
ui->labDist->setStyleSheet("border: 0px;");
|
ui->labDist->setStyleSheet("border: 0px;");
|
||||||
|
|
||||||
mem_jt9 = shdmem;
|
mem_jt9 = shdmem;
|
||||||
|
// Multiple instances:
|
||||||
|
mykey_jt9 = thekey;
|
||||||
readSettings(); //Restore user's setup params
|
readSettings(); //Restore user's setup params
|
||||||
if(m_dFreq.length()<=1) { //Use the startup default frequencies
|
if(m_dFreq.length()<=1) { //Use the startup default frequencies
|
||||||
m_dFreq.clear();
|
m_dFreq.clear();
|
||||||
|
@ -225,7 +228,12 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) :
|
||||||
lockFile.open(QIODevice::ReadWrite);
|
lockFile.open(QIODevice::ReadWrite);
|
||||||
//QFile quitFile(m_appDir + "/.lock");
|
//QFile quitFile(m_appDir + "/.lock");
|
||||||
//quitFile.remove();
|
//quitFile.remove();
|
||||||
proc_jt9.start(QDir::toNativeSeparators('"' + m_appDir + '"' + "/jt9 -s"));
|
|
||||||
|
// Multiple instances: make the Qstring key into command line arg
|
||||||
|
// Multiple instances: start "jt9 -s <thekey>"
|
||||||
|
QByteArray ba = mykey_jt9->toLocal8Bit();
|
||||||
|
const char *bc = ba.data();
|
||||||
|
proc_jt9.start(QDir::toNativeSeparators('"' + m_appDir + '"' + "/jt9 -s " + bc));
|
||||||
|
|
||||||
m_pbdecoding_style1="QPushButton{background-color: cyan; \
|
m_pbdecoding_style1="QPushButton{background-color: cyan; \
|
||||||
border-style: outset; border-width: 1px; border-radius: 5px; \
|
border-style: outset; border-width: 1px; border-radius: 5px; \
|
||||||
|
|
|
@ -27,8 +27,9 @@ class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// Multiple instances: call MainWindow() with *thekey
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QSharedMemory *shdmem, QWidget *parent = 0);
|
explicit MainWindow(QSharedMemory *shdmem, QString *thekey, QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -332,6 +333,8 @@ private:
|
||||||
SoundInThread soundInThread; //Instantiate the audio threads
|
SoundInThread soundInThread; //Instantiate the audio threads
|
||||||
SoundOutThread soundOutThread;
|
SoundOutThread soundOutThread;
|
||||||
QSharedMemory *mem_jt9;
|
QSharedMemory *mem_jt9;
|
||||||
|
// Multiple instances:
|
||||||
|
QString *mykey_jt9;
|
||||||
PSK_Reporter *psk_Reporter;
|
PSK_Reporter *psk_Reporter;
|
||||||
SignalMeter *signalMeter;
|
SignalMeter *signalMeter;
|
||||||
|
|
||||||
|
|
|
@ -2214,7 +2214,7 @@ p, li { white-space: pre-wrap; }
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuAdvanced">
|
<widget class="QMenu" name="menuAdvanced">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Advanced</string>
|
<string>Advanced</string>
|
||||||
|
|
Loading…
Reference in New Issue