/*! * * 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 GuiGlobals.h * \author (last) Behrouz NematiPour * \date (last) 16-Oct-2020 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #pragma once // Qt #include // Project namespace Gui { /*! * \brief The MainView class * \details A QQuickView inherited child. * Main entry of the QML. * It's not usual to inherit from QQuickView and most of the time the class QQuickView, itself, is used. * It's been inherited to grab all the events which is send/received to/from QML. * \sa VEventSpy */ class MainView : public QQuickView { Q_OBJECT bool event(QEvent* vEvent) override { emit eventSpy(vEvent); return QQuickView::event(vEvent); } signals: void eventSpy(QEvent* vEvent); }; extern MainView *_viewer; class GuiActions { Q_GADGET explicit GuiActions(); public: /*! * \brief The GuiActionsType_Enum enum * \details * *** This enum could use the Msg_IDs enum in MsgDefs.h, ***\n * *** But that enum has values in Normal (BigEndian) ***\n * *** So it has to be converted, each time it is referenced. ***\n * *** Since an enum is a constant value, ***\n * *** There is no point in calculating it on each reference. ***\n * *** Therefore it is preferred to keep them as constant values ***\n * *** Exactly as it is going to be shown/used in Denali Messages ***\n * *** then it can be compared exactly the way it is with no conversion.***\n */ enum GuiActionsType_Enum /* : quint16 QML doesn't support enum types */ { ID_Unknown = 0x0000, ID_CANBusFaultCount = 0x9909, ID_RawData = 0xFFFE, ID_Acknow = 0xFFFF, ID_AcknowGeneric = 0x0000, //< Generic Acknowledgment is not a unique message ID and inherits its Id from the actual message. Zero is a placeholder ID_HDDebugText = 0xF1FF, ID_DGDebugText = 0xF2FF, ID_DGCheckIn = 0x0600, ID_KeepAlive = 0x0700, // HD Data Messages ID_PowerOff = 0x0100, ID_ShuttingDown = 0x0E00, ID_TreatmentTime = 0x0D00, ID_BloodFlow = 0x0500, ID_DialysateInletFlow = 0x0800, ID_DialysateOutletFlow = 0x0B00, ID_TreatmentRanges = 0x1A00, // 26 ID_TreatmentStates = 0x0F00, // 15 ID_HDOperationModeData = 0x2500, // 37 ID_PressureOcclusion = 0x0900, ID_Saline = 0x2F00, // 47 ID_Heparin = 0x4D00, // 77 ID_Rinseback = 0x5600, // 86 ID_Recirculate = 0x5A00, // 90 ID_BloodPrime = 0x5900, // 89 ID_HDAccelerometerData = 0x3300, // 51 // Alarm Messages ID_AlarmStatus = 0x0200, ID_AlarmTriggered = 0x0300, ID_AlarmCleared = 0x0400, ID_AlarmClearedConditionReq = 0x3F00, // 63 // the same code is used for every unit to send and receive over the CANBus ID_AlarmClearedConditionRsp = 0x3F00, // 63 // the same code is used for every unit to send and receive over the CANBus ID_AlarmSilenceReq = 0x3200, // 50 ID_AlarmUserActionReq = 0x4000, // 64 // there is no response since it is kind of the response to the ID_AlarmStatus from UI to HD ID_AlarmVolumeSetReq = 0x4E00, // 78 ID_AlarmVolumeSetRsp = 0x7C00, // 124 // Pre-Treatment Parameters ID_TreatmentCreateReq = 0x3500, // 53 ID_TreatmentCreateRsp = 0x3600, // 54 ID_TreatmentStartReq = 0x3800, // 56 ID_TreatmentStartRsp = 0x3900, // 57 ID_TreatmentConfirmReq = 0x3B00, // 59 ID_TreatmentEndReq = 0x3C00, // 60 ID_TreatmentEndRsp = 0x3D00, // 61 ID_PrimingData = 0x4300, // 67 // DG Data Messages ID_DGROPumpData = 0x1F00, // 31 ID_DGPressuresData = 0x2000, // 32 ID_DGDrainPumpData = 0x2400, // 36 ID_DGOperationModeData = 0x2700, // 39 ID_DGReservoirData = 0x2800, // 40 ID_DGValvesStatesData = 0x2A00, // 42 ID_DGHeatersData = 0x2C00, // 44 ID_DGLoadCellReadingsData = 0x0C00, // 12 ID_DGTemperaturesData = 0x2D00, // 45 ID_DGAccelerometerData = 0x3400, // 52 // In-Treatment Adjustables ID_AdjustDurationReq = 0x1600, // 22 ID_AdjustDurationRsp = 0x1B00, // 27 ID_AdjustBloodDialysateReq = 0x1700, // 23 ID_AdjustBloodDialysateRsp = 0x1800, // 24 ID_AdjustPressuresLimitsReq = 0x4600, // 70 ID_AdjustPressuresLimitsRsp = 0x4700, // 71 ID_AdjustSalineReq = 0x1200, // 18 ID_AdjustSalineRsp = 0x1400, // 20 ID_AdjustHeparinReq = 0x4B00, // 75 ID_AdjustHeparinRsp = 0x4C00, // 76 // Ultrafiltration: has also In-Treatment Adjustables but kept together ID_AdjustUltrafiltrationInitReq = 0x4F00, // 79 ID_AdjustUltrafiltrationInitRsp = 0x5000, // 80 ID_AdjustUltrafiltrationStateReq = 0x1000, // 16 ID_AdjustUltrafiltrationStateRsp = 0x4100, // 65 ID_AdjustUltrafiltrationEditReq = 0x1100, // 17 ID_AdjustUltrafiltrationEditRsp = 0x1300, // 19 ID_AdjustUltrafiltrationConfirmReq = 0x1500, // 21 ID_AdjustUltrafiltrationConfirmRsp = 0x2E00, // 46 // post-treatment // Rinseback ID_AdjustRinsebackReq = 0x5200, // 82 ID_AdjustRinsebackRsp = 0x5300, // 83 // Recirculate ID_AdjustRecirculateReq = 0x5400, // 84 ID_AdjustRecirculateRsp = 0x5500, // 85 // Treatment End ID_AdjustTreatmentEndReq = 0x5700, // 87 ID_AdjustTreatmentEndRsp = 0x5800, // 88 // independent bidirectional ID_AdjustVersionsReq = 0x1C00, // 28 ID_AdjustServiceReq = 0x8900, // 137 ID_HDAdjustServiceRsp = 0x8A00, // 138 ID_DGAdjustServiceRsp = 0x8C00, // 140 ID_AdjustHDVersionsRsp = 0x1D00, // 29 ID_AdjustDGVersionsRsp = 0x1E00, // 30 ID_HDSerialNumberRsp = 0x8700, // 135 ID_DGSerialNumberRsp = 0x8800, // 136 // RTC ID_AdjustHDDateTimeReq = 0x6D00, // 109 ID_AdjustHDDateTimeRsp = 0x6E00, // 110 ID_AdjustDGDateTimeReq = 0x6F00, // 111 ID_AdjustDGDateTimeRsp = 0x7000, // 112 }; enum class GuiActionsData_Enum /*: quint8 QML doesn't support*/ { NoData = 0x00, Command = 0x00, // HD=>UI : should be handled in receive Request = 0x00, // UI=>HD : should be handled in transmit // UI=>HD : should be handled in transmit Accepted = 0x01, Rejected = 0x02, // Power-Off Data // HD=>UI : should be handled in receive Timeout = 0x01, }; enum AlertID { ID_Alert_None = 0, ID_Alert_BLE_Connection, ID_Alert_BLE_Measurement_Timeout, ID_Alert_Set_HD_RTC_Response, ID_Alert_Set_DG_RTC_Response }; struct AlertRequest { AlertID id; QString title; QString description; bool acknowledgeOnly; }; struct AlertResponse { AlertID id; bool confirmed = false; }; Q_ENUM(GuiActionsType_Enum) Q_ENUM(GuiActionsData_Enum) #include "AlarmDefs.h" Q_ENUM(Alarm_Priorities) Q_ENUM(Alarm_List ) Q_ENUM(Alarm_State_Flag_Bit_Positions) Q_ENUM(Alarm_User_Actions) #include "MsgDefs.h" Q_ENUM(Request_Reject_Reasons) #include "HDDefs.h" Q_ENUM(HD_Op_Modes) // Treatment Q_ENUM(Treatment_States) // Ultrafiltration Q_ENUM(UF_Adjustments) Q_ENUM(UF_Commands) Q_ENUM(UF_States) // Saline Q_ENUM(Saline_Bolus_States) Q_ENUM(Saline_Commands) // Heparin Q_ENUM(Heparin_States) Q_ENUM(Heparin_Commands) // Rinseback Q_ENUM(Rinseback_States) Q_ENUM(Requested_Rinseback_User_Actions) // Recirculate Q_ENUM(Treatment_Recirc_States) Q_ENUM(Requested_Treatment_Recirc_User_Actions) // Blood Prime Q_ENUM(Blood_Prime_States) // Treatment End Q_ENUM(Treatment_End_States) Q_ENUM(Requested_Treatment_End_User_Actions) // Treatment Stop #include "DGDefs.h" Q_ENUM(DG_Op_Modes) }; // to be able to use the enum as signal/slot parameter typedef GuiActions::GuiActionsType_Enum GuiActionType; typedef GuiActions::GuiActionsData_Enum GuiActionData; typedef GuiActions::Alarm_Priorities GuiAlarmPriority; typedef GuiActions::Alarm_List GuiAlarmID; typedef GuiActions::Alarm_State_Flag_Bit_Positions GuiAlarmFlags; typedef GuiActions::Alarm_User_Actions GuiAlarmUserActions; typedef GuiActions::Request_Reject_Reasons GuiRequestReasons; // operation mode typedef GuiActions::HD_Op_Modes GuiHDOpModes; typedef GuiActions::DG_Op_Modes GuiDGOpModes; // Treatment States typedef GuiActions::Treatment_States GuiTreatmentStates; // Ultrafiltration typedef GuiActions::UF_States GuiUFStates; typedef GuiActions::UF_Commands GuiUFCommands; typedef GuiActions::UF_Adjustments GuiUFAdjustment; // Saline typedef GuiActions::Saline_Bolus_States GuiSalineStates; typedef GuiActions::Saline_Commands GuiSalineCommands; // Heparin typedef GuiActions::Heparin_States GuiHeparinStates; typedef GuiActions::Heparin_Commands GuiHeparinCommands; // Rinseback typedef GuiActions::Rinseback_States GuiRinsebackStates; typedef GuiActions::Requested_Rinseback_User_Actions GuiRinsebackCommands; // Recirculate typedef GuiActions::Treatment_Recirc_States GuiRecirculateStates; typedef GuiActions::Requested_Treatment_Recirc_User_Actions GuiRecirculateCommands; // Blood Prime typedef GuiActions::Blood_Prime_States GuiBloodPrimeStates; // typedef GuiActions::Requested_Blood_Prime_User_Actions GuiBloodPrimeCommands; // No user Action defined // Treatment End typedef GuiActions::Treatment_End_States GuiTreatmentEndStates; typedef GuiActions::Requested_Treatment_End_User_Actions GuiTreatmentEndCommands; // Treatment Stop typedef GuiActions::Treatment_Stop_States GuiTreatmentStopStates; // typedef GuiActions::Requested_Treatment_Stop_User_Actions GuiTreatmentStopCommands; // No user Action defined typedef GuiActions::AlertID GuiAlertID; typedef GuiActions::AlertRequest GuiAlertRequestData; typedef GuiActions::AlertResponse GuiAlertResponseData; void registerTypes(); void registerQmlTypes(); bool startGui(); }