Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -r4b7b6f9506d7c7ad4f611b8c417ed37d5f9a48ac -r340cae5888596d927601687476618d0ede343a35 --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 4b7b6f9506d7c7ad4f611b8c417ed37d5f9a48ac) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 340cae5888596d927601687476618d0ede343a35) @@ -20,8 +20,10 @@ // Project #include "StorageGlobals.h" #include "FileHandler.h" +#include "ApplicationController.h" #include "Logger.h" -#include "MSettings.h" +// #include "MSettings.h" +#include "Settings.h" #include "CloudSyncController.h" #include "GuiGlobals.h" @@ -50,6 +52,26 @@ \details All the class signal/slot connections are defined here. */ void TreatmentLog::initConnections() { + connect(&_ApplicationController , + QOverload< const SettingsData & >::of( &ApplicationController::didActionReceive ), + [ this ] ( const SettingsData & ) + { + readAlarmTitles(); + readEventTitles(); + }); + + connect(&_ApplicationController , + QOverload< const AdjustSerialNumberHDResponseData & >::of( &ApplicationController::didActionReceive ), + [ this ] ( const AdjustSerialNumberHDResponseData &vData ) + { + // The serial number is going to be recieved from HD + // on POST or on request + // and will be used for the device ID + // which we designed initially to be different. + _deviceID = vData.mSerialNumber; + }); + + connect(&_Logger , SIGNAL(didLogPathSet(Logger::LogType, const QString &)), this , SLOT( onLogPathSet(Logger::LogType, const QString &))); @@ -69,6 +91,85 @@ } /*! + * \brief TreatmentLog::readAlarmTitles + * \details Reads the ListTitle text from the Alarms.conf for the titles of the alarms going to be written in the TxReport. + */ +void TreatmentLog::readAlarmTitles() +{ + //NOTE: It currently is the duplicate of VAlarmActiveList titles, + // but intentionally kept it separated to be able to implement a different text/titles in case on cloud we would want something different. + QString category = Storage::Settings_Category_Alarms; + QStringList groups = _Settings.groups(category); + for (const auto &group : groups) { + bool ok = true; + quint32 id = group.toInt( &ok ); + if ( ! ok ) { LOG_DEBUG(QString("Invalid Tx Alarm ID [%1]").arg(group)); continue; } + + for (const QString &key : _Settings.keys(category, group)) { + if (Storage::Settings::isKeyListTitle ( key ) ) { + _treatmentLogAlarmTitles[id] = _Settings.value(category, group, key).toString(); + } + } + } +} + +/*! + * \brief TreatmentLog::readEventTitles + * \details Reads the Title text from the Events.conf for the titles of the events going to be written in the TxReport. + */ +void TreatmentLog::readEventTitles() +{ + QString category = Storage::Settings_Category_Events; + QStringList groups = _Settings.groups(category); + for (const auto &group : groups) { + bool ok = true; + quint32 id = group.toInt( &ok ); + if ( ! ok ) { LOG_DEBUG(QString("Undefined Tx Events ID [%1]").arg(group)); continue; } + + for (const QString &key : _Settings.keys(category, group)) { + if (Storage::Settings::isKeyTitle ( key ) ) { + _treatmentLogEventTitles[id] = _Settings.value(category, group, key).toString(); + } + } + } +} + +/*! + * \brief TreatmentLog::alarmTitle + * \details prepares the alarm title and returns. + * \param vID - the alarm ID + * \return the alarm title + */ +QString TreatmentLog::alarmTitle(quint32 vID) { + QString str = "%1-%2"; + QString title = "undefined"; + if ( _treatmentLogAlarmTitles.contains(vID) ) { + title = _treatmentLogAlarmTitles[vID] + .replace("," , "-") // the Txr is a csv file and any ',' in the title will break it. + .replace("\n" , "-"); // removing any new line since this will break the Txr as well. + } + return str.arg(vID, 3).arg(title); +} + +/*! + * \brief TreatmentLog::eventTitle + * \details prepares the event title and returns. + * \param vID - the event ID + * \return the event title + */ +QString TreatmentLog::eventTitle(quint32 vID) { + QString str = "%1 - %2"; + QString title = "undefined"; + if ( _treatmentLogEventTitles.contains(vID) ) { + title = _treatmentLogEventTitles[vID] + .replace("," , "-") // the Txr is a csv file and any ',' in the title will break it. + .replace("\n" , "-"); // removing any new line since this will break the Txr as well. + } + return str.arg(vID, 3).arg(title); +} + + +/*! * \brief TreatmentLog::timerEvent * \details The overloaded method of the main class to capture the QObject timer. */ @@ -112,8 +213,6 @@ _valuesLog.clear(); for (int i = 0; i < eTreatmentLogIndexCount; i++) _valuesLog << ""; - _deviceID = mStrText.arg(vData.mDeviceID ); - _valuesLog[ePatientID ] = vPatientID.trimmed() ; _valuesLog[eBloodFlowRate ] = mStrText.arg(vData.mBloodFlowRate ); _valuesLog[eDialysateFlowRate ] = mStrText.arg(vData.mDialysateFlowRate ); @@ -289,8 +388,8 @@ QString line; line += csv.arg(item.mTimeStamp ); // line += csv.arg(NONE ); // removed during our meeting with Sean and Jahnavi 04/11/2022@16:00. - line += csv.arg(item.mBloodFlowRate ); - line += csv.arg(item.mDialysateFlowRate ); + line += csv.arg(item.mBloodFlowRate ,FLOAT3 ); + line += csv.arg(item.mDialysateFlowRate ,FLOAT3 ); line += csv.arg(item.mUFRate ,FLOAT3 ); line += csv.arg(item.mArterialPressure ,FLOAT3 ); line += csv.arg(item.mVenousPressure ,FLOAT3 ); @@ -304,20 +403,20 @@ for ( const TreatmentLogAlarmData &item : _treatmentLogAlarmData ) { QString line; // TODO : QString alarmText = Model::MAlarmStatus::toText(static_cast(item.mAlarmID)); - line += csv.arg(item.mTimeStamp ); - line += csv.arg(item.mAlarmID ); // may need to change, during our discussion with Sean and I 04/11/2022. to alarmText - line += csv.arg(item.mParam1 ); // may need to remove, during our discussion with Sean and I 04/11/2022. - line += end.arg(item.mParam2 ); // may need to remove, during our discussion with Sean and I 04/11/2022. + line += csv.arg( item.mTimeStamp ); + line += csv.arg( alarmTitle(item.mAlarmID )); + line += csv.arg( item.mParam1 ); + line += end.arg( item.mParam2 ); ADDALINE(line); } ADDTITLE("Treatment Events" ); for ( const TreatmentLogEventData &item : _treatmentLogEventData ) { QString line; - line += csv.arg(item.mTimeStamp ); - line += csv.arg(item.mEventID ); - line += csv.arg(item.mOldValue ,FLOAT3 ); - line += end.arg(item.mNewValue ,FLOAT3 ); + line += csv.arg( item.mTimeStamp ); + line += csv.arg( eventTitle(item.mEventID )); + line += csv.arg( item.mOldValue ,FLOAT3 ); + line += end.arg( item.mNewValue ,FLOAT3 ); ADDALINE(line); } ADDALINE("");