Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r5c430c3ac17fc8ad836fd70b8a3b8a12af44319e -reeaab2a9a685fb18845888d91040d3aa01977f6d --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 5c430c3ac17fc8ad836fd70b8a3b8a12af44319e) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision eeaab2a9a685fb18845888d91040d3aa01977f6d) @@ -8,8 +8,8 @@ * * @file ModeGenIdle.c * -* @author (last) Dara Navaei -* @date (last) 02-Jan-2023 +* @author (last) Michael Garthwaite +* @date (last) 16-May-2023 * * @author (original) Quang Nguyen * @date (original) 06-Aug-2021 @@ -46,7 +46,7 @@ // ********** private definitions ********** #define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. -#define TARGET_RO_FLOW_RATE_L 0.3F ///< Target flow rate for RO pump. +#define TARGET_RO_FLOW_RATE_L 0.4F ///< Target flow rate for RO pump. #define BAD_FLUSH_FILL_TARGET_VOLUME_ML 1000 ///< Target fill volume in the bad flush fill state. #define HD_LOST_COMM_TIMEOUT_MS (5 * SEC_PER_MIN * MS_PER_SECOND ) ///< The time of HD lost comm before DG transition back to standby. #define BAD_FILL_SUBSTATES_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the bad fill sub-states is published on the CAN bus. @@ -76,7 +76,7 @@ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFirstDrainState( void ); static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFlushFillState( void ); static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ); -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( void ); +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( DG_GEN_IDLE_MODE_STATE_T* idleState ); static void publishGenIdleSubstates(); @@ -104,7 +104,7 @@ { // Re-initialize each time we transition to generation idle mode initGenIdleMode(); - + setCurrentSubState( NO_SUB_STATE ); // Set initial actuator states setValveState( VSP, VALVE_STATE_CLOSED ); setValveState( VPI, VALVE_STATE_OPEN ); @@ -115,6 +115,9 @@ setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + // Set back the conductivity of CD2 calibration table to the normal calibration table + setCondcutivitySensorCalTable( CONDUCTIVITYSENSORS_CD2_SENSOR, CAL_DATA_CD2_COND_SENSOR ); + signalDrainPumpHardStop(); requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID, NO_PARK_CONC_PUMPS ); requestConcentratePumpOff( CONCENTRATEPUMPS_CP2_BICARB, NO_PARK_CONC_PUMPS ); @@ -127,9 +130,13 @@ // because the initial guess in the heaters driver needs the target flow to calculate // the new PWMs for the main and small primary heaters setROPumpTargetFlowRateLPM( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); - setHeaterTargetTemperature( DG_PRIMARY_HEATER, getPrimaryHeaterTargetTemperature() ); - startHeater( DG_PRIMARY_HEATER ); + if ( FALSE == isHeaterOn( DG_PRIMARY_HEATER ) ) + { + setHeaterTargetTemperature( DG_PRIMARY_HEATER, getPrimaryHeaterTargetTemperature() ); + startHeater( DG_PRIMARY_HEATER ); + } + setCPLDCleanLEDColor( CPLD_CLEAN_LED_OFF ); return genIdleState; @@ -276,12 +283,13 @@ * The handleBadFillState function executes the bad fill state of the * generation idle mode state machine. * @details Inputs: none - * @details Outputs: badFillState + * @details Outputs: badFillState, genIdleState * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_STATE_T handleBadFillState( void ) { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_HANDLE_BAD_FILL; + U32 priorSubState = badFillState; // Execute current bad fill state switch ( badFillState ) @@ -303,7 +311,7 @@ break; case DG_HANDLE_BAD_FILL_STATE_REFILL: - badFillState = handleRefillState(); + badFillState = handleRefillState( &result ); break; default: @@ -312,6 +320,10 @@ break; } + if ( priorSubState != badFillState ) + { + setCurrentSubState( badFillState ); + } return result; } @@ -346,7 +358,7 @@ DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; // Check if the alarm has been cleared by the user and if yes, continue with the fill - if ( FALSE == isAlarmActive( ALARM_ID_FILL_CONDUCTIVITY_OUT_OF_RANGE ) ) + if ( FALSE == isAlarmActive( ALARM_ID_DG_FILL_CONDUCTIVITY_OUT_OF_RANGE ) ) { // Save the HD target fill volume before command 1000 mL fill volume targetFillVolumeML = getTargetFillVolumeML(); @@ -400,17 +412,19 @@ * The handleRefillState function executes refill state of the handle bad * fill state machine. * @details Inputs: none - * @details Outputs: none + * @details Outputs: handleBadFillFlag + * @param idleState reference variable for the next idle state * @return the next state *************************************************************************/ -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( void ) +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( DG_GEN_IDLE_MODE_STATE_T* idleState ) { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_START; // Clear wait for dialysate alarm condition to allow resume - clearAlarmCondition( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT ); // resume option will appear + clearAlarmCondition( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); // resume option will appear // Set flag to FALSE here so next call to idle exec will move to normal flush water state handleBadFillFlag = FALSE; + *idleState = DG_GEN_IDLE_MODE_STATE_START; return state; }