Index: firmware/App/Controllers/Valves.h =================================================================== diff -u -rf5baeac6a5f000705cd51e4779a967acf4088981 -rc07917caced76b53a0ed8f35167fac6f9d8310a4 --- firmware/App/Controllers/Valves.h (.../Valves.h) (revision f5baeac6a5f000705cd51e4779a967acf4088981) +++ firmware/App/Controllers/Valves.h (.../Valves.h) (revision c07917caced76b53a0ed8f35167fac6f9d8310a4) @@ -1,79 +1,33 @@ /************************************************************************** * -* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* Copyright (c) 2024-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 ValvesDD.h +* @file Valves.h * -* @author (last) Vinayakam Mani -* @date (last) 14-Aug-2024 +* @author (last) “Raghu +* @date (last) 16-Oct-2025 * * @author (original) Vinayakam Mani -* @date (original) 14-Aug-2024 +* @date (original) 26-Aug-2024 * ***************************************************************************/ - -#ifndef __VALVES_DD_H__ -#define __VALVES_DD_H__ - + +#ifndef __VALVES_DD_H__ +#define __VALVES_DD_H__ + #include "DDCommon.h" - -/** - * @defgroup Valves Valves + +/** + * @defgroup Valves Valves * @brief Valves driver unit. Controls all hydraulics valves, balancing chamber and - * ultrafiltration valves through FPGA Interface. - * - * @addtogroup Valves - * @{ + * ultrafiltration valves through FPGA Interface. + * + * @addtogroup Valves + * @{ */ - -/// Enumeration of valves. -typedef enum Valves -{ - FIRST_HYD_VALVE = 0, ///< Start of Hydraulics valve group - D14_VALV = FIRST_HYD_VALVE, ///< Valve Hydraulics Outlet (D14) - D52_VALV, ///< Valve Thermal Disinfect (D52) - D8_VALV, ///< Valve Hydraulics Bypass (D8) - D54_VALV, ///< Valve Rinse Port (D54) - D53_VALV, ///< Valve Drain (D53) - D34_VALV, ///< Valve Dialyzer Bypass (D34) - D64_VALV, ///< Valve Purge 1 (D64) - D31_VALV, ///< Valve Pressure Test (D31) - D65_VALV, ///< Valve DryBcarb Inlet (D65) - D35_VALV, ///< Valve Dialyzer Inlet (D35) - D40_VALV, ///< Valve Dialyzer Outlet (D40) - D47_VALV, ///< Valve Dialysate Out Purge 2 (D47) - D3_VALV, ///< Valve Hydraulics Inlet (D3) - M4_VALV, ///< Valve Water Inlet (M4) -#ifdef __PUMPTEST__ - UF1, ///< UF1 valve - UF2, ///< UF2 valve - LAST_HYD_VALVE = UF2, ///< End of Hydraulics valve of group -#else - LAST_HYD_VALVE = M4_VALV, ///< End of Hydraulics valve of group - RSRVD_SPACE1, ///< This space has been reserved - RSRVD_SPACE2, ///< This space has been reserved -#endif - FIRST_BC_VALVE, ///< Start of Balancing Chamber valve group - D23_VALV = FIRST_BC_VALVE, ///< Balancing chamber Valve 1 (D23) - D19_VALV, ///< Balancing chamber Valve 2 (D19) - D25_VALV, ///< Balancing chamber Valve 3 (D25) - D26_VALV, ///< Balancing chamber Valve 7 (D26) - D24_VALV, ///< Balancing chamber Valve 5 (D24) - D20_VALV, ///< Balancing chamber Valve 6 (D20) - D21_VALV, ///< Balancing chamber Valve 4 (D21) - D22_VALV, ///< Balancing chamber Valve 8 (D22) - LAST_BC_VALVE = D22_VALV, ///< End of Balancing Chamber valve group - FIRST_UF_VALVE, ///< Start of Ultrafiltration valve group - D69_VALV = FIRST_UF_VALVE, ///< Ultrafiltration Valve 1 Inlet (D69) - D71_VALV, ///< Ultrafiltration Valve 2 Inlet (D71) - D70_VALV, ///< Ultrafiltration Valve 1 Outlet (D70) - D72_VALV, ///< Ultrafiltration Valve 2 Outlet (D72) - LAST_UF_VALVE = D72_VALV, ///< End of Ultrafiltration valve group - NUM_OF_VALVES ///< Number of valves -} VALVES_T; /// Enumeration of available valve state names per valve type (from SA and DD SRS documents). typedef enum ValveStateNames @@ -83,41 +37,56 @@ NUM_OF_VALVE_STATES ///< number of valve states } VALVE_STATE_NAMES_T; +#define NUM_OF_DD_VALVES ( ( LAST_DD_VALVE - FIRST_DD_VALVE ) + 1 ) +#define NUM_OF_IOFP_VALVES ( ( LAST_FP_VALVE - FIRST_IO_VALVE ) + 1 ) +#define NUM_OF_IO_VALVES ( ( LAST_IO_VALVE - FIRST_IO_VALVE ) + 1 ) +#define NUM_OF_FP_VALVES ( ( LAST_FP_VALVE - FIRST_FP_VALVE ) + 1 ) + #pragma pack(push, 1) /// Valves publish structure typedef struct { U16 valvesStatus; ///< 2 way valves status. U08 valvesBCStatus; ///< Balancing chamber valves status. - U08 valvesUFStatus; ///< Ultrafiltration valves status. - U08 valvesSensedState[ NUM_OF_VALVES ]; ///< DD valves sensed states. + U08 valveSPStatus; ///< Spare valves status. + U08 valvesSensedState[ LAST_DD_VALVE + 1 ]; ///< DD sensed valve states. } DD_VALVES_DATA_T; +/// Valves publish structure +typedef struct +{ + U08 valvesIOState; ///< Commanded IO valve states (bits). + U08 valvesFPState; ///< Commanded FP valve states (bits). + U08 valvesSensedState[ NUM_OF_IOFP_VALVES ]; ///< Sensed FP valve states (enumerations). +} FP_VALVES_DATA_T; + /// Balancing chamber valve states override structure typedef struct { U32 valveStatesBits; ///< Bits indicating whether balancing chamber valve states should be open(1) or closed(0). } DD_BC_VALVE_OVERRIDE_PAYLOAD_T; -#pragma pack(pop) - -// ********** public function prototypes ********** - -void initValves( void ); -void execValves( void ); +#pragma pack(pop) -BOOL setValveState( VALVES_T valve, VALVE_STATE_NAMES_T valveState ); -BOOL setValveStateDelayed( VALVES_T valve, VALVE_STATE_NAMES_T valveState, U32 delayMs ); -VALVE_STATE_NAMES_T getValveStateName( VALVES_T valveID ); +// ********** public function prototypes ********** + +void initValves( void ); +void execValves( void ); + +BOOL setValveState( DD_VALVES_T valve, VALVE_STATE_NAMES_T valveState ); +BOOL setValveStateDelayed( DD_VALVES_T valve, VALVE_STATE_NAMES_T valveState, U32 delayMs ); +VALVE_STATE_NAMES_T getValveStateName( DD_VALVES_T valveID ); void setHydValvesStatetoClosedState( void ); -void setUFValvesStatetoClosedState( void ); - + BOOL testValvesStatesPublishIntervalOverride( MESSAGE_T *message ); BOOL testValveStateOverride( MESSAGE_T *message ); BOOL testBCValveStatesOverride( MESSAGE_T *message ); BOOL testValveSensedStateOverride( MESSAGE_T *message ); BOOL testValveOpenCloseStateOverride( MESSAGE_T *message ); - -/**@}*/ - -#endif +BOOL testIOFPValvesStatesPublishIntervalOverride( MESSAGE_T *message ); +BOOL testIOFPValveStateOverride( MESSAGE_T *message ); +BOOL testIOFPValveSensedStateOverride( MESSAGE_T *message ); + +/**@}*/ + +#endif