Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rf4f7e0ee3baef51d91de64d44a0a00ff967f56c0 -rb61c8330905634762e69ed10fb6614a77552fd54 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision f4f7e0ee3baef51d91de64d44a0a00ff967f56c0) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) @@ -1252,8 +1252,7 @@ // Check blood pump current during running state BOOL const isRunningMCCurrentBad = ( ( BLOOD_PUMP_OFF_STATE != bloodPumpState ) && ( bpCurr > BP_MAX_CURR_WHEN_RUNNING_MA ) ? TRUE : FALSE ); - if ( ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BLOOD_PUMP_MC_CURRENT_CHECK, isOffMCCurrentBad || isRunningMCCurrentBad ) ) && - ( FALSE == isACPowerLost() ) ) + if ( ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BLOOD_PUMP_MC_CURRENT_CHECK, isOffMCCurrentBad || isRunningMCCurrentBad ) ) ) { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r4dda5ae6127e3580137ebf70caf3560e3b268892 -rb61c8330905634762e69ed10fb6614a77552fd54 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 4dda5ae6127e3580137ebf70caf3560e3b268892) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) @@ -233,7 +233,7 @@ *************************************************************************/ void execDGInterfaceMonitor( void ) { - if ( FALSE == isACPowerLost() ) + if ( getCPLDACPowerLossDetected() != TRUE ) { // Trigger alarm if not receiving new load cell data message in timely manner checkDGDataFreshness( ALARM_ID_HD_NEW_LOAD_CELL_DATA_MESSAGE_NOT_RECEIVE, &dgLoadCellDataFreshFlag ); @@ -1258,7 +1258,7 @@ U32 trimmerState = dgHeatersData.trimmerHeaterState; DG_OP_MODE_T dgOp = getDGOpMode(); - if ( FALSE == isACPowerLost() ) + if ( getCPLDACPowerLossDetected() != TRUE ) { if ( ( DG_MODE_GENE == dgOp ) || ( DG_MODE_FILL == dgOp ) || ( DG_MODE_DRAI == dgOp ) ) { Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r4dda5ae6127e3580137ebf70caf3560e3b268892 -rb61c8330905634762e69ed10fb6614a77552fd54 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 4dda5ae6127e3580137ebf70caf3560e3b268892) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) @@ -510,7 +510,7 @@ } else { // Alarm if not receiving new dialysate flow readings in timely manner - if ( ( TRUE == isDGCommunicating() ) && ( FALSE == isACPowerLost() ) ) + if ( ( TRUE == isDGCommunicating() ) && ( getCPLDACPowerLossDetected() != TRUE ) ) { if ( ++dialysateFlowDataFreshStatusCounter > DIP_DIALYSATE_FLOW_DATA_ALARM_THRESHOLD ) { @@ -1442,7 +1442,7 @@ F32 dipCurr; // only check current when we have A/C power - if ( FALSE == isACPowerLost() ) + if ( getCPLDACPowerLossDetected() != TRUE ) { // DialIn pump should be off if ( DIAL_IN_PUMP_OFF_STATE == dialInPumpState ) Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r3d409ee7130063937dce719281bb072c87023d3f -rb61c8330905634762e69ed10fb6614a77552fd54 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 3d409ee7130063937dce719281bb072c87023d3f) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) @@ -1162,7 +1162,7 @@ F32 dopCurr; // only check current when we have A/C power - if ( FALSE == isACPowerLost() ) + if ( getCPLDACPowerLossDetected() != TRUE ) { // DialOut pump should be off if ( DIAL_OUT_PUMP_OFF_STATE == dialOutPumpState ) Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r4dda5ae6127e3580137ebf70caf3560e3b268892 -rb61c8330905634762e69ed10fb6614a77552fd54 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 4dda5ae6127e3580137ebf70caf3560e3b268892) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) @@ -413,7 +413,7 @@ F32 fansMinAllowedRPM = fansNominalRPM - ( fansNominalRPM * FANS_MIN_RPM_OUT_OF_RANGE_TOL ); F32 fansMaxAllowedRPM = fansNominalRPM + ( fansNominalRPM * FANS_MAX_RPM_OUT_OF_RANGE_TOL ); - if ( FALSE == isACPowerLost() ) + if ( getCPLDACPowerLossDetected() != TRUE ) { // Loop through the fans and make sure the each of them have RPM in range for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r4dda5ae6127e3580137ebf70caf3560e3b268892 -rb61c8330905634762e69ed10fb6614a77552fd54 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 4dda5ae6127e3580137ebf70caf3560e3b268892) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) @@ -1202,7 +1202,7 @@ maxDeviation = MAX_DEVIATION_FROM_TRAGET_IN_POS_B; } - if ( FALSE == isACPowerLost() ) + if ( isACPowerLost() != TRUE ) { // Check if the current position has deviated from the position it is supposed to be in // For more than a certain amount of time. If it has, raise an alarm Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r4dda5ae6127e3580137ebf70caf3560e3b268892 -rb61c8330905634762e69ed10fb6614a77552fd54 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 4dda5ae6127e3580137ebf70caf3560e3b268892) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) @@ -42,7 +42,7 @@ #define ALARM_INFO_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Interval (ms/task time) Alarms are blocked after the return of AC power. -#define ALARM_BLOCKED_COUNT_AFTER_AC_RETURN ( 10*MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +#define ALARM_BLOCKED_TICK_COUNT_AFTER_AC_RETURN ( 10*MS_PER_SECOND / TASK_GENERAL_INTERVAL ) #define ALARM_SILENCE_EXPIRES_IN_SECS (60) ///< Alarm silence expiration time in seconds. @@ -116,7 +116,7 @@ static U32 alarmStatusPublicationTimerCounter = 0; ///< Used to schedule alarm status publication to CAN bus. static U32 alarmInfoPublicationTimerCounter = 0; ///< Used to schedule alarm information publication to CAN bus. static U32 audioTestStartTime; ///< Start time of audio alarm current self-test. -static U32 alarmsBlockedTimer = 0; ///< Countdown timer used to temporarily block new alarms from being initiated +static U32 alarmsBlockedCountdownTimer = 0; ///< Countdown timer used to temporarily block new alarms from being initiated /// Interval (in task intervals) at which to publish alarm status to CAN bus. static OVERRIDE_U32_T alarmStatusPublishInterval = { ALARM_STATUS_PUBLISH_INTERVAL, ALARM_STATUS_PUBLISH_INTERVAL, ALARM_STATUS_PUBLISH_INTERVAL, 0 }; @@ -161,6 +161,7 @@ static U32 getAlarmStartTime( ALARM_ID_T alarmID ); static void publishAlarmInfo( void ); +static void checkACPowerLost( void ); /*********************************************************************//** * @brief @@ -220,7 +221,7 @@ alarmStatus.noDialRecirc = FALSE; alarmStatus.ok = FALSE; - alarmsBlockedTimer = 0; + alarmsBlockedCountdownTimer = 0; alarmAudioTestToneRequested = FALSE; resumeBlockedByAlarmProperty = FALSE; alarmNoRetrigger = FALSE; @@ -246,9 +247,9 @@ publishAlarmInfo(); // Block new machine alarms during power fail recovery - if ( alarmsBlockedTimer > 0 ) + if ( alarmsBlockedCountdownTimer > 0 ) { - alarmsBlockedTimer--; + alarmsBlockedCountdownTimer--; } } @@ -360,15 +361,13 @@ void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2 ) { // Block if new alarms are occur during loss of AC power - if ( ( TRUE == getCPLDACPowerLossDetected() ) ) - { - alarmsBlockedTimer = ALARM_BLOCKED_COUNT_AFTER_AC_RETURN; - } + checkACPowerLost( ); + // Sanity check, verify valid alarm index if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { // if the block timer is 0 OR we have an unblockable alarm - if ( ( ALARM_NOT_BLOCKED == alarmsBlockedTimer ) + if ( ( ALARM_NOT_BLOCKED == alarmsBlockedCountdownTimer ) || ( ALARM_ID_HD_AC_POWER_LOST == alarm ) || ( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT == alarm ) ) { // do not re-trigger alarm if blocked by property @@ -688,23 +687,34 @@ *************************************************************************/ BOOL isACPowerLost( void ) { - BOOL result = TRUE; - - if ( ( FALSE == isAlarmConditionDetected( ALARM_ID_HD_AC_POWER_LOST ) ) && - ( FALSE == isAlarmConditionDetected( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT ) ) ) + BOOL result = FALSE; + if ( ( getCPLDACPowerLossDetected() != FALSE ) || + ( alarmsBlockedCountdownTimer != ALARM_NOT_BLOCKED ) ) { - result = FALSE; + result = TRUE; } - else - { - alarmsBlockedTimer = ALARM_BLOCKED_COUNT_AFTER_AC_RETURN; - } return result; } /*********************************************************************//** * @brief + * The checkACPowerLost function checks whether A/C power loss has been + * detected, and sets countdown timer to block new alarms. + * @details Inputs: alarmsBlockedCountdownTimer + * @details Outputs: none + * @return TRUE if A/C power loss condition is in effect, FALSE if not + *************************************************************************/ +static void checkACPowerLost( void ) +{ + if ( TRUE == isACPowerLost( ) ) + { + alarmsBlockedCountdownTimer = ALARM_BLOCKED_TICK_COUNT_AFTER_AC_RETURN; + } +} + +/*********************************************************************//** + * @brief * The isBloodRecircBlocked function determines whether any currently * active alarm is blocking blood re-circulation. * @details Inputs: alarmStatus