/*! * * 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 messageinterpreter.h * \date 12/11/2019 * \author Behrouz NematiPour * */ #pragma once // Qt #include // Project #include "messageglobals.h" #include "MModel.h" // forward declaration class tst_messaging; class tst_logging; namespace Can { /*! * \brief The MessageInterpreter class * \details This the class that interprets the messages to/from frames. * UI only understands GuiActionType and QVariantList data types * And CANBUS only understands QCanBusFrame with Hex values in QByteArrays * This is the class which interpret this data to/from. */ class MessageInterpreter : public QObject { Q_OBJECT // friend friend class ::tst_messaging; friend class ::tst_logging; bool isType (const Message &vMessage, Gui::GuiActionType vType) const; bool isPayloadLenValid (const Message &vMessage, Gui::GuiActionType vType) const; bool isValidMessage (const Message &vMessage, Gui::GuiActionType vType) const; void logInvalidLength (const Gui::GuiActionType &vActionId); void printUnhandled (const Message &vMessage ) const; bool prepareData (const Message &vMessage, Gui::GuiActionType vID, Model::MAbstract &vModel, QVariantList &vData ); void logReceivedMessage ( const Model::MAbstract &vModel ); bool interpretMessage_HD (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool interpretMessage_DG (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; // ----- Debug bool canbusFaultCountData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; // ----- Events // ----- - HD bool alarmStatus (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool alarmTriggered (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool alarmCleared (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; // ----- - DG // ----- Adjustments bool adjustUltrafiltrationState (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool adjustUltrafiltrationEdit (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool adjustUltrafiltrationConfirm (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; public: explicit MessageInterpreter(QObject *parent = nullptr); // interpret the data into GUI understandable Actions/Data bool interpretMessage(const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; bool interpretMessage(const Gui::GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) __attribute_warn_unused_result__; signals: ACTION_RECEIVE_SIGNALS }; }