/************************************************************************** * * Copyright (c) 2025-2025 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) 03-Oct-2025 * * @author (original) Vinayakam Mani * @date (original) 28-Jan-2025 * ***************************************************************************/ #ifndef __BAL_CHAMBER_H__ #define __BAL_CHAMBER_H__ #include "DDCommon.h" #include "DDDefs.h" /** * @defgroup BalancingChamber BalancingChamber * @brief Balancing Chamber unit. Performs balancing chamber functions via a state machine. * * @addtogroup BalancingChamber * @{ */ // ********** public definitions ********** #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. /// 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 U32 currentBalChamberSwitchingCounter; ///< Current balancing chamber switching counter BOOL isPressureStalbilizedDuringFill; ///< Whether pressure stabilized during fill or not BOOL balChamberSWOnlyState; ///< Balancing chamber switching only status ( On/Off) } BAL_CHAMBER_DATA_T; // ********** public function prototypes ********** void initBalanceChamber( void ); // Initialize balancing chamber unit void transitionToBalChamberFill( void ); // Prepares for transition to balancing chamber execution U32 execBalancingChamberControl( void ); // Execute the balancing chamber state machine 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 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 void valveControlForBCOpenState( void ); // Open all balancing chamber valves void valveControlForBCFreshSideOnlyOpenState( void ); // Open only fresh side balancing chamber valves 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 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 BOOL testBCSwitchOnlyStartStopOverride( MESSAGE_T *message ); // To override the balancning chamber switching only start/stop control BOOL testAcidDoseVolumeOverride( MESSAGE_T *message ); // To override acid dosing volume BOOL testBicarbDoseVolumeOverride( MESSAGE_T *message ); // To override bicarb dosing volume /**@}*/ #endif