Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -r0803f828b81e046166457564650acf6a9bbd3cc6 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 0803f828b81e046166457564650acf6a9bbd3cc6) @@ -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 ) @@ -177,14 +187,28 @@ flushFilterRequest = FALSE; filterFlushStartTime = getMSTimerCount(); setValveState( VPI, VALVE_STATE_OPEN ); - setValveState( VPD, VALVE_STATE_OPEN_C_TO_NC ); state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; } else if ( TRUE == pendingStartDGRequest ) { 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; } @@ -202,7 +226,7 @@ DG_STANDBY_MODE_STATE_T state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; U32 const filterFlushTimePeriod_ms = getU32OverrideValue( &filterFlushTimePeriod ); - checkInletPressure(); + checkInletWaterPressure(); if ( TRUE == didTimeout( filterFlushStartTime, filterFlushTimePeriod_ms ) ) { @@ -225,7 +249,6 @@ { endSampleWaterRequest = FALSE; setValveState( VPI, VALVE_STATE_CLOSED ); - setValveState( VPD, VALVE_STATE_CLOSED ); state = DG_STANDBY_MODE_STATE_IDLE; } @@ -258,7 +281,6 @@ { endSampleWaterRequest = FALSE; setValveState( VPI, VALVE_STATE_CLOSED ); - setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NO ); state = DG_STANDBY_MODE_STATE_IDLE; } @@ -282,8 +304,6 @@ { stopSampleWaterRequest = FALSE; setValveState( VSP, VALVE_STATE_CLOSED ); - - setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NO ); state = DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; } @@ -301,8 +321,8 @@ { DG_CMD_RESPONSE_T cmdResponse; - cmdResponse.commandID = DG_CMD_SAMPLE_WATER; - cmdResponse.rejected = TRUE; + cmdResponse.commandID = DG_CMD_SAMPLE_WATER; + cmdResponse.rejected = TRUE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_MODE; switch ( sampleWaterCmd ) @@ -311,7 +331,7 @@ if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_SAMPLE_WATER == standbyState ) ) { stopSampleWaterRequest = TRUE; - cmdResponse.rejected = FALSE; + cmdResponse.rejected = FALSE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; } break; @@ -320,25 +340,25 @@ if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE == standbyState ) ) { startSampleWaterRequest = TRUE; - cmdResponse.rejected = FALSE; - cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; } break; case SAMPLE_WATER_CMD_FLUSH: if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) ) { - flushFilterRequest = TRUE; - cmdResponse.rejected = FALSE; + flushFilterRequest = TRUE; + cmdResponse.rejected = FALSE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; } break; case SAMPLE_WATER_CMD_END: if ( DG_MODE_STAN == getCurrentOperationMode() ) { - endSampleWaterRequest = TRUE; - cmdResponse.rejected = FALSE; + endSampleWaterRequest = TRUE; + cmdResponse.rejected = FALSE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; } break; @@ -383,12 +403,36 @@ 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 ); + DG_CMD_RESPONSE_T cmdResponse; + OPN_CLS_STATE_T concCap = getSwitchStatus( CONCENTRATE_CAP ); + OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); + cmdResponse.commandID = DG_CMD_START_FLUSH; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; - result = TRUE; +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) + { + concCap = STATE_CLOSED; + diaCap = STATE_CLOSED; + } +#endif + + if ( ( STATE_OPEN == concCap ) || ( STATE_OPEN == diaCap ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); + } + else + { + pendingStartDGFlushRequest = TRUE; + result = TRUE; + } + + sendCommandResponseMsg( &cmdResponse ); } return result; @@ -406,11 +450,37 @@ 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; + DG_CMD_RESPONSE_T cmdResponse; + + cmdResponse.commandID = DG_CMD_START_HEAT_DISINFECT; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + OPN_CLS_STATE_T concCap = getSwitchStatus( CONCENTRATE_CAP ); + OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); + +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) + { + concCap = STATE_CLOSED; + diaCap = STATE_CLOSED; + } +#endif + + if ( ( STATE_OPEN == concCap ) || ( STATE_OPEN == diaCap ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); + } + else + { + pendingStartDGHeatDisinfectRequest = TRUE; + status = TRUE; + } + + sendCommandResponseMsg( &cmdResponse ); } return status; @@ -429,10 +499,38 @@ // 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; + DG_CMD_RESPONSE_T cmdResponse; + + cmdResponse.commandID = DG_CMD_START_CHEM_DISINFECT; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + OPN_CLS_STATE_T concCap = getSwitchStatus( CONCENTRATE_CAP ); + OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); + +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) + { + concCap = STATE_CLOSED; + diaCap = STATE_CLOSED; + } +#endif + + // When chemical disinfect is about to be started, both caps must be closed + if ( ( STATE_OPEN == concCap ) || ( STATE_OPEN == diaCap ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); + } + else + { + pendingStartDGChemicalDisinfectRequest = TRUE; + status = TRUE; + } + + sendCommandResponseMsg( &cmdResponse ); } return status;