Index: sources/model/MAbstract.h =================================================================== diff -u -r84c5373209a1a488c00917995f5553d442d159a4 -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/model/MAbstract.h (.../MAbstract.h) (revision 84c5373209a1a488c00917995f5553d442d159a4) +++ sources/model/MAbstract.h (.../MAbstract.h) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2024 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 MAbstract.h - * \author (last) Behrouz NematiPour - * \date (last) 20-Aug-2020 - * \author (original) Behrouz NemaiPour - * \date (original) 02-Jul-2020 + * \file MAbstract.h + * \author (last) Behrouz NematiPour + * \date (last) 04-Aug-2021 + * \author (original) Behrouz NemaiPour + * \date (original) 02-Jul-2020 * */ @@ -24,8 +24,8 @@ namespace Model { /*! - * \page GeneralModelsDescription General Models Description - * The Models are the entities which keep the data and methods to manipulate the data. + * \page GeneralModelsDescription General Models Description + * The Models are the entities which keep the data and methods to manipulate the data. * The UI Application is using different types of models in different situations. * One use case, as the Denali Device is using the Denali Message Protocol over the CANBus for all the messaging transactions * and almost all the Messages carrying data payloads of a model object for each message, @@ -57,7 +57,7 @@ private: const char _delimiter = ','; - quint8 _precision = 2; + quint8 _precision = 3; public: enum class Type_Enum { @@ -69,21 +69,41 @@ eUI, eHD, eDG, + eDV, }; private: - const QMap _typeText { - {Type_Enum::eDatum, "D"}, - {Type_Enum::eEvent, "E"} - }; + typedef QMap TypeMap; + static const TypeMap _typeText; + static const TypeMap _typeText_make() { + static const TypeMap map { + {MAbstract::Type_Enum::eDatum, "D"}, + {MAbstract::Type_Enum::eEvent, "E"} + }; + return map; + } - const QMap _unitText { - {Unit_Enum::eUI, "UI"}, - {Unit_Enum::eHD, "HD"}, - {Unit_Enum::eDG, "DG"} - }; + typedef QMap UnitMap; + static const UnitMap _unitText; + static const UnitMap _unitText_make() { + static const UnitMap map { + {MAbstract::Unit_Enum::eUI, "UI"}, + {MAbstract::Unit_Enum::eHD, "HD"}, + {MAbstract::Unit_Enum::eDG, "DG"}, + {MAbstract::Unit_Enum::eDV, "DV"} + }; + return map; + } public: + static const QString unitText(const Unit_Enum &vEnum) { + return _unitText[vEnum]; + } + static const QString typeText(const Type_Enum &vEnum) { + return _typeText[vEnum]; + } + + // the model needs to implement these since each model have different meaning of the bytes from different source(unit). /*! @@ -99,24 +119,31 @@ * \details type of the model which can be Data or Event which is mostly used in logging. * \return Enum of Types */ - virtual Type_Enum typeText ( ) const = 0; + virtual Type_Enum typeText () const = 0; /*! * \brief unitText * \details the unit which UI communicates with by using this model and is used in Logging mostly * \return Enum of Units */ - virtual Unit_Enum unitText ( ) const = 0; + virtual Unit_Enum unitText () const = 0; /*! * \brief infoText * \details the text description of the model which will be used in the logging. * \return QString */ - virtual QString infoText ( ) const = 0; + virtual QString infoText () const = 0; /*! * \brief parameters * \return current data values of the models. */ - virtual QVariantList parameters ( ) const = 0; + virtual QVariantList parameters () const = 0; + /*! + * \brief size + * \return This has to be implemented in each child to return the message payload length. + */ + // TODO : The message length can be get from the model itself but currently we have an enum for that. + // It needs work and will be done later. + // virtual quint32 size () const = 0; // Non-virtual methods which working with parameters virtual method. void toVariantList(QVariantList &vData) const;