Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r2510a84808ee5179d3f84f0b04f24c5a4122dbe5 -r58129c9bb3053c39efa07f60e975f17e2a04755a --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 2510a84808ee5179d3f84f0b04f24c5a4122dbe5) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 58129c9bb3053c39efa07f60e975f17e2a04755a) @@ -7,19 +7,22 @@ * * @file ModeDrain.c * -* @author (last) Sean Nash -* @date (last) 02-Jul-2020 +* @author (last) Quang Nguyen +* @date (last) 24-Aug-2020 * * @author (original) Leonardo Baloa * @date (original) 20-Dec-2019 * ***************************************************************************/ +#include "ConductivitySensors.h" #include "DrainPump.h" #include "LoadCell.h" #include "ModeDrain.h" #include "OperationModes.h" +#include "Pressures.h" #include "Reservoirs.h" +#include "TemperatureSensors.h" #include "Valves.h" /** @@ -41,10 +44,10 @@ /*********************************************************************//** * @brief - * The initOpParamsMode function initializes the Drain Mode module. + * The initDrainMode function initializes the drain mode module. * @details * Inputs : none - * Outputs : Operating Parameters Mode module initialized. + * Outputs : drainState * @return none *************************************************************************/ void initDrainMode( void ) @@ -54,11 +57,10 @@ /*********************************************************************//** * @brief - * The transitionToDrainMode function prepares for transition to drain \n - * mode. + * The transitionToDrainMode function prepares for transition to drain mode. * @details * Inputs : none - * Outputs : + * Outputs : Drain mode initialized * @return none *************************************************************************/ void transitionToDrainMode( void ) @@ -68,19 +70,25 @@ // set initial actuator states setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setDrainPumpTargetSpeed( TARGET_DRAIN_PUMP_RPM ); + setDrainPumpTargetRPM( TARGET_DRAIN_PUMP_RPM ); } /*********************************************************************//** * @brief - * The execDrainMode function executes the Drain Mode state machine. + * The execDrainMode function executes the drain mode state machine. * @details - * Inputs : none - * Outputs : + * Inputs : drainState + * Outputs : Check water quality, drain mode state machine executed * @return current state. *************************************************************************/ U32 execDrainMode( void ) { + // check inlet water conductivity, temperature, pressure, and RO rejection ratio + checkInletWaterConductivity(); + checkInletWaterTemperature(); + checkInletPressure(); + checkRORejectionRatio(); + // execute current drain state switch ( drainState ) { @@ -93,7 +101,7 @@ break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, drainState ) // TODO - add s/w fault enum to 1st data param + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, drainState ) // TODO - add s/w fault enum to 1st data param drainState = DG_DRAIN_STATE_START; break; } @@ -103,11 +111,10 @@ /*********************************************************************//** * @brief - * The handleDrainState function handles the drain state of the Drain Mode \n - * state machine. + * The handleDrainState function handles the drain state of the drain mode state machine. * @details * Inputs : none - * Outputs : + * Outputs : Drain out from reservoir * @return the next state *************************************************************************/ static DG_DRAIN_STATE_T handleDrainState( void ) @@ -116,19 +123,15 @@ LOAD_CELL_ID_T drainWeightLoadCell = LOAD_CELL_A1; // determine which load cell to use for drain volume - we want weight of inactive reservoir -#ifndef BETA_V1_BUILD if ( RESERVOIR_1 == getActiveReservoir() ) -#else - if ( RESERVOIR_2 == getActiveReservoir() ) -#endif { drainWeightLoadCell = LOAD_CELL_B1; } // if we've reached our target drain to volume (by weight), we're done draining - go back to re-circ mode if ( getReservoirDrainVolumeTargetMl() >= getLoadCellFilteredWeight( drainWeightLoadCell ) ) { - setDrainPumpTargetSpeed( 0 ); + setDrainPumpTargetRPM( 0 ); requestNewOperationMode( DG_MODE_CIRC ); } @@ -137,8 +140,7 @@ /*********************************************************************//** * @brief - * The getCurrentDrainState function returns the current state of the \n - * drain mode. + * The getCurrentDrainState function returns the current state of the drain mode. * @details * Inputs : drainState * Outputs : none