Updated decode locking. Removed DecodeButton and OptimizingProgressDialog

This commit is contained in:
Jordan Sherer 2019-11-14 10:04:29 -05:00
parent f450683e6e
commit 145cb16fde
3 changed files with 31 additions and 68 deletions

View File

@ -432,9 +432,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
m_lastMonitoredFrequency {default_frequency}, m_lastMonitoredFrequency {default_frequency},
m_toneSpacing {0.}, m_toneSpacing {0.},
m_firstDecode {0}, m_firstDecode {0},
m_optimizingProgress {"Optimizing decoder FFTs for your CPU.\n"
"Please be patient,\n"
"this may take a few minutes", QString {}, 0, 1, this},
m_messageClient {new MessageClient {QApplication::applicationName (), m_messageClient {new MessageClient {QApplication::applicationName (),
version (), revision (), version (), revision (),
m_config.udp_server_name (), m_config.udp_server_port (), m_config.udp_server_name (), m_config.udp_server_port (),
@ -466,10 +463,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
m_baseCall = Radio::base_callsign (m_config.my_callsign ()); m_baseCall = Radio::base_callsign (m_config.my_callsign ());
m_opCall = m_config.opCall(); m_opCall = m_config.opCall();
m_optimizingProgress.setWindowModality (Qt::WindowModal);
m_optimizingProgress.setAutoReset (false);
m_optimizingProgress.setMinimumDuration (15000); // only show after 15s delay
// Closedown. // Closedown.
connect (ui->actionExit, &QAction::triggered, this, &QMainWindow::close); connect (ui->actionExit, &QAction::triggered, this, &QMainWindow::close);
@ -828,23 +821,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
} }
#endif #endif
{
//delete any .quit file that might have been left lying around
//since its presence will cause jt9 to exit a soon as we start it
//and decodes will hang
QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")};
while (quitFile.exists ())
{
if (!quitFile.remove ())
{
MessageBox::query_message (this, tr ("Error removing \"%1\"").arg (quitFile.fileName ())
, tr ("Click OK to retry"));
}
}
}
initDecoderSubprocess(); initDecoderSubprocess();
decodeBusy(true);
QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))}; QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))};
QByteArray cfname=fname.toLocal8Bit(); QByteArray cfname=fname.toLocal8Bit();
@ -1580,6 +1557,21 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
} }
void MainWindow::initDecoderSubprocess(){ void MainWindow::initDecoderSubprocess(){
{
//delete any .quit file that might have been left lying around
//since its presence will cause jt9 to exit a soon as we start it
//and decodes will hang
QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")};
while (quitFile.exists ())
{
if (!quitFile.remove ())
{
MessageBox::query_message (this, tr ("Error removing \"%1\"").arg (quitFile.fileName ())
, tr ("Click OK to retry"));
}
}
}
//Create .lock so jt9 will wait //Create .lock so jt9 will wait
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite); QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
@ -4025,9 +4017,13 @@ bool MainWindow::decode(){
if(JS8_DEBUG_DECODE) qDebug() << "decoder checking if ready..." << "k" << k << "k0" << kZero; if(JS8_DEBUG_DECODE) qDebug() << "decoder checking if ready..." << "k" << k << "k0" << kZero;
// TODO: check js8 process hasn't stalled? if(k == kZero){
if(JS8_DEBUG_DECODE) qDebug() << "--> decoder stream has not advanced";
return false;
}
if(isMessageQueuedForTransmit()){ if(m_transmitting || !m_txFrameQueue.isEmpty()){
// we used to use isMessageQueuedForTransmit, but it checks total frames, not queued frames
if(JS8_DEBUG_DECODE) qDebug() << "--> decoder paused during transmit"; if(JS8_DEBUG_DECODE) qDebug() << "--> decoder paused during transmit";
return false; return false;
} }
@ -4262,8 +4258,6 @@ bool MainWindow::decodeProcessQueue(qint32 *pSubmode){
dec_data.params.nfa=m_wideGraph->nStartFreq(); dec_data.params.nfa=m_wideGraph->nStartFreq();
dec_data.params.nfb=m_wideGraph->Fmax(); dec_data.params.nfb=m_wideGraph->Fmax();
ui->DecodeButton->setChecked(true);
if(dec_data.params.nagain==0 && dec_data.params.newdat==1 && (!m_diskData)) { if(dec_data.params.nagain==0 && dec_data.params.newdat==1 && (!m_diskData)) {
qint64 ms = DriftingDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = DriftingDateTime::currentMSecsSinceEpoch() % 86400000;
int imin=ms/60000; int imin=ms/60000;
@ -4372,11 +4366,18 @@ bool MainWindow::decodeProcessQueue(qint32 *pSubmode){
*/ */
void MainWindow::decodeStart(){ void MainWindow::decodeStart(){
if(m_decoderBusy){ if(m_decoderBusy){
if(JS8_DEBUG_DECODE) qDebug() << "--> decoder cannot start...busy"; if(JS8_DEBUG_DECODE) qDebug() << "--> decoder cannot start...busy (busy flag)";
return;
}
QFile lock {m_config.temp_dir ().absoluteFilePath (".lock")};
if(!lock.exists()){
if(JS8_DEBUG_DECODE) qDebug() << "--> decoder cannot start...busy (lock missing)";
return; return;
} }
// mark the decoder busy early while we prep the memory copy // mark the decoder busy early while we prep the memory copy
// decodeDone is responsible for marking the decode _not_ busy
decodeBusy(true); decodeBusy(true);
{ {
if(JS8_DEBUG_DECODE) qDebug() << "--> decoder starting"; if(JS8_DEBUG_DECODE) qDebug() << "--> decoder starting";
@ -4404,8 +4405,8 @@ void MainWindow::decodeStart(){
} }
memcpy(to, from, qMin(mem_js8->size(), size)); memcpy(to, from, qMin(mem_js8->size(), size));
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove (); // Allow decoder to start
} }
lock.remove(); // Allow decoder to start
} }
/** /**
@ -4415,13 +4416,11 @@ void MainWindow::decodeStart(){
*/ */
void MainWindow::decodeBusy(bool b) //decodeBusy() void MainWindow::decodeBusy(bool b) //decodeBusy()
{ {
if (!b) m_optimizingProgress.reset ();
m_decoderBusy=b; m_decoderBusy=b;
if(m_decoderBusy){ if(m_decoderBusy){
tx_status_label.setText("Decoding"); tx_status_label.setText("Decoding");
m_decoderBusyStartTime = DriftingDateTime::currentDateTimeUtc(); m_decoderBusyStartTime = DriftingDateTime::currentDateTimeUtc();
} }
ui->DecodeButton->setEnabled(!b);
ui->actionOpen->setEnabled(!b); ui->actionOpen->setEnabled(!b);
ui->actionOpen_next_in_directory->setEnabled(!b); ui->actionOpen_next_in_directory->setEnabled(!b);
ui->actionDecode_remaining_files_in_directory->setEnabled(!b); ui->actionDecode_remaining_files_in_directory->setEnabled(!b);
@ -4435,12 +4434,11 @@ void MainWindow::decodeBusy(bool b) //decodeBusy()
*/ */
void MainWindow::decodeDone () void MainWindow::decodeDone ()
{ {
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
dec_data.params.newdat=0; dec_data.params.newdat=0;
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;
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
ui->DecodeButton->setChecked (false);
decodeBusy(false); decodeBusy(false);
m_RxLog=0; m_RxLog=0;
m_blankLine=true; m_blankLine=true;

View File

@ -913,7 +913,6 @@ private:
Frequency m_lastMonitoredFrequency; Frequency m_lastMonitoredFrequency;
double m_toneSpacing; double m_toneSpacing;
int m_firstDecode; int m_firstDecode;
QProgressDialog m_optimizingProgress;
MessageClient * m_messageClient; MessageClient * m_messageClient;
TCPClient * m_n3fjpClient; TCPClient * m_n3fjpClient;
PSK_Reporter *psk_Reporter; PSK_Reporter *psk_Reporter;

View File

@ -4500,39 +4500,6 @@ list. The list can be maintained in Settings (F2).</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="DecodeButton">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Decode most recent Rx period at QSO Frequency&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton:checked {
background-color: cyan;
border-style: outset;
border-width: 1px;
border-radius: 5px;
border-color: black;
min-width: 5em;
padding: 3px;
}</string>
</property>
<property name="text">
<string>&amp;Decode</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="autoButton"> <widget class="QPushButton" name="autoButton">
<property name="minimumSize"> <property name="minimumSize">
@ -5846,7 +5813,6 @@ list. The list can be maintained in Settings (F2).</string>
<tabstop>stopButton</tabstop> <tabstop>stopButton</tabstop>
<tabstop>EraseButton</tabstop> <tabstop>EraseButton</tabstop>
<tabstop>ClrAvgButton</tabstop> <tabstop>ClrAvgButton</tabstop>
<tabstop>DecodeButton</tabstop>
<tabstop>dxCallEntry</tabstop> <tabstop>dxCallEntry</tabstop>
<tabstop>dxGridEntry</tabstop> <tabstop>dxGridEntry</tabstop>
<tabstop>lookupButton</tabstop> <tabstop>lookupButton</tabstop>