Index: firmware/App/Controllers/BalancingChamber.h =================================================================== diff -u -r977f03e20990ed5579160b9b927df1c0f2428101 -rc53b6d8d57bd64bcfedf8a1bbb0d0eeab4502971 --- firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision 977f03e20990ed5579160b9b927df1c0f2428101) +++ firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision c53b6d8d57bd64bcfedf8a1bbb0d0eeab4502971) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* Copyright (c) 2025-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 BalancingChamber.h * -* @author (last) Vinayakam Mani -* @date (last) 06-Aug-2024 +* @author (last) Jashwant Gantyada +* @date (last) 30-Jun-2026 * * @author (original) Vinayakam Mani -* @date (original) 06-Aug-2024 +* @date (original) 28-Jan-2025 * ***************************************************************************/ @@ -31,25 +31,33 @@ // ********** public definitions ********** -#define FRESH_DIAL_PRESSURE_MIN_PSIG 22.0F ///< Minimum fresh dialysate pressure (D18) limit for balancing chamber fill operations. -#define FRESH_DIAL_PRESSURE_MAX_PSIG 28.0F ///< Maximum fresh dialysate pressure (D18) limit for balancing chamber fill operations. -#define SPENT_DIAL_PRESSURE_MIN_PSIG 30.0F ///< Minimum spent dialysate pressure (D51) limit for balancing chamber fill operations. -#define SPENT_DIAL_PRESSURE_MAX_PSIG 40.0F ///< Maximum spent dialysate pressure (D51) limit for balancing chamber fill operations. +#define FRESH_DIAL_PRESSURE_MIN_PSIG 23.0F ///< Minimum fresh dialysate pressure (D18) limit for balancing chamber fill operations. +#define FRESH_DIAL_PRESSURE_MAX_PSIG 27.0F ///< Maximum fresh dialysate pressure (D18) limit for balancing chamber fill operations. +#define SPENT_DIAL_PRESSURE_MIN_PSIG 33.0F ///< Minimum spent dialysate pressure (D51) limit for balancing chamber fill operations. +#define SPENT_DIAL_PRESSURE_MAX_PSIG 37.0F ///< Maximum spent dialysate pressure (D51) limit for balancing chamber fill operations. #define BC_FRESH_FILL_PRESSURE_PSIG 15.0F ///< Fresh side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. #define BC_SPENT_FILL_PRESSURE_PSIG 29.0F ///< Spent side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. #define BAL_CHAMBER_FILL_VOLUME_ML 30.0F ///< Balancing chamber fill/drain volume per batch operation. +#define BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM 250 ///< Minimum D48 speed and fixed speed for time-based balancing chamber switching. +#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_1 50.0F ///< Band 1 flowrate(50 mL/min) +#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_2 60.0F ///< Band 2 flowrate(60 mL/min) +#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_3 70.0F ///< Band 3 flowrate(70 mL/min) +#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_4 80.0F ///< Band 4 flowrate(80 mL/min) +#define BAL_CHAMBER_TIME_BASED_BAND_1 250 ///< Speed at D48 pump runs when the flowrate is between 50 mL/min and 60 mL/min. +#define BAL_CHAMBER_TIME_BASED_BAND_2 290 ///< Speed at D48 pump runs when the flowrate is between 60 mL/min and 70 mL/min. +#define BAL_CHAMBER_TIME_BASED_BAND_3 330 ///< Speed at D48 pump runs when the flowrate is between 80 mL/min and 80 mL/min. /// balancing chamber data structure typedef struct { U32 balChamberExecState; ///< Balancing chamber execution state U32 balChamberSWState; ///< Balancing chamber switching state (state 1 or state 2) F32 balChamberSWFreq; ///< Balancing chamber switching frequency - U32 balChamberSwPeriod; ///< Balancing chamber switching period - BOOL isBalChamberFillInProgress; ///< Whether balancing chamber fill in progress or not + BOOL isSpentFillComplete; ///< Whether balancing chamber spent fill completed or not U32 currentBalChamberSwitchingCounter; ///< Current balancing chamber switching counter - BOOL isPressureStalbilizedDuringFill; ///< Whether pressure stabilized during fill or not + BOOL isPressureStabilizedDuringFill; ///< Whether pressure stabilized during fill or not BOOL balChamberSWOnlyState; ///< Balancing chamber switching only status ( On/Off) + BOOL isBalChamberSwitchingActive; ///< Balancing chamber switching status } BAL_CHAMBER_DATA_T; // ********** public function prototypes ********** @@ -58,9 +66,11 @@ void transitionToBalChamberFill( void ); // Prepares for transition to balancing chamber execution U32 execBalancingChamberControl( void ); // Execute the balancing chamber state machine +void requestBalChamberSwitching( BOOL activate ); // Activates or Deactivates Balancing Chamber Switching. void updateBalChamberSwitchingPeriod( void ); // Update the balancing chamber switching period BAL_CHAMBER_EXEC_STATE_T getCurrentBalancingChamberExecState( void ); // Get the current state of the balancing chamber execution F32 getBalChamberSwitchingFreq( void ); // Get the balancing chamber switching frequency +F32 getBalChamberActiveDialysateFlowrate( void ); // Get the active Qd used by balancing chamber timing U32 getDialDeliveryProgressStatus( void ); // Get the dialysate delivery in progress status BOOL getBalancingChamberFillinProgressStatus( void ); // Get the balancing chamber fill in progress status void valveControlForBCClosedState( void ); // Closes all balancing chamber valves @@ -69,6 +79,11 @@ BOOL getBalChamberSwitchingOnlyStatus( void ); // Get balancing chamber switching only status void setBalChamberSwitchingOnlyStatus( BOOL OnOff ); // Set balancing chamber switching only status U32 getBalChamberSwitchingPeriod( void ); // Get balancing chamber switching period +F32 getBalancingChamberError( void ); // Get balancing chamber error to adjust UF rate. +F32 getBicarbDoseVol( void ); // Get liquid bicarb dose volume +F32 getAcidDoseVol( void ); // Get acid dose volume +BOOL isBalChamberSwitchImminent( void ); // Get the balancing chamber is within the valve-close window (50 ms) before switching. +BOOL getBalChamberFreshSideValvesClosedStatus( void ); // Get the balancing chamber fresh side valve close status BOOL testDDBalChamberDataPublishIntervalOverride( MESSAGE_T *message ); // To override the balancing chamber data publish interval BOOL testBalChamberSwFreqOverride( MESSAGE_T *message ); // To override the balancing chamber switching frequency