Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r669f36cf32c3b500aa2fd5b08c58ee5e6b2e7f08 -rd5f2ac4d84453feb1b782f35f9d69432977a95f6 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 669f36cf32c3b500aa2fd5b08c58ee5e6b2e7f08) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision d5f2ac4d84453feb1b782f35f9d69432977a95f6) @@ -7,8 +7,8 @@ * * @file ModeStandby.c * -* @author (last) Dara Navaei -* @date (last) 23-May-2022 +* @author (last) Michael Garthwaite +* @date (last) 07-Sep-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -26,6 +26,7 @@ #include "Pressures.h" #include "Reservoirs.h" #include "ROPump.h" +#include "RTC.h" #include "SystemComm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" @@ -95,7 +96,7 @@ pendingStartDGChemicalDisinfectRequest = FALSE; // Reset the heaters efficiency for another treatment - resetHeatersEfficiency(); + resetHeatersEstimationGain(); // Initialize the reservoirs parameters for another treatment. // This is to make sure the boolean flag for the first fill is set to TRUE. @@ -116,6 +117,8 @@ deenergizeActuators(); + setCPLDCleanLEDColor( CPLD_CLEAN_LED_OFF ); + return standbyState; } @@ -149,7 +152,7 @@ default: 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_START; + standbyState = DG_STANDBY_MODE_STATE_IDLE; break; } @@ -180,29 +183,35 @@ // if HD requests water sample, go to water sample state else if ( TRUE == flushFilterRequest ) { - flushFilterRequest = FALSE; + flushFilterRequest = FALSE; filterFlushStartTime = getMSTimerCount(); + setValveState( VPI, VALVE_STATE_OPEN ); + state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; } else if ( TRUE == pendingStartDGRequest ) { pendingStartDGRequest = FALSE; + signalSyncToHD(); 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 ); } @@ -230,7 +239,7 @@ state = DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; } - if ( FILTER_FLUSH_DATA_PUBLISH_INTERVAL <= filterFlushPublishTimerCounter++ ) + if ( ++filterFlushPublishTimerCounter >= FILTER_FLUSH_DATA_PUBLISH_INTERVAL ) { STANDBY_MODE_DATA_T data; @@ -380,8 +389,11 @@ if ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) { - result = TRUE; + result = TRUE; pendingStartDGRequest = TRUE; + + // Reset the volume accumulator for the next run + resetROGenerateVolumeL(); } return result; @@ -399,9 +411,10 @@ 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() ) ) { 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;