Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rf308cc4c35eab630ebbbde405cfe47d049afeafb -r3b70632c04247a6973960e1f37ae73eb4384a6b7 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f308cc4c35eab630ebbbde405cfe47d049afeafb) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 3b70632c04247a6973960e1f37ae73eb4384a6b7) @@ -1,29 +1,36 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * -* @file ModeStandby.c +* @file ModeStandby.c * -* @author (last) Quang Nguyen -* @date (last) 21-Jul-2020 +* @author (last) Michael Garthwaite +* @date (last) 07-Sep-2022 * -* @author (original) Dara Navaei -* @date (original) 05-Nov-2019 +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 * ***************************************************************************/ +#include "ConcentratePumps.h" #include "CPLD.h" #include "DrainPump.h" #include "Heaters.h" +#include "MessageSupport.h" +#include "ModeFault.h" +#include "ModeStandby.h" #include "OperationModes.h" +#include "Pressures.h" +#include "Reservoirs.h" #include "ROPump.h" #include "SystemComm.h" +#include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "Timers.h" #include "Valves.h" -#include "ModeStandby.h" /** * @addtogroup DGStandbyMode @@ -32,91 +39,117 @@ // ********** private definitions ********** -#define WATER_SAMPLE_TIME_MS ( 10 * MS_PER_SECOND ) ///< Duration of water sample state (in ms). +#define FILTER_FLUSH_TIME_MS ( 120 * MS_PER_SECOND ) ///< Duration of filter flush state (in ms). +#define MAX_WATER_SAMPLE_TIME_MS ( 10 * MS_PER_SECOND ) ///< Maximum duration of water sample state (in ms). +#define FLUSH_EXPIRATION_TIME_MS ( 10 * SEC_PER_MIN * MS_PER_SECOND ) ///< Duration in which a filter flush is valid (in ms). +#define FILTER_FLUSH_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Filter flush data broadcast interval. // ********** private data ********** -static DG_STANDBY_MODE_STATE_T standbyState = DG_STANDBY_MODE_STATE_START; ///< Currently active standby state. -static BOOL pendingSampleWaterRequest = FALSE; ///< Flag indicating HD has requested a water sample. -static BOOL pendingStartDGRequest = FALSE; ///< Flag indicating HD has requested DG start (go to re-circulate mode). -static U32 waterSampleStartTime = 0; ///< Time stamp for start of water sample state. +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; ///< 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. + // ********** private function prototypes ********** static DG_STANDBY_MODE_STATE_T handleStandbyIdleState( void ); +static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterState( void ); +static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterIdleState( void ); static DG_STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ); /*********************************************************************//** * @brief - * The initStandbyMode function initializes the Standby Mode module. - * @details - * Inputs : none - * Outputs : Standby Mode module initialized. + * The initStandbyMode function initializes the standby mode module. + * @details Inputs: none + * @details Outputs: standbyState, stopSampleWaterRequest, startSampleWaterRequest, + * flushFilterRequest, endSampleWaterRequest, waterSampleStartTime, + * filterFlushStartTime, filterFlushPublishTimerCounter, pendingStartDGRequest * @return none *************************************************************************/ void initStandbyMode( void ) { - standbyState = DG_STANDBY_MODE_STATE_START; - pendingSampleWaterRequest = FALSE; - pendingStartDGRequest = FALSE; - waterSampleStartTime = 0; + standbyState = DG_STANDBY_MODE_STATE_IDLE; + 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(); + + // Initialize the reservoirs parameters for another treatment. + // This is to make sure the boolean flag for the first fill is set to TRUE. + initReservoirs(); } /*********************************************************************//** * @brief * The transitionToStandbyMode function prepares for transition to standby mode. - * @details - * Inputs : none - * Outputs : - * @return none + * @details Inputs: none + * @details Outputs: Re-initialized standby mode + * @return initial state *************************************************************************/ -void transitionToStandbyMode( void ) +U32 transitionToStandbyMode( void ) { // re-initialize standby mode each time we transition to standby mode initStandbyMode(); - // set initial actuator states - setValveState( VPI, VALVE_STATE_CLOSED ); - setValveState( VSP, VALVE_STATE_CLOSED ); - setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - signalROPumpHardStop(); - signalDrainPumpHardStop(); - stopPrimaryHeater(); - stopTrimmerHeater(); - // conc. pumps off - // UV off + deenergizeActuators(); + + return standbyState; } /*********************************************************************//** * @brief - * The execStandbyMode function executes the Standby Mode state machine. - * @details - * Inputs : none - * Outputs : - * @return current state. + * The execStandbyMode function executes the standby mode state machine. + * @details Inputs: none + * @details Outputs: Standby mode state machine executed + * @return current state *************************************************************************/ U32 execStandbyMode( void ) { // execute current Standby state switch ( standbyState ) { - case DG_STANDBY_MODE_STATE_START: - standbyState = DG_STANDBY_MODE_STATE_IDLE; - break; - case DG_STANDBY_MODE_STATE_IDLE: standbyState = handleStandbyIdleState(); break; + case DG_STANDBY_MODE_STATE_FLUSH_FILTER: + standbyState = handleStandbyFlushFilterState(); + break; + + case DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE: + standbyState = handleStandbyFlushFilterIdleState(); + break; + case DG_STANDBY_MODE_STATE_SAMPLE_WATER: standbyState = handleStandbySampleWaterState(); break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, standbyState ) // TODO - add s/w fault enum to 1st data param - standbyState = DG_STANDBY_MODE_STATE_START; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_STANDBY_MODE_INVALID_EXEC_STATE, standbyState ) + standbyState = DG_STANDBY_MODE_STATE_IDLE; break; } @@ -125,91 +158,220 @@ /*********************************************************************//** * @brief - * The handleStandbyIdleState function executes the Idle state of the \n - * Standby Mode state machine. - * @details - * Inputs : pendingSampleWaterRequest, pendingStartDGRequest - * Outputs : possibly op mode + * The handleStandbyIdleState function executes the idle state of the + * standby mode state machine. + * @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 ) { - DG_STANDBY_MODE_STATE_T result = DG_STANDBY_MODE_STATE_IDLE; + DG_STANDBY_MODE_STATE_T state = DG_STANDBY_MODE_STATE_IDLE; // go to standby solo mode if HD is turned off or stops communicating. if ( FALSE == isHDCommunicating() ) { // TODO if HD comm loss, should we wait an hour or so before going to solo standby? requestNewOperationMode( DG_MODE_SOLO ); } // if HD requests water sample, go to water sample state - else if ( TRUE == pendingSampleWaterRequest ) + else if ( TRUE == flushFilterRequest ) { - pendingSampleWaterRequest = FALSE; - waterSampleStartTime = getMSTimerCount(); + flushFilterRequest = FALSE; + filterFlushStartTime = getMSTimerCount(); setValveState( VPI, VALVE_STATE_OPEN ); - setValveState( VSP, VALVE_STATE_OPEN ); - result = DG_STANDBY_MODE_STATE_SAMPLE_WATER; + state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; } else if ( TRUE == pendingStartDGRequest ) { pendingStartDGRequest = FALSE; - requestNewOperationMode( DG_MODE_CIRC ); + 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 result; + return state; } /*********************************************************************//** * @brief - * The handleStandbySampleWaterState function executes the sample water state \n - * of the Standby Mode state machine. - * @details - * Inputs : none - * Outputs : + * The handleStandbyFilterFlushState function executes the flush filter state + * of the standby mode state machine. + * @details Inputs: filterFLushStartTime + * @details Outputs: Flushed the filters * @return the next state *************************************************************************/ -static DG_STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ) +static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterState( void ) { - DG_STANDBY_MODE_STATE_T result = DG_STANDBY_MODE_STATE_SAMPLE_WATER; + DG_STANDBY_MODE_STATE_T state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; + U32 filterFlushTimePeriod_ms = getU32OverrideValue( &filterFlushTimePeriod ); - // VPi and VSP valves open for 10 seconds, then close and return to idle state - if ( TRUE == didTimeout( waterSampleStartTime, WATER_SAMPLE_TIME_MS ) ) + checkInletWaterPressure(); + + if ( TRUE == didTimeout( filterFlushStartTime, filterFlushTimePeriod_ms ) ) { setValveState( VPI, VALVE_STATE_CLOSED ); + state = DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; + } + + if ( FILTER_FLUSH_DATA_PUBLISH_INTERVAL <= filterFlushPublishTimerCounter++ ) + { + STANDBY_MODE_DATA_T data; + + data.timeout = filterFlushTimePeriod_ms / MS_PER_SECOND; + data.countdown = data.timeout - ( calcTimeSince( filterFlushStartTime ) / MS_PER_SECOND ); + filterFlushPublishTimerCounter = 0; + + broadcastData( MSG_ID_DG_FILTER_FLUSH_PROGRESS, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( STANDBY_MODE_DATA_T ) ); + } + + if ( TRUE == endSampleWaterRequest ) + { + endSampleWaterRequest = FALSE; + setValveState( VPI, VALVE_STATE_CLOSED ); + state = DG_STANDBY_MODE_STATE_IDLE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleStandbyFlushFilterIdleState function executes the flush filter + * idle state of the standby mode state machine. + * @details Inputs: filterFLushStartTime, startSampleWaterRequest, endSampleWaterRequest + * @details Outputs: Flushed the filters, startSampleWaterRequest, endSampleWaterRequest, + * waterSampleStartTime + * @return the next state + *************************************************************************/ +static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterIdleState( void ) +{ + DG_STANDBY_MODE_STATE_T state = DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; + + if ( TRUE == startSampleWaterRequest ) + { + startSampleWaterRequest = FALSE; + waterSampleStartTime = getMSTimerCount(); + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_OPEN ); + state = DG_STANDBY_MODE_STATE_SAMPLE_WATER; + } + + if ( TRUE == endSampleWaterRequest ) + { + endSampleWaterRequest = FALSE; + setValveState( VPI, VALVE_STATE_CLOSED ); + state = DG_STANDBY_MODE_STATE_IDLE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleStandbySampleWaterState function executes the sample water state + * of the standby mode state machine. + * @details Inputs: stopSampleWaterRequest, waterSampleStartTime + * @details Outputs: Finished sample water and closed valve + * @return the next state + *************************************************************************/ +static DG_STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ) +{ + DG_STANDBY_MODE_STATE_T state = DG_STANDBY_MODE_STATE_SAMPLE_WATER; + + // After HD requests to stop or 10 seconds has elapsed, close and return to idle state + if ( ( TRUE == stopSampleWaterRequest ) || ( TRUE == didTimeout( waterSampleStartTime, MAX_WATER_SAMPLE_TIME_MS ) ) ) + { + stopSampleWaterRequest = FALSE; setValveState( VSP, VALVE_STATE_CLOSED ); - result = DG_STANDBY_MODE_STATE_IDLE; + state = DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; } - return result; + return state; } /*********************************************************************//** * @brief * The requestWaterSample function handles an HD request to sample water. - * @details - * Inputs : standbyState - * Outputs : pendingSampleWaterRequest + * @details Inputs: standbyState + * @details Outputs: pendingSampleWaterRequest * @return TRUE if request accepted, FALSE if not. *************************************************************************/ -BOOL requestWaterSample( void ) +void waterSampleCommandHandler( SAMPLE_WATER_CMD_T sampleWaterCmd ) { - BOOL result = FALSE; + DG_CMD_RESPONSE_T cmdResponse; - if ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) + cmdResponse.commandID = DG_CMD_SAMPLE_WATER; + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_MODE; + + switch ( sampleWaterCmd ) { - result = TRUE; - pendingSampleWaterRequest = TRUE; + case SAMPLE_WATER_CMD_STOP: + if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_SAMPLE_WATER == standbyState ) ) + { + stopSampleWaterRequest = TRUE; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + } + break; + + case SAMPLE_WATER_CMD_START: + 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; + } + break; + + case SAMPLE_WATER_CMD_FLUSH: + if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) ) + { + 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; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + } + break; + + default: + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_PARAMETER; + break; } - return result; + sendCommandResponseMsg( &cmdResponse ); } /*********************************************************************//** * @brief - * The requestDGStart function handles an HD request to start (go to re-circulate mode). - * @details - * Inputs : standbyState - * Outputs : pendingSampleWaterRequest + * The requestDGStart function handles an HD request to start (go to generation idle mode). + * @details Inputs: standbyState + * @details Outputs: pendingSampleWaterRequest * @return TRUE if request accepted, FALSE if not. *************************************************************************/ BOOL requestDGStart( void ) @@ -227,16 +389,210 @@ /*********************************************************************//** * @brief - * The getCurrentStandbyState function returns the current state of the \n - * standby mode. - * @details - * Inputs : standbyState - * Outputs : none + * The startDGFlush function starts DG flush mode. + * @details Inputs: standbyState + * @details Outputs: none + * @return: TRUE if the switch was successful, otherwise FALSE + *************************************************************************/ +BOOL startDGFlush( void ) +{ + 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() ) ) + { + 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; + +#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; +} + +/*********************************************************************//** + * @brief + * The startDGHeatDisinfect function starts heat disinfect mode. + * @details Inputs: standbyState + * @details Outputs: none + * @return: TRUE if the switch was successful + *************************************************************************/ +BOOL startDGHeatDisinfect( void ) +{ + 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() ) ) + { + 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; +} + +/*********************************************************************//** + * @brief + * The startDGChemicalDisinfect function starts chemical disinfect mode. + * @details Inputs: standbyState + * @details Outputs: none + * @return: TRUE if the switch was successful + *************************************************************************/ +BOOL startDGChemicalDisinfect( void ) +{ + BOOL status = FALSE; + + // 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 ) ) + { + 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; +} + +/*********************************************************************//** + * @brief + * The getCurrentStandbyState function returns the current state of standby mode. + * @details Inputs: standbyState + * @details Outputs: none * @return the current state of standby mode. *************************************************************************/ DG_STANDBY_MODE_STATE_T getCurrentStandbyState( void ) { return standbyState; } + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetFilterFlushTimePeriodOverride function overrides the filter + * flush time period. + * @details Inputs: none + * @details Outputs: filterFlushTimePeriod + * @param value override concentrate pump data publish interval with (in ms) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetFilterFlushTimePeriodOverride( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + filterFlushTimePeriod.override = OVERRIDE_KEY; + filterFlushTimePeriod.ovData = value; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetFilterFlushTimePeriodOverride function resets the + * override of the filter flush time period. + * @details Inputs: none + * @details Outputs: filterFlushTimePeriod + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetFilterFlushTimePeriodOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + filterFlushTimePeriod.override = OVERRIDE_RESET; + filterFlushTimePeriod.ovData = filterFlushTimePeriod.ovInitData; + } + + return result; +} + /**@}*/