Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -rebd43ef11d75ff69de2eda6aec1142858bc1237e -r8a4182663ef6b12e3fd6414c0c14158943cd4ce1 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision ebd43ef11d75ff69de2eda6aec1142858bc1237e) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 8a4182663ef6b12e3fd6414c0c14158943cd4ce1) @@ -34,7 +34,7 @@ // ********** private definitions ********** #define TARGET_DRAIN_PUMP_RPM 2100 ///< Target drain pump speed (in RPM). -#define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 2 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. +#define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 15 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. #define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. #define TARGET_RO_FLOW_RATE_L 0.3 ///< Target flow rate for RO pump. @@ -43,6 +43,8 @@ static DG_DRAIN_STATE_T drainState = DG_DRAIN_STATE_START; ///< Currently active drain state. +static U32 tempTrans = 0; + // ********** private function prototypes ********** static DG_DRAIN_STATE_T handleDrainState( void ); @@ -71,7 +73,7 @@ // re-initialize each time we transition to drain mode initDrainMode(); -#ifndef V_2_SYSTEM +/*#ifndef V_2_SYSTEM DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); if ( DG_RESERVOIR_1 == inactiveReservoir ) @@ -82,12 +84,18 @@ { setValveState( VRD2, VALVE_STATE_OPEN ); } -#endif +#endif*/ - // set initial actuator states + // TODO test code remove + DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); + tempTrans = 0; setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + // TODO test code remove - setDrainPumpTargetRPM( TARGET_DRAIN_PUMP_RPM ); + // set initial actuator states + //setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); TODO uncomment + + //setDrainPumpTargetRPM( TARGET_DRAIN_PUMP_RPM ); //TODO comment this for testing setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); } @@ -136,8 +144,27 @@ static DG_DRAIN_STATE_T handleDrainState( void ) { DG_DRAIN_STATE_T result = DG_DRAIN_STATE_DRAIN; + + // TODO test code remove DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); + if ( ++tempTrans == 20 ) + { + if ( DG_RESERVOIR_2 == inactiveReservoir ) + { + setValveState( VRD2, VALVE_STATE_OPEN ); + } + else if ( DG_RESERVOIR_1 == inactiveReservoir ) + { + setValveState( VRD1, VALVE_STATE_OPEN ); + } + } + else if ( tempTrans == 40 ) + { + setDrainPumpTargetRPM( TARGET_DRAIN_PUMP_RPM ); + } + // TODO test code remove + // if we have reached our target drain to volume (by weight) or cannot drain anymore, we are done draining - go back to re-circ mode if ( TRUE == hasTargetDrainVolumeBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT ) ) {