Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r43667942550fa3b57e90a0845ed2be2203743a4e -r3a007e014c41538a1256ce5f42093763db82e84d --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 43667942550fa3b57e90a0845ed2be2203743a4e) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 3a007e014c41538a1256ce5f42093763db82e84d) @@ -82,7 +82,8 @@ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ); static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( DG_GEN_IDLE_MODE_STATE_T* idleState ); -static void publishGenIdleSubstates(); +static void checkInvalidReservoirFill( void ); +static void publishGenIdleSubstates( void ); /*********************************************************************//** * @brief @@ -253,6 +254,7 @@ break; } + checkInvalidReservoirFill(); publishGenIdleSubstates(); return (U32)genIdleState; @@ -302,12 +304,7 @@ static DG_GEN_IDLE_MODE_STATE_T handleFlushWaterState( void ) { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; - DG_RESERVOIR_ID_T currentInactiveReservoir = getInactiveReservoir(); - F32 reservoirWeight = getReservoirWeight( currentInactiveReservoir ); - HD_MODE_SUB_MODE_T mode; - getHDOperationMode( &mode ); - if ( ( TRUE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || ( TRUE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) { // The empty bottle alarms are active set the empty bottle alarm to TRUE. @@ -322,19 +319,6 @@ startFillCmd( getTargetFillVolumeML(), getTargetFillFlowRateLPM() ); } - if ( currentInactiveReservoir != inactiveReservoir ) - { - // Inactive Reservoir changed, update the start value - inactiveReservoir = currentInactiveReservoir; - initialReservoirWeight = getReservoirWeight( inactiveReservoir ); - } - - // Check for unwanted filling in treatment mode - if ( ( MODE_TREA == mode.hdMode) && ( reservoirWeight > ( initialReservoirWeight + MAX_IDLE_RSVR_WEIGHT_GAIN_ML ) ) ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_INACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE, initialReservoirWeight, reservoirWeight ); - } - return result; } @@ -491,6 +475,34 @@ /*********************************************************************//** * @brief + * The checkInvalidReservoirFill function checks for reservoir filling in + * generation idle mode when it should be constant. + * @details Inputs: inactiveReservoir, initialReservoirWeight + * @details Outputs: inactiveReservoir, initialReservoirWeight + * @return the next state + *************************************************************************/ +static void checkInvalidReservoirFill( void ) +{ + DG_RESERVOIR_ID_T currentInactiveReservoir = getInactiveReservoir(); + F32 reservoirWeight = getReservoirWeight( currentInactiveReservoir ); + + if ( currentInactiveReservoir != inactiveReservoir ) + { + // Inactive Reservoir changed, update the start value + inactiveReservoir = currentInactiveReservoir; + initialReservoirWeight = getReservoirWeight( inactiveReservoir ); + } + + // Check for unwanted filling unless a transfer is in progress + if ( ( FALSE == isReservoirTransferInProgress() ) && ( reservoirWeight > ( initialReservoirWeight + MAX_IDLE_RSVR_WEIGHT_GAIN_ML ) ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_INACTIVE_RESERVOIR_WEIGHT_OUT_OF_RANGE, initialReservoirWeight, reservoirWeight ); + } + +} + +/*********************************************************************//** + * @brief * The publishGenIdleSubstates function publishes gen idle * sub-states at the set interval. * @details Inputs: handleBadFillFlag, badFillState, targetFillVolumeML,