Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rd4dfcd3155274d9252ddb5f10d9d081f3ecd6b5a -raeeff23d7aec8a1396393d3cb188ac03eca60ead --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision d4dfcd3155274d9252ddb5f10d9d081f3ecd6b5a) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision aeeff23d7aec8a1396393d3cb188ac03eca60ead) @@ -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. @@ -308,6 +309,7 @@ syringePumpPlungerFound = FALSE; syringeVolumeAdequate = FALSE; syringePumpPrimeCompleted = FALSE; + syringePumpPreLoadCompleted = FALSE; syringePumpRampUpPct = 0.0; // Zero pump position counts buffer @@ -985,6 +987,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 @@ -1369,6 +1384,7 @@ syringePumpPlungerFound = FALSE; syringeVolumeAdequate = FALSE; syringePumpPrimeCompleted = FALSE; + syringePumpPreLoadCompleted = FALSE; // 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 ); } @@ -1412,38 +1428,34 @@ U32 preStop = getTreatmentParameterU32( TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME ); U32 setTxDur = getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION ); F32 hepDurHr = ( (F32)( setTxDur - preStop ) / (F32)MIN_PER_HOUR ); + // TODO Move this calculation earlier in the process? 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; - 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() ) { - stopPump = TRUE; + activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); + stopSyringePump(); + return result; } + syringePumpVolumeRequired = txVolumeReq; + txVolumeReq = txVolumeReq + SYRINGE_PUMP_PRELOAD_MARGIN_VOLUME_ML; + // 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 +1503,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 +1565,7 @@ syringePumpVolumeDelivered.data = 0.0; syringePumpSafetyVolumeDelivered = 0.0; syringePumpVolumeStartPosition = syringePumpPosition.data; + syringePumpPreLoadCompleted = FALSE; } // Has syringe been removed?