Merged in the extended free text experiment patch

This commit is contained in:
Jordan Sherer 2018-03-08 17:01:33 -05:00
parent 55261b6149
commit 4df7aae11a
7 changed files with 2745 additions and 2511 deletions

Binary file not shown.

View File

@ -23,7 +23,8 @@ namespace
"MSK144", "MSK144",
"QRA64", "QRA64",
"FreqCal", "FreqCal",
"FT8" "FT8",
"FT8Free"
}; };
std::size_t constexpr mode_names_size = sizeof (mode_names) / sizeof (mode_names[0]); std::size_t constexpr mode_names_size = sizeof (mode_names) / sizeof (mode_names[0]);
} }

View File

@ -50,6 +50,7 @@ public:
QRA64, QRA64,
FreqCal, FreqCal,
FT8, FT8,
FT8Free,
MODES_END_SENTINAL_AND_COUNT // this must be last MODES_END_SENTINAL_AND_COUNT // this must be last
}; };
Q_ENUM (Mode) Q_ENUM (Mode)

View File

@ -295,8 +295,12 @@ int main(int argc, char *argv[])
mem_jt9.setKey(a.applicationName ()); mem_jt9.setKey(a.applicationName ());
if(!mem_jt9.attach()) { if(!mem_jt9.attach()) {
std::cerr << QString("memory attach error: %1").arg(mem_jt9.error()).toLocal8Bit ().data () << std::endl;
if (!mem_jt9.create(sizeof(struct dec_data))) { if (!mem_jt9.create(sizeof(struct dec_data))) {
splash.hide (); splash.hide ();
std::cerr << QString("memory create error: %1").arg(mem_jt9.error()).toLocal8Bit ().data () << std::endl;
MessageBox::critical_message (nullptr, a.translate ("main", "Shared memory error"), MessageBox::critical_message (nullptr, a.translate ("main", "Shared memory error"),
a.translate ("main", "Unable to create shared memory segment")); a.translate ("main", "Unable to create shared memory segment"));
throw std::runtime_error {"Shared memory error"}; throw std::runtime_error {"Shared memory error"};

View File

@ -664,6 +664,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
ui->tx5->setValidator (new QRegExpValidator {message_alphabet, this}); ui->tx5->setValidator (new QRegExpValidator {message_alphabet, this});
ui->tx6->setValidator (new QRegExpValidator {message_alphabet, this}); ui->tx6->setValidator (new QRegExpValidator {message_alphabet, this});
ui->freeTextMsg->setValidator (new QRegExpValidator {message_alphabet, this}); ui->freeTextMsg->setValidator (new QRegExpValidator {message_alphabet, this});
ui->nextFreeTextMsg->setValidator (new QRegExpValidator {message_alphabet, this});
//ui->extFreeTextMsg->setValidator (new QRegExpValidator {message_alphabet, this});
// Free text macros model to widget hook up. // Free text macros model to widget hook up.
ui->tx5->setModel (m_config.macros ()); ui->tx5->setModel (m_config.macros ());
@ -673,6 +675,12 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
connect (ui->freeTextMsg->lineEdit () connect (ui->freeTextMsg->lineEdit ()
, &QLineEdit::editingFinished , &QLineEdit::editingFinished
, [this] () {on_freeTextMsg_currentTextChanged (ui->freeTextMsg->lineEdit ()->text ());}); , [this] () {on_freeTextMsg_currentTextChanged (ui->freeTextMsg->lineEdit ()->text ());});
connect (ui->nextFreeTextMsg
, &QLineEdit::editingFinished
, [this] () {on_nextFreeTextMsg_currentTextChanged (ui->nextFreeTextMsg->text ());});
connect (ui->extFreeTextMsg
, &QTextEdit::textChanged
, [this] () {on_extFreeTextMsg_currentTextChanged (ui->extFreeTextMsg->toPlainText ());});
connect(&m_guiTimer, &QTimer::timeout, this, &MainWindow::guiUpdate); connect(&m_guiTimer, &QTimer::timeout, this, &MainWindow::guiUpdate);
m_guiTimer.start(100); //### Don't change the 100 ms! ### m_guiTimer.start(100); //### Don't change the 100 ms! ###
@ -917,10 +925,12 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
} }
*/ */
/*
if(QCoreApplication::applicationVersion().contains("-devel") or if(QCoreApplication::applicationVersion().contains("-devel") or
QCoreApplication::applicationVersion().contains("-rc")) { QCoreApplication::applicationVersion().contains("-rc")) {
QTimer::singleShot (0, this, SLOT (not_GA_warning_message ())); QTimer::singleShot (0, this, SLOT (not_GA_warning_message ()));
} }
*/
if(!ui->cbMenus->isChecked()) { if(!ui->cbMenus->isChecked()) {
ui->cbMenus->setChecked(true); ui->cbMenus->setChecked(true);
@ -2959,6 +2969,8 @@ void MainWindow::readFromStdout() //readFromStdout
if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked(); if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked();
} }
m_QSOText = decodedtext.string ().trimmed (); m_QSOText = decodedtext.string ().trimmed ();
//ui->textEditRX->insertHtml(decodedtext.messageWords().first().trimmed() + " ");
} }
if(m_mode=="FT8" and m_config.bHound()) { if(m_mode=="FT8" and m_config.bHound()) {
@ -3363,6 +3375,7 @@ void MainWindow::guiUpdate()
if(m_ntx == 6) ba=ui->tx6->text().toLocal8Bit(); if(m_ntx == 6) ba=ui->tx6->text().toLocal8Bit();
if(m_ntx == 7) ba=ui->genMsg->text().toLocal8Bit(); if(m_ntx == 7) ba=ui->genMsg->text().toLocal8Bit();
if(m_ntx == 8) ba=ui->freeTextMsg->currentText().toLocal8Bit(); if(m_ntx == 8) ba=ui->freeTextMsg->currentText().toLocal8Bit();
if(m_ntx == 9) ba=ui->nextFreeTextMsg->text().toLocal8Bit();
} }
ba2msg(ba,message); ba2msg(ba,message);
@ -3720,6 +3733,27 @@ void MainWindow::stopTx()
tx_status_label.setStyleSheet(""); tx_status_label.setStyleSheet("");
tx_status_label.setText(""); tx_status_label.setText("");
} }
if(ui->tabWidget->currentIndex() == 3){
//1. check to see if there are more messages to send
//2. if there are, fixup next message and continue transmitting
//3. if not, allow the transmission to stop
// TODO: refactor this to "count remaining"
QString txt = ui->extFreeTextMsg->toPlainText();
int sz = countFreeTextMsgs(txt.trimmed().mid(m_extFreeTxtPos).trimmed());
if(sz > 0){
splitNextFreeTextMsg();
ui->txFirstCheckBox->setChecked(!m_txFirst);
} else {
if(ui->autoButton->isChecked()){
ui->autoButton->click();
}
ui->nextFreeTextMsg->clear();
ui->extFreeTextMsg->clear();
m_extFreeTxtPos = 0;
}
}
ptt0Timer.start(200); //end-of-transmission sequencer delay ptt0Timer.start(200); //end-of-transmission sequencer delay
monitor (true); monitor (true);
statusUpdate (); statusUpdate ();
@ -3944,6 +3978,35 @@ void MainWindow::on_txb6_clicked()
if (m_transmitting) m_restart=true; if (m_transmitting) m_restart=true;
} }
void MainWindow::on_pbNextFreeTextMsg_clicked()
{
m_ntx=9;
m_QSOProgress = CALLING;
set_dateTimeQSO(-1);
ui->rbNextFreeTextMsg->setChecked(true);
if (m_transmitting) m_restart=true;
splitNextFreeTextMsg();
// TODO: detect if we're currently in a possible transmit cycle...and if so, wait...
QDateTime now {QDateTime::currentDateTimeUtc()};
int s=now.time().second();
int n=s % (2*m_TRperiod);
if((n <= m_TRperiod && m_txFirst) || (n > m_TRperiod && !m_txFirst)){
ui->txFirstCheckBox->setChecked(!m_txFirst);
}
if(!ui->autoButton->isChecked()){
ui->autoButton->click();
}
}
void MainWindow::on_rbNextFreeTextMsg_toggled (bool status)
{
if (status) {
m_ntx = 9;
}
}
void MainWindow::doubleClickOnCall2(Qt::KeyboardModifiers modifiers) void MainWindow::doubleClickOnCall2(Qt::KeyboardModifiers modifiers)
{ {
set_dateTimeQSO(-1); // reset our QSO start time set_dateTimeQSO(-1); // reset our QSO start time
@ -4794,6 +4857,92 @@ void MainWindow::on_tx6_editingFinished() //tx6 edited
msgtype(t, ui->tx6); msgtype(t, ui->tx6);
} }
void MainWindow::on_nextFreeTextMsg_currentTextChanged (QString const& text)
{
msgtype(text, ui->nextFreeTextMsg);
}
void MainWindow::on_extFreeTextMsg_currentTextChanged (QString const& text)
{
QString x;
QString::const_iterator i;
for(i = text.constBegin(); i != text.constEnd(); i++){
if(message_alphabet.exactMatch(QString(*i))){
x += (*i).toUpper();
}
}
if(x != text){
int pos = ui->extFreeTextMsg->textCursor().position();
int maxpos = x.size();
ui->extFreeTextMsg->setPlainText(x);
QTextCursor c = ui->extFreeTextMsg->textCursor();
c.setPosition(pos < maxpos ? pos : maxpos, QTextCursor::MoveAnchor);
ui->extFreeTextMsg->setTextCursor(c);
}
int count = countFreeTextMsgs(x.trimmed().mid(m_extFreeTxtPos).trimmed());
ui->lblTxNum->setText(QString("Remaining Tx Sequences: %1").arg(count));
}
QString MainWindow::parseFT8Message(QString input){
char message[29];
char msgsent[29];
char volatile ft8msgbits[75];
int volatile itone[NUM_ISCAT_SYMBOLS];
QByteArray ba = input.toLocal8Bit();
ba2msg(ba,message);
qint32 i3bit = 0;
bool bcontest=ui->cbVHFcontest->isChecked();
char MyGrid[6];
strncpy(MyGrid, (m_config.my_grid()+" ").toLatin1(),6);
genft8_(message, MyGrid, &bcontest, &i3bit, msgsent, const_cast<char *> (ft8msgbits),
const_cast<int *> (itone), 22, 6, 22);
msgsent[22]=0;
return QString::fromLatin1(msgsent).trimmed();
}
int MainWindow::countFreeTextMsgs(QString input){
int count = 0;
while(input.size() > 0){
QString nextTxt = parseFT8Message(input);
QRegExp n = QRegExp("^" + QRegExp::escape(nextTxt));
int sz = input.size();
input = input.remove(n).trimmed();
count++;
if(input.size() == sz){
break;
}
}
return count;
}
void MainWindow::splitNextFreeTextMsg()
{
QString txt = ui->extFreeTextMsg->toPlainText().trimmed().mid(m_extFreeTxtPos).trimmed();
QString nextTxt = parseFT8Message(txt);
ui->nextFreeTextMsg->setText(nextTxt);
QRegExp n = QRegExp("^" + QRegExp::escape(nextTxt));
ui->extFreeTextMsg->setPlainText(txt.remove(n).trimmed());
/*
if(txt.contains(n)){
QTextCursor tc = ui->extFreeTextMsg->textCursor();
tc.setPosition(0);
m_extFreeTxtPos += n.matchedLength();
tc.setPosition(m_extFreeTxtPos, QTextCursor::KeepAnchor);
QTextCharFormat cf = tc.charFormat();
cf.setFontStrikeOut(true);
tc.mergeCharFormat(cf);
}
*/
}
void MainWindow::on_dxCallEntry_textChanged (QString const& call) void MainWindow::on_dxCallEntry_textChanged (QString const& call)
{ {
m_hisCall = call; m_hisCall = call;
@ -4940,6 +5089,7 @@ void MainWindow::displayWidgets(qint64 n)
if(i==32) ui->cbCQonly->setVisible(b); if(i==32) ui->cbCQonly->setVisible(b);
j=j>>1; j=j>>1;
} }
ui->tabWidget->setTabEnabled(2, "FT8" == m_mode);
m_lastCallsign.clear (); // ensures Tx5 is updated for new modes m_lastCallsign.clear (); // ensures Tx5 is updated for new modes
genStdMsgs (m_rpt, true); genStdMsgs (m_rpt, true);
} }

View File

@ -180,6 +180,8 @@ private slots:
void on_txb5_clicked(); void on_txb5_clicked();
void on_txb5_doubleClicked (); void on_txb5_doubleClicked ();
void on_txb6_clicked(); void on_txb6_clicked();
void on_pbNextFreeTextMsg_clicked();
void on_rbNextFreeTextMsg_toggled (bool status);
void on_lookupButton_clicked(); void on_lookupButton_clicked();
void on_addButton_clicked(); void on_addButton_clicked();
void on_dxCallEntry_textChanged (QString const&); void on_dxCallEntry_textChanged (QString const&);
@ -214,6 +216,11 @@ private slots:
void on_rbGenMsg_clicked(bool checked); void on_rbGenMsg_clicked(bool checked);
void on_rbFreeText_clicked(bool checked); void on_rbFreeText_clicked(bool checked);
void on_freeTextMsg_currentTextChanged (QString const&); void on_freeTextMsg_currentTextChanged (QString const&);
void on_nextFreeTextMsg_currentTextChanged (QString const&);
void on_extFreeTextMsg_currentTextChanged (QString const&);
QString parseFT8Message(QString input);
int countFreeTextMsgs(QString input);
void splitNextFreeTextMsg();
void on_rptSpinBox_valueChanged(int n); void on_rptSpinBox_valueChanged(int n);
void killFile(); void killFile();
void on_tuneButton_clicked (bool); void on_tuneButton_clicked (bool);
@ -498,6 +505,7 @@ private:
} }
m_QSOProgress; m_QSOProgress;
int m_extFreeTxtPos;
int m_ihsym; int m_ihsym;
int m_nzap; int m_nzap;
int m_npts8; int m_npts8;

View File

@ -1864,6 +1864,76 @@ list. The list can be maintained in Settings (F2).</string>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>4</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QRadioButton" name="rbNextFreeTextMsg">
<property name="text">
<string>Extended free msg</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nextFreeTextMsg">
<property name="maxLength">
<number>100</number>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>Next Tx Msg...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Message:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="extFreeTextMsg">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>Your message, if longer than 13 characters, will be split into separate free text transmissions. At the start of each tx cycle, the next chunk of the message will move from here to the textbox above for transmission.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblTxNum">
<property name="text">
<string>Remaining Tx Sequences: 0</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbNextFreeTextMsg">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -2448,28 +2518,28 @@ list. The list can be maintained in Settings (F2).</string>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QPushButton { <string notr="true">QPushButton {
font-family: helvetica; font-family: helvetica;
font-size: 9pt; font-size: 9pt;
font-weight: bold; font-weight: bold;
background-color: white; background-color: white;
color: black; color: black;
border-style: solid; border-style: solid;
border-width:1px; border-width:1px;
border-radius:10px; border-radius:10px;
border-color: gray; border-color: gray;
max-width:20px; max-width:20px;
max-height:20px; max-height:20px;
min-width:20px; min-width:20px;
min-height:20px; min-height:20px;
} }
QPushButton[state=&quot;error&quot;] { QPushButton[state=&quot;error&quot;] {
background-color: red; background-color: red;
} }
QPushButton[state=&quot;warning&quot;] { QPushButton[state=&quot;warning&quot;] {
background-color: orange; background-color: orange;
} }
QPushButton[state=&quot;ok&quot;] { QPushButton[state=&quot;ok&quot;] {
background-color: #00ff00; background-color: #00ff00;
}</string> }</string>
</property> </property>
<property name="text"> <property name="text">