Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r7bbf1fb04f7e4788c3072ca173413ed052c608d3 -r4d96b3ddd98babc1214e4bbbb981797c3c2eb70a --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 7bbf1fb04f7e4788c3072ca173413ed052c608d3) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 4d96b3ddd98babc1214e4bbbb981797c3c2eb70a) @@ -104,14 +104,16 @@ static U32 emptySalineBagCtr = 0; ///< Timer counter for empty bag detection. -static U08 lastVenousPressureReadCtr; ///< Previous venous pressure read counter. -static U08 lastBPOcclReadCtr; ///< Previous BP occlusion read counter. -static U08 lastDPiOcclReadCtr; ///< Previous DPi occlusion read counter. -static U08 lastDPoOcclReadCtr; ///< Previous DPo occlusion read counter. +static U08 lastVenousPressureReadCtr; ///< Previous venous pressure read count. +static U08 lastBPOcclReadCtr; ///< Previous BP occlusion read count. +static U08 lastDPiOcclReadCtr; ///< Previous DPi occlusion read count. +static U08 lastDPoOcclReadCtr; ///< Previous DPo occlusion read count. +static U08 lastBPErrorCtr; ///< Previous BP error count. +static U08 lastDPIErrorCtr; ///< Previous DPi error count. +static U08 lastDPOErrorCtr; ///< Previous DPo error count. // ********** private function prototypes ********** -static PRESSURE_STATE_T handlePresOcclInitState( void ); static PRESSURE_STATE_T handlePresOcclContReadState( void ); static void convertInlinePressures( void ); static void convertOcclusionPressures( void ); @@ -140,11 +142,17 @@ initPersistentAlarm( ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_DPI_OCCLUSON_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_DPO_OCCLUSION_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_DPI_OCCLUSION_SENSOR_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_DPO_OCCLUSION_SENSOR_ERROR, 0, PRES_ALARM_PERSISTENCE ); lastVenousPressureReadCtr = 0; lastBPOcclReadCtr = 0; lastDPiOcclReadCtr = 0; lastDPoOcclReadCtr = 0; + lastBPErrorCtr = 0; + lastDPIErrorCtr = 0; + lastDPOErrorCtr = 0; } /*********************************************************************//** @@ -162,8 +170,7 @@ U32 diOccl = getMeasuredDialInPumpOcclusion(); U32 doOccl = getMeasuredDialOutPumpOcclusion(); - if ( ( bpOccl >= CARTRIDGE_LOADED_THRESHOLD ) && - ( diOccl >= CARTRIDGE_LOADED_THRESHOLD ) && + if ( ( bpOccl >= CARTRIDGE_LOADED_THRESHOLD ) && ( diOccl >= CARTRIDGE_LOADED_THRESHOLD ) && ( doOccl >= CARTRIDGE_LOADED_THRESHOLD ) ) { result = TRUE; @@ -174,6 +181,23 @@ /*********************************************************************//** * @brief + * The isCartridgeUnloaded function determines if a cartridge has been + * unloaded by looking at the 3 occlusion pressure sensors. + * @details Inputs: occlusion pressures for the pumps + * @details Outputs: none + * @return TRUE if all 3 occlusion sensors read below loaded threshold, FALSE if not. + *************************************************************************/ +BOOL isCartridgeUnloaded( void ) +{ + BOOL const bpOcclBelowLoadedThreshold = getMeasuredBloodPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + BOOL const diOcclBelowLoadedThreshold = getMeasuredDialInPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + BOOL const doOcclBelowLoadedThreshold = getMeasuredDialOutPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + + return ( bpOcclBelowLoadedThreshold && diOcclBelowLoadedThreshold && doOcclBelowLoadedThreshold ); +} + +/*********************************************************************//** + * @brief * The isSalineBagEmpty function determines whether the saline bag is empty. * It is assumed that this function will only be called from mode handling * (General Task) when pumping (BP) from the saline bag. @@ -214,7 +238,7 @@ switch ( presOcclState ) { case PRESSURE_INIT_STATE: - presOcclState = handlePresOcclInitState(); + presOcclState = PRESSURE_CONTINUOUS_READ_STATE; break; case PRESSURE_CONTINUOUS_READ_STATE: @@ -232,21 +256,6 @@ /*********************************************************************//** * @brief - * The handlePresOcclInitState function handles the initialize state - * of the pressure/occlusion monitor state machine. - * @details Inputs: TBD - * @details Outputs: TBD - * @return next state - *************************************************************************/ -static PRESSURE_STATE_T handlePresOcclInitState( void ) -{ - PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; - - return result; -} - -/*********************************************************************//** - * @brief * The handlePresOcclContReadState function handles the continuous read state * of the pressure/occlusion monitor state machine. * @details Inputs: FPGA pressure/occlusion readings @@ -325,7 +334,7 @@ else { #ifndef DISABLE_PRESSURE_CHECKS - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, (U32)venPresStatus ) // TODO - persistence? +// SET_ALARM_WITH_1_U32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, (U32)venPresStatus ) // TODO - persistence? YES, need persistence - getting a stale data status. OR maybe speed up ADC in FPGA. #endif } @@ -353,17 +362,16 @@ U08 dpiErrorCtr = getFPGADialInPumpOcclusionErrorCounter(); U08 dpoErrorCtr = getFPGADialOutPumpOcclusionErrorCounter(); -#ifndef DISABLE_FPGA_COUNTER_CHECKS // Check for sensor errors - if ( bpErrorCtr > 0 ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR, ( bpErrorCtr != lastBPErrorCtr ) ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR, (U32)bpErrorCtr ) } - if ( dpiErrorCtr > 0 ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DPI_OCCLUSION_SENSOR_ERROR, ( dpiErrorCtr != lastDPIErrorCtr ) ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DPI_OCCLUSION_SENSOR_ERROR, (U32)dpiErrorCtr ) } - if ( dpoErrorCtr > 0 ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DPO_OCCLUSION_SENSOR_ERROR, ( dpoErrorCtr != lastDPOErrorCtr ) ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DPO_OCCLUSION_SENSOR_ERROR, (U32)dpoErrorCtr ) } @@ -381,17 +389,19 @@ { activateAlarmNoData( ALARM_ID_HD_DPO_OCCLUSION_READ_TIMEOUT_ERROR ); } -#endif // Record occlusion sensor readings bloodPumpOcclusion.data = (U32)getFPGABloodPumpOcclusion(); dialInPumpOcclusion.data = (U32)getFPGADialInPumpOcclusion(); dialOutPumpOcclusion.data = (U32)getFPGADialOutPumpOcclusion(); - // Record occlusion read counters for next time around + // Record occlusion read and error counters for next time around lastBPOcclReadCtr = bpReadCtr; lastDPiOcclReadCtr = dpiReadCtr; lastDPoOcclReadCtr = dpoReadCtr; + lastBPErrorCtr = bpErrorCtr; + lastDPIErrorCtr = dpiErrorCtr; + lastDPOErrorCtr = dpoErrorCtr; } /*********************************************************************//**