Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -rb4bc2e0337b358ee180650101d98e18346bf7c22 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision b4bc2e0337b358ee180650101d98e18346bf7c22) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -32,12 +32,10 @@ // ********** public definitions ********** -#define DRAIN_RESERVOIR_TO_VOLUME_ML 0 ///< Drain reservoir to this volume (in mL) during treatment. -#ifndef V1_5_SYSTEM -#define FILL_RESERVOIR_TO_VOLUME_ML 1700 ///< Fill reservoir to this volume (in mL) during treatment. -#else -#define FILL_RESERVOIR_TO_VOLUME_ML 1300 ///< Fill reservoir to this volume (in mL) during treatment. -#endif +#define DRAIN_RESERVOIR_TO_VOLUME_ML 0 ///< Drain reservoir to this volume (in mL) during treatment. +#define FILL_RESERVOIR_TO_VOLUME_ML 1700 ///< Fill reservoir to this volume (in mL) during treatment. +#define FILL_RESERVOIR_TO_VOLUME_LOW_FLOW_ML 1300 ///< Fill reservoir to this volume (in mL) during treatment if dialysate flow is slow. +#define SLOW_DIALYSATE_FLOW_ML_MIN 250 ///< Threshold for slow dialysate flow designation. /// Enumeration of DG pressure sensors. typedef enum DG_PressureSensors @@ -133,6 +131,7 @@ F32 getDGROPumpFlowRateMlMin( void ); U32 getDGDrainPumpRPMSetPt( void ); F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ); +F32 getReservoirWeight( DG_RESERVOIR_ID_T resID ); F32 getReservoirWeightLargeFilter( DG_RESERVOIR_ID_T resID ); void setDGOpMode( U32 opMode, U32 subMode ); Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -rb4bc2e0337b358ee180650101d98e18346bf7c22 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision b4bc2e0337b358ee180650101d98e18346bf7c22) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -50,15 +50,16 @@ #define VENOUS_PRESSURE_SELF_TEST_MIN ( -100.0 ) ///< Minimum self-test value for venous pressure sensor reading (in mmHg). #define VENOUS_PRESSURE_SELF_TEST_MAX ( 600.0 ) ///< Maximum self-test value for venous pressure sensor reading (in mmHg). +#define VENOUS_PRESSURE_MIN_TEMP ( 0.0 ) ///< Minimum venous pressure sensor temperature. TODO - get from Systems +#define VENOUS_PRESSURE_MAX_TEMP ( 50.0 ) ///< Maximum venous pressure sensor temperature. TODO - get from Systems + #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). -static const U32 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. @@ -101,8 +102,15 @@ 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 U32 staleVenousPressureCtr = 0; ///< Timer counter for stale venous pressure reading. static U32 emptySalineBagCtr = 0; ///< Timer counter for empty bag detection. + +static U08 lastVenousPressureReadCtr; ///< Previous venous pressure read count. +static U08 lastBPOcclReadCtr; ///< Previous BP occlusion read count. +static U08 lastDPiOcclReadCtr; ///< Previous DPi occlusion read count. +static U08 lastDPoOcclReadCtr; ///< Previous DPo occlusion read count. +static U08 lastBPErrorCtr; ///< Previous BP error count. +static U08 lastDPIErrorCtr; ///< Previous DPi error count. +static U08 lastDPOErrorCtr; ///< Previous DPo error count. // ********** private function prototypes ********** @@ -129,6 +137,22 @@ initPersistentAlarm( ALARM_ID_ARTERIAL_PRESSURE_HIGH, PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_VENOUS_PRESSURE_LOW, PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_VENOUS_PRESSURE_HIGH, PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_VENOUS_PRESSURE_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_VENOUS_PRESSURE_SENSOR_TEMP_OUT_OF_RANGE, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_DPI_OCCLUSON_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_DPO_OCCLUSION_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_DPI_OCCLUSION_SENSOR_ERROR, 0, PRES_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_DPO_OCCLUSION_SENSOR_ERROR, 0, PRES_ALARM_PERSISTENCE ); + + lastVenousPressureReadCtr = 0; + lastBPOcclReadCtr = 0; + lastDPiOcclReadCtr = 0; + lastDPoOcclReadCtr = 0; + lastBPErrorCtr = 0; + lastDPIErrorCtr = 0; + lastDPOErrorCtr = 0; } /*********************************************************************//** @@ -270,15 +294,17 @@ { 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 + U08 artPresAlarm = (U08)( fpgaArtPres >> SHIFT_24_BITS ); // 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; + F32 venTemp = getFPGAVenousPressureTemperature(); + U08 venReadCtr = getFPGAVenousPressureReadCounter(); // TODO - any filtering required??? - // Convert arterial pressure to mmHg if no alarm + // Convert arterial pressure to mmHg if no fault if ( 0 == artPresAlarm ) { arterialPressure.data = ARTERIAL_PRESSURE_V_PER_BIT * ( (F32)(artPres) / ( ARTERIAL_PRESSURE_SENSITIVITY * ARTERIAL_PRESSURE_V_BIAS ) ); @@ -290,31 +316,33 @@ #endif } - // Convert venous pressure to PSI + // Check for stale venous pressure reading + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_VENOUS_PRESSURE_READ_TIMEOUT_ERROR, ( lastVenousPressureReadCtr == venReadCtr ) ) ) + { + activateAlarmNoData( ALARM_ID_HD_VENOUS_PRESSURE_READ_TIMEOUT_ERROR ); + } + // Record venous read counter for next time around + lastVenousPressureReadCtr = venReadCtr; + // Convert venous pressure to PSI and then mmHg 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 + // If venous pressure sensor status is not normal, 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 ) +// SET_ALARM_WITH_1_U32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, (U32)venPresStatus ) // TODO - persistence? YES, need persistence - getting a stale data status. OR maybe speed up ADC in FPGA. #endif - } } - // Check for venous pressure sensor alarm or in wrong (cmd) mode - if ( ( VENOUS_PRESSURE_DIAG_CONDITION == venPresStatus ) || ( VENOUS_PRESSURE_CMD_MODE == venPresStatus ) ) + // Check venous pressure sensor temperature + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_VENOUS_PRESSURE_SENSOR_TEMP_OUT_OF_RANGE, + ( venTemp > VENOUS_PRESSURE_MAX_TEMP || venTemp < VENOUS_PRESSURE_MIN_TEMP ) ) ) { -#ifndef DISABLE_PRESSURE_CHECKS - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, (U32)venPresStatus ) -#endif + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, venTemp ) } } @@ -327,10 +355,53 @@ *************************************************************************/ static void convertOcclusionPressures( void ) { - // Occlusion sensor values have no unit - take as is + U08 bpReadCtr = getFPGABloodPumpOcclusionReadCounter(); + U08 dpiReadCtr = getFPGADialInPumpOcclusionReadCounter(); + U08 dpoReadCtr = getFPGADialOutPumpOcclusionReadCounter(); + U08 bpErrorCtr = getFPGABloodPumpOcclusionErrorCounter(); + U08 dpiErrorCtr = getFPGADialInPumpOcclusionErrorCounter(); + U08 dpoErrorCtr = getFPGADialOutPumpOcclusionErrorCounter(); + + // Check for sensor errors + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR, ( bpErrorCtr != lastBPErrorCtr ) ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR, (U32)bpErrorCtr ) + } + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DPI_OCCLUSION_SENSOR_ERROR, ( dpiErrorCtr != lastDPIErrorCtr ) ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DPI_OCCLUSION_SENSOR_ERROR, (U32)dpiErrorCtr ) + } + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DPO_OCCLUSION_SENSOR_ERROR, ( dpoErrorCtr != lastDPOErrorCtr ) ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DPO_OCCLUSION_SENSOR_ERROR, (U32)dpoErrorCtr ) + } + + // Check for stale occlusion reads + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR, ( bpReadCtr == lastBPOcclReadCtr ) ) ) + { + activateAlarmNoData( ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR ); + } + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR, ( dpiReadCtr == lastDPiOcclReadCtr ) ) ) + { + activateAlarmNoData( ALARM_ID_HD_DPI_OCCLUSON_READ_TIMEOUT_ERROR ); + } + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR, ( dpoReadCtr == lastDPoOcclReadCtr ) ) ) + { + activateAlarmNoData( ALARM_ID_HD_DPO_OCCLUSION_READ_TIMEOUT_ERROR ); + } + + // Record occlusion sensor readings bloodPumpOcclusion.data = (U32)getFPGABloodPumpOcclusion(); dialInPumpOcclusion.data = (U32)getFPGADialInPumpOcclusion(); dialOutPumpOcclusion.data = (U32)getFPGADialOutPumpOcclusion(); + + // Record occlusion read and error counters for next time around + lastBPOcclReadCtr = bpReadCtr; + lastDPiOcclReadCtr = dpiReadCtr; + lastDPoOcclReadCtr = dpoReadCtr; + lastBPErrorCtr = bpErrorCtr; + lastDPIErrorCtr = dpiErrorCtr; + lastDPOErrorCtr = dpoErrorCtr; } /*********************************************************************//** @@ -602,7 +673,8 @@ * @return none *************************************************************************/ void execPresOcclTest( void ) -{ +{ +#ifndef DISABLE_PRESSURE_CHECKS U32 const bpPressure = getMeasuredBloodPumpOcclusion(); U32 const dialysateInPressure = getMeasuredDialInPumpOcclusion(); U32 const dialysateOutPressure = getMeasuredDialOutPumpOcclusion(); @@ -633,6 +705,7 @@ { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_VENOUS_PRESSURE_SELF_TEST_FAILURE, venousPressure ); } +#endif } /*********************************************************************//** Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -rc14a0220256e92a6339a444a3e1bc85e159ccce3 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision c14a0220256e92a6339a444a3e1bc85e159ccce3) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -62,6 +62,8 @@ static F32 measUFVolume; ///< Current total measured volume for ultrafiltration (Where are we w/r/t ultrafiltration). static F32 resStartVolume[ NUM_OF_DG_RESERVOIRS ]; ///< Reservoir start volume for ultrafiltration (i.e. where did we start with each reservoir). static F32 resFinalVolume[ NUM_OF_DG_RESERVOIRS ]; ///< Reservoir final volume for ultrafiltration (i.e. where did we end after switch with each reservoir). +static F32 resCurrVolume[ NUM_OF_DG_RESERVOIRS ]; ///< Reservoir current volume. +static F32 resLastVolume[ NUM_OF_DG_RESERVOIRS ]; ///< Reservoir previous volume. static F32 measUFVolumeFromPriorReservoirs; ///< Current total ultrafiltration volume from previous reservoirs in current treatment. static U32 uFTimeMS; ///< Current elapsed ultrafiltration time (in ms). Used for calculating UF reference volume. @@ -75,7 +77,7 @@ static U32 salineBolusBroadcastTimerCtr; ///< Saline bolus data broadcast timer counter used to schedule when to transmit data. static BOOL salineBolusStartRequested; ///< Flag indicates a saline bolus start has been requested by user. static BOOL salineBolusAbortRequested; ///< Flag indicates a salien bolus abort has been requested by user. -static BOOL salineBolusAutoResumeUF; ///< Flag indicates UF should be auto-resumed after saline bolus completes. +static BOOL salineBolusAutoResumeUF = FALSE; ///< Flag indicates UF should be auto-resumed after saline bolus completes. static F32 totalSalineVolumeDelivered; ///< Volume (mL) in total of saline delivered so far (cumulative for all boluses including current one). static F32 bolusSalineVolumeDelivered; ///< Volume (mL) of current bolus delivered so far. static F32 bolusSalineVolumeDelivered_Safety; ///< Volume (mL) of current bolus delivered so far according to safety monitor. @@ -125,6 +127,8 @@ refUFVolume = 0.0; measUFVolume = 0.0; measUFVolumeFromPriorReservoirs = 0.0; + // Send reset UF volumes to dialysate outlet pump + setDialOutUFVolumes( refUFVolume, measUFVolume ); uFTimeMS = 0; lastUFTimeStamp = 0; @@ -156,14 +160,18 @@ { salineBolusStartRequested = FALSE; salineBolusAbortRequested = FALSE; - salineBolusAutoResumeUF = FALSE; bolusSalineVolumeDelivered = 0.0; bolusSalineVolumeDelivered_Safety = 0.0; bolusSalineMotorCount = 0; if ( currentSalineBolusState != SALINE_BOLUS_STATE_MAX_DELIVERED ) { currentSalineBolusState = SALINE_BOLUS_STATE_IDLE; } + if ( TRUE == salineBolusAutoResumeUF ) + { + salineBolusAutoResumeUF = FALSE; + currentUFState = UF_RUNNING_STATE; + } } /*********************************************************************//** @@ -226,12 +234,12 @@ { HEPARIN_STATE_T currentHeparinState = getHeparinState(); U32 preStop = getTreatmentParameterU32( TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME ); - U32 minRem = getTreatmentTimeRemainingSecs() / SEC_PER_MIN; + F32 minRem = (F32)getTreatmentTimeRemainingSecs() / (F32)SEC_PER_MIN; F32 bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); F32 hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ); // Do not run syringe pump if no Heparin included in prescription or it was paused or if Heparin should be stopped at this stage of treatment - if ( ( minRem > preStop ) && ( HEPARIN_STATE_STOPPED == currentHeparinState ) ) + if ( ( minRem > (F32)preStop ) && ( HEPARIN_STATE_STOPPED == currentHeparinState ) ) { // If not done with bolus, start/resume bolus if ( ( bolusVol > 0.0 ) && ( getSyringePumpVolumeDelivered() < bolusVol ) ) @@ -241,7 +249,14 @@ // Otherwise, start/resume continuous delivery else { - startHeparinContinuous(); // TODO - check return status + if ( hepRate > 0.0 ) + { + startHeparinContinuous(); // TODO - check return status + } + else + { + setHeparinCompleted(); + } } } else @@ -329,14 +344,14 @@ { rejReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } - else if ( currSalineBolusState != SALINE_BOLUS_STATE_IDLE ) - { - rejReason = REQUEST_REJECT_REASON_SALINE_BOLUS_IN_PROGRESS; - } else if ( totalSalineVolumeDelivered >= (F32)MAX_SALINE_VOLUME_DELIVERED ) { rejReason = REQUEST_REJECT_REASON_SALINE_MAX_VOLUME_REACHED; } + else if ( currSalineBolusState != SALINE_BOLUS_STATE_IDLE ) + { + rejReason = REQUEST_REJECT_REASON_SALINE_BOLUS_IN_PROGRESS; + } else { accept = TRUE; @@ -601,10 +616,10 @@ { DIALYSIS_STATE_T result = DIALYSIS_UF_STATE; U32 preStop = getTreatmentParameterU32( TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME ); - U32 minRem = getTreatmentTimeRemainingSecs() / SEC_PER_MIN; + F32 minRem = (F32)getTreatmentTimeRemainingSecs() / (F32)SEC_PER_MIN; // Stop Heparin delivery if we have reached Heparin pre-stop point - if ( getTreatmentTimeRemainingSecs() < preStop ) + if ( minRem <= (F32)preStop ) { stopSyringePump(); setHeparinCompleted(); @@ -1052,7 +1067,7 @@ LOAD_CELL_ID_T loadCell = ( activeRes == DG_RESERVOIR_1 ? LOAD_CELL_RESERVOIR_1_PRIMARY : LOAD_CELL_RESERVOIR_2_PRIMARY ); F32 latestResVolume = getLoadCellWeight( loadCell ); #ifndef DISABLE_UF_ALARMS - F32 deltaVolume = latestResVolume - resFinalVolume[ activeRes ]; + F32 deltaVolume = latestResVolume - resLastVolume[ activeRes ]; // ensure volume change is not too excessive - indication that load cell was impacted by some kind of shock if ( fabs(deltaVolume) > MAX_ACTIVE_LOAD_CELL_CHANGE_G ) @@ -1126,4 +1141,22 @@ measUFVolumeFromPriorReservoirs += ( resFinalVolume[ inactiveRes ] - resStartVolume[ inactiveRes ] ); } +/*********************************************************************//** + * @brief + * The updateReservoirVolumes function updates the reservoir volumes based + * on new load cell readings. + * @details Inputs: none + * @details Outputs: resCurrVolume[], resLastVolume[] + * @param res1Vol new volume for reservoir 1 + * @param res2Vol new volume for reservoir 2 + * @return none + *************************************************************************/ +void updateReservoirVolumes( F32 res1Vol, F32 res2Vol ) +{ + resLastVolume[ DG_RESERVOIR_1 ] = resCurrVolume[ DG_RESERVOIR_1 ]; + resLastVolume[ DG_RESERVOIR_2 ] = resCurrVolume[ DG_RESERVOIR_2 ]; + resCurrVolume[ DG_RESERVOIR_1 ] = res1Vol; + resCurrVolume[ DG_RESERVOIR_2 ] = res2Vol; +} + /**@}*/ Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -re25708d560989de50b01aa38bba81ea2b5794645 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision e25708d560989de50b01aa38bba81ea2b5794645) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -215,10 +215,10 @@ void transitionToNoCartSelfTests( void ) { F32 const bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); - F32 const hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); + F32 const hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ); #ifndef DISABLE_SYRINGE_PUMP - useHeparin = ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ); + useHeparin = ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ? TRUE : FALSE ); #else useHeparin = FALSE; #endif @@ -337,14 +337,6 @@ *************************************************************************/ void transitionToDrySelfTests() { - F32 const bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); - F32 const hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); - -#ifndef DISABLE_SYRINGE_PUMP - useHeparin = ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ); -#else - useHeparin = FALSE; -#endif currentDrySelfTestsState = DRY_SELF_TESTS_START_STATE; pressureSelfTestBloodPumpRunStartTime = 0; pressureSelfTestNormalizedStartTime = 0; @@ -644,7 +636,7 @@ if ( TRUE == useHeparin ) { - if ( ( FALSE == isSyringePumpHome() ) && ( TRUE == isSyringePumpStopped() ) ) + if ( TRUE == isSyringePumpStopped() ) { retractSyringePump(); } Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r276c2634eab5a641ed7f0a548b31e1bb13ef5477 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 276c2634eab5a641ed7f0a548b31e1bb13ef5477) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -63,7 +63,7 @@ BOOL alarmsToEscalate; ///< Are any active alarms due to escalate (should UI show count down timer?) U32 alarmsEscalatesIn; ///< Time until alarm will escalate (seconds) ALARM_ID_T alarmTop; ///< ID of current top alarm that will drive lamp/audio and UI should be displaying right now - BOOL topAlarmConditionnDetected; ///< Condition for top alarm is still being detected + BOOL topAlarmConditionDetected; ///< Condition for top alarm is still being detected BOOL systemFault; ///< A system fault is active? BOOL stop; ///< We should be in controlled stop right now BOOL noClear; ///< No recovery will be possible @@ -73,6 +73,7 @@ BOOL noNewTreatment; ///< No new treatments may be started even if current treatment is ended BOOL noDialRecirc; ///< No dialysate re-circulation allowed at this time BOOL usrACKRequired; ///< The user must acknowledge top alarm + BOOL noMinimize; ///< Prevent user from minimizing the alarm window BOOL lampOn; ///< The alarm lamp is on } COMP_ALARM_STATUS_T; @@ -115,6 +116,17 @@ ALARM_DATA_TYPES_T dataType; ///< The type of alarm data provided. ALARM_DATAS_T data; ///< The alarm data of specified type. } ALARM_DATA_T; + +/// Payload record structure for the alarm info message. +typedef struct +{ + U32 audioVolume; ///< Audio volume level (1..5) + F32 audioCurrHG; ///< Primary alarm audio current - high gain (mA) + F32 audioCurrLG; ///< Primary alarm audio current - low gain (mA) + F32 backupAudioCurr; ///< Backup alarm audio current (mA) + BOOL safetyShutdown; ///< Safety shutdown activated? (T/F) +} ALARM_INFO_PAYLOAD_T; + #pragma pack(pop) #pragma pack(push, 2) @@ -273,13 +285,28 @@ BOOL doesAlarmStatusIndicateStop( void ); ALARM_PRIORITY_T getCurrentAlarmStatePriority( void ); BOOL isAlarmRecoverable( ALARM_ID_T alarm ); -void setAlarmAudioVolume( U32 volumeLevel ); +void setAlarmAudioVolume( U32 volumeLevel ); +U32 getAlarmAudioVolume( void ); +F32 getAlarmAudioPrimaryHighGainCurrent( void ); +F32 getAlarmAudioPrimaryLowGainCurrent( void ); +F32 getAlarmAudioBackupCurrent( void ); +SELF_TEST_STATUS_T execAlarmAudioSelfTest( void ); BOOL testSetAlarmStateOverride( U32 alarmID, BOOL value ); BOOL testResetAlarmStateOverride( U32 alarmID ); BOOL testSetAlarmStartOverride( U32 alarmID, U32 value ); BOOL testResetAlarmStartOverride( U32 alarmID ); -BOOL testClearAllAlarms( U32 key ); +BOOL testClearAllAlarms( U32 key ); +BOOL testSetAlarmInfoPublishIntervalOverride( U32 ms ); +BOOL testResetAlarmInfoPublishIntervalOverride( void ); +BOOL testSetAlarmAudioVolumeLevelOverride( U32 volume ); +BOOL testResetAlarmAudioVolumeLevelOverride( void ); +BOOL testSetPrimaryAlarmAudioCurrentHGOverride( F32 mA ); +BOOL testResetPrimaryAlarmAudioCurrentHGOverride( void ); +BOOL testSetPrimaryAlarmAudioCurrentLGOverride( F32 mA ); +BOOL testResetPrimaryAlarmAudioCurrentLGOverride( void ); +BOOL testSetBackupAlarmAudioCurrentOverride( F32 mA ); +BOOL testResetBackupAlarmAudioCurrentOverride( void ); /**@}*/ Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r6c0750e3fad58595adcda4bcc26da0032daeff57 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 6c0750e3fad58595adcda4bcc26da0032daeff57) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -20,8 +20,9 @@ #include "sci.h" #include "sys_dma.h" -#include "FPGA.h" #include "Comm.h" +#include "Compatible.h" +#include "FPGA.h" #include "SystemCommMessages.h" #include "Utilities.h" @@ -93,6 +94,12 @@ #define FPGA_ADA_BUBBLE_SELF_TEST_CMD 0x04 ///< Bit for arterial air bubble detector self-test command. #define FPGA_ADV_BUBBLE_SELF_TEST_CMD 0x08 ///< Bit for venous air bubble detector self-test command. +#define FPGA_PBO_TEMP_DIVISOR 2047.0 ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_GAIN 200.0 ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_OFFSET 50.0 ///< Used in conversion of PBo temperature reading to deg C. + +#define FPGA_ALARM_AUDIO_VOLUME_SHIFT 3 ///< Shift alarm audio volume 3 bits to left before writing to register. + // FPGA Sensors Record #pragma pack(push,1) /// Record structure for FPGA header read. @@ -526,9 +533,14 @@ } // If retries for commands exceeds limit, fault - if ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) + if ( ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) +#ifdef _RELEASE_ + || ( fpgaSensorReadings.errorCountProcessor > MAX_COMM_ERROR_RETRIES ) ) +#else + ) +#endif { - activateAlarmNoData( ALARM_ID_HD_FPGA_COMM_TIMEOUT ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_COMM_TIMEOUT, fpgaCommRetryCount, (U32)fpgaSensorReadings.errorCountProcessor ) } // Reset comm flags after processing incoming responses @@ -867,7 +879,23 @@ // Check FPGA reported correct ID if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) { - result = SELF_TEST_STATUS_PASSED; + // Check FPGA compatibility w/ firmware + if ( fpgaHeader.fpgaRevMajor > MIN_HD_FPGA_MAJOR ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + if ( ( MIN_HD_FPGA_MAJOR == fpgaHeader.fpgaRevMajor ) && ( fpgaHeader.fpgaRev >= MIN_HD_FPGA_MINOR ) ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaRevMajor, (U32)fpgaHeader.fpgaRev ) + } + } } else { @@ -1072,6 +1100,7 @@ * 1 - Low priority alarm tone (c e) * 2 - Medium priority alarm tone (c f# c) * 3 - High priority alarm tone (c f# c - c f#) + * 4 - Continuous test tone (e) * @param volumeLevel the level of attenuation to command (0..4) * 4 - 3 dB gain * 3 - 6 dB gain @@ -1080,25 +1109,24 @@ * 0 - 15 dB gain * @return none *************************************************************************/ -void setAlarmAudioState( ALARM_PRIORITY_T state, U32 volumeLevel ) +void setAlarmAudioState( U32 state, U32 volumeLevel ) { - if ( ( state < NUM_OF_ALARM_PRIORITIES ) && ( volumeLevel <= MAX_ALARM_VOLUME_ATTENUATION ) ) - { - U08 audioCmd = (U08)state; + U08 audioCmd = (U08)state; - audioCmd |= ( (U08)volumeLevel << 2 ); + audioCmd |= ( (U08)volumeLevel << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); + + if ( ( state <= NUM_OF_ALARM_PRIORITIES ) && ( volumeLevel <= MAX_ALARM_VOLUME_ATTENUATION ) ) + { fpgaActuatorSetPoints.alarmControl = audioCmd; } else { - U08 audioCmd = (U08)ALARM_PRIORITY_HIGH; - + // S/w fault to indicate issue w/ s/w + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_ALARM_AUDIO_PARAM, (U32)audioCmd ) // Set alarm audio to high priority, max volume for safety since s/w seems to be having trouble setting audio correctly - audioCmd |= ( (U08)MIN_ALARM_VOLUME_ATTENUATION << 2 ); + audioCmd = (U08)ALARM_PRIORITY_HIGH; + audioCmd |= ( (U08)MIN_ALARM_VOLUME_ATTENUATION << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); fpgaActuatorSetPoints.alarmControl = audioCmd; - // S/w fault to indicate issue w/ s/w - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_ALARM_AUDIO_PARAM, volumeLevel ) - } } @@ -1142,30 +1170,82 @@ /*********************************************************************//** * @brief - * The getFPGADialysateFlow function gets the latest dialysate flow reading. + * The getFPGABloodFlowMeterStatus function gets the blood flow meter status. * @details Inputs: fpgaSensorReadings * @details Outputs: none - * @return last dialysate flow reading + * @return current blood flow meter status *************************************************************************/ -F32 getFPGADialysateFlow( void ) +U08 getFPGABloodFlowMeterStatus( void ) { - return fpgaSensorReadings.dialysateFlowLast; + return fpgaSensorReadings.bloodFlowMeterDeviceStatus; } /*********************************************************************//** * @brief - * The getFPGABloodFlowMeterStatus function gets the blood flow meter status. + * The getFPGABloodFlowFastPacketReadCounter function gets the blood + * flow meter fast packet read counter. * @details Inputs: fpgaSensorReadings * @details Outputs: none - * @return current blood flow meter status + * @return current blood flow meter fast packet read counter *************************************************************************/ -U08 getFPGABloodFlowMeterStatus( void ) +U08 getFPGABloodFlowFastPacketReadCounter( void ) { - return fpgaSensorReadings.bloodFlowMeterDeviceStatus; + return fpgaSensorReadings.bloodFlowMeterDataPktCount; } /*********************************************************************//** * @brief + * The getFPGABloodFlowSlowPacketReadCounter function gets the blood + * flow meter slow packet read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter slow packet read counter + *************************************************************************/ +U08 getFPGABloodFlowSlowPacketReadCounter( void ) +{ + return ( fpgaSensorReadings.bloodFlowMeterSlowPktCounts & MASK_OFF_NIBBLE_LSB ) >> SHIFT_BITS_BY_4; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodFlowStatusPacketReadCounter function gets the blood + * flow meter status packet read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter status packet read counter + *************************************************************************/ +U08 getFPGABloodFlowStatusPacketReadCounter( void ) +{ + return ( fpgaSensorReadings.bloodFlowMeterSlowPktCounts & MASK_OFF_NIBBLE_MSB ); +} + +/*********************************************************************//** + * @brief + * The getFPGABloodFlowErrorCounter function gets the blood flow meter + * error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter error counter + *************************************************************************/ +U08 getFPGABloodFlowErrorCounter( void ) +{ + return fpgaSensorReadings.bloodFlowMeterErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialysateFlow function gets the latest dialysate flow reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate flow reading + *************************************************************************/ +F32 getFPGADialysateFlow( void ) +{ + return fpgaSensorReadings.dialysateFlowLast; +} + +/*********************************************************************//** + * @brief * The getFPGADialysateFlowMeterStatus function gets the dialysate flow meter status. * @details Inputs: fpgaSensorReadings * @details Outputs: none @@ -1178,6 +1258,58 @@ /*********************************************************************//** * @brief + * The getFPGADialysateFlowFastPacketReadCounter function gets the dialysate + * flow meter fast packet read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current dialysate flow meter fast packet read counter + *************************************************************************/ +U08 getFPGADialysateFlowFastPacketReadCounter( void ) +{ + return fpgaSensorReadings.dialysateFlowMeterDataPktCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialysateFlowSlowPacketReadCounter function gets the dialysate + * flow meter slow packet read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current dialysate flow meter slow packet read counter + *************************************************************************/ +U08 getFPGADialysateFlowSlowPacketReadCounter( void ) +{ + return ( fpgaSensorReadings.dialysateFlowMeterSlowPckCounts & MASK_OFF_NIBBLE_LSB ) >> SHIFT_BITS_BY_4; +} + +/*********************************************************************//** + * @brief + * The getFPGADialysateFlowStatusPacketReadCounter function gets the dialysate + * flow meter status packet read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current dialysate flow meter status packet read counter + *************************************************************************/ +U08 getFPGADialysateFlowStatusPacketReadCounter( void ) +{ + return ( fpgaSensorReadings.dialysateFlowMeterSlowPckCounts & MASK_OFF_NIBBLE_MSB ); +} + +/*********************************************************************//** + * @brief + * The getFPGADialysateFlowErrorCounter function gets the dialysate flow meter + * error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current dialysate flow meter error counter + *************************************************************************/ +U08 getFPGADialysateFlowErrorCounter( void ) +{ + return fpgaSensorReadings.dialysateFlowMeterErrorCount; +} + +/*********************************************************************//** + * @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 @@ -1196,9 +1328,9 @@ * @brief * The getFPGABloodPumpHallSensorStatus function gets the latest blood pump * hall sensor status. - * Bit 0 - Derived direction of the blood pump motor (0=Fwd, 1=Rev) - * Bit 1 - A direction error was detected in the current hall sensor phase - * Bit 2 - A direction error was detected since the last read of this register + * Bit 7 - Derived direction of the blood pump motor (0=Fwd, 1=Rev) + * Bit 6 - Unused + * Bit 5-0 - Direction error count since power-up (rolls over) * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last blood pump hall sensor status reading. @@ -1228,9 +1360,9 @@ * @brief * The getFPGADialInPumpHallSensorStatus function gets the latest dialysate inlet pump * hall sensor status. - * Bit 0 - Derived direction of the dialyste inlet pump motor (0=Fwd, 1=Rev) - * Bit 1 - A direction error was detected in the current hall sensor phase - * Bit 2 - A direction error was detected since the last read of this register + * Bit 7 - Derived direction of the dialysate inlet pump motor (0=Fwd, 1=Rev) + * Bit 6 - Unused + * Bit 5-0 - Direction error count since power-up (rolls over) * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last dialysate inlet pump hall sensor status reading. @@ -1260,9 +1392,9 @@ * @brief * The getFPGADialOutPumpHallSensorStatus function gets the latest dialysate outlet pump * hall sensor status. - * Bit 0 - Derived direction of the dialysate outlet pump motor (0=Fwd, 1=Rev) - * Bit 1 - A direction error was detected in the current hall sensor phase - * Bit 2 - A direction error was detected since the last read of this register + * Bit 7 - Derived direction of the dialysate outlet pump motor (0=Fwd, 1=Rev) + * Bit 6 - Unused + * Bit 5-0 - Direction error count since power-up (rolls over) * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last dialysate outlet pump hall sensor status reading. @@ -1312,6 +1444,84 @@ /*********************************************************************//** * @brief + * The getFPGABloodPumpOcclusionReadCounter function gets the latest blood + * pump occlusion read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last blood pump occlusion read counter + *************************************************************************/ +U08 getFPGABloodPumpOcclusionReadCounter( void ) +{ + return fpgaSensorReadings.bloodOcclusionReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialInPumpOcclusionReadCounter function gets the latest dialysate + * inlet pump occlusion read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate inlet pump occlusion read counter + *************************************************************************/ +U08 getFPGADialInPumpOcclusionReadCounter( void ) +{ + return fpgaSensorReadings.dialysateInOcclusionReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialOutPumpOcclusionReadCounter function gets the latest dialysate + * outlet pump occlusion read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate outlet pump occlusion read counter + *************************************************************************/ +U08 getFPGADialOutPumpOcclusionReadCounter( void ) +{ + return fpgaSensorReadings.dialysateOutOcclusionReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodPumpOcclusionErrorCounter function gets the latest blood + * pump occlusion error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last blood pump occlusion error counter + *************************************************************************/ +U08 getFPGABloodPumpOcclusionErrorCounter( void ) +{ + return fpgaSensorReadings.bloodOcclusionErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialInPumpOcclusionErrorCounter function gets the latest dialysate + * inlet pump occlusion error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate inlet pump occlusion error counter + *************************************************************************/ +U08 getFPGADialInPumpOcclusionErrorCounter( void ) +{ + return fpgaSensorReadings.dialysateInOcclusionErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialOutPumpOcclusionErrorCounter function gets the latest dialysate + * outlet pump occlusion error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate outlet pump occlusion error counter + *************************************************************************/ +U08 getFPGADialOutPumpOcclusionErrorCounter( void ) +{ + return fpgaSensorReadings.dialysateOutOcclusionErrorCount; +} + +/*********************************************************************//** + * @brief * The getFPGAArterialPressure function gets the latest arterial pressure reading. * High byte indicates alarm status for ADC channel. * Low 24-bits are channel reading. Subtract 2^23 from low 24 bits to get @@ -1327,7 +1537,7 @@ /*********************************************************************//** * @brief - * The getFPGAVenousPressure function gets the venous arterial pressure reading. + * The getFPGAVenousPressure function gets the latest venous pressure reading. * The high 2 bits are status bits: 00=ok, 01=cmd mode, 10=stale data, 11=diag * The low 14 bits are data. Zero is at 1638. Values above are positive, * below are negative. @@ -1342,6 +1552,34 @@ /*********************************************************************//** * @brief + * The getFPGAVenousPressureTemperature function gets the latest venous pressure + * sensor temperature reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last venous pressure sensor temperature reading + *************************************************************************/ +F32 getFPGAVenousPressureTemperature( void ) +{ + F32 result = ( (F32)fpgaSensorReadings.venousTemperature / FPGA_PBO_TEMP_DIVISOR ) * FPGA_PBO_TEMP_GAIN - FPGA_PBO_TEMP_OFFSET; + + return result; +} + +/*********************************************************************//** + * @brief + * The getFPGAVenousPressureReadCounter function gets the latest venous pressure + * sensor read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last venous pressure sensor read counter + *************************************************************************/ +U08 getFPGAVenousPressureReadCounter( void ) +{ + return fpgaSensorReadings.venousReadCounter; +} + +/*********************************************************************//** + * @brief * The setFPGASyringePumpControlFlags function sets the syringe pump control * register per given bit flags. * @details Inputs: none Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rcaaba168f0caee9420acc13ce5287451483a58cd -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision caaba168f0caee9420acc13ce5287451483a58cd) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -52,16 +52,24 @@ void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ); -void setAlarmAudioState( ALARM_PRIORITY_T state, U32 volumeLevel ); +void setAlarmAudioState( U32 state, U32 volumeLevel ); F32 getFPGABloodFlowSignalStrength( void ); F32 getFPGADialysateFlowSignalStrength( void ); F32 getFPGABloodFlow( void ); -F32 getFPGADialysateFlow( void ); - U08 getFPGABloodFlowMeterStatus( void ); +U08 getFPGABloodFlowFastPacketReadCounter( void ); +U08 getFPGABloodFlowSlowPacketReadCounter( void ); +U08 getFPGABloodFlowStatusPacketReadCounter( void ); +U08 getFPGABloodFlowErrorCounter( void ); + +F32 getFPGADialysateFlow( void ); U08 getFPGADialysateFlowMeterStatus( void ); +U08 getFPGADialysateFlowFastPacketReadCounter( void ); +U08 getFPGADialysateFlowSlowPacketReadCounter( void ); +U08 getFPGADialysateFlowStatusPacketReadCounter( void ); +U08 getFPGADialysateFlowErrorCounter( void ); U16 getFPGABloodPumpHallSensorCount( void ); U08 getFPGABloodPumpHallSensorStatus( void ); @@ -72,9 +80,17 @@ U32 getFPGAArterialPressure( void ); U16 getFPGAVenousPressure( void ); +F32 getFPGAVenousPressureTemperature( void ); +U08 getFPGAVenousPressureReadCounter( void ); U16 getFPGABloodPumpOcclusion( void ); U16 getFPGADialInPumpOcclusion( void ); U16 getFPGADialOutPumpOcclusion( void ); +U08 getFPGABloodPumpOcclusionReadCounter( void ); +U08 getFPGADialInPumpOcclusionReadCounter( void ); +U08 getFPGADialOutPumpOcclusionReadCounter( void ); +U08 getFPGABloodPumpOcclusionErrorCounter( void ); +U08 getFPGADialInPumpOcclusionErrorCounter( void ); +U08 getFPGADialOutPumpOcclusionErrorCounter( void ); void setFPGASyringePumpControlFlags( U08 bitFlags ); void setFPGASyringePumpADCandDACControlFlags( U08 bitFlags ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r276c2634eab5a641ed7f0a548b31e1bb13ef5477 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 276c2634eab5a641ed7f0a548b31e1bb13ef5477) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -943,8 +943,10 @@ if ( TRUE == didTimeout( timeOfLastDGCheckIn, DG_COMM_TIMEOUT_IN_MS ) ) { +#ifndef RUN_WITHOUT_DG activateAlarmNoData( ALARM_ID_DG_COMM_TIMEOUT ); dgIsCommunicating = FALSE; +#endif } } } @@ -1207,6 +1209,10 @@ handleHeparinCommandRequest( message ); break; + case MSG_ID_UI_SET_ALARM_AUDIO_VOLUME_LEVEL_CMD: + handleAlarmAudioVolumeSetCmd( message ); + break; + case MSG_ID_UI_SET_UF_VOLUME_PARAMETER: handleUFVolumeSetRequest( message ); break; @@ -1271,36 +1277,24 @@ handleDGCmdResp( message ); break; - case MSG_ID_TESTER_LOGIN_REQUEST: - handleTesterLogInRequest( message ); + case MSG_ID_UI_HD_SET_RTC_REQUEST: + handleUIClockSyncRequest( message ); break; - case MSG_ID_HD_SET_CALIBRATION_RECORD: - handleSetHDCalibrationRecord( message ); + case MSG_ID_DG_POST_FINAL_TEST_RESULT: + handleDGPOSTFinalResult( message ); break; - case MSG_ID_HD_GET_CALIBRATION_RECORD: - handleGetHDCalibrationRecord( message ); + case MSG_ID_UI_POST_FINAL_TEST_RESULT: + handleUIPOSTFinalResult( message ); break; - case MSG_ID_HD_SET_SYSTEM_RECORD: - handleSetHDSystemRecord( message ); + case MSG_ID_TESTER_LOGIN_REQUEST: + handleTesterLogInRequest( message ); break; - case MSG_ID_HD_GET_SYSTEM_RECORD: - handleGetHDSystemRecord( message ); - break; - - case MSG_ID_HD_GET_SERVICE_RECORD: - handleGetHDServiceRecord( message ); - break; - - case MSG_ID_HD_SET_SERVICE_RECORD: - handleSetHDServiceRecord( message ); - break; - default: - // Unrecognized message ID received - ignore + // Un-recognized or un-handled message ID received - ignore break; } @@ -1603,6 +1597,74 @@ handleTestSyringePumpMeasuredVolumeOverrideRequest( message ); break; + case MSG_ID_HD_MONITORED_VOLTAGES_SEND_INTERVAL_OVERRIDE: + handleTestMonitoredVoltagesSendIntervalOverrideRequest( message ); + break; + + case MSG_ID_HD_MONITORED_VOLTAGES_OVERRIDE: + handleTestMonitoredVoltageOverrideRequest( message ); + break; + + case MSG_ID_HD_ALARM_INFO_SEND_INTERVAL_OVERRIDE: + handleTestAlarmInfoSendIntervalOverrideRequest( message ); + break; + + case MSG_ID_HD_ALARM_AUDIO_VOLUME_LEVEL_OVERRIDE: + handleTestAlarmAudioVolumeOverrideRequest( message ); + break; + + case MSG_ID_HD_ALARM_AUDIO_CURRENT_HG_OVERRIDE: + handleTestAlarmAudioCurrentHgOverrideRequest( message ); + break; + + case MSG_ID_HD_ALARM_AUDIO_CURRENT_LG_OVERRIDE: + handleTestAlarmAudioCurrentLgOverrideRequest( message ); + break; + + case MSG_ID_HD_ALARM_BACKUP_AUDIO_CURRENT_OVERRIDE: + handleTestAlarmBackupAudioCurrentOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_STATUS_OVERRIDE: + handleTestSyringePumpStatusOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_ENCODER_STATUS_OVERRIDE: + handleTestSyringePumpEncoderStatusOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_ADC_DAC_STATUS_OVERRIDE: + handleTestSyringePumpADCandDACStatusOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_ADC_READ_COUNTER_OVERRIDE: + handleTestSyringePumpADCReadCtrOverrideRequest( message ); + break; + + case MSG_ID_HD_SET_CALIBRATION_RECORD: + handleSetHDCalibrationRecord( message ); + break; + + case MSG_ID_HD_GET_CALIBRATION_RECORD: + handleGetHDCalibrationRecord( message ); + break; + + case MSG_ID_HD_SET_SYSTEM_RECORD: + handleSetHDSystemRecord( message ); + break; + + case MSG_ID_HD_GET_SYSTEM_RECORD: + handleGetHDSystemRecord( message ); + break; + + case MSG_ID_HD_GET_SERVICE_RECORD: + handleGetHDServiceRecord( message ); + break; + + case MSG_ID_HD_SET_SERVICE_RECORD: + handleSetHDServiceRecord( message ); + break; + default: // Unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r276c2634eab5a641ed7f0a548b31e1bb13ef5477 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 276c2634eab5a641ed7f0a548b31e1bb13ef5477) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -497,6 +497,38 @@ return result; } +/*********************************************************************//** + * @brief + * The sendAlarmAudioVolumeSetResponse function constructs an alarm audio + * volume set request response to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Alarm audio volume set. + * @param accepted flag indicating whether request was accepted + * @param rejReason rejection reason code + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendAlarmAudioVolumeSetResponse( U32 accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_ALARM_AUDIO_VOLUME_SET_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) * 2; + + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + /*********************************************************************//** * @brief * The sendTreatmentParamsRangesToUI function constructs a treatment parameter @@ -1110,27 +1142,72 @@ * The handleDGCmdResp function handles a DG command response message. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. - * @param messagePtr pointer to the message to handle. + * @param message pointer to the message to handle. * @return none *************************************************************************/ -void handleDGCmdResp( MESSAGE_T *messagePtr ) +void handleDGCmdResp( MESSAGE_T *message ) { BOOL result = FALSE; - if ( messagePtr->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) + if ( message->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) { DG_CMD_RESPONSE_T dgCmdResponse; result = TRUE; - memcpy( &dgCmdResponse, messagePtr->payload, sizeof( DG_CMD_RESPONSE_T ) ); + memcpy( &dgCmdResponse, message->payload, sizeof( DG_CMD_RESPONSE_T ) ); handleDGCommandResponse( &dgCmdResponse ); } - sendAckResponseMsg( (MSG_ID_T)messagePtr->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); } /*********************************************************************//** * @brief + * The handleUIClockSyncRequest function handles a UI clock sync message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleUIClockSyncRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 rejReason = REQUEST_REJECT_REASON_NONE; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U32 epoch; + + memcpy( &epoch, message->payload, sizeof( U32 ) ); + result = setRTCEpoch( epoch ); + if ( FALSE == result ) + { + rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; + } + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Create a response message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_UI_SET_RTC_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + memcpy( payloadPtr, &result, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief * The handleDGOpMode function handles a DG broadcast of its current mode. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. @@ -1236,14 +1313,43 @@ payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_TO_ESCALATE) : 0 ); payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_SILENCED) : 0 ); payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_LAMP_ON) : 0 ); - payload.alarmsFlags |= ( almStatus.topAlarmConditionnDetected ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION) : 0 ); + payload.alarmsFlags |= ( almStatus.noMinimize ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_MINIMIZE) : 0 ); + payload.alarmsFlags |= ( almStatus.topAlarmConditionDetected ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION) : 0 ); memcpy( payloadPtr, &payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_ALARM, ACK_NOT_REQUIRED ); return result; +} + +/*********************************************************************//** + * @brief + * The broadcastAlarmInfo function constructs an alarm information msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: alarm information msg constructed and queued. + * @param data alarm information record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAlarmInfo( ALARM_INFO_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_ALARM_INFORMATION; + msg.hdr.payloadLen = sizeof( ALARM_INFO_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( ALARM_INFO_PAYLOAD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } /*********************************************************************//** @@ -1507,6 +1613,34 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); return result; +} + +/*********************************************************************//** + * @brief + * The broadcastVoltagesData function constructs a monitored voltages data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: monitored voltages data msg constructed and queued. + * @param data Latest monitored voltage values. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastVoltagesData( VOLTAGES_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_VOLTAGES_DATA; + msg.hdr.payloadLen = sizeof( VOLTAGES_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( VOLTAGES_DATA_PAYLOAD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } /*********************************************************************//** @@ -2335,14 +2469,24 @@ *************************************************************************/ void handleUIAlarmSilenceRequest( MESSAGE_T *message ) { +#ifndef TEMP_UI_ALARM_SILENCE_FIX if ( message->hdr.payloadLen == sizeof( U32 ) ) +#else + if ( message->hdr.payloadLen == sizeof( U08 ) ) +#endif { U08 *payloadPtr = message->payload; +#ifndef TEMP_UI_ALARM_SILENCE_FIX U32 cmd; memcpy( &cmd, payloadPtr, sizeof( U32 ) ); + signalAlarmSilence( (ALARM_SILENCE_CMD_T)cmd ); +#else + U08 cmd; + memcpy( &cmd, payloadPtr, sizeof( U08 ) ); signalAlarmSilence( (ALARM_SILENCE_CMD_T)cmd ); +#endif } else { @@ -2378,6 +2522,117 @@ } } +/*********************************************************************//** + * @brief + * The sendPOSTTestResult function constructs an HD POST test result message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD POST test result msg constructed and queued. + * @param test ID of HD POST test + * @param passed TRUE if POST test passed, FALSE if not + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPOSTTestResult( HD_POST_STATE_T test, BOOL passed ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 testID = (U32)test; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_POST_SINGLE_TEST_RESULT; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &passed, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &testID, sizeof( U32) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); // TODO - make ack required when UI ready + + return result; + +} + +/*********************************************************************//** + * @brief + * The sendPOSTFinalResult function constructs an HD POST final result message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD POST final result msg constructed and queued. + * @param passed TRUE if HD POST passed, FALSE if not + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPOSTFinalResult( BOOL passed ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_POST_FINAL_TEST_RESULT; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &passed, sizeof( BOOL ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); // TODO - make ack required when UI ready + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGPOSTFinalResult function handles a DG POST final result message. + * @details Inputs: none + * @details Outputs: DG POST final result delivered to InitPOST mode. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGPOSTFinalResult( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( BOOL ) ) + { + U08 *payloadPtr = message->payload; + BOOL passed; + + memcpy( &passed, payloadPtr, sizeof( BOOL ) ); + + // TODO - handle DG POST final result + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleUIPOSTFinalResult function handles a UI POST final result message. + * @details Inputs: none + * @details Outputs: UI POST final result delivered to InitPOST mode. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIPOSTFinalResult( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( BOOL ) ) + { + U08 *payloadPtr = message->payload; + BOOL passed; + + memcpy( &passed, payloadPtr, sizeof( BOOL ) ); + + // TODO - handle UI POST final result + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + /*********************************************************************//** * @brief * The handleOffButtonConfirmMsgFromUI function handles a response to an @@ -2938,6 +3193,31 @@ /*********************************************************************//** * @brief + * The handleAlarmAudioVolumeSetCmd function handles a alarm audio volume + * set request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmAudioVolumeSetCmd( MESSAGE_T *message ) +{ + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 payload; + + memcpy( &payload, &message->payload[0], sizeof( U32 ) ); + + setAlarmAudioVolume( payload ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief * The handleSalineBolusRequest function handles a saline bolus request * message from the UI. * @details Inputs: none @@ -5734,4 +6014,356 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleTestMonitoredVoltagesSendIntervalOverrideRequest function handles a + * request to override the monitored HD voltages data publication interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestMonitoredVoltagesSendIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetVoltagesDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetVoltagesDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestMonitoredVoltageOverrideRequest function handles a + * request to override the monitored HD voltage override. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestMonitoredVoltageOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetLineLevelOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetLineLevelOverride( payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmInfoSendIntervalOverrideRequest function handles a + * request to override the HD alarm information broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmInfoSendIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetAlarmInfoPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetAlarmInfoPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmAudioVolumeOverrideRequest function handles a + * request to override the alarm audio volume level. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmAudioVolumeOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetAlarmAudioVolumeLevelOverride( payload.state.u32 ); + } + else + { + result = testResetAlarmAudioVolumeLevelOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmAudioCurrentHgOverrideRequest function handles a + * request to override the alarm audio (high gain) current. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmAudioCurrentHgOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetPrimaryAlarmAudioCurrentHGOverride( payload.state.f32 ); + } + else + { + result = testResetPrimaryAlarmAudioCurrentHGOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmAudioCurrentLgOverrideRequest function handles a + * request to override the alarm audio (low gain) current. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmAudioCurrentLgOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetPrimaryAlarmAudioCurrentLGOverride( payload.state.f32 ); + } + else + { + result = testResetPrimaryAlarmAudioCurrentLGOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmBackupAudioCurrentOverrideRequest function handles a + * request to override the backup alarm audio current. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmBackupAudioCurrentOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetBackupAlarmAudioCurrentOverride( payload.state.f32 ); + } + else + { + result = testResetBackupAlarmAudioCurrentOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpStatusOverrideRequest function handles a + * request to override the syringe pump status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpStatusOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpStatus( payload.state.u32 ); + } + else + { + result = testResetSyringePumpStatus(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpEncoderStatusOverrideRequest function handles a + * request to override the syringe pump encoder status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpEncoderStatusOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpEncoderStatus( payload.state.u32 ); + } + else + { + result = testResetSyringePumpEncoderStatus(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpADCandDACStatusOverrideRequest function handles a + * request to override the syringe pump ADC & DAC status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpADCandDACStatusOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpADCandDACStatus( payload.state.u32 ); + } + else + { + result = testResetSyringePumpADCandDACStatus(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpADCReadCtrOverrideRequest function handles a + * request to override the syringe pump ADC read counter. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpADCReadCtrOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpADCReadCounter( payload.state.u32 ); + } + else + { + result = testResetSyringePumpADCReadCounter(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r276c2634eab5a641ed7f0a548b31e1bb13ef5477 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 276c2634eab5a641ed7f0a548b31e1bb13ef5477) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -39,6 +39,7 @@ #include "Rinseback.h" #include "SyringePump.h" #include "Valves.h" +#include "Voltages.h" /** * @defgroup SystemCommMessages SystemCommMessages @@ -81,6 +82,18 @@ // MSG_ID_ALARM_CONDITION_CLEARED void handleAlarmUserAction( MESSAGE_T *message ); +// MSG_ID_HD_POST_SINGLE_TEST_RESULT +BOOL sendPOSTTestResult( HD_POST_STATE_T test, BOOL passed ); + +// MSG_ID_HD_POST_FINAL_TEST_RESULT +BOOL sendPOSTFinalResult( BOOL passed ); + +// MSG_ID_DG_POST_FINAL_TEST_RESULT +void handleDGPOSTFinalResult( MESSAGE_T *message ); + +// MSG_ID_UI_POST_FINAL_TEST_RESULT +void handleUIPOSTFinalResult( MESSAGE_T *message ); + // MSG_ID_LOAD_CELL_READINGS void handleLoadCellReadingsFromDG( MESSAGE_T *message ); @@ -174,6 +187,12 @@ // MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ); +// MSG_ID_UI_SET_ALARM_AUDIO_VOLUME_LEVEL_CMD +void handleAlarmAudioVolumeSetCmd( MESSAGE_T *message ); + +// MSG_ID_HD_ALARM_AUDIO_VOLUME_SET_RESPONSE +BOOL sendAlarmAudioVolumeSetResponse( U32 accepted, U32 rejReason ); + // MSG_ID_UI_SAMPLE_WATER_CMD void handleSampleWaterCmd( MESSAGE_T *message ); @@ -274,6 +293,9 @@ // MSG_ID_DG_COMMAND_RESPONSE void handleDGCmdResp( MESSAGE_T *messagePtr ); + +// MSG_ID_UI_HD_SET_RTC_REQUEST: +void handleUIClockSyncRequest( MESSAGE_T *message ); // MSG_ID_DG_OP_MODE void handleDGOpMode( MESSAGE_T *message ); @@ -284,7 +306,10 @@ BOOL broadcastAccelData( F32 x, F32 y, F32 z, F32 xm, F32 ym, F32 zm, F32 xt, F32 yt, F32 zt ); // MSG_ID_ALARM_STATUS -BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ); +BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ); + +// MSG_ID_HD_ALARM_INFORMATION +BOOL broadcastAlarmInfo( ALARM_INFO_PAYLOAD_T data ); // MSG_ID_ALARM_TRIGGERED BOOL broadcastAlarmTriggered( U32 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ); @@ -315,6 +340,9 @@ // MSG_ID_PRESSURE_OCCLUSION_DATA BOOL broadcastPresOcclData( PRESSURE_OCCLUSION_DATA_T data ); + +// MSG_ID_HD_VOLTAGES_DATA +BOOL broadcastVoltagesData( VOLTAGES_DATA_PAYLOAD_T data ); // MSG_ID_RTC_EPOCH BOOL broadcastRTCEpoch( U32 epoch ); @@ -550,9 +578,6 @@ void handleSetHDValvePWMOverrideRequest( MESSAGE_T *message ); #endif -// MSG_ID_HD_SET_PARAMETER_TREATMENT_PARAMETER -void handleTestSetTreatmentParameter( MESSAGE_T *message ); - // MSG_ID_HD_SOFTWARE_RESET_REQUEST void handleHDSoftwareResetRequest( MESSAGE_T *message ); @@ -646,6 +671,39 @@ // MSG_ID_HD_SYRINGE_PUMP_MEASURED_VOLUME_OVERRIDE: void handleTestSyringePumpMeasuredVolumeOverrideRequest( MESSAGE_T *message ); +// MSG_ID_HD_MONITORED_VOLTAGES_SEND_INTERVAL_OVERRIDE +void handleTestMonitoredVoltagesSendIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_MONITORED_VOLTAGES_OVERRIDE +void handleTestMonitoredVoltageOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_ALARM_INFO_SEND_INTERVAL_OVERRIDE +void handleTestAlarmInfoSendIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_ALARM_AUDIO_VOLUME_LEVEL_OVERRIDE +void handleTestAlarmAudioVolumeOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_ALARM_AUDIO_CURRENT_HG_OVERRIDE +void handleTestAlarmAudioCurrentHgOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_ALARM_AUDIO_CURRENT_LG_OVERRIDE +void handleTestAlarmAudioCurrentLgOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_ALARM_BACKUP_AUDIO_CURRENT_OVERRIDE +void handleTestAlarmBackupAudioCurrentOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_STATUS_OVERRIDE +void handleTestSyringePumpStatusOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_ENCODER_STATUS_OVERRIDE +void handleTestSyringePumpEncoderStatusOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_ADC_DAC_STATUS_OVERRIDE +void handleTestSyringePumpADCandDACStatusOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_ADC_READ_COUNTER_OVERRIDE +void handleTestSyringePumpADCReadCtrOverrideRequest( MESSAGE_T *message ); + /**@}*/ #endif Index: firmware/source/sys_main.c =================================================================== diff -u -r9f2e4e5933d2e418b75f91e3db5df69c71878d43 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/source/sys_main.c (.../sys_main.c) (revision 9f2e4e5933d2e418b75f91e3db5df69c71878d43) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -68,6 +68,8 @@ #include "AlarmLamp.h" #include "Battery.h" #include "BloodFlow.h" +#include "BloodLeak.h" +#include "Bubble.h" #include "Buttons.h" #include "CommBuffers.h" #include "CPLD.h" @@ -187,7 +189,10 @@ initWatchdogMgmt(); // Initialize monitors initAccel(); + initBloodLeak(); + initBubbles(); initButtons(); + initFluidLeak(); initPresOccl(); initVoltagesMonitor(); // Initialize controllers @@ -198,7 +203,6 @@ initDialOutFlow(); initSyringePump(); initValves(); - initFluidLeak(); // Initialize modes initOperationModes(); // Initialize async interrupt handlers