Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -rd03ddbc63925f2e5a5a5ceeba3487992e65a8ecf -r773bd9e1eebab013afa0b303231be73e8016c84c --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision d03ddbc63925f2e5a5a5ceeba3487992e65a8ecf) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 773bd9e1eebab013afa0b303231be73e8016c84c) @@ -241,32 +241,28 @@ 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 + } + else 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; } -// else -// { -// requestNewOperationMode( DG_MODE_GENE ); -// } + else + { + requestNewOperationMode( DG_MODE_GENE ); + } } - // 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 - } - else if ( TRUE == isEmptyBicarbBottle() ) // is bicarb volume < 10% - { - setThisFisrtFillFlag( TRUE ); // indicates bottles need prime - activateAlarmNoData( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ); // trigger empty bicarb bottle alarm - } - else - { - requestNewOperationMode( DG_MODE_GENE ); // in idle, reject moving from idle to fill if alarm is active - } - // Drain timed out raise the alarm if ( TRUE == didTimeout( dialysateDrainStartTime, DIALYSATE_DRAIN_TIME_OUT ) ) { Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r3bdc6566ae1bccafce60d942c23be54a8d1c2acf -r773bd9e1eebab013afa0b303231be73e8016c84c --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 3bdc6566ae1bccafce60d942c23be54a8d1c2acf) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 773bd9e1eebab013afa0b303231be73e8016c84c) @@ -23,6 +23,7 @@ #include "Heaters.h" #include "LoadCell.h" #include "ModeFill.h" +#include "ModeGenIdle.h" #include "NVDataMgmtDGRecords.h" #include "NVDataMgmt.h" #include "OperationModes.h" @@ -62,8 +63,6 @@ #define ACID_BICARB_CONCENTRATE_ADDITION_MULTIPLER 1.06 ///< Acid and bicarbonate concentrates make up around 6% to total volume. #define FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE 0.1 ///< Flow integrated volume has 10% tolerance compare to load cell reading. -#define CONDUCTIVITY_WHEN_ACID_JUG_EMPTY 10000.0 ///< The conductivity value when the acid jug is empty. -#define CONDUCTIVITY_WHEN_BICARB_JUG_EMPTY 12000.0 ///< The conductivity value when the bicarb jug is empty. #define ACID_TEST_CD1_TCD 12252.1 ///< Used for testing CD1 acid theoretical conductivity. #define ACID_TEST_CD2_TCD ACID_TEST_CD1_TCD ///< Used for testing CD2 acid theoretical conductivity. #define BICARB_TEST_CD2_TCD 6820.91 ///< Used for testing CD2 bicarb theoretical conductivity. @@ -97,7 +96,6 @@ F32 fillFlowRateAverage; ///< Fill flow average value. F32 fillLastTemperature; ///< Fill last temperature value. BOOL isThisFirstFill; ///< Fill flag to indicate whether it is the first fill or not. - BOOL fillAvgConductivityOutOfRange; ///< Fill average conductivity out of range. BOOL fillEmtyAcidBottleDetected; ///< Fill acid bottle empty detected. BOOL fillEmtyBicarbBottleDetected; ///< Fill bicarb bottle empty detected. } FILL_CONDITION_STATUS_T; @@ -379,7 +377,6 @@ fillStatus.fillTemperatureAverage = getHeaterTargetTemperature( DG_TRIMMER_HEATER ); fillStatus.fillLastTemperature = getHeaterTargetTemperature( DG_TRIMMER_HEATER ) + RESERVOIR_EXTRA_TEMPERATURE; fillStatus.isThisFirstFill = TRUE; - fillStatus.fillAvgConductivityOutOfRange = FALSE; fillStatus.fillEmtyAcidBottleDetected = FALSE; fillStatus.fillEmtyBicarbBottleDetected = FALSE; } @@ -399,19 +396,6 @@ /*********************************************************************//** * @brief - * The isAvgConductivityOutOfRange function returns the boolean flag that indicates - * whether the average conductivity is out of range. - * @details Inputs: none - * @details Outputs: none - * @return fillStatus.fillAvgConductivityOutOfRange - *************************************************************************/ -BOOL isAvgConductivityOutOfRange( void ) -{ - return fillStatus.fillAvgConductivityOutOfRange; -} - -/*********************************************************************//** - * @brief * The isEmptyAcidBottle function returns the boolean flag that indicates * whether the acid bottle is empty. * @details Inputs: none @@ -759,10 +743,8 @@ requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID ); requestConcentratePumpOff( CONCENTRATEPUMPS_CP2_BICARB ); setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - //activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); // trigger empty acid bottle alarm at the end of drain mode and set both bottles need prime fillStatus.isThisFirstFill = TRUE; // empty bottles need replaced, set isThisFirstFill to FALSE so that prime, flush, acid & bicarb test are needed fillStatus.fillEmtyAcidBottleDetected = TRUE; // set this variable to FALSE when user presses OK on the alarm to confirm bottle has been replaced and resume - //requestNewOperationMode( DG_MODE_GENE ); } if ( ( ( BICARB_CONCENTRATION_BOTTLE_VOLUME_ML - getF32OverrideValue( &usedBicarbVolumeML ) ) <= CONCENTRATION_BOTTLE_LOW_VOLUME_ML ) ) // || // SRSDG 438 @@ -771,13 +753,13 @@ requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID ); requestConcentratePumpOff( CONCENTRATEPUMPS_CP2_BICARB ); setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - //activateAlarmNoData( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ); // trigger empty bicarb bottle alarm at the end of drain mode and set both bottles need prime fillStatus.isThisFirstFill = TRUE; fillStatus.fillEmtyBicarbBottleDetected = TRUE; - //requestNewOperationMode( DG_MODE_GENE ); // Fill -> Generation Idle } #endif + setBadAvgConductivityDetectedFlag( FALSE ); + // If we've reached our target fill to volume (by weight), we're done filling - go back to generation idle mode // SRSDG 398 if ( TRUE == hasTargetFillVolumeBeenReached( inactiveReservoir ) ) { @@ -786,9 +768,6 @@ F32 avgAcidConductivity = acidConductivityTotal / conductivitySampleCount; F32 avgBicarbConductivity = bicarbConductivityTotal / conductivitySampleCount; - fillStatus.fillAvgConductivityOutOfRange = FALSE; // init to FALSE when fill has reached target - - #ifndef DISABLE_FLOW_CHECK_IN_FILL if ( integratedVolumeToLoadCellReadingPercent > FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE ) // SRSDG 439 { @@ -799,17 +778,17 @@ #ifndef DISABLE_DIALYSATE_CHECK // SRSDG 400 if ( TRUE == isValueWithinPercentRange( avgBicarbConductivity, BICARB_NORMAL_CONDUCTIVITY, FIVE_PERCENT_FACTOR ) ) { - fillStatus.fillAvgConductivityOutOfRange = TRUE; // flag to signal idle mode to handle bad fill fillStatus.isThisFirstFill = TRUE; + setBadAvgConductivityDetectedFlag( TRUE ); // signal idle bad avg conductivity detected setThisFisrtFillFlag( TRUE ); SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FILL_CONDUCTIVITY_OUT_OF_RANGE, avgBicarbConductivity, BICARB_NORMAL_CONDUCTIVITY ); // trigger replace bottles alarm #1 activateAlarmNoData ( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT ); } if ( TRUE == isValueWithinPercentRange( avgAcidConductivity, ACID_NORMAL_CONDUCTIVITY, FIVE_PERCENT_FACTOR ) ) { - fillStatus.fillAvgConductivityOutOfRange = TRUE; // flag to signal idle mode to handle bad fill fillStatus.isThisFirstFill = TRUE; + setBadAvgConductivityDetectedFlag( TRUE ); // signal idle bad avg conductivity detected setThisFisrtFillFlag( TRUE ); SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FILL_CONDUCTIVITY_OUT_OF_RANGE, avgAcidConductivity, ACID_NORMAL_CONDUCTIVITY ); // trigger replace bottles alarm #1 then activateAlarmNoData ( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT ); Index: firmware/App/Modes/ModeFill.h =================================================================== diff -u -r0c599603188536e9d329fbd60a8768affd0c49a2 -r773bd9e1eebab013afa0b303231be73e8016c84c --- firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision 0c599603188536e9d329fbd60a8768affd0c49a2) +++ firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision 773bd9e1eebab013afa0b303231be73e8016c84c) @@ -55,8 +55,6 @@ BOOL isEmptyBicarbBottle( void ); -BOOL isAvgConductivityOutOfRange( void ); - BOOL testSetUsedAcidVolumeMLOverride( F32 value ); BOOL testSetUsedBicarbVolumeMLOverride( F32 value ); Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -rd03ddbc63925f2e5a5a5ceeba3487992e65a8ecf -r773bd9e1eebab013afa0b303231be73e8016c84c --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision d03ddbc63925f2e5a5a5ceeba3487992e65a8ecf) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 773bd9e1eebab013afa0b303231be73e8016c84c) @@ -44,17 +44,19 @@ #define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. #define TARGET_RO_FLOW_RATE_L 0.3 ///< Target flow rate for RO pump. +#define BAD_FLUSH_FILL_TARGET_VOLUME_ML 1000 ///< Target fill volume in the bad flush fill state. /// The time of HD lost comm before DG transition back to standby. #define HD_LOST_COMM_TIMEOUT_MS (5 * SEC_PER_MIN * MS_PER_SECOND ) // ********** private data ********** -static DG_GEN_IDLE_MODE_STATE_T genIdleState; ///< Currently active generation idle state. -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T badFillState; ///< Current active bad fill state. -static U32 hdLostCommStartTime_ms = 0; ///< Lost communication with HD start time in ms. -static U32 targetFillVolumeML; ///< Save the target fill volume before calling startFillCmd() -static BOOL handleBadFillFlag; ///< Internal signal flag to handle bad fill +static DG_GEN_IDLE_MODE_STATE_T genIdleState; ///< Currently active generation idle state. +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T badFillState = DG_HANDLE_BAD_FILL_STATE_START; ///< Initialize bad fill sub-state. +static U32 hdLostCommStartTime_ms = 0; ///< Lost communication with HD start time in ms. +static U32 targetFillVolumeML; ///< Save the target fill volume before calling startFillCmd(). +static BOOL handleBadFillFlag; ///< Internal signal flag to handle bad fill. +static BOOL badAvgConductivityDetected; ///< Bad average conductivity detected. // ********** private function prototypes ********** @@ -82,6 +84,7 @@ hdLostCommStartTime_ms = 0; targetFillVolumeML = 0; handleBadFillFlag = FALSE; + badAvgConductivityDetected = FALSE; } /*********************************************************************//** @@ -157,6 +160,18 @@ /*********************************************************************//** * @brief + * The setBadAvgConductivityDetectedFlag function sets a flag to indicate + * that bad average conductivity is detected. + * @details Inputs: none + * @details Outputs: none + * @param flag to TRUE if bad avg conductivity otherwise FALSE + *************************************************************************/ +void setBadAvgConductivityDetectedFlag( BOOL badAvgConducitivyflag ) +{ + badAvgConductivityDetected = badAvgConducitivyflag; +} +/*********************************************************************//** + * @brief * The execGenIdleMode function executes the generation idle mode state machine. * @details Inputs: genIdleState * @details Outputs: Check water quality, generation idle mode state machine executed @@ -187,7 +202,6 @@ switch ( genIdleState ) { case DG_GEN_IDLE_MODE_STATE_START: - badFillState = DG_HANDLE_BAD_FILL_STATE_START; genIdleState = handleIdleStartState(); break; @@ -220,14 +234,14 @@ { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_START; - if ( TRUE == isAvgConductivityOutOfRange() ) + if ( TRUE == badAvgConductivityDetected ) { handleBadFillFlag = TRUE; } if ( TRUE == handleBadFillFlag ) { - result = DG_GEN_IDLE_MODE_STATE_HANDLE_BAD_FILL ; + result = DG_GEN_IDLE_MODE_STATE_HANDLE_BAD_FILL; } else { @@ -279,7 +293,7 @@ badFillState = handleFlushFillState(); break; - case DG_HANDLE_BAD_FILL_STATE_SECOND_DRAIN: // idle 1.2 + case DG_HANDLE_BAD_FILL_STATE_SECOND_DRAIN: // idle 1.2. badFillState = handleSecondDrainState(); break; @@ -310,7 +324,7 @@ *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFirstDrainState( void ) { - DG_GEN_IDLE_MODE_BAD_FILL_STATE_T result = DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL; // after first drain is completed, go to next sub-state + DG_GEN_IDLE_MODE_BAD_FILL_STATE_T result = DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL; // after first drain is completed, go to next bad fill sub-state requestNewOperationMode( DG_MODE_DRAI ); // go to drain mode to empty bad dialysate because this is a bad fill @@ -328,14 +342,13 @@ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFlushFillState( void ) { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T result = DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL; - U32 fillToVolumeML = 1000; if ( FALSE == isAlarmActive( ALARM_ID_FILL_CONDUCTIVITY_OUT_OF_RANGE ) ) // alarm is no longer active - cleared by user { targetFillVolumeML = getTargetFillVolumeML(); // save the HD target fill volume before command 1000 mL fill volume - startFillCmd( fillToVolumeML, getTargetFillFlowRateLPM() ); + startFillCmd( BAD_FLUSH_FILL_TARGET_VOLUME_ML, getTargetFillFlowRateLPM() ); - if ( TRUE == isAvgConductivityOutOfRange() ) + if ( TRUE == badAvgConductivityDetected ) { result = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; // (idle 1.0) } @@ -397,7 +410,7 @@ // clear wait for dialysate alarm condition to allow resume clearAlarmCondition( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT ); // resume option will appear handleBadFillFlag = FALSE; // set flag to FALSE here so next call to idle exec will move to normal flush water state - requestNewOperationMode( DG_MODE_GENE ); // go to generation idle mode + genIdleState = DG_GEN_IDLE_MODE_STATE_START; return result; } Index: firmware/App/Modes/ModeGenIdle.h =================================================================== diff -u -rd502fb7b72c8b3aa4f3a7cdbc4b3c4f7b5ae7c92 -r773bd9e1eebab013afa0b303231be73e8016c84c --- firmware/App/Modes/ModeGenIdle.h (.../ModeGenIdle.h) (revision d502fb7b72c8b3aa4f3a7cdbc4b3c4f7b5ae7c92) +++ firmware/App/Modes/ModeGenIdle.h (.../ModeGenIdle.h) (revision 773bd9e1eebab013afa0b303231be73e8016c84c) @@ -36,6 +36,7 @@ void initGenIdleMode( void ); // initialize this module U32 transitionToGenIdleMode( void ); // prepares for transition to generation idle mode U32 execGenIdleMode( void ); // execute the generation idle mode state machine (call from OperationModes) +void setBadAvgConductivityDetectedFlag( BOOL badAvgConducitivyflag ); // used by fill mode to signal idle mode of bad average conductivity DG_GEN_IDLE_MODE_STATE_T getCurrentGenIdleState( void ); // get the current state of generation idle mode