Index: sources/model/MModel.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r12e7b6dda53cf8db7707c7fa55dcf6137e7d6997 --- sources/model/MModel.h (.../MModel.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/model/MModel.h (.../MModel.h) (revision 12e7b6dda53cf8db7707c7fa55dcf6137e7d6997) @@ -5,11 +5,9 @@ * 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 MModel.h - * \author (last) Behrouz NematiPour - * \date (last) 20-Aug-2020 - * \author (original) Behrouz NemaiPour - * \date (original) 02-Jul-2020 + * \file MModel.h + * \date 3/4/2020 + * \author Behrouz NematiPour * */ #pragma once @@ -53,71 +51,128 @@ #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" ]; + * } * - * 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 + * \enddot * - * 3 - MSG Payload Len : - * Add a line in the "messageglobals.h" in payloadLen hash table - * to define the required payload length of the message + * \note + * 00 - sort .pro file after all new files added. * - * 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. + * \details + * This comment explains how to add a Denali Message in Denali UI Application * - * 5 - Register Model : - * Add the required lines like the other models in the mmodel.h file. + * Model : * - * 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; + * 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 * - * Model::MPressureOcclusion mData; - * ok = mData.fromByteArray(vMessage.data); - * LOG_DATUM("HD," + mData.toString()); + * 02 - MessageGlobals.h : add len + * \code{.cpp} + * {Gui::GuiActionType::ID_HDOperationModeData , 1 * 4 }, // 1 parameter each 4bytes + * \endcode * - * mData.toVariantList(vData); - * emit didActionReceive(mData.data()); + * 03 - Implement the model by copy/paste of the closest model, fit to your need. + * \sa MHDOperationMode + * \sa MHDOperationModeData.h + * \sa MHDOperationModeData.cpp * - * return ok; - * } - * \endcode + * 04 - Added #include in MModel.h for the implemented model + * \code{.cpp} + * #include "MHDOperationModeData.h" + * \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 + * 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 * + * 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 + * + * 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 ) \ @@ -145,7 +200,7 @@ \ REGISTER_METATYPE( HDDebugTextData ) \ REGISTER_METATYPE( DGDebugTextData ) \ - /* Request */ \ + /* Request */ \ REGISTER_METATYPE( AdjustBloodDialysateRequestData ) \ REGISTER_METATYPE( AdjustDurationRequestData ) \ REGISTER_METATYPE( AdjustUltrafiltrationStateRequestData ) \ @@ -158,10 +213,11 @@ REGISTER_METATYPE( AdjustUltrafiltrationStateResponseData ) \ REGISTER_METATYPE( AdjustUltrafiltrationEditResponseData ) \ REGISTER_METATYPE( AdjustUltrafiltrationConfirmResponseData ) \ - REGISTER_METATYPE( AdjustSalineResponseData ) + REGISTER_METATYPE( AdjustSalineResponseData ) \ //===============================================================================// #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 ) \ @@ -194,17 +250,21 @@ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustDurationResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationEditResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationConfirmResponseData ) \ - ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustSalineResponseData ) + ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustSalineResponseData ) \ + // /* 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 ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationEditRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationConfirmRequestData ) \ - ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustSalineRequestData ) + ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustSalineRequestData ) \ + //===============================================================================// #define ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS \ + \ ACTION_RECEIVE_BRIDGE_DEFINITION( BloodFlowData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( DialysateFlowData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( OutletFlowData ) \ @@ -237,25 +297,30 @@ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustDurationResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationEditResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationConfirmResponseData ) \ - ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustSalineResponseData ) -// /* Request */ ---------------------------------------------------------// + ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustSalineResponseData ) \ + + #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS \ + /* Request --------------------------------------------------------- */ \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustBloodDialysateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustDurationRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustUltrafiltrationStateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustUltrafiltrationEditRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustUltrafiltrationConfirmRequestData ) \ - ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustSalineRequestData ) -// /* Request */ ----------------------- NoEmit --------------------------// + ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustSalineRequestData ) \ + + #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 ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustUltrafiltrationEditRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustUltrafiltrationConfirmRequestData ) \ - ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustSalineRequestData ) -// /* Request */ ----------------------- public --------------------------// + ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustSalineRequestData ) \ + #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 ) \ @@ -264,6 +329,7 @@ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustSalineRequestData ) //===============================================================================// #define ACTION_RECEIVE_SIGNALS \ + /* Received signals */ \ ACTION_RECEIVE_SIGNAL( BloodFlowData ) \ ACTION_RECEIVE_SIGNAL( DialysateFlowData ) \ ACTION_RECEIVE_SIGNAL( OutletFlowData ) \