Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r5e2d30dcbd02f5eb737aee7ec45c63d868daf252 -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 5e2d30dcbd02f5eb737aee7ec45c63d868daf252) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -240,7 +240,7 @@ bpMotorSpeedCalcIdx = 0; for ( i = 0; i < BP_SPEED_CALC_BUFFER_LEN; i++ ) { - bpLastMotorHallSensorCounts[ i ] = 0; + bpLastMotorHallSensorCounts[ i ] = getFPGABloodPumpHallSensorCount(); } resetBloodPumpRotorCount(); @@ -1086,7 +1086,9 @@ ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMP_DIRECTION_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) ) { lastBloodPumpDirectionCount = dirErrorCnt; +#ifndef DISABLE_PUMP_DIRECTION_CHECKS SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_BLOOD_PUMP ) +#endif } bpMCDir = ( getMeasuredBloodPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); bpDir = ( getMeasuredBloodPumpSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r5e2d30dcbd02f5eb737aee7ec45c63d868daf252 -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 5e2d30dcbd02f5eb737aee7ec45c63d868daf252) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -237,7 +237,7 @@ dipMotorSpeedCalcIdx = 0; for ( i = 0; i < DIP_SPEED_CALC_BUFFER_LEN; i++ ) { - dipLastMotorHallSensorCounts[ i ] = 0; + dipLastMotorHallSensorCounts[ i ] = getFPGADialInPumpHallSensorCount(); } // Initialize dialysate inlet flow PI controller @@ -1020,7 +1020,9 @@ ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMP_DIRECTION_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) ) { lastDialInPumpDirectionCount = dirErrorCnt; +#ifndef DISABLE_PUMP_DIRECTION_CHECKS SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_DIALYSATE_INLET_PUMP ) +#endif } dipMCDir = ( getMeasuredDialInPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r5e2d30dcbd02f5eb737aee7ec45c63d868daf252 -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 5e2d30dcbd02f5eb737aee7ec45c63d868daf252) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -233,7 +233,7 @@ dopMotorSpeedCalcIdx = 0; for ( i = 0; i < DOP_SPEED_CALC_BUFFER__LEN; i++ ) { - dopLastMotorHallSensorCounts[ i ] = 0; + dopLastMotorHallSensorCounts[ i ] = getFPGADialOutPumpHallSensorCount(); } dopMeasuredRate = 0.0; @@ -933,7 +933,9 @@ if ( lastDialOutPumpDirectionCount != dirErrorCnt ) { lastDialOutPumpDirectionCount = dirErrorCnt; +#ifndef DISABLE_PUMP_DIRECTION_CHECKS SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_DIALYSATE_OUTLET_PUMP ) +#endif } dopMCDir = ( getMeasuredDialOutPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r5e2d30dcbd02f5eb737aee7ec45c63d868daf252 -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 5e2d30dcbd02f5eb737aee7ec45c63d868daf252) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -67,6 +67,7 @@ #define PSI_TO_MMHG ( 51.7149 ) ///< Conversion factor for converting PSI to mmHg. +// The new arterial pressure sensor is the same as the venous pressure sensor #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). @@ -78,11 +79,12 @@ #define ARTERIAL_PRESSURE_STALE_DATA 2 ///< Arterial pressure status bits indicate data is stale (no new data since last fpga read). #define ARTERIAL_PRESSURE_DIAG_CONDITION 3 ///< Arterial pressure status bits diagnostic condition (alarm). -#define OCCLUSION_THRESHOLD_OFFSET 10000 ///< Threshold offset. Combined with initial reading after cartridge install, a threshold is derived above which an occlusion is detected. -#define OCCLUSION_CLEAR_THRESHOLD_OFFSET 6000 ///< Threshold offset. Combined with initial reading after cartridge install, a threshold is derived below which an occlusion is cleared. +#define OCCLUSION_THRESHOLD_OFFSET 4000 ///< Threshold offset. Combined with initial reading after cartridge install, a threshold is derived above which an occlusion is detected. +#define OCCLUSION_CLEAR_THRESHOLD_OFFSET 4000 ///< Threshold offset. Combined with initial reading after cartridge install, a threshold is derived below which an occlusion is cleared. #define CARTRIDGE_LOADED_THRESHOLD 5000 ///< Threshold above which a cartridge is considered loaded. -/// Occlusion sensors maximum pressure reading limit when cartridge is considered loaded. -#define OCCLUSION_CARTRIDGE_LOADED_PRESSURE_READING_MAX 20000 +#define MIN_OCCLUSION_COUNTS 2000 ///< Minimum occlusion sensor reading for range check. +#define MAX_OCCLUSION_COUNTS 32766 ///< Maximum occlusion sensor reading for range check. +#define OCCLUSION_CARTRIDGE_LOADED_PRESSURE_READING_MAX 26000 ///< Occlusion sensors maximum pressure reading limit when cartridge is considered loaded. #define EMPTY_SALINE_BAG_THRESHOLD_MMHG -300.0 ///< Threshold below which the saline bag is considered empty (in mmHg). TODO - get real threshold from Systems static const U32 EMPTY_SALINE_BAG_PERSISTENCE = ( 250 / TASK_GENERAL_INTERVAL ); ///< Time that saline bag looks empty before saying it is empty. @@ -454,7 +456,7 @@ } else { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_ARTERIAL_PRESSURE_READ_TIMEOUT_ERROR, (U32)artErrorCtr ); + //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_ARTERIAL_PRESSURE_READ_TIMEOUT_ERROR, (U32)artErrorCtr ); } // Record arterial pressure sensor read counter for next time around lastArterialPressureReadCtr = artReadCtr; @@ -555,7 +557,9 @@ { F32 artPres = getFilteredArterialPressure(); +#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ARTERIAL_PRESSURE_CHECK ) != SW_CONFIG_ENABLE_VALUE ) +#endif { // Check arterial pressure is in range if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_ARTERIAL_PRESSURE_OUT_OF_RANGE, @@ -666,12 +670,13 @@ *************************************************************************/ static void checkOcclusions( void ) { - U32 bpOccl = getMeasuredBloodPumpOcclusion(); + U32 bpOccl = getMeasuredBloodPumpOcclusion(); + BOOL outOfRange = ( bpOccl < MIN_OCCLUSION_COUNTS || bpOccl > MAX_OCCLUSION_COUNTS ? TRUE : FALSE ); if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRESSURE_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) { // Range check occlusion sensor - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_OCCLUSION_OUT_OF_RANGE, bpOccl < MIN_OCCLUSION_COUNTS ) ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_OCCLUSION_OUT_OF_RANGE, outOfRange ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BP_OCCLUSION_OUT_OF_RANGE, bpOccl ); } @@ -682,7 +687,7 @@ signalBloodPumpHardStop(); // Stop pump immediately SET_ALARM_WITH_1_U32_DATA( ALARM_ID_OCCLUSION_BLOOD_PUMP, bpOccl ) } - else if ( bpOccl < ( OCCLUSION_CLEAR_THRESHOLD_OFFSET + bloodPumpOcclusionAfterCartridgeInstall ) ) + else if ( bpOccl <= ( OCCLUSION_CLEAR_THRESHOLD_OFFSET + bloodPumpOcclusionAfterCartridgeInstall ) ) { clearAlarmCondition( ALARM_ID_OCCLUSION_BLOOD_PUMP ); } Index: firmware/App/HDCommon.h =================================================================== diff -u -ra6c5c93afcfb3b64c8ddd937911b1d6a8c9efcc9 -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/HDCommon.h (.../HDCommon.h) (revision a6c5c93afcfb3b64c8ddd937911b1d6a8c9efcc9) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -10,8 +10,8 @@ * @author (last) Dara Navaei * @date (last) 04-Jan-2022 * -* @author (original) Sean -* @date (original) 27-Feb-2020 +* @author (original) Sean +* @date (original) 27-Feb-2020 * ***************************************************************************/ @@ -25,7 +25,7 @@ #define HD_VERSION_MAJOR 0 #define HD_VERSION_MINOR 6 #define HD_VERSION_MICRO 0 -#define HD_VERSION_BUILD 31 +#define HD_VERSION_BUILD 225 // ********** development build switches ********** @@ -38,6 +38,7 @@ // #define RUN_WITHOUT_DG 1 // Run HD w/o DG // #define SIMULATE_UI 1 // Build w/o requirement that UI be there // #define TASK_TIMING_OUTPUT_ENABLED 1 // Re-purposes alarm lamp pins for task timing + #define DISABLE_BATT_COMM 1 // Disable battery communication // #define READ_FPGA_ASYNC_DATA 1 // Test build reads non-priority register page every other time // #define DISABLE_FPGA_COUNTER_CHECKS 1 // Disable alarms associated with FPGA read/error counters Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r5e2d30dcbd02f5eb737aee7ec45c63d868daf252 -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 5e2d30dcbd02f5eb737aee7ec45c63d868daf252) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -254,22 +254,13 @@ // 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 > (F32)preStop ) && ( HEPARIN_STATE_STOPPED == currentHeparinState ) ) { - // If not done with bolus, start/resume bolus - if ( ( bolusVol > 0.0 ) && ( getSyringePumpVolumeDelivered() < bolusVol ) ) + if ( hepRate > 0.0 ) { - startHeparinBolus(); // TODO - check return status or have function trigger alarm if not successful + startHeparinContinuous(); // TODO - check return status } - // Otherwise, start/resume continuous delivery else { - if ( hepRate > 0.0 ) - { - startHeparinContinuous(); // TODO - check return status - } - else - { - setHeparinCompleted(); - } + setHeparinCompleted(); } } else Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r1507b3d6f58c87107d96a9da744423d06a70057c -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 1507b3d6f58c87107d96a9da744423d06a70057c) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -46,11 +46,9 @@ // ********** private definitions ********** #define MAX_TREATMENT_TIME_MINUTES ( 8 * MIN_PER_HOUR ) ///< Maximum treatment time (in minutes). -#ifndef ALLOW_1_MIN_TREATMENT_DURATION + #define MIN_TREATMENT_TIME_MINUTES ( 1 * MIN_PER_HOUR ) ///< Minimum treatment time (in minutes). -#else -#define MIN_TREATMENT_TIME_MINUTES ( 1 ) ///< Minimum treatment time (in minutes). -#endif + #define MAX_DIALYSATE_VOLUME_ML ( 150 * ML_PER_LITER ) ///< Maximum dialysate volume (in mL). #define USER_CONFIRM_CHANGE_TIMEOUT_MS ( 60 * MS_PER_SECOND ) ///< Require user to confirm UF volume change within this time. @@ -135,6 +133,7 @@ static void resetAlarmSignalFlags( void ); static void broadcastTreatmentSettingsRanges( void ); static void broadcastTreatmentPeriodicData(); +static U32 getTreatmentTimeInMinutes( void ); static TREATMENT_STATE_T handleTreatmentStartState( void ); static TREATMENT_STATE_T handleTreatmentBloodPrimeState( void ); static TREATMENT_STATE_T handleTreatmentDialysisState( void ); @@ -972,7 +971,7 @@ // Check if we are in an appropriate treatment state for settings adjustment if ( ( MODE_TREA == currMode ) && ( currentTreatmentState > TREATMENT_START_STATE ) && ( currentTreatmentState < TREATMENT_END_STATE ) && - ( CALC_ELAPSED_TREAT_TIME_IN_MIN() < treatmentTime ) && ( treatmentTime >= MIN_TREATMENT_TIME_MINUTES ) ) + ( CALC_ELAPSED_TREAT_TIME_IN_MIN() < treatmentTime ) && ( treatmentTime >= getTreatmentTimeInMinutes() ) ) { F32 uFVolume; U32 dialVolume = getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ) * treatmentTime; // In mL @@ -1016,7 +1015,7 @@ { rejectReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } - else if ( treatmentTime < MIN_TREATMENT_TIME_MINUTES ) + else if ( treatmentTime < getTreatmentTimeInMinutes() ) { rejectReason = REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_MINIMUM; } @@ -1094,7 +1093,7 @@ pendingUFRateChange = 0.0; } // Verify treatment duration change would be valid (leave zero if not valid - UI will disable option) - if ( ( trtTime <= MAX_TREATMENT_TIME_MINUTES ) && ( trtTime >= MIN_TREATMENT_TIME_MINUTES ) && + if ( ( trtTime <= MAX_TREATMENT_TIME_MINUTES ) && ( trtTime >= getTreatmentTimeInMinutes() ) && ( dialVolume <= MAX_DIALYSATE_VOLUME_ML ) ) { result = TRUE; @@ -1446,7 +1445,7 @@ // Compute minimum treatment duration U32 presTime = ( presTreatmentTimeSecs / SEC_PER_MIN ); U32 elapseTime = CALC_ELAPSED_TREAT_TIME_IN_MIN(); - U32 minTime = MAX( (elapseTime + 2), MIN_TREATMENT_TIME_MINUTES ); // Treatment duration cannot be < 1 hour. add two minutes to cover rounding and ensure it is valid for next minute + U32 minTime = MAX( (elapseTime + 2), getTreatmentTimeInMinutes() ); // Treatment duration cannot be < 1 hour. add two minutes to cover rounding and ensure it is valid for next minute // Compute maximum treatment duration (from both UF and dialysate volume perspectives) U32 maxTimeRem = ( MAX_UF_VOLUME_ML - (U32)getUltrafiltrationReferenceVolume() ) / ( presUFRate > 0.0 ? (U32)presUFRate : 1 ); U32 maxTime1 = minTime + maxTimeRem; @@ -1526,7 +1525,31 @@ } } +/*********************************************************************//** + * @brief + * The getTreatmentTimeInMinutes function returns the treatment time in minutes. + * @details Inputs: none + * @details Outputs: none + * @return treatment time in minutes + *************************************************************************/ +static U32 getTreatmentTimeInMinutes( void ) +{ + // Assuming a 1 minute treatment + // NOTE: no # define for the 1 minute treatment time since this is only used for testing + U32 treatmentTime = 1; +#ifndef _RELEASE_ + // Check if the 1 minute treatment software configuration has not been enabled + if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_1_MIN_TREATMENT ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + treatmentTime = MIN_TREATMENT_TIME_MINUTES; + } + + return treatmentTime; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/