Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b -r67731d57db9a620418b3b848d8f75ff204902c36 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 67731d57db9a620418b3b848d8f75ff204902c36) @@ -15,6 +15,7 @@ * ***************************************************************************/ +#include "BalancingChamber.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "Heaters.h" @@ -42,7 +43,8 @@ static DD_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. -static OVERRIDE_U32_T pendingStartDDRequest; ///< Flag indicating TD has requested DD start the dialysis delivery(Overridable). +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. @@ -63,10 +65,8 @@ void initStandbyMode( void ) { standbyState = DD_STANDBY_MODE_STATE_IDLE; - pendingStartDDRequest.data = FALSE; - pendingStartDDRequest.ovData = FALSE; - pendingStartDDRequest.ovInitData = FALSE; - pendingStartDDRequest.override = OVERRIDE_RESET; + pendingStartDDPreGenRequest = FALSE; + pendingBalanceChamberSwOnlyRequest = FALSE; // pendingStartDDFlushRequest = FALSE; // pendingStartDDHeatDisinfectRequest = FALSE; // pendingStartDDHeatDisinfectActiveCoolRequest = FALSE; @@ -92,8 +92,8 @@ // // 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 ); // // // Send DD usage data to TD @@ -116,11 +116,6 @@ *************************************************************************/ U32 execStandbyMode( void ) { - if ( TRUE == areInletWaterConditionsAlarmsActive() ) - { - standbyState = DD_STANDBY_MODE_STATE_PAUSE; - } - // execute current Standby state switch ( standbyState ) { @@ -143,33 +138,9 @@ /*********************************************************************//** * @brief - * The areInletWaterConditionsAlarmsActive function checks whether the inlet - * water pressure conditions are out of range and any of their alarms are active. - * @details \b Inputs: Input and Output pressure of water inlet pressur regulator. - * @details \b Outputs: None - * @return TRUE if any of the alarms are active, otherwise, FALSE - *************************************************************************/ -BOOL areInletWaterConditionsAlarmsActive( void ) -{ - BOOL status = FALSE; - - // Check Inlet Water Pressure - both Water inlet pressure Input, pressure Output after pressure regulator. - checkInletWaterPressure(); - - // Check any active alarms - status |= isAlarmActive( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_LOW_RANGE ); - status |= isAlarmActive( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_HIGH_RANGE ); - status |= isAlarmActive( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_HIGH_RANGE ); - status |= isAlarmActive( ALARM_ID_DD_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, pendingStartDDRequest, + * @details \b Inputs: pendingSampleWaterRequest, pendingStartDDPreGenRequest, * pendingStartDDFlushRequest, pendingStartDDHeatDisinfectRequest, * pendingStartDDChemicalDisinfectRequest * @details \b Outputs: Idle state of the standby mode executed, @@ -183,16 +154,20 @@ { DD_STANDBY_MODE_STATE_T state = DD_STANDBY_MODE_STATE_IDLE; - // go to standby solo mode if TD is turned off or stops communicating. - if ( FALSE == isTDCommunicating() ) - { // TODO if TD comm loss, do we need solo standby? - SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_TD_COMMUNICATION_LOSS, 0, 0 ) - //requestNewOperationMode( DD_MODE_SOLO ); + //TODO : Define comm loss alarm when TD is turned off or stops communicating +// if ( FALSE == isTDCommunicating() ) +// { + // define the alarm +// } + if ( TRUE == pendingStartDDPreGenRequest ) + { + pendingStartDDPreGenRequest = FALSE; + requestNewOperationMode( DD_MODE_PREG ); } - else if ( TRUE == getU32OverrideValue( &pendingStartDDRequest ) ) + //Test request to handle only balancing chamber switching + else if ( TRUE == pendingBalanceChamberSwOnlyRequest ) { - pendingStartDDRequest.data = FALSE; - requestNewOperationMode( DD_MODE_GEND ); + execBalancingChamberControl(); } // else if ( TRUE == pendingStartDDFlushRequest ) // { @@ -230,36 +205,68 @@ { DD_STANDBY_MODE_STATE_T state = DD_STANDBY_MODE_STATE_PAUSE; - if ( FALSE == areInletWaterConditionsAlarmsActive() ) + return state; +} + +/*********************************************************************//** + * @brief + * The requestDDPreGenStart function handles an TD request to start/ + * go to pre generation dialysis mode. + * @details \b Inputs: standbyState + * @details \b Outputs: pendingStartDDPreGenRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestDDPreGenStart( void ) +{ + BOOL result = FALSE; + + if ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) { - state = DD_STANDBY_MODE_STATE_IDLE; + result = TRUE; + pendingStartDDPreGenRequest = TRUE; } - return state; + return result; } /*********************************************************************//** * @brief - * The requestDDStart function handles an TD request to start (go to generation dialysis mode). + * The requestBCSwitchingOnlyStart function handles Balancing chamber switching + * only start request. * @details \b Inputs: standbyState - * @details \b Outputs: pendingStartDDRequest + * @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; - pendingStartDDRequest.data = TRUE; + result = TRUE; + pendingBalanceChamberSwOnlyRequest = TRUE; } return result; } /*********************************************************************//** * @brief + * The requestBCSwitchingOnlyStop function handles Balancing chamber switching + * only stop request. + * @details \b Inputs: standbyState + * @details \b Outputs: pendingBalanceChamberSwOnlyRequest + * @return none. + *************************************************************************/ +void requestBCSwitchingOnlyStop( void ) +{ + pendingBalanceChamberSwOnlyRequest = FALSE; + // Close all balancing chamber valves + valveControlForBCClosedState(); +} + +/*********************************************************************//** + * @brief * The startDDFlush function starts DD flush mode. * @details \b Inputs: standbyState * @details \b Outputs: none @@ -457,21 +464,4 @@ *************************************************************************/ -/*********************************************************************//** - * @brief - * The testDDstartGenDialysateOverride function sets the override value - * to start the gen dialysate operation mode. - * @details Inputs: pendingStartDDRequest - * @details Outputs: pendingStartDDRequest - * @param message Override message from Dialin which includes the flag - * to override the operation mode. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testDDstartGenDialysateOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &pendingStartDDRequest, FALSE, TRUE ); - - return result; -} - /**@}*/