Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -re0cdf49eb0f54239e5d765282e0952cea7ded1bd -rb8a409a6f04c2912cb20eb4c9191bff573080162 --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision e0cdf49eb0f54239e5d765282e0952cea7ded1bd) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision b8a409a6f04c2912cb20eb4c9191bff573080162) @@ -81,19 +81,19 @@ // ********** private data ********** -static DG_FLUSH_STATE_T flushState = DG_FLUSH_STATE_START; ///< Current active flush state. -static DG_FLUSH_STATE_T prevFlushState = DG_FLUSH_STATE_START; ///< Previous flush state. -static DG_FLUSH_UI_STATE_T flushUIState = FLUSH_UI_STATE_NOT_RUNNING; ///< Current UI flush state. -static U32 rsrvrFillStableTimeCounter = 0; ///< Reservoirs fill stable time counter. -static U32 overallFlushElapsedTimeStart = 0; ///< Overall flush mode elapsed time start. -static U32 stateTimerStart = 0; ///< State timer start. +static DG_FLUSH_STATE_T flushState; ///< Current active flush state. +static DG_FLUSH_STATE_T prevFlushState; ///< Previous flush state. +static DG_FLUSH_UI_STATE_T flushUIState; ///< Current UI flush state. +static U32 rsrvrFillStableTimeCounter; ///< Reservoirs fill stable time counter. +static U32 overallFlushElapsedTimeStart; ///< Overall flush mode elapsed time start. +static U32 stateTimerStart; ///< State timer start. static ALARM_ID_T alarmDetectedPendingTrigger; ///< Alarm ID that is detected and is pending to be triggered. -static DG_RESERVOIR_STATUS_T rsrvr1Status = NUM_OF_DG_RESERVOIR_STATUS; ///< Reservoir 1 status. -static DG_RESERVOIR_STATUS_T rsrvr2Status = NUM_OF_DG_RESERVOIR_STATUS; ///< Reservoir 2 status. -static BOOL isThisInitialDrain = TRUE; ///< Initial drain boolean flag. -static U32 dataPublishCounter = 0; ///< Flush data publish counter. -static BOOL hasWaterCancellationBeenSet = FALSE; ///< Water cancellation set/not set boolean flag. -static F32 flushLinesVolumeL = 0.0; ///< Volume of water pumped by RO pump during flush lines state. +static DG_RESERVOIR_STATUS_T rsrvr1Status; ///< Reservoir 1 status. +static DG_RESERVOIR_STATUS_T rsrvr2Status; ///< Reservoir 2 status. +static BOOL isThisInitialDrain; ///< Initial drain boolean flag. +static U32 dataPublishCounter; ///< Flush data publish counter. +static BOOL hasWaterCancellationBeenSet; ///< Water cancellation set/not set boolean flag. +static F32 flushLinesVolumeL; ///< Volume of water pumped by RO pump during flush lines state. static BOOL haveDrainParamsBeenInit; ///< Boolean flag to indicate whether the drain parameters have been reset or not. // ********** private function prototypes ********** @@ -117,6 +117,7 @@ static DG_RESERVOIR_STATUS_T getRsrvrFillStatus( DG_RESERVOIR_ID_T r, F32 targetVol, U32 timeout ); static DG_RESERVOIR_STATUS_T getRsrvrDrainStatus( DG_RESERVOIR_ID_T r, U32 drainSteadyStateTimeout, U32 timeout ); static void publishFlushData( void ); +static void monitorModeFlush( void ); /*********************************************************************//** * @brief @@ -125,7 +126,7 @@ * @details Outputs: flushState, prevFlushState, rsrvrFillStableTimeCounter, * overallFlushElapsedTime, isThisInitialDrain, dataPublishCounter, * rsrvr1Status, rsrvr2Status, hasWaterCancellationBeenSet, - * flushLinesVolumeL, haveDrainParamsBeenInit + * flushLinesVolumeL, haveDrainParamsBeenInit, stateTimerStart * @return none *************************************************************************/ void initFlushMode( void ) @@ -143,6 +144,7 @@ hasWaterCancellationBeenSet = FALSE; flushLinesVolumeL = 0.0; haveDrainParamsBeenInit = FALSE; + stateTimerStart = 0; } /*********************************************************************//** @@ -171,6 +173,8 @@ *************************************************************************/ U32 execFlushMode( void ) { + monitorModeFlush(); + // Execute current flush state switch ( flushState ) { @@ -868,6 +872,12 @@ // Raise the alarm failFlushMode(); + + // If the caps alarm was active, clear it at the of the cancel water path + if ( TRUE == isAlarmActive( ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION ) ) + { + clearAlarmCondition( ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION ); + } } } else if ( DG_RESERVOIR_NOT_REACHED_TARGET == rsrvr1Status ) @@ -1028,4 +1038,28 @@ } } +/*********************************************************************//** + * @brief + * The monitorModeFlush function monitors the status of the caps and sets the + * state of the state machine to water cancellation path if the caps are not + * closed during the run. + * @details Inputs: none + * @details Outputs: prevFlushState, flushState, alarmDetectedPendingTrigger + * @return: none + *************************************************************************/ +static void monitorModeFlush( void ) +{ + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + // Set the variables to fail and go to cancel water path. Set the pending alarm to no alarm so the cancel water path + // will not be raising the alarm at end of the cancel water path. The recoverable alarm is raised here in this function + U32 cap = (U32)( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ? CONCENTRATE_CAP : DIALYSATE_CAP ); + prevFlushState = flushState; + flushState = DG_FLUSH_STATE_CANCEL_WATER_PATH; + alarmDetectedPendingTrigger = ALARM_ID_NO_ALARM; + + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION, cap ) + } +} + /**@}*/