/*! * * Copyright (c) 2021-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 MAdjustRequestsBase.h * \author (last) Behrouz NematiPour * \date (last) 22-Jul-2022 * \author (original) Behrouz NematiPour * \date (original) 22-Mar-2021 * */ #pragma once // Qt #include //project #include "MessageGlobals.h" #define ROUND_FLOATS using namespace Gui; namespace Model { /*! * Simple request models * These are models to send the request for the doAdjustment * The the only reason thy have been defined to help overloading the adjustment methods * Otherwise the parameters are so tiny models. */ class MModel { protected: /*! * \brief toString * \details the global toString function for all the request message models * which is mainly used for logging and debugging. * \param vStringPrefix - a prefix string to be inserted after senderID (UI) and parameter values list. * This is comma separated. * \param vParameters - list of parameter values of the model as a comma separated string. * \return QString */ static QString toString (const QString &vStringPrefix, const QVariantList &vParameters) { const char delimiter = ','; quint8 precision = 3; QString senderID = "UI,"; QString mString = senderID + vStringPrefix; for( const auto ¶meter : vParameters ) { if (parameter.typeId() == QMetaType::Float) // Qt has a mixed definition of QVariant::Type and QMetaType seems like a not fixed issue. #ifdef ROUND_FLOATS mString += delimiter + QString("%1").arg(parameter.toFloat(),0,'f',precision); #else mString += _delimiter + parameter.toString(); #endif else mString += delimiter + parameter.toString(); } return mString; } public: /*! * \brief canid returns the default channel id of the message. * it can be modified by the specific message which inherits the MModel. * \return Can::Can_Id */ static Can::Can_Id canid () { return Can::Can_Id::eChlid_UI_TD; } }; }