/************************************************************************** * * Copyright (c) 2019-2020 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 ModeFault.c * * @author (last) Quang Nguyen * @date (last) 24-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include "DrainPump.h" #include "Heaters.h" #include "ModeFault.h" #include "OperationModes.h" #include "ROPump.h" #include "UVReactors.h" #include "Valves.h" /** * @addtogroup DGFaultMode * @{ */ // ********** private definitions ********** // ********** private data ********** static DG_FAULT_STATE_T faultState = DG_FAULT_STATE_START; ///< Currently active fault state. // ********** private function prototypes ********** /*********************************************************************//** * @brief * The initFaultMode function initializes the Fault Mode module. * @details Inputs: none * @details Outputs: Fault mode module initialized * @return none *************************************************************************/ void initFaultMode( void ) { faultState = DG_FAULT_STATE_START; } /*********************************************************************//** * @brief * The transitionToFaultMode function prepares for transition to fault mode. * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void transitionToFaultMode( void ) { } /*********************************************************************//** * @brief * The execFaultMode function executes the fault mode state machine. * @details Inputs: none * @details Outputs: Fault mode state machine executed * @return current state of fault mode *************************************************************************/ U32 execFaultMode( void ) { // execute current fault state switch ( faultState ) { case DG_FAULT_STATE_START: break; default: // TODO - s/w fault faultState = DG_FAULT_STATE_START; break; } return faultState; } /*********************************************************************//** * @brief * The getCurrentFaultState function returns the current state of the fault mode. * @details Inputs: faultState * @details Outputs: none * @return current state of fault mode *************************************************************************/ DG_FAULT_STATE_T getCurrentFaultState( void ) { return faultState; } /*********************************************************************//** * @brief * The deenergizeActuators function sets all the actuators to reset and * de-energized state. * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void deenergizeActuators( void ) { // Turn off the UV reactors turnOffUVReactor( INLET_UV_REACTOR ); turnOffUVReactor( OUTLET_UV_REACTOR ); // De-energize all the valves setValveState( VPI, VALVE_STATE_CLOSED ); setValveState( VBF, VALVE_STATE_CLOSED ); setValveState( VSP, VALVE_STATE_CLOSED ); #ifndef V_2_SYSTEM setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NO ); #else setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); #endif setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VRO, VALVE_STATE_R1_C_TO_NO ); #ifndef V_2_SYSTEM setValveState( VRD1, VALVE_STATE_CLOSED ); setValveState( VRD2, VALVE_STATE_CLOSED ); #else setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); #endif setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); //TODO add the composition pumps signalROPumpHardStop(); signalDrainPumpHardStop(); stopPrimaryHeater(); stopTrimmerHeater(); } /**@}*/