Index: firmware/App/DGCommon.h =================================================================== diff -u -r264d5853c97ab9550878609c9302e87464078734 -rb8a409a6f04c2912cb20eb4c9191bff573080162 --- firmware/App/DGCommon.h (.../DGCommon.h) (revision 264d5853c97ab9550878609c9302e87464078734) +++ firmware/App/DGCommon.h (.../DGCommon.h) (revision b8a409a6f04c2912cb20eb4c9191bff573080162) @@ -57,7 +57,7 @@ #define DISABLE_HEATERS_EFFICIENCY 1 #define DISABLE_DISINFECT_CONDUCTIVITY 1 // Implement // #define DISABLE_CONC_PUMPS 1 - #define DISABLE_CAP_SWITCHES 1 // Implement +// #define DISABLE_CAP_SWITCHES 1 // Implement // Turn these flags on to disable dialysate mixing #define DISABLE_DIALYSATE_CHECK 1 // Disabled for Tom // Implement Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -r264d5853c97ab9550878609c9302e87464078734 -rb8a409a6f04c2912cb20eb4c9191bff573080162 --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 264d5853c97ab9550878609c9302e87464078734) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision b8a409a6f04c2912cb20eb4c9191bff573080162) @@ -182,6 +182,7 @@ static DG_RESERVOIR_STATUS_T getRsrvrDrainStatus( DG_RESERVOIR_ID_T r, U32 drainSteadyStateTimeout, U32 timeout ); static CHEM_DISINFECT_STATUS_T getChemicalDisinfectStatus( void ); static void publishChemicalDisinfectData( void ); +static void monitorModeChemicalDisinfect( void ); /*********************************************************************//** * @brief @@ -245,6 +246,8 @@ *************************************************************************/ U32 execChemicalDisinfectMode( void ) { + monitorModeChemicalDisinfect(); + switch ( chemDisinfectState ) { case DG_CHEM_DISINFECT_STATE_START: @@ -1184,7 +1187,6 @@ break; case CHEM_DISINFECT_COMPLETE: - // Turn off the concentrate pumps requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID ); @@ -1642,17 +1644,23 @@ if ( DG_RESERVOIR_REACHED_TARGET == rsrvr2Status ) { - // Done with filling, turn off the RO pump - signalROPumpHardStop(); - - setValveState( VRD2, VALVE_STATE_OPEN ); - // Turn on the drain pump to drain R2 - setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); - // If the number of post chemical disinfect rinses have finished, // transition to drain R1 state. Otherwise, start the next rinse. if ( ++numberOfPostDisinfectRinses >= NUM_OF_POST_DISINFECT_RINSES ) { + // Done with filling, turn off the RO pump + signalROPumpHardStop(); + + // Set the rest of the valve to be in the de-enrgize mode + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRD2, VALVE_STATE_OPEN ); + + // Turn on the drain pump to drain R2 + setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); + // Set the reservoir status rsrvr2Status = DG_RESERVOIR_ABOVE_TARGET; // This is last drain @@ -2068,4 +2076,74 @@ } } +/*********************************************************************//** + * @brief + * The monitorModeChemicalDisinfect 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: chemDisinfectState + * @details Outputs: prevChemDisinfectState, chemDisinfectState, + * alarmDetectedPendingTrigger + * @return: none + *************************************************************************/ +static void monitorModeChemicalDisinfect( void ) +{ + BOOL isAlarmNeeded = FALSE; + + switch( chemDisinfectState ) + { + case DG_CHEM_DISINFECT_STATE_START: + case DG_CHEM_DISINFECT_STATE_DRAIN_R1: + case DG_CHEM_DISINFECT_STATE_DRAIN_R2: + case DG_CHEM_DISINFECT_STATE_FLUSH_DRAIN: + case DG_CHEM_DISINFECT_STATE_FLUSH_CIRCULATION: + case DG_CHEM_DISINFECT_STATE_FLUSH_R1_AND_R2: + case DG_CHEM_DISINFECT_STATE_FLUSH_R2_AND_DRAIN_R1: + case DG_CHEM_DISINFECT_STATE_FLUSH_DRAIN_R2: + case DG_CHEM_DISINFECT_STATE_FLUSH_DRAIN_R1: + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + isAlarmNeeded = TRUE; + } + break; + + case DG_CHEM_DISINFECT_STATE_PRIME_ACID_LINE: + case DG_CHEM_DISINFECT_STATE_FILL_WITH_WATER_AND_DISINFECTANT: + if ( ( STATE_CLOSED == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + isAlarmNeeded = TRUE; + } + break; + + case DG_CHEM_DISINFECT_STATE_DISINFECT_R1_TO_R2: + case DG_CHEM_DISINFECT_STATE_FILL_R2_WITH_DISINFECTANT: + case DG_CHEM_DISINFECT_STATE_DISINFECT_R2_TO_R1: + case DG_CHEM_DISINFECT_STATE_DISINFECTANT_DRAIN_R1: + case DG_CHEM_DISINFECT_STATE_DISINFECTANT_DRAIN_R2: + case DG_CHEM_DISINFECT_STATE_RINSE_R1_TO_R2: + case DG_CHEM_DISINFECT_STATE_RINSE_R2_TO_R1_AND_DRAIN_R1: + case DG_CHEM_DISINFECT_STATE_RINSE_R1_TO_R2_AND_DRAIN_R2: + case DG_CHEM_DISINFECT_STATE_RINSE_CIRCULATION: + case DG_CHEM_DISINFECT_STATE_COMPLETE: + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + isAlarmNeeded = TRUE; + } + break; + } + + if ( TRUE == isAlarmNeeded ) + { + // 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 ConcCap = (U32)getSwitchStatus( CONCENTRATE_CAP ); + U32 DialysateCap = (U32)getSwitchStatus( DIALYSATE_CAP ); + prevChemDisinfectState = chemDisinfectState; + chemDisinfectState = DG_CHEM_DISINFECT_STATE_CANCEL_WATER_PATH; + alarmDetectedPendingTrigger = ALARM_ID_NO_ALARM; + + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION, ConcCap, DialysateCap ) + } +} + /**@}*/ 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 ) + } +} + /**@}*/ Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r264d5853c97ab9550878609c9302e87464078734 -rb8a409a6f04c2912cb20eb4c9191bff573080162 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 264d5853c97ab9550878609c9302e87464078734) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision b8a409a6f04c2912cb20eb4c9191bff573080162) @@ -196,6 +196,7 @@ static DG_RESERVOIR_STATUS_T getRsrvrDrainStatus( DG_RESERVOIR_ID_T r, U32 drainSteadyStateTimeout, U32 timeout ); static HEAT_DISINFECT_STATUS_T getHeatDisinfectStatus( void ); static void publishHeatDisinfectData( void ); +static void monitorModeHeatDisinfect( void ); /*********************************************************************//** * @brief @@ -248,28 +249,10 @@ *************************************************************************/ U32 transitionToHeatDisinfectMode( void ) { - 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; - deenergizeActuators(); initHeatDisinfectMode(); -#ifndef DISABLE_CAP_SWITCHES - if ( ( STATE_CLOSED == getSwitchStatus( CONCENTRATE_CAP ) ) && ( STATE_CLOSED == 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 ); - stopDGHeatDisinfect(); - } - - sendCommandResponseMsg( &cmdResponse ); -#endif - return heatDisinfectState; } @@ -283,6 +266,8 @@ *************************************************************************/ U32 execHeatDisinfectMode( void ) { + monitorModeHeatDisinfect(); + switch ( heatDisinfectState ) { case DG_HEAT_DISINFECT_STATE_START: @@ -2059,4 +2044,29 @@ } } +/*********************************************************************//** + * @brief + * The monitorModeHeatDisinfect 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: prevHeatDisinfectState, heatDisinfectState, + * alarmDetectedPendingTrigger + * @return: none + *************************************************************************/ +static void monitorModeHeatDisinfect( 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 ); + prevHeatDisinfectState = heatDisinfectState; + heatDisinfectState = DG_HEAT_DISINFECT_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 ) + } +} + /**@}*/ 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;