Index: .gitignore =================================================================== diff -u -rf68b226e67eb500758ee94fe015df48931240013 -r6210028a421d6259963bf172efbe4f23abfecf2f --- .gitignore (.../.gitignore) (revision f68b226e67eb500758ee94fe015df48931240013) +++ .gitignore (.../.gitignore) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -5,3 +5,5 @@ resources/settings denali.pro.* denali.pro.user.* + +*.sh~ Index: imake.sh =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- imake.sh (.../imake.sh) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ imake.sh (.../imake.sh) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ########################################################################### # # Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. @@ -15,6 +15,15 @@ # ############################################################################ -./alarmMapping.sh -./cppcheck.sh +if [[ "$1" == "0" ]]; then + echo " ********** skipped the alarmMapping call **********" +else + ./alarmMapping.sh +fi +if [[ "$2" == "0" ]]; then + echo " ********** skipped the cppcheck call **********" +else + ./cppcheck.sh +fi + Index: sources/gui/qml/pages/posttreatment/PostTreatmentStack.qml =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- sources/gui/qml/pages/posttreatment/PostTreatmentStack.qml (.../PostTreatmentStack.qml) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/gui/qml/pages/posttreatment/PostTreatmentStack.qml (.../PostTreatmentStack.qml) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -37,7 +37,7 @@ onPatientDisconnectionConfirm : { vPostTreatmentAdjustmentPatientDisconnectionConfirm .doConfirm( ) /* No wait for Rsp, so navigates => */ page( _treatmentReviewConfirm ) - /* After navigate ask for Tx data */ vPostTreatmentAdjustmentTreatmentLog .doRequest( )} + /* After navigation ask for Tx data */ vPostTreatmentAdjustmentTreatmentLog .doRequest( )} onTreatmentReviewConfirm : page( _disposablesRemovalConfirm ) onDisposablesRemovalConfirm : vPostTreatmentAdjustmentDisposablesRemovalConfirm .doConfirm( ) onDisposablesRemovalBack : page( _treatmentReviewConfirm ) Index: sources/storage/FileHandler.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/storage/FileHandler.cpp (.../FileHandler.cpp) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -90,7 +90,7 @@ * \param vContent - The content of the file which will be set when done. * \return false if file cannot be opened. */ -bool FileHandler::read(const QString &vFileName, QString &vContent) +bool FileHandler::read(const QString &vFileName, QString &vContent, bool vAppend) { QFile file(vFileName); if (! file.open(QFile::Text | QFile::ReadOnly)) { @@ -100,7 +100,12 @@ return false; } QTextStream in(&file); - vContent = in.readAll(); + if ( vAppend ) { + vContent += in.readAll(); + } + else { + vContent = in.readAll(); + } return true; } Index: sources/storage/FileHandler.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- sources/storage/FileHandler.h (.../FileHandler.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/storage/FileHandler.h (.../FileHandler.h) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -58,8 +58,8 @@ }; public: - static bool write (const QString &vFileName, const QString &vContent, bool vAppend = true); - static bool read (const QString &vFileName, QString &vContent); + static bool write (const QString &vFileName, const QString &vContent, bool vAppend = true ); + static bool read (const QString &vFileName, QString &vContent, bool vAppend = false); static bool read (const QString &vFileName, QJsonObject &vContent, QJsonParseError *error = nullptr); static int copyFolder (const QString &vSource , const QString &vDestination); Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -112,6 +112,7 @@ const char *Log_Folder_Application = "log/" ; // Event/Data Log const char *Log_Folder_Service = "service/" ; // Service Log const char *Log_Folder_Treatment = "treatment/" ; // Treatment Log + const char *Log_Folder_Pending = "treatment/pending/" ; // Treatment Log Pending, have not been saved on cloud yet. // FIXME : Not sure having global settings object is a good idea. Index: sources/storage/StorageGlobals.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -71,6 +71,7 @@ extern const char *Log_Folder_Application; // Event/Data Log extern const char *Log_Folder_Service; // Service Log extern const char *Log_Folder_Treatment; // Treatment Log + extern const char *Log_Folder_Pending; // Treatment Log Pending, have not been saved on cloud yet. // Date and Time extern const char *Date_Time_Set_Sh; Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -34,6 +34,7 @@ #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"; + /*! * \brief TreatmentLog::TreatmentLog * The constructor to initial the Treatment Log @@ -173,7 +174,12 @@ else { _treatmentLogPath = vLogPath; } - LOG_DEBUG(QString("Treatment log folder has been set to %1").arg(_treatmentLogPath)); + _treatmentLogPath_Pending = QString("%1%2") + .arg(Storage::SDCard_Base_Path_Name) + .arg(Storage::Log_Folder_Pending ); + + LOG_DEBUG(QString("Treatment log folder has been set to %1" ).arg(_treatmentLogPath )); + LOG_DEBUG(QString("Treatment log pending folder has been set to %1" ).arg(_treatmentLogPath_Pending )); } } @@ -218,7 +224,7 @@ QString end = "%1" ; uint index = 0 ; - ADDTITLE("Title"); + // ADDTITLE("Title"); // will be added with Tx Code when gets out of pending, by receiving the Tx Code from CloudSync ADDTOLOG( ePatientID ); ADDTITLE("Treatment Parameters" ); @@ -304,12 +310,12 @@ _lastTxInfo.mDeviceID = _deviceID; _lastTxInfo.mPatientID = _values[ePatientID]; _lastTxInfo.mFileName = QString("%1%2_%3.log") - .arg(_treatmentLogPath) + .arg(_treatmentLogPath_Pending) .arg(_lastTxInfo.mDateTime) .arg(_lastTxInfo.mDeviceID); - ok = Storage::FileHandler::makeFolder(_treatmentLogPath); - if ( ! ok ) { LOG_DEBUG(QString("Cannot create folder %1").arg(_treatmentLogPath)); return ok; } + ok = Storage::FileHandler::makeFolder(_treatmentLogPath_Pending); + if ( ! ok ) { LOG_DEBUG(QString("Cannot create folder %1").arg(_treatmentLogPath_Pending)); return ok; } ok = Storage::FileHandler::write(_lastTxInfo.mFileName, logContent, false); if ( ! ok ) { LOG_DEBUG(QString("Cannot write to file %1").arg(_lastTxInfo.mFileName)); return ok; } _treatmentLogAvrgeData.clear(); @@ -409,5 +415,40 @@ void TreatmentLog::onTxCodeReceive(const QString &vTxCode) { _txCode = vTxCode; + addTxCode(); emit didTxCodeReceive(_txCode); } + +/*! + * \brief TreatmentLog::addTxCode + * \details Adds the [Title] and Tx Code to the file and moves it from pending. + * \return true on success, false on any case of read, write, remove. + */ +bool TreatmentLog::addTxCode() +{ + bool ok = true; + QString src = _lastTxInfo.mFileName; + QString dst = _treatmentLogPath + QFileInfo(src).fileName(); + QString logContent; + ADDTITLE("Title"); + ADDALINE(QString("Tx Code,%1,").arg(_txCode)); + + ok = FileHandler::read (src, logContent, true ); // reads the file and appends the content to logContent + if ( ! ok ) { + LOG_DEBUG(QString("Couldn't read pending treatment log file '%1'").arg(src)); + return ok; + } + + ok = FileHandler::write (dst, logContent ); + if ( ! ok ) { + LOG_DEBUG(QString("Couldn't settle pending treatment log file '%1'").arg(src)); + return ok; + } + + QFile::remove(src); + if ( ! ok ) { + LOG_DEBUG(QString("Couldn't remove pending treatment log file '%1'").arg(src)); + return ok; + } + return ok; +} Index: sources/storage/TreatmentLog.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r6210028a421d6259963bf172efbe4f23abfecf2f --- sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 6210028a421d6259963bf172efbe4f23abfecf2f) @@ -41,6 +41,7 @@ Q_OBJECT QString _treatmentLogPath; + QString _treatmentLogPath_Pending; QFutureWatcher _saveWatcher; QFutureWatcher _exportWatcher; @@ -213,6 +214,7 @@ void saveLogConcurrent (); bool exportLog (); void exportLogConcurrent(); + bool addTxCode(); NOTIFIER(isIdle) SINGLETON(TreatmentLog)