/************************************************************************** * * Copyright (c) 2024-2024 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 (original) Vinayakam Mani * @date (original) 06-Aug-2024 * ***************************************************************************/ #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 21.0F ///< Minimum fresh dialysate pressure (PDf) limit for balancing chamber fill operations. #define FRESH_DIAL_PRESSURE_MAX_PSIG 27.0F ///< Maximum fresh dialysate pressure (PDf) limit for balancing chamber fill operations. #define SPENT_DIAL_PRESSURE_MIN_PSIG 27.0F ///< Minimum spent dialysate pressure (PDs) limit for balancing chamber fill operations. #define SPENT_DIAL_PRESSURE_MAX_PSIG 31.0F ///< Maximum spent dialysate pressure (PDs) limit for balancing chamber fill operations. /// 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 BOOL getBalChamberSwitchingOnlyStatus( void ); // Get balancing chamber switching only status void setBalChamberSwitchingOnlyStatus( BOOL OnOff ); // Set balancing chamber switching only 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 BOOL testBCSwitchOnlyStartStopOverride( MESSAGE_T *message ); // To override the balancning chamber switching only start/stop control /**@}*/ #endif