Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r46617afb446c35270b59e21085b270433d13d113 -r8cebc7f282f403c99f712d422454c15414b6fc73 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 46617afb446c35270b59e21085b270433d13d113) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 8cebc7f282f403c99f712d422454c15414b6fc73) @@ -69,12 +69,7 @@ #define BP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< Maximum motor speed (RPM) while motor is commanded off. #define BP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< Maximum difference in speed between motor and rotor (in rotor RPM). #define BP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. -#ifdef USE_FMB_FLOW_SENSOR -#define BP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< Maximum difference between measured speed and speed implied by measured flow. -/// Persist time (task intervals) for flow vs. motor speed error condition. -static const U32 BP_FLOW_VS_SPEED_PERSIST = ( 5 * MS_PER_SECOND ); -#endif /// Persist time (task intervals) for motor off error condition. static const U32 BP_OFF_ERROR_PERSIST = ( 5 * MS_PER_SECOND ); /// Persist time (task intervals) motor speed error condition. @@ -111,36 +106,15 @@ /// Macro converts 12 bit ADC value to signed 16-bit value. #define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)BLOODPUMP_ADC_ZERO ) -#ifndef USE_FMB_FLOW_SENSOR /// Measured blood flow is filtered w/ moving average. #define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 1 ) -#else -/// Measured blood flow is filtered w/ moving average. -#define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 10 ) -/// Blood flow sensor signal strength low alarm persistence. -#define FLOW_SIG_STRGTH_ALARM_PERSIST ( BP_CONTROL_INTERVAL_SEC * MS_PER_SECOND ) -#define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). - -/// Blood flow fast read timeout alarm persistence. -#define BLOOD_FLOW_FAST_READ_TO_PERSIST 100 -/// Blood flow slow read timeout alarm persistence. -#define BLOOD_FLOW_SLOW_READ_TO_PERSIST ( MS_PER_SECOND * 3 ) -/// Blood flow comm error persistence. -#define BLOOD_FLOW_COMM_ERROR_PERSIST MS_PER_SECOND - -#define BFM_SENSOR_CONNECTED_STATUS 0x00 ///< Blood flow meter connected status. -#define BFM_SENSOR_PARAM_CORRUPT_STATUS 0x07 ///< Blood flow meter NVM parameter status. -#endif - #define PUMP_DIR_ERROR_COUNT_MASK 0x3F ///< Bit mask for pump direction error counter. -#ifndef USE_FMB_FLOW_SENSOR #define BP_FLOW_ALPHA_Y_INTERCEPT 1.218 ///< Y intercept used for alpha flow coefficient calculation. #define BP_FLOW_WEAR_A_TERM 0.000000007474 ///< A term used for wear portion of alpha flow coefficient. #define BP_FLOW_WEAR_B_TERM 0.0006053 ///< B term used for wear portion of alpha flow coefficient. #define BP_MAX_ROTOR_COUNT_FOR_WEAR 25000 ///< Maximum rotor count for determining wear of the cartridge (negligible affect beyond this threshold). -#endif /// Enumeration of blood pump controller states. typedef enum BloodPump_States @@ -191,35 +165,18 @@ static OVERRIDE_F32_T adcBloodPumpMCSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured blood pump motor controller speed. static OVERRIDE_F32_T adcBloodPumpMCCurrentmA = { 0.0, 0.0, 0.0, 0 }; ///< Measured blood pump motor controller current. -#ifdef USE_FMB_FLOW_SENSOR -static OVERRIDE_F32_T bloodFlowSignalStrength = { 0.0, 0.0, 0.0, 0 }; ///< Measured blood flow signal strength (%). - -static U08 lastBloodFlowFastPacketReadCtr = 0; ///< Previous read counter for the blood flow fast packets. -static U08 lastBloodFlowSlowPacketReadCtr = 0; ///< Previous read counter for the blood flow slow packets. -#ifndef DISABLE_PUMP_FLOW_CHECKS -static U08 lastBloodFlowCommErrorCount = 0; ///< Previous BP flow sensor comm error count. -#endif -static HD_FLOW_SENSORS_CAL_RECORD_T bloodFlowCalRecord; ///< Blood flow sensor calibration record. -#endif - static U08 lastBloodPumpDirectionCount = 0; ///< Previous pump direction error count reported by FPGA. -#ifndef USE_FMB_FLOW_SENSOR static F32 rpmReadings[ SIZE_OF_ROLLING_AVG ]; ///< Holds RPM samples for a rolling average. static U32 rpmReadingsIdx = 0; ///< Index for next sample in rolling average array. static F32 rpmReadingsTotal = 0.0; ///< Rolling total - used to calc average. static U32 rpmReadingsCount = 0; ///< Number of samples in RPM rolling average buffer. static F32 filteredBloodPumpSpeed = 0.0; ///< Filtered blood pump speed used in blood flow estimation. -#else -static F32 flowReadings[ SIZE_OF_ROLLING_AVG ]; ///< Holds flow samples for a rolling average. -static U32 flowReadingsIdx = 0; ///< Index for next sample in rolling average array. -static F32 flowReadingsTotal = 0.0; ///< Rolling total - used to calc average. -static U32 flowReadingsCount = 0; ///< Number of samples in flow rolling average buffer. -#endif + static U32 bpControlTimerCounter = 0; ///< Determines when to perform control on blood flow static U32 bpRotorRevStartTime = 0; ///< Blood pump rotor rotation start time (in ms) -static U32 bloodPumpRotorCounter = 0; ///< Running counter for blood pump rotor revolutions +static OVERRIDE_U32_T bloodPumpRotorCounter = { 0, 0, 0, 0 }; ///< Running counter for blood pump rotor revolutions static BOOL bpStopAtHomePosition = FALSE; ///< Stop blood pump at next home position static U32 bpHomeStartTime = 0; ///< When did blood pump home command begin? (in ms) @@ -246,16 +203,9 @@ static void checkBloodPumpMCCurrent( void ); static void checkBloodPumpFlowRate( void ); -#ifdef USE_FMB_FLOW_SENSOR -static void resetBloodFlowMovingAverage( void ); -static void filterBloodFlowReadings( F32 flow ); -static void checkBloodFlowSensorSignalStrength( void ); -static BOOL processCalibrationData( void ); -#else static F32 calcBloodFlow( void ); static void resetBloodPumpRPMMovingAverage( void ); static void filterBloodPumpRPMReadings( F32 rpm ); -#endif /*********************************************************************//** * @brief @@ -271,13 +221,8 @@ stopBloodPump(); setBloodPumpDirection( MOTOR_DIR_FORWARD ); -#ifndef USE_FMB_FLOW_SENSOR // Zero rolling pump speed average buffer resetBloodPumpRPMMovingAverage(); -#else - // Zero rolling flow average buffer - resetBloodFlowMovingAverage(); -#endif // Zero motor hall sensors counts buffer bpMotorSpeedCalcIdx = 0; @@ -299,13 +244,6 @@ initPersistentAlarm( ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK, 0, BP_DIRECTION_ERROR_PERSIST ); initPersistentAlarm( ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_TOO_HIGH, 0, BP_MAX_ROTOR_SPEED_ERROR_PERSIST ); initPersistentAlarm( ALARM_ID_BLOOD_PUMP_MC_CURRENT_CHECK, 0, BP_MAX_CURR_ERROR_DURATION_MS ); -#ifdef USE_FMB_FLOW_SENSOR - initPersistentAlarm( ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, 0, BP_FLOW_VS_SPEED_PERSIST ); - initPersistentAlarm( ALARM_ID_BLOOD_FLOW_SIGNAL_STRENGTH_TOO_LOW, FLOW_SIG_STRGTH_ALARM_PERSIST, FLOW_SIG_STRGTH_ALARM_PERSIST ); - initPersistentAlarm( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, 0, BLOOD_FLOW_FAST_READ_TO_PERSIST ); - initPersistentAlarm( ALARM_ID_HD_BP_FLOW_SLOW_READ_TIMEOUT_ERROR, 0, BLOOD_FLOW_SLOW_READ_TO_PERSIST ); - initPersistentAlarm( ALARM_ID_HD_BP_FLOW_SENSOR_ERROR, 0, BLOOD_FLOW_COMM_ERROR_PERSIST ); -#endif initPersistentAlarm( ALARM_ID_HD_BLOOD_FLOW_OUT_OF_RANGE, 0, BP_MAX_FLOW_RATE_OUT_OF_RANGE_PERSIST ); } @@ -332,11 +270,7 @@ if ( flowRate <= MAX_SET_BLOOD_FLOW_RATE ) #endif { -#ifndef USE_FMB_FLOW_SENSOR resetBloodPumpRPMMovingAverage(); -#else - resetBloodFlowMovingAverage(); -#endif targetBloodFlowRate = ( dir == MOTOR_DIR_FORWARD ? (S32)flowRate : (S32)flowRate * -1 ); bloodPumpDirection = dir; bloodPumpControlMode = mode; @@ -387,7 +321,6 @@ return result; } -#ifndef USE_FMB_FLOW_SENSOR /*********************************************************************//** * @brief * The calcBloodFlow function calculates an estimated blood flow rate from @@ -402,7 +335,8 @@ F32 artPres = getLongFilteredArterialPressure(); F32 rotSpd = filteredBloodPumpSpeed / BP_GEAR_RATIO; #ifndef WORN_OUT_CARTRIDGE - U32 rotCnt = CAP( bloodPumpRotorCounter, BP_MAX_ROTOR_COUNT_FOR_WEAR ); + U32 r = getBloodPumpRotorCount(); + U32 rotCnt = CAP( r, BP_MAX_ROTOR_COUNT_FOR_WEAR ); #else U32 rotCnt = BP_MAX_ROTOR_COUNT_FOR_WEAR; #endif @@ -412,7 +346,6 @@ return flow; } -#endif /*********************************************************************//** * @brief @@ -446,7 +379,7 @@ U32 deltaTime = calcTimeBetween( bpRotorRevStartTime, rotTime ); // Increment rotor counter - bloodPumpRotorCounter++; + bloodPumpRotorCounter.data++; // Calculate rotor speed (in RPM) bloodPumpRotorSpeedRPM.data = ( 1.0 / (F32)deltaTime ) * (F32)MS_PER_SECOND * (F32)SEC_PER_MIN; @@ -504,7 +437,14 @@ *************************************************************************/ U32 getBloodPumpRotorCount( void ) { - return bloodPumpRotorCounter; + U32 result = bloodPumpRotorCounter.data; + + if ( OVERRIDE_KEY == bloodPumpRotorCounter.override ) + { + result = bloodPumpRotorCounter.ovData; + } + + return result; } /*********************************************************************//** @@ -531,7 +471,7 @@ *************************************************************************/ void resetBloodPumpRotorCount( void ) { - bloodPumpRotorCounter = 0; + bloodPumpRotorCounter.data = 0; } /*********************************************************************//** @@ -551,59 +491,12 @@ U08 spReadCtr = getFPGABloodFlowSlowPacketReadCounter(); U08 flowErrorCtr = getFPGABloodFlowErrorCounter(); U08 flowStatus = getFPGABloodFlowMeterStatus(); -#ifdef USE_FMB_FLOW_SENSOR - F32 bpFlow; - F32 fpgaBloodFlow = getFPGABloodFlow(); - // Check if a new calibration is available - if ( TRUE == isNewCalibrationRecordAvailable() ) - { - // Get the new calibration data and check its validity - processCalibrationData(); - } -#ifndef DISABLE_PUMP_FLOW_CHECKS - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_FLOW_SENSOR_ERROR, ( flowErrorCtr != lastBloodFlowCommErrorCount ) ) ) - { - activateAlarmNoData( ALARM_ID_HD_BP_FLOW_SENSOR_ERROR ); - } - if ( flowStatus != BFM_SENSOR_CONNECTED_STATUS ) - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BLOOD_FLOW_STATUS_SELF_TEST_FAILURE, (U32)flowStatus ); - } - lastBloodFlowCommErrorCount = flowErrorCtr; -#endif -#ifndef DISABLE_FPGA_COUNTER_CHECKS - // Check for stale flow reading - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, ( fpReadCtr == lastBloodFlowFastPacketReadCtr ) ) ) - { - activateAlarmNoData( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR ); - } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_FLOW_SLOW_READ_TIMEOUT_ERROR, ( spReadCtr == lastBloodFlowSlowPacketReadCtr ) ) ) - { - activateAlarmNoData( ALARM_ID_HD_BP_FLOW_SLOW_READ_TIMEOUT_ERROR ); - } -#endif - - // Record flow read counters for next time around - lastBloodFlowFastPacketReadCtr = fpReadCtr; - lastBloodFlowSlowPacketReadCtr = spReadCtr; -#endif - adcBloodPumpMCSpeedRPM.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpRPM)) * BP_SPEED_ADC_TO_RPM_FACTOR; adcBloodPumpMCCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpmA)) * BP_CURRENT_ADC_TO_MA_FACTOR; -#ifndef USE_FMB_FLOW_SENSOR filterBloodPumpRPMReadings( getMeasuredBloodPumpMCSpeed() ); measuredBloodFlowRate.data = calcBloodFlow(); // Pressure and rotor speed already filtered as inputs to calc, so no need to filter flow any further -#else - bloodFlowSignalStrength.data = getFPGABloodFlowSignalStrength(); - bpFlow = pow(fpgaBloodFlow, 4) * bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].fourthOrderCoeff + - pow(fpgaBloodFlow, 3) * bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].thirdOrderCoeff + - pow(fpgaBloodFlow, 2) * bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].secondOrderCoeff + - fpgaBloodFlow * bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].gain + - bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].offset; - filterBloodFlowReadings( bpFlow ); -#endif // Calculate blood pump motor speed/direction from hall sensor count updateBloodPumpSpeedAndDirectionFromHallSensors(); @@ -620,10 +513,6 @@ checkBloodPumpFlowRate(); // Check for home position, zero/low speed checkBloodPumpRotor(); -#ifdef USE_FMB_FLOW_SENSOR - // Check flow sensor signal strength - checkBloodFlowSensorSignalStrength(); -#endif } // Publish blood flow data on interval @@ -714,11 +603,7 @@ // Have we reached end of ramp up? else if ( bloodPumpPWMDutyCyclePctSet >= bloodPumpPWMDutyCyclePct ) { -#ifndef USE_FMB_FLOW_SENSOR resetBloodPumpRPMMovingAverage(); -#else - resetBloodFlowMovingAverage(); -#endif bloodPumpPWMDutyCyclePctSet = bloodPumpPWMDutyCyclePct; resetPIController( PI_CONTROLLER_ID_BLOOD_FLOW, bloodPumpPWMDutyCyclePctSet ); bloodPumpControlModeSet = bloodPumpControlMode; @@ -757,11 +642,7 @@ // Have we reached end of ramp down? else if ( bloodPumpPWMDutyCyclePctSet <= bloodPumpPWMDutyCyclePct ) { -#ifndef USE_FMB_FLOW_SENSOR resetBloodPumpRPMMovingAverage(); -#else - resetBloodFlowMovingAverage(); -#endif bloodPumpPWMDutyCyclePctSet = bloodPumpPWMDutyCyclePct; resetPIController( PI_CONTROLLER_ID_BLOOD_FLOW, bloodPumpPWMDutyCyclePctSet ); bloodPumpControlModeSet = bloodPumpControlMode; @@ -900,28 +781,6 @@ return result; } -#ifdef USE_FMB_FLOW_SENSOR -/*********************************************************************//** - * @brief - * The getMeasuredBloodFlowSignalStrength function gets the measured blood flow - * signal strength. - * @details Inputs: bloodFlowSignalStrength - * @details Outputs: none - * @return the current blood flow signal strength (in %). - *************************************************************************/ -F32 getMeasuredBloodFlowSignalStrength( void ) -{ - F32 result = bloodFlowSignalStrength.data; - - if ( OVERRIDE_KEY == bloodFlowSignalStrength.override ) - { - result = bloodFlowSignalStrength.ovData; - } - - return result; -} -#endif - /*********************************************************************//** * @brief * The getMeasuredBloodPumpRotorSpeed function gets the measured blood flow @@ -1025,17 +884,12 @@ payload.measMCSpd = getMeasuredBloodPumpMCSpeed(); payload.measMCCurr = getMeasuredBloodPumpMCCurrent(); payload.pwmDC = bloodPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; -#ifdef USE_FMB_FLOW_SENSOR - payload.flowSigStrength = getMeasuredBloodFlowSignalStrength() * FRACTION_TO_PERCENT_FACTOR; -#else - payload.flowSigStrength = 0.0; -#endif + payload.rotorCount = getBloodPumpRotorCount(); broadcastData( MSG_ID_BLOOD_FLOW_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&payload, sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ) ); bloodFlowDataPublicationTimerCounter = 0; } } -#ifndef USE_FMB_FLOW_SENSOR /*********************************************************************//** * @brief * The resetBloodPumpRPMMovingAverage function re-initializes the pump speed @@ -1073,47 +927,9 @@ rpmReadingsCount = INC_CAP( rpmReadingsCount, SIZE_OF_ROLLING_AVG ); filteredBloodPumpSpeed = rpmReadingsTotal / (F32)rpmReadingsCount; } -#else + /*********************************************************************//** * @brief - * The resetBloodFlowMovingAverage function re-initializes the blood flow - * moving average sample buffer. - * @details Inputs: none - * @details Outputs: flowReadingsTotal, flowReadingsIdx, flowReadingsCount all set to zero. - * @return none - *************************************************************************/ -static void resetBloodFlowMovingAverage( void ) -{ - flowReadingsIdx = 0; - flowReadingsCount = 0; - flowReadingsTotal = 0.0; - bpControlTimerCounter = 0; -} - -/*********************************************************************//** - * @brief - * The filterBloodFlowReadings function adds a new flow sample to the filter. - * @details Inputs: none - * @details Outputs: flowReadings[], flowReadingsIdx, flowReadingsCount, flowReadingsTotal - * @param flow newest blood flow sample - * @return none - *************************************************************************/ -static void filterBloodFlowReadings( F32 flow ) -{ - if ( flowReadingsCount >= SIZE_OF_ROLLING_AVG ) - { - flowReadingsTotal -= flowReadings[ flowReadingsIdx ]; - } - flowReadings[ flowReadingsIdx ] = flow; - flowReadingsTotal += flow; - flowReadingsIdx = INC_WRAP( flowReadingsIdx, 0, SIZE_OF_ROLLING_AVG - 1 ); - flowReadingsCount = INC_CAP( flowReadingsCount, SIZE_OF_ROLLING_AVG ); - measuredBloodFlowRate.data = flowReadingsTotal / (F32)flowReadingsCount; -} -#endif - -/*********************************************************************//** - * @brief * The updateBloodPumpSpeedAndDirectionFromHallSensors function calculates * the blood pump motor speed and direction from hall sensor counter on * a 1 second interval. @@ -1341,103 +1157,7 @@ SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_BLOOD_FLOW_OUT_OF_RANGE, flow ); } #endif - -#ifdef USE_FMB_FLOW_SENSOR - // Flow vs. speed check only performed while in treatment mode and while we are in control to target state - if ( ( MODE_TREA == getCurrentOperationMode() ) && ( BLOOD_PUMP_CONTROL_TO_TARGET_STATE == bloodPumpState ) ) - { - F32 speed = getMeasuredBloodPumpSpeed(); - F32 impliedSpeed = ( flow / (F32)ML_PER_LITER ) * BP_REV_PER_LITER * BP_GEAR_RATIO; - F32 delta = fabs( speed - impliedSpeed ); - - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, delta > BP_MAX_FLOW_VS_SPEED_DIFF_RPM ) ) - { -#ifndef DISABLE_PUMP_SPEED_CHECKS - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, flow, speed ); -#endif - } - } - else - { - resetPersistentAlarmTimer( ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK ); - } -#endif } - -#ifdef USE_FMB_FLOW_SENSOR -/*********************************************************************//** - * @brief - * The checkBloodFlowSensorSignalStrength function checks the measured blood - * flow sensor signal strength is sufficient for accurate flow sensing. - * @details Inputs: - * @details Outputs: - * @return none - *************************************************************************/ -static void checkBloodFlowSensorSignalStrength( void ) -{ -#ifndef DISABLE_PUMP_FLOW_CHECKS - HD_OP_MODE_T opMode = getCurrentOperationMode(); - - // Check flow sensor signal strength when appropriate TODO - in pre-treatment, must be far enough along for fluid to be in tubing - if ( MODE_TREA == opMode || ( MODE_PRET == opMode && FALSE ) ) - { - F32 sigStrength = getMeasuredBloodFlowSignalStrength(); - BOOL outOfRange = ( sigStrength < MIN_FLOW_SIG_STRENGTH ? TRUE : FALSE ); - - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_BLOOD_FLOW_SIGNAL_STRENGTH_TOO_LOW, outOfRange ) ) - { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_BLOOD_FLOW_SIGNAL_STRENGTH_TOO_LOW, sigStrength, MIN_FLOW_SIG_STRENGTH ); - } - } -#endif -} - -/*********************************************************************//** - * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: bloodFlowCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - - // Get the calibration record from NVDataMgmt - HD_FLOW_SENSORS_CAL_RECORD_T calData = getHDFlowSensorsCalibrationRecord(); - - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the blood flow sensors data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].calibrationTime ) - { -#ifndef SKIP_CAL_CHECK - activateAlarmNoData( ALARM_ID_HD_BLOOD_FLOW_INVALID_CAL_RECORD ); - status = FALSE; -#endif - } - - // The calibration data was valid, update the local copy - bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].fourthOrderCoeff = - calData.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].fourthOrderCoeff; - - bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].thirdOrderCoeff = - calData.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].thirdOrderCoeff; - - bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].secondOrderCoeff = - calData.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].secondOrderCoeff; - - bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].gain = - calData.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].gain; - - bloodFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].offset = - calData.hdFlowSensors[ CAL_DATA_HD_BLOOD_FLOW_SENSOR ].offset; - - return status; -} -#endif /*********************************************************************//** * @brief @@ -1449,31 +1169,9 @@ *************************************************************************/ SELF_TEST_STATUS_T execBloodFlowTest( void ) { -#ifdef USE_FMB_FLOW_SENSOR - SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - U08 const bfmStatus = getFPGABloodFlowMeterStatus(); - - // Retrieve blood flow sensor calibration data and check for sensor connected status - if ( BFM_SENSOR_PARAM_CORRUPT_STATUS != bfmStatus ) - { - BOOL calStatus = processCalibrationData(); - - if ( TRUE == calStatus ) - { - result = SELF_TEST_STATUS_PASSED; - } - else - { - result = SELF_TEST_STATUS_FAILED; - } - } - else - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BLOOD_FLOW_STATUS_SELF_TEST_FAILURE, (U32)bfmStatus ); - } -#else SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; -#endif + + // TODO - anything to test here? return result; } @@ -1792,51 +1490,49 @@ return result; } -#ifdef USE_FMB_FLOW_SENSOR /*********************************************************************//** * @brief - * The testSetMeasuredBloodFlowSignalStrengthOverride function overrides the measured - * blood flow signal strength. + * The testSetBloodPumpRotorCountOverride function overrides the blood pump + * rotor counter value. * @details Inputs: none - * @details Outputs: bloodFlowSignalStrength - * @param value override measured blood flow signal strength (in %) + * @details Outputs: bloodPumpRotorCounter + * @param value override blood pump rotor counter value * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetMeasuredBloodFlowSignalStrengthOverride( F32 value ) +BOOL testSetBloodPumpRotorCountOverride( U32 value ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { result = TRUE; - bloodFlowSignalStrength.ovData = value / 100.0; - bloodFlowSignalStrength.override = OVERRIDE_KEY; + bloodPumpRotorCounter.ovData = value; + bloodPumpRotorCounter.override = OVERRIDE_KEY; } return result; } /*********************************************************************//** * @brief - * The testResetMeasuredBloodFlowSignalStrengthOverride function resets the override - * of the measured blood flow signal strength. + * The testResetBloodPumpRotorCountOverride function resets the override + * of the blood pump rotor counter. * @details Inputs: none - * @details Outputs: bloodFlowSignalStrength + * @details Outputs: bloodPumpRotorCounter * @return TRUE if reset successful, FALSE if not *************************************************************************/ -BOOL testResetMeasuredBloodFlowSignalStrengthOverride( void ) +BOOL testResetBloodPumpRotorCountOverride( void ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { result = TRUE; - bloodFlowSignalStrength.override = OVERRIDE_RESET; - bloodFlowSignalStrength.ovData = bloodFlowSignalStrength.ovInitData; + bloodPumpRotorCounter.override = OVERRIDE_RESET; + bloodPumpRotorCounter.ovData = bloodPumpRotorCounter.ovInitData; } return result; } -#endif /**@}*/