/************************************************************************** * * 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 ValvesDD.h * * @author (last) Vinayakam Mani * @date (last) 14-Aug-2024 * * @author (original) Vinayakam Mani * @date (original) 14-Aug-2024 * ***************************************************************************/ #ifndef __VALVES_DD_H__ #define __VALVES_DD_H__ #include "DDCommon.h" /** * @defgroup Valves Valves * @brief Valves driver unit. Controls all hydraulics valves, balancing chamber and * ultrafiltration valves through FPGA Interface. * * @addtogroup Valves * @{ */ /// Enumeration of available valve state names per valve type (from SA and DD SRS documents). typedef enum ValveStateNames { VALVE_STATE_OPEN = 0, ///< Open valve state, VALVE_STATE_CLOSED, ///< Closed valve state, 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 valveSPStatus; ///< Spare valves status. U08 valvesSensedState[ LAST_DD_VALVE + 1 ]; ///< DD sensed valve states. } DD_VALVES_DATA_T; /// Valves publish structure typedef struct { U16 valvesCmdState; ///< 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 ); 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 ); 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 ); BOOL testIOFPValvesStatesPublishIntervalOverride( MESSAGE_T *message ); BOOL testIOFPValveStateOverride( MESSAGE_T *message ); BOOL testIOFPValveSensedStateOverride( MESSAGE_T *message ); /**@}*/ #endif