Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r92f7cf45960398664518966bfaa2199f287cf2bd -r0ae9200f9979d57cd43e175801b2a676c1ba1f7b --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 92f7cf45960398664518966bfaa2199f287cf2bd) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 0ae9200f9979d57cd43e175801b2a676c1ba1f7b) @@ -56,9 +56,10 @@ #define OCCLUSION_THRESHOLD 25000 ///< Threshold above which an occlusion is detected. #define CARTRIDGE_LOADED_THRESHOLD 5000 ///< Threshold above which a cartridge is considered loaded. -#define EMPTY_SALINE_BAG_THRESHOLD_MMGH -200.0 ///< Threshold below which the saline bag is considered empty (in mmHg). TODO - get real threshold from Systems +#define EMPTY_SALINE_BAG_THRESHOLD_MMHG -300.0 ///< Threshold below which the saline bag is considered empty (in mmHg). TODO - get real threshold from Systems +#define EMPTY_SALINE_BAG_PERSISTENCE ( 250 / TASK_GENERAL_INTERVAL ) ///< Time that saline bag looks empty before saying it is empty. TODO - use persistent alarm when updated -#define PRES_ALARM_PERSISTENCE ( 1 * MS_PER_SECOND ) ///< Alarm persistence period for pressure alarms. +#define PRES_ALARM_PERSISTENCE ( 1 * MS_PER_SECOND ) ///< Alarm persistence period for pressure alarms. /// Defined states for the pressure and occlusion monitor state machine. typedef enum PresOccl_States @@ -88,13 +89,14 @@ static OVERRIDE_F32_T venousPressure = {0.0, 0.0, 0.0, 0 }; ///< Measured venous pressure. static OVERRIDE_U32_T bloodPumpOcclusion = {0, 0, 0, 0 }; ///< Measured blood pump occlusion pressure. static OVERRIDE_U32_T dialInPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate inlet pump occlusion pressure. -static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate outlet pump occlusion pressure. - +static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate outlet pump occlusion pressure. + /// Current pressure self-test state. static PRESSURE_SELF_TEST_STATE_T presOcclSelfTestState = PRESSURE_SELF_TEST_STATE_START; static U32 bloodPumpSelfTestTimerCount = 0; ///< Timer counter for pressure self-test. static U32 staleVenousPressureCtr = 0; ///< Timer counter for stale venous pressure reading. +static U32 emptySalineBagCtr = 0; ///< Timer counter for empty bag detection. // ********** private function prototypes ********** @@ -156,9 +158,9 @@ /*********************************************************************//** * @brief * The isSalineBagEmpty function determines whether the saline bag is empty. - * It is assumed that this function will only be called when pumping (BP) from - * the saline bag. Determination is based on pressure going below a negative - * threshold. + * It is assumed that this function will only be called from mode handling + * (General Task) when pumping (BP) from the saline bag. + * Determination is based on pressure going below a negative threshold. * @details Inputs: arterial line pressure * @details Outputs: none * @return TRUE if arterial line pressure is below threshold, FALSE if not. @@ -167,10 +169,17 @@ { BOOL result = FALSE; - if ( getMeasuredArterialPressure() < EMPTY_SALINE_BAG_THRESHOLD_MMGH ) + if ( getMeasuredArterialPressure() < EMPTY_SALINE_BAG_THRESHOLD_MMHG ) { - result = TRUE; + if ( ++emptySalineBagCtr >= EMPTY_SALINE_BAG_PERSISTENCE ) + { + result = TRUE; + } } + else + { + emptySalineBagCtr = 0; + } return result; }