Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -rd106a0eefd1e2ffe5873cd862ebbd53c1002de27 -rddcaa054bec161fc48d07b86c3e2550c5bb15fbe --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision d106a0eefd1e2ffe5873cd862ebbd53c1002de27) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision ddcaa054bec161fc48d07b86c3e2550c5bb15fbe) @@ -7,8 +7,8 @@ * * @file Reservoirs.c * -* @author (last) Dara Navaei -* @date (last) 19-Sep-2023 +* @author (last) Sean Nash +* @date (last) 30-Sep-2023 * * @author (original) Dara Navaei * @date (original) 21-Nov-2021 @@ -30,13 +30,18 @@ #include "TaskGeneral.h" #include "Timers.h" +/** + * @addtogroup Reservoirs + * @{ + */ + // ********** private definitions ********** #define RESERVOIR_FRESH_SETTLE_TIME_MS 15000 ///< Allocated time to settle the freshly filled reservoir in milliseconds. #define RESERVOIR_USED_SETTLE_TIME_MS 5000 ///< Allocated time to settle the depleted reservoir in milliseconds. #define RESERVOIR_CYCLE_EXTRA_MARGIN_TIME_MS 8000 ///< Reservoir extra time in during the cycle for error in milliseconds. -#define MAX_RESERVOIR_VOLUME_ML 1900.0F ///< Maximum allowed fluid in a reservoir in milliliters. +#define MAX_RESERVOIR_VOLUME_ML 1950.0F ///< Maximum allowed fluid in a reservoir in milliliters. #define MAX_RESERVOIR_DILUTION 0.15F ///< Maximum reservoir dilution limit. #define MAX_RESERVOIR_RECIRCULATION_400_MLP 1.1F ///< Maximum reservoir recirculation limit <= 400mL/m. #define MAX_RESERVOIR_RECIRCULATION_450_MLP 1.15F ///< Maximum reservoir recirculation limit <= 450mL/m. @@ -54,11 +59,6 @@ #define TGT_FILL_FLOW_800_ML_PER_MIN 0.8F ///< Target fill flow rate 800 mL/min. #define TGT_FILL_FLOW_ERROR_ALLOWANCE 0.9F ///< Target fill flow rate for dialysate allowed error percentage. -#define DIA_FLOW_TO_FILL_FLOW_SECOND_ORDER_COEFF 10.0F ///< Dialysate flow rate to fill flow rate second order coefficient. -#define DIA_FLOW_TO_FILL_FLOW_FIRST_ORDER_COEFF 7.5F ///< Dialysate flow rate to fill flow rate first order coefficient. -#define DIA_FLOW_TO_FILL_FLOW_CONSTANT 2.0F ///< Dialysate flow rate to fill flow rate constant. - -#define MAX_RESERVOIR_VOL_BEFORE_SWITCH_ML 1900.0F ///< Maximum reservoir volume before we switch reservoirs (in mL). #define FILL_VOLUME_INTERCEPT_ML_QD_ABOVE_400_MLPM 1100 ///< Fill volume intercept in milliliters for Qd above 400 mL/min. // ********** private data ********** @@ -536,7 +536,9 @@ // Check if the dilution level has exceeded the limit or the spent volume is more than the amount of volume in the reservoir // If it has, trigger the fill command. This if should not happen and the predictive dilution level should trigger just in time // in advance - if ( ( dilutionLevelPct >= MAX_RESERVOIR_DILUTION ) || ( volSpentML >= (F32)prevTargetFillVolumeML[ activeRsrvr ] ) ) + if ( ( dilutionLevelPct >= MAX_RESERVOIR_DILUTION ) || + ( volSpentML >= (F32)prevTargetFillVolumeML[ activeRsrvr ] ) || + ( TRUE == isAlarmActive( ALARM_ID_HD_ACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE ) ) ) { if ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) { @@ -607,10 +609,6 @@ // Check if DG has moved out of the fill mode if ( ( DG_MODE_GENE == dgOpMode ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) ) { - // Clear any of the recoverable conditions in case they were raised during the fill or wait to fill - clearAlarmCondition( ALARM_ID_HD_ACTIVE_RESERVOIR_RECIRCULATION_OUT_OF_RANGE ); - clearAlarmCondition( ALARM_ID_HD_ACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE ); - reservoirSwitchStartTimeMS = getMSTimerCount(); state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_FILL_SETTLE_STATE; } @@ -655,9 +653,13 @@ // Signal dialysis sub-mode to switch reservoirs signalReservoirsSwitched(); - // Get ready for the next delivery + // Reset spent volume for fresh reservoir that we've just switched to volSpentML = 0.0; + // Clear any of the recoverable conditions that were waiting for reservoir switch to allow treatment resume + clearAlarmCondition( ALARM_ID_HD_ACTIVE_RESERVOIR_RECIRCULATION_OUT_OF_RANGE ); + clearAlarmCondition( ALARM_ID_HD_ACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE ); + // Wait for used reservoir to settle reservoirSwitchStartTimeMS = getMSTimerCount(); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rb57a1e523e178cafddb96cd91388dcb60dd73497 -rddcaa054bec161fc48d07b86c3e2550c5bb15fbe --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision b57a1e523e178cafddb96cd91388dcb60dd73497) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ddcaa054bec161fc48d07b86c3e2550c5bb15fbe) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.c * -* @author (last) Vinayakam Mani -* @date (last) 30-Aug-2023 +* @author (last) Sean Nash +* @date (last) 30-Sep-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -5445,7 +5445,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetSwitchesStatusOverrideRequest function handles a * request to override the status of a switch in HD. @@ -5477,7 +5477,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleTestSwitchesPublishIntervalOverrideRequest function handles a * request to override the the switches data publish interval. Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rd106a0eefd1e2ffe5873cd862ebbd53c1002de27 -rddcaa054bec161fc48d07b86c3e2550c5bb15fbe --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision d106a0eefd1e2ffe5873cd862ebbd53c1002de27) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision ddcaa054bec161fc48d07b86c3e2550c5bb15fbe) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.h * -* @author (last) Vinayakam Mani -* @date (last) 30-Aug-2023 +* @author (last) Sean Nash +* @date (last) 30-Sep-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -65,23 +65,27 @@ #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 @@ -94,6 +98,7 @@ 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 @@ -103,6 +108,7 @@ 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 @@ -111,6 +117,7 @@ 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 @@ -119,6 +126,7 @@ U32 dialRate; ///< new dialysate flow rate } BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T; +/// Payload record structure for event messages. typedef struct { U32 event; ///< Event ID @@ -128,6 +136,7 @@ EVENT_DATAS_T data2; ///< Data field 2 } EVENT_PAYLOAD_T; +/// Payload record structure for treatment parameter broadcast messages. typedef struct { U32 minTreatmentTime; ///< Minimum treatment duration (in minutes) @@ -222,18 +231,9 @@ // MSG_ID_DG_TEMPERATURE_DATA: void handleDGTemperatureData( MESSAGE_T *message ); -// MSG_ID_RO_PUMP_DATA: -void handleROPumpData( MESSAGE_T *message ); - // MSG_ID_DG_FLOW_SENSORS_DATA void handleDialysateFlowData( MESSAGE_T *message ); -// MSG_ID_DRAIN_PUMP_DATA: -void handleDrainPumpData( MESSAGE_T *message ); - -// MSG_ID_DG_PRESSURES_DATA: -void handleDGPressuresData( MESSAGE_T *message ); - // MSG_ID_DG_RESERVOIR_DATA: void handleDGReservoirData( MESSAGE_T *message ); @@ -773,9 +773,6 @@ // MSG_ID_SUPER_CLEAR_ALARMS_CMD void handleTestSuperClearAlarmsRequest( MESSAGE_T *message ); -// MSG_ID_HD_REQUEST_CALIBRATION_DATA -void handleTestHDCalibrationDataRequest( MESSAGE_T *message ); - // MSG_ID_HD_SET_CALIBRATION_RECORD void handleSetHDCalibrationRecord( MESSAGE_T *message );