Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r88a641b7b0185e0bad77e21e6d438e1d7283fd28 -r5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 88a641b7b0185e0bad77e21e6d438e1d7283fd28) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7) @@ -102,7 +102,9 @@ /// Blood flow sensor signal strength low alarm persistence. #define FLOW_SIG_STRGTH_ALARM_PERSIST ( 5 * MS_PER_SECOND ) -#define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). +#define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). + +#define BFM_SENSOR_CONNECTED_STATUS 2 ///< Blood flow meter connected status. /// Enumeration of blood pump controller states. typedef enum BloodPump_States @@ -182,9 +184,6 @@ static U32 bpCurrErrorDurationCtr = 0; ///< Used for tracking persistence of bp current errors -static BLOOD_FLOW_SELF_TEST_STATE_T bloodPumpSelfTestState = BLOOD_FLOW_SELF_TEST_STATE_START; ///< Current blood pump self-test state -static U32 bloodPumpSelfTestTimerCount = 0; ///< Timer counter for blood pump self-test - // ********** private function prototypes ********** static BLOOD_PUMP_STATE_T handleBloodPumpOffState( void ); @@ -1261,28 +1260,12 @@ SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; CALIBRATION_DATA_T cal; - switch ( bloodPumpSelfTestState ) + // Retrieve blood flow sensor calibration data and check for sensor connected status + if ( ( TRUE == getCalibrationData( &cal ) ) && ( BFM_SENSOR_CONNECTED_STATUS == getFPGABloodFlowMeterStatus() ) ) { - case BLOOD_FLOW_SELF_TEST_STATE_START: - // Retrieve blood flow sensor calibration data - if ( TRUE == getCalibrationData( &cal ) ) - { - bloodFlowCalGain = cal.bloodFlowGain; - bloodFlowCalOffset = cal.bloodFlowOffset_mL_min; - bloodPumpSelfTestState = BLOOD_FLOW_TEST_STATE_COMPLETE; // TODO - implement rest of self-test(s) - result = SELF_TEST_STATUS_PASSED; - } - break; - - case BLOOD_FLOW_TEST_STATE_IN_PROGRESS: - break; - - case BLOOD_FLOW_TEST_STATE_COMPLETE: - break; - - default: - // TODO - s/w fault - break; + bloodFlowCalGain = cal.bloodFlowGain; + bloodFlowCalOffset = cal.bloodFlowOffset_mL_min; + result = SELF_TEST_STATUS_PASSED; } return result; Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r88a641b7b0185e0bad77e21e6d438e1d7283fd28 -r5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 88a641b7b0185e0bad77e21e6d438e1d7283fd28) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7) @@ -101,6 +101,8 @@ #define FLOW_SIG_STRGTH_ALARM_PERSIST ( 5 * MS_PER_SECOND ) #define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). +#define DFM_SENSOR_CONNECTED_STATUS 2 ///< Dialysate flow meter connected status. + /// Enumeration of dialysate inlet pump states. typedef enum DialInPump_States { @@ -176,9 +178,6 @@ static U32 dipCurrErrorDurationCtr = 0; ///< Used for tracking persistence of dip current errors -static DIAL_IN_FLOW_SELF_TEST_STATE_T dialInPumpSelfTestState = DIAL_IN_FLOW_SELF_TEST_STATE_START; ///< Current dialIn pump self-test state -static U32 dialInPumpSelfTestTimerCount = 0; ///< Timer counter for dialIn pump self-test - // ********** private function prototypes ********** static DIAL_IN_PUMP_STATE_T handleDialInPumpOffState( void ); @@ -1223,28 +1222,12 @@ SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; CALIBRATION_DATA_T cal; - switch ( dialInPumpSelfTestState ) + // Retrieve dialysate flow sensor calibration data + if ( ( TRUE == getCalibrationData( &cal ) ) && ( DFM_SENSOR_CONNECTED_STATUS == getFPGADialysateFlowMeterStatus() ) ) { - case DIAL_IN_FLOW_SELF_TEST_STATE_START: - // Retrieve blood flow sensor calibration data - if ( TRUE == getCalibrationData( &cal ) ) - { - dialInFlowCalGain = cal.dialysateFlowGain; - dialInFlowCalOffset = cal.dialysateFlowOffset_mL_min; - dialInPumpSelfTestState = DIAL_IN_FLOW_TEST_STATE_COMPLETE; // TODO - implement rest of self-test(s) - result = SELF_TEST_STATUS_PASSED; - } - break; - - case DIAL_IN_FLOW_TEST_STATE_IN_PROGRESS: - break; - - case DIAL_IN_FLOW_TEST_STATE_COMPLETE: - break; - - default: - // TODO - s/w fault - break; + dialInFlowCalGain = cal.dialysateFlowGain; + dialInFlowCalOffset = cal.dialysateFlowOffset_mL_min; + result = SELF_TEST_STATUS_PASSED; } return result; Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r8b7c7ff2bdb82aca355e3eed90cbdc6eb9507719 -r5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 8b7c7ff2bdb82aca355e3eed90cbdc6eb9507719) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7) @@ -55,6 +55,7 @@ #define OCCLUSION_THRESHOLD 25000 ///< Threshold above which an occlusion is detected. #define CARTRIDGE_LOADED_THRESHOLD 5000 ///< Threshold above which a cartridge is considered loaded. +#define MINIMUM_PRESSURE_LIMIT 2000 ///< Pressure reading minimum limit. #define PRES_ALARM_PERSISTENCE ( 1 * MS_PER_SECOND ) ///< Alarm persistence period for pressure alarms. @@ -568,9 +569,28 @@ *************************************************************************/ SELF_TEST_STATUS_T execPresOcclTest( void ) { - SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + + U32 const bpPressure = getMeasuredBloodPumpOcclusion(); + U32 const dialysateInPressure = getMeasuredDialInPumpOcclusion(); + U32 const dialysateOutPressure = getMeasuredDialOutPumpOcclusion(); + + if ( ( bpPressure <= MINIMUM_PRESSURE_LIMIT ) || ( bpPressure >= OCCLUSION_THRESHOLD ) ) + { + result = SELF_TEST_STATUS_FAILED; + } + + if ( ( dialysateInPressure <= MINIMUM_PRESSURE_LIMIT ) || ( bpPressure >= OCCLUSION_THRESHOLD ) ) + { + result = SELF_TEST_STATUS_FAILED; + } + + if ( ( dialysateOutPressure <= MINIMUM_PRESSURE_LIMIT ) || ( bpPressure >= OCCLUSION_THRESHOLD ) ) + { + result = SELF_TEST_STATUS_FAILED; + } - // TODO - implement self-test(s) + // TODO - implement arterial blood and venous pressure self-test(s) return result; } Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r911f6526ec3ba03ba0131681c7fb371c0abda6bb -r5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 911f6526ec3ba03ba0131681c7fb371c0abda6bb) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7) @@ -1141,6 +1141,30 @@ /*********************************************************************//** * @brief + * The getFPGABloodFlowMeterStatus function gets the blood flow meter status. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter status + *************************************************************************/ +U08 getFPGABloodFlowMeterStatus( void ) +{ + return fpgaSensorReadings.bloodFlowMeterDeviceStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGADialysateFlowMeterStatus function gets the dialysate flow meter status. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current dialysate flow meter status + *************************************************************************/ +U08 getFPGADialysateFlowMeterStatus( void ) +{ + return fpgaSensorReadings.dialysateFlowMeterDeviceStatus; +} + +/*********************************************************************//** + * @brief * The getFPGABloodPumpHallSensorCount function gets the latest blood pump * hall sensor count. Count is a 16 bit free running counter. If counter is * counting up, indicates motor is running in forward direction. If counter is Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rc672f41061bcd500d6593655641cb27ce3ae58fc -r5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision c672f41061bcd500d6593655641cb27ce3ae58fc) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 5dc6f629ae40d8939fd3bd7c4e3dffb04fa137e7) @@ -53,6 +53,9 @@ F32 getFPGABloodFlow( void ); F32 getFPGADialysateFlow( void ); +U08 getFPGABloodFlowMeterStatus( void ); +U08 getFPGADialysateFlowMeterStatus( void ); + U16 getFPGABloodPumpHallSensorCount( void ); U08 getFPGABloodPumpHallSensorStatus( void ); U16 getFPGADialInPumpHallSensorCount( void );