Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rb61c8330905634762e69ed10fb6614a77552fd54 -r7593a04d1121869dffb536f31c20c57cf571611b --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 7593a04d1121869dffb536f31c20c57cf571611b) @@ -18,6 +18,7 @@ #include // To check for NaN #include "Battery.h" +#include "CPLD.h" #include "DialInFlow.h" #include "Dialysis.h" #include "DGDefs.h" @@ -203,7 +204,7 @@ *************************************************************************/ static void checkDGDataFreshness( ALARM_ID_T alarmID, BOOL *dgFreshDataFlag ) { - if ( TRUE == *dgFreshDataFlag ) + if ( ( TRUE == *dgFreshDataFlag ) || ( getCPLDACPowerLossDetected() != FALSE ) ) { *dgFreshDataFlag = FALSE; checkPersistentAlarm( alarmID, FALSE, 0.0, 0.0 ); @@ -233,27 +234,28 @@ *************************************************************************/ void execDGInterfaceMonitor( void ) { - 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 ); + // 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 ); - // Trigger alarm if not receiving new dialysate temperature data message in timely manner - checkDGDataFreshness( ALARM_ID_HD_NEW_DIALYSATE_TEMP_DATA_MESSAGE_NOT_RECEIVE, &dgDialysateTemperatureDataFreshFlag ); + // Trigger alarm if not receiving new dialysate temperature data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_DIALYSATE_TEMP_DATA_MESSAGE_NOT_RECEIVE, &dgDialysateTemperatureDataFreshFlag ); - // Trigger alarm if not receiving new reservoirs data message in timely manner - checkDGDataFreshness( ALARM_ID_HD_NEW_RESERVOIRS_DATA_MESSAGE_NOT_RECEIVE, &dgReservoirsDataFreshFlag ); + // Trigger alarm if not receiving new reservoirs data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_RESERVOIRS_DATA_MESSAGE_NOT_RECEIVE, &dgReservoirsDataFreshFlag ); - // Trigger alarm if not receiving new DG op mode message in timely manner - checkDGDataFreshness( ALARM_ID_HD_DG_NEW_OPERATION_MODE_MESSAGE_NOT_RECEIVE, &dgOpModeDataFreshFlag ); + // Trigger alarm if not receiving new DG op mode message in timely manner + checkDGDataFreshness( ALARM_ID_HD_DG_NEW_OPERATION_MODE_MESSAGE_NOT_RECEIVE, &dgOpModeDataFreshFlag ); - // Check to see if DG has restarted - checkDGRestart(); + // Check to see if DG has restarted + checkDGRestart(); - // Check the status of the trimmer heater - if ( ++dgTrimmerTempCheckTimerCtr >= DG_TRIMMER_HTR_CHECK_INTERVAL ) + // Check the status of the trimmer heater + if ( ++dgTrimmerTempCheckTimerCtr >= DG_TRIMMER_HTR_CHECK_INTERVAL ) + + { + dgTrimmerTempCheckTimerCtr = 0; + if ( getCPLDACPowerLossDetected() != TRUE ) { - dgTrimmerTempCheckTimerCtr = 0; checkDGTrimmerHeaterStatus(); } } @@ -1258,25 +1260,21 @@ U32 trimmerState = dgHeatersData.trimmerHeaterState; DG_OP_MODE_T dgOp = getDGOpMode(); - if ( getCPLDACPowerLossDetected() != TRUE ) + if ( ( DG_MODE_GENE == dgOp ) || ( DG_MODE_FILL == dgOp ) || ( DG_MODE_DRAI == dgOp ) ) { - if ( ( DG_MODE_GENE == dgOp ) || ( DG_MODE_FILL == dgOp ) || ( DG_MODE_DRAI == dgOp ) ) + // In heat disinfect and chemical disinfect, the trimmer heater is controlled by the DG itself so no commands from HD should be sent + // regarding the trimmer heater. + if ( ( TRUE == dgTrimmerHeaterOn ) && ( HEATER_EXEC_STATE_OFF == trimmerState ) ) { - // In heat disinfect and chemical disinfect, the trimmer heater is controlled by the DG itself so no commands from HD should be sent - // regarding the trimmer heater. - if ( ( TRUE == dgTrimmerHeaterOn ) && ( HEATER_EXEC_STATE_OFF == trimmerState ) ) - { - cmdStartDGTrimmerHeater(); - } - else if ( ( FALSE == dgTrimmerHeaterOn ) && ( trimmerState != HEATER_EXEC_STATE_OFF ) ) - { - cmdStopDGTrimmerHeater(); - } + cmdStartDGTrimmerHeater(); } + else if ( ( FALSE == dgTrimmerHeaterOn ) && ( trimmerState != HEATER_EXEC_STATE_OFF ) ) + { + cmdStopDGTrimmerHeater(); + } } } - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rb61c8330905634762e69ed10fb6614a77552fd54 -r7593a04d1121869dffb536f31c20c57cf571611b --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 7593a04d1121869dffb536f31c20c57cf571611b) @@ -22,6 +22,7 @@ #include "mibspi.h" #include "Battery.h" +#include "CPLD.h" #include "DialInFlow.h" #include "FPGA.h" #include "InternalADC.h" @@ -1441,53 +1442,49 @@ { F32 dipCurr; - // only check current when we have A/C power - if ( getCPLDACPowerLossDetected() != TRUE ) + // DialIn pump should be off + if ( DIAL_IN_PUMP_OFF_STATE == dialInPumpState ) { - // DialIn pump should be off - if ( DIAL_IN_PUMP_OFF_STATE == dialInPumpState ) + dipCurr = fabs( getMeasuredDialInPumpMCCurrent() ); + if ( dipCurr > DIP_MAX_CURR_WHEN_STOPPED_MA ) { - dipCurr = fabs( getMeasuredDialInPumpMCCurrent() ); - if ( dipCurr > DIP_MAX_CURR_WHEN_STOPPED_MA ) + dipCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; + if ( dipCurrErrorDurationCtr > DIP_MAX_CURR_ERROR_DURATION_MS ) { - dipCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; - if ( dipCurrErrorDurationCtr > DIP_MAX_CURR_ERROR_DURATION_MS ) - { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) #endif - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_IN_PUMP_MC_CURRENT_CHECK, getMeasuredDialInPumpMCCurrent() ); - } + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_IN_PUMP_MC_CURRENT_CHECK, getMeasuredDialInPumpMCCurrent() ); } } - else - { - dipCurrErrorDurationCtr = 0; - } } - // DialIn pump should be running else { - dipCurr = fabs( getMeasuredDialInPumpMCCurrent() ); - if ( dipCurr > DIP_MAX_CURR_WHEN_RUNNING_MA ) + dipCurrErrorDurationCtr = 0; + } + } + // DialIn pump should be running + else + { + dipCurr = fabs( getMeasuredDialInPumpMCCurrent() ); + if ( dipCurr > DIP_MAX_CURR_WHEN_RUNNING_MA ) + { + dipCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; + if ( dipCurrErrorDurationCtr > DIP_MAX_CURR_ERROR_DURATION_MS ) { - dipCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; - if ( dipCurrErrorDurationCtr > DIP_MAX_CURR_ERROR_DURATION_MS ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) - #endif - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_IN_PUMP_MC_CURRENT_CHECK, getMeasuredDialInPumpMCCurrent() ); - } + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_IN_PUMP_MC_CURRENT_CHECK, getMeasuredDialInPumpMCCurrent() ); } } - else - { - dipCurrErrorDurationCtr = 0; - } } + else + { + dipCurrErrorDurationCtr = 0; + } } } Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rb61c8330905634762e69ed10fb6614a77552fd54 -r7593a04d1121869dffb536f31c20c57cf571611b --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 7593a04d1121869dffb536f31c20c57cf571611b) @@ -1161,53 +1161,49 @@ { F32 dopCurr; - // only check current when we have A/C power - if ( getCPLDACPowerLossDetected() != TRUE ) + // DialOut pump should be off + if ( DIAL_OUT_PUMP_OFF_STATE == dialOutPumpState ) { - // DialOut pump should be off - if ( DIAL_OUT_PUMP_OFF_STATE == dialOutPumpState ) + dopCurr = fabs( getMeasuredDialOutPumpMCCurrent() ); + if ( dopCurr > DOP_MAX_CURR_WHEN_STOPPED_MA ) { - dopCurr = fabs( getMeasuredDialOutPumpMCCurrent() ); - if ( dopCurr > DOP_MAX_CURR_WHEN_STOPPED_MA ) + dopCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; + if ( dopCurrErrorDurationCtr > DOP_MAX_CURR_ERROR_DURATION_MS ) { - dopCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; - if ( dopCurrErrorDurationCtr > DOP_MAX_CURR_ERROR_DURATION_MS ) - { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) #endif - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_OUT_PUMP_MC_CURRENT_CHECK, getMeasuredDialOutPumpMCCurrent() ); - } + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_OUT_PUMP_MC_CURRENT_CHECK, getMeasuredDialOutPumpMCCurrent() ); } } - else - { - dopCurrErrorDurationCtr = 0; - } } - // DialOut pump should be running else { - dopCurr = fabs( getMeasuredDialOutPumpMCCurrent() ); - if ( dopCurr > DOP_MAX_CURR_WHEN_RUNNING_MA ) + dopCurrErrorDurationCtr = 0; + } + } + // DialOut pump should be running + else + { + dopCurr = fabs( getMeasuredDialOutPumpMCCurrent() ); + if ( dopCurr > DOP_MAX_CURR_WHEN_RUNNING_MA ) + { + dopCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; + if ( dopCurrErrorDurationCtr > DOP_MAX_CURR_ERROR_DURATION_MS ) { - dopCurrErrorDurationCtr += TASK_PRIORITY_INTERVAL; - if ( dopCurrErrorDurationCtr > DOP_MAX_CURR_ERROR_DURATION_MS ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MOTOR_CURRNT_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) - #endif - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_OUT_PUMP_MC_CURRENT_CHECK, getMeasuredDialOutPumpMCCurrent() ); - } + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_DIAL_OUT_PUMP_MC_CURRENT_CHECK, getMeasuredDialOutPumpMCCurrent() ); } } - else - { - dopCurrErrorDurationCtr = 0; - } } + else + { + dopCurrErrorDurationCtr = 0; + } } } Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -ra56235b9faf8b3d4948c9d522c463a19e596a870 -r7593a04d1121869dffb536f31c20c57cf571611b --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision a56235b9faf8b3d4948c9d522c463a19e596a870) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 7593a04d1121869dffb536f31c20c57cf571611b) @@ -1229,6 +1229,10 @@ valvesStatus[ valve ].positionOutOfRangeCounter = 0; } } + else + { + valvesStatus[ valve ].positionOutOfRangeCounter = 0; + } } else { Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -rb61c8330905634762e69ed10fb6614a77552fd54 -r7593a04d1121869dffb536f31c20c57cf571611b --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 7593a04d1121869dffb536f31c20c57cf571611b) @@ -162,6 +162,7 @@ static void publishAlarmInfo( void ); static void checkACPowerLost( void ); +static BOOL isNewAlarmBlocked( ALARM_ID_T alarm ); /*********************************************************************//** * @brief @@ -246,11 +247,8 @@ // Publish alarm status and information at interval publishAlarmInfo(); - // Block new machine alarms during power fail recovery - if ( alarmsBlockedCountdownTimer > 0 ) - { - alarmsBlockedCountdownTimer--; - } + // Block if new alarms are occur during loss of AC power + checkACPowerLost( ); } /*********************************************************************//** @@ -360,16 +358,11 @@ *************************************************************************/ 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 - 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 == alarmsBlockedCountdownTimer ) - || ( ALARM_ID_HD_AC_POWER_LOST == alarm ) - || ( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT == alarm ) ) + if ( isNewAlarmBlocked( alarm ) != TRUE ) { // do not re-trigger alarm if blocked by property if ( ( FALSE == alarmNoRetrigger ) || ( ( ALARM_TABLE[ alarm ].alarmNoRetrigOnRB != TRUE ) && ( ALARM_TABLE[ alarm ].alarmNoRetrigOnEndTx != TRUE ) ) ) @@ -679,16 +672,34 @@ /*********************************************************************//** * @brief + * The isNewAlarmBlocked function determines whether A/C power loss has + * blocked new alarms. + * @details Inputs: alarmsBlockedCountdownTimer + * @details Outputs: none + * @return TRUE if A/C power loss condition is in effect, FALSE if not + *************************************************************************/ +static BOOL isNewAlarmBlocked( ALARM_ID_T alarm ) +{ + BOOL result = FALSE; + result = ( ALARM_NOT_BLOCKED == alarmsBlockedCountdownTimer ) || + ( ALARM_ID_HD_AC_POWER_LOST == alarm ) || + ( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT == alarm ); + + return result; +} + +/*********************************************************************//** + * @brief * The isACPowerLost function determines whether A/C power loss has been * detected. - * @details Inputs: none + * @details Inputs: alarmsBlockedCountdownTimer * @details Outputs: none * @return TRUE if A/C power loss condition is in effect, FALSE if not *************************************************************************/ BOOL isACPowerLost( void ) { BOOL result = FALSE; - if ( ( getCPLDACPowerLossDetected() != FALSE ) || + if ( ( getCPLDACPowerLossDetected( ) != FALSE ) || ( alarmsBlockedCountdownTimer != ALARM_NOT_BLOCKED ) ) { result = TRUE; @@ -701,16 +712,20 @@ * @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 + * @details Inputs: none + * @details Outputs: alarmsBlockedCountdownTimer * @return TRUE if A/C power loss condition is in effect, FALSE if not *************************************************************************/ static void checkACPowerLost( void ) { - if ( TRUE == isACPowerLost( ) ) + if ( TRUE == getCPLDACPowerLossDetected( ) ) { alarmsBlockedCountdownTimer = ALARM_BLOCKED_TICK_COUNT_AFTER_AC_RETURN; } + else if ( alarmsBlockedCountdownTimer > 0 ) + { + alarmsBlockedCountdownTimer--; + } } /*********************************************************************//**