Index: firmware/App/Modes/Prime.c =================================================================== diff -u -r8afac005a36a62d8d36e58a4c46d0225b3367204 -r6a3548084b4c7268dcee35009ab2b0fd6beb9c08 --- firmware/App/Modes/Prime.c (.../Prime.c) (revision 8afac005a36a62d8d36e58a4c46d0225b3367204) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision 6a3548084b4c7268dcee35009ab2b0fd6beb9c08) @@ -8,7 +8,7 @@ * @file Prime.c * * @author (last) Sean Nash -* @date (last) 02-Feb-2023 +* @date (last) 03-May-2023 * * @author (original) Quang Nguyen * @date (original) 08-Dec-2020 @@ -24,6 +24,7 @@ #include "ModeTreatmentParams.h" #include "Prime.h" #include "SelfTests.h" +#include "Switches.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Timers.h" @@ -58,9 +59,10 @@ #define PURGE_AIR_TIME_OUT_COUNT ( 240 * MS_PER_SECOND ) ///< Time period count for purge air time out. #define PRIME_SALINE_DIALYZER_TIME_OUT_COUNT ( 60 * MS_PER_SECOND ) ///< Time period count for prime saline dialyzer time out. #define LOAD_CELL_STEADY_VOLUME_SAMPLING_TIME ( 1 * MS_PER_SECOND ) ///< Time load cell reading steady state detection sampling time in seconds. -#define PRIME_DIALYSATE_BYPASS_TIME_LIMIT ( 15 * MS_PER_SECOND ) ///< Time limit for priming dialysate bypass circuit. +#define PRIME_DIALYSATE_BYPASS_TIME_LIMIT ( 8 * MS_PER_SECOND ) ///< Time limit for priming dialysate bypass circuit. #define STEADY_VOLUME_COUNT_SEC ( 10000 / LOAD_CELL_STEADY_VOLUME_SAMPLING_TIME ) ///< Counter must be greater than 10 seconds before steady volume is true. -#define STEADY_VOLUME_TIME_DEADLINE_MS ( 55 * MS_PER_SECOND ) ///< Time in msec for the steady volume deadline time out. +#define STEADY_VOLUME_DIALYSATE_PRIME_TIME_LIMIT_MS ( 55 * MS_PER_SECOND ) ///< Time in msec for the reservoir volume to stabilize during dialysate prime state. +#define STEADY_VOLUME_BYPASS_PRIME_TIME_LIMIT_MS ( 25 * MS_PER_SECOND ) ///< Time in msec for the reservoir volume to stabilize during bypass dialysate prime state. #define VENOUS_PRESSURE_BUBBLE_CLEAR_MAX_MMHG ( 200.0F ) ///< Maximum venous pressure reading (in mmHg) for bubble clear. #define BUBBLE_CLEAR_WAIT_TIME_INITIAL_MS ( 10 * MS_PER_SECOND ) ///< Time in msec to wait for initial bubble clear pressure. @@ -198,12 +200,7 @@ signalDialInPumpHardStop(); signalDialOutPumpHardStop(); stopSyringePump(); -#ifndef _RELEASE_ - if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) -#endif - { - setAirPumpState( AIR_PUMP_STATE_OFF ); - } + setAirPumpState( AIR_PUMP_STATE_OFF ); // Set valves to default positions setValveAirTrap( STATE_CLOSED ); @@ -421,11 +418,7 @@ { U32 const elapsedPrimeTimeInSecs = calcTimeSince( primeStartTime ) / MS_PER_SECOND; - if ( elapsedPrimeTimeInSecs > MAX_PRIME_TIME ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_PRIME_OUT_OF_TIME, elapsedPrimeTimeInSecs, MAX_PRIME_TIME ); - } - + // timeout alarm that used to trigger when max prime time elapsed was removed. if ( ++primeStatusBroadcastTimerCounter >= PRIME_DATA_PUB_INTERVAL ) { PRIMING_DATA_PAYLOAD_T primeData; @@ -450,7 +443,7 @@ setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); // Allow fluid to get to VBA per DEN-14171 setValveAirTrap( STATE_OPEN ); signalDialOutPumpHardStop(); @@ -494,11 +487,12 @@ } else #endif - - if ( TRUE == primeStartRequested ) { - primeStartRequested = FALSE; - state = HD_PRIME_SALINE_SETUP_STATE; + if ( TRUE == primeStartRequested ) + { + primeStartRequested = FALSE; + state = HD_PRIME_SALINE_SETUP_STATE; + } } return state; @@ -696,7 +690,7 @@ if ( TRUE == getReservoirFillStatus( DG_RESERVOIR_1 ) ) { - if ( TRUE == hasDGCompletedReservoirSwitch() ) + if ( ( TRUE == hasDGCompletedReservoirSwitch() ) && ( DG_RESERVOIR_1 == getDGActiveReservoir() ) ) { U32 dialyzerDialysateVolume = getDialyzerDialysateVolume(); @@ -781,9 +775,9 @@ steadyVolumeSamplingStartTime = getMSTimerCount(); } - if ( TRUE == didTimeout( primeDialysateDialyzerStartTime, primeDialysateDialyzerTimeLimit + STEADY_VOLUME_TIME_DEADLINE_MS ) ) + if ( TRUE == didTimeout( primeDialysateDialyzerStartTime, primeDialysateDialyzerTimeLimit + STEADY_VOLUME_DIALYSATE_PRIME_TIME_LIMIT_MS ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_PRIME_DIALYSATE_DIALYZER_TIME_OUT, primeDialysateDialyzerTimeLimit ); + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PRIME_DIALYSATE_DIALYZER_TIME_OUT, primeDialysateDialyzerTimeLimit ); } if ( TRUE == doesAlarmStatusIndicateStop() ) @@ -850,7 +844,7 @@ // TODO: Rework alarm and timeout logic here. PRIME_SALINE_DIALYZER_TIME_OUT_COUNT may not be reached. if ( TRUE == didTimeout( primeSalineDialyzerStartTime, PRIME_SALINE_DIALYZER_TIME_OUT_COUNT ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_PRIME_SALINE_DIALYZER_TIME_OUT, PRIME_SALINE_DIALYZER_TIME_OUT_COUNT ); // Trigger HD prime saline dialyzer time out alarm. + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PRIME_SALINE_DIALYZER_TIME_OUT, PRIME_SALINE_DIALYZER_TIME_OUT_COUNT ); // Trigger HD prime saline dialyzer time out alarm. } if ( TRUE == doesAlarmStatusIndicateStop() ) @@ -866,7 +860,7 @@ * @brief * The handlePrimeReservoirTwoFillCompleteState function waits for DG to finish * filling reservoir 2 before moving to pre-treatment re-circulation. - * @details Inputs: reservoirFilledStatus[] + * @details Inputs: none * @details Outputs: update valves and pumps configuration on state change * @return current state *************************************************************************/ @@ -876,14 +870,7 @@ if ( TRUE == getReservoirFillStatus( DG_RESERVOIR_2 ) ) { - DG_SWITCH_RSRVRS_CMD_T rsrvrCmd; - - rsrvrCmd.reservoirID = (U32)DG_RESERVOIR_2; - rsrvrCmd.useLastTrimmerHeaterDC = FALSE; - - cmdSetDGActiveReservoir( &rsrvrCmd ); - - if ( TRUE == hasDGCompletedReservoirSwitch() ) + if ( ( TRUE == hasDGCompletedReservoirSwitch() ) && ( DG_RESERVOIR_2 == getDGActiveReservoir() ) ) { signalBloodPumpHardStop(); setDialInPumpTargetFlowRate( DIALYSATE_PUMP_FAST_PRIME_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); @@ -952,9 +939,9 @@ steadyVolumeSamplingStartTime = getMSTimerCount(); } - if ( TRUE == didTimeout( primeDialysateBypassStartTime, PRIME_DIALYSATE_BYPASS_TIME_LIMIT + STEADY_VOLUME_TIME_DEADLINE_MS ) ) // allocate 55 seconds for the steady state logic to do its job before timing out + if ( TRUE == didTimeout( primeDialysateBypassStartTime, PRIME_DIALYSATE_BYPASS_TIME_LIMIT + STEADY_VOLUME_BYPASS_PRIME_TIME_LIMIT_MS ) ) // allocate 25 seconds for the steady state logic to do its job before timing out { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_PRIME_DIALYSATE_BYPASS_TIME_OUT, PRIME_DIALYSATE_BYPASS_TIME_LIMIT ); + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PRIME_DIALYSATE_BYPASS_TIME_OUT, PRIME_DIALYSATE_BYPASS_TIME_LIMIT ); } if ( TRUE == doesAlarmStatusIndicateStop() ) @@ -1008,7 +995,19 @@ static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimePause( void ) { HD_PRE_TREATMENT_PRIME_STATE_T state = HD_PRIME_PAUSE; + BOOL doorClosed = ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ? TRUE : FALSE ); + BOOL latchClosed = ( STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) ? TRUE : FALSE ); + // require front door and pump track to be closed before allowing resume + if ( ( TRUE == doorClosed ) && ( TRUE == latchClosed ) ) + { + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); + } + else + { + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); + } + if ( TRUE == primeResumeRequested ) { primeResumeRequested = FALSE;