Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -re86b330049966e34035f03496e40f22e6bd4e5a9 -rb71077660606609cc3b06911ad4aaa2ffaebd9f2 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision e86b330049966e34035f03496e40f22e6bd4e5a9) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision b71077660606609cc3b06911ad4aaa2ffaebd9f2) @@ -52,6 +52,9 @@ #define MAX_ACTIVE_LOAD_CELL_CHANGE_G 50.0F ///< Maximum delta between new and previous measured UF volume. +// 3.07 + 12.28 has been received from the mechanical team and 5 mL of margine has been added for safety +#define DPI_TO_BLD_VOLUME_ML ( 3.07F + 12.28F + 5.0F ) ///< Dialysate inlet pump to blood detect sensor volume in milliliters. + /// Defined states for the Load Cell cycles. typedef enum Reservoir_Steady_Cycle { @@ -62,6 +65,17 @@ // ********** private data ********** +/// Blood leak treatment zeroing data structure +typedef struct +{ + F32 DPiToBLDFlushedVolML; ///< Dialysate inlet pump to blood leak flushed volume in milliliters. + BOOL hasBloodLeakZeroingBeenCompleted; ///< Flag to indicate blood leak zeroing has been completed successfully. + BOOL hasBloodLeakZeroingBeenRequested; ///< Flag to indicate blood leak zeroing has been requested. + BOOL isZeroingRequestedFromTreatmentStop; ///< Flag to indicate blood leak zeroing has been requested from treatment stop. + BLOOD_LEAK_ZEROING_STATE_T bloodLeakZeroingState; ///< Blood leak zeroing state. + DIALYSIS_STATE_T* dialysisState; ///< Pointer to current dialysis state. +} BLOOD_LEAK_ZEROING_T ; + static DIALYSIS_STATE_T currentDialysisState; ///< Current state of the dialysis sub-mode state machine. static UF_STATE_T currentUFState; ///< Current state of the ultrafiltration state machine. static SALINE_BOLUS_STATE_T currentSalineBolusState; ///< Current state of the saline bolus state machine. @@ -91,6 +105,7 @@ static F32 totalSalineVolumeDelivered_mL; ///< Volume (mL) in total of saline delivered so far (cumulative for all boluses including current one). static F32 bolusSalineVolumeDelivered_mL; ///< Volume (mL) of current bolus delivered so far (calculated from measured blood flow rate). static U32 bolusSalineLastVolumeTimeStamp; ///< Time stamp for last saline volume update. +static BLOOD_LEAK_ZEROING_T bloodLeakZeroingStatus; ///< Blood leak zeroing status. // ********** private function prototypes ********** @@ -106,11 +121,19 @@ static SALINE_BOLUS_STATE_T handleSalineBolusInProgressState( DIALYSIS_STATE_T *dialysisState ); static SALINE_BOLUS_STATE_T handleSalineBolusMaxDeliveredState( DIALYSIS_STATE_T *dialysisState ); +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingIdleState( void ); +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingSet2BypassState( void ); +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingFlushState( void ); +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingZeroState( void ); +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingVerifyZeroingState( void ); +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingCompleteState( void ); + static void checkUFControl( void ); static void updateUFVolumes( void ); static void publishSalineBolusData( void ); static void checkLoadCellsStablePrimaryBackupDriftOutOfRange( DG_RESERVOIR_ID_T reservoirID, RESERVOIR_STEADY_CYCLE_T cycle ); +static BOOL hasDPiToBLDVolumeBeenFlushed( void ); /*********************************************************************//** * @brief @@ -166,6 +189,7 @@ } resetSalineBolus(); + resetBloodLeakZeroing(); } /*********************************************************************//** @@ -663,8 +687,8 @@ if ( ( TRUE == isBloodLeakZeroingNeeded() ) && ( DIALYSIS_UF_STATE == currentDialysisState ) ) { - requestBloodLeakZeroing(); - currentDialysisState = DIALYSIS_BLOOD_LEAK_ZEROING_STATE; + requestBloodLeakZeroing( FALSE ); + signalInitiatePressureStabilization( USE_NORMAL_STABILIZATION_PERIOD ); } // Dialysis state machine @@ -809,11 +833,6 @@ execBloodLeakZeroing(); - if ( TRUE == isBloodLeakZeroingComplete() ) - { - result = DIALYSIS_UF_STATE; - } - return result; } @@ -1042,7 +1061,6 @@ setCurrentSubState( (U32)DIALYSIS_UF_STATE ); setCurrent4thLevelState( (U32)currentUFState ); sendOperationStatusEvent(); - } signalInitiatePressureStabilization( USE_NORMAL_STABILIZATION_PERIOD ); // Resume dialysis @@ -1075,6 +1093,171 @@ /*********************************************************************//** * @brief + * The handleBloodLeakZeroingIdleState function handles the blood leak zeroing + * idle state. In this state the actuators and parameters are set to run + * the blood leak zeroing state machine. + * @details Inputs: bloodLeakZeroingStatus + * @details Outputs: bloodLeakZeroingStatus + * @return next state of the blood leak zeroing state + *************************************************************************/ +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingIdleState( void ) +{ + BLOOD_LEAK_ZEROING_STATE_T state = BLD_ZEROING_IDLE; + + if ( TRUE == bloodLeakZeroingStatus.hasBloodLeakZeroingBeenRequested ) + { + bloodLeakZeroingStatus.hasBloodLeakZeroingBeenRequested = FALSE; + + // Cmd all pumps to stop + // TODO do we need to stop the dialysate pump? + //setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + stopSyringePump(); + + state = BLD_ZEROING_SET_TO_BYPASS; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakZeroingSet2BypassState function handles the blood leak zeroing + * set to bypass state. In this state, the actuators are set to in dialysate + * bypass. + * @details Inputs: none + * @details Outputs: bloodLeakZeroingStatus + * @return next state of the blood leak zeroing state + *************************************************************************/ +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingSet2BypassState( void ) +{ + BLOOD_LEAK_ZEROING_STATE_T state = BLD_ZEROING_SET_TO_BYPASS; + + if ( FALSE == isDialOutPumpRunning() ) + { + bloodLeakZeroingStatus.DPiToBLDFlushedVolML = 0.0F; + + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + + state = BLD_ZEROING_FLUSH; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakZeroingFlushState function handles the blood leak zeroing + * flush state. In this state, the line in between the dialysate inlet pump + * to blood leak detector is flushed with new dialysate. + * @details Inputs: none + * @details Outputs: none + * @return next state of the blood leak zeroing state + *************************************************************************/ +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingFlushState( void ) +{ + BLOOD_LEAK_ZEROING_STATE_T state = BLD_ZEROING_FLUSH; + + if ( TRUE == hasDPiToBLDVolumeBeenFlushed() ) + { + state = BLD_ZEROING_ZERO; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakZeroingZeroState function handles the blood leak zeroing + * zero state. In this state, the zero blood leak command is issued. + * @details Inputs: none + * @details Outputs: none + * @return next state of the blood leak zeroing state + *************************************************************************/ +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingZeroState( void ) +{ + BLOOD_LEAK_ZEROING_STATE_T state = BLD_ZEROING_ZERO; + + if ( TRUE == zeroBloodLeak() ) + { + state = BLD_ZEROING_VERIFY_ZEROING; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakZeroingVerifyZeroingState function handles the blood + * leak verifying whether zeroing was successful or not. Based on the pass + * or fail status of the blood leak zeroing the state transition occurs. + * @details Inputs: none + * @details Outputs: none + * @return next state of the blood leak zeroing state + *************************************************************************/ +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingVerifyZeroingState( void ) +{ + BLOOD_LEAK_ZEROING_STATE_T state = BLD_ZEROING_VERIFY_ZEROING; + SELF_TEST_STATUS_T zeroSelfTestStatus = getBloodLeakSelfTestStatus(); + + if ( SELF_TEST_STATUS_PASSED == zeroSelfTestStatus ) + { + state = BLD_ZEROING_COMPLETE; + } + else if ( SELF_TEST_STATUS_FAILED == zeroSelfTestStatus ) + { + if ( TRUE == hasBloodLeakZeroSequenceFailed() ) + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SENSOR_ZERO_SEQUENCE_FAILED ); + } + else + { + state = BLD_ZEROING_ZERO; + } + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakZeroingCompleteState function handles the blood + * leak complete state. The state requests a transition back to dialysis + * if the request to zero the blood leak was issued from the dialysis sub-mode. + * @details Inputs: bloodLeakZeroingStatus, autoResumeUF + * @details Outputs: bloodLeakZeroingStatus, autoResumeUF, currentUFState + * @return next state of the blood leak zeroing state + *************************************************************************/ +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingCompleteState( void ) +{ + BLOOD_LEAK_ZEROING_STATE_T state = BLD_ZEROING_COMPLETE; + + if ( FALSE == bloodLeakZeroingStatus.isZeroingRequestedFromTreatmentStop ) + { + *bloodLeakZeroingStatus.dialysisState = DIALYSIS_UF_STATE; + + // Resume UF if appropriate + if ( TRUE == autoResumeUF ) + { + autoResumeUF = FALSE; + currentUFState = UF_RUNNING_STATE; + //Set substate for event + setCurrentSubState( (U32)DIALYSIS_UF_STATE ); + setCurrent4thLevelState( (U32)currentUFState ); + sendOperationStatusEvent(); + } + + signalInitiatePressureStabilization( USE_NORMAL_STABILIZATION_PERIOD ); + // Resume dialysis + transitionToDialysis(); + } + + return state; +} + +/*********************************************************************//** + * @brief * The publishSalineBolusData function handles the max saline delivered * state of the saline bolus state machine. This is a terminal state. * @details Inputs: none @@ -1267,6 +1450,88 @@ /*********************************************************************//** * @brief + * The execBloodLeakZeroing function handles the blood leak zeroing sequence + * @details Inputs: bloodLeakZeroing + * @details Outputs: bloodLeakZeroing + * @return none + *************************************************************************/ +void execBloodLeakZeroing( void ) +{ + BLOOD_LEAK_ZEROING_STATE_T prevState = bloodLeakZeroingStatus.bloodLeakZeroingState; + + switch( bloodLeakZeroingStatus.bloodLeakZeroingState ) + { + case BLD_ZEROING_IDLE: + bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingIdleState(); + break; + + case BLD_ZEROING_SET_TO_BYPASS: + bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingSet2BypassState(); + break; + + case BLD_ZEROING_FLUSH: + bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingFlushState(); + break; + + case BLD_ZEROING_ZERO: + bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingZeroState(); + break; + + case BLD_ZEROING_VERIFY_ZEROING: + bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingVerifyZeroingState(); + break; + + case BLD_ZEROING_COMPLETE: + bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingCompleteState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_INVALID_BLOOD_LEAK_ZEROING_STATE, + bloodLeakZeroingStatus.bloodLeakZeroingState ) + break; + } + + if ( prevState != bloodLeakZeroingStatus.bloodLeakZeroingState ) + { + setCurrent4thLevelState( (U32)bloodLeakZeroingStatus.bloodLeakZeroingState ); + SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, prevState, bloodLeakZeroingStatus.bloodLeakZeroingState ) + } +} + +/*********************************************************************//** + * @brief + * The requestBloodLeakZeroing function sets the flag the requests the + * blood leak zeroing. + * @details Inputs: none + * @details Outputs: bloodLeakZeroing + * @return none + *************************************************************************/ +void requestBloodLeakZeroing( BOOL isRequestFromTreatmentStop ) +{ + bloodLeakZeroingStatus.hasBloodLeakZeroingBeenRequested = TRUE; + bloodLeakZeroingStatus.isZeroingRequestedFromTreatmentStop = isRequestFromTreatmentStop; + bloodLeakZeroingStatus.dialysisState = ¤tDialysisState; +} + +/*********************************************************************//** + * @brief + * The resetBloodLeakZeroingParameters function resets the blood leak zeroing + * parameters. + * @details Inputs: none + * @details Outputs: bloodLeakZeroing + * @return none + *************************************************************************/ +void resetBloodLeakZeroing( void ) +{ + bloodLeakZeroingStatus.DPiToBLDFlushedVolML = 0.0F; + bloodLeakZeroingStatus.bloodLeakZeroingState = BLD_ZEROING_IDLE; + bloodLeakZeroingStatus.hasBloodLeakZeroingBeenCompleted = FALSE; + bloodLeakZeroingStatus.hasBloodLeakZeroingBeenRequested = FALSE; + bloodLeakZeroingStatus.isZeroingRequestedFromTreatmentStop = FALSE; +} + +/*********************************************************************//** + * @brief * The checkLoadCellsStablePrimaryBackupDriftOutOfRange function checks the * load cells' primary and backup drift when the reservoir level has been stable * for greater than large filter time. @@ -1325,4 +1590,24 @@ } } +/*********************************************************************//** + * @brief + * The hasDPiToBLDVolumeBeenFlushed function checks whether the line in + * between dialysate inlet pump to the blood leak detector has been flushed + * with fresh fluid or not. + * @details Inputs: bloodLeakZeroing + * @details Outputs: bloodLeakZeroing + * @return TRUE if the line has been flushed otherwise, FALSE + *************************************************************************/ +static BOOL hasDPiToBLDVolumeBeenFlushed( void ) +{ + BOOL status = FALSE; + F32 measuredDPiMLPM = getMeasuredDialInFlowRate(); + + bloodLeakZeroingStatus.DPiToBLDFlushedVolML += ( measuredDPiMLPM * TASK_GENERAL_INTERVAL ) / ( SEC_PER_MIN * MS_PER_SECOND ); + status = ( ( bloodLeakZeroingStatus.DPiToBLDFlushedVolML - DPI_TO_BLD_VOLUME_ML ) < NEARLY_ZERO ? TRUE : FALSE ); + + return status; +} + /**@}*/ Index: firmware/App/Modes/Dialysis.h =================================================================== diff -u -r20d0c02f453b6dae1884fb1b5ba542053852ffc1 -rb71077660606609cc3b06911ad4aaa2ffaebd9f2 --- firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision 20d0c02f453b6dae1884fb1b5ba542053852ffc1) +++ firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision b71077660606609cc3b06911ad4aaa2ffaebd9f2) @@ -80,6 +80,10 @@ void setFinalReservoirVolume( void ); F32 getReservoirUltrafiltrationVol( DG_RESERVOIR_ID_T reservoirID ); +void execBloodLeakZeroing( void ); +void requestBloodLeakZeroing( BOOL isRequestFromTreatmentStop ); +void resetBloodLeakZeroing( void ); + /**@}*/ #endif Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r14d1cffaeeebd5729f5c05c21b9eb1ac414b4750 -rb71077660606609cc3b06911ad4aaa2ffaebd9f2 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 14d1cffaeeebd5729f5c05c21b9eb1ac414b4750) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision b71077660606609cc3b06911ad4aaa2ffaebd9f2) @@ -75,28 +75,6 @@ /// Macro to calculate the remaining treatment time in seconds. #define CALC_TREAT_TIME_REMAINING_IN_SECS() ( (S32)presTreatmentTimeSecs - (S32)( treatmentTimeMS / MS_PER_SECOND ) ) -// 3.07 + 12.28 has been received from the mechanical team and 5 mL of margine has been added for safety -#define DPI_TO_BLD_VOLUME_ML ( 3.07F + 12.28F + 5.0F ) ///< Dialysate inlet pump to blood detect sensor volume in milliliters. - -/// Blood leak zeroing states -typedef enum BloodLeakZeroingState -{ - BLD_ZEROING_SET_TO_BYPASS = 0, ///< Blood leak zeroing set to bypass. - BLD_ZEROING_FLUSH, ///< Blood leak zeroing flush. - BLD_ZEROING_ZERO, ///< Blood leak zeroing zero. - BLD_ZEROING_VERIFY_ZEROING, ///< Blood leak zeroing verify zeroing. - BLD_ZEROING_COMPLETE, ///< Blood leak zeroing complete. - NUM_OF_BLD_ZEROING ///< Number of blood leak zeroing state. -} BLOOD_LEAK_ZEROING_STATE_T; - -/// Blood leak treatment zeroing data structure -typedef struct -{ - F32 DPiToBLDFlushedVolML; ///< Dialysate inlet pump to blood leak flushed volume in milliliters. - BOOL hasBloodLeakZeroingBeenCompleted; ///< Flag to indicate blood leak zeroing has been completed successfully. - BLOOD_LEAK_ZEROING_STATE_T bloodLeakZeroingState; ///< Blood leak zeroing state. -} BLOOD_LEAK_ZEROING_T ; - // ********** private data ********** static TREATMENT_STATE_T currentTreatmentState; ///< Current state (sub-mode) of treatment mode. @@ -155,8 +133,6 @@ static U32 treatmentStartTimeStamp; ///< Treatment start timestampt for logging purpose. static U32 treatmentEndTimeStamp; ///< Treatment end timestampt for logging purpose. -static BLOOD_LEAK_ZEROING_T bloodLeakZeroing; ///< Blood leak zeroing status. - // ********** private function prototypes ********** static void broadcastTreatmentSettingsRanges( void ); @@ -171,7 +147,6 @@ static TREATMENT_STATE_T handleTreatmentEndState( void ); static void resetSignalFlags( void ); static void resetAlarmSignalFlags( void ); -static BOOL hasDPiToBLDVolumeBeenFlushed( void ); /*********************************************************************//** * @brief @@ -224,8 +199,6 @@ treatmentStartTimeStamp = getRTCTimestamp(); treatmentEndTimeStamp = 0; - memset( &bloodLeakZeroing, 0x0, sizeof( BLOOD_LEAK_ZEROING_T ) ); - // reset dialysate temperature alarm persistences prior to starting a treatment. resetPersistentAlarmTimer( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP ); resetPersistentAlarmTimer( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ); @@ -816,7 +789,7 @@ DIALYSIS_STATE_T dialysisState = getDialysisState(); // Update treatment time (unless delivering a saline bolus or is in blood leak zeroing state) - if ( ( dialysisState != DIALYSIS_SALINE_BOLUS_STATE ) || ( dialysisState != DIALYSIS_BLOOD_LEAK_ZEROING_STATE ) ) + if ( ( dialysisState != DIALYSIS_SALINE_BOLUS_STATE ) && ( dialysisState != DIALYSIS_BLOOD_LEAK_ZEROING_STATE ) ) { treatmentTimeMS += msSinceLast; } @@ -1531,105 +1504,6 @@ /*********************************************************************//** * @brief - * The execBloodLeakZeroing function handles the blood leak zeroing sequence - * @details Inputs: bloodLeakZeroing - * @details Outputs: bloodLeakZeroing - * @return none - *************************************************************************/ -void execBloodLeakZeroing( void ) -{ - BOOL status = FALSE; - SELF_TEST_STATUS_T zeroStatus = getBloodLeakSelfTestStatus(); - BLOOD_LEAK_ZEROING_STATE_T prevState = bloodLeakZeroing.bloodLeakZeroingState; - - // TODO investigate whether we need to stop the before going to bypass - - switch( bloodLeakZeroing.bloodLeakZeroingState ) // TODO we need handlers for this state machine? - { - case BLD_ZEROING_SET_TO_BYPASS: - // Set Dialysate valves to bypass filter for recirculation - signalDialOutPumpHardStop(); - stopSyringePump(); - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - bloodLeakZeroing.bloodLeakZeroingState = BLD_ZEROING_FLUSH; - break; - - case BLD_ZEROING_FLUSH: - status = hasDPiToBLDVolumeBeenFlushed(); - bloodLeakZeroing.bloodLeakZeroingState = ( TRUE == status ? BLD_ZEROING_ZERO : BLD_ZEROING_FLUSH ); - break; - - case BLD_ZEROING_ZERO: - status = zeroBloodLeak(); - bloodLeakZeroing.bloodLeakZeroingState = ( TRUE == status ? BLD_ZEROING_VERIFY_ZEROING : BLD_ZEROING_ZERO ); - break; - - case BLD_ZEROING_VERIFY_ZEROING: - if ( SELF_TEST_STATUS_PASSED == status ) - { - bloodLeakZeroing.bloodLeakZeroingState = BLD_ZEROING_COMPLETE; - } - else if ( SELF_TEST_STATUS_FAILED == status ) - { - if ( TRUE == hasBloodLeakZeroSequenceFailed() ) - { - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SENSOR_ZERO_SEQUENCE_FAILED ); - } - else - { - bloodLeakZeroing.bloodLeakZeroingState = BLD_ZEROING_ZERO; - } - } - break; - - case BLD_ZEROING_COMPLETE: - bloodLeakZeroing.hasBloodLeakZeroingBeenCompleted = TRUE; - break; - - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_INVALID_BLOOD_LEAK_ZEROING_STATE, - bloodLeakZeroing.bloodLeakZeroingState ) - break; - } - - if ( prevState != bloodLeakZeroing.bloodLeakZeroingState ) - { - setCurrent4thLevelState( (U32)bloodLeakZeroing.bloodLeakZeroingState ); - SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, prevState, bloodLeakZeroing.bloodLeakZeroingState ); - } -} - -/*********************************************************************//** - * @brief - * The requestBloodLeakZeroing function sets the flag the requests the - * blood leak zeroing. - * @details Inputs: none - * @details Outputs: bloodLeakZeroing - * @return none - *************************************************************************/ -void requestBloodLeakZeroing( void ) -{ - bloodLeakZeroing.DPiToBLDFlushedVolML = 0.0F; - bloodLeakZeroing.bloodLeakZeroingState = BLD_ZEROING_SET_TO_BYPASS; - bloodLeakZeroing.hasBloodLeakZeroingBeenCompleted = FALSE; -} - -/*********************************************************************//** - * @brief - * The isBloodLeakZeroingComplete function returns the status of the blood - * leak zeroing complete - * @details Inputs: none - * @details Outputs: bloodLeakZeroing - * @return TRUE if blood leak zeroing was complete otherwise, FALSE - *************************************************************************/ -BOOL isBloodLeakZeroingComplete( void ) -{ - return bloodLeakZeroing.hasBloodLeakZeroingBeenCompleted; -} - -/*********************************************************************//** - * @brief * The broadcastTreatmentSettingsRanges function computes and broadcasts * updated treatment parameter ranges that the user may change during treatment. * It is assumed that prescription settings have already been set prior to calling @@ -1785,26 +1659,6 @@ endTreatmentAlarmResponseRequest = FALSE; } -/*********************************************************************//** - * @brief - * The hasDPiToBLDVolumeBeenFlushed function checks whether the line in - * between dialysate inlet pump to the blood leak detector has been flushed - * with fresh fluid or not. - * @details Inputs: bloodLeakZeroing - * @details Outputs: bloodLeakZeroing - * @return TRUE if the line has been flushed otherwise, FALSE - *************************************************************************/ -static BOOL hasDPiToBLDVolumeBeenFlushed( void ) -{ - BOOL status = FALSE; - F32 measuredDPiMLPM = getMeasuredDialInFlowRate(); - - bloodLeakZeroing.DPiToBLDFlushedVolML += ( measuredDPiMLPM * TASK_GENERAL_INTERVAL ) / ( SEC_PER_MIN * MS_PER_SECOND ); - status = ( ( bloodLeakZeroing.DPiToBLDFlushedVolML - DPI_TO_BLD_VOLUME_ML ) < NEARLY_ZERO ? TRUE : FALSE ); - - return status; -} - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Modes/ModeTreatment.h =================================================================== diff -u -r14d1cffaeeebd5729f5c05c21b9eb1ac414b4750 -rb71077660606609cc3b06911ad4aaa2ffaebd9f2 --- firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision 14d1cffaeeebd5729f5c05c21b9eb1ac414b4750) +++ firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision b71077660606609cc3b06911ad4aaa2ffaebd9f2) @@ -130,10 +130,6 @@ void broadcastTreatmentTimeAndState( void ); // Broadcast the times and states of this treatment -void execBloodLeakZeroing( void ); -void requestBloodLeakZeroing( void ); -BOOL isBloodLeakZeroingComplete( void ); - BOOL verifyTreatmentDurationSettingChange( U32 treatmentTime ); BOOL verifyUFSettingsChange( F32 uFVolume ); BOOL verifyUFSettingsConfirmation( F32 uFVolume, U32 adjustment ); Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r9ded16038a0d6dd844da697aaf03505ec3ed335a -rb71077660606609cc3b06911ad4aaa2ffaebd9f2 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 9ded16038a0d6dd844da697aaf03505ec3ed335a) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision b71077660606609cc3b06911ad4aaa2ffaebd9f2) @@ -118,6 +118,9 @@ // Reset saline bolus state in case alarm interrupted one resetSalineBolus(); + // Reset blood leak zeroing params + resetBloodLeakZeroing(); + // Enable venous bubble detection (in case returning from mid-treatment rinseback) setVenousBubbleDetectionEnabled( TRUE ); @@ -201,7 +204,7 @@ doorClosedRequired( TRUE, TRUE ); cmdStartDGTrimmerHeater(); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_BLOOD_DETECT_RECOVERY_MLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - requestBloodLeakZeroing(); + requestBloodLeakZeroing( TRUE ); } /*********************************************************************//**