/*! * * 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 MessageGlobals.h * date 12/6/2019 * author Behrouz NematiPour * */ #pragma once // Qt #include // Project #include "guiglobals.h" using namespace Gui; namespace Can { /*! * \brief Payload Length * \details List of each action acceptable data length in the whole message packet. */ const QHash payloadLen { // {/*GuiActionType::PowerOff*/ 0x0100, 1}, // {/*GuiActionType::Check_In*/ 0x0700, 0} {static_cast(GuiActionType::PowerOff ), 1}, {static_cast(GuiActionType::KeepAlive), 0}, {static_cast(GuiActionType::String ), 255}, }; /*! * \brief The Payload_Data enum * \details Global information for message packet. */ enum Payload_Data : quint8 { ePayload_None = 0x00, ePayload_Sync = 0xA5, }; /*! * \brief The Frame_Data enum * \details Global information for each message frame. */ enum Frame_Data : quint8 { eLenCanFrame = 8, eLenMaxHeaderData = 3, eLenMaxData = 255, eLenSyncByte = 1, eLenActionId = 2, eLenLength = 1, }; /*! * \brief The Can_Id enum * \details The Valid Can Bus Message Id of each frame */ enum Can_Id : quint16 { // Broadcasts //// Alarm eChlid_HD_Alarm = 0x001, ///< HD alarm broadcast eChlid_DG_Alarm = 0x002, ///< DG alarm broadcast eChlid_UI_Alarm = 0x004, ///< UI alarm broadcast [Out] //// Sync eChlid_HD_Sync = 0x040, ///< HD sync broadcast eChlid_DG_Sync = 0x080, ///< DG sync broadcast eChlid_UI_Sync = 0x200, ///< UI sync broadcast [Out] // UI not listening eChlid_HD_DG = 0x008, ///< HD => DG eChlid_DG_HD = 0x010, ///< DG => HD // UI is listening eChlid_HD = 0x020, ///< HD => UI eChlid_UI = 0x100, ///< UI => HD [Out] // UI lessens occasionally eChlid_DG_UI = eChlid_DG_Alarm, ///< No direct channel has been defined between DG&UI, May be required for logging eChlid_UI_DG = eChlid_UI_Sync , ///< No direct channel has been defined between DG&UI, May be required for logging }; /*! * \brief The Message struct * \details The message structure after it's been glued together. */ struct Message { // TODO : Should be converted to MessageModel GuiActionType actionId = GuiActionType::Unknown; int length = 0; QByteArray data; bool initialized = false; bool isEmpty () { return !initialized || !data.length(); } bool isComplete() { return !isEmpty() && data.length() == length; } }; typedef QList MessageList; typedef QList FrameList; }