Index: denali.pro.user =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- denali.pro.user (.../denali.pro.user) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ denali.pro.user (.../denali.pro.user) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/canbus/caninterface.cpp =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -108,11 +108,12 @@ * \param vEnabled - Enalbe console output if true */ void CanInterface::enableConsoleOut(bool vEnabled) { + if (_enableConsoleOut == vEnabled) return; _enableConsoleOut = vEnabled; if (_enableConsoleOut) { - LOG_EVENT_ONCE("UI," + tr("Console out CanInterface enabled")); + LOG_EVENT("UI," + tr("Console out CanInterface enabled")); } else { - LOG_EVENT_ONCE("UI," + tr("Console out CanInterface disabled")); + LOG_EVENT("UI," + tr("Console out CanInterface disabled")); } } Index: sources/canbus/messagebuilder.cpp =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -290,11 +290,12 @@ * \param vEnabled */ void MessageBuilder::enableConsoleOut(bool vEnabled) { + if (_enableConsoleOut == vEnabled) return; _enableConsoleOut = vEnabled; if (_enableConsoleOut) { - LOG_EVENT_ONCE("UI," + tr("Console out MessageBuilder enabled")); + LOG_EVENT("UI," + tr("Console out MessageBuilder enabled")); } else { - LOG_EVENT_ONCE("UI," + tr("Console out MessageBuilder disabled")); + LOG_EVENT("UI," + tr("Console out MessageBuilder disabled")); } } Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,20 +15,25 @@ // Qt #include +// #include // Project #include "logger.h" #include "format.h" using namespace Can; -#define EMIT_RECEIVE_SIGNAL(vID, vMODEL) \ -{ \ +#define DEBUG_RECEIVE_SIGNAL(vID, vMODEL) // Debug() << #vID << #vMODEL; + +// This define helps to prevent having multiple overloaded function for each model +#define EMIT_RECEIVE_SIGNAL(vID, vMODEL) { \ vMODEL mModel; \ ok = prepareData(vMessage, vID, mModel, vData); \ - if (ok) emit didActionReceive(mModel.data()); \ -} \ -break; + if ( ! ok ) return false; \ + emit didActionReceive(mModel.data()); \ + LOG_BASIC(mModel.toString()); \ + DEBUG_RECEIVE_SIGNAL(vID, vMODEL) \ +} /*! * \brief MessageInterpreter::MessageInterpreter @@ -124,10 +129,7 @@ { bool ok = false; if ( ! isValidMessage(vMessage, vID) ) return ok; - ok = vModel.fromByteArray(vMessage.data); - LOG_DATUM(vModel.toString()); - vModel.toVariantList(vData); return ok; } @@ -288,13 +290,13 @@ case Gui::GuiActionType::ID_CANBusFaultCount : ok = canbusFaultCountData (vMessage, vData); break; // ----- Datum - case Gui::GuiActionType::ID_TreatmentTime : ok = treatmentTimeData (vMessage, vData); break; - case Gui::GuiActionType::ID_BloodFlow : ok = bloodFlowData (vMessage, vData); break; - case Gui::GuiActionType::ID_DialysateInletFlow : ok = dialysateInletFlowData (vMessage, vData); break; - case Gui::GuiActionType::ID_DialysateOutletFlow : ok = dialysateOutletFlowData (vMessage, vData); break; - case Gui::GuiActionType::ID_TreatmentRanges : ok = treatmentRangesData (vMessage, vData); break; - case Gui::GuiActionType::ID_PressureOcclusion : ok = pressureOcclusionData (vMessage, vData); break; - case Gui::GuiActionType::ID_TreatmentState : ok = treatmentStateData (vMessage, vData); break; + case Gui::GuiActionType::ID_TreatmentTime : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_TreatmentTime , Model::MTreatmentTime ); break; + case Gui::GuiActionType::ID_BloodFlow : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_BloodFlow , Model::MBloodFlow ); break; + case Gui::GuiActionType::ID_DialysateInletFlow : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DialysateInletFlow , Model::MDialysateFlow ); break; + case Gui::GuiActionType::ID_DialysateOutletFlow : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DialysateOutletFlow , Model::MOutletFlow ); break; + case Gui::GuiActionType::ID_TreatmentRanges : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_TreatmentRanges , Model::MTreatmentRanges ); break; + case Gui::GuiActionType::ID_PressureOcclusion : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_PressureOcclusion , Model::MPressureOcclusion ); break; + case Gui::GuiActionType::ID_TreatmentState : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_TreatmentState , Model::MTreatmentStates ); break; // ----- Events case Gui::GuiActionType::ID_Acknow : ok = true; break; @@ -305,8 +307,8 @@ case Gui::GuiActionType::ID_AlarmCleared : ok = alarmCleared (vMessage, vData); break; // Adjustment Response Messages - case Gui::GuiActionType::ID_AdjustDurationRsp : ok = adjustDuration (vMessage, vData); break; - case Gui::GuiActionType::ID_AdjustBloodDialysateRsp : ok = adjustBloodDialysate (vMessage, vData); break; + case Gui::GuiActionType::ID_AdjustDurationRsp : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_AdjustDurationRsp , Model::MAdjustDurationResponse ); break; + case Gui::GuiActionType::ID_AdjustBloodDialysateRsp : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_AdjustBloodDialysateRsp , Model::MAdjustBloodDialysateResponse ); break; case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq : ok = adjustUltrafiltrationState (vMessage, vData); break; case Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp : ok = adjustUltrafiltrationEdit (vMessage, vData); break; case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp: ok = adjustUltrafiltrationConfirm (vMessage, vData); break; @@ -344,15 +346,15 @@ LOG_EVENT(mSenderID + QString("DG,CheckIn," + QVariant(vData).toStringList().join(','))); break; - case Gui::GuiActionType::ID_DGROPumpData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGROPumpData , Model::MDGROPump ) - case Gui::GuiActionType::ID_DGPressuresData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGPressuresData , Model::MDGPressures ) - case Gui::GuiActionType::ID_DGDrainPumpData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGDrainPumpData , Model::MDGDrainPump ) - case Gui::GuiActionType::ID_DGOperationModeData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGOperationModeData , Model::MDGOperationMode ) - case Gui::GuiActionType::ID_DGReservoirData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGReservoirData , Model::MDGReservoir ) - case Gui::GuiActionType::ID_DGValvesStatesData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGValvesStatesData , Model::MDGValvesStates ) - case Gui::GuiActionType::ID_DGHeatersData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGHeatersData , Model::MDGHeaters ) - case Gui::GuiActionType::ID_DGLoadCellReadingsData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGLoadCellReadingsData , Model::MDGLoadCellReadings ) - case Gui::GuiActionType::ID_DGTemperaturesData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGTemperaturesData , Model::MDGTemperatures ) + case Gui::GuiActionType::ID_DGROPumpData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGROPumpData , Model::MDGROPump ); break; + case Gui::GuiActionType::ID_DGPressuresData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGPressuresData , Model::MDGPressures ); break; + case Gui::GuiActionType::ID_DGDrainPumpData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGDrainPumpData , Model::MDGDrainPump ); break; + case Gui::GuiActionType::ID_DGOperationModeData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGOperationModeData , Model::MDGOperationMode ); break; + case Gui::GuiActionType::ID_DGReservoirData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGReservoirData , Model::MDGReservoir ); break; + case Gui::GuiActionType::ID_DGValvesStatesData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGValvesStatesData , Model::MDGValvesStates ); break; + case Gui::GuiActionType::ID_DGHeatersData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGHeatersData , Model::MDGHeaters ); break; + case Gui::GuiActionType::ID_DGLoadCellReadingsData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGLoadCellReadingsData , Model::MDGLoadCellReadings ); break; + case Gui::GuiActionType::ID_DGTemperaturesData : EMIT_RECEIVE_SIGNAL(Gui::GuiActionType::ID_DGTemperaturesData , Model::MDGTemperatures ); break; // unhandles messages: these will only be logged as received message // there has nothing been defined for these messages. @@ -395,187 +397,6 @@ return ok; } -// ---------- ---------- ---------- ---------- ---------- Data ---------- ---------- ---------- ---------- ---------- // -// ---------- ---------- ---------- ---------- ---------- - HD ---------- ---------- ---------- ---------- ---------- // - -/*! - * \brief MessageInterpreter::treatmentTimeData - * \details This method interprets Treatment Time message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Treatment Time data - * \return true if the data can be extracted as defined for Treatment Time Message ID - */ -bool MessageInterpreter::treatmentTimeData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_TreatmentTime) ) return ok; - - Model::MTreatmentTime mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::bloodFlowData - * \details This method interprets Blood Flow message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Blood Flow data - * \return true if the data can be extracted as defined for Blood Flow Message ID - */ -bool MessageInterpreter::bloodFlowData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_BloodFlow)) return ok; - - Model::MBloodFlow mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::dialysateInletFlowData - * \details This method interprets Dialysate Inlet Flow message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Dialysate Inlet Flow data - * \return true if the data can be extracted as defined for Dialysate Inlet Flow Message ID - */ -bool MessageInterpreter::dialysateInletFlowData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_DialysateInletFlow) ) return ok; - - Model::MDialysateFlow mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::dialysateOutletFlowData - * \details This method interprets Dialysate Outlet Flow message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Dialysate Outlet Flow data - * \return true if the data can be extracted as defined for Dialysate Outlet Flow Message ID - */ -bool MessageInterpreter::dialysateOutletFlowData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_DialysateOutletFlow) ) return ok; - - Model::MOutletFlow mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::treatmentRangesData - * \details This method interprets Treatment Ranges message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Treatment Ranges data - * \return true if the data can be extracted as defined for Treatment Ranges Message ID - */ -bool MessageInterpreter::treatmentRangesData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_TreatmentRanges) ) return ok; - - Model::MTreatmentRanges mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::pressureOcclusionData - * \details This method interprets Pressure/Occlusion message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Pressure/Occlusion data - * \return true if the data can be extracted as defined for Pressure/Occlusion Message ID - */ -bool MessageInterpreter::pressureOcclusionData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_PressureOcclusion) ) return ok; - - Model::MPressureOcclusion mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::treatmentStateData - * \details This method interprets Treatment State message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Treatment State data - * \return true if the data can be extracted as defined for Treatment State Message ID - */ -bool MessageInterpreter::treatmentStateData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_TreatmentState) ) return ok; - - Model::MTreatmentState mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -// ---------- ---------- ---------- ---------- ---------- - DG ---------- ---------- ---------- ---------- ---------- // - - // ---------- ---------- ---------- ---------- ---------- Events ---------- ---------- ---------- ---------- ---------- // // ---------- ---------- ---------- ---------- ---------- - HD ---------- ---------- ---------- ---------- ---------- // @@ -689,55 +510,6 @@ // ---------- ---------- ---------- ---------- ---------- Adjustments ---------- ---------- ---------- ---------- ---------- // /*! - * \brief MessageInterpreter::adjustDurationData - * \details This method interprets Treatment Duration Adjustment Response message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Treatment Duration Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Duration Adjustment Response Message ID - */ -bool MessageInterpreter::adjustDuration(const Message &vMessage, QVariantList &vData) -{ - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustDurationRsp) ) return ok; - - Model::MAdjustDurationResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_EVENT("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::adjustBloodDialysateData - * \details This method interprets AdjustBlood Dialysate Response message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - AdjustBlood Dialysate Response data - * \return true if the data can be extracted as defined for AdjustBlood Dialysate Response Message ID - */ -bool MessageInterpreter::adjustBloodDialysate(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustBloodDialysateRsp) ) return ok; - - Model::MAdjustBloodDialysateResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_EVENT("HD," + mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! * \brief MessageInterpreter::ultrafiltrationState * \details This method interprets Treatment Ultrafiltration State Adjustment Response message data * in vMessage of type Message. @@ -751,7 +523,7 @@ bool ok = false; // TODO : In HD the Ultrafiltration State change shall have the rejection reason like other responses. if ( ! isType (vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::ID_AcknowGeneric ) ) return ok; + if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::ID_AcknowGeneric ) ) return ok; // This is an exception It has to be changed. Model::MAdjustUltrafiltrationStateResponse mData; ok = mData.fromByteArray(vMessage.data); Index: sources/canbus/messageinterpreter.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -41,40 +41,29 @@ friend class ::tst_messaging; friend class ::tst_logging; - bool isType(const Message &vMessage, Gui::GuiActionType vType) const; - bool isPayloadLenValid(const Message &vMessage, Gui::GuiActionType vType) const; - bool isValidMessage(const Message &vMessage, Gui::GuiActionType vType) const; - void printUnhandled(const Message &vMessage ) const; + bool isType (const Message &vMessage, Gui::GuiActionType vType) const; + bool isPayloadLenValid (const Message &vMessage, Gui::GuiActionType vType) const; + bool isValidMessage (const Message &vMessage, Gui::GuiActionType vType) const; - bool interpretMessage_HD(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool interpretMessage_DG(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + void printUnhandled (const Message &vMessage ) const; + bool prepareData (const Message &vMessage, Gui::GuiActionType vID, Model::MAbstract &vModel, QVariantList &vData); + bool interpretMessage_HD (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool interpretMessage_DG (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + // ----- Debug - bool canbusFaultCountData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool canbusFaultCountData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - // ----- Data - // ----- - HD - bool treatmentTimeData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool bloodFlowData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool dialysateInletFlowData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool dialysateOutletFlowData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool treatmentRangesData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool pressureOcclusionData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool treatmentStateData(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - // ----- Events // ----- - HD - bool powerOff(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool alarmStatus(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool alarmTriggered(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool alarmCleared(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool powerOff (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool alarmStatus (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool alarmTriggered (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + bool alarmCleared (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; // ----- - DG - bool prepareData (const Message &vMessage, Gui::GuiActionType vID, Model::MAbstract &vModel, QVariantList &vData); // ----- Adjustments - bool adjustDuration (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - bool adjustBloodDialysate (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool adjustUltrafiltrationState (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool adjustUltrafiltrationEdit (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool adjustUltrafiltrationConfirm (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; @@ -89,7 +78,6 @@ signals: ACTION_RECEIVE_SIGNALS -public slots: }; } Index: sources/gui/qml/pages/SettingsHome.qml =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -95,7 +95,7 @@ Connections { target: _GuiView onDidActionReceive: { - if (vAction === GuiActions.CanBUSFaultCount ) { + if (vAction === GuiActions.ID_CANBusFaultCount ) { _canbusFaultCountText.count = vData[0] } } Index: sources/model/MAbstract.cpp =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/MAbstract.cpp (.../MAbstract.cpp) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ sources/model/MAbstract.cpp (.../MAbstract.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -11,34 +11,45 @@ * \author Behrouz NematiPour * */ + #include "MAbstract.h" +#include + using namespace Model; /*! - * \brief MAbstract::toVariantList - * \param vData + * \brief MAbstract::toVariantList + * \details Currnet values of the model data will be listed in a QVariantList vData. + * It has been mostly been used for debugging with the Generic onAcitonRecived which has the QVariantList as the signal parameter. + * \param vData - The output data of the QVariantList */ void MAbstract::toVariantList(QVariantList &vData) const { vData = parameters(); } /*! - * \brief MAbstract::toString - * \return + * \brief MAbstract::toString + * \details String Representation of the model data. + * \return String */ QString MAbstract::toString() const { QVariantList mParameters = parameters(); QString mString = description(); for( const auto ¶meter : mParameters ) { - mString += _delimiter + parameter.toString(); + if (parameter.type() == uint(QMetaType::Float)) // Qt has a mixed definition of QVariant::Type and QMetaType seems like a not fixed issue. + mString += _delimiter + QString("%1").arg(parameter.toFloat(),0,'f',_precision); + else + mString += _delimiter + parameter.toString(); + } return mString; } /*! - * \brief MAbstract::description - * \return + * \brief MAbstract::description + * \details The description of the model. mostly used in logging. + * \return String */ QString MAbstract::description() const { return _typeText[typeText()] + _delimiter + _unitText[unitText()] + _delimiter + infoText(); Index: sources/model/MAbstract.h =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/MAbstract.h (.../MAbstract.h) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ sources/model/MAbstract.h (.../MAbstract.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -26,6 +26,7 @@ private: QString _delimiter = ","; + quint8 _precision = 2; protected: enum class Type_Enum { Index: sources/model/dg/data/MDGDrainPumpData.h =================================================================== diff -u -r90bcc276f2a879169fef20e9168711cf906c0e54 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/dg/data/MDGDrainPumpData.h (.../MDGDrainPumpData.h) (revision 90bcc276f2a879169fef20e9168711cf906c0e54) +++ sources/model/dg/data/MDGDrainPumpData.h (.../MDGDrainPumpData.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -47,7 +47,7 @@ quint32 mDAC = 0; /*!< Reservoir2 Bkup value of type float extracted out */ }; - MDGDrainPump () {} + MDGDrainPump () { } bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; Data data ( ) const ; Index: sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.cpp (.../MTreatmentAdjustBloodDialysateResponse.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.cpp (.../MTreatmentAdjustBloodDialysateResponse.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,21 +15,15 @@ using namespace Model; -QString MAdjustBloodDialysateResponse::toString() const { - return QString(stringPrefix + ",%1,%2,%3,%4") - .arg(_data.mAccepted .value) - .arg(_data.mReason .value) - .arg(_data.mBloodRate .value) - .arg(_data.mDialydateReate .value); +QVariantList MAdjustBloodDialysateResponse::parameters() const { + return { + _data.mAccepted .value, + _data.mReason .value, + _data.mBloodRate .value, + _data.mDialydateReate.value + }; } -void MAdjustBloodDialysateResponse::toVariantList(QVariantList &vData) const { - vData += _data.mAccepted .value; - vData += _data.mReason .value; - vData += _data.mBloodRate .value; - vData += _data.mDialydateReate .value; -} - bool MAdjustBloodDialysateResponse::fromByteArray(const QByteArray &vByteArray, int *vIndex) { int index = 0; // message data start position if (GetValue(vByteArray, index, _data.mAccepted )) @@ -45,9 +39,9 @@ AdjustBloodDialysateResponseData MAdjustBloodDialysateResponse::data() const { Data data; - data.mAccepted = _data.mAccepted .value; - data.mReason = _data.mReason .value; - data.mBloodRate = _data.mBloodRate .value; - data.mDialydateReate = _data.mDialydateReate .value; + data.mAccepted = _data.mAccepted .value; + data.mReason = _data.mReason .value; + data.mBloodRate = _data.mBloodRate .value; + data.mDialydateReate = _data.mDialydateReate.value; return data; } Index: sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.h (.../MTreatmentAdjustBloodDialysateResponse.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/adjustment/MTreatmentAdjustBloodDialysateResponse.h (.../MTreatmentAdjustBloodDialysateResponse.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,28 +17,24 @@ #include // Project +#include "MAbstract.h" #include "types.h" // forward declarations class tst_models; namespace Model { -class MAdjustBloodDialysateResponse { +class MAdjustBloodDialysateResponse : public MAbstract { // friends friend class ::tst_models; -public: - QString stringPrefix = "Adjust Blood/Dialisate"; - struct Data { - bool mAccepted = 0; /*!< Accepted value of type quint32 extracted out */ - quint32 mReason = 0; /*!< Reason value of type quint32 extracted out */ - quint32 mBloodRate = 0; /*!< BloodRate value of type quint32 extracted out */ - quint32 mDialydateReate = 0; /*!< DialydateReate value of type quint32 extracted out */ - }; + Type_Enum typeText () const override { return Type_Enum::eEvent; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("AdjustBloodDialisate"); } + QVariantList parameters() const override; -private: struct { Types::U32 mAccepted ; Types::U32 mReason ; @@ -47,13 +43,17 @@ } _data; public: + struct Data { + bool mAccepted = 0; /*!< Accepted value of type quint32 extracted out */ + quint32 mReason = 0; /*!< Reason value of type quint32 extracted out */ + quint32 mBloodRate = 0; /*!< BloodRate value of type quint32 extracted out */ + quint32 mDialydateReate = 0; /*!< DialydateReate value of type quint32 extracted out */ + }; + MAdjustBloodDialysateResponse () { } - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); - - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } Index: sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.cpp (.../MTreatmentAdjustDurationResponse.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.cpp (.../MTreatmentAdjustDurationResponse.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,19 +15,14 @@ using namespace Model; -QString MAdjustDurationResponse::toString() const { - return QString(stringPrefix + ",%1,%2,%3,%4") - .arg(_data.mAccepted .value) - .arg(_data.mReason .value) - .arg(_data.mDuration .value) - .arg(_data.mUFVolume .value); -} -void MAdjustDurationResponse::toVariantList(QVariantList &vData) const { - vData += _data.mAccepted .value; - vData += _data.mReason .value; - vData += _data.mDuration .value; - vData += _data.mUFVolume .value; +QVariantList MAdjustDurationResponse::parameters() const { + return { + _data.mAccepted.value, + _data.mReason .value, + _data.mDuration.value, + _data.mUFVolume.value + }; } bool MAdjustDurationResponse::fromByteArray(const QByteArray &vByteArray, int *vIndex) { @@ -45,9 +40,9 @@ AdjustDurationResponseData MAdjustDurationResponse::data() const { Data data; - data.mAccepted = _data.mAccepted .value; - data.mReason = _data.mReason .value; - data.mDuration = _data.mDuration .value; - data.mUFVolume = _data.mUFVolume .value; + data.mAccepted = _data.mAccepted.value; + data.mReason = _data.mReason .value; + data.mDuration = _data.mDuration.value; + data.mUFVolume = _data.mUFVolume.value; return data; } Index: sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.h (.../MTreatmentAdjustDurationResponse.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/adjustment/MTreatmentAdjustDurationResponse.h (.../MTreatmentAdjustDurationResponse.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,28 +17,24 @@ #include // Project +#include "MAbstract.h" #include "types.h" // forward declarations class tst_models; namespace Model { -class MAdjustDurationResponse { +class MAdjustDurationResponse : public MAbstract { // friends friend class ::tst_models; -public: - QString stringPrefix = "Adjust Duration"; - struct Data { - bool mAccepted = 0; /*!< Accepted value of type quint32 extracted out */ - quint32 mReason = 0; /*!< Reason value of type quint32 extracted out */ - quint32 mDuration = 0; /*!< Duration value of type quint32 extracted out */ - float mUFVolume = 0; /*!< UF Volume value of type quint32 extracted out */ - }; + Type_Enum typeText () const override { return Type_Enum::eEvent; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("AdjustDuration"); } + QVariantList parameters() const override; -private: struct { Types::U32 mAccepted ; Types::U32 mReason ; @@ -47,13 +43,17 @@ } _data; public: + struct Data { + bool mAccepted = 0; /*!< Accepted value of type quint32 extracted out */ + quint32 mReason = 0; /*!< Reason value of type quint32 extracted out */ + quint32 mDuration = 0; /*!< Duration value of type quint32 extracted out */ + float mUFVolume = 0; /*!< UF Volume value of type quint32 extracted out */ + }; + MAdjustDurationResponse () { } - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); - - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } Index: sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationEditResponse.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationEditResponse.h (.../MTreatmentAdjustUltrafiltrationEditResponse.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationEditResponse.h (.../MTreatmentAdjustUltrafiltrationEditResponse.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,8 +17,8 @@ #include // Project -#include "types.h" #include "MTreatmentAdjustUltrafiltrationConfirmResponse.h" +#include "types.h" // forward declarations class tst_models; Index: sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.cpp (.../MTreatmentAdjustUltrafiltrationStateResponse.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.cpp (.../MTreatmentAdjustUltrafiltrationStateResponse.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,13 +15,11 @@ using namespace Model; -QString MAdjustUltrafiltrationStateResponse::toString() const { - return QString(stringPrefix + ",%1") - .arg(_data.mAccepted.value); -} -void MAdjustUltrafiltrationStateResponse::toVariantList(QVariantList &vData) const { - vData += _data.mAccepted.value; +QVariantList MAdjustUltrafiltrationStateResponse::parameters() const { + return { + _data.mAccepted.value + }; } bool MAdjustUltrafiltrationStateResponse::fromByteArray(const QByteArray &vByteArray, int *vIndex) { Index: sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.h (.../MTreatmentAdjustUltrafiltrationStateResponse.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/adjustment/MTreatmentAdjustUltrafiltrationStateResponse.h (.../MTreatmentAdjustUltrafiltrationStateResponse.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,37 +17,37 @@ #include // Project +#include "MAbstract.h" #include "types.h" // forward declarations class tst_models; namespace Model { -class MAdjustUltrafiltrationStateResponse { +class MAdjustUltrafiltrationStateResponse : public MAbstract { // friends friend class ::tst_models; -public: - QString stringPrefix = "Ultrafiltration State"; - struct Data { - bool mAccepted = 0; /*!< Accepted value of type quint32 extracted out */ - }; + Type_Enum typeText () const override { return Type_Enum::eEvent; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("AdjustUFState"); } + QVariantList parameters() const override; -private: struct { Types::U08 mAccepted ; // IMPORTANT : This is a response to AcknowGeneric which has a data of 1 byte for the accepted/rejected. } _data; public: + struct Data { + bool mAccepted = 0; /*!< Accepted value of type quint32 extracted out */ + }; + MAdjustUltrafiltrationStateResponse() { } - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); - - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } Index: sources/model/hd/data/MTreatmentFlowsData.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentFlowsData.cpp (.../MTreatmentFlowsData.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentFlowsData.cpp (.../MTreatmentFlowsData.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -16,25 +16,17 @@ using namespace Model; // ----- BloodFlow ----- -QString MFlow::toString() const { - return QString(stringPrefix + ",%1,%2,%3,%4,%5,%6,%7") - .arg(_data.mFlowSetPoint .value) - .arg(_data.mMeasuredFlow .value) - .arg(_data.mRotorSpeed .value) - .arg(_data.mMotorSpeed .value) - .arg(_data.mMotorCtlSpeed .value) - .arg(_data.mMotorCtlCurrent .value) - .arg(_data.mPWMDutyCycle .value); -} -void MFlow::toVariantList(QVariantList &vData) const { - vData += _data.mFlowSetPoint .value; - vData += _data.mMeasuredFlow .value; - vData += _data.mRotorSpeed .value; - vData += _data.mMotorSpeed .value; - vData += _data.mMotorCtlSpeed .value; - vData += _data.mMotorCtlCurrent .value; - vData += _data.mPWMDutyCycle .value; +QVariantList MFlow::parameters() const { + return { + _data.mFlowSetPoint .value, + _data.mMeasuredFlow .value, + _data.mRotorSpeed .value, + _data.mMotorSpeed .value, + _data.mMotorCtlSpeed .value, + _data.mMotorCtlCurrent.value, + _data.mPWMDutyCycle .value + }; } bool MFlow::fromByteArray(const QByteArray &vByteArray, int *vIndex) { @@ -56,32 +48,28 @@ else { if(vIndex) *vIndex = index; return false; } } -const MFlow::Data &MFlow::data() const { - return _data; -} - // ----- BloodFlow ----- MBloodFlow::Data MBloodFlow::data() const { Data data; - data.mFlowSetPoint = MFlow::data().mFlowSetPoint .value; - data.mMeasuredFlow = MFlow::data().mMeasuredFlow .value; - data.mRotorSpeed = MFlow::data().mRotorSpeed .value; - data.mMotorSpeed = MFlow::data().mMotorSpeed .value; - data.mMotorCtlSpeed = MFlow::data().mMotorCtlSpeed .value; - data.mMotorCtlCurrent = MFlow::data().mMotorCtlCurrent.value; - data.mPWMDutyCycle = MFlow::data().mPWMDutyCycle .value; + data.mFlowSetPoint = _data.mFlowSetPoint .value; + data.mMeasuredFlow = _data.mMeasuredFlow .value; + data.mRotorSpeed = _data.mRotorSpeed .value; + data.mMotorSpeed = _data.mMotorSpeed .value; + data.mMotorCtlSpeed = _data.mMotorCtlSpeed .value; + data.mMotorCtlCurrent = _data.mMotorCtlCurrent.value; + data.mPWMDutyCycle = _data.mPWMDutyCycle .value; return data; } // ----- DialysateFlow ----- MDialysateFlow::Data MDialysateFlow::data() const { Data data; - data.mFlowSetPoint = MFlow::data().mFlowSetPoint .value; - data.mMeasuredFlow = MFlow::data().mMeasuredFlow .value; - data.mRotorSpeed = MFlow::data().mRotorSpeed .value; - data.mMotorSpeed = MFlow::data().mMotorSpeed .value; - data.mMotorCtlSpeed = MFlow::data().mMotorCtlSpeed .value; - data.mMotorCtlCurrent = MFlow::data().mMotorCtlCurrent.value; - data.mPWMDutyCycle = MFlow::data().mPWMDutyCycle .value; + data.mFlowSetPoint = _data.mFlowSetPoint .value; + data.mMeasuredFlow = _data.mMeasuredFlow .value; + data.mRotorSpeed = _data.mRotorSpeed .value; + data.mMotorSpeed = _data.mMotorSpeed .value; + data.mMotorCtlSpeed = _data.mMotorCtlSpeed .value; + data.mMotorCtlCurrent = _data.mMotorCtlCurrent.value; + data.mPWMDutyCycle = _data.mPWMDutyCycle .value; return data; } Index: sources/model/hd/data/MTreatmentFlowsData.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentFlowsData.h (.../MTreatmentFlowsData.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentFlowsData.h (.../MTreatmentFlowsData.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -18,19 +18,21 @@ #include // Project +#include "MAbstract.h" #include "types.h" namespace Model { /*! * \brief The Flow Data class */ -class MFlow { +class MFlow : public MAbstract { -public: - QString stringPrefix = ""; + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QVariantList parameters() const override; -private: +protected: struct Data { Types::S32 mFlowSetPoint ; /*!< vFlowSetPoint - Flow Set Point value of type signed int extracted out */ Types::F32 mMeasuredFlow ; /*!< vMeasuredFlow - Measured Flow value of type float extracted out */ @@ -44,17 +46,16 @@ public: MFlow () { } - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); - - const Data &data() const ; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; }; /*! * \brief The Blood Flow Data class */ class MBloodFlow : public MFlow { + + QString infoText () const override { return QString("BloodFlow"); } + public: struct Data { qint32 mFlowSetPoint = 0; /*!< vFlowSetPoint - Flow Set Point value of type signed int extracted out */ @@ -65,14 +66,19 @@ float mMotorCtlCurrent = 0; /*!< vMotorCtlCurrent - Motor Controller Current value of type float extracted out */ float mPWMDutyCycle = 0; /*!< vPWMDtCycle - PWM Duty Cycle in % value of type float extracted out */ }; - MBloodFlow() { stringPrefix = "Blood Flow"; } + + MBloodFlow() { } + Data data() const; }; /*! * \brief The Dialysate Flow Data class */ class MDialysateFlow : public MFlow { + + QString infoText () const override { return QString("DialysateFlow"); } + public: struct Data { qint32 mFlowSetPoint = 0; /*!< vFlowSetPoint - Flow Set Point value of type signed int extracted out */ @@ -83,8 +89,10 @@ float mMotorCtlCurrent = 0; /*!< vMotorCtlCurrent - Motor Controller Current value of type float extracted out */ float mPWMDutyCycle = 0; /*!< vPWMDtCycle - PWM Duty Cycle in % value of type float extracted out */ }; - MDialysateFlow() { stringPrefix = "Dialysate Flow"; } - Data data() const; + + MDialysateFlow() { } + + Data data() const; }; } Index: sources/model/hd/data/MTreatmentOutletFlowData.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentOutletFlowData.cpp (.../MTreatmentOutletFlowData.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentOutletFlowData.cpp (.../MTreatmentOutletFlowData.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,28 +15,18 @@ using namespace Model; -// ----- OutletFlow ----- -QString MOutletFlow::toString() const { - return QString(stringPrefix + ",%1,%2,%3,%4,%5,%6,%7") - .arg(_data.mRefUFVol .value) - .arg(_data.mMeasUFVol .value) - .arg(_data.mRotorSpeed .value) - .arg(_data.mMotorSpeed .value) - .arg(_data.mMotorCtlSpeed .value) - .arg(_data.mMotorCtlCurrent .value) - .arg(_data.mPWMDtCycle .value); +QVariantList MOutletFlow::parameters() const { + return { + _data.mRefUFVol .value, + _data.mMeasUFVol .value, + _data.mRotorSpeed .value, + _data.mMotorSpeed .value, + _data.mMotorCtlSpeed .value, + _data.mMotorCtlCurrent .value, + _data.mPWMDtCycle .value + }; } -void MOutletFlow::toVariantList(QVariantList &vData) const { - vData += _data.mRefUFVol .value; - vData += _data.mMeasUFVol .value; - vData += _data.mRotorSpeed .value; - vData += _data.mMotorSpeed .value; - vData += _data.mMotorCtlSpeed .value; - vData += _data.mMotorCtlCurrent.value; - vData += _data.mPWMDtCycle .value; -} - bool MOutletFlow::fromByteArray(const QByteArray &vByteArray, int *vIndex) { int index = 0; // message data start position if (GetValue(vByteArray, index, _data.mRefUFVol )) Index: sources/model/hd/data/MTreatmentOutletFlowData.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentOutletFlowData.h (.../MTreatmentOutletFlowData.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentOutletFlowData.h (.../MTreatmentOutletFlowData.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,24 +17,18 @@ #include // Project +#include "MAbstract.h" #include "types.h" namespace Model { -class MOutletFlow { -public: - QString stringPrefix = "Dialysate Outlet Flow"; - struct Data { - float mRefUFVol = 0; /*!< Reference UF Volume value of type float extracted out */ - float mMeasUFVol = 0; /*!< Measured UF Volume value of type float extracted out */ - float mRotorSpeed = 0; /*!< Rotor Speed value of type float extracted out */ - float mMotorSpeed = 0; /*!< Motor Speed value of type float extracted out */ - float mMotorCtlSpeed = 0; /*!< Motor Controller Speed value of type float extracted out */ - float mMotorCtlCurrent = 0; /*!< Motor Controller Current value of type float extracted out */ - float mPWMDtCycle = 0; /*!< PWM Duty Cycle in % value of type float extracted out */ - }; +class MOutletFlow : public MAbstract { -private: + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("OutletFlow"); } + QVariantList parameters() const override; + struct { Types::F32 mRefUFVol ; Types::F32 mMeasUFVol ; @@ -46,13 +40,21 @@ } _data; public: + QString stringPrefix = "Dialysate Outlet Flow"; + struct Data { + float mRefUFVol = 0; /*!< Reference UF Volume value of type float extracted out */ + float mMeasUFVol = 0; /*!< Measured UF Volume value of type float extracted out */ + float mRotorSpeed = 0; /*!< Rotor Speed value of type float extracted out */ + float mMotorSpeed = 0; /*!< Motor Speed value of type float extracted out */ + float mMotorCtlSpeed = 0; /*!< Motor Controller Speed value of type float extracted out */ + float mMotorCtlCurrent = 0; /*!< Motor Controller Current value of type float extracted out */ + float mPWMDtCycle = 0; /*!< PWM Duty Cycle in % value of type float extracted out */ + }; + MOutletFlow () { } - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); - - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } Index: sources/model/hd/data/MTreatmentPressureOcclusionData.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentPressureOcclusionData.cpp (.../MTreatmentPressureOcclusionData.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentPressureOcclusionData.cpp (.../MTreatmentPressureOcclusionData.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,23 +15,16 @@ using namespace Model; -QString MPressureOcclusion::toString() const { - return QString(stringPrefix + ",%1,%2,%3,%4,%5") - .arg(_data.mArterialPressure .value) - .arg(_data.mVenousPressure .value) - .arg(_data.mBloodPumpOcclusion .value) - .arg(_data.mDialysateInletPumpOcclusion .value) - .arg(_data.mDialysateOutletPumpOcclusion .value); +QVariantList MPressureOcclusion::parameters() const { + return { + _data.mArterialPressure .value, + _data.mVenousPressure .value, + _data.mBloodPumpOcclusion .value, + _data.mDialysateInletPumpOcclusion .value, + _data.mDialysateOutletPumpOcclusion .value + }; } -void MPressureOcclusion::toVariantList(QVariantList &vData) const { - vData += _data.mArterialPressure .value; - vData += _data.mVenousPressure .value; - vData += _data.mBloodPumpOcclusion .value; - vData += _data.mDialysateInletPumpOcclusion .value; - vData += _data.mDialysateOutletPumpOcclusion .value; -} - bool MPressureOcclusion::fromByteArray(const QByteArray &vByteArray, int *vIndex) { int index = 0; // message data start position if (GetValue(vByteArray, index, _data.mArterialPressure )) Index: sources/model/hd/data/MTreatmentPressureOcclusionData.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentPressureOcclusionData.h (.../MTreatmentPressureOcclusionData.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentPressureOcclusionData.h (.../MTreatmentPressureOcclusionData.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,22 +17,19 @@ #include // Project +#include "MAbstract.h" #include "types.h" namespace Model { -class MPressureOcclusion { +class MPressureOcclusion : public MAbstract { public: - QString stringPrefix = "Pressure/Occlusion"; - struct Data { - float mArterialPressure = 0; /*!< ArterialPressure value of type float extracted out */ - float mVenousPressure = 0; /*!< VenousPressure value of type float extracted out */ - float mBloodPumpOcclusion = 0; /*!< BloodPumpOcclusion value of type float extracted out */ - float mDialysateInletPumpOcclusion = 0; /*!< DialysateInletPumpOcclusion value of type float extracted out */ - float mDialysateOutletPumpOcclusion = 0; /*!< DialysateOutletPumpOcclusion value of type float extracted out */ - }; -private: + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("Pressure/Occlusion"); } + QVariantList parameters() const override; + struct { Types::F32 mArterialPressure ; Types::F32 mVenousPressure ; @@ -42,13 +39,18 @@ } _data; public: + struct Data { + float mArterialPressure = 0; /*!< ArterialPressure value of type float extracted out */ + float mVenousPressure = 0; /*!< VenousPressure value of type float extracted out */ + float mBloodPumpOcclusion = 0; /*!< BloodPumpOcclusion value of type float extracted out */ + float mDialysateInletPumpOcclusion = 0; /*!< DialysateInletPumpOcclusion value of type float extracted out */ + float mDialysateOutletPumpOcclusion = 0; /*!< DialysateOutletPumpOcclusion value of type float extracted out */ + }; + MPressureOcclusion () { } - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); - - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } Index: sources/model/hd/data/MTreatmentRangesData.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentRangesData.cpp (.../MTreatmentRangesData.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentRangesData.cpp (.../MTreatmentRangesData.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,33 +15,25 @@ using namespace Model; -QString MTreatmentRanges::toString() const { - return QString(stringPrefix + ",%1,%2,%3,%4,%5,%6") - .arg(_data.mDuration_Min .value) - .arg(_data.mDuration_Max .value) - .arg(_data.mUltrafiltration_Volume_Min .value) - .arg(_data.mUltrafiltration_Volume_Max .value) - .arg(_data.mDialysate_Flow_Min .value) - .arg(_data.mDialysate_Flow_Max .value); +QVariantList MTreatmentRanges::parameters() const { + return { + _data.mDuration_Min .value, + _data.mDuration_Max .value, + _data.mUltrafiltration_Volume_Min.value, + _data.mUltrafiltration_Volume_Max.value, + _data.mDialysate_Flow_Min .value, + _data.mDialysate_Flow_Max .value + }; } -void MTreatmentRanges::toVariantList(QVariantList &vData) const { - vData += _data.mDuration_Min .value; - vData += _data.mDuration_Max .value; - vData += _data.mUltrafiltration_Volume_Min .value; - vData += _data.mUltrafiltration_Volume_Max .value; - vData += _data.mDialysate_Flow_Min .value; - vData += _data.mDialysate_Flow_Max .value; -} - bool MTreatmentRanges::fromByteArray(const QByteArray &vByteArray, int *vIndex) { int index = 0; // message data start position - if (GetValue(vByteArray, index, _data.mDuration_Min )) - if (GetValue(vByteArray, index, _data.mDuration_Max )) - if (GetValue(vByteArray, index, _data.mUltrafiltration_Volume_Min )) - if (GetValue(vByteArray, index, _data.mUltrafiltration_Volume_Max )) - if (GetValue(vByteArray, index, _data.mDialysate_Flow_Min )) - if (GetValue(vByteArray, index, _data.mDialysate_Flow_Max )) + if (GetValue(vByteArray, index, _data.mDuration_Min )) + if (GetValue(vByteArray, index, _data.mDuration_Max )) + if (GetValue(vByteArray, index, _data.mUltrafiltration_Volume_Min)) + if (GetValue(vByteArray, index, _data.mUltrafiltration_Volume_Max)) + if (GetValue(vByteArray, index, _data.mDialysate_Flow_Min )) + if (GetValue(vByteArray, index, _data.mDialysate_Flow_Max )) return true ; else { if(vIndex) *vIndex = index; return false; } else { if(vIndex) *vIndex = index; return false; } @@ -53,11 +45,11 @@ MTreatmentRanges::Data MTreatmentRanges::data() const { Data data; - data.mDuration_Min = _data.mDuration_Min .value; - data.mDuration_Max = _data.mDuration_Max .value; - data.mUltrafiltration_Volume_Min = _data.mUltrafiltration_Volume_Min .value; - data.mUltrafiltration_Volume_Max = _data.mUltrafiltration_Volume_Max .value; - data.mDialysate_Flow_Min = _data.mDialysate_Flow_Min .value; - data.mDialysate_Flow_Max = _data.mDialysate_Flow_Max .value; + data.mDuration_Min = _data.mDuration_Min .value; + data.mDuration_Max = _data.mDuration_Max .value; + data.mUltrafiltration_Volume_Min = _data.mUltrafiltration_Volume_Min.value; + data.mUltrafiltration_Volume_Max = _data.mUltrafiltration_Volume_Max.value; + data.mDialysate_Flow_Min = _data.mDialysate_Flow_Min .value; + data.mDialysate_Flow_Max = _data.mDialysate_Flow_Max .value; return data; } Index: sources/model/hd/data/MTreatmentRangesData.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentRangesData.h (.../MTreatmentRangesData.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentRangesData.h (.../MTreatmentRangesData.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,6 +17,7 @@ #include // Project +#include "MAbstract.h" #include "types.h" // forward declarations @@ -25,23 +26,16 @@ namespace Model { -class MTreatmentRanges { +class MTreatmentRanges : public MAbstract { // friends friend class ::tst_models; -public: - QString stringPrefix = "Treatment Ranges"; - struct Data { - quint32 mDuration_Min = 0; /*!< mDuration_Min value of type U32 extracted out */ - quint32 mDuration_Max = 0; /*!< mDuration_Max value of type U32 extracted out */ - float mUltrafiltration_Volume_Min = 0; /*!< mUltrafiltration_Volume_Min value of type float extracted out */ - float mUltrafiltration_Volume_Max = 0; /*!< mUltrafiltration_Volume_Max value of type float extracted out */ - quint32 mDialysate_Flow_Min = 0; /*!< mDialysate_Flow_Min value of type U32 extracted out */ - quint32 mDialysate_Flow_Max = 0; /*!< mDialysate_Flow_Max value of type U32 extracted out */ - }; + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("TreatmentRanges"); } + QVariantList parameters() const override; -private: struct { Types::U32 mDuration_Min ; Types::U32 mDuration_Max ; @@ -52,13 +46,19 @@ } _data; public: + struct Data { + quint32 mDuration_Min = 0; /*!< mDuration_Min value of type U32 extracted out */ + quint32 mDuration_Max = 0; /*!< mDuration_Max value of type U32 extracted out */ + float mUltrafiltration_Volume_Min = 0; /*!< mUltrafiltration_Volume_Min value of type float extracted out */ + float mUltrafiltration_Volume_Max = 0; /*!< mUltrafiltration_Volume_Max value of type float extracted out */ + quint32 mDialysate_Flow_Min = 0; /*!< mDialysate_Flow_Min value of type U32 extracted out */ + quint32 mDialysate_Flow_Max = 0; /*!< mDialysate_Flow_Max value of type U32 extracted out */ + }; + MTreatmentRanges () { } - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); - - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } Index: sources/model/hd/data/MTreatmentStatesData.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentStatesData.cpp (.../MTreatmentStatesData.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentStatesData.cpp (.../MTreatmentStatesData.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,20 +15,15 @@ using namespace Model; -QString MTreatmentState::toString() const { - return QString(stringPrefix + ",%1,%2,%3") - .arg(_data.mSubMode .value) - .arg(_data.mUFState .value) - .arg(_data.mSalineState.value); +QVariantList MTreatmentStates::parameters() const { + return { + _data.mSubMode .value, + _data.mUFState .value, + _data.mSalineState.value + }; } -void MTreatmentState::toVariantList(QVariantList &vData) const { - vData += _data.mSubMode .value; - vData += _data.mUFState .value; - vData += _data.mSalineState.value; -} - -bool MTreatmentState::fromByteArray(const QByteArray &vByteArray, int *vIndex) { +bool MTreatmentStates::fromByteArray(const QByteArray &vByteArray, int *vIndex) { int index = 0; // message data start position if (GetValue(vByteArray, index, _data.mSubMode )) if (GetValue(vByteArray, index, _data.mUFState )) @@ -39,7 +34,7 @@ else { if(vIndex) *vIndex = index; return false; } } -MTreatmentState::Data MTreatmentState::data() const { +MTreatmentStates::Data MTreatmentStates::data() const { Data data; data.mSubMode = _data.mSubMode .value; data.mUFState = _data.mUFState .value; Index: sources/model/hd/data/MTreatmentStatesData.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentStatesData.h (.../MTreatmentStatesData.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentStatesData.h (.../MTreatmentStatesData.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -17,43 +17,43 @@ #include // Project +#include "MAbstract.h" #include "types.h" // forward declarations class tst_models; namespace Model { -class MTreatmentState { +class MTreatmentStates : public MAbstract { // friends friend class ::tst_models; -public: - QString stringPrefix = "Treatment State"; - struct Data { - quint32 mSubMode = 0; /*!< Sub-Mode value of type quint32 extracted out */ - quint32 mUFState = 0; /*!< UF State value of type quint32 extracted out */ - quint32 mSalineState = 0; /*!< Saline State value of type quint32 extracted out */ - }; + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("TreatmentStates"); } + QVariantList parameters() const override; -private: struct { Types::U32 mSubMode ; Types::U32 mUFState ; Types::U32 mSalineState ; } _data; public: - MTreatmentState() { } + struct Data { + quint32 mSubMode = 0; /*!< Sub-Mode value of type quint32 extracted out */ + quint32 mUFState = 0; /*!< UF State value of type quint32 extracted out */ + quint32 mSalineState = 0; /*!< Saline State value of type quint32 extracted out */ + }; - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); + MTreatmentStates() { } - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } -typedef Model::MTreatmentState::Data TreatmentStateData; +typedef Model::MTreatmentStates::Data TreatmentStateData; Index: sources/model/hd/data/MTreatmentTimeData.cpp =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentTimeData.cpp (.../MTreatmentTimeData.cpp) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentTimeData.cpp (.../MTreatmentTimeData.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -15,22 +15,14 @@ using namespace Model; -MTreatmentTime::MTreatmentTime() { } - -// ----- TreatmentTime ----- -QString MTreatmentTime::toString() const { - return QString(stringPrefix + ",%1,%2,%3") - .arg(_data.mTotal .value) - .arg(_data.mElapsed .value) - .arg(_data.mRemaining .value); +QVariantList MTreatmentTime::parameters() const { + return { + _data.mTotal .value, + _data.mElapsed .value, + _data.mRemaining.value, + }; } -void MTreatmentTime::toVariantList(QVariantList &vData) const { - vData += _data.mTotal .value; - vData += _data.mElapsed .value; - vData += _data.mRemaining .value; -} - bool MTreatmentTime::fromByteArray(const QByteArray &vByteArray, int *vIndex) { int index = 0; // message data start position if (GetValue(vByteArray, index, _data.mTotal )) @@ -44,8 +36,8 @@ MTreatmentTime::Data MTreatmentTime::data() const { Data data; - data.mTotal = _data.mTotal .value; - data.mElapsed = _data.mElapsed .value; - data.mRemaining = _data.mRemaining .value; + data.mTotal = _data.mTotal .value; + data.mElapsed = _data.mElapsed .value; + data.mRemaining = _data.mRemaining.value; return data; } Index: sources/model/hd/data/MTreatmentTimeData.h =================================================================== diff -u -r6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/model/hd/data/MTreatmentTimeData.h (.../MTreatmentTimeData.h) (revision 6ae83fa9a1a3204864fc5b50fe906ac09e9c1ea5) +++ sources/model/hd/data/MTreatmentTimeData.h (.../MTreatmentTimeData.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -18,34 +18,36 @@ #include // Project +#include "MAbstract.h" #include "types.h" namespace Model { -class MTreatmentTime { -public: - QString stringPrefix = "Treatment Time"; - struct Data { - quint32 mTotal = 0; /*!< Total treatment time in sec */ - quint32 mElapsed = 0; /*!< Elapsed treatment time in sec */ - quint32 mRemaining = 0; /*!< Remaining treatment time in sec */ - }; +class MTreatmentTime : public MAbstract { -private: + Type_Enum typeText () const override { return Type_Enum::eDatum; } + Unit_Enum unitText () const override { return Unit_Enum::eHD ; } + QString infoText () const override { return QString("TreamtmentTime"); } + QVariantList parameters() const override; + struct { Types::U32 mTotal ; Types::U32 mElapsed ; Types::U32 mRemaining ; } _data; public: - MTreatmentTime(); + struct Data { + quint32 mTotal = 0; /*!< Total treatment time in sec */ + quint32 mElapsed = 0; /*!< Elapsed treatment time in sec */ + quint32 mRemaining = 0; /*!< Remaining treatment time in sec */ + }; - QString toString ( ) const ; - void toVariantList ( QVariantList &vData ) const ; - bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr); +public: + MTreatmentTime () { } - Data data() const; + bool fromByteArray (const QByteArray &vByteArray , int *vIndex = nullptr) override; + Data data ( ) const ; }; } Index: sources/storage/logger.cpp =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/storage/logger.cpp (.../logger.cpp) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/storage/logger.cpp (.../logger.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -183,6 +183,7 @@ bool Logger::setLogPath() { bool ok = true; + if ( ! setLogPath(LogType::eLogBasic) ) ok = false; if ( ! setLogPath(LogType::eLogEvent) ) ok = false; if ( ! setLogPath(LogType::eLogError) ) ok = false; if ( ! setLogPath(LogType::eLogDatum) ) ok = false; @@ -202,7 +203,7 @@ if ( ! _dir.exists(_logBasePathNames[vLogType]) ) { if ( ! _dir.mkpath(_logBasePathNames[vLogType]) ) { LOG_ERROR(tr("Can't create %1 log path (%2)") - .arg(_logPrefix[vLogType]) + .arg(_logTypeName [vLogType]) .arg(_logPathNames[vLogType]) ); return false; @@ -219,42 +220,39 @@ * \note This method is not thread-safe so is private and needs to be called by concurrentLog * Which uses QtConcurrent::run to run in thread and thread-safe. */ -void Logger::log(const QString &vContent, Logger::LogType vLogType) +void Logger::log(const QString &vContent, LogType vLogType) { QString date = QDate::currentDate().toString(_dateFormat); QString fileName = date + _dateSeparator; - QString mContent; switch (vLogType) { - case eLogEvent: - fileName += Log_File_Name_Event; + case LogType::eLogBasic: + case LogType::eLogEvent: + case LogType::eLogDatum: + case LogType::eLogError: + fileName += _logFileNameBase[vLogType]; break; - case eLogDatum: - fileName += Log_File_Name_Datum; - break; - - case eLogError: - fileName += Log_File_Name_Error; - break; - default: - fileName += Log_File_Name_Error; + fileName += _logFileNameBase[LogType::eLogError]; LOG_ERROR(tr("Incorrect type of logging %1").arg(vLogType)); } + QString mContent = QTime::currentTime().toString(_timeFormat) + _separator; + QString logPrefix = _logPrefix[vLogType]; if ( ! logPrefix.isEmpty()) { mContent += logPrefix; - mContent += _prefixSeparator; + mContent += _separator; } - mContent += QTime::currentTime().toString(_timeFormat); - mContent += _timeSeparator + vContent; + mContent += vContent; + + QString logPathName = _logPathNames[vLogType]; if (logPathName.isEmpty()) logPathName = _logPathNames[LogType::eLogError]; _logFileName = logPathName + fileName; FileHandler::write(_logFileName, mContent + "\r\n", true); - if (vLogType == eLogError) { + if (vLogType == LogType::eLogError) { #ifdef QT_DEBUG //mContent.prepend("\033[1;31m --- @ --- \033[0m"); mContent.prepend(" @ "); Index: sources/storage/logger.h =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/storage/logger.h (.../logger.h) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/storage/logger.h (.../logger.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -28,36 +28,12 @@ #define LOG_EXPORT _Logger.concurrentExport() -#define LOG_EVENT(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogEvent) -#define LOG_EVENT_ONCE_LOGGED \ - bLOG_EVENT_ONCE_LOGGED -#define LOG_EVENT_ONCE(vCONTENT) \ - static bool LOG_EVENT_ONCE_LOGGED = false; \ - if ( ! LOG_EVENT_ONCE_LOGGED ) { \ - LOG_EVENT_ONCE_LOGGED = true; \ - LOG_EVENT(vCONTENT); \ - } -#define LOG_ERROR(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogError) -#define LOG_ERROR_ONCE_LOGGED \ - bLOG_ERROR_ONCE_LOGGED -#define LOG_ERROR_ONCE(vCONTENT) \ - static bool LOG_ERROR_ONCE_LOGGED = false; \ - if ( ! LOG_ERROR_ONCE_LOGGED ) { \ - LOG_ERROR_ONCE_LOGGED = true; \ - LOG_ERROR(vCONTENT); \ - } +#define LOG_BASIC(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogBasic) +#define LOG_EVENT(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogEvent) +#define LOG_ERROR(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogError) +#define LOG_DATUM(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDatum) -#define LOG_DATUM(vCONTENT) emit Storage::Logger::I().didLog(vCONTENT, Storage::Logger::LogType::eLogDatum) -#define LOG_DATUM_ONCE_LOGGED \ - bLOG_DATUM_ONCE_LOGGED -#define LOG_DATUM_ONCE(vCONTENT) \ - static bool LOG_DATUM_ONCE_LOGGED = false; \ - if ( ! LOG_DATUM_ONCE_LOGGED ) { \ - LOG_DATUM_ONCE_LOGGED = true; \ - LOG_DATUM(vCONTENT); \ - } - // forward declarations class tst_logging; @@ -82,36 +58,49 @@ // friends friend class ::tst_logging; - -public: +public : enum LogType { + eLogBasic, eLogEvent, eLogError, eLogDatum, eLogType_Count, - }; + }; private: QDir _dir; QHash _logPathNames; QHash _logBasePathNames { - { eLogEvent, "log/" }, - { eLogDatum, "log/" }, - { eLogError, "log/" }, + { LogType::eLogBasic, "log/" }, + { LogType::eLogEvent, "log/" }, + { LogType::eLogDatum, "log/" }, + { LogType::eLogError, "log/" }, }; - QHash _logPrefix { - { eLogEvent, "E" }, - { eLogDatum, "D" }, - { eLogError, "" }, // it has its own file and all the content are Errors + QHash _logPrefix { // Will be used for the logging in the file + { LogType::eLogBasic, "" }, // Object itself tells what it is + { LogType::eLogEvent, "E" }, + { LogType::eLogDatum, "D" }, + { LogType::eLogError, "" }, // it has its own file and all the content is Error }; + QHash _logTypeName { // Will be used for for information + { LogType::eLogBasic, "Basic" }, // Object itself tells what it is + { LogType::eLogEvent, "Event" }, + { LogType::eLogDatum, "Datum" }, + { LogType::eLogError, "Error" }, // it has its own file and all the content is Error + }; + QHash _logFileNameBase { + { LogType::eLogBasic, "denali.log" }, + { LogType::eLogEvent, "denali.log" }, + { LogType::eLogDatum, "denali.log" }, + { LogType::eLogError, "denali.err" }, + }; const char *_dateFormat = "yyyy_MM_dd"; const char *_timeFormat = "HH:mm:ss"; const char *_dateSeparator = "_"; // used in filename - const char *_prefixSeparator = ","; - const char *_timeSeparator = ","; + const char *_separator = ","; QString _logFileName = ""; Index: sources/storage/storageglobals.cpp =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -23,7 +23,4 @@ // Log const char *Log_Base_Path_Name = "/media/sd-card/"; const char *Log_Base_Path_Name_Location = "/media/sd-card/log/"; - const char *Log_File_Name_Event = "denali.log"; - const char *Log_File_Name_Datum = "denali.log"; - const char *Log_File_Name_Error = "denali.err"; } Index: sources/storage/storageglobals.h =================================================================== diff -u -r2437559b2d4cd4c2ac6a926b4f55652e55e1f616 -r30f83b2813e68ae3c2806399bf808b642c215b67 --- sources/storage/storageglobals.h (.../storageglobals.h) (revision 2437559b2d4cd4c2ac6a926b4f55652e55e1f616) +++ sources/storage/storageglobals.h (.../storageglobals.h) (revision 30f83b2813e68ae3c2806399bf808b642c215b67) @@ -25,7 +25,4 @@ // Log extern const char *Log_Base_Path_Name ; extern const char *Log_Base_Path_Name_Location; - extern const char *Log_File_Name_Event ; - extern const char *Log_File_Name_Datum ; - extern const char *Log_File_Name_Error ; }