Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rb36fc8801adfc9d2f402450abffe721e71f9a5e5 -rfe91ec494378a7df34e3c14853a797f9f8f044e9 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision b36fc8801adfc9d2f402450abffe721e71f9a5e5) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision fe91ec494378a7df34e3c14853a797f9f8f044e9) @@ -188,6 +188,8 @@ static OVERRIDE_U32_T syringePumpADCandDACStatus = {0, 0, 0, 0}; ///< Syringe pump ADC and DAC status reported by FPGA. static OVERRIDE_U32_T syringePumpADCReadCtr = {0, 0, 0, 0}; ///< Syringe pump ADC read counter reported by FPGA. +static BOOL requireSyringeDetection; ///< Flag indicating whether syringe detection is required in the current state. + static F32 syringePumpSetRate; ///< Set rate for syringe pump (in mL/hr). static F32 forceAtEndOfSeek; ///< Force sensor reading in Volts at the end of seek. static U32 syringePumpSetToggleTime; ///< Set rate for syringe pump (in uSec/toggle). @@ -275,6 +277,8 @@ syringePumpState = SYRINGE_PUMP_INIT_STATE; heparinDeliveryState = HEPARIN_STATE_OFF; + requireSyringeDetection = FALSE; + syringePumpSetRate = 0.0; syringePumpSetToggleTime = 0; syringePumpSafetyVolumeDelivered = 0.0; @@ -675,6 +679,20 @@ /*********************************************************************//** * @brief + * The syringeDetectionRequired function sets a flag indicating whether + * the syringe detection is required in current state. + * @details Inputs: none + * @details Outputs: requireSyringeDetection + * @param req True if syringe detection is required in the current state + * @return none + *************************************************************************/ +void syringeDetectionRequired( BOOL req ) +{ + requireSyringeDetection = req; +} + +/*********************************************************************//** + * @brief * The getSyringePumpVolumeDelivered function gets the current syringe pump * volume delivered. * @details Inputs: syringePumpVolumeDelivered @@ -959,37 +977,59 @@ // Get latest ADC data and convert to V syringePumpMeasHome.data = ( (F32)getFPGASyringePumpADCChannel2() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; - syringePumpMeasSyringeDetectionSwitch.data = ( (F32)getFPGASyringePumpADCChannel1() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_DISABLE_VALUE ) + { + syringePumpMeasSyringeDetectionSwitch.data = 0.0; // if syringe pump disabled, always report no detection + } + else +#endif + { + syringePumpMeasSyringeDetectionSwitch.data = ( (F32)getFPGASyringePumpADCChannel1() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; + } // Log syringe detect switch changes if ( prevSyringeDetected != isSyringeDetected() ) { sendTreatmentLogEventData( SYRINGE_DETECTION_SWITCH_CHANGED_EVENT, (F32)prevSyringeDetected, (F32)isSyringeDetected() ); } + // Handle syringe detect alarm management #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { - // On transition from not detected to detected - clear syringe removed alarm condition - if ( ( prevSyringeDetected != TRUE ) && ( TRUE == isSyringeDetected() ) ) + F32 bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); + F32 hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ); + + // Syringe detection not required if not using Heparin in treatment + if ( ( bolusVol > NEARLY_ZERO ) || ( hepRate > NEARLY_ZERO ) ) { - clearAlarmCondition( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_REMOVED ); + // On transition from not detected to detected or if syringe detection not required - clear syringe removed alarm condition + if ( ( ( prevSyringeDetected != TRUE ) && ( TRUE == isSyringeDetected() ) ) || ( requireSyringeDetection != TRUE ) ) + { + clearAlarmCondition( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_REMOVED ); + } + // If no syringe detected and detection is required, trigger alarm condition + else if ( ( FALSE == isSyringeDetected() ) && ( TRUE == requireSyringeDetection ) ) + { + activateAlarmNoData( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_REMOVED ); + } + // On transition from detected to not detected - clear syringe detected alarm condition + if ( ( TRUE == prevSyringeDetected ) && ( isSyringeDetected() != TRUE ) ) + { + clearAlarmCondition( ALARM_ID_HD_SYRINGE_DETECTED ); + } + // If syringe detected and alarm active, maintain alarm condition + else if ( ( TRUE == isSyringeDetected() ) && ( TRUE == isAlarmActive( ALARM_ID_HD_SYRINGE_DETECTED ) ) ) + { + activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); + } } - // If no syringe detected while syringe removed alarm is active, maintain alarm condition - else if ( ( FALSE == isSyringeDetected() ) && ( TRUE == isAlarmActive( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_REMOVED ) ) ) + else { - activateAlarmNoData( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_REMOVED ); - } - // On transition from detected to not detected - clear syringe detected alarm condition - if ( ( TRUE == prevSyringeDetected ) && ( isSyringeDetected() != TRUE ) ) - { + clearAlarmCondition( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_REMOVED ); clearAlarmCondition( ALARM_ID_HD_SYRINGE_DETECTED ); } - // If syringe detected while syringe detected alarm is active, maintain alarm condition - else if ( ( TRUE == isSyringeDetected() ) && ( TRUE == isAlarmActive( ALARM_ID_HD_SYRINGE_DETECTED ) ) ) - { - activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); - } } forceSensorBeforCal = ( (F32)getFPGASyringePumpADCChannel0() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS;