Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -r74bbba7a4f0e454b04c23acfc40e6ca3ec13472c -r43ebe58702128e865210533f9e6deaf13f99d262 --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 74bbba7a4f0e454b04c23acfc40e6ca3ec13472c) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 43ebe58702128e865210533f9e6deaf13f99d262) @@ -8,7 +8,7 @@ * @file DryBiCart.c * * @author (last) Sameer Kalliadan Poyil -* @date (last) 16-Jun-2026 +* @date (last) 25-Jun-2026 * * @author (original) Vinayakam Mani * @date (original) 19-Nov-2025 @@ -52,14 +52,12 @@ #define DRY_BICART_FILL_COMPLETE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to reset the request flag after fill complete #define DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCDI2_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID2 #define DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCID1_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID1 -#define GET_DRY_BICART_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) \ - != TRUE ? DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ) +#define GET_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) != TRUE ? \ + DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ) ///< Get fill complete pressure based on the WCID configuration #define DRY_BICART_FILL_INITIATE_PRESSURE_PSI 1.5F ///< Minimum pressure required to initiate the dry bicart fill process. #define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 10.0F ///< Maximum pressure allowed at bicart fill during supply process/state #define DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI 3.0F ///< Minimum pressure required to initiate the dry bicart fill during supply process/state -#define MAX_DRY_BICART_FILL_COMPLETE_PRESSURE 20.0F ///< Very max dry bicart fill complete pressure for persistence on d66 -#define DRY_BICART_DEFAULT_MAX_FILL_CYCLE_CNT 10 ///< Default max fill cycle allowed for dry bicart fill/mix with water. -#define DRY_BICART_MAX_FILL_CYCLE_CNT 15 ///< Max fill cycle allowed (by override) for dry bicart fill/mix with water. +#define DRY_BICART_MAX_FILL_CYCLE_CNT 10 ///< Max fill cycle allowed (by override) for dry bicart fill/mix with water. #define DRY_BICART_MINIMUM_FILL_CYCLE_CNT 3 ///< Minimum fill cycle count for filling dry bicart // Dry Bicart Fill Vent #define DRY_BICART_FILL_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bicart gas before actuating Bicarb chamber(F) venting. @@ -98,6 +96,7 @@ DRY_BICART_INITIAL_FILL, ///< Dry bicart initial fill DRY_BICART_SUPPLY, ///< Dry bicart chamber fill DRY_BICART_DRAIN, ///< Dry bicart drain + DRY_BICART_DEPRESSURIZE, ///< Dry bicart depressurize NUM_OF_DRY_BICART_OPERATION ///< Number of dry bicart operation } DRY_BICART_OPERATION_T; @@ -106,6 +105,7 @@ static DRY_BICART_FILL_EXEC_STATE_T dryBiCartFillExecState; ///< Current state of dry bicart fill executive state machine. static BICARB_CHAMBER_FILL_EXEC_STATE_T bicarbChamberFillExecState; ///< Current state of bicarb chamber fill executive state machine. static DRY_BICART_DRAIN_EXEC_STATE_T dryBiCartDrainExecState; ///< Current state of dry bicart drain executive state machine +static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T dryBiCartDepressurizeExecState; ///< Current state of dry bicart depressurize executive state machine // fill static U32 dryBiCartFillStartTime; ///< Dry bicart fill start time. static U32 biCartFillCycleCounter; ///< Number of drybicart fill cycle @@ -120,6 +120,7 @@ static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop dry bicart fill. static OVERRIDE_U32_T bicarbChamberFillRequested; ///< Start/stop bicarb chamber fill. static OVERRIDE_U32_T dryBiCartDrainRequested; ///< Start/stop dry bicart drain. +static OVERRIDE_U32_T dryBiCartDepressurizeRequested; ///< Start/stop dry bicart depressurize // publish static OVERRIDE_U32_T dryBiCartDataPublishInterval; ///< Dry bicart data publish interval. static U32 dryBiCartDataPublicationTimerCounter; ///< Used to schedule drybicart data publication to CAN bus. @@ -167,6 +168,10 @@ static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainDurationCheckState( void ); static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainEndState( void ); +static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeStartState( void ); +static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeVentStartState( void ); +static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeVentEndState( void ); + static F32 getDryBicartLowerCartPressure( void ); static F32 getDryBicartUpperCartPressure( void ); @@ -194,8 +199,8 @@ dryBiCartDataPublishInterval.ovInitData = 0; dryBiCartDataPublishInterval.override = OVERRIDE_RESET; - biCartMaxFillCycleCount.data = DRY_BICART_DEFAULT_MAX_FILL_CYCLE_CNT; - biCartMaxFillCycleCount.ovData = DRY_BICART_DEFAULT_MAX_FILL_CYCLE_CNT; + biCartMaxFillCycleCount.data = DRY_BICART_MAX_FILL_CYCLE_CNT; + biCartMaxFillCycleCount.ovData = DRY_BICART_MAX_FILL_CYCLE_CNT; biCartMaxFillCycleCount.ovInitData = 0; biCartMaxFillCycleCount.override = OVERRIDE_RESET; @@ -271,9 +276,6 @@ *************************************************************************/ void execDryBicart( void ) { - - execMixingControl(); - // top level state machine selection DRY_BICART_OPERATION_T dryBicartState = dryBicartStartRequest; @@ -299,6 +301,11 @@ execDryBicartDrainMode(); break; + case DRY_BICART_DEPRESSURIZE: + // Dry bicart depressurize + execDryBicartDepressurize(); + break; + default: // software fault, dryBicartStartRequest = DRY_BICART_IDLE; @@ -455,16 +462,53 @@ /*********************************************************************//** * @brief + * The execDryBicartDepressurize function executes the dry bicart depressurize state machine. + * @details \b Inputs: dryBiCartDepressurizeExecState + * @details \b Outputs: dryBiCartDepressurizeExecState + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong dry bicart depressurize state + * invoked. + * @return current state. + *************************************************************************/ +U32 execDryBicartDepressurize( void ) +{ + // execute drybicart depressurize state machines + switch ( dryBiCartDepressurizeExecState ) + { + case DRY_BICART_DEPRESSURIZE_START_STATE: + dryBiCartDepressurizeExecState = handleDryBicartDepressurizeStartState(); + break; + + case DRY_BICART_DEPRESSURIZE_VENT_START_STATE: + dryBiCartDepressurizeExecState = handleDryBicartDepressurizeVentStartState(); + break; + + case DRY_BICART_DEPRESSURIZE_VENT_END_STATE: + dryBiCartDepressurizeExecState = handleDryBicartDepressurizeVentEndState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_DRY_BICART_DEPRESURIZE_INVALID_EXEC_STATE, dryBiCartDepressurizeExecState ); + break; + } + + return dryBiCartDepressurizeExecState; +} + +/*********************************************************************//** + * @brief * The setBicarbChamberFillRequested function sets the chmaberFillRequest * flag value to be True. - * @details \b Inputs: dryBiCartFillRequested, dryBiCartDrainRequested + * @details \b Inputs: dryBiCartFillRequested, dryBiCartDrainRequested, + * dryBiCartDepressurizeRequested * @details \b Outputs: bicarbChamberFillRequested * @return TRUE if successful, FALSE if not. *************************************************************************/ BOOL setBicarbChamberFillRequested( void ) { BOOL result = FALSE; - BOOL requestStatus = getU32OverrideValue( &dryBiCartFillRequested ) || getU32OverrideValue( &dryBiCartDrainRequested ); + BOOL requestStatus = getU32OverrideValue( &dryBiCartFillRequested ) ||\ + getU32OverrideValue( &dryBiCartDrainRequested ) || \ + getU32OverrideValue( &dryBiCartDepressurizeRequested ); // ensure that there is no other operation in progress before new request set to true if ( FALSE == requestStatus ) @@ -538,14 +582,17 @@ * @brief * The setBicartFillRequested function sets the bicart fill request * flag value to be True. - * @details \b Inputs: bicarbChamberFillRequested, dryBiCartDrainRequested + * @details \b Inputs: bicarbChamberFillRequested, dryBiCartDrainRequested, + * dryBiCartDepressurizeRequested * @details \b Outputs: dryBiCartFillRequested * @return TRUE if successful, FALSE if not. *************************************************************************/ BOOL setBicartFillRequested( void ) { BOOL result = FALSE; - BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) || getU32OverrideValue( &dryBiCartDrainRequested ); + BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) \ + || getU32OverrideValue( &dryBiCartDrainRequested ) || \ + getU32OverrideValue( &dryBiCartDepressurizeRequested ) ; //ensure that there is no other operation in progress before new request set to true if ( FALSE == requestStatus ) @@ -581,14 +628,17 @@ * @brief * The setBicartDrainRequested function sets the bicart drain request * flag value to be True. - * @details \b Inputs: bicarbChamberFillRequested,dryBiCartFillRequested + * @details \b Inputs: bicarbChamberFillRequested,dryBiCartFillRequested, + * dryBiCartDepressurizeRequested * @details \b Outputs: dryBiCartDrainRequested * @return TRUE if successful, FALSE if not. *************************************************************************/ BOOL setBicartDrainRequested( void ) { BOOL result = FALSE; - BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) || getU32OverrideValue( &dryBiCartFillRequested ); + BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) || \ + getU32OverrideValue( &dryBiCartFillRequested ) || \ + getU32OverrideValue( &dryBiCartDepressurizeRequested ); //ensure that there is no other operation in progress before new request set to true if ( FALSE == requestStatus ) @@ -622,6 +672,51 @@ /*********************************************************************//** * @brief + * The setBicartDepressurizeRequested function sets the bicart depressurize request + * flag value to be True. + * @details \b Inputs: bicarbChamberFillRequested,dryBiCartFillRequested,dryBiCartDrainRequested + * @details \b Outputs: dryBiCartDepressurizeRequested + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +BOOL setBicartDepressurizeRequested( void ) +{ + BOOL result = FALSE; + BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) || \ + getU32OverrideValue( &dryBiCartFillRequested ) || \ + getU32OverrideValue( &dryBiCartDrainRequested ); + + //ensure that there is no other operation in progress before new request set to true + if ( FALSE == requestStatus ) + { + dryBiCartDepressurizeRequested.data = TRUE; + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getBicartDepressurizeRequested function gets the bicart depressurize request + * flag value + * @details \b Inputs: dryBiCartDepressurizeRequested + * @details \b Outputs: none + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +BOOL getBicartDepressurizeRequested( void ) +{ + BOOL result = FALSE; + + if ( ( TRUE == getU32OverrideValue( &dryBiCartDepressurizeRequested ) ) ) + { + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The getCurrentDryBiCartFillExecState function returns the current state * of the dry bicart fill state. * @details \b Inputs: dryBiCartFillExecState @@ -663,7 +758,8 @@ /*********************************************************************//** * @brief - * The updateDrybicartOperation function initiates the water fill, bicarbonate supply or bicarbonate drain + * The updateDrybicartOperation function initiates bicart fill water, bicarbonate supply, + * bicart drain or bicart depressurize * operation * @details \b Inputs: none * @details \b Outputs: dryBicartStartRequest @@ -686,6 +782,10 @@ //drain dryBicartStartRequest = DRY_BICART_DRAIN; } + else if ( TRUE == getBicartDepressurizeRequested() ) + { + dryBicartStartRequest = DRY_BICART_DEPRESSURIZE; + } else { // idle @@ -765,7 +865,7 @@ { DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_FILL_WATER_END_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); - F32 fillCompletePressure = GET_DRY_BICART_FILL_COMPLETE_PRESSURE_PSI; + F32 fillCompletePressure = GET_FILL_COMPLETE_PRESSURE_PSI; // Close dry bicart inlet water if D66 pressure is 17 PSI if ( d66Pressure >= fillCompletePressure ) @@ -775,19 +875,7 @@ { dryBiCartPersistenceStartTime = getMSTimerCount(); } - //check the the maximum cart pressure during persistence on D66 - if ( d66Pressure >= MAX_DRY_BICART_FILL_COMPLETE_PRESSURE ) - { - setValveState( D65_VALV, VALVE_STATE_CLOSED ); - lastFillDurationInMS = currentFillDurationInMS; - currentFillDurationInMS = calcTimeSince( dryBiCartFillStartTime ); - //Increment number of fill cycle - biCartFillCycleCounter++; - dryBiCartPersistenceStartTime = 0; - - state = DRY_BICART_DEGAS_START_STATE; - } // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { @@ -802,6 +890,10 @@ state = DRY_BICART_DEGAS_START_STATE; } } + else + { + dryBiCartPersistenceStartTime = 0; + } //TODO:Handle timeout alarm for opening D65 valve too long return state; @@ -876,6 +968,10 @@ state = DRY_BICART_FILL_DURATION_CHECK_STATE; } + else + { + dryBiCartPersistenceStartTime = 0; + } } //TODO: Alarm when vent timeout exceeded, but pressure not dropped below expected PSI (0 psi) @@ -1037,7 +1133,7 @@ { BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_END_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); - F32 fillCompletePressure = GET_DRY_BICART_FILL_COMPLETE_PRESSURE_PSI; + F32 fillCompletePressure = GET_FILL_COMPLETE_PRESSURE_PSI; closeD65IfBalChamberSwitchImminent(); @@ -1061,15 +1157,7 @@ { dryBiCartPersistenceStartTime = getMSTimerCount(); } - // check the the maximum cart pressure during persistence on D66 - if ( d66Pressure >= MAX_DRY_BICART_FILL_COMPLETE_PRESSURE ) - { - // Close water inlet valve as D66 pressure reaches max PSI(20) after persistence - setValveState( D65_VALV, VALVE_STATE_CLOSED ); - dryBiCartPersistenceStartTime = 0; - state = BICARB_CHAMBER_SUPPLY_STATE; - } // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { @@ -1080,6 +1168,10 @@ state = BICARB_CHAMBER_SUPPLY_STATE; } } + else + { + dryBiCartPersistenceStartTime = 0; + } return state; } @@ -1176,19 +1268,19 @@ { dryBiCartPersistenceStartTime = getMSTimerCount(); } - //check the the maximum cart pressure during persistence on D66 - if ( d66Pressure >= MAX_DRY_BICART_FILL_COMPLETE_PRESSURE ) - { - setValveState( D65_VALV, VALVE_STATE_CLOSED ); - dryBiCartPersistenceStartTime = 0; - } + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; } } + else + { + dryBiCartPersistenceStartTime = 0; + drybicartPersistenceOnLowercartPressureStartTime = 0; + } return state; } @@ -1236,6 +1328,10 @@ state = BICARB_SUPPLY_VENT_END_STATE; } + else + { + dryBiCartPersistenceStartTime = 0; + } } return state; @@ -1290,32 +1386,6 @@ dryBiCartDrainTimePeriod = SMALL_DRY_BICART_MAX_DRAIN_TIME_MS; } - //Close D14 valve - setValveState( D14_VALV, VALVE_STATE_CLOSED ); - setValveState( D34_VALV, VALVE_STATE_CLOSED ); - setValveState( D35_VALV, VALVE_STATE_CLOSED ); - setValveState( D40_VALV, VALVE_STATE_CLOSED ); - setValveState( D91_VALV, VALVE_STATE_CLOSED ); - - // open bypass valve - setValveState( D34_VALV, VALVE_STATE_OPEN ); - - // open DD drain - setValveState( D53_VALV, VALVE_STATE_OPEN ); - - // open iofp drain valve - setValveState( M12_VALV, VALVE_STATE_OPEN ); - - // Open balancing chamber valves - valveControlForBCOpenState(); - - // Run D10 In Open loop mode(max speed 200ml/min) - setConcentratePumpTargetSpeed( D10_PUMP, DRAIN_BICART_PUMP_SPEED, DOSING_CONT_VOLUME ); - requestConcentratePumpOn( D10_PUMP ); - - // Run D48 at 1000 rpm,There is no improvement over above 1000 rpm for drain duration. - setDialysatePumpTargetRPM( D48_PUMP, DIAL_PUMP_DRAIN_RPM, TRUE ); - dryBiCartDrainStartTime = getMSTimerCount(); dryBiCartDrainLastCondSampleTime = dryBiCartDrainStartTime; dryBiCartDrainCondStableCount = 0; @@ -1338,14 +1408,33 @@ { DRY_BICART_DRAIN_EXEC_STATE_T state = DRY_BICART_FLUID_DRAIN_STATE; - // Open vent valves and close de-scaling valve - setValveState( D80_VALV, VALVE_STATE_OPEN ); + //Close D14 valve + setValveState( D14_VALV, VALVE_STATE_CLOSED ); + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + setValveState( D35_VALV, VALVE_STATE_CLOSED ); + setValveState( D40_VALV, VALVE_STATE_CLOSED ); + setValveState( D91_VALV, VALVE_STATE_CLOSED ); setValveState( D81_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_OPEN ); + // Open vent valves and close descaling valve + setValveState( D80_VALV, VALVE_STATE_OPEN ); + setValveState( D85_VALV, VALVE_STATE_OPEN ); // Open D64 valve (vent for equilibrium) setValveState( D64_VALV, VALVE_STATE_OPEN ); + // open bypass valve + setValveState( D34_VALV, VALVE_STATE_OPEN ); + // TODO: open iofp drain valve, remove, this should be handled in IO/FP module. + setValveState( M12_VALV, VALVE_STATE_OPEN ); + // Open balancing chamber valves + valveControlForBCOpenState(); + // Run D10 In Open loop mode(max speed 200ml/min) + setConcentratePumpTargetSpeed( D10_PUMP, DRAIN_BICART_PUMP_SPEED, DOSING_CONT_VOLUME ); + requestConcentratePumpOn( D10_PUMP ); + + // Run D48 at 1000 rpm,There is no improvement over above 1000 rpm for drain duration. + setDialysatePumpTargetRPM( D48_PUMP, DIAL_PUMP_DRAIN_RPM, TRUE ); + state = DRY_BICART_FLUID_DRAIN_DURATION_CHECK_STATE; return state; @@ -1380,14 +1469,10 @@ setValveState( D64_VALV, VALVE_STATE_CLOSED ); setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D85_VALV, VALVE_STATE_CLOSED ); - // close bypass valve setValveState( D34_VALV, VALVE_STATE_CLOSED ); - // TODO: close DD drain - setValveState( D53_VALV, VALVE_STATE_CLOSED ); - - // TODO : close iofp drain valve + // TODO : close iofp drain valve, remove this should be handled in IO/FP module. setValveState( M12_VALV, VALVE_STATE_CLOSED ); //close all balancing chamber valves @@ -1447,6 +1532,97 @@ /*********************************************************************//** * @brief + * The handleDryBicartDepressurizeStartState function set the one time actuation + * for drybicart de-pressurise request. + * @details \b Inputs: dryBiCartDepressurizeRequested + * @details \b Outputs: none + * @return the next drybicart depressurize state. + *************************************************************************/ +static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeStartState( void ) +{ + DRY_BICART_DEPRESSURIZE_EXEC_STATE_T state = DRY_BICART_DEPRESSURIZE_START_STATE; + + if ( TRUE == getU32OverrideValue( &dryBiCartDepressurizeRequested ) ) + { + setValveState( D85_VALV, VALVE_STATE_OPEN ); + + state = DRY_BICART_DEPRESSURIZE_VENT_START_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleDryBicartDepressurizeVentStartState function handles the vent start state for + * drybicart de-pressurise + * @details \b Inputs: dryBiCarbSypplyVentStartTime, dryBiCartPersistenceStartTime + * @details \b Outputs: none + * @return the next drybicart depressurize state. + *************************************************************************/ +static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeVentStartState( void ) +{ + DRY_BICART_DEPRESSURIZE_EXEC_STATE_T state = DRY_BICART_DEPRESSURIZE_VENT_START_STATE; + + F32 d66Pressure = getFilteredPressure( D66_PRES ); + + if ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_SUPPLY_VENT_TIME_MS ) ) + { + //Vent chamber F to atmosphere + setValveState( D64_VALV, VALVE_STATE_OPEN ); + + // D66 pressure drops to below 1.5 PSI or time out + if ( ( d66Pressure <= DRY_BICART_FILL_VENT_COMPLETE_PRESSURE_PSI ) ) + { + // start the persistence timer once d66 reaches if it drops below 1.5 + if ( 0 == dryBiCartPersistenceStartTime ) + { + dryBiCartPersistenceStartTime = getMSTimerCount(); + } + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening + if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) + { + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + dryBiCartPersistenceStartTime = 0; + + state = DRY_BICART_DEPRESSURIZE_VENT_END_STATE; + } + } + else + { + dryBiCartPersistenceStartTime = 0; + } + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleDryBicartDepressurizeVentEndState function handles the vent end state for + * drybicart de-pressurise + * @details \b Inputs: none + * @details \b Outputs: dryBiCartDepressurizeRequested + * @return the next drybicart depressurize state. + *************************************************************************/ +static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeVentEndState( void ) +{ + DRY_BICART_DEPRESSURIZE_EXEC_STATE_T state = DRY_BICART_DEPRESSURIZE_VENT_END_STATE; + + // Go idle + dryBiCartDepressurizeRequested.data = FALSE; + // for this request override also cleared + dryBiCartDepressurizeRequested.ovData = FALSE; + + state = DRY_BICART_DEPRESSURIZE_START_STATE; + + dryBicartStartRequest = DRY_BICART_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief * The publishDryBicartData function broadcasts the dry bicart * data at defined interval. * @details \b Inputs: dryBiCartDataPublicationTimerCounter @@ -1573,6 +1749,23 @@ /*********************************************************************//** * @brief + * The testDryBiCartDepressurizeRequestOverride function starts/stops the bicart + * depressurize request + * @details \b Inputs: dryBiCartDepressurizeRequested + * @details \b Outputs: dryBiCartDepressurizeRequested + * @param message set message from Dialin which includes the bicart + * depressurize request start/stop. + * @return TRUE if set request is successful, FALSE if not + *************************************************************************/ +BOOL testDryBiCartDepressurizeRequestOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &dryBiCartDepressurizeRequested, FALSE, TRUE ); + + return result; +} + +/*********************************************************************//** + * @brief * The testDryBiCartTypeOverride function selects small/large cartridge type * @details \b Inputs: dryBiCartType * @details \b Outputs: dryBiCartType