Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rc7ed4f90b600fe684097654f150e4972646ffec9 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision c7ed4f90b600fe684097654f150e4972646ffec9) @@ -8,7 +8,7 @@ * @file ModeDrain.c * * @author (last) Dara Navaei -* @date (last) 01-Jan-2022 +* @date (last) 25-Feb-2022 * * @author (original) Leonardo Baloa * @date (original) 20-Dec-2019 @@ -19,6 +19,7 @@ #include "ConductivitySensors.h" #include "DrainPump.h" #include "Heaters.h" +#include "ModeFill.h" #include "ModeDrain.h" #include "OperationModes.h" #include "Pressures.h" @@ -50,11 +51,10 @@ #define DIALYSATE_DRAIN_TIME_OUT ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Dialysate drain time out. -/// Time period to wait for concentrate lines to rinse. -#define RINSE_CONCENTRATE_LINES_WAIT ( 25 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) -/// Reserver the concentrate speed to rinse out concentrate lines. -#define RINSE_SPEED ( ( CONCENTRATE_PUMP_MAX_SPEED - 3.0 ) * -1.0 ) +#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.0 ) * -1.0 ) ///< Reserver the concentrate speed to rinse out concentrate lines. + // ********** private data ********** static DG_DRAIN_STATE_T drainState; ///< Currently active drain state. @@ -108,6 +108,9 @@ { setValveStateDelayed( VRD2, VALVE_STATE_OPEN, DELAY_RES_DRAIN_VALVE_MS ); } + + initDrainParameters( inactiveReservoir ); + // set initial actuator states setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); setDrainPumpTargetRPMDelayed( TARGET_DRAIN_PUMP_RPM, DELAY_DRAIN_PUMP_MS ); @@ -240,6 +243,19 @@ setValveState( VRD2, VALVE_STATE_CLOSED ); } + // check for empty bottles at the end of drain + if ( TRUE == isEmptyAcidBottle() ) // is acid volume < 10% + { + setThisFisrtFillFlag( TRUE ); // indicates bottles need prime + activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); // trigger empty acid bottle alarm + } + + if ( TRUE == isEmptyBicarbBottle() ) + { + setThisFisrtFillFlag( TRUE ); + activateAlarmNoData( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ); + } + if ( TRUE == isReservoirTarePending() ) { // Tare reservoir load cells at empty if requested result = DG_DRAIN_STATE_TARE; @@ -249,9 +265,7 @@ requestNewOperationMode( DG_MODE_GENE ); } } - - // Drain timed out raise the alarm - if ( TRUE == didTimeout( dialysateDrainStartTime, DIALYSATE_DRAIN_TIME_OUT ) ) + else if ( TRUE == didTimeout( dialysateDrainStartTime, DIALYSATE_DRAIN_TIME_OUT ) ) // Drain timed out raise the alarm { activateAlarmNoData( ALARM_ID_DG_DIALYSATE_DRAIN_TIME_OUT ); }