Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -ra069eb423b26296eb95214e18383c81adae07497 -r604d8aaceeb8e0b650ac2054644333fc7717bb51 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision a069eb423b26296eb95214e18383c81adae07497) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 604d8aaceeb8e0b650ac2054644333fc7717bb51) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file ModeDrain.c * -* @author (last) Sean Nash -* @date (last) 12-Nov-2021 +* @author (last) Dara Navaei +* @date (last) 31-Mar-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 ); }