Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rb8a409a6f04c2912cb20eb4c9191bff573080162 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision b8a409a6f04c2912cb20eb4c9191bff573080162) @@ -46,16 +46,19 @@ // ********** private data ********** -static DG_STANDBY_MODE_STATE_T standbyState = DG_STANDBY_MODE_STATE_START; ///< Currently active standby state. -static BOOL stopSampleWaterRequest = FALSE; ///< Flag indicating HD has requested to stop sample water -static BOOL startSampleWaterRequest = FALSE; ///< Flag indicating HD has requested to start sample water -static BOOL flushFilterRequest = FALSE; ///< Flag indicating HD has requested to flush filters -static BOOL endSampleWaterRequest = FALSE; ///< Flag indicating HD has requested to end sample water +static DG_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. +static BOOL stopSampleWaterRequest; ///< Flag indicating HD has requested to stop sample water +static BOOL startSampleWaterRequest; ///< Flag indicating HD has requested to start sample water +static BOOL flushFilterRequest; ///< Flag indicating HD has requested to flush filters +static BOOL endSampleWaterRequest; ///< Flag indicating HD has requested to end sample water -static BOOL pendingStartDGRequest = FALSE; ///< Flag indicating HD has requested DG start (go to generation idle mode). -static U32 waterSampleStartTime = 0; ///< Time stamp for start of water sample state. -static U32 filterFlushStartTime = 0; ///< Time stamp for start of filter flush state. -static U32 filterFlushPublishTimerCounter = 0; ///< Filter flush data publish timer counter. +static BOOL pendingStartDGRequest; ///< Flag indicating HD has requested DG start (go to generation idle mode). +static U32 waterSampleStartTime; ///< Time stamp for start of water sample state. +static U32 filterFlushStartTime; ///< Time stamp for start of filter flush state. +static U32 filterFlushPublishTimerCounter; ///< Filter flush data publish timer counter. +static BOOL pendingStartDGFlushRequest; ///< Flag indicating HD has requested DG start flush. +static BOOL pendingStartDGHeatDisinfectRequest; ///< Flag indicating HD has requested DG start heat disinfect. +static BOOL pendingStartDGChemicalDisinfectRequest; ///< Flag indicating HD has requested DG start chemical disinfect. static OVERRIDE_U32_T filterFlushTimePeriod = { FILTER_FLUSH_TIME_MS, FILTER_FLUSH_TIME_MS, 0, 0 }; ///< Filter flush time period in ms. @@ -78,15 +81,18 @@ *************************************************************************/ void initStandbyMode( void ) { - standbyState = DG_STANDBY_MODE_STATE_START; - stopSampleWaterRequest = FALSE; - startSampleWaterRequest = FALSE; - flushFilterRequest = FALSE; - endSampleWaterRequest = FALSE; - waterSampleStartTime = 0; - filterFlushStartTime = 0; - filterFlushPublishTimerCounter = 0; - pendingStartDGRequest = FALSE; + standbyState = DG_STANDBY_MODE_STATE_START; + stopSampleWaterRequest = FALSE; + startSampleWaterRequest = FALSE; + flushFilterRequest = FALSE; + endSampleWaterRequest = FALSE; + waterSampleStartTime = 0; + filterFlushStartTime = 0; + filterFlushPublishTimerCounter = 0; + pendingStartDGRequest = FALSE; + pendingStartDGFlushRequest = FALSE; + pendingStartDGHeatDisinfectRequest = FALSE; + pendingStartDGChemicalDisinfectRequest = FALSE; // Reset the heaters efficiency for another treatment resetHeatersEfficiency(); @@ -158,8 +164,12 @@ * @brief * The handleStandbyIdleState function executes the idle state of the * standby mode state machine. - * @details Inputs: pendingSampleWaterRequest, pendingStartDGRequest - * @details Outputs: Idle state of the standby mode executed + * @details Inputs: pendingSampleWaterRequest, pendingStartDGRequest, + * pendingStartDGFlushRequest, pendingStartDGHeatDisinfectRequest, + * pendingStartDGChemicalDisinfectRequest + * @details Outputs: Idle state of the standby mode executed, + * pendingStartDGFlushRequest, pendingStartDGHeatDisinfectRequest, + * pendingStartDGChemicalDisinfectRequest * @return the next state *************************************************************************/ static DG_STANDBY_MODE_STATE_T handleStandbyIdleState( void ) @@ -185,6 +195,21 @@ pendingStartDGRequest = FALSE; requestNewOperationMode( DG_MODE_GENE ); } + else if ( TRUE == pendingStartDGFlushRequest ) + { + pendingStartDGFlushRequest = FALSE; + requestNewOperationMode( DG_MODE_FLUS ); + } + else if ( TRUE == pendingStartDGHeatDisinfectRequest ) + { + pendingStartDGHeatDisinfectRequest = FALSE; + requestNewOperationMode( DG_MODE_HEAT ); + } + else if ( TRUE == pendingStartDGChemicalDisinfectRequest ) + { + pendingStartDGChemicalDisinfectRequest = FALSE; + requestNewOperationMode( DG_MODE_CHEM ); + } return state; } @@ -383,12 +408,29 @@ BOOL result = FALSE; // If DG is in standby mode or in the solo mode and the standby mode is in Idle state, request DG flush - if ( ( DG_MODE_STAN == getCurrentOperationMode() && DG_STANDBY_MODE_STATE_IDLE == standbyState ) || - DG_MODE_SOLO == getCurrentOperationMode() ) + if ( ( DG_MODE_STAN == getCurrentOperationMode() && DG_STANDBY_MODE_STATE_IDLE == standbyState ) || DG_MODE_SOLO == getCurrentOperationMode() ) { - requestNewOperationMode( DG_MODE_FLUS ); +#ifndef DISABLE_CAP_SWITCHES + DG_CMD_RESPONSE_T cmdResponse; - result = TRUE; + cmdResponse.commandID = MSG_ID_DG_START_STOP_FLUSH; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); + + sendCommandResponseMsg( &cmdResponse ); + } + else +#endif + { + pendingStartDGFlushRequest = TRUE; + result = TRUE; + } } return result; @@ -406,11 +448,29 @@ BOOL status = FALSE; // If DG is in standby mode and the standby mode is in Idle state or if DG is in solo mode, request DG heat disinfect - if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) || - ( DG_MODE_SOLO == getCurrentOperationMode() ) ) + if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) || ( DG_MODE_SOLO == getCurrentOperationMode() ) ) { - requestNewOperationMode( DG_MODE_HEAT ); - status = TRUE; +#ifndef DISABLE_CAP_SWITCHES + DG_CMD_RESPONSE_T cmdResponse; + + cmdResponse.commandID = MSG_ID_DG_START_STOP_HEAT_DISINFECT; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); + + sendCommandResponseMsg( &cmdResponse ); + } + else +#endif + { + pendingStartDGHeatDisinfectRequest = TRUE; + status = TRUE; + } } return status; @@ -429,10 +489,30 @@ // If DG is in standby mode and the standby mode is in Idle, request chemical disinfect // Chemical disinfect cannot be run in solo mode because the user has to confirm that the acid is inserted or removed - //if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) ) TODO un-comment this line. This is commented to be able to run chemical without HD for development + if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) ) { - requestNewOperationMode( DG_MODE_CHEM ); - status = TRUE; +#ifndef DISABLE_CAP_SWITCHES + DG_CMD_RESPONSE_T cmdResponse; + + cmdResponse.commandID = MSG_ID_DG_START_STOP_HEAT_DISINFECT; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + + // When chemical disinfect is about to be started, both caps must be closed + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); + + sendCommandResponseMsg( &cmdResponse ); + } + else +#endif + { + pendingStartDGChemicalDisinfectRequest = TRUE; + status = TRUE; + } } return status;