Continuing to work on Rig Control.

Changed "Tx = QSO Freq" button to a band-change ComboBox.
Rig control of frequency setting and T/R now works on TS-2000.
T/R sequencing is not yet correct, but I thimnk it still works OK in the 
DTR/RTS switching mode.


git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3083 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2013-03-24 17:29:26 +00:00
parent 1e1e5f1856
commit a1e43d4a77
5 changed files with 209 additions and 47 deletions

View File

@ -16,7 +16,8 @@ wchar_t buffer[256];
bool btxok; //True if OK to transmit bool btxok; //True if OK to transmit
bool btxMute; bool btxMute;
double outputLatency; //Latency in seconds double outputLatency; //Latency in seconds
//float c0[2*1800*1500]; double dFreq[]={0.136,0.4742,1.838,3.578,5.2872,7.078,10.130,14.078,
18.1046,21.078,24.9246,28.078,50.293,70.091,144.489,0.0};
WideGraph* g_pWideGraph = NULL; WideGraph* g_pWideGraph = NULL;
QSharedMemory mem_jt9("mem_jt9"); QSharedMemory mem_jt9("mem_jt9");
@ -100,6 +101,12 @@ MainWindow::MainWindow(QWidget *parent) :
QTimer *guiTimer = new QTimer(this); QTimer *guiTimer = new QTimer(this);
connect(guiTimer, SIGNAL(timeout()), this, SLOT(guiUpdate())); connect(guiTimer, SIGNAL(timeout()), this, SLOT(guiUpdate()));
guiTimer->start(100); //Don't change the 100 ms! guiTimer->start(100); //Don't change the 100 ms!
ptt0Timer = new QTimer(this);
ptt0Timer->setSingleShot(true);
connect(ptt0Timer, SIGNAL(timeout()), this, SLOT(stopTx2()));
ptt1Timer = new QTimer(this);
ptt1Timer->setSingleShot(true);
connect(ptt1Timer, SIGNAL(timeout()), this, SLOT(startTx2()));
m_auto=false; m_auto=false;
m_waterfallAvg = 1; m_waterfallAvg = 1;
@ -901,7 +908,6 @@ void MainWindow::diskDat() //diskDat()
void MainWindow::diskWriteFinished() //diskWriteFinished void MainWindow::diskWriteFinished() //diskWriteFinished
{ {
// qDebug() << "diskWriteFinished";
} }
//Delete ../save/*.wav //Delete ../save/*.wav
@ -1202,7 +1208,7 @@ void MainWindow::decodeBusy(bool b) //decodeBusy()
void MainWindow::guiUpdate() void MainWindow::guiUpdate()
{ {
static int iptt0=0; static int iptt0=0;
static int iptt=0; // static int iptt=0;
static bool btxok0=false; static bool btxok0=false;
static int nc0=1; static int nc0=1;
static int nc1=1; static int nc1=1;
@ -1231,24 +1237,25 @@ void MainWindow::guiUpdate()
if(f.exists() and fmod(tsec,m_TRperiod)<1.0 + 85.0*m_nsps/12000.0) if(f.exists() and fmod(tsec,m_TRperiod)<1.0 + 85.0*m_nsps/12000.0)
bTxTime=true; bTxTime=true;
if(bTxTime and iptt==0 and !btxMute) { if(bTxTime and m_iptt==0 and !btxMute) {
/* #define NEW
#ifdef NEW
//Raise PTT //Raise PTT
if(m_pttMethodIndex==0) { if(m_pttMethodIndex==0) {
m_cmnd=rig_command() + " T 1"; m_cmnd=rig_command() + " T 1";
p3.start(m_cmnd); p3.start(m_cmnd);
p3.waitForFinished(); p3.waitForFinished();
m_iptt=1;
} }
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
ptt(m_pttPort,1,&m_iptt,&m_COMportOpen); ptt(m_pttPort,1,&m_iptt,&m_COMportOpen);
// ptt(m_pttPort,1,&m_iptt); // ptt(m_pttPort,1,&m_iptt);
} }
qDebug() << "ptt1Timer A"; // qDebug() << "ptt1Timer" << m_iptt;
ptt1Timer->start(200); //Sequencer delay ptt1Timer->start(200); //Sequencer delay
*/ #else
int itx=1; int itx=1;
ptt(m_pttPort,itx,&iptt,&m_COMportOpen); // Raise PTT ptt(m_pttPort,itx,&m_iptt,&m_COMportOpen); // Raise PTT
if(!soundOutThread.isRunning()) { if(!soundOutThread.isRunning()) {
QString t=ui->tx6->text(); QString t=ui->tx6->text();
double snr=t.mid(1,5).toDouble(); double snr=t.mid(1,5).toDouble();
@ -1256,7 +1263,7 @@ void MainWindow::guiUpdate()
soundOutThread.setTxSNR(snr); soundOutThread.setTxSNR(snr);
soundOutThread.start(QThread::HighPriority); soundOutThread.start(QThread::HighPriority);
} }
#endif
} }
if(!bTxTime || btxMute) { if(!bTxTime || btxMute) {
btxok=false; btxok=false;
@ -1264,7 +1271,7 @@ void MainWindow::guiUpdate()
} }
// Calculate Tx tones when needed // Calculate Tx tones when needed
if((iptt==1 && iptt0==0) || m_restart) { if((m_iptt==1 && iptt0==0) || m_restart) {
QByteArray ba; QByteArray ba;
if(m_ntx == 1) ba=ui->tx1->text().toLocal8Bit(); if(m_ntx == 1) ba=ui->tx1->text().toLocal8Bit();
if(m_ntx == 2) ba=ui->tx2->text().toLocal8Bit(); if(m_ntx == 2) ba=ui->tx2->text().toLocal8Bit();
@ -1314,7 +1321,7 @@ void MainWindow::guiUpdate()
} }
// If PTT was just raised, start a countdown for raising TxOK: // If PTT was just raised, start a countdown for raising TxOK:
if(iptt==1 && iptt0==0) nc1=-9; // TxDelay = 0.8 s if(m_iptt==1 && iptt0==0) nc1=-9; // TxDelay = 0.8 s
if(nc1 <= 0) nc1++; if(nc1 <= 0) nc1++;
if(nc1 == 0) { if(nc1 == 0) {
ui->xThermo->setValue(0.0); //Set Thermo to zero ui->xThermo->setValue(0.0); //Set Thermo to zero
@ -1331,14 +1338,18 @@ void MainWindow::guiUpdate()
f.close(); f.close();
} }
//###
if(!btxok && btxok0 && m_iptt==1) stopTx();
// If btxok was just lowered, start a countdown for lowering PTT // If btxok was just lowered, start a countdown for lowering PTT
if(!btxok && btxok0 && iptt==1) nc0=-11; //RxDelay = 1.0 s if(!btxok && btxok0 && m_iptt==1) nc0=-11; //RxDelay = 1.0 s
if(nc0 <= 0) { if(nc0 <= 0) {
nc0++; nc0++;
} }
if(nc0 == 0) { if(nc0 == 0) {
/* #ifdef NEW
//Lower PTT //Lower PTT
if(m_pttMethodIndex==0) { if(m_pttMethodIndex==0) {
m_cmnd=rig_command() + " T 0"; m_cmnd=rig_command() + " T 0";
@ -1347,12 +1358,10 @@ void MainWindow::guiUpdate()
} }
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
ptt(m_pttPort,0,&m_iptt,&m_COMportOpen); ptt(m_pttPort,0,&m_iptt,&m_COMportOpen);
// ptt(m_pttPort,0,&m_iptt);
} }
*/ #else
int itx=0; int itx=0;
ptt(m_pttPort,itx,&iptt,&m_COMportOpen); // Lower PTT ptt(m_pttPort,itx,&m_iptt,&m_COMportOpen); // Lower PTT
if(!btxMute) soundOutThread.quitExecution=true; if(!btxMute) soundOutThread.quitExecution=true;
m_transmitting=false; m_transmitting=false;
@ -1360,9 +1369,10 @@ void MainWindow::guiUpdate()
m_monitoring=true; m_monitoring=true;
soundInThread.setMonitoring(m_monitoring); soundInThread.setMonitoring(m_monitoring);
} }
#endif
} }
if(iptt == 0 && !btxok) { if(m_iptt == 0 && !btxok) {
// sending="" // sending=""
// nsendingsh=0 // nsendingsh=0
} }
@ -1412,7 +1422,7 @@ void MainWindow::guiUpdate()
m_sec0=nsec; m_sec0=nsec;
} }
iptt0=iptt; iptt0=m_iptt;
btxok0=btxok; btxok0=btxok;
} }
@ -1427,6 +1437,65 @@ QString MainWindow::rig_command()
return cmnd1+cmnd2; return cmnd1+cmnd2;
} }
void MainWindow::startTx2()
{
if(!soundOutThread.isRunning()) {
// qDebug() << "startTx2";
if(!soundOutThread.isRunning()) {
QString t=ui->tx6->text();
double snr=t.mid(1,5).toDouble();
if(snr>0.0 or snr < -50.0) snr=99.0;
soundOutThread.setTxSNR(snr);
soundOutThread.start(QThread::HighPriority);
}
ui->xThermo->setValue(0.0); //Set Thermo to zero
m_monitoring=false;
soundInThread.setMonitoring(false);
btxok=true;
m_transmitting=true;
// qDebug() << btxok << m_transmitting << m_monitoring;
/*
QFile f("ALL.TXT");
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
QTextStream out(&f);
out << QDateTime::currentDateTimeUtc().toString("hhmm")
<< " Transmitting: " << QString::fromAscii(msgsent) << endl;
f.close();
*/
m_transmitting=true;
}
}
void MainWindow::stopTx()
{
if (soundOutThread.isRunning()) {
soundOutThread.quitExecution=true;
soundOutThread.wait(3000);
}
m_transmitting=false;
m_iptt=0;
lab1->setStyleSheet("");
lab1->setText("");
ptt0Timer->start(200); //Sequencer delay
m_monitoring=true;
soundInThread.setMonitoring(true);
}
void MainWindow::stopTx2()
{
//Lower PTT
if(m_pttMethodIndex==0) {
m_cmnd=rig_command() + " T 0";
p3.start(m_cmnd);
p3.waitForFinished();
}
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
ptt(m_pttPort,0,&m_iptt,&m_COMportOpen);
}
}
void MainWindow::ba2msg(QByteArray ba, char message[]) //ba2msg() void MainWindow::ba2msg(QByteArray ba, char message[]) //ba2msg()
{ {
bool eom; bool eom;
@ -1934,13 +2003,6 @@ void MainWindow::on_TxFreqSpinBox_valueChanged(int n)
soundOutThread.setTxFreq(n); soundOutThread.setTxFreq(n);
} }
void MainWindow::on_pbTxFreq_clicked()
{
int ntx=g_pWideGraph->QSOfreq();
m_txFreq=ntx;
ui->TxFreqSpinBox->setValue(ntx);
}
void MainWindow::on_actionQuickDecode_triggered() void MainWindow::on_actionQuickDecode_triggered()
{ {
m_ndepth=1; m_ndepth=1;
@ -2071,3 +2133,19 @@ void MainWindow::on_actionLog_dB_reports_to_Comments_triggered(bool checked)
{ {
m_dBtoComments=checked; m_dBtoComments=checked;
} }
void MainWindow::on_bandComboBox_currentIndexChanged(int index)
{
m_band=index;
m_dialFreq=dFreq[index];
if(g_pWideGraph!=NULL) g_pWideGraph->setDialFreq(m_dialFreq);
if(m_catEnabled) {
int nHz=int(1000000.0*m_dialFreq + 0.5);
QString cmnd1,cmnd3;
cmnd1=rig_command();
cmnd3.sprintf(" F %d",nHz);
m_cmnd=cmnd1 + cmnd3;
p3.start(m_cmnd);
p3.waitForFinished();
}
}

View File

@ -101,7 +101,6 @@ private slots:
void on_NBcheckBox_toggled(bool checked); void on_NBcheckBox_toggled(bool checked);
void on_NBslider_valueChanged(int value); void on_NBslider_valueChanged(int value);
void on_TxFreqSpinBox_valueChanged(int arg1); void on_TxFreqSpinBox_valueChanged(int arg1);
void on_pbTxFreq_clicked();
void on_actionSave_synced_triggered(); void on_actionSave_synced_triggered();
void on_actionSave_decoded_triggered(); void on_actionSave_decoded_triggered();
void on_actionQuickDecode_triggered(); void on_actionQuickDecode_triggered();
@ -127,6 +126,11 @@ private slots:
void on_actionConvert_JT9_x_to_RTTY_triggered(bool checked); void on_actionConvert_JT9_x_to_RTTY_triggered(bool checked);
void on_actionLog_JT9_without_submode_triggered(bool checked); void on_actionLog_JT9_without_submode_triggered(bool checked);
void on_actionLog_dB_reports_to_Comments_triggered(bool checked); void on_actionLog_dB_reports_to_Comments_triggered(bool checked);
void startTx2();
void stopTx();
void stopTx2();
void on_bandComboBox_currentIndexChanged(int index);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
@ -174,6 +178,7 @@ private:
qint32 m_secID; qint32 m_secID;
qint32 m_COMportOpen; qint32 m_COMportOpen;
qint32 m_iptt; qint32 m_iptt;
qint32 m_band;
bool m_monitoring; bool m_monitoring;
bool m_transmitting; bool m_transmitting;
@ -228,6 +233,9 @@ private:
QProcess proc_jt9; QProcess proc_jt9;
QProcess p3; QProcess p3;
QTimer* ptt0Timer;
QTimer* ptt1Timer;
QString m_path; QString m_path;
QString m_pbdecoding_style1; QString m_pbdecoding_style1;
QString m_pbmonitor_style; QString m_pbmonitor_style;

View File

@ -878,25 +878,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="8">
<widget class="QPushButton" name="pbTxFreq">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Tx = QSO Freq</string>
</property>
</widget>
</item>
<item row="5" column="5" rowspan="2" colspan="2"> <item row="5" column="5" rowspan="2" colspan="2">
<widget class="QLabel" name="labUTC"> <widget class="QLabel" name="labUTC">
<property name="sizePolicy"> <property name="sizePolicy">
@ -1551,6 +1532,93 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="8">
<widget class="QComboBox" name="bandComboBox">
<property name="currentIndex">
<number>7</number>
</property>
<item>
<property name="text">
<string>2200 m</string>
</property>
</item>
<item>
<property name="text">
<string>630 m</string>
</property>
</item>
<item>
<property name="text">
<string>160 m</string>
</property>
</item>
<item>
<property name="text">
<string>80 m</string>
</property>
</item>
<item>
<property name="text">
<string>60 m</string>
</property>
</item>
<item>
<property name="text">
<string>40 m</string>
</property>
</item>
<item>
<property name="text">
<string>30 m</string>
</property>
</item>
<item>
<property name="text">
<string>20 m</string>
</property>
</item>
<item>
<property name="text">
<string>17 m</string>
</property>
</item>
<item>
<property name="text">
<string>15 m</string>
</property>
</item>
<item>
<property name="text">
<string>12 m</string>
</property>
</item>
<item>
<property name="text">
<string>10 m</string>
</property>
</item>
<item>
<property name="text">
<string>6 m</string>
</property>
</item>
<item>
<property name="text">
<string>4 m</string>
</property>
</item>
<item>
<property name="text">
<string>2 m</string>
</property>
</item>
<item>
<property name="text">
<string>Other</string>
</property>
</item>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -259,6 +259,13 @@ void WideGraph::setTxFreq(int n)
ui->widePlot->setTxFreq(n); ui->widePlot->setTxFreq(n);
} }
void WideGraph::setDialFreq(double f)
{
m_dialFreq=f;
ui->fDialLineEdit->setText(QString::number(m_dialFreq));
emit dialFreqChanged(m_dialFreq);
}
void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1) void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1)
{ {
ui->widePlot->m_bCurrent=false; ui->widePlot->m_bCurrent=false;

View File

@ -31,6 +31,7 @@ public:
void setTxFreq(int n); void setTxFreq(int n);
double fGreen(); double fGreen();
double dialFreq(); double dialFreq();
void setDialFreq(double freq);
qint32 m_qsoFreq; qint32 m_qsoFreq;