Save contest exchange to ADIF log. (Not finished...)

This commit is contained in:
Joe Taylor 2018-10-02 15:52:25 -04:00 committed by Bill Somerville
parent efc6d56a27
commit a221de3c9d
6 changed files with 57 additions and 44 deletions

View File

@ -180,11 +180,12 @@ int ADIF::getCount() const
return _data.size();
}
QByteArray ADIF::QSOToADIF(QString const& hisCall, QString const& hisGrid, QString const& mode
, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn
, QDateTime const& dateTimeOff, QString const& band, QString const& comments
, QString const& name, QString const& strDialFreq, QString const& m_myCall
, QString const& m_myGrid, QString const& m_txPower, QString const& operator_call)
QByteArray ADIF::QSOToADIF(QString const& hisCall, QString const& hisGrid, QString const& mode,
QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn,
QDateTime const& dateTimeOff, QString const& band, QString const& comments,
QString const& name, QString const& strDialFreq, QString const& m_myCall,
QString const& m_myGrid, QString const& m_txPower, QString const& operator_call,
QString const& xSent, QString const& xRcvd)
{
QString t;
t = "<call:" + QString::number(hisCall.length()) + ">" + hisCall;
@ -198,26 +199,17 @@ QByteArray ADIF::QSOToADIF(QString const& hisCall, QString const& hisGrid, QStri
t += " <time_off:6>" + dateTimeOff.time().toString("hhmmss");
t += " <band:" + QString::number(band.length()) + ">" + band;
t += " <freq:" + QString::number(strDialFreq.length()) + ">" + strDialFreq;
t += " <station_callsign:" + QString::number(m_myCall.length()) + ">" +
m_myCall;
t += " <my_gridsquare:" + QString::number(m_myGrid.length()) + ">" +
m_myGrid;
if (m_txPower != "")
t += " <tx_pwr:" + QString::number(m_txPower.length()) +
">" + m_txPower;
if (comments != "")
t += " <comment:" + QString::number(comments.length()) +
">" + comments;
if (name != "")
t += " <name:" + QString::number(name.length()) +
">" + name;
if (operator_call!="")
t+=" <operator:" + QString::number(operator_call.length()) +
">" + operator_call;
return t.toLatin1 ();
t += " <station_callsign:" + QString::number(m_myCall.length()) + ">" + m_myCall;
t += " <my_gridsquare:" + QString::number(m_myGrid.length()) + ">" + m_myGrid;
if(m_txPower!="") t += " <tx_pwr:" + QString::number(m_txPower.length()) + ">" + m_txPower;
if(comments!="") t += " <comment:" + QString::number(comments.length()) + ">" + comments;
if(name!="") t += " <name:" + QString::number(name.length()) + ">" + name;
if(operator_call!="") t+=" <operator:" + QString::number(operator_call.length()) + ">" + operator_call;
if(xSent!="") t += " <STX_STRING:" + QString::number(xSent.length()) + ">" + xSent;
if(xRcvd!="") t += " <SRX_STRING:" + QString::number(xRcvd.length()) + ">" + xRcvd;
return t.toLatin1();
}
// open ADIF file and append the QSO details. Return true on success
bool ADIF::addQSOToFile(QByteArray const& ADIF_record)
{

View File

@ -33,11 +33,12 @@ class ADIF
// open ADIF file and append the QSO details. Return true on success
bool addQSOToFile(QByteArray const& ADIF_record);
QByteArray QSOToADIF(QString const& hisCall, QString const& hisGrid, QString const& mode, QString const& rptSent
, QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff
, QString const& band, QString const& comments, QString const& name
, QString const& strDialFreq, QString const& m_myCall, QString const& m_myGrid
, QString const& m_txPower, QString const& operator_call);
QByteArray QSOToADIF(QString const& hisCall, QString const& hisGrid, QString const& mode,
QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn,
QDateTime const& dateTimeOff, QString const& band, QString const& comments,
QString const& name, QString const& strDialFreq, QString const& m_myCall,
QString const& m_myGrid, QString const& m_txPower, QString const& operator_call,
QString const& xSent, QString const& xRcvd);
private:
struct QSO

View File

@ -60,9 +60,13 @@ void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString
QDateTime const& dateTimeOn, QDateTime const& dateTimeOff,
Radio::Frequency dialFreq, QString const& myCall, QString const& myGrid,
bool noSuffix, bool toRTTY, bool dBtoComments, bool bFox,
bool bAutoLog, QString const& opCall)
bool bAutoLog, QString const& opCall, qint32 nContest,
QString xSent, QString xRcvd)
{
if(!isHidden()) return;
m_nContest=nContest;
m_xSent=xSent;
m_xRcvd=xRcvd;
ui->call->setText(hisCall);
ui->grid->setText(hisGrid);
ui->name->setText("");
@ -120,8 +124,9 @@ void LogQSO::accept()
auto adifilePath = QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx_log.adi");
adifile.init(adifilePath);
QByteArray ADIF {adifile.QSOToADIF (hisCall, hisGrid, mode, rptSent, rptRcvd, m_dateTimeOn, m_dateTimeOff, band
, comments, name, strDialFreq, m_myCall, m_myGrid, m_txPower, operator_call)};
QByteArray ADIF {adifile.QSOToADIF (hisCall, hisGrid, mode, rptSent, rptRcvd,
m_dateTimeOn, m_dateTimeOff, band, comments, name, strDialFreq, m_myCall,
m_myGrid, m_txPower, operator_call, m_xSent, m_xRcvd)};
if (!adifile.addQSOToFile (ADIF))
{
MessageBox::warning_message (this, tr ("Log file error"),

View File

@ -34,7 +34,8 @@ public:
QDateTime const& dateTimeOff,
Radio::Frequency dialFreq, QString const& myCall, QString const& myGrid,
bool noSuffix, bool toRTTY, bool dBtoComments, bool bFox,
bool bAutoLog, QString const& opCall);
bool bAutoLog, QString const& opCall, qint32 nContest, QString xSent,
QString xRcvd);
public slots:
void accept();
@ -62,6 +63,9 @@ private:
Radio::Frequency m_dialFreq;
QString m_myCall;
QString m_myGrid;
QString m_xSent;
QString m_xRcvd;
qint32 m_nContest;
QDateTime m_dateTimeOn;
QDateTime m_dateTimeOff;
};

View File

@ -5167,23 +5167,35 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button
if (dateTimeQSOOff < m_dateTimeQSOOn) dateTimeQSOOff = m_dateTimeQSOOn;
QString grid=m_hisGrid;
if(grid=="....") grid="";
bool bAutoLog=m_config.autoLog() and m_nContest>0;
m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd,
m_dateTimeQSOOn, dateTimeQSOOff, m_freqNominal + ui->TxFreqSpinBox->value(),
m_config.my_callsign(), m_config.my_grid(), m_noSuffix,
m_config.log_as_RTTY(), m_config.report_in_comments(),
m_config.bFox(), bAutoLog, m_opCall);
if(m_nContest!=NONE) {
if(m_nContest>NONE and m_nContest<FOX) {
if(m_nContest==NA_VHF) {
m_xSent=m_config.my_grid().left(4);
m_xRcvd=m_hisGrid;
}
if(m_nContest!=NONE) {
int n=ui->sbSerialNumber->value();
ui->sbSerialNumber->setValue(n+1);
cabLog(); //Call the Cabrillo contest logger
if(m_nContest==EU_VHF) {
m_rptSent=m_xSent.split(" ").at(0).left(2);
m_rptRcvd=m_xRcvd.split(" ").at(0).left(2);
}
if(m_nContest==FIELD_DAY) {
m_rptSent=m_xSent.split(" ").at(0);
m_rptRcvd=m_xRcvd.split(" ").at(0);
}
if(m_nContest==RTTY) {
m_rptSent=m_xSent.split(" ").at(0);
m_rptRcvd=m_xRcvd.split(" ").at(0);
}
int n=ui->sbSerialNumber->value();
ui->sbSerialNumber->setValue(n+1);
cabLog(); //Call the Cabrillo contest logger
}
bool bAutoLog=m_config.autoLog() and m_nContest>0;
m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd,
m_dateTimeQSOOn, dateTimeQSOOff, m_freqNominal +
ui->TxFreqSpinBox->value(), m_config.my_callsign(),
m_config.my_grid(), m_noSuffix, m_config.log_as_RTTY(),
m_config.report_in_comments(), m_config.bFox(),
bAutoLog, m_opCall, m_nContest, m_xSent, m_xRcvd);
}
void MainWindow::cabLog()

View File

@ -156,5 +156,4 @@ void MessageAveraging::contestAddLog(qint32 nContest, QString logLine)
int score=m_mult_*m_nLogged_;
t.sprintf("Score: %d",score);
ui->lab3->setText(t);
qDebug() << m_nLogged_ << m_mult_ << score;
}