/************************************************************************** * * Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. * * 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 Messaging.h * * @author (last) Sean * @date (last) 30-Jul-2024 * * @author (original) Sean * @date (original) 30-Jul-2024 * ***************************************************************************/ #ifndef __MESSAGING_H__ #define __MESSAGING_H__ #include "TDCommon.h" #include "TDDefs.h" #include "MessageSupport.h" #include "MsgQueues.h" /** * @defgroup Messaging Messaging * @brief The system communication messages unit provides helper functions * for sending outgoing system message and handling incoming system messages. * * @addtogroup Messaging * @{ */ // ********** public definitions ********** #define ACK_REQUIRED TRUE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. #define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. #pragma pack(push, 1) /// Payload record structure for ACK response. typedef struct { U08 acknowledgement; ///< Acknowledgement Byte } ACK_RESPONSE_PAYLOAD_T; /// Payload record structure for off button response. typedef struct { U08 userRequest; ///< request to confirm, cancel, or reject off button request } UI_OFF_BUTTON_RESPONSE_PAYLOAD_T; #pragma pack(pop) /// Payload record structure for UI response. typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. } UI_RESPONSE_PAYLOAD_T; /// Payload record structure for UF change response. typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. F32 ufVolume; ///< UF Volume in mL. U32 durationInMinutes; ///< new Treatment duration in minutes. S32 timeDiff; ///< Treatment duration difference. F32 ufRate; ///< new UF rate in mL/min. F32 rateDiff; ///< difference between new and old UF rates. F32 oldUFRate; ///< Previous UF Rate in mL/min. } UF_SETTINGS_CHANGE_RESPONSE_PAYLOAD_T; /// Payload record structure for UF change confirmation response. typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. F32 volume; ///< UF Volume in mL. U32 duration; ///< Treatment duration in minutes F32 ufRate; ///< UF rate in mL. } UF_SETTINGS_CONFIRMATION_RESPONSE_PAYLOAD_T; /// Payload record structure for treatment duration change response. typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. U32 duration; ///< Treatment duration in minutes F32 volume; ///< UF Volume in mL. } TREATMENT_TIME_CHANGE_RESPONSE_PAYLOAD_T; /// Payload record structure for blood / dialysate rate change response. typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. U32 bloodRate; ///< new blood flow rate U32 dialRate; ///< new dialysate flow rate } BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T; /// Payload record structure for treatment parameter broadcast messages. typedef struct { U32 minTreatmentTime; ///< Minimum treatment duration (in minutes) U32 maxTreatmentTime; ///< Maximum treatment duration (in minutes) F32 minUFVolume; ///< Minimum ultrafiltration volume (in mL) F32 maxUFVolume; ///< Maximum ultrafiltration volume (in mL) U32 minDialRate; ///< Minimum dialysate flow rate (in mL/min) U32 maxDialRate; ///< Maximum dialysate flow rate (in mL/min) } TREATMENT_PARAM_BROADCAST_PAYLOAD_T; typedef struct { U32 minBloodFlowMLPM; ///< Min blood flow in mL/min. U32 maxBloodFlowMLPM; ///< Max blood flow in mL/min. U32 minDialysateFlowMLPM; ///< Min dialysate flow in mL/min. U32 maxDialysateFlowMLPM; ///< Max dialysate flow in mL/min. U32 minTxDurationMIN; ///< Min treatment duration in minutes. U32 maxTxDurationMIN; ///< Max treatment duration in minutes. U32 minStopHeparinDispBeforeTxEndMIN; ///< Min stop heparin dispense before treatment end in minutes. U32 maxStopHeparinDispBeforeTxEndMIN; ///< Max stop heparin dispense before treatment end in minutes. U32 minSalineBolusVolumeML; ///< Min saline bolus volume in milliliters. U32 maxSalineBolusVolumeML; ///< Max saline bolus volume in milliliters. F32 minDialysateTempC; ///< Min dialysate temperature in C. F32 maxDialysateTempC; ///< Max dialysate temperature in C. S32 minArtPressLimitWindowMMHG; ///< Min arterial pressure limit window in mmHg. S32 maxArtPressLimitWindowMMHG; ///< Max arterial pressure limit window in mmHg. S32 minVenPressLimitWindowMMHG; ///< Min venous pressure limit window in mmHg. S32 maxVenPressLimitWindowMMHG; ///< Max venous pressure limit window in mmHg. S32 minVenAsymPressLimitMMHG; ///< Min venous asymmetric pressure limit in mmHg. S32 maxVenAsymPressLimitMMHG; ///< Max venous asymmetric pressure limit in mmHg. F32 minUFVolumeL; ///< Min ultrafiltration volume in mL. F32 maxUFVolumeL; ///< Max ultrafiltration volume in mL. F32 minHeparinDispRateMLPHR; ///< Min heparin dispense rate in mL/hr. F32 maxHeparinDispRateMLPHR; ///< Max heparin dispense rate in mL/hr. F32 minHeparinBolusVolumeML; ///< Min heparin bolus volume in mL. F32 maxHeparinBolusVolumeML; ///< Max heparin bolus volume in mL. U32 enableChemicalDisinfect; ///< Enable/disable chemical disinfect. } HD_INSTITUTIONAL_LOCAL_RECORD_T; // ********** public function prototypes ********** // Serialize message U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ); // ACK MSG BOOL sendACKMsg( MESSAGE_T *message ); // Handle version request message BOOL handleVersionRequestMessage( MESSAGE_T *message ); // Test Support Messaging Functions ************************** BOOL isTestingActivated( void ); void setTesterStatusToLoggedOut( void ); void handleIncomingMessage( MESSAGE_T *message ); BOOL handleUICheckIn( MESSAGE_T *message ); BOOL handleTesterLogInRequest( MESSAGE_T *message ); BOOL testTDSoftwareResetRequest( MESSAGE_T *message ); // Test send message helper functions BOOL sendEvent( TD_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ); BOOL sendOffButtonMsgToUI( U08 prompt ); BOOL testSetTestConfiguration( MESSAGE_T *message ); BOOL testGetTestConfiguration( MESSAGE_T *message ); BOOL testResetAllTestConfigurations( MESSAGE_T *message ); /**@}*/ #endif