Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rc1b9ac0dbf2196280895d2e440dd7ac288ac8424 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision c1b9ac0dbf2196280895d2e440dd7ac288ac8424) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -233,7 +233,7 @@ *************************************************************************/ void execDGInterfaceMonitor( void ) { - if ( isACPowerLost() != TRUE ) + if ( FALSE == isACPowerLost() ) { // 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 ( isACPowerLost() != TRUE ) + if ( FALSE == isACPowerLost() ) { if ( ( DG_MODE_GENE == dgOp ) || ( DG_MODE_FILL == dgOp ) || ( DG_MODE_DRAI == dgOp ) ) { Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r3d409ee7130063937dce719281bb072c87023d3f -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 3d409ee7130063937dce719281bb072c87023d3f) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -509,7 +509,7 @@ } else { // Alarm if not receiving new dialysate flow readings in timely manner - if ( ( TRUE == isDGCommunicating() ) && ( isACPowerLost() != TRUE ) ) + if ( ( TRUE == isDGCommunicating() ) && ( FALSE == isACPowerLost() ) ) { if ( ++dialysateFlowDataFreshStatusCounter > DIP_DIALYSATE_FLOW_DATA_ALARM_THRESHOLD ) { Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r1bff8e530735be63ba557b77557a0bc2ac4b37b2 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 1bff8e530735be63ba557b77557a0bc2ac4b37b2) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -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 ( isACPowerLost() != TRUE ) + if ( FALSE == isACPowerLost() ) { // 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 -r82bd1d24c050e79690a7f5b236e49dd7db7e2a91 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 82bd1d24c050e79690a7f5b236e49dd7db7e2a91) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -1187,7 +1187,7 @@ for ( valve = VDI; valve < NUM_OF_VALVES; valve++ ) { // Check the valve is in Idle state, otherwise the position should not be checked - if ( ( valvesStatus[ valve ].execState == VALVE_STATE_IDLE ) && ( FALSE == isACPowerLost() ) ) + if ( ( valvesStatus[ valve ].execState == VALVE_STATE_IDLE ) && ( FALSE == getCPLDACPowerLossDetected() ) ) { U32 maxDeviation = MAX_DEVIATION_FROM_TARGET_IN_COUNTS; @@ -1201,28 +1201,35 @@ maxDeviation = MAX_DEVIATION_FROM_TRAGET_IN_POS_B; } - // 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 - // Absolute value is used for comparison to cover +/- from the commanded position - if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + if ( FALSE == isACPowerLost() ) { - valvesStatus[ valve ].positionOutOfRangeCounter++; - } + // 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 + // Absolute value is used for comparison to cover +/- from the commanded position + if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + { + valvesStatus[ valve ].positionOutOfRangeCounter++; + } - if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) - { - // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. - // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here - // because this is a monitor function that is called in the controller function. - valvesStatus[ valve ].execState = VALVE_STATE_IDLE; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); + if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) + { + // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. + // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here + // because this is a monitor function that is called in the controller function. + valvesStatus[ valve ].execState = VALVE_STATE_IDLE; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); - if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + { + activateSafetyShutdown(); + } + } + else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) { - activateSafetyShutdown(); + valvesStatus[ valve ].positionOutOfRangeCounter = 0; } } - else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) + else { valvesStatus[ valve ].positionOutOfRangeCounter = 0; } Index: firmware/App/Drivers/Battery.c =================================================================== diff -u -rbf44edd28c59df78a75165764b6b654f2e91e556 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Drivers/Battery.c (.../Battery.c) (revision bf44edd28c59df78a75165764b6b654f2e91e556) +++ firmware/App/Drivers/Battery.c (.../Battery.c) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -221,27 +221,6 @@ /*********************************************************************//** * @brief - * The isACPowerLost function determines whether A/C power loss has been - * detected. - * @details Inputs: none - * @details Outputs: none - * @return TRUE if A/C power loss condition is in effect, FALSE if not - *************************************************************************/ -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 ) ) ) - { - result = FALSE; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getI2CStatusRegister function returns the I2C status register * @details Inputs: batteryI2CStatusRegister, i2cREG1->STR * @details Outputs: none Index: firmware/App/Drivers/Battery.h =================================================================== diff -u -raa8b9687b9396b4878cf0d5327d72a5d67477761 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Drivers/Battery.h (.../Battery.h) (revision aa8b9687b9396b4878cf0d5327d72a5d67477761) +++ firmware/App/Drivers/Battery.h (.../Battery.h) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -78,7 +78,6 @@ void execBatteryMonitor( void ); BOOL isBatteryCharged( void ); -BOOL isACPowerLost( void ); BOOL testSetBatteryRemainingCapacityOverride( F32 value ); BOOL testResetBatteryRemainingCapacityOverride( void ); Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r069e667671a8732eb9373acf8fcc6d3c9cc1c6b9 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 069e667671a8732eb9373acf8fcc6d3c9cc1c6b9) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -252,6 +252,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 @@ -260,6 +287,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 ) ) { @@ -356,12 +388,7 @@ * @return none *************************************************************************/ 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; - } +{ // Sanity check, verify valid alarm index if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r12708a04ae3365e11180182fc52d005c229a7bc6 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 12708a04ae3365e11180182fc52d005c229a7bc6) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -201,6 +201,7 @@ void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ); void signalAlarmSilence( ALARM_SILENCE_CMD_T cmd ); void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ); +BOOL isACPowerLost( void ); BOOL isAlarmActive( ALARM_ID_T alarm ); BOOL isAlarmConditionDetected( ALARM_ID_T alarm ); BOOL isAnyAlarmActive( void );