Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r4fb1e15d35f6b968bab5620909c30baec98bfd4e -r67731d57db9a620418b3b848d8f75ff204902c36 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 4fb1e15d35f6b968bab5620909c30baec98bfd4e) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 67731d57db9a620418b3b848d8f75ff204902c36) @@ -15,27 +15,21 @@ * ***************************************************************************/ -//#include "ConcentratePumps.h" -//#include "ConductivitySensors.h" -//#include "CPLD.h" -//#include "DrainPump.h" -//#include "Heaters.h" -//#include "ModeChemicalDisinfect.h" +#include "BalancingChamber.h" +#include "ConcentratePumps.h" +#include "ConductivitySensors.h" +#include "Heaters.h" #include "ModeFault.h" -//#include "ModeHeatDisinfect.h" #include "ModeStandby.h" +#include "MessageSupport.h" +#include "Messaging.h" //#include "NVDataMgmt.h" #include "OperationModes.h" -//#include "Pressures.h" -//#include "Reservoirs.h" -//#include "ROPump.h" -//#include "RTC.h" +#include "Pressure.h" #include "SystemCommDD.h" -#include "Messaging.h" #include "TaskGeneral.h" -#include "MessageSupport.h" //#include "Timers.h" -//#include "Valves.h" +#include "Valves.h" /** * @addtogroup DDStandbyMode @@ -44,73 +38,39 @@ // ********** private definitions ********** -#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 DD_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 DD 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 DD start flush. -//static BOOL pendingStartDGHeatDisinfectRequest; ///< Flag indicating HD has requested DD start heat disinfect. -//static BOOL pendingStartDGChemicalDisinfectRequest; ///< Flag indicating HD has requested DD start chemical disinfect. -//static BOOL pendingStartDGHeatDisinfectActiveCoolRequest; ///< Flag indicating HD has requested DD start heat disinfect active cool. -//static BOOL pendingStartDGChemicalDisinfectFlushRequest; ///< Flag indicating HD has requested DD start chemical disinfect flush. -//static BOOL pendingStartDGROPermeateSampleRequest; ///< Flag indicating HD has requested DD start RO permeate sample. +static DD_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. -static OVERRIDE_U32_T filterFlushTimePeriod = { FILTER_FLUSH_TIME_MS, - FILTER_FLUSH_TIME_MS, 0, 0 }; ///< Filter flush time period in ms. +static BOOL pendingStartDDPreGenRequest; ///< Flag indicating TD has requested DD start the pre generation dialysate request. +static BOOL pendingBalanceChamberSwOnlyRequest; ///< Flag indicating balancing chamber switch only request. +//static BOOL pendingStartDDFlushRequest; ///< Flag indicating TD has requested DD start flush. +//static BOOL pendingStartDDHeatDisinfectRequest; ///< Flag indicating TD has requested DD start heat disinfect. +//static BOOL pendingStartDDHeatDisinfectActiveCoolRequest; ///< Flag indicating TD has requested DD start heat disinfect active cool. +//static BOOL pendingStartDGROPermeateSampleRequest; ///< Flag indicating TD has requested DD to command RO to start permeate sample. // ********** private function prototypes ********** -static BOOL areInletWaterConditionsAlarmsActive( void ); - static DD_STANDBY_MODE_STATE_T handleStandbyIdleState( void ); -static DD_STANDBY_MODE_STATE_T handleStandbyFlushFilterState( void ); -static DD_STANDBY_MODE_STATE_T handleStandbyFlushFilterIdleState( void ); -static DD_STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ); static DD_STANDBY_MODE_STATE_T handleStandbyPauseState( void ); /*********************************************************************//** * @brief - * The initStandbyMode function initializes the standby mode module. + * The initStandbyMode function initializes the standby mode unit. * @details \b Inputs: none - * @details \b Outputs: standbyState, stopSampleWaterRequest, startSampleWaterRequest, - * flushFilterRequest, endSampleWaterRequest, waterSampleStartTime, - * filterFlushStartTime, filterFlushPublishTimerCounter, pendingStartDGRequest, - * pendingStartDGHeatDisinfectActiveCoolRequest, - * pendingStartDGROPermeateSampleRequest + * @details \b Outputs:unit variables initialized. * @return none *************************************************************************/ void initStandbyMode( void ) { standbyState = DD_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; -// pendingStartDGHeatDisinfectActiveCoolRequest = FALSE; -// pendingStartDGROPermeateSampleRequest = FALSE; - - // Reset the heaters efficiency for another treatment - //resetHeatersEstimationGain(); + pendingStartDDPreGenRequest = FALSE; + pendingBalanceChamberSwOnlyRequest = FALSE; +// pendingStartDDFlushRequest = FALSE; +// pendingStartDDHeatDisinfectRequest = FALSE; +// pendingStartDDHeatDisinfectActiveCoolRequest = FALSE; +// pendingStartDDROPermeateSampleRequest = FALSE; } /*********************************************************************//** @@ -128,30 +88,20 @@ // re-initialize standby mode each time we transition to standby mode initStandbyMode(); -// deenergizeActuators( PARK_CONC_PUMPS ); -// -// setCPLDCleanLEDColor( CPLD_CLEAN_LED_OFF ); -// + deenergizeActuators( PARK_CONC_PUMPS ); + // // Upon transition to mode standby set CD1 and CD2 calibration records to be picked to the normal // // table. If the chemical disinfect fails, the mode transitions back to mode standby. -// setCondcutivitySensorCalTable( CONDUCTIVITYSENSORS_CD1_SENSOR, CAL_DATA_CD1_COND_SENSOR ); -// setCondcutivitySensorCalTable( CONDUCTIVITYSENSORS_CD2_SENSOR, CAL_DATA_CD2_COND_SENSOR ); +// setCondcutivitySensorCalTable( D17_COND, CAL_DATA_CD1_COND_SENSOR ); +// setCondcutivitySensorCalTable( D27_COND, CAL_DATA_CD2_COND_SENSOR ); // -//#ifndef _RELEASE_ -// setHeatNelsonSupportMode( NELSON_NONE ); -// setChemNelsonSupportMode( NELSON_NONE ); -//#endif // -// // Initialize the reservoirs parameters for another treatment. -// // This is to make sure the boolean flag for the first fill is set to TRUE. -// initReservoirs(); - - // Send DG usage data to HD + // Send DD usage data to TD // The message ID will not be put here because the messages list script will pick this up for another send command // The only important item is the payload length that must be 0 for the handler // usageMsg.hdr.msgID = 0; // usageMsg.hdr.payloadLen = 0; - //handleHDRequestDGUsageInfo( &usageMsg ); + //handleTDRequestDDUsageInfo( &usageMsg ); return standbyState; } @@ -166,31 +116,13 @@ *************************************************************************/ U32 execStandbyMode( void ) { - if ( TRUE == areInletWaterConditionsAlarmsActive() ) - { - //setValveState( VSP, VALVE_STATE_CLOSED ); - standbyState = DD_STANDBY_MODE_STATE_PAUSE; - } - // execute current Standby state switch ( standbyState ) { case DD_STANDBY_MODE_STATE_IDLE: standbyState = handleStandbyIdleState(); break; - case DD_STANDBY_MODE_STATE_FLUSH_FILTER: - standbyState = handleStandbyFlushFilterState(); - break; - - case DD_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE: - standbyState = handleStandbyFlushFilterIdleState(); - break; - - case DD_STANDBY_MODE_STATE_SAMPLE_WATER: - standbyState = handleStandbySampleWaterState(); - break; - case DD_STANDBY_MODE_STATE_PAUSE: standbyState = handleStandbyPauseState(); break; @@ -206,96 +138,56 @@ /*********************************************************************//** * @brief - * The areInletWaterConditionsAlarmsActive function checks whether the inlet - * water conditions are out of range and any of their alarms are active. - * @details \b Inputs: none - * @details \b Outputs: None - * @return TRUE if any of the alarms are active, otherwise, FALSE - *************************************************************************/ -static BOOL areInletWaterConditionsAlarmsActive( void ) -{ - // Check inlet water conductivity, temperature, pressure, and RO rejection ratio - BOOL status = FALSE; - -// checkInletWaterConductivity(); -// checkInletWaterTemperature(); -// checkInletWaterPressure(); -// -// status |= isAlarmConditionActive( ALARM_ID_DG_INLET_WATER_CONDUCTIVITY_IN_LOW_RANGE ); -// status |= isAlarmConditionActive( ALARM_ID_DG_INLET_WATER_CONDUCTIVITY_IN_HIGH_RANGE ); -// status |= isAlarmConditionActive( ALARM_ID_DG_INLET_WATER_TEMPERATURE_IN_HIGH_RANGE ); -// status |= isAlarmConditionActive( ALARM_ID_DG_INLET_WATER_TEMPERATURE_IN_LOW_RANGE ); -// status |= isAlarmConditionActive( ALARM_ID_DG_OUTLET_PRIMARY_CONDUCTIVITY_OUT_OF_RANGE ); -// status |= isAlarmConditionActive( ALARM_ID_DG_INLET_WATER_PRESSURE_IN_HIGH_RANGE ); -// status |= isAlarmConditionActive( ALARM_ID_DG_INLET_WATER_PRESSURE_IN_LOW_RANGE ); - - return status; -} - -/*********************************************************************//** - * @brief * The handleStandbyIdleState function executes the idle state of the * standby mode state machine. - * @details \b Inputs: pendingSampleWaterRequest, pendingStartDGRequest, - * pendingStartDGFlushRequest, pendingStartDGHeatDisinfectRequest, - * pendingStartDGChemicalDisinfectRequest + * @details \b Inputs: pendingSampleWaterRequest, pendingStartDDPreGenRequest, + * pendingStartDDFlushRequest, pendingStartDDHeatDisinfectRequest, + * pendingStartDDChemicalDisinfectRequest * @details \b Outputs: Idle state of the standby mode executed, - * pendingStartDGFlushRequest, pendingStartDGHeatDisinfectRequest, - * pendingStartDGChemicalDisinfectRequest + * pendingStartDDFlushRequest, pendingStartDDHeatDisinfectRequest, + * pendingStartDDChemicalDisinfectRequest + * @details \b Message \Sent: DD_EVENT_TD_COMMUNICATION_LOSS ( Evend Id:8 ) + * updates TD communication loss. * @return the next state *************************************************************************/ static DD_STANDBY_MODE_STATE_T handleStandbyIdleState( void ) { DD_STANDBY_MODE_STATE_T state = DD_STANDBY_MODE_STATE_IDLE; - // go to standby solo mode if HD is turned off or stops communicating. - if ( FALSE == isTDCommunicating() ) - { // 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 == flushFilterRequest ) + //TODO : Define comm loss alarm when TD is turned off or stops communicating +// if ( FALSE == isTDCommunicating() ) // { -// setValveState( VPI, VALVE_STATE_OPEN ); -// flushFilterRequest = FALSE; -// filterFlushStartTime = getMSTimerCount(); -// state = DD_STANDBY_MODE_STATE_FLUSH_FILTER; + // define the alarm // } -// else if ( TRUE == pendingStartDGRequest ) + if ( TRUE == pendingStartDDPreGenRequest ) + { + pendingStartDDPreGenRequest = FALSE; + requestNewOperationMode( DD_MODE_PREG ); + } + //Test request to handle only balancing chamber switching + else if ( TRUE == pendingBalanceChamberSwOnlyRequest ) + { + execBalancingChamberControl(); + } +// else if ( TRUE == pendingStartDDFlushRequest ) // { -// pendingStartDGRequest = FALSE; -// signalSyncToHD(); -// requestNewOperationMode( DD_MODE_GENE ); +// pendingStartDDFlushRequest = FALSE; +// requestNewOperationMode( DD_MODE_FLUS ); // } -// else if ( TRUE == pendingStartDGFlushRequest ) +// else if ( TRUE == pendingStartDDHeatDisinfectRequest ) // { -// pendingStartDGFlushRequest = FALSE; -// requestNewOperationMode( DG_MODE_FLUS ); -// } -// else if ( TRUE == pendingStartDGHeatDisinfectRequest ) -// { -// pendingStartDGHeatDisinfectRequest = FALSE; +// pendingStartDDHeatDisinfectRequest = FALSE; // requestNewOperationMode( DD_MODE_HEAT ); // } -// else if ( TRUE == pendingStartDGChemicalDisinfectRequest ) +// else if ( TRUE == pendingStartDDHeatDisinfectActiveCoolRequest ) // { -// pendingStartDGChemicalDisinfectRequest = FALSE; -// requestNewOperationMode( DD_MODE_CHEM ); -// } -// else if ( TRUE == pendingStartDGHeatDisinfectActiveCoolRequest ) -// { -// pendingStartDGHeatDisinfectActiveCoolRequest = FALSE; +// pendingStartDDHeatDisinfectActiveCoolRequest = FALSE; // // requestNewOperationMode( DD_MODE_HCOL ); // } -// else if ( TRUE == pendingStartDGChemicalDisinfectFlushRequest ) +// else if ( TRUE == pendingStartDDROPermeateSampleRequest ) // { -// pendingStartDGChemicalDisinfectFlushRequest = FALSE; -// requestNewOperationMode( DD_MODE_CHFL ); -// } -// else if ( TRUE == pendingStartDGROPermeateSampleRequest ) -// { -// pendingStartDGROPermeateSampleRequest = FALSE; +// pendingStartDDROPermeateSampleRequest = FALSE; // requestNewOperationMode( DD_MODE_ROPS ); // } @@ -304,226 +196,73 @@ /*********************************************************************//** * @brief - * The handleStandbyFilterFlushState function executes the flush filter state - * of the standby mode state machine. - * @details \b Inputs: filterFLushStartTime - * @details \b Outputs: Flushed the filters + * The handleStandbyPauseState function executes the standby pause state. + * @details \b Inputs: Water inlet pressure alarms + * @details \b Outputs: state * @return the next state *************************************************************************/ -static DD_STANDBY_MODE_STATE_T handleStandbyFlushFilterState( void ) -{ - DD_STANDBY_MODE_STATE_T state = DD_STANDBY_MODE_STATE_FLUSH_FILTER; -// U32 filterFlushTimePeriod_ms = getU32OverrideValue( &filterFlushTimePeriod ); -// -// if ( TRUE == didTimeout( filterFlushStartTime, filterFlushTimePeriod_ms ) ) -// { -// setValveState( VPI, VALVE_STATE_CLOSED ); -// state = DD_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; -// } -// -// if ( ++filterFlushPublishTimerCounter >= FILTER_FLUSH_DATA_PUBLISH_INTERVAL ) -// { -// 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_DD_FILTER_FLUSH_PROGRESS_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( STANDBY_MODE_DATA_T ) ); -// } -// -// if ( TRUE == endSampleWaterRequest ) -// { -// endSampleWaterRequest = FALSE; -// setValveState( VPI, VALVE_STATE_CLOSED ); -// state = DD_STANDBY_MODE_STATE_IDLE; -// } - - return state; -} - -/*********************************************************************//** - * @brief - * The handleStandbyFlushFilterIdleState function executes the flush filter - * idle state of the standby mode state machine. - * @details \b Inputs: filterFLushStartTime, startSampleWaterRequest, endSampleWaterRequest - * @details \b Outputs: Flushed the filters, startSampleWaterRequest, endSampleWaterRequest, - * waterSampleStartTime - * @return the next state - *************************************************************************/ -static DD_STANDBY_MODE_STATE_T handleStandbyFlushFilterIdleState( void ) -{ - DD_STANDBY_MODE_STATE_T state = DD_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; - -// if ( TRUE == startSampleWaterRequest ) -// { -// waterSampleStartTime = getMSTimerCount(); -// setValveState( VPI, VALVE_STATE_OPEN ); -// setValveState( VSP, VALVE_STATE_OPEN ); -// state = DD_STANDBY_MODE_STATE_SAMPLE_WATER; -// } -// -// if ( TRUE == endSampleWaterRequest ) -// { -// endSampleWaterRequest = FALSE; -// setValveState( VPI, VALVE_STATE_CLOSED ); -// state = DD_STANDBY_MODE_STATE_IDLE; -// } -// -// startSampleWaterRequest = FALSE; - - return state; -} - -/*********************************************************************//** - * @brief - * The handleStandbySampleWaterState function executes the sample water state - * of the standby mode state machine. - * @details \b Inputs: stopSampleWaterRequest, waterSampleStartTime - * @details \b Outputs: Finished sample water and closed valve - * @return the next state - *************************************************************************/ -static DD_STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ) -{ - DD_STANDBY_MODE_STATE_T state = DD_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 ); -// setValveState( VPI, VALVE_STATE_CLOSED ); -// state = DD_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; -// } - - return state; -} - -/*********************************************************************//** - * @brief - * The handleStandbyPauseState function executes the pause state. - * @details \b Inputs: none - * @details \b Outputs: filterFlushStartTime - * @return the next state - *************************************************************************/ static DD_STANDBY_MODE_STATE_T handleStandbyPauseState( void ) { DD_STANDBY_MODE_STATE_T state = DD_STANDBY_MODE_STATE_PAUSE; -// if ( FALSE == areInletWaterConditionsAlarmsActive() ) -// { -// filterFlushStartTime = getMSTimerCount(); -// state = DD_STANDBY_MODE_STATE_FLUSH_FILTER; -// } - return state; } /*********************************************************************//** * @brief - * The requestWaterSample function handles an HD request to sample water. + * The requestDDPreGenStart function handles an TD request to start/ + * go to pre generation dialysis mode. * @details \b Inputs: standbyState - * @details \b Outputs: pendingSampleWaterRequest + * @details \b Outputs: pendingStartDDPreGenRequest * @return TRUE if request accepted, FALSE if not. *************************************************************************/ -void waterSampleCommandHandler( SAMPLE_WATER_CMD_T sampleWaterCmd ) +BOOL requestDDPreGenStart( void ) { -// DD_CMD_RESPONSE_T cmdResponse; -// -// cmdResponse.commandID = DD_CMD_SAMPLE_WATER; -// cmdResponse.rejected = TRUE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_INVALID_MODE; -// -// switch ( sampleWaterCmd ) -// { -// case SAMPLE_WATER_CMD_STOP: -// if ( ( DD_MODE_STAN == getCurrentOperationMode() ) && ( DD_STANDBY_MODE_STATE_SAMPLE_WATER == standbyState ) ) -// { -// stopSampleWaterRequest = TRUE; -// cmdResponse.rejected = FALSE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_NONE; -// } -// break; -// -// case SAMPLE_WATER_CMD_START: -// if ( ( DD_MODE_STAN == getCurrentOperationMode() ) && ( DD_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE == standbyState ) ) -// { -// startSampleWaterRequest = TRUE; -// cmdResponse.rejected = FALSE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_NONE; -// } -// break; -// -// case SAMPLE_WATER_CMD_FLUSH: -// if ( ( DD_MODE_STAN == getCurrentOperationMode() ) && ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) ) -// { -// flushFilterRequest = TRUE; -// cmdResponse.rejected = FALSE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_NONE; -// } -// break; -// -// case SAMPLE_WATER_CMD_END: -// if ( DD_MODE_STAN == getCurrentOperationMode() ) -// { -// endSampleWaterRequest = TRUE; -// cmdResponse.rejected = FALSE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_NONE; -// } -// break; -// -// default: -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_INVALID_PARAMETER; -// break; -// } -// -// sendCommandResponseMsg( &cmdResponse ); + BOOL result = FALSE; + + if ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) + { + result = TRUE; + pendingStartDDPreGenRequest = TRUE; + } + + return result; } /*********************************************************************//** * @brief - * The requestDDStart function handles an HD request to start (go to generation idle mode). + * The requestBCSwitchingOnlyStart function handles Balancing chamber switching + * only start request. * @details \b Inputs: standbyState - * @details \b Outputs: pendingSampleWaterRequest + * @details \b Outputs: pendingBalanceChamberSwOnlyRequest * @return TRUE if request accepted, FALSE if not. *************************************************************************/ -BOOL requestDDStart( void ) +BOOL requestBCSwitchingOnlyStart( void ) { BOOL result = FALSE; if ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) { - result = TRUE; - //pendingStartDGRequest = TRUE; - - // Reset the volume accumulator for the next run -// resetROGenerateVolumeL(); + result = TRUE; + pendingBalanceChamberSwOnlyRequest = TRUE; } return result; } /*********************************************************************//** * @brief - * The signalAbortWaterSampling function handles an HD request to abort water - * sampling (return to standby idle state). - * @details \b Inputs: none - * @details \b Outputs: standby mode variable initialized - * @return TRUE if request accepted, FALSE if not + * The requestBCSwitchingOnlyStop function handles Balancing chamber switching + * only stop request. + * @details \b Inputs: standbyState + * @details \b Outputs: pendingBalanceChamberSwOnlyRequest + * @return none. *************************************************************************/ -BOOL signalAbortWaterSampling( void ) +void requestBCSwitchingOnlyStop( void ) { - BOOL result = FALSE; - - if ( ( DD_MODE_STAN == getCurrentOperationMode() ) && ( standbyState != DD_STANDBY_MODE_STATE_IDLE ) ) - { - result = TRUE; - initStandbyMode(); -// setValveState( VSP, VALVE_STATE_CLOSED ); -// setValveState( VPI, VALVE_STATE_CLOSED ); - } - - return result; + pendingBalanceChamberSwOnlyRequest = FALSE; + // Close all balancing chamber valves + valveControlForBCClosedState(); } /*********************************************************************//** @@ -709,172 +448,6 @@ /*********************************************************************//** * @brief - * The startDDChemicalDisinfect function starts chemical disinfect mode. - * @details \b Inputs: standbyState - * @details \b Outputs: none - * @return: TRUE if the switch was successful - *************************************************************************/ -BOOL startDDChemicalDisinfect( void ) -{ - BOOL status = FALSE; - -// // If DD 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 ( ( DD_MODE_STAN == getCurrentOperationMode() ) && ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) ) -// { -// DD_CMD_RESPONSE_T cmdResponse; -// -// cmdResponse.commandID = DD_CMD_START_CHEM_DISINFECT; -// cmdResponse.rejected = FALSE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_NONE; -// OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); -// -//#ifndef _RELEASE_ -// if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) -// { -// diaCap = STATE_CLOSED; -// } -//#endif -// -// // When chemical disinfect is about to be started, dialysate caps must be closed -// if ( STATE_OPEN == diaCap ) -// { -// cmdResponse.rejected = TRUE; -// cmdResponse.rejectCode = REQUEST_REJECT_REASON_DD_DIALYSATE_CAP_OPEN; -// } -// else -// { -// pendingStartDDChemicalDisinfectRequest = TRUE; -// status = TRUE; -// } -// -// sendCommandResponseMsg( &cmdResponse ); -// } - - return status; -} - -/*********************************************************************//** - * @brief - * The startDDChemicalDisinfectFlush function starts chemical disinfect flush mode. - * @details \b Inputs: standbyState - * @details \b Outputs: none - * @return: TRUE if the switch was successful - *************************************************************************/ -BOOL startDDChemicalDisinfectFlush( void ) -{ - BOOL status = FALSE; -// DD_CMD_RESPONSE_T cmdResponse; -// -// cmdResponse.commandID = DD_CMD_START_CHEM_DISINFECT_FLUSH; -// cmdResponse.rejected = FALSE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_NONE; -// -// // If DD is in standby mode and the standby mode is in Idle, request chemical disinfect flush -// // Chemical disinfect flush cannot be run in solo mode because the user has to confirm that the acid is inserted or removed -// if ( ( DD_MODE_STAN == getCurrentOperationMode() ) && ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) ) -// { -// 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_DD_DIALYSATE_CAP_OPEN : -// REQUEST_REJECT_REASON_DD_CONCENTRATE_CAP_OPEN ); -// } -// else -// { -// pendingStartDDChemicalDisinfectFlushRequest = TRUE; -// status = TRUE; -// } -// } -// else -// { -// cmdResponse.rejected = TRUE; -// cmdResponse.rejectCode = REQUEST_REJECT_REASON_DD_NOT_IN_STANDBY_IDLE_STATE; -// } -// -// sendCommandResponseMsg( &cmdResponse ); - - return status; -} - -/*********************************************************************//** - * @brief - * The startDDROPermeateSample function starts RO permeate sample mode. - * @details \b Inputs: standbyState - * @details \b Outputs: pendingStartDDChemicalDisinfectFlushRequest - * @return: TRUE if the switch was successful - *************************************************************************/ -BOOL startDDROPermeateSample( void ) -{ - BOOL status = FALSE; -// DD_CMD_RESPONSE_T cmdResponse; -// -// cmdResponse.commandID = DD_CMD_START_RO_PERMEATE_SAMPLE; -// cmdResponse.rejected = FALSE; -// cmdResponse.rejectCode = DD_CMD_REQUEST_REJECT_REASON_NONE; -// -// // If DD is in standby mode and the standby mode is in Idle, request RO permeate sample -// if ( ( DD_MODE_STAN == getCurrentOperationMode() ) && ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) ) -// { -// DD_USAGE_INFO_RECORD_T usageInfo; -// OPN_CLS_STATE_T concCap = getSwitchStatus( CONCENTRATE_CAP ); -// OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); -// -// getNVRecord2Driver( GET_USAGE_RECORD, (U08*)&usageInfo, sizeof( DD_USAGE_INFO_RECORD_T ), 0, ALARM_ID_NO_ALARM ); -// -//#ifndef _RELEASE_ -// if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) -// { -// concCap = STATE_CLOSED; -// diaCap = STATE_CLOSED; -// // Using the caps switch to disable the chemical disinfect date checks. -// // This is for debug builds only to simulate that a chem flush has been done after chem -// usageInfo.lastChemDisFlushCompleteDateEpoch = 40; -// usageInfo.lastChemDisStartDateEpoch = 32; -// } -//#endif -// -// if ( ( STATE_OPEN == concCap ) || ( STATE_OPEN == diaCap ) ) -// { -// cmdResponse.rejected = TRUE; -// cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DD_DIALYSATE_CAP_OPEN : -// REQUEST_REJECT_REASON_DD_CONCENTRATE_CAP_OPEN ); -// } -// else if ( usageInfo.lastChemDisFlushCompleteDateEpoch < usageInfo.lastChemDisStartDateEpoch ) -// { -// cmdResponse.rejected = TRUE; -// cmdResponse.rejectCode = REQUEST_REJECT_REASON_DD_CHEM_FLUSH_NOT_COMPLETED; -// } -// else -// { -// pendingStartDDROPermeateSampleRequest = TRUE; -// status = TRUE; -// } -// } -// else -// { -// cmdResponse.rejected = TRUE; -// cmdResponse.rejectCode = REQUEST_REJECT_REASON_DD_NOT_IN_STANDBY_IDLE_STATE; -// } -// -// sendCommandResponseMsg( &cmdResponse ); - - return status; -} - -/*********************************************************************//** - * @brief * The getCurrentStandbyState function returns the current state of standby mode. * @details \b Inputs: standbyState * @details \b Outputs: none @@ -891,49 +464,4 @@ *************************************************************************/ -/*********************************************************************//** - * @brief - * The testSetFilterFlushTimePeriodOverride function overrides the filter - * flush time period. - * @details \b Inputs: none - * @details \b 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 \b Inputs: none - * @details \b 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; -} - /**@}*/