Index: denali.pro =================================================================== diff -u -r595ed1fbe8066960afd4c8fea168208e81b173d9 -r35959dd708a5c4fdf02626306441e5a77e7f7782 --- denali.pro (.../denali.pro) (revision 595ed1fbe8066960afd4c8fea168208e81b173d9) +++ denali.pro (.../denali.pro) (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -38,6 +38,7 @@ HEADERS += \ sources/main.h \ sources/maintimer.h \ + sources/model/mtreatmentpressureocclusion.h \ sources/threads.h \ sources/applicationcontroller.h \ sources/applicationpost.h \ @@ -78,6 +79,7 @@ SOURCES += \ main.cpp \ sources/maintimer.cpp \ + sources/model/mtreatmentpressureocclusion.cpp \ sources/threads.cpp \ sources/applicationcontroller.cpp \ sources/applicationpost.cpp \ Index: sources/canbus/messageglobals.h =================================================================== diff -u -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 -r35959dd708a5c4fdf02626306441e5a77e7f7782 --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -49,6 +49,7 @@ {Gui::GuiActionType::DialysateInletFlow , 7 * 4 }, // 7 parameters each 4bytes {Gui::GuiActionType::DialysateOutletFlow, 7 * 4 }, // 7 parameters each 4bytes {Gui::GuiActionType::TreatmentTime , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::PressureOcclusion , 5 * 4 }, // 5 parameters each 4bytes {Gui::GuiActionType::String , 255 }, {Gui::GuiActionType::Acknow , 0 }, }; Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r6c59703781373f33cfec27eacf1f7e4ba1374626 -r35959dd708a5c4fdf02626306441e5a77e7f7782 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 6c59703781373f33cfec27eacf1f7e4ba1374626) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -212,8 +212,7 @@ break; case Gui::GuiActionType::PressureOcclusion: - printUnhandled (vMessage); - ok = true; + ok = pressureOcclusionData (vMessage, vData); break; default: @@ -540,3 +539,34 @@ // Types::getBits(ba, i, flag, 32); // qDebug() << '@' << flag << flag.toString() << ba; } + +bool MessageInterpreter::getPressureOcclusionData(const Message &vMessage, Model::MPressureOcclusion &vData) +{ + if ( vMessage.actionId != Gui::GuiActionType::PressureOcclusion ) { + return false; + } + + if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::PressureOcclusion] ) { + QString mActionIdHexString = Format::toHexString(vMessage.actionId); + LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); + return false; + } + + vData.fromByteArray(vMessage.data); + + return true; +} + +bool MessageInterpreter::pressureOcclusionData(const Message &vMessage, QVariantList &vData) +{ + bool ok; + Model::MPressureOcclusion mData; + ok = getPressureOcclusionData(vMessage, mData); + LOG_DATUM(mData.toString()); + + if (ok) { + mData.toVariantList(vData); + emit didActionReceive(mData.data()); + } + return ok; +} Index: sources/canbus/messageinterpreter.h =================================================================== diff -u -r057d3ef4e29c63235040c5cfe8c6421ef7787d6a -r35959dd708a5c4fdf02626306441e5a77e7f7782 --- sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 057d3ef4e29c63235040c5cfe8c6421ef7787d6a) +++ sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -62,6 +62,10 @@ bool getTreatmentTime (const Message &vMessage, Model::MTreatmentTime &vData); bool treatmentTime (const Message &vMessage, QVariantList &vData); + // ---- Treatment Pressure/Occlusion + bool getPressureOcclusionData (const Message &vMessage, Model::MPressureOcclusion &vData) __attribute_warn_unused_result__; + bool pressureOcclusionData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + public: explicit MessageInterpreter(QObject *parent = nullptr); Index: sources/gui/guiglobals.h =================================================================== diff -u -r4a6abe765f03feae8100ec660aa04aa218d4dfa3 -r35959dd708a5c4fdf02626306441e5a77e7f7782 --- sources/gui/guiglobals.h (.../guiglobals.h) (revision 4a6abe765f03feae8100ec660aa04aa218d4dfa3) +++ sources/gui/guiglobals.h (.../guiglobals.h) (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -42,7 +42,7 @@ AlarmTriggered = 0x0300, AlarmCleared = 0x0400, - PressureOcclusion = 0x0900, + PressureOcclusion = 0x0900, // message 9 String = 0xFFFE, Index: sources/model/mmodel.h =================================================================== diff -u -r595ed1fbe8066960afd4c8fea168208e81b173d9 -r35959dd708a5c4fdf02626306441e5a77e7f7782 --- sources/model/mmodel.h (.../mmodel.h) (revision 595ed1fbe8066960afd4c8fea168208e81b173d9) +++ sources/model/mmodel.h (.../mmodel.h) (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -20,8 +20,86 @@ #include "mtreatmenttime.h" #include "mtreatmentflows.h" #include "mtreatmentoutletflow.h" +#include "mtreatmentpressureocclusion.h" #include "mpoweroff.h" +/*! + * \brief Message interpretation instruction + * \details This comment explains how to add a Denali Message in Denali UI Application + * + * 1 - Look at the message structure in the "message list.xlsx" + * + * 2 - MSG ID : + * Add an enum for the message in the guiglobals.h : GuiActionsType_Enum + * and assign a correct message value to it. + * example : MSG ID = 9 => + * \code{.cpp} + * PressureOcclusion = 0x0900, //(little endian) + * \endcode + * + * 3 - MSG Payload Len : + * Add a line in the "messageglobals.h" in paloadLen hash table + * to define the required payload length of the message + * + * 4 - Model Implementation : + * Implement a model like MPressureOcclusion by copy/paste the closest model .h/.cpp file + * and adding it to project and modify to fit the new model. + * + * 5 - Register Model : + * Add the required lines like the other models in the mmodel.h file. + * + * 6 - Populate/Interpret Model Data : + * Copy/Paste one of the other implementations of the Messages setter/getter. + * example : be careful about the type. + * in the header should be like: + * \code{.cpp} + * bool getPressureOcclusionData (const Message &vMessage, Model::MPressureOcclusion &vData) __attribute_warn_unused_result__; + * bool pressureOcclusionData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + * \endcode + * in the implementation should be like: + * \code{.cpp} + * bool MessageInterpreter::getPressureOcclusionData(const Message &vMessage, Model::MPressureOcclusion &vData) + * { + * if ( vMessage.actionId != Gui::GuiActionType::PressureOcclusion ) { + * return false; + * } + * + * if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::PressureOcclusion] ) { + * QString mActionIdHexString = Format::toHexString(vMessage.actionId); + * LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); + * return false; + * } + * + * vData.fromByteArray(vMessage.data); + * + * return true; + * } + * + * bool MessageInterpreter::pressureOcclusionData(const Message &vMessage, QVariantList &vData) + * { + * bool ok; + * Model::MPressureOcclusion mData; + * ok = getPressureOcclusionData(vMessage, mData); + * LOG_DATUM(mData.toString()); + * + * if (ok) { + * mData.toVariantList(vData); + * emit didActionReceive(mData.data()); + * } + * return ok; + * } + * \endcode + * + * Add a case in MessageInterpreter::interpretMessage_HD for that message id Enum + * with lines like : + * \code{.cpp} + * case Gui::GuiActionType::PressureOcclusion: + * ok = pressureOcclusionData (vMessage, vData); + * break; + * \endcode + * + */ + //--------------------------------------------------------------------------------// //-------- Please add the model type to the lists below to register them ---------// //--------------------------------------------------------------------------------// @@ -30,6 +108,7 @@ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, DialysateFlowData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, OutletFlowData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, TreatmentTimeData ) \ + ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, PressureOcclusionData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AlarmStatusData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, PowerOffData ) //--------------------------------------------------------------------------------// @@ -38,6 +117,7 @@ ACTION_RECEIVE_BRIDGE_DEFINITION( DialysateFlowData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( OutletFlowData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( TreatmentTimeData ) \ + ACTION_RECEIVE_BRIDGE_DEFINITION( PressureOcclusionData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AlarmStatusData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( PowerOffData ) //--------------------------------------------------------------------------------// @@ -46,6 +126,7 @@ REGISTER_METATYPE( DialysateFlowData ) \ REGISTER_METATYPE( OutletFlowData ) \ REGISTER_METATYPE( TreatmentTimeData ) \ + REGISTER_METATYPE( PressureOcclusionData ) \ REGISTER_METATYPE( AlarmStatusData ) \ REGISTER_METATYPE( AlarmStatusFlag ) \ REGISTER_METATYPE( PowerOffData ) @@ -55,6 +136,7 @@ ACTION_RECEIVE_BRIDGE_CONNECTION(_interpreter, DialysateFlowData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(_interpreter, OutletFlowData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(_interpreter, TreatmentTimeData ) \ + ACTION_RECEIVE_BRIDGE_CONNECTION(_interpreter, PressureOcclusionData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(_interpreter, AlarmStatusData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(_interpreter, PowerOffData ) //--------------------------------------------------------------------------------// @@ -63,6 +145,7 @@ ACTION_RECEIVE_SIGNAL( DialysateFlowData ) \ ACTION_RECEIVE_SIGNAL( OutletFlowData ) \ ACTION_RECEIVE_SIGNAL( TreatmentTimeData ) \ + ACTION_RECEIVE_SIGNAL( PressureOcclusionData ) \ ACTION_RECEIVE_SIGNAL( AlarmStatusData ) \ ACTION_RECEIVE_SIGNAL( PowerOffData ) //--------------------------------------------------------------------------------// Index: sources/model/mtreatmentpressureocclusion.cpp =================================================================== diff -u --- sources/model/mtreatmentpressureocclusion.cpp (revision 0) +++ sources/model/mtreatmentpressureocclusion.cpp (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -0,0 +1,52 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, + * IN PART OR IN WHOLE, + * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * file mtreatmentpressureocclusion.cpp + * date 3/23/2020 + * author Behrouz NematiPour + * + */ +#include "mtreatmentpressureocclusion.h" + +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); +} + +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; +} + +void MPressureOcclusion::fromByteArray(const QByteArray &vByteArray) { + int index = 0; // message data start position + Types::getValue<>(vByteArray, index, _data.mArterialPressure ); + Types::getValue<>(vByteArray, index, _data.mVenousPressure ); + Types::getValue<>(vByteArray, index, _data.mBloodPumpOcclusion ); + Types::getValue<>(vByteArray, index, _data.mDialysateInletPumpOcclusion ); + Types::getValue<>(vByteArray, index, _data.mDialysateOutletPumpOcclusion ); +} + +MPressureOcclusion::Data MPressureOcclusion::data() const { + Data data; + data.mArterialPressure = _data.mArterialPressure .value; + data.mVenousPressure = _data.mVenousPressure .value; + data.mBloodPumpOcclusion = _data.mBloodPumpOcclusion .value; + data.mDialysateInletPumpOcclusion = _data.mDialysateInletPumpOcclusion .value; + data.mDialysateOutletPumpOcclusion = _data.mDialysateOutletPumpOcclusion .value; + return data; +} Index: sources/model/mtreatmentpressureocclusion.h =================================================================== diff -u --- sources/model/mtreatmentpressureocclusion.h (revision 0) +++ sources/model/mtreatmentpressureocclusion.h (revision 35959dd708a5c4fdf02626306441e5a77e7f7782) @@ -0,0 +1,56 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, + * IN PART OR IN WHOLE, + * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * file mtreatmentpressureocclusion.h + * date 3/23/2020 + * author Behrouz NematiPour + * + */ +#pragma once + +// Qt +#include + +// Project +#include "types.h" + +namespace Model { + +class MPressureOcclusion { +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: + struct { + Types::F32 mArterialPressure ; + Types::F32 mVenousPressure ; + Types::F32 mBloodPumpOcclusion ; + Types::F32 mDialysateInletPumpOcclusion ; + Types::F32 mDialysateOutletPumpOcclusion ; + } _data; + +public: + MPressureOcclusion () { } + + QString toString ( ) const ; + void toVariantList ( QVariantList &vData ) const ; + void fromByteArray (const QByteArray &vByteArray ); + + Data data() const; +}; + +} + +typedef Model::MPressureOcclusion::Data PressureOcclusionData;