Index: sources/canbus/messageglobals.h =================================================================== diff -u -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 -radf89000bad1a50ec33114ea76d65621a1d351d5 --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision adf89000bad1a50ec33114ea76d65621a1d351d5) @@ -1,15 +1,16 @@ /*! - * + * * 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 - * + * \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 + * \author (last) Behrouz NematiPour + * \date (last) 20-Aug-2020 + * \author (original) Behrouz NematiPour + * \date (original) 06-Dec-2019 + * */ #pragma once @@ -42,15 +43,88 @@ * So the data collector has to collect this amount of bytes as payload of a message. */ const QHash payloadLen { - {Gui::GuiActionType::PowerOff , 1 }, - {Gui::GuiActionType::PowerOffBroadcast , 0 }, - {Gui::GuiActionType::KeepAlive , 255 }, // 0 => 255 to be able to run a multi-frame test. - {Gui::GuiActionType::BloodFlow , 7 * 4 }, // 7 parameters each 4bytes - {Gui::GuiActionType::DialysateInletFlow , 7 * 4 }, // 7 parameters each 4bytes - {Gui::GuiActionType::DialysateOutletFlow, 7 * 4 }, // 7 parameters each 4bytes - {Gui::GuiActionType::TreatmentTime , 3 * 4 }, // 3 parameters each 4bytes - {Gui::GuiActionType::String , 255 }, - {Gui::GuiActionType::Acknow , 0 }, + // ---- + {Gui::GuiActionType::ID_PowerOff , 1 }, + {Gui::GuiActionType::ID_ShuttingDown , 0 }, + {Gui::GuiActionType::ID_KeepAlive , 255 }, // 0 => 255 to be able to run a multi-frame test. + + // ----- + {Gui::GuiActionType::ID_TreatmentTime , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_BloodFlow , 7 * 4 }, // 7 parameters each 4bytes + {Gui::GuiActionType::ID_DialysateInletFlow , 7 * 4 }, // 7 parameters each 4bytes + {Gui::GuiActionType::ID_DialysateOutletFlow , 7 * 4 }, // 7 parameters each 4bytes + {Gui::GuiActionType::ID_PressureOcclusion , 5 * 4 }, // 5 parameters each 4bytes + {Gui::GuiActionType::ID_Saline , 3 * 4 }, // 3 parameters each 4bytes + + // ---- + {Gui::GuiActionType::ID_HDOperationModeData , 1 * 4 }, // 1 parameter each 4bytes + + // ---- + {Gui::GuiActionType::ID_DGROPumpData , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_DGPressuresData , 4 * 4 }, // 4 parameters each 4bytes + {Gui::GuiActionType::ID_DGDrainPumpData , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_DGOperationModeData , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_DGReservoirData , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_DGValvesStatesData , 1 * 2 }, // 1 parameters each 2bytes + {Gui::GuiActionType::ID_DGHeatersData , 3 * 4 }, // 3 parameters each 4bytes + {Gui::GuiActionType::ID_DGLoadCellReadingsData , 4 * 4 }, // 4 parameters each 4bytes + {Gui::GuiActionType::ID_DGTemperaturesData , 12 * 4 }, // 12 parameters each 4bytes + + // ---- + {Gui::GuiActionType::ID_AlarmStatus , 4 * 4 + 2 }, // 4 parameters each 4bytes + 1 parameter 2bytes + {Gui::GuiActionType::ID_AlarmTriggered , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AlarmCleared , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AlarmSilenceReq , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AlarmUserAckReq , 1 * 4 }, // 1 parameter each 4bytes + + // ---- + {Gui::GuiActionType::ID_StartTreatmentReq , 1 * 4 }, // 1 parameters each 4bytes + {Gui::GuiActionType::ID_StartTreatmentRsp , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_ConfirmTreatmentReq , 0 }, + {Gui::GuiActionType::ID_EndTreatmentReq , 0 }, + + // ---- + {Gui::GuiActionType::ID_TreatmentRanges , 6 * 4 }, // 6 parameters each 4bytes + {Gui::GuiActionType::ID_TreatmentStates , 3 * 4 }, // 3 parameters each 4bytes + + // ---- + {Gui::GuiActionType::ID_AdjustBloodDialysateReq , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_AdjustBloodDialysateRsp , 4 * 4 }, // 4 parameters each 4bytes + + // ---- + {Gui::GuiActionType::ID_AdjustDurationReq , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AdjustDurationRsp , 4 * 4 }, // 4 parameters each 4bytes + + // ---- + {Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq , 1 * 4 }, // 1 parameter each 4bytes + + // ---- + {Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp , 8 * 4 }, // 8 parameters each 4bytes + + // --- + {Gui::GuiActionType::ID_CreateTreatmentReq , 17 * 4 }, // 17 parameters, each 4 bytes + {Gui::GuiActionType::ID_CreateTreatmentRsp , 18 * 4 }, // 18 parameters, each 4 bytes + + // ---- + {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp , 5 * 4 }, + + // ---- + {Gui::GuiActionType::ID_PrimingData , 3 * 4 }, // 3 parameters each 4bytes + // ---- + {Gui::GuiActionType::ID_AdjustSalineReq , 1 * 4 }, // 1 parameter each 4bytes + {Gui::GuiActionType::ID_AdjustSalineRsp , 3 * 4 }, // 3 parameters each 4bytes + + // ---- + {Gui::GuiActionType::ID_CANBusFaultCount , 1 }, + {Gui::GuiActionType::ID_RawData , 255 }, + {Gui::GuiActionType::ID_Acknow , 0 }, + {Gui::GuiActionType::ID_AcknowGeneric , 1 }, + + {Gui::GuiActionType::ID_HDDebugText , 40 + 1 }, // ASCII text - 40 bytes + null term + {Gui::GuiActionType::ID_DGDebugText , 40 + 1 }, // ASCII text - 40 bytes + null term + }; /*! @@ -110,7 +184,7 @@ eChlid_UI_HD = 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_DG_UI = 0x070, ///< DG => UI eChlid_UI_DG = eChlid_UI_Sync , ///< No direct channel has been defined between DG&UI, May be required for logging }; @@ -121,18 +195,31 @@ struct Message { // TODO : Should be converted to MessageModel class // no time left for now !!! Can_Id can_id; Sequence sequence = 0; // seq 0 is invalid - Gui::GuiActionType actionId = Gui::GuiActionType::Unknown; + Gui::GuiActionType actionId = Gui::GuiActionType::ID_Unknown; int length = 0; QByteArray head; QByteArray data; bool initialized = false; - bool isEmpty () { return !initialized || !data.length(); } - bool isComplete() { return !isEmpty() && data.length() == length; } + bool isEmpty () { + // coco begin validated:Has been validated manually. + // Since the crc is part of the data and there is no message without crc + // initialized flag and data.length() == 0 became the same. + // It's been preferred too keep it as it is so the initialization would be independent of the data. + return !initialized || !data.length(); + // coco end + } + bool isComplete() { + // coco begin validated:Has been validated manually. + // Since the crc is part of the data and there is no message without crc + // then a message would never be empty. + // I prefer too keep it as it is so the initialization would be independent of the data. + return !isEmpty() && data.length() == length; + // coco end + } }; typedef QList MessageList; typedef QList FrameList; - }