Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -r5315092604c1a6f4ec8ba1339809bd0099f921da -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 5315092604c1a6f4ec8ba1339809bd0099f921da) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -1364,7 +1364,7 @@ static DG_RESERVOIR_STATUS_T getRsrvrDrainStatus( DG_RESERVOIR_ID_T r, U32 drainSteadyStateTimeout, U32 timeout ) { DG_RESERVOIR_STATUS_T status = DG_RESERVOIR_ABOVE_TARGET; - BOOL isDrainComplete = hasTargetDrainVolumeBeenReached( r, drainSteadyStateTimeout ); + BOOL isDrainComplete = hasTargetDrainToZeroBeenReached( r, drainSteadyStateTimeout ); // If the drain parameters of the reservoir is not initialized, initialize them if ( FALSE == haveDrainParamsBeenInit[ r ] ) Index: firmware/App/Modes/ModeChemicalDisinfectFlush.c =================================================================== diff -u -r5315092604c1a6f4ec8ba1339809bd0099f921da -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Modes/ModeChemicalDisinfectFlush.c (.../ModeChemicalDisinfectFlush.c) (revision 5315092604c1a6f4ec8ba1339809bd0099f921da) +++ firmware/App/Modes/ModeChemicalDisinfectFlush.c (.../ModeChemicalDisinfectFlush.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -945,7 +945,7 @@ // NOTE: the drain status should be checked once the reservoirs parameters are initialized. This is to make sure the // the timers for stable drain time are initialized prior to using them again - isDrainComplete = hasTargetDrainVolumeBeenReached( r, drainSteadyStateTimeout ); + isDrainComplete = hasTargetDrainToZeroBeenReached( r, drainSteadyStateTimeout ); if ( TRUE == isDrainComplete ) { Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r67da3f0d10e1143173b1e8c29061097d609d8623 -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 67da3f0d10e1143173b1e8c29061097d609d8623) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -247,9 +247,20 @@ { DG_DRAIN_STATE_T result = DG_DRAIN_STATE_DRAIN; DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); + U32 targetVolumeML = getTargetDrainVolumeML(); + BOOL drainStatus = FALSE; + if ( 0 == targetVolumeML ) + { + drainStatus = hasTargetDrainToZeroBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT_MS ); + } + else + { + drainStatus = hasTargetDrainToVolumeBeenReached( inactiveReservoir, targetVolumeML, DRAIN_WEIGHT_UNCHANGE_TIMEOUT_MS ); + } + // if we have reached our target drain to volume (by weight) or cannot drain anymore, we are done draining - go back to generation idle mode - if ( TRUE == hasTargetDrainVolumeBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT_MS ) ) + if ( TRUE == drainStatus ) { DG_ACID_CONCENTRATES_RECORD_T acid; F32 acidBottleVolML; Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -re12f1b3d41ae133bc0975fcb126e431c2bedda59 -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision e12f1b3d41ae133bc0975fcb126e431c2bedda59) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -1043,7 +1043,7 @@ // NOTE: the drain status should be checked once the reservoirs parameters are initialized. This is to make sure the // the timers for stable drain time are initialized prior to using them again - isDrainComplete = hasTargetDrainVolumeBeenReached( r, drainSteadyStateTimeout ); + isDrainComplete = hasTargetDrainToZeroBeenReached( r, drainSteadyStateTimeout ); if ( TRUE == isDrainComplete ) { Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r5315092604c1a6f4ec8ba1339809bd0099f921da -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 5315092604c1a6f4ec8ba1339809bd0099f921da) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -1700,7 +1700,7 @@ // NOTE: the drain status should be checked once the reservoirs parameters are initialized. This is to make sure the // the timers for stable drain time are initialized prior to using them again - isDrainComplete = hasTargetDrainVolumeBeenReached( r, drainSteadyStateTimeout ); + isDrainComplete = hasTargetDrainToZeroBeenReached( r, drainSteadyStateTimeout ); if ( TRUE == isDrainComplete ) { Index: firmware/App/Modes/ModeHeatDisinfectActiveCool.c =================================================================== diff -u -re12f1b3d41ae133bc0975fcb126e431c2bedda59 -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Modes/ModeHeatDisinfectActiveCool.c (.../ModeHeatDisinfectActiveCool.c) (revision e12f1b3d41ae133bc0975fcb126e431c2bedda59) +++ firmware/App/Modes/ModeHeatDisinfectActiveCool.c (.../ModeHeatDisinfectActiveCool.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -390,7 +390,7 @@ // NOTE: the drain status should be checked once the reservoirs parameters are initialized. This is to make sure the // the timers for stable drain time are initialized prior to using them again - isDrainComplete = hasTargetDrainVolumeBeenReached( rsrvrID, drainSteadyTimeoutMS ); + isDrainComplete = hasTargetDrainToZeroBeenReached( rsrvrID, drainSteadyTimeoutMS ); if ( TRUE == isDrainComplete ) { Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -re58e3385eaf5e920335f963937b2e9f654a32cfe -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision e58e3385eaf5e920335f963937b2e9f654a32cfe) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -617,6 +617,21 @@ /*********************************************************************//** * @brief + * The getTargetDrainVolumeML function returns the target drain volume + * in milliliters. + * @details Inputs: drainVolumeTargetMl + * @details Outputs: none + * @return target drain volume in milliliters + *************************************************************************/ +U32 getTargetDrainVolumeML( void ) +{ + U32 targetDrainVolML = getU32OverrideValue( &drainVolumeTargetMl ); + + return targetDrainVolML; +} + +/*********************************************************************//** + * @brief * The setDialysateHeatingParameters function sets the dialysate heating * parameters. * @details Inputs: none @@ -847,16 +862,15 @@ /*********************************************************************//** * @brief - * The hasTargetDrainVolumeReached function checks if the target drain volume - * for specific reservoir has been reached or exceed time limit. - * @details Inputs: reservoirWeightUnchangeStartTime, reservoirWeightUnchangeStartTime - * @details Outputs: reservoirWeightUnchangeStartTime, tareLoadCellRequest, - * reservoirWeightUnchangeStartTime + * The hasTargetDrainToZeroBeenReached function checks if the specific + * reservoir has been drained to zero or it has exceeded the time limit. + * @details Inputs: reservoirWeightUnchangeStartTime, associatedLoadCell + * @details Outputs: reservoirWeightUnchangeStartTime, tareLoadCellRequest * @param reservoirId reservoir id * @param timeout timeout period when weight remains the same * @return TRUE if target drain volume has been reached or exceeds time limit, FALSE if not. *************************************************************************/ -BOOL hasTargetDrainVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 timeout ) +BOOL hasTargetDrainToZeroBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 timeout ) { BOOL result = FALSE; F32 loadcellWeightML = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); @@ -908,6 +922,46 @@ /*********************************************************************//** * @brief + * The hasTargetDrainVolumeReached function checks if the target drain volume + * for specific reservoir has been reached or exceeded time limit. + * @details Inputs: reservoirWeightUnchangeStartTime, associatedLoadCell + * @details Outputs: reservoirWeightUnchangeStartTime + * @param reservoirId reservoir id + * @param targetVolumeML target volume to be drained to in milliliters + * @param timeoutMS timeout period when weight remains the same in milliseconds + * @return TRUE if target drain volume has been reached or exceeds time + * limit, FALSE if not. + *************************************************************************/ +BOOL hasTargetDrainToVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 targetVolumeML, U32 timeoutMS ) +{ + BOOL result = FALSE; + F32 loadcellWeightML = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); + U32 drainPumpFeedbackRPM = getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ); + + if ( drainPumpFeedbackRPM > 0 ) + { + if ( loadcellWeightML < (F32)targetVolumeML ) + { + result = TRUE; + } + + if ( 0 == reservoirWeightUnchangeStartTime[ reservoirId ] ) + { + // This function is only used when drain is done to a non-zero target which is for testing only so using + // the current available variables was used. + reservoirWeightUnchangeStartTime[ reservoirId ] = getMSTimerCount(); + } + else if ( TRUE == didTimeout( reservoirWeightUnchangeStartTime[ reservoirId ], timeoutMS ) ) + { + result = TRUE; + } + } + + return result; +} + +/*********************************************************************//** + * @brief * The tareLoadCellsAtEmpty function tares the load cells for the given * reservoir when empty and tare request is pending. * @details Inputs: tareLoadCellRequest Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -re12f1b3d41ae133bc0975fcb126e431c2bedda59 -rbec5bb7634100c96341d19cf89e540a01aa86b1d --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision e12f1b3d41ae133bc0975fcb126e431c2bedda59) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) @@ -111,6 +111,7 @@ void setDialysateHeatingParameters( DG_CMD_DIALYSATE_HEATING_PARAMS_T params ); U32 getTargetFillVolumeML( void ); F32 getTargetFillFlowRateLPM( void ); +U32 getTargetDrainVolumeML( void ); F32 getPrimaryHeaterTargetTemperature( void ); F32 getReservoirCurrentTemperature( void ); F32 getTargetDialysateFlowLPM( void ); @@ -122,7 +123,8 @@ void getFillChemicalCondRecord( DG_CHEMICALS_FILL_COND_CAL_RECORD_T* fillRecord ); BOOL hasTargetFillVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId ); -BOOL hasTargetDrainVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 timeout ); +BOOL hasTargetDrainToZeroBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 timeout ); +BOOL hasTargetDrainToVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 targetVolumeML, U32 timeoutMS ); void tareLoadCellsAtEmpty( DG_RESERVOIR_ID_T reservoirId ); BOOL isReservoirTarePending( void ); void initDrainParameters( DG_RESERVOIR_ID_T reservoirId );