/*! * * 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, // POST ID_HDPostSingleResultData = 0x8E00, // 142 ID_HDPostFinalResultData = 0x8F00, // 143 ID_DGPostSingleResultData = 0x9000, // 144 ID_DGPostFinalResultData = 0x9100, // 145 ID_UIPostFinalResultData = 0x9200, // 146 // ----- Settings // Version ID_AdjustVersionsUIReq = 0x1C00, // 28 ID_AdjustVersionsUIRsp = 0x9F00, // 159 // ID_UIVersionsTxr - UI Version response transmit ID_AdjustVersionsHDReq = 0x9E00, // 158 // ID_HDVersionsRxq - HD Version request received ID_AdjustVersionsHDRsp = 0x1D00, // 29 ID_AdjustVersionsDGRsp = 0x1E00, // 30 ID_AdjustSerialHDRsp = 0x9900, // 153 ID_AdjustSerialDGRsp = 0x8800, // 136 // Service Information ID_AdjustServiceReq = 0x8900, // 137 ID_AdjustServiceHDRsp = 0x8A00, // 138 ID_AdjustServiceDGRsp = 0x8C00, // 140 // RTC ID_AdjustHDDateTimeReq = 0x6D00, // 109 ID_AdjustHDDateTimeRsp = 0x6E00, // 110 ID_AdjustDGDateTimeReq = 0x6F00, // 111 ID_AdjustDGDateTimeRsp = 0x7000, // 112 // State Messages ID_HDOperationModeData = 0x2500, // 37 ID_PreTreatmentStates = 0x5C00, // 92 ID_TreatmentStates = 0x0F00, // 15 ID_PostTreatmentStates = 0x7700, // 119 ID_DisinfectStates = 0x7E00, // 129 // DG message // ----- ID_PowerOff = 0x0100, ID_ShuttingDown = 0x0E00, ID_TreatmentTime = 0x0D00, ID_BloodFlow = 0x0500, ID_DialysateInletFlow = 0x0800, ID_DialysateOutletFlow = 0x0B00, ID_TreatmentRanges = 0x1A00, // 26 ID_PressureOcclusion = 0x0900, ID_Saline = 0x2F00, // 47 ID_Heparin = 0x4D00, // 77 ID_Rinseback = 0x5600, // 86 ID_Recirculate = 0x5A00, // 90 ID_BloodPrime = 0x5900, // 89 // 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_AlarmActiveListReq = 0x9700, // 151 ID_AlarmActiveListRsp = 0x9800, // 152 ID_AlarmVolumeSetReq = 0x4E00, // 78 ID_AlarmVolumeSetRsp = 0x7C00, // 124 // Pre-Treatment // Pre-Treatment Initiate Treatment ID_AdjustInitTreatmentReq = 0x3800, // 56 ID_AdjustInitTreatmentRsp = 0x3900, // 57 // Pre-Treatment Parameters Validation/Confirm ID_AdjustParametersValidationReq = 0x3500, // 53 ID_AdjustParametersValidationRsp = 0x3600, // 54 ID_AdjustParametersConfirmReq = 0x3B00, // 59 // Pre-Treatment Water Sample ID_DGFilterFlushData = 0x6000, // 96 ID_AdjustWaterSampleReq = 0x5D00, // 93 ID_AdjustWaterSampleRsp = 0x5E00, // 94 ID_AdjustWaterSampleResultReq = 0x5F00, // 95 // there is no specific response message for this request and changing of the state in Pre_Treatment_States is used as the response // Pre-Treatment Consumables Installation Confirm ID_AdjustConsumablesConfirmReq = 0x6800, // 104 // there is no specific response message for this request and changing of the state in Pre_Treatment_States is used as the response // Pre-Treatment SelfTest NoCartridge Progress Data ID_SelfTestNoCartridgeData = 0x6100, // 97 // there is no specific response message for this request and changing of the state in Pre_Treatment_States is used as the response // Pre-Treatment Disposables Installation Confirm ID_AdjustDisposablesConfirmReq = 0x6200, // 98 // there is no specific response message for this request and changing of the state in Pre_Treatment_States is used as the response // Pre-Treatment SelfTest Dry Progress Data ID_SelfTestDryData = 0x6300, // 99 // Pre-Treatment Disposable Priming ID_AdjustDisposablesPrimeReq = 0x3C00, // 60 ID_AdjustDisposablesPrimeRsp = 0x3D00, // 61 ID_DisposablesPrimeData = 0x4300, // 67 // Pre-Treatment Patient Connection Begin ID_AdjustPatientConnectionBeginReq = 0x6400, // 100 ID_AdjustPatientConnectionBeginRsp = 0x6500, // 101 // Pre-Treatment Ultrafiltration initial volume ID_AdjustUltrafiltrationInitReq = 0x4F00, // 79 ID_AdjustUltrafiltrationInitRsp = 0x5000, // 80 // Pre-Treatment Patient Connection Confirm ID_AdjustPatientConnectionConfirmReq = 0x6600, // 102 ID_AdjustPatientConnectionConfirmRsp = 0x6700, // 103 // Pre-Treatment Start Treatment ID_AdjustStartTreatmentReq = 0x7100, // 113 ID_AdjustStartTreatmentRsp = 0x7200, // 114 // 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 // HD Data Messages ID_HDAccelerometerData = 0x3300, // 51 ID_HDSyringePumpData = 0x6900, // 105 // 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 ID_AdjustUltrafiltrationStateReq = 0x1000, // 16 ID_AdjustUltrafiltrationStateRsp = 0x4100, // 65 ID_AdjustUltrafiltrationEditReq = 0x1100, // 17 ID_AdjustUltrafiltrationEditRsp = 0x1300, // 19 ID_AdjustUltrafiltrationConfirmReq = 0x1500, // 21 ID_AdjustUltrafiltrationConfirmRsp = 0x2E00, // 46 // End-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 // Post-Treatment // Patient Disconnect ID_AdjustPatientDisconnectionConfirmReq = 0x4A00, // 74 // there is no specific response message for this request and changing of the state in Pre_Treatment_States is used as the response // Disposables Removal ID_AdjustDisposablesRemovalConfirmReq = 0x7300, // 115 ID_AdjustDisposableRemovalConfirmRsp = 0x7400, // 116 // Treatment Log Adjs ID_AdjustTreatmentLogReq = 0x7500, // 117 ID_AdjustTreatmentLogRsp = 0x7600, // 118 // Treatment Log Data ID_TreatmentLogAvrgeData = 0x9400, // 148 ID_TreatmentLogAlarmData = 0x9500, // 149 ID_TreatmentLogEventData = 0x9600, // 150 // Disinfect ID_AdjustDisinfectReq = 0x7F00, // 127 ID_AdjustDisinfectRsp = 0x8000, // 128 ID_AdjustChemicalConfirmReq = 0x8100, // 129 ID_AdjustChemicalConfirmRsp = 0x8200, // 130 ID_DisinfectDGFlushTimeData = 0x8300, // 131 ID_DisinfectDGHeatTimeData = 0x8400, // 132 ID_DisinfectDGChemicalTimeData = 0x8500, // 133 }; 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, }; 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) Q_ENUM(Alarm_Data_Types) #include "MsgDefs.h" Q_ENUM(Request_Reject_Reasons) #include "HDDefs.h" Q_ENUM(HD_POST_States) Q_ENUM(HD_Op_Modes) Q_ENUM(HD_Standby_States) // 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) // Pre-Treatment SubMode Q_ENUM(HD_Pre_Treatment_Mode_States) // Pre-Treatment Water Sample Q_ENUM(HD_Pre_Treatment_Sample_Water_States) Q_ENUM(Requested_Sample_Water_User_Actions) // Pre-Treatment Self Test Consumable Q_ENUM(HD_Pre_Treatment_Consumable_Self_Test_States) // Pre-Treatment Self Test No Cartridge Q_ENUM(HD_Pre_Treatment_No_Cart_Self_Tests_States) // Pre-Treatment Self Test Dry Q_ENUM(HD_Pre_Treatment_Dry_Self_Tests_States) // Pre-Treatment Prime Q_ENUM(HD_Pre_Treatment_Prime_States) // Pre-Treatment Recirculate Q_ENUM(HD_Pre_Treatment_Recirc_States) // Disinfection #include "DGDefs.h" Q_ENUM(DG_POST_States) Q_ENUM(DG_Op_Modes) Q_ENUM(DG_Disinfect_States) Q_ENUM(DG_Flush_UI_States) Q_ENUM(DG_Heat_UI_States) Q_ENUM(DG_Chem_UI_States) }; // 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::Alarm_Data_Types GuiAlarmDataTypes; typedef GuiActions::Request_Reject_Reasons GuiRequestReasons; // POST typedef GuiActions::HD_POST_States GuiHDPOSTStates; typedef GuiActions::DG_POST_States GuiDGPOSTStates; // operation mode typedef GuiActions::HD_Op_Modes GuiHDOpModes; typedef GuiActions::DG_Op_Modes GuiDGOpModes; typedef GuiActions::HD_Standby_States GuiHDStandbyStates; // 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 // Pre-Treatment SubMode typedef GuiActions::HD_Pre_Treatment_Mode_States GuiPreTreatmentStates; // Pre-Treatment Water Sample typedef GuiActions::HD_Pre_Treatment_Sample_Water_States GuiPreTreatmentWaterSampleStates; typedef GuiActions::Requested_Sample_Water_User_Actions GuiPreTreatmentWaterSampleCommands; // Pre-Treatment Self Test Consumable typedef GuiActions::HD_Pre_Treatment_Consumable_Self_Test_States GuiPreTreatmentSelfTestConsumablesStates; // Pre-Treatment Self Test No Cartridge typedef GuiActions::HD_Pre_Treatment_No_Cart_Self_Tests_States GuiPreTreatmentSelfTestNoCartridgeStates; // Pre-Treatment Self Test Dry typedef GuiActions::HD_Pre_Treatment_Dry_Self_Tests_States GuiPreTreatmentSelfTestDryStates; // Pre-Treatment Prime typedef GuiActions::HD_Pre_Treatment_Prime_States GuiPreTreatmentPrimeStates; // Pre-Treatment Recirculate typedef GuiActions::HD_Pre_Treatment_Recirc_States GuiPreTreatmentRecirculateStates; // Post-Treatment SubMode typedef GuiActions::HD_Post_Treatment_Mode_States GuiPostTreatmentStates; // Disinfection Heat States typedef GuiActions::DG_Disinfect_States GuiDisinfectDGStates; typedef GuiActions::DG_Flush_UI_States GuiDisinfectDGFlushStates; typedef GuiActions::DG_Heat_UI_States GuiDisinfectDGHeatStates; typedef GuiActions::DG_Chem_UI_States GuiDisinfectDGChemicalStates; /*! * \brief enumString * \details converts the enum index to it's code defined text * \note the enum has to be defined in the Qt metadata by Q_ENUM * \note the passed vEnum has to be in the type of enum and if not has to be cast by static_cast< ENUM >( VALUE ) * \param vEnum - the enum to get the name of it * \param vUndefined - the string format to be used to return if enum is undefined and the number itself is going to be returned. * \return name of the enum as string or a formatted text by vUndefined containing the enum index number. */ template QString enumString(const T_ENUM &vEnum, const char *vUndefined = nullptr) { const QMetaObject *mo = qt_getEnumMetaObject(vEnum); int enumIdx = mo->indexOfEnumerator(qt_getEnumName(vEnum)); const char *key = mo->enumerator(enumIdx).valueToKey(vEnum); if (key) { return qPrintable(key); } else { QString undefined; if ( vUndefined ) { undefined = vUndefined; if (undefined.trimmed().isEmpty()) undefined = "UNDEFINED [%1]"; } return undefined.arg(vEnum); } } void registerTypes(); void registerQmlTypes(); bool startGui(); }