Index: sources/model/MModel.h =================================================================== diff -u -rbfde9964a92b954e7da925e0d04e797a225a5352 -rb61d8a3e01fef66eee8095c9cddf835d9bb32b66 --- sources/model/MModel.h (.../MModel.h) (revision bfde9964a92b954e7da925e0d04e797a225a5352) +++ sources/model/MModel.h (.../MModel.h) (revision b61d8a3e01fef66eee8095c9cddf835d9bb32b66) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file MModel.h - * \author (last) Behrouz NematiPour - * \date (last) 20-Aug-2020 + * \author (last) Peter Lucia + * \date (last) 15-Oct-2020 * \author (original) Behrouz NemaiPour * \date (original) 02-Jul-2020 * @@ -58,71 +58,126 @@ #include "MTreatmentAdjustSalineResponse.h" /*! - * \brief Message interpretation instruction - * \details This comment explains how to add a Denali Message in Denali UI Application + * \page MessageFlow Message interpretation Flow + * \dot + * digraph callgraph { + * node [shape=ellipse, fontname=Arial, fontsize=11]; + * user [shape=box ]; + * QML [URL="\ref application/sources/gui" ]; + * GuiView [URL="\ref Gui::GuiView" ]; + * View [URL="\ref application/sources/view" ]; + * GuiController [URL="\ref Gui::GuiController" ]; + * ApplicationController [URL="\ref ApplicationController" ]; + * FrameInterface [URL="\ref Can::FrameInterface" ]; + * CanInterface [URL="\ref Can::CanInterface" ]; + * CANBus [shape=box ]; + * subgraph MessageDispatcher { + * node [shape=ellipse, fontname=Arial, fontsize=11, URL="\ref Can::MessageDispatcher"]; + * label = "Message_Dispatcher"; + * MessageAcknow [URL="\ref Can::MessageAcknowModel" ]; + * MessageInterpreter [URL="\ref Can::MessageInterpreter" ]; + * MessageBuilder [URL="\ref Can::MessageBuilder" ]; + * MessageDispatcher -> MessageInterpreter [dir="both" ]; + * MessageDispatcher -> MessageAcknow [dir="both" ]; + * MessageInterpreter -> MessageBuilder [dir="both" ]; + * } + * user -> QML [dir="both" ]; + * QML -> { GuiView } [dir="both" ]; + * { GuiView, } -> GuiController [dir="both" ]; + * GuiController -> ApplicationController [dir="both" ]; + * ApplicationController -> MessageDispatcher [dir="both" ]; + * MessageDispatcher -> FrameInterface [dir="both" ]; + * FrameInterface -> CanInterface [dir="both" ]; + * CanInterface -> CANBus [dir="both" ]; + * } + * \enddot * - * 1 - Look at the message structure in the "message list.xlsx" + * \note + * 00 - sort .pro file after all new files added. * - * 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 + * \details + * This comment explains how to add a Denali Message in Denali UI Application * - * 3 - MSG Payload Len : - * Add a line in the "messageglobals.h" in payloadLen hash table - * to define the required payload length of the message + * Model : * - * 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. + * 01 - Look at the message structure in the "message list.xlsx" and in GuiGlobals.h define enum ID_ + * Add an enum for the message in the guiglobals.h : GuiActionsType_Enum + * and assign a correct message value to it. + * Note that it needs to be in little endian so if you have a message Id of 37 your enum should have a value of 0x2500 in hex. + * \code{.cpp} + * ID_HDOperationModeData = 0x2500, // 37 // little endian + * \endcode * - * 5 - Register Model : - * Add the required lines like the other models in the mmodel.h file. + * 02 - MessageGlobals.h : add len + * \code{.cpp} + * {Gui::GuiActionType::ID_HDOperationModeData , 1 * 4 }, // 1 parameter each 4bytes + * \endcode * - * 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 pressureOcclusionData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; - * \endcode - * in the implementation should be like: - * \code{.cpp} - * bool MessageInterpreter::pressureOcclusionData(const Message &vMessage, QVariantList &vData) - * { - * // TODO : review other methods - * bool ok = false; - * if ( ! isType (vMessage, Gui::GuiActionType::PressureOcclusion) ) return ok; - * if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::PressureOcclusion) ) return ok; + * 03 - Implement the model by copy/paste of the closest model, fit to your need. + * \sa MHDOperationMode + * \sa MHDOperationModeData.h + * \sa MHDOperationModeData.cpp * - * Model::MPressureOcclusion mData; - * ok = mData.fromByteArray(vMessage.data); - * LOG_DATUM("HD," + mData.toString()); + * 04 - Added #include in MModel.h for the implemented model + * \code{.cpp} + * #include "MHDOperationModeData.h" + * \endcode * - * mData.toVariantList(vData); - * emit didActionReceive(mData.data()); + * 05 - Register the model in MModel.h by adding it to the macro lists : + * - \ref REGISTER_MODEL_METATYPES + * - \ref ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS + * - \ref ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS + * - \ref ACTION_RECEIVE_SIGNALS * - * return ok; - * } - * \endcode + * 06 - In the MessageInterpreter add a line of handler in interpretMessage_ method + * and put the enum and model. + * \sa MessageInterpreter::interpretMessage_HD + * \sa MessageInterpreter::interpretMessage_DG + * \sa MessageInterpreter.cpp * - * 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 + * View : + * 07 - Implement the view by copy/paste of the closest view, fit to your need. + * \sa VHDOperationMode + * \sa VHDOperationModeData.h + * \sa VHDOperationModeData.cpp * + * 08 - Register the view in VView.h in macro list + * \sa REGISTER_VIEW_TYPES + * \sa VView.h + * + * 09 - Include the view header in the GuiGlobals.cpp + * \code{.cpp} + * #include "VHDOperationModeData.h" + * \endcode + * \sa GuiGlobals.cpp + * + * QML : + * 10 - Import the registered view + * \code{.js} + * import VHDOperationMode 0.1; + * \endcode + * \sa main.qml + * + * 11 - Create an object + * \code{.js} + * VHDOperationMode { id: vHDOperationMode } + * \endcode + * \sa main.qml + * + * 12 - Use it. */ + //--------------------------------------------------------------------------------// //-------- Please add the model type to the lists below to register them ---------// //--------------------------------------------------------------------------------// + +/*! + \def REGISTER_MODEL_METATYPES + \details Registers the models in the Qt MetaType so it can be used in signal/slots between threads. + */ #define REGISTER_MODEL_METATYPES \ + \ REGISTER_METATYPE( BloodFlowData ) \ REGISTER_METATYPE( DialysateFlowData ) \ REGISTER_METATYPE( OutletFlowData ) \ @@ -179,7 +234,21 @@ REGISTER_METATYPE( AdjustTreatmentParametersResponseData ) //===============================================================================// +/*! + \def ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS + \details This macro connects the source object vSource to the models defined in the list for received messages. + It connects source didActionReceive() signal to the this pointer of the class object + onActionReceive(). + The code below is implemented for each model : + \code {.cpp} + connect(&vSOURCE, SIGNAL(didActionReceive(const vTYPE &)), + this , SLOT( onActionReceive(const vTYPE &))); + \endcode + This macro should be used in the cpp file of the class. + This macro should be used with its counterpart macro \ref ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS + */ #define ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(vSOURCE) \ + \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, BloodFlowData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, DialysateFlowData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, OutletFlowData ) \ @@ -217,8 +286,10 @@ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, EndTreatmentResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustSalineResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustTreatmentParametersResponseData ) -//===============================================================================// + +// /* Request */ ---------------------------------------------------------// #define ADJUST_TRANSMT_MODEL_BRIDGE_CONNECTIONS(vSOURCE) \ + \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustBloodDialysateRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustDurationRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationStateRequestData ) \ @@ -231,8 +302,26 @@ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustTreatmentParametersRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AlarmAcknowledgeRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AlarmSilenceRequestData ) + //===============================================================================// +/*! + \def ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS + \details This macro defines the signal/slot of the source object vSource to the models + listed in its definition for received messages. + The code below will be implemented for each model : + \code {.cpp} + private slots: + void onActionReceive (const vTYPE &vData) { + emit didActionReceive(vData); + } + signals: + void didActionReceive (const vTYPE &vData); + \endcode + This macro should be used in the header file of the class. + This macro should be used with its counterpart macro \ref ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS + */ #define ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS \ + \ ACTION_RECEIVE_BRIDGE_DEFINITION( BloodFlowData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( DialysateFlowData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( OutletFlowData ) \ @@ -270,8 +359,9 @@ ACTION_RECEIVE_BRIDGE_DEFINITION( EndTreatmentResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustSalineResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustTreatmentParametersResponseData ) -// /* Request */ ---------------------------------------------------------// + #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS \ + /* Request --------------------------------------------------------- */ \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustBloodDialysateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustDurationRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustUltrafiltrationStateRequestData ) \ @@ -284,8 +374,9 @@ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustTreatmentParametersRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AlarmAcknowledgeRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AlarmSilenceRequestData ) -// /* Request */ ----------------------- NoEmit --------------------------// + #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS_NOEMIT \ + /* Request ----------------------- NoEmit -------------------------- */ \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustBloodDialysateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustDurationRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustUltrafiltrationStateRequestData ) \ @@ -298,8 +389,9 @@ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustTreatmentParametersRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AlarmSilenceRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AlarmAcknowledgeRequestData ) -// /* Request */ ----------------------- public --------------------------// + #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS_PUBLIC \ + /* Request ----------------------- public -------------------------- */ \ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustBloodDialysateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustDurationRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustUltrafiltrationStateRequestData ) \ @@ -314,6 +406,7 @@ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AlarmSilenceRequestData ) //===============================================================================// #define ACTION_RECEIVE_SIGNALS \ + /* Received signals */ \ ACTION_RECEIVE_SIGNAL( BloodFlowData ) \ ACTION_RECEIVE_SIGNAL( DialysateFlowData ) \ ACTION_RECEIVE_SIGNAL( OutletFlowData ) \