Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r90d598a098a5454769a7eabb8ba2b4595afe47a6 -rf0745a42b391c571718598d306eeb5d8554e46ad --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 90d598a098a5454769a7eabb8ba2b4595afe47a6) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision f0745a42b391c571718598d306eeb5d8554e46ad) @@ -158,6 +158,7 @@ static U08 bloodLeakSetPointSequence[ BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH ][ 2 ]; ///< Blood leak set point sequence array. static HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T bloodLeakCalRecord; ///< Blood leak calibration record structure. static BOOL bloodLeakExitNormalRequested; ///< Blood leak exit normal state requested. +static BOOL bloodLeakEnterNormalRequested; ///< Blood leak enter normal state requested. static U32 bloodLeakRecoveryStartTimeMS; ///< Blood leak recovery start time in milliseconds. // Embedded mode variables @@ -221,7 +222,8 @@ * bloodLeakEmbModeRespBuffer, bloodLeakEmbModeRespIndex, * bloodLeakExitNormalRequested, bloodLeakEmbModeCmdSeqLength, * bloodLeakEmbModeHasRxRqstBeenSent, bloodLeakEmbModeInfoCmdEnqLastTimeStamp, - * bloodLeakEmbModeInfoCmdCounter, bloodLeakRecoveryStartTimeMS + * bloodLeakEmbModeInfoCmdCounter, bloodLeakRecoveryStartTimeMS, + * bloodLeakEnterNormalRequested * @return none *************************************************************************/ void initBloodLeak( void ) @@ -255,6 +257,7 @@ bloodLeakEmbModeInfoCmdEnqLastTimeStamp = getMSTimerCount(); bloodLeakEmbModeInfoCmdCounter = 0; bloodLeakRecoveryStartTimeMS = getMSTimerCount(); + bloodLeakEnterNormalRequested = FALSE; // Set the blood leak embedded mode command queue to zero memset( bloodLeakEmbModeCmdQ, 0x0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE ); @@ -430,6 +433,19 @@ /*********************************************************************//** * @brief + * The enterBloodLeakNormalState requests that the blood leak sensor to enter + * its normal state. + * @details Inputs: none + * @details Outputs: bloodLeakEnterNormalRequested + * @return none + *************************************************************************/ +void enterBloodLeakNormalState( void ) +{ + bloodLeakEnterNormalRequested = TRUE; +} + +/*********************************************************************//** + * @brief * The execBloodLeakSelfTest function executes the blood leak self-test. * @details Inputs: none * @details Outputs: none @@ -658,7 +674,8 @@ * @details Inputs: bloodLeakStatus, bloodLeakPersistenceCtr, * bloodLeakExitNormalRequested * @details Outputs: bloodLeakStatus, bloodLeakPersistenceCtr, - * bloodLeakExitNormalRequested, bloodLeakEmbModeHasZeroBeenRqustd + * bloodLeakExitNormalRequested, bloodLeakEmbModeHasZeroBeenRqustd, + * bloodLeakRecoveryStartTimeMS * @return next state *************************************************************************/ static BLOOD_LEAK_STATE_T handleBloodLeakNormalState( void ) @@ -685,8 +702,9 @@ #endif { activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); - state = BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE; - //exitBloodLeakNormalState(); // so we don't keep triggering after user clears it (rinseback or end tx). // TODO remove + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ); + bloodLeakRecoveryStartTimeMS = getMSTimerCount(); + state = BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE; } } } @@ -703,6 +721,7 @@ #endif { clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ); } } } @@ -726,9 +745,11 @@ * @brief * The handleBloodLeakRecoverBloodDetectState function handles the blood * leak recover blood detect state. - * @details Inputs: bloodLeakStatus, bloodLeakRecoveryStartTimeMS + * @details Inputs: bloodLeakStatus, bloodLeakRecoveryStartTimeMS, + * bloodLeakEnterNormalRequested, bloodLeakEmbModeHasZeroBeenRqustd * @details Outputs: bloodLeakStatus, bloodLeakRecoveryStartTimeMS, - * bloodLeakPersistenceCtr + * bloodLeakPersistenceCtr, bloodLeakEnterNormalRequested, + * bloodLeakEmbModeHasZeroBeenRqustd * @return next state *************************************************************************/ static BLOOD_LEAK_STATE_T handleBloodLeakRecoverBloodDetectState( void ) @@ -742,21 +763,28 @@ if ( TRUE == didTimeout( bloodLeakRecoveryStartTimeMS, BLOOD_LEAK_DETECT_RECOVERY_MIN_TIME_MS ) ) { // Blood has not been detected for the specified period of time so clear the alarm condition - clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ); } } else { bloodLeakRecoveryStartTimeMS = getMSTimerCount(); } - if ( isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_DETECTED ) != TRUE ) + if ( TRUE == bloodLeakEnterNormalRequested ) { // Once the user hit resume, transition back to normal state to continue detecting for blood - // Reset the blood detect counter prior to transitioning - bloodLeakPersistenceCtr = 0; - state = BLOOD_LEAK_NORMAL_STATE; + // Reset the blood detect counter prior to transitioning back + bloodLeakPersistenceCtr = 0; + bloodLeakEnterNormalRequested = FALSE; + state = BLOOD_LEAK_NORMAL_STATE; } + else if ( TRUE == bloodLeakEmbModeHasZeroBeenRqustd ) + { + // Check whether zeroing the sensor has been requested or not if yes, transition to zero command state otherwise, stay in this state + bloodLeakEmbModeHasZeroBeenRqustd = FALSE; + state = BLOOD_LEAK_CHECK_ZERO_AND_SELF_TEST_STATE; + } return state; } Index: firmware/App/Controllers/BloodLeak.h =================================================================== diff -u -r57f9f2d3b4c109c952034003c77a315bb3c41717 -rf0745a42b391c571718598d306eeb5d8554e46ad --- firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision 57f9f2d3b4c109c952034003c77a315bb3c41717) +++ firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision f0745a42b391c571718598d306eeb5d8554e46ad) @@ -59,6 +59,7 @@ BOOL hasBloodLeakZeroSequenceFailed( void ); void exitBloodLeakNormalState( void ); +void enterBloodLeakNormalState( void ); SELF_TEST_STATUS_T execBloodLeakSelfTest( void ); Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r90d598a098a5454769a7eabb8ba2b4595afe47a6 -rf0745a42b391c571718598d306eeb5d8554e46ad --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 90d598a098a5454769a7eabb8ba2b4595afe47a6) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision f0745a42b391c571718598d306eeb5d8554e46ad) @@ -53,11 +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 setupForRecoverBloodDetectState( void ); static void handleTreatmentStopBloodSittingTimer( void ); static void publishTreatmentStopData( void ); @@ -189,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 ) +{ + handleTreatmentStopBloodSittingTimer(); + doorClosedRequired( TRUE, TRUE ); + 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 @@ -414,25 +429,16 @@ result = handleTreatmentStopAlarmsAndSignals( result ); + if ( isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ) != TRUE ) + { + enterBloodLeakNormalState(); + } + return result; } /*********************************************************************//** * @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 ); - setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_BLOOD_DETECT_RECOVERY_MLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); -} - -/*********************************************************************//** - * @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.