Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r3e5c16b70fb34da7d58f5cf6efff896fdb3d00c3 -ra0c1350fb3266a722f91298dde1e97876081cd2e --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 3e5c16b70fb34da7d58f5cf6efff896fdb3d00c3) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision a0c1350fb3266a722f91298dde1e97876081cd2e) @@ -94,8 +94,7 @@ static U32 dataPublishCounter; ///< used to schedule reservoir data publication to CAN bus. static OVERRIDE_U32_T activeReservoir = { 0, 0, 0, 0 }; ///< The active reservoir that the DG is filling/draining/etc. -static OVERRIDE_U32_T fillVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir fill volume (in mL). - +static OVERRIDE_U32_T fillVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir fill volume (in mL). static OVERRIDE_U32_T drainVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir drain volume (in mL). /// The reservoirs' associate load cell. @@ -617,6 +616,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 @@ -834,8 +848,15 @@ F32 loadcellWeight1 = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); F32 loadcellWeight2 = getLoadCellSmallFilteredWeight( redundantLoadCell[ reservoirId ] ); U32 targetFillVolume = getU32OverrideValue( &fillVolumeTargetMl ); - BOOL hasTargetReached = ( ( loadcellWeight1 >= targetFillVolume || loadcellWeight2 > ( targetFillVolume + MAX_REDUNDANT_LOAD_CELL_DIFF ) ) ? TRUE : FALSE ); + BOOL hasTargetReached = FALSE; + if ( DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL == getCurrentGenIdleBadFillState() ) + { + targetFillVolume = BAD_FLUSH_FILL_TARGET_VOLUME_ML; + } + + hasTargetReached = ( ( loadcellWeight1 >= targetFillVolume || loadcellWeight2 > ( targetFillVolume + MAX_REDUNDANT_LOAD_CELL_DIFF ) ) ? TRUE : FALSE ); + // if redundant load cells too far apart at end of fill, alarm if ( loadcellWeight1 < targetFillVolume ) { @@ -847,16 +868,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 +928,36 @@ /*********************************************************************//** * @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 ) +{ + // NOTE: this function is used for testing only. No timeout is implemented right now. + 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; + } + } + + return result; +} + +/*********************************************************************//** + * @brief * The tareLoadCellsAtEmpty function tares the load cells for the given * reservoir when empty and tare request is pending. * @details Inputs: tareLoadCellRequest @@ -917,7 +967,7 @@ *************************************************************************/ void tareLoadCellsAtEmpty( DG_RESERVOIR_ID_T reservoirId ) { - U32 const targetDrainVolume = getU32OverrideValue( &drainVolumeTargetMl ); + U32 targetDrainVolume = getU32OverrideValue( &drainVolumeTargetMl ); if ( TRUE == tareLoadCellRequest ) {