Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -rb16dca16497e752a74bab670eb06bd25f4207659 -r89174f563de1dbc04be63776766651e1c3f85192 --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision b16dca16497e752a74bab670eb06bd25f4207659) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 89174f563de1dbc04be63776766651e1c3f85192) @@ -339,10 +339,11 @@ 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 +581,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 +595,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 +636,7 @@ */ void TreatmentLog::testPendingTxReports() { + static QString pendingTxr = ""; if ( _pendingCounter ) { _pendingCounter -- ; return; @@ -631,6 +655,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 ); } }