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; }