Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r67731d57db9a620418b3b848d8f75ff204902c36 -r6d4aa77e6b85aa7621a234660f631e725fb1d441 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 67731d57db9a620418b3b848d8f75ff204902c36) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 6d4aa77e6b85aa7621a234660f631e725fb1d441) @@ -1,30 +1,33 @@ /************************************************************************** * -* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* Copyright (c) 2024-2026 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 * -* @author (last) Vinayakam Mani -* @date (last) 06-Aug-2024 +* @author (last) Raghu Kallala +* @date (last) 22-Apr-2026 * * @author (original) Vinayakam Mani -* @date (original) 06-Aug-2024 +* @date (original) 07-Aug-2024 * ***************************************************************************/ #include "BalancingChamber.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" +#include "FPOperationModes.h" #include "Heaters.h" #include "ModeFault.h" #include "ModeStandby.h" +#include "ModeGenDialysate.h" #include "MessageSupport.h" #include "Messaging.h" //#include "NVDataMgmt.h" #include "OperationModes.h" +#include "PermeateTank.h" #include "Pressure.h" #include "SystemCommDD.h" #include "TaskGeneral.h" @@ -44,7 +47,6 @@ static DD_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. 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. @@ -66,7 +68,6 @@ { standbyState = DD_STANDBY_MODE_STATE_IDLE; pendingStartDDPreGenRequest = FALSE; - pendingBalanceChamberSwOnlyRequest = FALSE; // pendingStartDDFlushRequest = FALSE; // pendingStartDDHeatDisinfectRequest = FALSE; // pendingStartDDHeatDisinfectActiveCoolRequest = FALSE; @@ -90,6 +91,11 @@ deenergizeActuators( PARK_CONC_PUMPS ); + resetPermeateTank(); + + // Deactivate Balancing Chamber Switching + requestBalChamberSwitching( FALSE ); + // // 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( D17_COND, CAL_DATA_CD1_COND_SENSOR ); @@ -153,6 +159,7 @@ static DD_STANDBY_MODE_STATE_T handleStandbyIdleState( void ) { DD_STANDBY_MODE_STATE_T state = DD_STANDBY_MODE_STATE_IDLE; + FP_OP_MODE_T fpMode = getCurrentFPOperationMode(); //TODO : Define comm loss alarm when TD is turned off or stops communicating // if ( FALSE == isTDCommunicating() ) @@ -161,14 +168,18 @@ // } if ( TRUE == pendingStartDDPreGenRequest ) { - pendingStartDDPreGenRequest = FALSE; - requestNewOperationMode( DD_MODE_PREG ); + // wait for IOFP GENP mode and when IOFP manual control is not set + if ( ( ( FP_MODE_GENP == fpMode ) || ( FP_MODE_DEGP == fpMode ) ) && ( getTestConfigStatus( TEST_CONFIG_DD_RUN_SOLO ) == FALSE ) ) + { + pendingStartDDPreGenRequest = FALSE; + requestNewOperationMode( DD_MODE_PREG ); + } + else if ( getTestConfigStatus( TEST_CONFIG_DD_RUN_SOLO ) == TRUE ) + { + pendingStartDDPreGenRequest = FALSE; + requestNewOperationMode( DD_MODE_PREG ); + } } - //Test request to handle only balancing chamber switching - else if ( TRUE == pendingBalanceChamberSwOnlyRequest ) - { - execBalancingChamberControl(); - } // else if ( TRUE == pendingStartDDFlushRequest ) // { // pendingStartDDFlushRequest = FALSE; @@ -234,7 +245,7 @@ * The requestBCSwitchingOnlyStart function handles Balancing chamber switching * only start request. * @details \b Inputs: standbyState - * @details \b Outputs: pendingBalanceChamberSwOnlyRequest + * @details \b Outputs: none * @return TRUE if request accepted, FALSE if not. *************************************************************************/ BOOL requestBCSwitchingOnlyStart( void ) @@ -244,7 +255,9 @@ if ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) { result = TRUE; - pendingBalanceChamberSwOnlyRequest = TRUE; + + // Activate Balancing Chamber Switching + requestBalChamberSwitching( TRUE ); } return result; @@ -255,12 +268,14 @@ * The requestBCSwitchingOnlyStop function handles Balancing chamber switching * only stop request. * @details \b Inputs: standbyState - * @details \b Outputs: pendingBalanceChamberSwOnlyRequest + * @details \b Outputs: none * @return none. *************************************************************************/ void requestBCSwitchingOnlyStop( void ) { - pendingBalanceChamberSwOnlyRequest = FALSE; + // Deactivate Balancing Chamber Switching + requestBalChamberSwitching( FALSE ); + // Close all balancing chamber valves valveControlForBCClosedState(); } @@ -464,4 +479,60 @@ *************************************************************************/ +/*********************************************************************//** + * @brief + * The testValidateDDStandbyChangeReq function validate whether request + * operation sub mode is legal or not. + * @details \b Inputs: none + * @details \b Outputs: none + * @param newSubMode the enumerated sub state of the mode + * @return TRUE if request is legal, FALSE if not + *************************************************************************/ +BOOL testValidateDDStandbyChangeReq( U32 newSubMode ) +{ + BOOL result = FALSE; + + if ( newSubMode < NUM_OF_DD_STANDBY_MODE_STATES ) + { + switch ( newSubMode ) + { + case DD_STANDBY_MODE_STATE_IDLE: + result = TRUE; + break; + + case DD_STANDBY_MODE_STATE_PAUSE: + default: + break; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testSignalNewDDStandbySubMode function request transition to a + * new operation sub mode. + * @details \b Inputs: none + * @details \b Outputs: standbyState + * @param newSubMode the enumerated sub state of the mode + * @return none + *************************************************************************/ +void testSignalNewDDStandbySubMode( U32 newSubMode ) +{ + if ( newSubMode < NUM_OF_DD_STANDBY_MODE_STATES ) + { + standbyState = (DD_STANDBY_MODE_STATE_T)newSubMode; + + switch ( newSubMode ) + { + // Any of these state require no special handling + case DD_STANDBY_MODE_STATE_IDLE: + case DD_STANDBY_MODE_STATE_PAUSE: + default: + break; + } + } +} + /**@}*/