Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -rf5b02f03b6695c0c76fd8a4d902a13114e1a8aca -ra52e41cc2219362d433149ca034908c8763d8378 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision f5b02f03b6695c0c76fd8a4d902a13114e1a8aca) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision a52e41cc2219362d433149ca034908c8763d8378) @@ -64,6 +64,7 @@ // TODO - set initial actuator states // VDr to drain + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); } /*********************************************************************//** @@ -109,7 +110,20 @@ static DG_DRAIN_STATE_T handleDrainState( void ) { DG_DRAIN_STATE_T result = DG_DRAIN_STATE_DRAIN; + LOAD_CELL_ID_T drainWeightLoadCell = LOAD_CELL_A1; + // determine which load cell to use for drain volume - we want weight of inactive reservoir + if ( RESERVOIR_1 == getActiveReservoir() ) + { + 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 ) ) + { + requestNewOperationMode( DG_MODE_CIRC ); + } + return result; } Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rf5b02f03b6695c0c76fd8a4d902a13114e1a8aca -ra52e41cc2219362d433149ca034908c8763d8378 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision f5b02f03b6695c0c76fd8a4d902a13114e1a8aca) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision a52e41cc2219362d433149ca034908c8763d8378) @@ -68,6 +68,8 @@ // TODO - set initial actuator states setFPGAValveStates(0x014F); // VDr, VPo to drain + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); // Conc. pumps on } @@ -122,8 +124,7 @@ // TODO - transition when temperature and mix is in range if ( 1 ) { - // TODO - VPo to reservoir - setFPGAValveStates(0x015F); + setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; } @@ -148,8 +149,7 @@ if ( 0 ) { - // TODO - VPo to drain - setFPGAValveStates(0x014F); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); result = DG_FILL_MODE_STATE_DIALYSATE_PRODUCTION; } Index: firmware/App/Modes/ModeRecirculate.c =================================================================== diff -u -r3e7b064885d99793bb56d940bd613555b1cdbdfa -ra52e41cc2219362d433149ca034908c8763d8378 --- firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision 3e7b064885d99793bb56d940bd613555b1cdbdfa) +++ firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision a52e41cc2219362d433149ca034908c8763d8378) @@ -139,7 +139,7 @@ // when enough water volume has flowed to flush the lines, transition to re-circ state if ( flushLinesVolume >= FLUSH_LINES_VOLUME_L ) { - // TODO - change VDr from drain to re-circulate + setValveState( VDR, VALVE_STATE_RECIRC_C_TO_NC ); result = DG_RECIRCULATE_MODE_STATE_RECIRC_WATER; } Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r3e7b064885d99793bb56d940bd613555b1cdbdfa -ra52e41cc2219362d433149ca034908c8763d8378 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 3e7b064885d99793bb56d940bd613555b1cdbdfa) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision a52e41cc2219362d433149ca034908c8763d8378) @@ -21,6 +21,7 @@ #include "OperationModes.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" +#include "Valves.h" #include "Reservoirs.h" /** @@ -61,7 +62,11 @@ *************************************************************************/ void initReservoirs( void ) { - activeReservoir.data = RESERVOIR_1; + activeReservoir.data = RESERVOIR_2; + setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); + setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NC ); + setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); fillVolumeTargetMl.data = DEFAULT_FILL_VOLUME_ML; drainVolumeTargetMl.data = DEFAULT_DRAIN_VOLUME_ML; } @@ -104,11 +109,29 @@ // switch reservoir command only valid in re-circulate mode if ( DG_MODE_CIRC == getCurrentOperationMode() ) { - // validate parameters - if ( resID < NUM_OF_RESERVOIRS ) + switch ( resID ) { - activeReservoir.data = (U32)resID; - result = TRUE; + case RESERVOIR_1: + activeReservoir.data = (U32)resID; + result = TRUE; + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + break; + + case RESERVOIR_2: + activeReservoir.data = (U32)resID; + result = TRUE; + setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); + setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NC ); + setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); + break; + + default: + // invalid reservoir given - cmd will be NAK'd w/ false result. + break; } }