Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r52761961d73cdc8f5f9c0c83ef420bcd43a27551 -rbb144484d4d22e3f24a280eda9c8abf9570a443a --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 52761961d73cdc8f5f9c0c83ef420bcd43a27551) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision bb144484d4d22e3f24a280eda9c8abf9570a443a) @@ -260,9 +260,17 @@ // ********** private function prototypes ********** -static void resetSyringePumpRequestFlags( void ); -static void resetHeparinVolumeDelivered( void ); static void execSyringePumpMonitor( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpInitState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpOffState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpRetractState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpPreLoadState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpSeekState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpPrimeState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpBolusState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpContinuousState( void ); +static SYRINGE_PUMP_STATE_T handleSyringePumpCalibrateForceSensorState( void ); + static S32 getSyringePumpPosition( void ); static F32 getSyringePumpMeasRate( void ); static F32 getSyringePumpSyringeDetectorV( void ); @@ -274,28 +282,23 @@ static U08 getSyringePumpADCReadCounter( void ); static U08 getSyringePumpADCandDACStatus( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpInitState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpOffState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpRetractState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpPreLoadState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpSeekState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpPrimeState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpBolusState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpContinuousState( void ); -static SYRINGE_PUMP_STATE_T handleSyringePumpCalibrateForceSensorState( void ); -static void rampSyringePump( void ); -static void calcStepperToggleTimeForTargetRate( F32 rate ); -static void calcMeasRate( void ); -static void calcSafetyVolumeDelivered( void ); static BOOL checkDirection( BOOL stopPump, MOTOR_DIR_T expDir ); static BOOL checkSyringeEmpty( BOOL stopPump ); static BOOL checkSyringeRemoved( BOOL stopPump ); static BOOL checkMaxTravel( BOOL stopPump, S32 maxPos ); static BOOL checkMeasRate( BOOL stopPump, F32 pctMargin ); static BOOL checkVolumeVsSafetyVolume( BOOL stopPump, F32 pctMargin ); static BOOL checkForStall( BOOL stopPump ); -static void publishSyringePumpData( void ); + +static void resetSyringePumpRequestFlags( void ); +static void resetHeparinVolumeDelivered( void ); +static void rampSyringePump( void ); +static void calcStepperToggleTimeForTargetRate( F32 rate ); +static void calcMeasRate( void ); +static void calcSafetyVolumeDelivered( void ); + static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ); +static void publishSyringePumpData( void ); /*********************************************************************//** * @brief @@ -364,20 +367,112 @@ /*********************************************************************//** * @brief - * The resetSyringePumpRequestFlags function resets request flags. + * The execSyringePump function executes the syringe pump control state machine. + * @details \b Inputs: syringePumpState + * @details \b Outputs: syringePumpState + * @return none + *************************************************************************/ +void execSyringePump( void ) +{ + SYRINGE_PUMP_STATE_T priorSyringeState = syringePumpState; + // Execute syringe pump monitor + execSyringePumpMonitor(); + + if ( syringePumpDACRetryCount > 0 ) + { + syringePumpDACRetryTimer++; + } + + // Execute syringe pump control state machine + switch ( syringePumpState ) + { + case SYRINGE_PUMP_INIT_STATE: + syringePumpState = handleSyringePumpInitState(); + break; + + case SYRINGE_PUMP_OFF_STATE: + syringePumpState = handleSyringePumpOffState(); + break; + + case SYRINGE_PUMP_RETRACT_STATE: + syringePumpState = handleSyringePumpRetractState(); + break; + + case SYRINGE_PUMP_PRELOAD_STATE: + syringePumpState = handleSyringePumpPreLoadState(); + break; + + case SYRINGE_PUMP_SEEK_STATE: + syringePumpState = handleSyringePumpSeekState(); + break; + + case SYRINGE_PUMP_PRIME_STATE: + syringePumpState = handleSyringePumpPrimeState(); + break; + + case SYRINGE_PUMP_HEP_BOLUS_STATE: + syringePumpState = handleSyringePumpBolusState(); + break; + + case SYRINGE_PUMP_HEP_CONTINUOUS_STATE: + syringePumpState = handleSyringePumpContinuousState(); + break; + + case SYRINGE_PUMP_CONFIG_FORCE_SENSOR_STATE: + syringePumpState = handleSyringePumpCalibrateForceSensorState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_TD_SYRINGE_INVALID_STATE, syringePumpState ); + break; + } + + if ( priorSyringeState != syringePumpState ) + { + SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_SYRINGE_PUMP_STATE, priorSyringeState, syringePumpState ); + } + + resetSyringePumpRequestFlags(); + + // Save syringe pump info for next time + syringePumpLastPosition = getSyringePumpPosition(); + prevSyringeDetected = isSyringeDetected(); + + // Publish syringe pump data on interval + publishSyringePumpData(); +} + +/*********************************************************************//** + * @brief + * The execSyringePumpSelfTest function executes the state machine for the + * syringe pump self-test. * @details \b Inputs: none - * @details \b Out\b Outputs:quest flags reset - * @return TRUE if request accepted, FALSE if not + * @details \b Outputs: forceSensorCalRecord + * @return TRUE if the self test passed otherwise, FALSE *************************************************************************/ -static void resetSyringePumpRequestFlags( void ) +SELF_TEST_STATUS_T execSyringePumpSelfTest( void ) { - syringePumpRetractRequested = FALSE; - syringePumpSeekRequested = FALSE; - syringePumpPreloadRequested = FALSE; - syringePumpPrimeRequested = FALSE; - syringePumpBolusRequested = FALSE; - syringePumpContinuousRequested = FALSE; - syringePumpDACVrefSetRequested = FALSE; + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + BOOL calStatus = FALSE; + // Read/check force sensor calibration +// BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), +// 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); + +#ifndef _RELEASE_ +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + } + + return result; } /*********************************************************************//** @@ -640,17 +735,45 @@ /*********************************************************************//** * @brief - * The resetHeparinVolumeDelivered function resets the Heparin volume delivered. - * @details \b Inputs: none - * @details \b Outputs: syringePumpVolumeDelivered, syringePumpSafetyVolumeDelivered, - * syringePumpVolumeStartPosition - * @return none + * The checkForPrimeOcclusion function checks the force sensor for excessive + * pressure. Would indicate occlusion or jam or empty syringe. + * @details \b Inputs: syringePumpMeasForce.data, syringePumpPosition.data + * @details \b Outputs: alarm triggered if max force detected + * @param stopPump flag passed in by caller indicating whether pump should be stopped + * @return TRUE if pump should be stopped, FALSE if not *************************************************************************/ -static void resetHeparinVolumeDelivered( void ) +BOOL checkForSyringeOcclusion( BOOL stopPump ) { - syringePumpVolumeDelivered.data = 0.0; - syringePumpSafetyVolumeDelivered = 0.0; - syringePumpVolumeStartPosition = getSyringePumpPosition(); + BOOL result = stopPump; + F32 currentForceV = getSyringePumpForceV(); // Read the force sensor at the end of the priming + F32 forceDelta = currentForceV - forceAtEndOfSeek; // Occlusion is detected if force at end of prime is > than force at end of seek by 0.5 volts or more + BOOL occlusionDetected = FALSE; + + // Checking for occlusion in dry self tests without persistence + if ( MODE_PRET == getCurrentOperationMode() ) + { + occlusionDetected = ( forceDelta >= SYRINGE_FORCE_OCCLUSION_DIFF_V ? TRUE : FALSE ); + + if ( TRUE == occlusionDetected ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION, forceAtEndOfSeek, currentForceV ) + result = TRUE; + } + else + { + clearAlarmCondition( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION ); + } + } + + // Check with persistence during continuous state + if ( SYRINGE_PUMP_OP_CONTINUOUS == syringePumpState ) + { + occlusionDetected = ( currentForceV >= SYRINGE_FORCE_OCCLUSION_THRESHOLD_V ? TRUE : FALSE ); + + checkPersistentAlarm( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION, occlusionDetected, forceAtEndOfSeek, currentForceV ); + } + + return result; } /*********************************************************************//** @@ -801,149 +924,9 @@ } } -/*********************************************************************//** - * @brief - * The getSyringePumpVolumeDelivered function gets the current syringe pump - * volume delivered. - * @details \b Inputs: syringePumpVolumeDelivered - * @details \b Outputs: none - * @return the current syringe pump volume delivered (in mL). - *************************************************************************/ -F32 getSyringePumpVolumeDelivered( void ) -{ - return getF32OverrideValue( &syringePumpVolumeDelivered ); -} /*********************************************************************//** * @brief - * The getSyringePumpMeasRate function gets the current syringe pump measured - * rate. - * @details \b Inputs: syringePumpMeasRate - * @details \b Outputs: none - * @return the current syringe pump measured rate (in mL/hr). - *************************************************************************/ -static F32 getSyringePumpMeasRate( void ) -{ - return getF32OverrideValue( &syringePumpMeasRate ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpSyringeDetectorV function gets the current syringe pump - * syringe detect signal. - * @details \b Inputs: syringePumpMeasSyringeDetectionSwitch - * @details \b Outputs: none - * @return the current syringe pump syringe detect signal (in V). - *************************************************************************/ -static F32 getSyringePumpSyringeDetectorV( void ) -{ - return getF32OverrideValue( &syringePumpMeasSyringeDetectionSwitch ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpHomeDetectorV function gets the current syringe pump - * home detect signal. - * @details \b Inputs: syringePumpMeasHome - * @details \b Outputs: none - * @return the current syringe pump home detect signal (in V). - *************************************************************************/ -static F32 getSyringePumpHomeDetectorV( void ) -{ - return getF32OverrideValue( &syringePumpMeasHome ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpForceV function gets the current syringe pump force. - * @details \b Inputs: syringePumpMeasForce - * @details \b Outputs: none - * @return the current syringe pump force (in V). - *************************************************************************/ -static F32 getSyringePumpForceV( void ) -{ - return getF32OverrideValue( &syringePumpMeasForce ); -} - -/*********************************************************************//** - * @brief - * The getHeprinBolusTargetRate function gets the heprin bolus target - * flow rate. - * @details \b Inputs: getHeprinBolusTargetRate - * @details \b Outputs: getHeprinBolusTargetRate - * @return the current target heprin bolus flow rate (in mL/hour). - *************************************************************************/ -static F32 getHeprinBolusTargetRate( void ) -{ - return getF32OverrideValue( &heparinBolusTargetRate ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpPosition function gets the current syringe pump - * position. - * @details \b Inputs: syringePumpPosition - * @details \b Outputs: none - * @return the current syringe pump syringe position (in steps). - *************************************************************************/ -static S32 getSyringePumpPosition( void ) -{ - return getS32OverrideValue( &syringePumpPosition ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpStatus function gets the current syringe pump status. - * @details \b Inputs: syringePumpStatus - * @details \b Outputs: none - * @return the current syringe pump status. - *************************************************************************/ -static U08 getSyringePumpStatus() -{ - return getU08OverrideValue( &syringePumpStatus ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpEncoderStatus function gets the current syringe pump - * encoder status. - * @details \b Inputs: syringePumpEncoderStatus - * @details \b Outputs: none - * @return the current syringe pump encoder status. - *************************************************************************/ -static U08 getSyringePumpEncoderStatus() -{ - return getU08OverrideValue( &syringePumpEncoderStatus ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpADCReadCounter function gets the current syringe pump - * ADC read counter. - * @details \b Inputs: syringePumpADCReadCtr - * @details \b Outputs: none - * @return the current syringe pump ADC read counter. - *************************************************************************/ -static U08 getSyringePumpADCReadCounter() -{ - return getU08OverrideValue( &syringePumpADCReadCtr ); -} - -/*********************************************************************//** - * @brief - * The getSyringePumpADCandDACStatus function gets the current syringe pump - * ADC and DAC status reported by the FPGA. - * @details \b Inputs: syringePumpADCandDACStatus - * @details \b Outputs: none - * @return the current syringe pump ADC and DAC status. - *************************************************************************/ -static U08 getSyringePumpADCandDACStatus() -{ - return getU08OverrideValue( &syringePumpADCandDACStatus ); -} - -/*********************************************************************//** - * @brief * The isSyringeDetected function determines whether a syringe is currently * detected. * @details \b Inputs: syringePumpMeasSyringeDetectionSwitch @@ -1072,6 +1055,20 @@ /*********************************************************************//** * @brief + * The getSyringePumpVolumeDelivered function gets the current syringe pump + * volume delivered. + * @details \b Inputs: syringePumpVolumeDelivered + * @details \b Outputs: none + * @return the current syringe pump volume delivered (in mL). + *************************************************************************/ +F32 getSyringePumpVolumeDelivered( void ) +{ + return getF32OverrideValue( &syringePumpVolumeDelivered ); +} + + +/*********************************************************************//** + * @brief * The execSyringePumpMonitor function executes the syringe pump monitor. * @details \b Inputs: FPGA syringe pump readings * @details \b Outputs: Alarm(s) may be triggered @@ -1197,116 +1194,6 @@ /*********************************************************************//** * @brief - * The execSyringePump function executes the syringe pump control state machine. - * @details \b Inputs: syringePumpState - * @details \b Outputs: syringePumpState - * @return none - *************************************************************************/ -void execSyringePump( void ) -{ - SYRINGE_PUMP_STATE_T priorSyringeState = syringePumpState; - // Execute syringe pump monitor - execSyringePumpMonitor(); - - if ( syringePumpDACRetryCount > 0 ) - { - syringePumpDACRetryTimer++; - } - - // Execute syringe pump control state machine - switch ( syringePumpState ) - { - case SYRINGE_PUMP_INIT_STATE: - syringePumpState = handleSyringePumpInitState(); - break; - - case SYRINGE_PUMP_OFF_STATE: - syringePumpState = handleSyringePumpOffState(); - break; - - case SYRINGE_PUMP_RETRACT_STATE: - syringePumpState = handleSyringePumpRetractState(); - break; - - case SYRINGE_PUMP_PRELOAD_STATE: - syringePumpState = handleSyringePumpPreLoadState(); - break; - - case SYRINGE_PUMP_SEEK_STATE: - syringePumpState = handleSyringePumpSeekState(); - break; - - case SYRINGE_PUMP_PRIME_STATE: - syringePumpState = handleSyringePumpPrimeState(); - break; - - case SYRINGE_PUMP_HEP_BOLUS_STATE: - syringePumpState = handleSyringePumpBolusState(); - break; - - case SYRINGE_PUMP_HEP_CONTINUOUS_STATE: - syringePumpState = handleSyringePumpContinuousState(); - break; - - case SYRINGE_PUMP_CONFIG_FORCE_SENSOR_STATE: - syringePumpState = handleSyringePumpCalibrateForceSensorState(); - break; - - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_TD_SYRINGE_INVALID_STATE, syringePumpState ); - break; - } - - if ( priorSyringeState != syringePumpState ) - { - SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_SYRINGE_PUMP_STATE, priorSyringeState, syringePumpState ); - } - - resetSyringePumpRequestFlags(); - - // Save syringe pump info for next time - syringePumpLastPosition = getSyringePumpPosition(); - prevSyringeDetected = isSyringeDetected(); - - // Publish syringe pump data on interval - publishSyringePumpData(); -} - -/*********************************************************************//** - * @brief - * The execSyringePumpSelfTest function executes the state machine for the - * syringe pump self-test. - * @details \b Inputs: none - * @details \b Outputs: forceSensorCalRecord - * @return TRUE if the self test passed otherwise, FALSE - *************************************************************************/ -SELF_TEST_STATUS_T execSyringePumpSelfTest( void ) -{ - SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; - BOOL calStatus = FALSE; - // Read/check force sensor calibration -// BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), -// 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); - -#ifndef _RELEASE_ -// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - if ( TRUE == calStatus ) - { - result = SELF_TEST_STATUS_PASSED; - } - else - { - result = SELF_TEST_STATUS_FAILED; - } - } - - return result; -} - -/*********************************************************************//** - * @brief * The handleSyringePumpInitState function handles the initialize state * of the syringe pump control state machine. * @details \b Inputs: none @@ -1829,6 +1716,136 @@ /*********************************************************************//** * @brief + * The getSyringePumpPosition function gets the current syringe pump + * position. + * @details \b Inputs: syringePumpPosition + * @details \b Outputs: none + * @return the current syringe pump syringe position (in steps). + *************************************************************************/ +static S32 getSyringePumpPosition( void ) +{ + return getS32OverrideValue( &syringePumpPosition ); +} + +/*********************************************************************//** + * @brief + * The getSyringePumpMeasRate function gets the current syringe pump measured + * rate. + * @details \b Inputs: syringePumpMeasRate + * @details \b Outputs: none + * @return the current syringe pump measured rate (in mL/hr). + *************************************************************************/ +static F32 getSyringePumpMeasRate( void ) +{ + return getF32OverrideValue( &syringePumpMeasRate ); +} + +/*********************************************************************//** + * @brief + * The getSyringePumpSyringeDetectorV function gets the current syringe pump + * syringe detect signal. + * @details \b Inputs: syringePumpMeasSyringeDetectionSwitch + * @details \b Outputs: none + * @return the current syringe pump syringe detect signal (in V). + *************************************************************************/ +static F32 getSyringePumpSyringeDetectorV( void ) +{ + return getF32OverrideValue( &syringePumpMeasSyringeDetectionSwitch ); +} + +/*********************************************************************//** + * @brief + * The getSyringePumpHomeDetectorV function gets the current syringe pump + * home detect signal. + * @details \b Inputs: syringePumpMeasHome + * @details \b Outputs: none + * @return the current syringe pump home detect signal (in V). + *************************************************************************/ +static F32 getSyringePumpHomeDetectorV( void ) +{ + return getF32OverrideValue( &syringePumpMeasHome ); +} + +/*********************************************************************//** + * @brief + * The getSyringePumpForceV function gets the current syringe pump force. + * @details \b Inputs: syringePumpMeasForce + * @details \b Outputs: none + * @return the current syringe pump force (in V). + *************************************************************************/ +static F32 getSyringePumpForceV( void ) +{ + return getF32OverrideValue( &syringePumpMeasForce ); +} + +/*********************************************************************//** + * @brief + * The getHeprinBolusTargetRate function gets the heprin bolus target + * flow rate. + * @details \b Inputs: getHeprinBolusTargetRate + * @details \b Outputs: getHeprinBolusTargetRate + * @return the current target heprin bolus flow rate (in mL/hour). + *************************************************************************/ +static F32 getHeprinBolusTargetRate( void ) +{ + return getF32OverrideValue( &heparinBolusTargetRate ); +} + + + +/*********************************************************************//** + * @brief + * The getSyringePumpStatus function gets the current syringe pump status. + * @details \b Inputs: syringePumpStatus + * @details \b Outputs: none + * @return the current syringe pump status. + *************************************************************************/ +static U08 getSyringePumpStatus() +{ + return getU08OverrideValue( &syringePumpStatus ); +} + +/*********************************************************************//** + * @brief + * The getSyringePumpEncoderStatus function gets the current syringe pump + * encoder status. + * @details \b Inputs: syringePumpEncoderStatus + * @details \b Outputs: none + * @return the current syringe pump encoder status. + *************************************************************************/ +static U08 getSyringePumpEncoderStatus() +{ + return getU08OverrideValue( &syringePumpEncoderStatus ); +} + +/*********************************************************************//** + * @brief + * The getSyringePumpADCReadCounter function gets the current syringe pump + * ADC read counter. + * @details \b Inputs: syringePumpADCReadCtr + * @details \b Outputs: none + * @return the current syringe pump ADC read counter. + *************************************************************************/ +static U08 getSyringePumpADCReadCounter() +{ + return getU08OverrideValue( &syringePumpADCReadCtr ); +} + +/*********************************************************************//** + * @brief + * The getSyringePumpADCandDACStatus function gets the current syringe pump + * ADC and DAC status reported by the FPGA. + * @details \b Inputs: syringePumpADCandDACStatus + * @details \b Outputs: none + * @return the current syringe pump ADC and DAC status. + *************************************************************************/ +static U08 getSyringePumpADCandDACStatus() +{ + return getU08OverrideValue( &syringePumpADCandDACStatus ); +} + +/*********************************************************************//** + * @brief * The checkDirection function checks the measured direction of the syringe * pump vs. the given expected direction. * @details \b Inputs: syringePumpMeasForce.data, syringePumpPosition.data @@ -1905,49 +1922,7 @@ return result; } -/*********************************************************************//** - * @brief - * The checkForPrimeOcclusion function checks the force sensor for excessive - * pressure. Would indicate occlusion or jam or empty syringe. - * @details \b Inputs: syringePumpMeasForce.data, syringePumpPosition.data - * @details \b Outputs: alarm triggered if max force detected - * @param stopPump flag passed in by caller indicating whether pump should be stopped - * @return TRUE if pump should be stopped, FALSE if not - *************************************************************************/ -BOOL checkForSyringeOcclusion( BOOL stopPump ) -{ - BOOL result = stopPump; - F32 currentForceV = getSyringePumpForceV(); // Read the force sensor at the end of the priming - F32 forceDelta = currentForceV - forceAtEndOfSeek; // Occlusion is detected if force at end of prime is > than force at end of seek by 0.5 volts or more - BOOL occlusionDetected = FALSE; - // Checking for occlusion in dry self tests without persistence - if ( MODE_PRET == getCurrentOperationMode() ) - { - occlusionDetected = ( forceDelta >= SYRINGE_FORCE_OCCLUSION_DIFF_V ? TRUE : FALSE ); - - if ( TRUE == occlusionDetected ) - { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION, forceAtEndOfSeek, currentForceV ) - result = TRUE; - } - else - { - clearAlarmCondition( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION ); - } - } - - // Check with persistence during continuous state - if ( SYRINGE_PUMP_OP_CONTINUOUS == syringePumpState ) - { - occlusionDetected = ( currentForceV >= SYRINGE_FORCE_OCCLUSION_THRESHOLD_V ? TRUE : FALSE ); - - checkPersistentAlarm( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION, occlusionDetected, forceAtEndOfSeek, currentForceV ); - } - - return result; -} - /*********************************************************************//** * @brief * The checkSyringeRemoved function checks whether the syringe has been removed. @@ -2105,6 +2080,39 @@ /*********************************************************************//** * @brief + * The resetSyringePumpRequestFlags function resets request flags. + * @details \b Inputs: none + * @details \b Out\b Outputs:quest flags reset + * @return TRUE if request accepted, FALSE if not + *************************************************************************/ +static void resetSyringePumpRequestFlags( void ) +{ + syringePumpRetractRequested = FALSE; + syringePumpSeekRequested = FALSE; + syringePumpPreloadRequested = FALSE; + syringePumpPrimeRequested = FALSE; + syringePumpBolusRequested = FALSE; + syringePumpContinuousRequested = FALSE; + syringePumpDACVrefSetRequested = FALSE; +} + +/*********************************************************************//** + * @brief + * The resetHeparinVolumeDelivered function resets the Heparin volume delivered. + * @details \b Inputs: none + * @details \b Outputs: syringePumpVolumeDelivered, syringePumpSafetyVolumeDelivered, + * syringePumpVolumeStartPosition + * @return none + *************************************************************************/ +static void resetHeparinVolumeDelivered( void ) +{ + syringePumpVolumeDelivered.data = 0.0; + syringePumpSafetyVolumeDelivered = 0.0; + syringePumpVolumeStartPosition = getSyringePumpPosition(); +} + +/*********************************************************************//** + * @brief * The rampSyringePump function handles the ramp-up for the syringe pump. * @details \b Inputs: syringePumpRampTimerCtr, syringePumpSetToggleTime * @details \b Outputs: syringePumpRampUpToggleTime @@ -2203,6 +2211,29 @@ /*********************************************************************//** * @brief + * The sendHeparinCommandResponse function constructs a Heparin command response + * to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Heparin command response msg constructed and queued. + * @param accepted flag indicating whether request was accepted + * @param rejReason rejection reason code + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ) +{ + BOOL result; + UI_RESPONSE_PAYLOAD_T payload; + + payload.accepted = accepted; + payload.rejectionReason = rejReason; + result = sendMessage( MSG_ID_TD_HEPARIN_PAUSE_RESUME_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&payload), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief * The publishSyringePumpData function publishes syringe pump data at the * set interval. * @details \b Inputs: latest syringe pump data, syringePumpDataPublicationTimerCounter @@ -2241,29 +2272,6 @@ } } -/*********************************************************************//** - * @brief - * The sendHeparinCommandResponse function constructs a Heparin command response - * to the UI and queues the msg for transmit on the - * appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Heparin command response msg constructed and queued. - * @param accepted flag indicating whether request was accepted - * @param rejReason rejection reason code - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ) -{ - BOOL result; - UI_RESPONSE_PAYLOAD_T payload; - - payload.accepted = accepted; - payload.rejectionReason = rejReason; - result = sendMessage( MSG_ID_TD_HEPARIN_PAUSE_RESUME_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&payload), sizeof( UI_RESPONSE_PAYLOAD_T ) ); - - return result; -} - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -2315,9 +2323,12 @@ result = startHeparinContinuous(); break; + case SYRINGE_PUMP_OP_PRELOAD: + result = preloadSyringePlunger(); + break; + default: - // Software Fault - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, op ); + // Ok, just ignore and we will return FALSE rejecting request break; } } @@ -2359,6 +2370,22 @@ /*********************************************************************//** * @brief + * The testHeprinBolusTargetRateOverride function overrides the + * heprine bolus target rate. + * @details \b Inputs: heprinBolusTargetRate + * @details \b Outputs: heprinBolusTargetRate + * @param: value : override heprinBolusTargetRate (in mL/hour) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testHeprinBolusTargetRateOverride( MESSAGE_T *message ) +{ + BOOL result = f32Override( message, &heparinBolusTargetRate ); + + return result; +} + +/*********************************************************************//** + * @brief * The testSyringePumpMeasuredForceOverride function overrides the measured * force analog signal of the syringe pump. * @details \b Inputs: none @@ -2441,22 +2468,6 @@ /*********************************************************************//** * @brief - * The testHeprinBolusTargetRateOverride function overrides the - * heprine bolus target rate. - * @details \b Inputs: heprinBolusTargetRate - * @details \b Outputs: heprinBolusTargetRate - * @param: value : override heprinBolusTargetRate (in mL/hour) - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testHeprinBolusTargetRateOverride( MESSAGE_T *message ) -{ - BOOL result = f32Override( message, &heparinBolusTargetRate ); - - return result; -} - -/*********************************************************************//** - * @brief * The testSyringePumpStatus function overrides the syringe pump * status. * @details \b Inputs: none