Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -raed14ca8e1c47f2a821ae279103bfe0bbd346bee -r8747e947a7bc52dc3a4fb1346935740e08f5e974 --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision aed14ca8e1c47f2a821ae279103bfe0bbd346bee) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 8747e947a7bc52dc3a4fb1346935740e08f5e974) @@ -7,8 +7,8 @@ * * @file BloodPrime.c * -* @author (last) Sean Nash -* @date (last) 12-Apr-2023 +* @author (last) Michael Garthwaite +* @date (last) 15-May-2023 * * @author (original) Sean Nash * @date (original) 06-Feb-2021 @@ -139,6 +139,7 @@ setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); cmdStartDGTrimmerHeater(); + setCurrentSubState( NO_SUB_STATE ); // Start air trap control startAirTrapControl(); Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r6aa0022f6854683b2ec6f8f7e5cf94f18a688e22 -r8747e947a7bc52dc3a4fb1346935740e08f5e974 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 6aa0022f6854683b2ec6f8f7e5cf94f18a688e22) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 8747e947a7bc52dc3a4fb1346935740e08f5e974) @@ -7,8 +7,8 @@ * * @file ModePreTreat.c * -* @author (last) Dara Navaei -* @date (last) 04-May-2023 +* @author (last) Michael Garthwaite +* @date (last) 16-May-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -812,6 +812,7 @@ { submodeCompleteTransitionTimeCounter = 0; state = HD_PRE_TREATMENT_CART_INSTALL_STATE; + setCurrentSubState( NO_SUB_STATE ); transitionToCartridgeInstallation(); } } @@ -961,6 +962,8 @@ *************************************************************************/ static HD_PRE_TREATMENT_MODE_STATE_T handlePatientConnectionState( void ) { + HD_PRE_TREATMENT_PAT_CONN_STATE_T priorSubState = currentPreTxPatConnState; + switch ( currentPreTxPatConnState ) { case PRE_TREATMENT_PAT_CONN_WAIT_FOR_UF_VOL_STATE: @@ -984,6 +987,12 @@ break; } + if ( priorSubState != currentPreTxPatConnState ) + { + setCurrentSubState( (U32)currentPreTxPatConnState ); + SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentPreTxPatConnState ); + } + // handle alarms w/ stop property if ( TRUE == doesAlarmStatusIndicateStop() ) { @@ -1005,22 +1014,45 @@ /*********************************************************************//** * @brief + * The handlePatientConnectionDoorOpened function handles the check + * for door opened in pre-treatment patient connection + * sub-mode. + * @details Inputs: none + * @details Outputs: doorOpened + * @return none + *************************************************************************/ +static void handlePatientConnectionDoorOpened( void ) +{ + // Look for cartridge door to open (indicating user inverting dialyzer) + if ( STATE_OPEN == getSwitchStatus( FRONT_DOOR ) ) + { + doorOpened = TRUE; + cmdStopDGTrimmerHeater(); + signalDialInPumpHardStop(); + } + else + { + setDialInPumpTargetFlowRate( DIP_PATIENT_CONNECTION_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + cmdStartDGTrimmerHeater(); + } +} + +/*********************************************************************//** + * @brief * The handlePatientConnectionWait4UFVolState function handles the wait * for ultrafiltration volume setting state of pre-treatment patient connection * sub-mode. * @details Inputs: setUFVolStatus - * @details Outputs: setUFVolStatus, doorOpened + * @details Outputs: setUFVolStatus * @return next patient connection state *************************************************************************/ static HD_PRE_TREATMENT_PAT_CONN_STATE_T handlePatientConnectionWait4UFVolState( void ) { HD_PRE_TREATMENT_PAT_CONN_STATE_T nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_UF_VOL_STATE; - // Look for cartridge door to open (indicating user inverting dialyzer) - if ( STATE_OPEN == getSwitchStatus( FRONT_DOOR ) ) - { - doorOpened = TRUE; - } + // Look for cartridge door to open and then close (indicating user inverted dialyzer) + handlePatientConnectionDoorOpened(); + // If UF volume set by user, move on to next state if ( TRUE == setUFVolStatus ) { @@ -1037,20 +1069,20 @@ * for dialyzer invert confirmation state of pre-treatment patient connection * sub-mode. * @details Inputs: doorOpened - * @details Outputs: doorOpened + * @details Outputs: none * @return next patient connection state *************************************************************************/ static HD_PRE_TREATMENT_PAT_CONN_STATE_T handlePatientConnectionWait4DialyzerInvertState( void ) { HD_PRE_TREATMENT_PAT_CONN_STATE_T nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_DLZR_INVERT_STATE; // Look for cartridge door to open and then close (indicating user inverted dialyzer) - if ( STATE_OPEN == getSwitchStatus( FRONT_DOOR ) ) - { - doorOpened = TRUE; - } + handlePatientConnectionDoorOpened(); + if ( ( TRUE == doorOpened ) && ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) ) { + doorClosedRequired( TRUE, TRUE ); + doorOpened = FALSE; nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_USER_CONFIRM_STATE; } @@ -1072,7 +1104,7 @@ if ( TRUE == patientConnectionConfirm ) { - doorClosedRequired( TRUE, TRUE ); + patientConnectionConfirm = FALSE; nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_TREATMENT_START_STATE; } Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rf53ecc014c076fc476e7963b67d688b7233579ee -r8747e947a7bc52dc3a4fb1346935740e08f5e974 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f53ecc014c076fc476e7963b67d688b7233579ee) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 8747e947a7bc52dc3a4fb1346935740e08f5e974) @@ -7,8 +7,8 @@ * * @file ModeStandby.c * -* @author (last) Sean Nash -* @date (last) 04-May-2023 +* @author (last) Michael Garthwaite +* @date (last) 16-May-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -147,6 +147,7 @@ resetDialInPumpRotorCount(); resetPreLoadStatus(); setVenousBubbleDetectionEnabled( FALSE ); + setCurrentSubState( NO_SUB_STATE ); // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); @@ -198,6 +199,15 @@ handleDisinfectCancel( stop ); + // if no active alarms anymore, restore to default valve states for standby mode + if ( ( FALSE == doesAlarmStatusIndicateStop() ) && ( VALVE_POSITION_C_CLOSE == getValvePosition( VDI ) ) ) + { + setValvePosition( VDI, VALVE_POSITION_A_INSERT_EJECT ); + setValvePosition( VDO, VALVE_POSITION_A_INSERT_EJECT ); + setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT ); + setValvePosition( VBV, VALVE_POSITION_A_INSERT_EJECT ); + } + // State machine to get DG to prep a reservoir so we can start a treatment switch ( currentStandbyState ) { @@ -355,7 +365,27 @@ *************************************************************************/ void signalAlarmActionToStandbyMode( ALARM_ACTION_T action ) { - // Alarm actions not handled in Standby mode + switch ( action ) + { + case ALARM_ACTION_STOP: + // Pumps should be off + signalBloodPumpHardStop(); + signalDialInPumpHardStop(); + signalDialOutPumpHardStop(); + stopSyringePump(); + + // Set valves to safe positions + setValveAirTrap( STATE_CLOSED ); + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + break; + + default: + // do not handle other actions in standby mode + break; + } } /*********************************************************************//** Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -rf9c0896317f27b4fe62fc51c3938b242a40d69ce -r8747e947a7bc52dc3a4fb1346935740e08f5e974 --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision f9c0896317f27b4fe62fc51c3938b242a40d69ce) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 8747e947a7bc52dc3a4fb1346935740e08f5e974) @@ -7,8 +7,8 @@ * * @file SelfTests.c * -* @author (last) Sean Nash -* @date (last) 15-May-2023 +* @author (last) Michael Garthwaite +* @date (last) 16-May-2023 * * @author (original) Quang Nguyen * @date (original) 28-Jan-2021 @@ -295,7 +295,7 @@ pumpHomingRequestedForNCST = FALSE; selfTestStartTime = getMSTimerCount(); selfTestPreviousPublishDataTime = getMSTimerCount(); - + setCurrentSubState( (U32)currentNoCartSelfTestsState ); doorClosedRequired( TRUE, TRUE ); // Pumps should be off @@ -371,6 +371,7 @@ if ( priorSubState != currentNoCartSelfTestsState ) { + setCurrentSubState( (U32)currentNoCartSelfTestsState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentNoCartSelfTestsState ); } // Publish current self-test time data @@ -428,7 +429,7 @@ selfTestPreviousPublishDataTime = getMSTimerCount(); selfTestCartridgeSettleTime = getMSTimerCount(); doorClosedRequired( FALSE, TRUE ); - + setCurrentSubState( (U32)currentDrySelfTestsState ); // Pumps should be off signalBloodPumpHardStop(); signalDialInPumpHardStop(); @@ -532,6 +533,7 @@ if ( priorSubState != currentDrySelfTestsState ) { + setCurrentSubState( (U32)currentDrySelfTestsState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentDrySelfTestsState ); } // Publish current self-test time data