Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r885564dbf68d445e1c95a61b05ea66b6b0690c01 -r0d205f6ddf739549eb942d0b552b0a6790d4366f --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 885564dbf68d445e1c95a61b05ea66b6b0690c01) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 0d205f6ddf739549eb942d0b552b0a6790d4366f) @@ -260,6 +260,33 @@ /*********************************************************************//** * @brief + * The isACPowerLost function determines whether A/C power loss has + * been detected. This function sets the alarms blocked condition to + * allow smooth alarm recovery. + * + * @details Inputs: alarmStatus + * @details Outputs: alarmsBlockedTimer + * @return TRUE if A/C power loss alarm is in effect, FALSE if not + *************************************************************************/ +BOOL isACPowerLost( void ) +{ + BOOL result = TRUE; + + // Continue to block new alarms until the alarms are cleared. + if ( ( FALSE == isAlarmConditionDetected( ALARM_ID_HD_AC_POWER_LOST ) ) && + ( FALSE == isAlarmConditionDetected( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT ) ) ) + { + result = FALSE; + } + else + { + alarmsBlockedTimer = ALARM_BLOCKED_COUNT_AFTER_AC_RETURN; + } + return result; +} + +/*********************************************************************//** + * @brief * The activateAlarm function activates a given alarm. * @details Inputs: none * @details Outputs: alarmIsActive[], alarmStartedAt[], alarmStatus is updated @@ -268,6 +295,11 @@ *************************************************************************/ static void activateAlarm( ALARM_ID_T alarm ) { + // Block new alarms, occuring during loss of AC power + if ( ( TRUE == getCPLDACPowerLossDetected() ) ) + { + alarmsBlockedTimer = ALARM_BLOCKED_COUNT_AFTER_AC_RETURN; + } // Verify valid alarm index if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { @@ -1383,6 +1415,9 @@ if ( ( TRUE == alarmIsActive[ a ] ) && ( ( TRUE == ALARM_TABLE[ a ].alarmConditionClearImmed ) || ( alarmIsDetected[ a ] != TRUE ) || ( action != ALARM_USER_ACTION_RESUME ) ) ) { + HD_OP_MODE_T mode = getCurrentOperationMode(); + U32 sub = getCurrentSubMode(); + // set no re-trigger flag if appropriate if ( ( ALARM_USER_ACTION_RINSEBACK == action ) && ( TRUE == ALARM_TABLE[ a ].alarmNoRetrigOnRB ) ) { // alarms with no re-trigger on rinseback property should set the no re-trigger flag @@ -1396,15 +1431,32 @@ { if ( ( TRUE == ALARM_TABLE[ a ].alarmNoResume ) && ( TRUE == ALARM_TABLE[ a ].alarmNoRinseback ) ) { // alarms that only allow end-tx that occur in rinseback or recirc states of treatment mode should set the no re-trigger flag - if ( ( MODE_TREA == getCurrentOperationMode() ) && - ( ( TREATMENT_RINSEBACK_STATE == getCurrentSubMode() ) || ( TREATMENT_RECIRC_STATE == getCurrentSubMode() ) ) ) + if ( ( MODE_TREA == mode ) && ( ( TREATMENT_RINSEBACK_STATE == sub ) || ( TREATMENT_RECIRC_STATE == sub ) ) ) { alarmNoRetrigger = TRUE; } } } - // clear this alarm - clearAlarm( a ); + // check special cases where we do not want to clear this alarm - otherwise, clear it + if ( ( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT == a ) && ( TRUE == alarmIsDetected[ a ] ) && ( mode != MODE_POST ) && + ( action != ALARM_USER_ACTION_RINSEBACK ) && ( action != ALARM_USER_ACTION_END_TREATMENT ) ) + { + // do not clear this alarm if condition not cleared first (unless treatment is over) + result = FALSE; + } + else if ( ( ( ALARM_ID_DG_FILL_CONDUCTIVITY_OUT_OF_RANGE == a ) || + ( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME == a ) || + ( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME == a ) ) && + ( alarmStatus.alarmTop != a ) ) + { + // do not clear this alarm unless it is top (user is specifically clearing this alarm) + result = FALSE; + } + else + { + // clear this alarm + clearAlarm( a ); + } } else if ( TRUE == alarmIsActive[ a ] ) {