Index: firmware/App/Modes/TreatmentEnd.c =================================================================== diff -u -r3833c8a7a90288a6010a625a884048c775c598d3 -rd30cbd6a87d41e58709ae6ad8466f5e193a32397 --- firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision 3833c8a7a90288a6010a625a884048c775c598d3) +++ firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision d30cbd6a87d41e58709ae6ad8466f5e193a32397) @@ -8,7 +8,7 @@ * @file TreatmentEnd.c * * @author (last) Sean Nash -* @date (last) 23-Jun-2023 +* @date (last) 21-Jul-2023 * * @author (original) Sean Nash * @date (original) 05-Feb-2021 @@ -189,12 +189,6 @@ txEndTimerCtr++; - // Check for user confirmation of end treatment - if ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == getConfirmationRequestStatus( GENERIC_CONFIRM_ID_TREATMENT_END ) ) - { - txEndAlarmEndTreatmentRequested = TRUE; - } - switch ( treatmentEndState ) { case TREATMENT_END_WAIT_FOR_RINSEBACK_STATE: @@ -365,8 +359,7 @@ *************************************************************************/ void signalTreatmentEndAlarmEndTxUserAction( void ) { - // Send message to UI to get user confirmation to end treatment - action initiated only upon receipt of user confirmation from UI - addConfirmationRequest( GENERIC_CONFIRM_ID_TREATMENT_END, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0 ); + txEndAlarmEndTreatmentRequested = TRUE; } /*********************************************************************//** Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r3833c8a7a90288a6010a625a884048c775c598d3 -rd30cbd6a87d41e58709ae6ad8466f5e193a32397 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 3833c8a7a90288a6010a625a884048c775c598d3) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision d30cbd6a87d41e58709ae6ad8466f5e193a32397) @@ -7,8 +7,8 @@ * * @file TreatmentStop.c * -* @author (last) Sean Nash -* @date (last) 21-Jun-2023 +* @author (last) Dara Navaei +* @date (last) 19-Jul-2023 * * @author (original) Sean * @date (original) 15-Jan-2020 @@ -36,7 +36,8 @@ // ********** private definitions ********** /// Treatment stop status broadcast interval. -#define TREATMENT_STOP_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +#define TREATMENT_STOP_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +#define DIALYSATE_FLOW_RATE_FOR_BLOOD_DETECT_RECOVERY_MLPM 600 ///< Dialysate flow rate for blood detect recovery in mL/min. // ********** private data ********** @@ -52,9 +53,11 @@ static TREATMENT_STOP_STATE_T handleTreatmentStopNoRecircState( void ); static void setupForDialysateRecirculationState( void ); static void setupForBloodRecirculationState( void ); +static void setupForRecoverBloodDetectState( void ); static TREATMENT_STOP_STATE_T handleTreatmentStopAlarmsAndSignals( TREATMENT_STOP_STATE_T state ); static TREATMENT_STOP_STATE_T handleTreatmentStopDialysateRecircState( void ); static TREATMENT_STOP_STATE_T handleTreatmentStopBloodRecircState( void ); +static TREATMENT_STOP_STATE_T handleTreatmentStopRecoverBloodDetectState( void ); static void handleTreatmentStopBloodSittingTimer( void ); static void publishTreatmentStopData( void ); @@ -109,7 +112,7 @@ setupForDialysateRecirculationState(); - signalUserRateChange(); // so pressure limits re-stabilize + signalInitiatePressureStabilization(); // Reset saline bolus state in case alarm interrupted one resetSalineBolus(); @@ -186,6 +189,21 @@ /*********************************************************************//** * @brief + * The setupForRecoverBloodDetectState function handles the setup for + * recovering blood detection state. + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +static void setupForRecoverBloodDetectState( void ) +{ + doorClosedRequired( TRUE, TRUE ); + cmdStartDGTrimmerHeater(); + setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_BLOOD_DETECT_RECOVERY_MLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); +} + +/*********************************************************************//** + * @brief * The setupForDialysateRecirculationStopState function sets actuators appropriately * for dialysate re-circulation stopped state. * @details Inputs: none @@ -252,6 +270,10 @@ currentTxStopState = handleTreatmentStopNoRecircState(); break; + case TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE: + currentTxStopState = handleTreatmentStopRecoverBloodDetectState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_TREATMENT_STOP_INVALID_STATE, currentTxStopState ); break; @@ -277,38 +299,39 @@ static TREATMENT_STOP_STATE_T handleTreatmentStopAlarmsAndSignals( TREATMENT_STOP_STATE_T state ) { TREATMENT_STOP_STATE_T result = state; - BOOL bloodRecircBlocked = isBloodRecircBlocked(); - BOOL dialysateRecircBlocked = isDialysateRecircBlocked(); + BOOL bloodRecircBlocked = isBloodRecircBlocked(); + BOOL dialysateRecircBlocked = isDialysateRecircBlocked(); + if ( ( TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE != state ) && ( dialysateRecircBlocked != TRUE ) && + ( TRUE == isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ) ) && ( FALSE == isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_DETECTED ) ) ) + { + setupForRecoverBloodDetectState(); + result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; + } // Both unblocked and not in recirculate both state - if ( ( TREATMENT_STOP_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) + else if ( ( TREATMENT_STOP_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) { setupForBloodRecirculationState(); setupForDialysateRecirculationState(); result = TREATMENT_STOP_RECIRC_STATE; } - // Both blocked and not in stopped state - if ( ( TREATMENT_STOP_NO_RECIRC_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && ( TRUE == bloodRecircBlocked ) ) + else if ( ( TREATMENT_STOP_NO_RECIRC_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && ( TRUE == bloodRecircBlocked ) ) { setupForBloodRecirculationStopState(); setupForDialysateRecirculationStopState(); result = TREATMENT_STOP_NO_RECIRC_STATE; } - // Dialysate recirculation blocked and not in blood recirc state - if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) && - ( TRUE == dialysateRecircBlocked ) && - ( FALSE == bloodRecircBlocked ) ) + else if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && + ( FALSE == bloodRecircBlocked ) ) { setupForDialysateRecirculationStopState(); result = TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE; } - // Blood recirculation blocked and not in dialysate recirc state - if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) && - ( TRUE == bloodRecircBlocked ) && - ( FALSE == dialysateRecircBlocked ) ) + else if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) && ( TRUE == bloodRecircBlocked ) && + ( FALSE == dialysateRecircBlocked ) ) { setupForBloodRecirculationStopState(); result = TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE; @@ -393,6 +416,25 @@ /*********************************************************************//** * @brief + * The handleTreatmentStopRecoverBloodDetectState function handles the recovering + * for blood detect state in treatment stop. + * @details Inputs: none + * @details Outputs: none + * @return next treatment stop state + *************************************************************************/ +static TREATMENT_STOP_STATE_T handleTreatmentStopRecoverBloodDetectState( void ) +{ + TREATMENT_STOP_STATE_T result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; + + // Keep reseting the blood sitting timer + handleTreatmentStopBloodSittingTimer(); + result = handleTreatmentStopAlarmsAndSignals( result ); + + return result; +} + +/*********************************************************************//** + * @brief * The handleTreatmentStopBloodSittingTimer function handles the no re-circ * blood timer. It should only be called when Blood is NOT circulating. * Increments and checks for warning and alarm timeouts.