Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r66cc826068b54bc436cde0fae70a05ba6c1ac974 -r1722e975682c9e41e0b75551ada1139d3dc522a6 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 66cc826068b54bc436cde0fae70a05ba6c1ac974) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 1722e975682c9e41e0b75551ada1139d3dc522a6) @@ -38,30 +38,34 @@ // ********** private definitions ********** -#define TARGET_DRAIN_PUMP_RPM 2300 ///< 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 TARGET_DRAIN_PUMP_RPM 2300 ///< 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_EMPTY_TARE_WAIT ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Time period to wait after drain complete and before taring load cells. +#define DRAIN_EMPTY_TARE_WAIT ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Time period to wait after drain complete and before taring load cells. -#define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. -#define TARGET_RO_FLOW_RATE_L 0.3F ///< Target flow rate for RO pump. +#define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. +#define TARGET_RO_FLOW_RATE_L 0.3F ///< Target flow rate for RO pump. -#define DELAY_RES_DRAIN_VALVE_MS 1000 ///< Delay reservoir drain valve open by 1 second. -#define DELAY_DRAIN_PUMP_MS 2000 ///< Delay drain pump on by 2 seconds. +#define DELAY_RES_DRAIN_VALVE_MS 1000 ///< Delay reservoir drain valve open by 1 second. +#define DELAY_DRAIN_PUMP_MS 2000 ///< Delay drain pump on by 2 seconds. -#define DIALYSATE_DRAIN_TIME_OUT ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Dialysate drain time out. +#define DIALYSATE_DRAIN_TIME_OUT ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Dialysate drain time out. -#define RINSE_CONCENTRATE_LINES_WAIT ( 25 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Time period to wait for concentrate lines to rinse. +#define RINSE_CONCENTRATE_LINES_WAIT ( 25 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Time period to wait for concentrate lines to rinse. -#define RINSE_SPEED ( ( CONCENTRATE_PUMP_MAX_SPEED - 3.0F ) * -1.0F ) ///< Reserver the concentrate speed to rinse out concentrate lines. +#define RINSE_SPEED ( ( CONCENTRATE_PUMP_MAX_SPEED - 3.0F ) * -1.0F ) ///< Reserver the concentrate speed to rinse out concentrate lines. +#define ACID_CONCENTRATION_BOTTLE_VOLUME_ML 3430.0F ///< Bottle volume of acid concentration in mL. +#define BICARB_CONCENTRATION_BOTTLE_VOLUME_ML 3780.0F ///< Bottle volume of bicarb concentration in mL. +#define CONCENTRATION_BOTTLE_LOW_VOLUME_ML 100.0F ///< Concentration bottle low volume in mL. + // ********** private data ********** -static DG_DRAIN_STATE_T drainState; ///< Currently active drain state. -static U32 drainEmptyTareTimerCtr; ///< Timer counter for delay between drain complete and load cell tare. -static BOOL rinseConcentrateLines; ///< Flag indicates to rinse concentrate lines. -static U32 rinseConcentrateLinesTimerCtr; ///< Timer counter for rinsing concentrate lines. -static U32 dialysateDrainStartTime; ///< Dialysate drain start time. +static DG_DRAIN_STATE_T drainState; ///< Currently active drain state. +static U32 drainEmptyTareTimerCtr; ///< Timer counter for delay between drain complete and load cell tare. +static BOOL rinseConcentrateLines; ///< Flag indicates to rinse concentrate lines. +static U32 rinseConcentrateLinesTimerCtr; ///< Timer counter for rinsing concentrate lines. +static U32 dialysateDrainStartTime; ///< Dialysate drain start time. // ********** private function prototypes ********** static DG_DRAIN_STATE_T handleDrainStateStart( void ); @@ -243,15 +247,17 @@ setValveState( VRD2, VALVE_STATE_CLOSED ); } - // check for empty bottles at the end of drain - if ( TRUE == isEmptyAcidBottle() ) // is acid volume < 10% + // Detect empty bottles using integrated volumes + if ( ( ( ACID_CONCENTRATION_BOTTLE_VOLUME_ML - getChemicalUsedVolumeML( ACID ) ) <= CONCENTRATION_BOTTLE_LOW_VOLUME_ML ) ) // || // SRSDG 437 { + resetChemicalUsedVolumeML( ACID ); setThisFisrtFillFlag( TRUE ); // indicates bottles need prime - activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); // trigger empty acid bottle alarm + activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); } - if ( TRUE == isEmptyBicarbBottle() ) + if ( ( ( BICARB_CONCENTRATION_BOTTLE_VOLUME_ML - getChemicalUsedVolumeML( BICARB ) ) <= CONCENTRATION_BOTTLE_LOW_VOLUME_ML ) ) // || // SRSDG 438 { + resetChemicalUsedVolumeML( BICARB ); setThisFisrtFillFlag( TRUE ); activateAlarmNoData( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ); }