Index: sources/cloudsync/CloudSyncController.cpp =================================================================== diff -u -r72a7f822f243d779f0d23e8060671dc59aacc748 -r51a16e937898f4aec639e9dc5ff33bd0d67bf4ab --- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 72a7f822f243d779f0d23e8060671dc59aacc748) +++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 51a16e937898f4aec639e9dc5ff33bd0d67bf4ab) @@ -24,6 +24,7 @@ #include "DeviceController.h" #include "FileHandler.h" #include "crc.h" +#include "TreatmentLog.h" /*! * \brief CloudSyncController::CloudSyncController @@ -90,6 +91,8 @@ this , SLOT( onWatchFileChange (const QString &))); connect(&_MessageDispatcher , SIGNAL(didActionReceive (GuiActionType,const QVariantList &)), this , SLOT( onActionReceive (GuiActionType,const QVariantList &))); + connect(&_TreatmentLog , SIGNAL(didTreatmentLogSave(const QString &, const QString &, const QString &)), + this , SLOT( onTreatmentLogSave(const QString &, const QString &, const QString &))); } /*! @@ -423,7 +426,23 @@ // store the last message data _lastReceivedData[eMessageID_DeviceState] = data; sendUIHistory (eMessageID_DeviceState); + break; + default: break; } } + +/*! + * \brief CloudSyncController::onTreatmentLogSave + * \details The slot being called when the TreatmentLogController notifies the CloudSyncController, about the treatment log being successfully saved. + * \param vPatientID - Patient ID + * \param vDeviceID - Device ID + * \param vFileName - The complete Treatment log path and file name. + */ +void CloudSyncController::onTreatmentLogSave(const QString &vPatientID, const QString &vDeviceID, const QString &vFileName) +{ + QStringList data { vPatientID, vDeviceID, vFileName }; + _lastReceivedData[eMessageID_TxReport] = data; + sendUIHistory (eMessageID_TxReport); +} Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -r72a7f822f243d779f0d23e8060671dc59aacc748 -r51a16e937898f4aec639e9dc5ff33bd0d67bf4ab --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 72a7f822f243d779f0d23e8060671dc59aacc748) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 51a16e937898f4aec639e9dc5ff33bd0d67bf4ab) @@ -132,6 +132,9 @@ void onWatchFileChange (const QString &vFile); void onActionReceive (GuiActionType vAction, const QVariantList &vData); + void onTreatmentLogSave (const QString &vPatientID , + const QString &vDeviceID , + const QString &vFileName ); private: void initConnections(); Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -rc4bd7072571428744e11dd24d5da1d1a3e1d1686 -r51a16e937898f4aec639e9dc5ff33bd0d67bf4ab --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision c4bd7072571428744e11dd24d5da1d1a3e1d1686) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 51a16e937898f4aec639e9dc5ff33bd0d67bf4ab) @@ -197,6 +197,7 @@ */ bool TreatmentLog::saveLog() { + _lastTxInfo.clear(); bool ok = (unsigned)_values.count() >= eTreatmentLogIndexCount; if (!ok) return false; @@ -288,23 +289,26 @@ } ADDALINE(""); - QString mDateTime = _values[eTreatmentStartDateTime]; - mDateTime.replace("/", "" ); // remove date separator - mDateTime.replace(":", "" ); // remove time separator - mDateTime.replace(" ", "_"); // replace spaces + _lastTxInfo.mDateTime = _values[eTreatmentStartDateTime]; + _lastTxInfo.mDateTime.replace("/", "" ); // remove date separator + _lastTxInfo.mDateTime.replace(":", "" ); // remove time separator + _lastTxInfo.mDateTime.replace(" ", "_"); // replace spaces - QString mDeviceID = _values[eDeviceID]; - QString mFileName = QString("%1_%2.log") - .arg(mDateTime) - .arg(mDeviceID); + _lastTxInfo.mDeviceID = _values[eDeviceID]; + _lastTxInfo.mPatientID = _values[ePatientID]; + _lastTxInfo.mFileName = QString("%1%2_%3.log") + .arg(_treatmentLogPath) + .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::write(mFileName.prepend(_treatmentLogPath), logContent, false); - if ( ! ok ) { LOG_DEBUG(QString("Cannot write to file %1").arg(mFileName )); 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(); _treatmentLogAlarmData.clear(); _treatmentLogEventData.clear(); + _lastTxInfo.mStatus = ok; return ok; } @@ -316,6 +320,10 @@ { LOG_DEBUG(QString("Save Treatment Log Ended: %1").arg(_saveWatcher.result())); isIdle(true); + if ( _lastTxInfo.mStatus ) + emit didTreatmentLogSave( _lastTxInfo.mDeviceID , + _lastTxInfo.mPatientID , + _lastTxInfo.mFileName ); } // ----- Export Index: sources/storage/TreatmentLog.h =================================================================== diff -u -r7b34653589ba6e4f4705fb4026fcd9319c41c352 -r51a16e937898f4aec639e9dc5ff33bd0d67bf4ab --- sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 7b34653589ba6e4f4705fb4026fcd9319c41c352) +++ sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 51a16e937898f4aec639e9dc5ff33bd0d67bf4ab) @@ -61,7 +61,23 @@ QString _unitTextDispencingRate = tr("mL/hr" ); QString _unitTextBloodPressure = tr("mmHg" ); + struct TxInfo { + void clear() { + mStatus = false; + mDateTime = ""; + mDeviceID = ""; + mPatientID = ""; + mFileName = ""; + } + bool mStatus = false; + QString mDateTime = ""; + QString mDeviceID = ""; + QString mPatientID = ""; + QString mFileName = ""; + } + _lastTxInfo; + enum Role { eValue, eTitle, @@ -232,7 +248,9 @@ void doExport (); signals: - + void didTreatmentLogSave( const QString &vPatientID , + const QString &vDeviceID , + const QString &vFileName ); }; }