Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r82bd1d24c050e79690a7f5b236e49dd7db7e2a91 -r556668d4ef26ad4afbc438cc28d397a898459084 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 82bd1d24c050e79690a7f5b236e49dd7db7e2a91) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 556668d4ef26ad4afbc438cc28d397a898459084) @@ -7,8 +7,8 @@ * * @file Reservoirs.c * -* @author (last) Dara Navaei -* @date (last) 11-May-2023 +* @author (last) Michael Garthwaite +* @date (last) 15-Jun-2023 * * @author (original) Dara Navaei * @date (original) 21-Nov-2021 @@ -106,6 +106,7 @@ static void calculateActiveReservoirCycleTime( void ); static F32 getReservoirRecirculationMaxPercent( void ); static void publishReservoirData( void ); +static BOOL isDialysateTempAlarmActive( void ); static TREATMENT_RESERVOIR_MGMT_STATE_T handleReservoirMgmtStartState( void ); static TREATMENT_RESERVOIR_MGMT_STATE_T handleReservoirMgmtDrainState( void ); @@ -420,25 +421,25 @@ static F32 getReservoirRecirculationMaxPercent( void ) { U32 targetDialysateFlowMLP = getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ); - F32 maxPercent = 0.0F; + F32 maxPercent = 0.0F; - if (RESERVOIR_FLOW_400_MLP >= targetDialysateFlowMLP) + if ( targetDialysateFlowMLP <= RESERVOIR_FLOW_400_MLP ) { maxPercent = MAX_RESERVOIR_RECIRCULATION_400_MLP; } - else if (RESERVOIR_FLOW_450_MLP >= targetDialysateFlowMLP) + else if ( targetDialysateFlowMLP <= RESERVOIR_FLOW_450_MLP ) { maxPercent = MAX_RESERVOIR_RECIRCULATION_450_MLP; } - else if (RESERVOIR_FLOW_500_MLP >= targetDialysateFlowMLP) + else if ( targetDialysateFlowMLP <= RESERVOIR_FLOW_500_MLP ) { maxPercent = MAX_RESERVOIR_RECIRCULATION_500_MLP; } - else if (RESERVOIR_FLOW_550_MLP >= targetDialysateFlowMLP) + else if ( targetDialysateFlowMLP <= RESERVOIR_FLOW_550_MLP ) { maxPercent = MAX_RESERVOIR_RECIRCULATION_550_MLP; } - else // if (RESERVOIR_FLOW_600_MLP >= targetDialysateFlowMLP) + else { maxPercent = MAX_RESERVOIR_RECIRCULATION_600_MLP; } @@ -551,6 +552,14 @@ cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML, targetFillFlowRateLPM ); } } + // If we have active dialysate temp alarms, we want to fill immediately. + else if ( TRUE == isDialysateTempAlarmActive() ) + { + if ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) + { + cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML, targetFillFlowRateLPM ); + } + } else { // Time to wait prior to next fill is depletion time - the whole group of how much time is needed to fill a reservoir + @@ -635,7 +644,7 @@ // Wait for the reservoir to settle and then send the commands to switch the active reservoir if ( ( TRUE == didTimeout( reservoirSwitchStartTimeMS, RESERVOIR_FRESH_SETTLE_TIME_MS ) ) && - ( ( dilutionLevelPct >= MAX_RESERVOIR_DILUTION ) || ( volSpentML >= (F32)FILL_RESERVOIR_TO_VOLUME_ML ) || ( getReservoirWeight( active ) > MAX_RESERVOIR_VOL_BEFORE_SWITCH_ML ) ) ) + ( ( dilutionLevelPct >= MAX_RESERVOIR_DILUTION ) || ( volSpentML >= (F32)FILL_RESERVOIR_TO_VOLUME_ML ) || ( getReservoirWeight( active ) > MAX_RESERVOIR_VOL_BEFORE_SWITCH_ML ) || ( TRUE == isDialysateTempAlarmActive() ) ) ) { DG_SWITCH_RSRVRS_CMD_T rsrvrCmd; @@ -659,6 +668,7 @@ reservoirSwitchStartTimeMS = getMSTimerCount(); state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE; + } return state; @@ -693,4 +703,26 @@ return state; } +/*********************************************************************//** + * @brief + * The isDialysateTempAlarmActive function checks for active dialysate + * temperature alarms + * @details Inputs: none + * @details Outputs: none + * @return True if dialysate temperature alarm is active. False if not. + *************************************************************************/ +static BOOL isDialysateTempAlarmActive( void ) +{ + BOOL result = FALSE; + if ( ( TREATMENT_STOP_STATE == getTreatmentState() ) && + ( TRUE == isAlarmConditionDetected( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP ) || + TRUE == isAlarmConditionDetected( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP ) || + TRUE == isAlarmConditionDetected( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ) ) ) + { + result = TRUE; + } + + return result; +} + /**@}*/