Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r7bbf1fb04f7e4788c3072ca173413ed052c608d3 -r316f8773970f94c9b1996a03f2235050afb514da --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 7bbf1fb04f7e4788c3072ca173413ed052c608d3) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 316f8773970f94c9b1996a03f2235050afb514da) @@ -37,6 +37,8 @@ #define RESERVOIR_SETTLE_TIME_MS 5000 ///< Time (in ms) allotted for reservoir to settle (after fill, before drain). +#define MAX_RESERVOIR_VOLUME_ML 1950.0 ///< Maximum reservoir volume. Switch reservoirs if active reservoir exceeds this volume. + #define SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. /// States of the treatment reservoir management state machine. @@ -227,6 +229,19 @@ } resUseTimer = getMSTimerCount(); + // Alarm if active reservoir is full and inactive reservoir is not yet ready + if ( getReservoirWeight( getDGActiveReservoir() ) > MAX_RESERVOIR_VOLUME_ML ) + { + if ( currentTrtResMgmtState < TREATMENT_RESERVOIR_MGMT_WAIT_FOR_RES_SWITCH_STATE ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_RESERVOIR_FULL_AND_DG_NOT_READY_TO_SWITCH, getReservoirWeight( getDGActiveReservoir(), (F32)currentTrtResMgmtState ) + } + else + { + clearAlarmCondition( ALARM_ID_HD_RESERVOIR_FULL_AND_DG_NOT_READY_TO_SWITCH ); + } + } + // Treatment reservoir mgmt. state machine switch ( currentTrtResMgmtState ) { @@ -266,8 +281,14 @@ if ( DG_MODE_CIRC == dgOpMode ) { if ( DG_RECIRCULATE_MODE_STATE_RECIRC_WATER == dgSubMode ) - { - cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML ); + { + U32 fillToVolume = FILL_RESERVOIR_TO_VOLUME_ML; + + if ( getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ) <= SLOW_DIALYSATE_FLOW_ML_MIN ) + { + fillToVolume = FILL_RESERVOIR_TO_VOLUME_LOW_FLOW_ML; + } + cmdStartDGFill( fillToVolume ); } } else @@ -298,9 +319,8 @@ case TREATMENT_RESERVOIR_MGMT_WAIT_FOR_RES_SWITCH_STATE: // Reservoir switch during treatment should only occur in this state (i.e. when DG is ready). - // Switch reservoirs when active reservoir is spent (i.e. we have pumped fill volume through dialyzer) and DG ready - if ( ( DG_MODE_CIRC == getDGOpMode() ) && ( DG_RECIRCULATE_MODE_STATE_RECIRC_WATER == getDGSubMode() ) && - ( resUseVolumeMl >= (F32)dgReservoirFillVolumeTargetSet ) ) + // Switch reservoirs when active reservoir is spent or full (i.e. we have pumped fill volume through dialyzer) and DG ready + if ( ( resUseVolumeMl >= (F32)dgReservoirFillVolumeTargetSet ) || ( getReservoirWeight( getDGActiveReservoir() ) > MAX_RESERVOIR_VOLUME_ML ) ) { DG_RESERVOIR_ID_T inactiveRes = getDGInactiveReservoir(); @@ -519,6 +539,23 @@ return result; } +/*********************************************************************//** + * @brief + * The getReservoirWeight function gets the load cell weight of a given + * reservoir. + * @details Inputs: loadCellWeightInGrams[] + * @details Outputs: none + * @param resID ID of reservoir to get weight for + * @return the current weight of the given reservoir in grams + *************************************************************************/ +F32 getReservoirWeight( DG_RESERVOIR_ID_T resID ) +{ + LOAD_CELL_ID_T lc = ( DG_RESERVOIR_1 == resID ? LOAD_CELL_RESERVOIR_1_PRIMARY : LOAD_CELL_RESERVOIR_2_PRIMARY ); + F32 wt = getLoadCellWeight( lc ); + + return wt; +} + /*********************************************************************//** * @brief * The setDGOpMode function sets the latest DG operating mode reported by