Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -re5006f5263e8540e730dd802016fef5973ecea4c -rd37f31cff6c20085953ecb598558e4d91e42f0af --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision e5006f5263e8540e730dd802016fef5973ecea4c) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision d37f31cff6c20085953ecb598558e4d91e42f0af) @@ -91,7 +91,6 @@ /// Expected position of empty in relation to home position. #define SYRINGE_PUMP_EMPTY_POS ( SYRINGE_ENCODER_COUNTS_PER_ML * 10.84 ) ///< get syringe volume from home to empty (11 mL is placeholder) - /// Margin of error for empty position determination. #define SYRINGE_PUMP_EMPTY_POS_MARGIN ( SYRINGE_ENCODER_COUNTS_PER_ML * 0.5 ) /// Minimum retract position. @@ -183,6 +182,8 @@ 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 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. static OVERRIDE_U32_T syringePumpEncoderStatus = {0, 0, 0, 0}; ///< Syringe pump encoder status reported by FPGA. static OVERRIDE_U32_T syringePumpADCandDACStatus = {0, 0, 0, 0}; ///< Syringe pump ADC and DAC status reported by FPGA. @@ -232,10 +233,12 @@ static F32 getSyringePumpSyringeDetectorV( void ); static F32 getSyringePumpHomeDetectorV( void ); static F32 getSyringePumpForceV( void ); +static F32 getHeprinBolusTargetRate( void ); static U08 getSyringePumpStatus( void ); static U08 getSyringePumpEncoderStatus( void ); 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 ); @@ -556,23 +559,21 @@ *************************************************************************/ BOOL startHeparinBolus( void ) { - F32 tgtRate = HEPARIN_BOLUS_TARGET_RATE; // fixed rate - // If valid to start a bolus, kick it off if ( FALSE == isSyringePumpHome() ) { if ( ( TRUE == isSyringeDetected() ) && ( TRUE == syringePumpPrimeCompleted ) && ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) && ( HEPARIN_STATE_STOPPED == heparinDeliveryState ) ) { - syringePumpSetRate = tgtRate; + syringePumpSetRate = getHeprinBolusTargetRate(); syringePumpBolusRequested = TRUE; } } else { if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_HD_SYRINGE_INVALID_BOLUS_CMD, tgtRate ) + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_HD_SYRINGE_INVALID_BOLUS_CMD, syringePumpSetRate ) } } @@ -646,14 +647,7 @@ *************************************************************************/ F32 getSyringePumpVolumeDelivered( void ) { - F32 result = syringePumpVolumeDelivered.data; - - if ( OVERRIDE_KEY == syringePumpVolumeDelivered.override ) - { - result = syringePumpVolumeDelivered.ovData; - } - - return result; + return getF32OverrideValue( &syringePumpVolumeDelivered ); } /*********************************************************************//** @@ -666,38 +660,11 @@ *************************************************************************/ static F32 getSyringePumpMeasRate( void ) { - F32 result = syringePumpMeasRate.data; - - if ( OVERRIDE_KEY == syringePumpMeasRate.override ) - { - result = syringePumpMeasRate.ovData; - } - - return result; + return getF32OverrideValue( &syringePumpMeasRate ); } /*********************************************************************//** * @brief - * The getSyringePumpPosition function gets the current syringe pump - * position. - * @details Inputs: syringePumpPosition - * @details Outputs: none - * @return the current syringe pump syringe position (in steps). - *************************************************************************/ -static S32 getSyringePumpPosition( void ) -{ - S32 result = syringePumpPosition.data; - - if ( OVERRIDE_KEY == syringePumpPosition.override ) - { - result = syringePumpPosition.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getSyringePumpSyringeDetectorV function gets the current syringe pump * syringe detect signal. * @details Inputs: syringePumpMeasSyringeDetectionSwitch @@ -706,14 +673,7 @@ *************************************************************************/ static F32 getSyringePumpSyringeDetectorV( void ) { - F32 result = syringePumpMeasSyringeDetectionSwitch.data; - - if ( OVERRIDE_KEY == syringePumpMeasSyringeDetectionSwitch.override ) - { - result = syringePumpMeasSyringeDetectionSwitch.ovData; - } - - return result; + return getF32OverrideValue( &syringePumpMeasSyringeDetectionSwitch ); } /*********************************************************************//** @@ -726,14 +686,7 @@ *************************************************************************/ static F32 getSyringePumpHomeDetectorV( void ) { - F32 result = syringePumpMeasHome.data; - - if ( OVERRIDE_KEY == syringePumpMeasHome.override ) - { - result = syringePumpMeasHome.ovData; - } - - return result; + return getF32OverrideValue( &syringePumpMeasHome ); } /*********************************************************************//** @@ -745,14 +698,33 @@ *************************************************************************/ static F32 getSyringePumpForceV( void ) { - F32 result = syringePumpMeasForce.data; + return getF32OverrideValue( &syringePumpMeasForce ); +} - if ( OVERRIDE_KEY == syringePumpMeasForce.override ) - { - result = syringePumpMeasForce.ovData; - } +/*********************************************************************//** + * @brief + * The getHeprinBolusTargetRate function gets the heprin bolus target + * flow rate. + * @details Inputs: getHeprinBolusTargetRate + * @details Outputs: getHeprinBolusTargetRate + * @return the current target heprin bolus flow rate (in mL/hour). + *************************************************************************/ +static F32 getHeprinBolusTargetRate( void ) +{ + return getF32OverrideValue( &heparinBolusTargetRate ); +} - return result; +/*********************************************************************//** + * @brief + * The getSyringePumpPosition function gets the current syringe pump + * position. + * @details Inputs: syringePumpPosition + * @details Outputs: none + * @return the current syringe pump syringe position (in steps). + *************************************************************************/ +static S32 getSyringePumpPosition( void ) +{ + return getS32OverrideValue( &syringePumpPosition ); } /*********************************************************************//** @@ -764,14 +736,7 @@ *************************************************************************/ static U08 getSyringePumpStatus() { - U08 result = (U08)(syringePumpStatus.data & MASK_OFF_U32_MSBS); - - if ( OVERRIDE_KEY == syringePumpStatus.override ) - { - result = (U08)(syringePumpStatus.ovData & MASK_OFF_U32_MSBS); - } - - return result; + return getU08OverrideValue( &syringePumpStatus ); } /*********************************************************************//** @@ -784,14 +749,7 @@ *************************************************************************/ static U08 getSyringePumpEncoderStatus() { - U08 result = (U08)(syringePumpEncoderStatus.data & MASK_OFF_U32_MSBS); - - if ( OVERRIDE_KEY == syringePumpEncoderStatus.override ) - { - result = (U08)(syringePumpEncoderStatus.ovData & MASK_OFF_U32_MSBS); - } - - return result; + return getU08OverrideValue( &syringePumpEncoderStatus ); } /*********************************************************************//** @@ -804,14 +762,7 @@ *************************************************************************/ static U08 getSyringePumpADCReadCounter() { - U08 result = (U08)(syringePumpADCReadCtr.data & MASK_OFF_U32_MSBS); - - if ( OVERRIDE_KEY == syringePumpADCReadCtr.override ) - { - result = (U08)(syringePumpADCReadCtr.ovData & MASK_OFF_U32_MSBS); - } - - return result; + return getU08OverrideValue( &syringePumpADCReadCtr ); } /*********************************************************************//** @@ -824,14 +775,7 @@ *************************************************************************/ static U08 getSyringePumpADCandDACStatus() { - U08 result = (U08)(syringePumpADCandDACStatus.data & MASK_OFF_U32_MSBS); - - if ( OVERRIDE_KEY == syringePumpADCandDACStatus.override ) - { - result = (U08)(syringePumpADCandDACStatus.ovData & MASK_OFF_U32_MSBS); - } - - return result; + return getU08OverrideValue( &syringePumpADCandDACStatus ); } /*********************************************************************//** @@ -1011,8 +955,7 @@ // Check if syringe pump is on while BP is off { - BOOL runWhileOff = ( ( ( SYRINGE_PUMP_HEP_BOLUS_STATE == syringePumpState ) || ( SYRINGE_PUMP_HEP_CONTINUOUS_STATE == syringePumpState ) ) && - ( isBloodPumpRunning() != TRUE ) ); + BOOL runWhileOff = ( ( SYRINGE_PUMP_HEP_CONTINUOUS_STATE == syringePumpState ) && ( isBloodPumpRunning() != TRUE ) ); if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR, runWhileOff ) ) { @@ -2288,6 +2231,54 @@ /*********************************************************************//** * @brief + * The testSetHeprinBolusTargetRateOverride function overrides the + * heprine bolus target rate. + * @details Inputs: heprinBolusTargetRate + * @details Outputs: heprinBolusTargetRate + * @param: value : override heprinBolusTargetRate (in mL/hour) + * @param: value : override heprinBolusTargetRate (in mL/hour) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetHeprinBolusTargetRateOverride( F32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + heparinBolusTargetRate.ovInitData = heparinBolusTargetRate.data; + heparinBolusTargetRate.ovData = value; + heparinBolusTargetRate.override = OVERRIDE_KEY; + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetHeprinBolusTargetRateOverride function resets the override + * of the heprin bolus target rate. + * @details Inputs: heprinBolusTargetRate + * @details Outputs: heprinBolusTargetRate + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testResetHeprinBolusTargetRateOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + heparinBolusTargetRate.override = OVERRIDE_RESET; + heparinBolusTargetRate.ovData = heparinBolusTargetRate.ovInitData; + heparinBolusTargetRate.ovInitData = 0.0; + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetSyringePumpStatus function overrides the syringe pump * status. * @details Inputs: none