Index: sources/storage/Settings.h =================================================================== diff -u -r6e80ef971f83e73b2972b8ec38213f603eef31ff -r85c0a859a587d035997f3d163dcf4303afb86d05 --- sources/storage/Settings.h (.../Settings.h) (revision 6e80ef971f83e73b2972b8ec38213f603eef31ff) +++ sources/storage/Settings.h (.../Settings.h) (revision 85c0a859a587d035997f3d163dcf4303afb86d05) @@ -113,6 +113,7 @@ eInstructions , eConfigurationsDataList , // TODO: the category for this conf is not used. may need to be merged into the Settings, but since it is list, It needs a little more thought. eAlarms , + eEvents , eMessagesUnhandled , eSettingsSystem , eGenericConfirm , @@ -141,6 +142,7 @@ case eInstructions : return Storage::Settings_Category_Instructions ; case eConfigurationsDataList : return Storage::Settings_Category_ConfigurationsDataList ; case eAlarms : return Storage::Settings_Category_Alarms ; + case eEvents : return Storage::Settings_Category_Events ; case eMessagesUnhandled : return Storage::Settings_Category_MessagesUnhandled ; case eSettingsSystem : return Storage::Settings_Category_SettingsSystem ; case eGenericConfirm : return Storage::Settings_Category_GenericConfirm ; Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -ra7c580f0998ee781c47314384f677249cea4c4b4 -r85c0a859a587d035997f3d163dcf4303afb86d05 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision a7c580f0998ee781c47314384f677249cea4c4b4) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 85c0a859a587d035997f3d163dcf4303afb86d05) @@ -94,6 +94,7 @@ const char *Settings_Category_InstructionsImagesLoc = "%1/Instructions/"; const char *Settings_Category_ConfigurationsDataList = "Configurations/DataList" ; const char *Settings_Category_Alarms = "Alarms/Alarms" ; + const char *Settings_Category_Events = "Alarms/Events" ; const char *Settings_Category_MessagesUnhandled = "Messages/Unhandled" ; const char *Settings_Category_SettingsSystem = "Settings/System" ; const char *Settings_Category_NoCANBus = "Development/NoCANBus" ; Index: sources/storage/StorageGlobals.h =================================================================== diff -u -ra7c580f0998ee781c47314384f677249cea4c4b4 -r85c0a859a587d035997f3d163dcf4303afb86d05 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision a7c580f0998ee781c47314384f677249cea4c4b4) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 85c0a859a587d035997f3d163dcf4303afb86d05) @@ -60,6 +60,7 @@ extern const char *Settings_Category_InstructionsImagesLoc ; extern const char *Settings_Category_ConfigurationsDataList ; extern const char *Settings_Category_Alarms ; + extern const char *Settings_Category_Events ; extern const char *Settings_Category_MessagesUnhandled ; extern const char *Settings_Category_SettingsSystem ; extern const char *Settings_Category_NoCANBus ; Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -ra9a506f16293b28e582395f90a0cba2bcdc0b34c -r85c0a859a587d035997f3d163dcf4303afb86d05 --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision a9a506f16293b28e582395f90a0cba2bcdc0b34c) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 85c0a859a587d035997f3d163dcf4303afb86d05) @@ -23,6 +23,7 @@ #include "ApplicationController.h" #include "Logger.h" #include "MSettings.h" +#include "Settings.h" #include "CloudSyncController.h" #include "GuiGlobals.h" @@ -52,15 +53,25 @@ */ 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 ) { + [ 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 &))); @@ -80,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. */ @@ -313,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(""); Index: sources/storage/TreatmentLog.h =================================================================== diff -u -ra9a506f16293b28e582395f90a0cba2bcdc0b34c -r85c0a859a587d035997f3d163dcf4303afb86d05 --- sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision a9a506f16293b28e582395f90a0cba2bcdc0b34c) +++ sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 85c0a859a587d035997f3d163dcf4303afb86d05) @@ -83,7 +83,6 @@ } _lastTxInfo; - QString _deviceID = "unknown"; QString _txCode = ""; // content of this value comes from CloudSync App. QString _pendingTx = ""; @@ -216,6 +215,14 @@ QList _treatmentLogAlarmData; QList _treatmentLogEventData; + QMap _treatmentLogAlarmTitles; + QMap _treatmentLogEventTitles; + + void readAlarmTitles ( ); + void readEventTitles ( ); + QString alarmTitle (quint32 vID); + QString eventTitle (quint32 vID); + void initConnections(); void logPath (Logger::LogType vLogType, QString vLogPath); Index: sources/view/hd/alarm/VAlarmActiveList.cpp =================================================================== diff -u -r611bbf4dcba67768db87cf30f21fd2db788f677d -r85c0a859a587d035997f3d163dcf4303afb86d05 --- sources/view/hd/alarm/VAlarmActiveList.cpp (.../VAlarmActiveList.cpp) (revision 611bbf4dcba67768db87cf30f21fd2db788f677d) +++ sources/view/hd/alarm/VAlarmActiveList.cpp (.../VAlarmActiveList.cpp) (revision 85c0a859a587d035997f3d163dcf4303afb86d05) @@ -118,7 +118,7 @@ for (const auto &group : groups) { bool ok = true; quint32 id = group.toInt( &ok ); - if ( ! ok ) { LOG_DEBUG(QString("Not an alarm ID number [%1]").arg(group)); continue; } + if ( ! ok ) { LOG_DEBUG(QString("Invalid Alarm List ID [%1]").arg(group)); continue; } for (const QString &key : _Settings.keys(category, group)) { if (Storage::Settings::isKeyListTitle ( key ) ) { Index: sources/view/hd/alarm/VAlarmStatus.cpp =================================================================== diff -u -raf8d98b36b427e2b5f4d6659fcf3b58ee79eab6a -r85c0a859a587d035997f3d163dcf4303afb86d05 --- sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision af8d98b36b427e2b5f4d6659fcf3b58ee79eab6a) +++ sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision 85c0a859a587d035997f3d163dcf4303afb86d05) @@ -212,7 +212,7 @@ for (const auto &group : groups) { bool ok = true; quint32 id = group.toInt( &ok ); - if ( ! ok ) { LOG_DEBUG(QString("Not an alarm ID number [%1]").arg(group)); continue; } + if ( ! ok ) { LOG_DEBUG(QString("Invalid Alarm ID [%1]").arg(group)); continue; } AlarmData alarmData; InstructionData instructionData;