Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -rb16dca16497e752a74bab670eb06bd25f4207659 -r20d74e4816626ec810d9401752de4903650c9830 --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision b16dca16497e752a74bab670eb06bd25f4207659) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 20d74e4816626ec810d9401752de4903650c9830) @@ -32,7 +32,7 @@ #define FLOAT3 0,'f',3 #define ADDTITLE(vTITLE) logContent += QString("[%1]\n").arg(vTITLE) #define ADDALINE(vTEXT ) logContent += QString("%1\n" ).arg(vTEXT ) -#define ADDTOLOG(vINDEX) index = vINDEX; logContent += title(index) + sep + value(index) + sep + unit(index) + "\n"; +#define ADDTOLOG(vINDEX) index = vINDEX; logContent += title(index) + _sep + value(index) + _sep + unit(index) + "\n"; /*! * \brief TreatmentLog::TreatmentLog @@ -335,14 +335,14 @@ QString logContent ; - QString sep = "," ; - QString csv = "%1" + sep ; + QString csv = "%1" + _sep ; QString end = "%1" ; uint index = 0 ; - QString txCode = "Tx Code,%1," ; + QString txCode = "%1,%2," ; ADDTITLE("Title"); - ADDALINE(txCode.arg(_gTxCode) ); + ADDALINE(txCode + .arg(_txCodeKey).arg(_gTxCode) ); ADDTOLOG( ePatientID ); ADDTITLE("Treatment Parameters" ); @@ -580,7 +580,7 @@ ok = _gTxCode == _rTxCode; if ( ! ok ) { - LOG_DEBUG(QString("Generated '%1' TxCode and Received TxCode '%1' does not match").arg(_gTxCode).arg(_rTxCode)); + LOG_DEBUG(QString("Generated '%1' TxCode and Received TxCode '%2' does not match").arg(_gTxCode).arg(_rTxCode)); return ok; } @@ -594,6 +594,28 @@ return ok; } +bool TreatmentLog::findTxCode() +{ + bool ok = false; + QString content = ""; + FileHandler::read(_pendingTxr, content); + QStringList lines = content.split('\n'); + for ( const QString &line : lines ) { + if ( line.contains(_txCodeKey) ) { + QStringList fields = line.split(','); + if ( fields.count() >= Role::eCount ) { + if ( fields[Role::eTitle] == _txCodeKey ) { + if ( fields[Role::eValue].length() ) { + _gTxCode = fields[Role::eValue]; + ok = true; + } + } + } + } + } + return ok; +} + /*! * \brief TreatmentLog::sendPending * \details Resets the pending counter to immediately/ASAP as for the pending and won't waits for the timeout. @@ -613,6 +635,7 @@ */ void TreatmentLog::testPendingTxReports() { + static QString pendingTxr = ""; if ( _pendingCounter ) { _pendingCounter -- ; return; @@ -631,6 +654,12 @@ if ( pendingFiles.count() ) { // the most recent/first Tx file, to first ask for the current treatment which has just saved as pending on screen _pendingTxr = pendingFiles.first().absoluteFilePath(); + if (pendingTxr != _pendingTxr ) { + pendingTxr = _pendingTxr; + findTxCode(); + } + QString message = pendingTxr + " , " + _pendingTxr + " , " + _gTxCode; + LOG_DEBUG(message); emit didTxPending( _pendingTxr ); } }