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