Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -ra3a01327c8fe80f65f6658ae6cbef4910a4a8033 -r8e7158d8231435496fcf1d5649e51babf859ccc7 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision a3a01327c8fe80f65f6658ae6cbef4910a4a8033) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 8e7158d8231435496fcf1d5649e51babf859ccc7) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file PresOccl.c * * @author (last) Sean Nash -* @date (last) 12-Jun-2020 +* @date (last) 01-Dec-2020 * * @author (original) Sean * @date (original) 15-Jan-2020 @@ -17,8 +17,10 @@ #include "PresOccl.h" #include "AlarmMgmt.h" -#include "FPGA.h" -#include "OperationModes.h" +#include "FPGA.h" +#include "ModeTreatmentParams.h" +#include "OperationModes.h" +#include "PersistentAlarm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Timers.h" @@ -39,8 +41,22 @@ #define VENOUS_PRESSURE_OFFSET ( 1638 ) ///< Offset for 14-bit venous pressure sensor reading. #define VENOUS_PRESSURE_SCALE ( 14745 - VENOUS_PRESSURE_OFFSET ) ///< Scale for venous pressure sensor. -#define VENOUS_PRESSURE_MIN ( 30.0 ) ///< Minimum of scale for venous pressure sensor reading (in TBD u/m). -#define VENOUS_PRESSURE_MAX ( 90.0 ) ///< Maximum of scale for venous pressure sensor reading (in TBD u/m). +#define VENOUS_PRESSURE_MIN ( -30.0 ) ///< Minimum of scale for venous pressure sensor reading (in PSI). +#define VENOUS_PRESSURE_MAX ( 30.0 ) ///< Maximum of scale for venous pressure sensor reading (in PSI). + +#define PSI_TO_MMHG ( 51.7149 ) ///< Conversion factor for converting PSI to mmHg. + +#define VENOUS_PRESSURE_NORMAL_OP 0 ///< Venous pressure status bits indicate normal operation. +#define VENOUS_PRESSURE_CMD_MODE 1 ///< Venous pressure status bits indicate sensor in command mode. +#define VENOUS_PRESSURE_STALE_DATA 2 ///< Venous pressure status bits indicate data is stale (no new data since last fpga read). +#define VENOUS_PRESSURE_DIAG_CONDITION 3 ///< Venous pressure status bits diagnostic condition (alarm). + +#define MAX_TIME_BETWEEN_VENOUS_READINGS ( 500 / TASK_GENERAL_INTERVAL ) ///< Maximum time without fresh inline venous pressure reading. + +#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 PRES_ALARM_PERSISTENCE ( 1 * MS_PER_SECOND ) ///< Alarm persistence period for pressure alarms. /// Defined states for the pressure and occlusion monitor state machine. typedef enum PresOccl_States @@ -64,119 +80,82 @@ static PRESSURE_STATE_T presOcclState = PRESSURE_INIT_STATE; ///< current state of pressure monitor state machine. static U32 presOcclDataPublicationTimerCounter = 0; ///< used to schedule pressure data publication to CAN bus. -static OVERRIDE_F32_T measuredBloodFlowRate = { 0.0, 0.0, 0.0, 0 }; ///< measured blood flow rate - -static OVERRIDE_U32_T presOcclDataPublishInterval = { PRES_OCCL_DATA_PUB_INTERVAL, PRES_OCCL_DATA_PUB_INTERVAL, 0, 0 }; ///< interval (in ms) at which to publish pressure/occlusion data to CAN bus. +/// interval (in ms) at which to publish pressure/occlusion data to CAN bus. +static OVERRIDE_U32_T presOcclDataPublishInterval = { PRES_OCCL_DATA_PUB_INTERVAL, PRES_OCCL_DATA_PUB_INTERVAL, 0, 0 }; static OVERRIDE_F32_T arterialPressure = {0.0, 0.0, 0.0, 0 }; ///< measured arterial pressure. static OVERRIDE_F32_T venousPressure = {0.0, 0.0, 0.0, 0 }; ///< measured venous pressure. -static OVERRIDE_F32_T bloodPumpOcclusion = {0.0, 0.0, 0.0, 0 }; ///< measured blood pump occlusion pressure. -static OVERRIDE_F32_T dialInPumpOcclusion = {0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump occlusion pressure. -static OVERRIDE_F32_T dialOutPumpOcclusion = {0.0, 0.0, 0.0, 0 }; ///< measured dialysate outlet pump occlusion pressure. +static OVERRIDE_U32_T bloodPumpOcclusion = {0, 0, 0, 0 }; ///< measured blood pump occlusion pressure. +static OVERRIDE_U32_T dialInPumpOcclusion = {0, 0, 0, 0 }; ///< measured dialysate inlet pump occlusion pressure. +static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< measured dialysate outlet pump occlusion pressure. -static PRESSURE_SELF_TEST_STATE_T presOcclSelfTestState = PRESSURE_SELF_TEST_STATE_START; ///< current pressure self-test state. +/// current pressure self-test state. +static PRESSURE_SELF_TEST_STATE_T presOcclSelfTestState = PRESSURE_SELF_TEST_STATE_START; static U32 bloodPumpSelfTestTimerCount = 0; ///< timer counter for pressure self-test. -static F32 arterialPressureLowLimitmmHG = 0.0; ///< lower alarm limit for arterial pressure. -static F32 arterialPressureHighLimitmmHG = 0.0; ///< upper alarm limit for arterial pressure. -static F32 venousPressureLowLimitmmHG = 0.0; ///< lower alarm limit for venous pressure. -static F32 venousPressureHighLimitmmHG = 0.0; ///< upper alarm limit for venous pressure. -// TODO - set thresholds for occlusions -static F32 bloodPumpOcclusionPressureThresholdmmHG = 50.0; ///< pressure threshold for blood pump occlusion. -static F32 dialInPumpOcclusionPressureThresholdmmHG = 50.0; ///< pressure threshold for dialysate inlet pump occlusion. -static F32 dialOutPumpOcclusionPressureThresholdmmHG = 50.0; ///< pressure threshold for dialysate outlet pump occlusion. +static U32 staleVenousPressureCtr = 0; ///< timer counter for stale venous pressure reading. // ********** private function prototypes ********** static PRESSURE_STATE_T handlePresOcclInitState( void ); -static PRESSURE_STATE_T handlePresOcclContReadState( void ); +static PRESSURE_STATE_T handlePresOcclContReadState( void ); +static void convertInlinePressures( void ); +static void convertOcclusionPressures( void ); +static void checkArterialPressureInRange( void ); +static void checkVenousPressureInRange( void ); static void checkOcclusions( void ); static void publishPresOcclData( void ); static DATA_GET_PROTOTYPE( U32, getPublishPresOcclDataInterval ); /*********************************************************************//** * @brief * The initPresOccl function initializes the initPresOccl module. - * @details - * Inputs : none - * Outputs : initPresOccl module initialized. + * @details Inputs: none + * @details Outputs: initPresOccl module initialized. * @return none *************************************************************************/ void initPresOccl( void ) { - // TODO - anything to initialize? + // initialize persistent pressure alarms + initPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_LOW, ALARM_ID_ARTERIAL_PRESSURE_LOW, + isAlarmRecoverable( ALARM_ID_ARTERIAL_PRESSURE_LOW ), PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_HIGH, ALARM_ID_ARTERIAL_PRESSURE_HIGH, + isAlarmRecoverable( ALARM_ID_ARTERIAL_PRESSURE_HIGH ), PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( PERSISTENT_ALARM_VENOUS_PRESSURE_LOW, ALARM_ID_VENOUS_PRESSURE_LOW, + isAlarmRecoverable( ALARM_ID_VENOUS_PRESSURE_LOW ), PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( PERSISTENT_ALARM_VENOUS_PRESSURE_HIGH, ALARM_ID_VENOUS_PRESSURE_HIGH, + isAlarmRecoverable( ALARM_ID_VENOUS_PRESSURE_HIGH ), PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); } +/*********************************************************************//** + * @brief + * The isCartridgeLoaded function determines whether a cartridge has been + * properly loaded by looking at the 3 occlusion pressure sensors. + * @details Inputs: occlusion pressures for the pumps + * @details Outputs: none + * @return TRUE if all 3 occlusion sensors read above loaded threshold, FALSE if not. + *************************************************************************/ +BOOL isCartridgeLoaded( void ) +{ + BOOL result = FALSE; + U32 bpOccl = getMeasuredBloodPumpOcclusion(); + U32 diOccl = getMeasuredDialInPumpOcclusion(); + U32 doOccl = getMeasuredDialOutPumpOcclusion(); + + if ( ( bpOccl >= CARTRIDGE_LOADED_THRESHOLD ) && + ( diOccl >= CARTRIDGE_LOADED_THRESHOLD ) && + ( doOccl >= CARTRIDGE_LOADED_THRESHOLD ) ) + { + result = TRUE; + } + + return result; +} + /*********************************************************************//** * @brief - * The setPressureLimits function sets the lower and upper alarm limits - * for a given pressure sensor. - * @details - * Inputs : none - * Outputs : pressure limits - * @param sensor pressure sensor we are setting limits for - * @param low lower alarm limit (mmHg) - * @param high upper alarm limit (mmHg) - * @return none - *************************************************************************/ -void setPressureLimits( PRESSURE_SENSORS_T sensor, F32 low, F32 high ) -{ - switch ( sensor ) // TODO - will low/high limits be range checked by caller or should we do it here? what are valid ranges? - { - case PRESSURE_SENSOR_ARTERIAL: - arterialPressureLowLimitmmHG = low; - arterialPressureHighLimitmmHG = high; - break; - - case PRESSURE_SENSOR_VENOUS: - venousPressureLowLimitmmHG = low; - venousPressureHighLimitmmHG = high; - break; - - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_PRES_OCCL_INVALID_PRES_SENSOR, sensor ) - break; - } -} - -/*********************************************************************//** - * @brief - * The setOcclusionThreshold function sets the occlusion pressure threshold - * for a given occlusion sensor. - * @details - * Inputs : none - * Outputs : pressure threshold - * @param sensor occlusion sensor we are setting threshold for - * @param threshold pressure threshold above which indicates an occlusion (mmHg) - * @return none - *************************************************************************/ -void setOcclusionThreshold( OCCLUSION_SENSORS_T sensor, F32 threshold ) -{ - switch ( sensor ) // TODO - will threshold be range checked by caller or should we do it here? what is valid range? - { - case OCCLUSION_SENSOR_BLOOD_PUMP: - bloodPumpOcclusionPressureThresholdmmHG = threshold; - break; - - case OCCLUSION_SENSOR_DIAL_IN_PUMP: - dialInPumpOcclusionPressureThresholdmmHG = threshold; - break; - - case OCCLUSION_SENSOR_DIAL_OUT_PUMP: - dialOutPumpOcclusionPressureThresholdmmHG = threshold; - break; - - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_PRES_OCCL_INVALID_OCCL_SENSOR, sensor ) - break; - } -} - -/*********************************************************************//** - * @brief * The execPresOccl function executes the pressure and occlusion monitor. - * @details - * Inputs : presOcclState - * Outputs : presOcclState + * @details Inputs: presOcclState + * @details Outputs: presOcclState * @return none *************************************************************************/ void execPresOccl( void ) @@ -205,9 +184,8 @@ * @brief * The handlePresOcclInitState function handles the pres/occl initialize state * of the pressure/occlusion monitor state machine. - * @details - * Inputs : TBD - * Outputs : TBD + * @details Inputs: TBD + * @details Outputs: TBD * @return next state *************************************************************************/ static PRESSURE_STATE_T handlePresOcclInitState( void ) @@ -221,67 +199,186 @@ * @brief * The handlePresOcclContReadState function handles the continuous read state * of the pressure/occlusion monitor state machine. - * @details - * Inputs : TBD - * Outputs : pressure sensor values updated + * @details Inputs: FPGA pressure/occlusion readings + * @details Outputs: pressure sensor values updated * @return next state *************************************************************************/ static PRESSURE_STATE_T handlePresOcclContReadState( void ) { - PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; - - S32 artPres = getFPGAArterialPressure(); - U16 venPres = getFPGAVenousPressure(); - U16 bldOccl = getFPGABloodPumpOcclusion(); - U16 dliOccl = getFPGADialInPumpOcclusion(); - U16 dloOccl = getFPGADialOutPumpOcclusion(); - - // TODO - convert ADC counts to mmHg for each sensor - arterialPressure.data = ARTERIAL_PRESSURE_V_PER_BIT * ( (F32)(artPres) / ( ARTERIAL_PRESSURE_SENSITIVITY / ARTERIAL_PRESSURE_V_BIAS ) ); - venousPressure.data = ( (F32)(venPres - VENOUS_PRESSURE_OFFSET) * (VENOUS_PRESSURE_MAX - VENOUS_PRESSURE_MIN) / (F32)VENOUS_PRESSURE_SCALE ) - VENOUS_PRESSURE_MIN; - bloodPumpOcclusion.data = (F32)bldOccl; - dialInPumpOcclusion.data = (F32)dliOccl; - dialOutPumpOcclusion.data = (F32)dloOccl; - - // TODO - any filtering required??? - + PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; + + // read latest in-line (arterial and venous) pressures + convertInlinePressures(); + + // read latest occlusion pressures + convertOcclusionPressures(); + + // check in-line pressures are in range + checkArterialPressureInRange(); + checkVenousPressureInRange(); + // check for occlusions - checkOcclusions(); - - // TODO - any other checks - + checkOcclusions(); + return result; } - + +/*********************************************************************//** + * @brief + * The convertInlinePressures function reads inline pressure sensor readings + * and converts to mmHg. Sensor status/alarm is checked. + * @details Inputs: FPGA + * @details Outputs: arterialPressure, venousPressure + * @return none + *************************************************************************/ +static void convertInlinePressures( void ) +{ + U32 fpgaArtPres = getFPGAArterialPressure(); + S32 artPres = (S32)( fpgaArtPres & MASK_OFF_U32_MSB ) - 0x800000; // subtract 2^23 from low 24 bits to get signed reading + U08 artPresAlarm = (U08)( fpgaArtPres >> 24 ); // high byte is alarm code for arterial pressure + U16 fpgaVenPres = getFPGAVenousPressure(); + U16 venPres = fpgaVenPres & 0x3FFF; // 14-bit data + U08 venPresStatus = (U08)( fpgaVenPres >> 14 ); // high 2 bits is status code for venous pressure + F32 venPresPSI; + + // TODO - any filtering required??? + + // convert arterial pressure to mmHg if no alarm + if ( 0 == artPresAlarm ) + { + arterialPressure.data = ARTERIAL_PRESSURE_V_PER_BIT * ( (F32)(artPres) / ( ARTERIAL_PRESSURE_SENSITIVITY * ARTERIAL_PRESSURE_V_BIAS ) ); + } + else + { +#ifndef DISABLE_PRESSURE_CHECKS + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_ARTERIAL_PRESSURE_SENSOR_FAULT, (U32)artPresAlarm ) +#endif + } + + // convert venous pressure to PSI + venPresPSI = ( (F32)(venPres - VENOUS_PRESSURE_OFFSET) * (VENOUS_PRESSURE_MAX - VENOUS_PRESSURE_MIN) / (F32)VENOUS_PRESSURE_SCALE ) + VENOUS_PRESSURE_MIN; + // convert venous pressure from PSI to mmHg if sensor status is normal + if ( VENOUS_PRESSURE_NORMAL_OP == venPresStatus ) + { + venousPressure.data = venPresPSI * PSI_TO_MMHG; + staleVenousPressureCtr = 0; + } + // if venous pressure sensor status is not normal or reading is stale for too long, fault + else + { + if ( ++staleVenousPressureCtr > MAX_TIME_BETWEEN_VENOUS_READINGS ) + { +#ifndef DISABLE_PRESSURE_CHECKS + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, VENOUS_PRESSURE_STALE_DATA ) +#endif + } + } + + // check for venous pressure sensor alarm or in wrong (cmd) mode + if ( ( VENOUS_PRESSURE_DIAG_CONDITION == venPresStatus ) || ( VENOUS_PRESSURE_CMD_MODE == venPresStatus ) ) + { +#ifndef DISABLE_PRESSURE_CHECKS + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, (U32)venPresStatus ) +#endif + } +} + +/*********************************************************************//** + * @brief + * The convertOcclusionPressures function reads occlusion sensor readings. + * @details Inputs: FPGA + * @details Outputs: bloodPumpOcclusion, dialInPumpOcclusion, dialOutPumpOcclusion + * @return none + *************************************************************************/ +static void convertOcclusionPressures( void ) +{ + // TODO - any filtering required??? + + // occlusion sensor values have no unit - take as is + bloodPumpOcclusion.data = (U32)getFPGABloodPumpOcclusion(); + dialInPumpOcclusion.data = (U32)getFPGADialInPumpOcclusion(); + dialOutPumpOcclusion.data = (U32)getFPGADialOutPumpOcclusion(); +} + +/*********************************************************************//** + * @brief + * The checkArterialPressureInRange function checks that artieral pressure is + * within the set alarm limits. Alarm is triggered if not. + * @details Inputs: arterialPressure + * @details Outputs: Alarm if out of range + * @return none + *************************************************************************/ +static void checkArterialPressureInRange( void ) +{ + F32 artPres = getMeasuredArterialPressure(); + + // check arterial pressure during treatment mode + if ( MODE_TREA == getCurrentOperationMode() ) + { + F32 artLowLimit = (F32)getTreatmentParameterS32( TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT ); + F32 artHighLimit = (F32)getTreatmentParameterS32( TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT ); + +#ifndef DISABLE_PRESSURE_CHECKS + checkPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_LOW, artPres < artLowLimit, artPres, artLowLimit ); + checkPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_HIGH, artPres > artHighLimit, artPres, artHighLimit ); +#endif + } +} + +/*********************************************************************//** + * @brief + * The checkVenousPressureInRange function checks that venous pressure is + * within the set alarm limits. Alarm is triggered if not. + * @details Inputs: venousPressure + * @details Outputs: Alarm if out of range + * @return none + *************************************************************************/ +static void checkVenousPressureInRange( void ) +{ + F32 venPres = getMeasuredVenousPressure(); + + // check arterial pressure during treatment mode + if ( MODE_TREA == getCurrentOperationMode() ) + { + F32 venLowLimit = (F32)getTreatmentParameterS32( TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT ); + F32 venHighLimit = (F32)getTreatmentParameterS32( TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ); + +#ifndef DISABLE_PRESSURE_CHECKS + checkPersistentAlarm( PERSISTENT_ALARM_VENOUS_PRESSURE_LOW, venPres < venLowLimit, venPres, venLowLimit ); + checkPersistentAlarm( PERSISTENT_ALARM_VENOUS_PRESSURE_HIGH, venPres > venHighLimit, venPres, venHighLimit ); +#endif + } +} + /*********************************************************************//** * @brief * The checkPressureLimits function gets the pressure/occlusion data * publication interval. - * @details - * Inputs : occlusion pressures for the pumps - * Outputs : + * @details Inputs: occlusion pressures for the pumps + * @details Outputs: Alarm if occlusion limit exceeded * @return none *************************************************************************/ static void checkOcclusions( void ) { - F32 bpOccl = getMeasuredBloodPumpOcclusion(); - F32 diOccl = getMeasuredDialInPumpOcclusion(); - F32 doOccl = getMeasuredDialOutPumpOcclusion(); - + U32 bpOccl = getMeasuredBloodPumpOcclusion(); + U32 diOccl = getMeasuredDialInPumpOcclusion(); + U32 doOccl = getMeasuredDialOutPumpOcclusion(); + + // TODO - add persistence #ifndef DISABLE_PRESSURE_CHECKS - if ( bpOccl > bloodPumpOcclusionPressureThresholdmmHG ) + if ( bpOccl > OCCLUSION_THRESHOLD ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_OCCLUSION_BLOOD_PUMP, bpOccl ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_OCCLUSION_BLOOD_PUMP, bpOccl ) // TODO - stop blood pump immediately, ... } - if ( diOccl > dialInPumpOcclusionPressureThresholdmmHG ) + if ( diOccl > OCCLUSION_THRESHOLD ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_OCCLUSION_DIAL_IN_PUMP, diOccl ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_OCCLUSION_DIAL_IN_PUMP, diOccl ) // TODO - stop dialysate inlet pump immediately, ... } - if ( doOccl > dialOutPumpOcclusionPressureThresholdmmHG ) + if ( doOccl > OCCLUSION_THRESHOLD ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_OCCLUSION_DIAL_OUT_PUMP, doOccl ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_OCCLUSION_DIAL_OUT_PUMP, doOccl ) // TODO - stop dialysate outlet pump immediately, ... } #endif @@ -291,87 +388,142 @@ * @brief * The getPublishPresOcclDataInterval function gets the pressure/occlusion data * publication interval. - * @details - * Inputs : presOcclDataPublishInterval - * Outputs : none + * @details Inputs: presOcclDataPublishInterval + * @details Outputs: none * @return the current pressure/occlusion data publication interval (in task intervals). *************************************************************************/ -DATA_GET( U32, getPublishPresOcclDataInterval, presOcclDataPublishInterval ) +U32 getPublishPresOcclDataInterval( void ) +{ + U32 result = presOcclDataPublishInterval.data; + + if ( OVERRIDE_KEY == presOcclDataPublishInterval.override ) + { + result = presOcclDataPublishInterval.ovData; + } + + return result; +} /*********************************************************************//** * @brief * The getMeasuredArterialPressure function gets the current arterial pressure. - * @details - * Inputs : arterialPressure - * Outputs : none + * @details Inputs: arterialPressure + * @details Outputs: none * @return the current arterial pressure (in mmHg). *************************************************************************/ -DATA_GET( F32, getMeasuredArterialPressure, arterialPressure ) +F32 getMeasuredArterialPressure( void ) +{ + F32 result = arterialPressure.data; + + if ( OVERRIDE_KEY == arterialPressure.override ) + { + result = arterialPressure.ovData; + } + + return result; +} /*********************************************************************//** * @brief * The getMeasuredVenousPressure function gets the measured venous pressure. - * @details - * Inputs : venousPressure - * Outputs : none + * @details Inputs: venousPressure + * @details Outputs: none * @return the current venous pressure (in mmHg). *************************************************************************/ -DATA_GET( F32, getMeasuredVenousPressure, venousPressure ) +F32 getMeasuredVenousPressure( void ) +{ + F32 result = venousPressure.data; + + if ( OVERRIDE_KEY == venousPressure.override ) + { + result = venousPressure.ovData; + } + + return result; +} /*********************************************************************//** * @brief * The getMeasuredBloodPumpOcclusion function gets the measured blood pump * occlusion pressure. - * @details - * Inputs : bloodPumpOcclusion - * Outputs : none + * @details Inputs: bloodPumpOcclusion + * @details Outputs: none * @return the current blood pump occlusion pressure (in mmHg). *************************************************************************/ -DATA_GET( F32, getMeasuredBloodPumpOcclusion, bloodPumpOcclusion ) +U32 getMeasuredBloodPumpOcclusion( void ) +{ + U32 result = bloodPumpOcclusion.data; + + if ( OVERRIDE_KEY == bloodPumpOcclusion.override ) + { + result = bloodPumpOcclusion.ovData; + } + + return result; +} /*********************************************************************//** * @brief * The getMeasuredDialInPumpOcclusion function gets the measured dialysate * inlet pump occlusion pressure. - * @details - * Inputs : dialInPumpOcclusion - * Outputs : none + * @details Inputs: dialInPumpOcclusion + * @details Outputs: none * @return the current dialysis inlet pump occlusion pressure (in mmHg). *************************************************************************/ -DATA_GET( F32, getMeasuredDialInPumpOcclusion, dialInPumpOcclusion ) +U32 getMeasuredDialInPumpOcclusion( void ) +{ + U32 result = dialInPumpOcclusion.data; + + if ( OVERRIDE_KEY == dialInPumpOcclusion.override ) + { + result = dialInPumpOcclusion.ovData; + } + + return result; +} /*********************************************************************//** * @brief * The getMeasuredDialOutPumpOcclusion function gets the measured dialysate * outlet pump occlusion pressure. - * @details - * Inputs : dialOutPumpOcclusion - * Outputs : none + * @details Inputs: dialOutPumpOcclusion + * @details Outputs: none * @return the current dialysis outlet pump occlusion pressure (in mmHg). *************************************************************************/ -DATA_GET( F32, getMeasuredDialOutPumpOcclusion, dialOutPumpOcclusion ) +U32 getMeasuredDialOutPumpOcclusion( void ) +{ + U32 result = dialOutPumpOcclusion.data; + + if ( OVERRIDE_KEY == dialOutPumpOcclusion.override ) + { + result = dialOutPumpOcclusion.ovData; + } + + return result; +} /*********************************************************************//** * @brief * The publishPresOcclData function publishes pressure/occlusion data at the * set interval. - * @details - * Inputs : TBD - * Outputs : Pressure/occlusion data are published to CAN bus. + * @details Inputs: latest pressure and occlusion readings + * @details Outputs: Pressure/occlusion data are published to CAN bus. * @return none *************************************************************************/ static void publishPresOcclData( void ) { // publish pressure/occlusion data on interval if ( ++presOcclDataPublicationTimerCounter >= getPublishPresOcclDataInterval() ) - { - F32 artPres = getMeasuredArterialPressure(); - F32 venPres = getMeasuredVenousPressure(); - F32 bpOccl = getMeasuredBloodPumpOcclusion(); - F32 diOccl = getMeasuredDialInPumpOcclusion(); - F32 doOccl = getMeasuredDialOutPumpOcclusion(); + { + PRESSURE_OCCLUSION_DATA_T data; - broadcastPresOcclData( artPres, venPres, bpOccl, diOccl, doOccl ); + data.arterialPressure = getMeasuredArterialPressure(); + data.venousPressure = getMeasuredVenousPressure(); + data.bldPumpOcclusion = getMeasuredBloodPumpOcclusion(); + data.diPumpOcclusion = getMeasuredDialInPumpOcclusion(); + data.doPumpOcclusion = getMeasuredDialOutPumpOcclusion(); + + broadcastPresOcclData( data ); presOcclDataPublicationTimerCounter = 0; } } @@ -380,9 +532,8 @@ * @brief * The execPresOcclTest function executes the state machine for the * PresOccl self-test. - * @details - * Inputs : none - * Outputs : none + * @details Inputs: none + * @details Outputs: none * @return the current state of the PresOccl self-test. *************************************************************************/ SELF_TEST_STATUS_T execPresOcclTest( void ) @@ -404,9 +555,8 @@ * @brief * The testSetPresOcclDataPublishIntervalOverride function overrides the * pressure and occlusion data publish interval. - * @details - * Inputs : none - * Outputs : presOcclDataPublishInterval + * @details Inputs: none + * @details Outputs: presOcclDataPublishInterval * @param value override pressure and occlusion data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -430,9 +580,8 @@ * @brief * The testResetPresOcclDataPublishIntervalOverride function resets the override * of the pressure and occlusion data publish interval. - * @details - * Inputs : none - * Outputs : presOcclDataPublishInterval + * @details Inputs: none + * @details Outputs: presOcclDataPublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetPresOcclDataPublishIntervalOverride( void ) @@ -453,9 +602,8 @@ * @brief * The testSetArterialPressureOverride function overrides the measured arterial * pressure. - * @details - * Inputs : none - * Outputs : arterialPressure + * @details Inputs: none + * @details Outputs: arterialPressure * @param value override arterial pressure (in mmHg) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -477,9 +625,8 @@ * @brief * The testResetArterialPressureOverride function resets the override of the * arterial pressure. - * @details - * Inputs : none - * Outputs : arterialPressure + * @details Inputs: none + * @details Outputs: arterialPressure * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetArterialPressureOverride( void ) @@ -500,9 +647,8 @@ * @brief * The testSetVenousPressureOverride function overrides the measured venous * pressure. - * @details - * Inputs : none - * Outputs : venousPressure + * @details Inputs: none + * @details Outputs: venousPressure * @param value override measured venous pressure with (in mmHg) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -524,9 +670,8 @@ * @brief * The testResetVenousPressureOverride function resets the override of the * venous pressure. - * @details - * Inputs : none - * Outputs : venousPressure + * @details Inputs: none + * @details Outputs: venousPressure * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetVenousPressureOverride( void ) @@ -546,14 +691,13 @@ /*********************************************************************//** * @brief * The testSetBloodPumpOcclusionOverride function overrides the measured - * blood pump occlusion pressure.n - * @details - * Inputs : none - * Outputs : bloodPumpOcclusion - * @param value override measured blood pump occlusion pressure with (in mmHg) + * blood pump occlusion pressure. + * @details Inputs: none + * @details Outputs: bloodPumpOcclusion + * @param value override measured blood pump occlusion pressure with * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetBloodPumpOcclusionOverride( F32 value ) +BOOL testSetBloodPumpOcclusionOverride( U32 value ) { BOOL result = FALSE; @@ -571,9 +715,8 @@ * @brief * The testResetBloodPumpOcclusionOverride function resets the override of the * measured blood pump occlusion pressure. - * @details - * Inputs : none - * Outputs : bloodPumpOcclusion + * @details Inputs: none + * @details Outputs: bloodPumpOcclusion * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetBloodPumpOcclusionOverride( void ) @@ -594,13 +737,12 @@ * @brief * The testSetDialInPumpOcclusionOverride function overrides the measured * dialysate inlet pump occlusion pressure.n - * @details - * Inputs : none - * Outputs : dialInPumpOcclusion - * @param value override measured dialysate inlet pump occlusion pressure (in mmHg) + * @details Inputs: none + * @details Outputs: dialInPumpOcclusion + * @param value override measured dialysate inlet pump occlusion pressure * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetDialInPumpOcclusionOverride( F32 value ) +BOOL testSetDialInPumpOcclusionOverride( U32 value ) { BOOL result = FALSE; @@ -618,9 +760,8 @@ * @brief * The testResetDialInPumpOcclusionOverride function resets the override of the * measured dialysate inlet pump occlusion pressure. - * @details - * Inputs : none - * Outputs : dialInPumpOcclusion + * @details Inputs: none + * @details Outputs: dialInPumpOcclusion * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetDialInPumpOcclusionOverride( void ) @@ -641,13 +782,12 @@ * @brief * The testSetDialOutPumpOcclusionOverride function overrides the measured * dialysate outlet pump occlusion pressure. - * @details - * Inputs : none - * Outputs : dialOutPumpOcclusion - * @param value override measured dialysate outlet pump occlusion pressure (in mmHg) + * @details Inputs: none + * @details Outputs: dialOutPumpOcclusion + * @param value override measured dialysate outlet pump occlusion pressure * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetDialOutPumpOcclusionOverride( F32 value ) +BOOL testSetDialOutPumpOcclusionOverride( U32 value ) { BOOL result = FALSE; @@ -665,9 +805,8 @@ * @brief * The testResetDialOutPumpOcclusionOverride function resets the override of the * measured dialysate outlet pump occlusion pressure. - * @details - * Inputs : none - * Outputs : dialOutPumpOcclusion + * @details Inputs: none + * @details Outputs: dialOutPumpOcclusion * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetDialOutPumpOcclusionOverride( void )