Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -rbec5bb7634100c96341d19cf89e540a01aa86b1d -r7e1358a440116fedad5a049d49c2d6f9be85d60e --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 7e1358a440116fedad5a049d49c2d6f9be85d60e) @@ -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. @@ -367,9 +366,13 @@ // validate parameters if ( fillToVolMl < MAX_FILL_VOLUME_ML ) { - fillVolumeTargetMl.data = fillToVolMl; - cmdResponse.rejected = FALSE; + if ( getCurrentGenIdleBadFillState() != DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN ) + { + fillVolumeTargetMl.data = fillToVolMl; + } + cmdResponse.rejected = FALSE; + if ( ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || // reject moving to fill mode if ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) // alarm is active { @@ -849,8 +852,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 ) { @@ -934,6 +944,7 @@ *************************************************************************/ 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 ); @@ -944,17 +955,6 @@ { 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;