Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rd4dfcd3155274d9252ddb5f10d9d081f3ecd6b5a -ra5ed2e6ec59ab5f9dbf5aabeb3728b7ed2503ea8 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision d4dfcd3155274d9252ddb5f10d9d081f3ecd6b5a) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision a5ed2e6ec59ab5f9dbf5aabeb3728b7ed2503ea8) @@ -187,7 +187,6 @@ static OVERRIDE_F32_T syringePumpMeasHome = { 0.0, 0.0, 0.0, 0 }; ///< Measured optical home (in V). static OVERRIDE_S32_T syringePumpPosition = { 0, 0, 0, 0 }; ///< Encoder based position (in steps). static OVERRIDE_F32_T syringePumpVolumeDelivered = { 0.0, 0.0, 0.0, 0 }; ///< Measured volume delivered (in mL). -static F32 syringePumpVolumeRequired = 0.0F; ///< Volume required for complete therapy (in mL). static OVERRIDE_F32_T heparinBolusTargetRate = { HEPARIN_BOLUS_TARGET_RATE, 0.0, HEPARIN_BOLUS_TARGET_RATE, 0 }; ///< Target rate of the heprin bolus in mL/hour static OVERRIDE_U32_T syringePumpStatus = {0, 0, 0, 0}; ///< Syringe pump status reported by FPGA. @@ -211,6 +210,7 @@ static U32 syringePumpSpeedCalcTimerCounter; ///< Used to calculate measured rate from change in position over time. static MOTOR_DIR_T syringePumpControllerMeasuredDirection; ///< Measured direction of syringe pump per controller. static MOTOR_DIR_T syringePumpEncoderMeasuredDirection; ///< Measured direction of syringe pump per encoder position relative to previous. +static F32 syringePumpVolumeRequired; ///< Volume required for complete therapy (in mL). static BOOL syringePumpRetractRequested; ///< Flag indicates a retract operation is requested. static BOOL syringePumpPreloadRequested; ///< Flag indicates a plunger preload operation is requested. @@ -224,6 +224,7 @@ static BOOL syringePumpPlungerFound; ///< Flag indicates plunger was found. static BOOL syringeVolumeAdequate; ///< Flag indicates whether Heparin volume is sufficient to complete treatment. static BOOL syringePumpPrimeCompleted; ///< Flag indicates prime operation was completed. +static BOOL syringePumpPreLoadCompleted; ///< Flag indicates preload operation was completed. static BOOL syringePumpDACVrefWriteInProgress; ///< Flag indicates DAC Vref write is in progress. static F32 syringePumpDACVref; ///< DAC Vref setting for force sensor. @@ -290,6 +291,7 @@ syringePumpVolumeStartPosition = 0; syringePumpHomePositionOffset = 0; syringePumpLastPosition = 0; + syringePumpVolumeRequired = 0.0; #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) @@ -308,6 +310,7 @@ syringePumpPlungerFound = FALSE; syringeVolumeAdequate = FALSE; syringePumpPrimeCompleted = FALSE; + syringePumpPreLoadCompleted = FALSE; syringePumpRampUpPct = 0.0; // Zero pump position counts buffer @@ -518,7 +521,7 @@ { heparinDeliveryState = HEPARIN_STATE_STOPPED; } - if ( ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) && ( FALSE == isSyringeDetected() ) && + if ( ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) && ( TRUE == syringePumpPositionKnown ) && ( heparinDeliveryState != HEPARIN_STATE_OFF ) ) { syringePumpSetRate = SYRINGE_PUMP_SEEK_RATE; @@ -985,6 +988,19 @@ /*********************************************************************//** * @brief + * The isSyringePumpPreLoaded function determines whether the syringe pump + * is has been moved to preload position. + * @details Inputs: syringePumpPreLoadCompleted + * @details Outputs: none + * @return TRUE if syringe pump operation is in preload position, FALSE if not. + *************************************************************************/ +BOOL isSyringePumpPreLoaded( void ) +{ + return syringePumpPreLoadCompleted; +} + +/*********************************************************************//** + * @brief * The execSyringePumpMonitor function executes the syringe pump monitor. * @details Inputs: FPGA syringe pump readings * @details Outputs: Alarm(s) may be triggered @@ -1064,7 +1080,6 @@ { clearAlarmCondition( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_REMOVED ); clearAlarmCondition( ALARM_ID_HD_SYRINGE_DETECTED ); - syringePumpVolumeRequired = 0.0F; } } @@ -1369,6 +1384,8 @@ syringePumpPlungerFound = FALSE; syringeVolumeAdequate = FALSE; syringePumpPrimeCompleted = FALSE; + syringePumpPreLoadCompleted = FALSE; + syringePumpVolumeRequired = 0.0F; // Clear insufficient volume alarm condition in case we're retracting to allow user to resolve alarm clearAlarmCondition( ALARM_ID_HD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM ); } @@ -1415,35 +1432,31 @@ F32 txVolumeReq = SYRINGE_PUMP_PRIME_VOLUME_ML + bolusVol + ( hepDurHr * contRate ); F32 syringeVol = ( SYRINGE_PUMP_EMPTY_POS - (F32)pos ) / SYRINGE_ENCODER_COUNTS_PER_ML; - syringePumpVolumeRequired = txVolumeReq + SYRINGE_PUMP_PRELOAD_MARGIN_VOLUME_ML; + syringePumpVolumeRequired = txVolumeReq; txVolumeReq = txVolumeReq + SYRINGE_PUMP_PRELOAD_MARGIN_VOLUME_ML; - // Keep at Home position if large volume to deliver. - if ( SYRINGE_PUMP_PRELOAD_MAX_VOLUME_ML < txVolumeReq ) + // Is syringe loaded? + if ( TRUE == isSyringeDetected() ) { + activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); stopPump = TRUE; } + else + { + // Handle ramp up + rampSyringePump(); + } - // Handle ramp up - rampSyringePump(); - - // Is plunger Heparin volume position detected? - if ( ( syringeVol <= txVolumeReq ) ) + // Is plunger Heparin volume position detected? or volume requiring full syringe. + if ( ( syringeVol <= txVolumeReq ) || ( SYRINGE_PUMP_PRELOAD_MAX_VOLUME_ML < txVolumeReq ) ) { stopPump = TRUE; syringePumpVolumeDelivered.data = 0.0; syringePumpSafetyVolumeDelivered = 0.0; syringePumpVolumeStartPosition = pos; - // TODO Need flag for Preload complete - check for this in SelfTests.c, handleDrySelfTestSyringePumpPrimeState + syringePumpPreLoadCompleted = TRUE; } - // Is syringe loaded? - if ( TRUE == isSyringeDetected() ) - { - activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); - stopPump = TRUE; - } - // Check max position > empty + 0.5 mL stopPump = checkMaxTravel( stopPump, SYRINGE_PUMP_EMPTY_POS + SYRINGE_PUMP_EMPTY_POS_MARGIN ); @@ -1491,6 +1504,7 @@ syringePumpVolumeDelivered.data = 0.0; syringePumpSafetyVolumeDelivered = 0.0; syringePumpVolumeStartPosition = pos; + syringePumpPreLoadCompleted = FALSE; // Check estimated syringe volume needed for treatment vs. volume detected - if insufficient for treatment needs, alarm if ( syringeVol >= txVolume ) @@ -1552,6 +1566,7 @@ syringePumpVolumeDelivered.data = 0.0; syringePumpSafetyVolumeDelivered = 0.0; syringePumpVolumeStartPosition = syringePumpPosition.data; + syringePumpPreLoadCompleted = FALSE; } // Has syringe been removed?