Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r640525dbad258a32c5dfecdc29268b432f72fb43 -r95d7d8e230da1c04c2fed2be5a43afd273d95846 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 640525dbad258a32c5dfecdc29268b432f72fb43) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 95d7d8e230da1c04c2fed2be5a43afd273d95846) @@ -45,6 +45,7 @@ #define DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C 2.0F ///< Dialysate temperature clear alarm tolerance C #define DIALYSATE_TEMP_OUT_OF_TARGET_TOL_C 4.0F ///< Dialysate temperature out of target tolerance C. +#define DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ( 90 * MS_PER_SECOND ) ///< Dialysate temperature out of target timeout in milliseconds. #define DIALYSATE_TEMP_UPPER_MAX_SAFETY_LIMIT_C 46.0F ///< Dialysate upper bound maximum temperature limit in C. #define DIALYSATE_TEMP_UPPER_MAX_SAFETY_TIMEOUT_MS ( 1 * MS_PER_SECOND ) ///< Dialysate temperature upper bound maximum safety timeout in milliseconds. #define DIALYSATE_TEMP_UPPER_SAFETY_LIMIT_C 42.0F ///< Dialysate upper bound safety temperature limit in C. @@ -98,9 +99,6 @@ static DG_RESERVOIR_ID_T dgActiveReservoir; ///< Latest active reservoir reported by the DG. static DG_RESERVOIR_ID_T dgActiveReservoirSet; ///< Active reservoir commanded. -// Tdi temperature Monitor -static DG_TDI_TEMP_COUNTER_T dgTdiTempCounter; ///< DG Tdi temperature Counter. - static DG_DISINFECT_UI_STATES_T disinfectsStatus; ///< DG disinfects status. static DG_MIXING_RATIOS_T dgMixingRatios; ///< DG mixing ratios. static HEATERS_DATA_T dgHeatersData; ///< DG heaters data. @@ -176,40 +174,16 @@ lgLoadCellBackupReadingsTotal[ DG_RESERVOIR_1 ] = 0.0F; lgLoadCellBackupReadingsTotal[ DG_RESERVOIR_2 ] = 0.0F; + initPersistentAlarm( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS, DIALYSATE_TEMP_UPPER_MAX_SAFETY_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_HD_NEW_LOAD_CELL_DATA_MESSAGE_NOT_RECEIVE, DG_DATA_FRESHNESS_TIMEOUT_MS, DG_DATA_FRESHNESS_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_HD_NEW_DIALYSATE_TEMP_DATA_MESSAGE_NOT_RECEIVE, DG_DATA_FRESHNESS_TIMEOUT_MS, DG_DATA_FRESHNESS_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_HD_NEW_RESERVOIRS_DATA_MESSAGE_NOT_RECEIVE, DG_DATA_FRESHNESS_TIMEOUT_MS, DG_DATA_FRESHNESS_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_HD_DG_NEW_OPERATION_MODE_MESSAGE_NOT_RECEIVE, DG_DATA_FRESHNESS_TIMEOUT_MS, DG_DATA_FRESHNESS_TIMEOUT_MS ); - - resetTdiTempCounters(); } -/*********************************************************************//** - * @brief - * The resetTdiTempCounters function initializes the counter variables. - * @details Inputs: none - * @details Outputs: TdiTemperature counter variables initialized. - * @return none - *************************************************************************/ -void resetTdiTempCounters ( void ) -{ - //Initialize tdi temperature counter values - dgTdiTempCounter.tdiHighTempUpCounter = 0; - dgTdiTempCounter.tdiHighTempDownCounter = 0; - dgTdiTempCounter.prevTdiHighTempUpCounter = 0; - dgTdiTempCounter.prevTdiHighTempDownCounter = 0; - dgTdiTempCounter.tdiHighclearAlarmStartTime = 0; - dgTdiTempCounter.tdiLowTempUpCounter = 0; - dgTdiTempCounter.tdiLowTempDownCounter = 0; - dgTdiTempCounter.prevTdiLowTempUpCounter = 0; - dgTdiTempCounter.prevTdiLowTempDownCounter = 0; - dgTdiTempCounter.tdiHighclearAlarmStartTime = 0; - dgTdiTempCounter.dgPrevActiveReservoir = DG_RESERVOIR_2; - dgTdiTempCounter.dgCurrentActiveReservoir = DG_RESERVOIR_2; -} - /**********************************************************************//** * @brief * The checkDGDataFreshness function checks the condition @@ -297,30 +271,6 @@ /*********************************************************************//** * @brief - * The getDGTdiTempCounter function gets the TDI temperature high and low counters values. - * @details Inputs: dgTdiTempCounter - * @details Outputs: none - * @return TDI temperature high and low temperature counter values. - *************************************************************************/ -DG_TDI_TEMP_COUNTER_T getDGTdiTempCounter( void ) -{ - return dgTdiTempCounter; -} - -/*********************************************************************//** - * @brief - * The getDGTdiTempetraure function gets the TDI temperature value. - * @details Inputs: dgDialysateTemp - * @details Outputs: none - * @return TDI temperature value. - *************************************************************************/ -F32 getDGTdiTempetraure( void ) -{ - return dgDialysateTemp; -} - -/*********************************************************************//** - * @brief * The getDGSubMode function gets the current DG operating sub-mode. * @details Inputs: dgSubMode * @details Outputs: none @@ -1312,124 +1262,29 @@ BOOL isTDiTempBelowDialysateTarget = ( dgDialysateTemp <= TDiLow ? TRUE : FALSE ); BOOL isTempBelowTrigger = (BOOL)( isTDITempBelowLowSafety || isTDiTempBelowDialysateTarget ); BOOL isTempAboveTrigger = (BOOL)( isTDiTempAboveLowSafety || isTDiTempAboveDialysateTarget ); - DG_RESERVOIR_ID_T currentActiveRes = getDGActiveReservoir(); #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DIALYSATE_TEMP_CHECK ) != SW_CONFIG_ENABLE_VALUE ) #endif { - // Check Tdi High/Low temperature alarm active - BOOL alarmTdiHighIsActive = isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ); - BOOL alarmTdiLowIsActive = isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP ); - - // Tdi high temp alarm clear - if ( dgDialysateTemp <= ( dgTrimmerTempSet + DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ) + // check clear condition first + if ( TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP ) ) { - if ( TRUE == alarmTdiHighIsActive ) - { - if ( dgTdiTempCounter.tdiHighclearAlarmStartTime == 0 ) - { - dgTdiTempCounter.tdiHighclearAlarmStartTime = getMSTimerCount(); - } - else if ( TRUE == didTimeout(dgTdiTempCounter.tdiHighclearAlarmStartTime, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS ) ) - { - clearAlarmCondition( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ); - } - } + isTDiTempAboveHighSafety = ( dgDialysateTemp <= ( dgTrimmerTempSet + DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ? FALSE : TRUE ); } - else - { - dgTdiTempCounter.tdiHighclearAlarmStartTime = 0; - } + checkPersistentAlarm(ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP, isTDiTempAboveHighSafety, dgDialysateTemp, dgTrimmerTempSet ); - // Tdi Low temp alarm clear - if ( dgDialysateTemp >= ( dgTrimmerTempSet - DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ) + if ( TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ) ) { - if ( TRUE == alarmTdiLowIsActive ) - { - if ( dgTdiTempCounter.tdiLowclearAlarmStartTime == 0 ) - { - dgTdiTempCounter.tdiLowclearAlarmStartTime = getMSTimerCount(); - } - else if ( TRUE == didTimeout(dgTdiTempCounter.tdiLowclearAlarmStartTime, DIALYSATE_TEMP_CLEAR_TIMEOUT_MS ) ) - { - clearAlarmCondition( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP ); - } - } + isTempAboveTrigger = ( dgDialysateTemp <= ( dgTrimmerTempSet + DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ? FALSE : TRUE ); } - else - { - dgTdiTempCounter.tdiLowclearAlarmStartTime = 0; - } + checkPersistentAlarm(ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP, isTempAboveTrigger, dgDialysateTemp, dgTrimmerTempSet ); - if ( currentActiveRes != dgTdiTempCounter.dgPrevActiveReservoir ) + if ( TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP ) ) { - // Tdi high temp alarm set - if ( TRUE == isTempAboveTrigger ) - { - //Increment tdi high temp up count when temperature is exceeded the defined threshold - dgTdiTempCounter.tdiHighTempUpCounter++; - } - // Initiate tdi high temp down Counter only when temperature is crossed the threshold. otherwise do not increment down counter - else if ( dgTdiTempCounter.tdiHighTempUpCounter > 0 ) - { - dgTdiTempCounter.tdiHighTempDownCounter++; - } - - //Tdi Low temp alarm set - if ( TRUE == isTempBelowTrigger ) - { - //Increment tdi low temp down count when temperature is goes below the defined threshold - dgTdiTempCounter.tdiLowTempDownCounter++; - } - // Initiate Tdi low up Counter only when temperature is crossed the threshold. otherwise do not increment up counter - else if ( dgTdiTempCounter.tdiLowTempDownCounter > 0 ) - { - dgTdiTempCounter.tdiLowTempUpCounter++; - } - - //get current reservoir value - dgTdiTempCounter.dgCurrentActiveReservoir = currentActiveRes; + isTempBelowTrigger = ( dgDialysateTemp >= ( dgTrimmerTempSet - DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ? FALSE : TRUE ); } - else - { - // last reservoir cycle temperature should have crossed the threshold level, - // to compute next reservoir cycle temperature rise count is greater than the previous one. - if ( (dgTdiTempCounter.prevTdiHighTempUpCounter != 0) && - (dgTdiTempCounter.tdiHighTempUpCounter >= dgTdiTempCounter.prevTdiHighTempUpCounter ) && - (dgTdiTempCounter.tdiHighTempDownCounter <= dgTdiTempCounter.prevTdiHighTempDownCounter ) ) - { - //Activate Alarm - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP, dgDialysateTemp, dgTrimmerTempSet ); - } - // Tdi low temp alarm - if ( (dgTdiTempCounter.prevTdiLowTempDownCounter != 0) && - (dgTdiTempCounter.tdiLowTempDownCounter >= dgTdiTempCounter.prevTdiLowTempDownCounter ) && - (dgTdiTempCounter.tdiLowTempUpCounter <= dgTdiTempCounter.prevTdiLowTempUpCounter ) ) - { - //Activate Alarm - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP, dgDialysateTemp, dgTrimmerTempSet ); - } - // readiness for the next reservoir cycle - dgTdiTempCounter.prevTdiHighTempUpCounter = dgTdiTempCounter.tdiHighTempUpCounter; - dgTdiTempCounter.prevTdiHighTempDownCounter = dgTdiTempCounter.tdiHighTempDownCounter; - dgTdiTempCounter.tdiHighTempUpCounter = 0; - dgTdiTempCounter.tdiHighTempDownCounter = 0; - dgTdiTempCounter.prevTdiLowTempUpCounter = dgTdiTempCounter.tdiLowTempUpCounter; - dgTdiTempCounter.prevTdiLowTempDownCounter = dgTdiTempCounter.tdiLowTempDownCounter; - dgTdiTempCounter.tdiLowTempUpCounter = 0; - dgTdiTempCounter.tdiLowTempDownCounter = 0; - - // assign last current reservoir to previous Active reservoir value once reservoir switch happened - dgTdiTempCounter.dgPrevActiveReservoir = dgTdiTempCounter.dgCurrentActiveReservoir; - } - - // check clear condition first - if ( TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP ) ) - { - isTDiTempAboveHighSafety = ( dgDialysateTemp <= ( dgTrimmerTempSet + DIALYSATE_TEMP_OUT_OF_TARGET_CLEAR_TOL_C ) ? FALSE : TRUE ); - } - checkPersistentAlarm(ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP, isTDiTempAboveHighSafety, dgDialysateTemp, dgTrimmerTempSet ); + checkPersistentAlarm(ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP, isTempBelowTrigger, dgDialysateTemp, dgTrimmerTempSet ); } }