Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -rb71077660606609cc3b06911ad4aaa2ffaebd9f2 -rcef8ee5540ff7d849b1ccb2fa54e6d70e5d62db4 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision b71077660606609cc3b06911ad4aaa2ffaebd9f2) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision cef8ee5540ff7d849b1ccb2fa54e6d70e5d62db4) @@ -73,7 +73,6 @@ 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. @@ -122,11 +121,10 @@ 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 BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingCompleteState( DIALYSIS_STATE_T *dialysisState ); static void checkUFControl( void ); static void updateUFVolumes( void ); @@ -831,7 +829,7 @@ { DIALYSIS_STATE_T result = DIALYSIS_BLOOD_LEAK_ZEROING_STATE; - execBloodLeakZeroing(); + result = execBloodLeakZeroing(); return result; } @@ -1107,36 +1105,14 @@ if ( TRUE == bloodLeakZeroingStatus.hasBloodLeakZeroingBeenRequested ) { bloodLeakZeroingStatus.hasBloodLeakZeroingBeenRequested = FALSE; + bloodLeakZeroingStatus.DPiToBLDFlushedVolML = 0.0F; // 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 ); @@ -1227,15 +1203,16 @@ * if the request to zero the blood leak was issued from the dialysis sub-mode. * @details Inputs: bloodLeakZeroingStatus, autoResumeUF * @details Outputs: bloodLeakZeroingStatus, autoResumeUF, currentUFState + * @param pointer to the local dialysis state * @return next state of the blood leak zeroing state *************************************************************************/ -static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingCompleteState( void ) +static BLOOD_LEAK_ZEROING_STATE_T handleBloodLeakZeroingCompleteState( DIALYSIS_STATE_T *dialysisState ) { BLOOD_LEAK_ZEROING_STATE_T state = BLD_ZEROING_COMPLETE; if ( FALSE == bloodLeakZeroingStatus.isZeroingRequestedFromTreatmentStop ) { - *bloodLeakZeroingStatus.dialysisState = DIALYSIS_UF_STATE; + *dialysisState = DIALYSIS_UF_STATE; // Resume UF if appropriate if ( TRUE == autoResumeUF ) @@ -1453,22 +1430,19 @@ * The execBloodLeakZeroing function handles the blood leak zeroing sequence * @details Inputs: bloodLeakZeroing * @details Outputs: bloodLeakZeroing - * @return none + * @return next state of the dialysis state machine *************************************************************************/ -void execBloodLeakZeroing( void ) +DIALYSIS_STATE_T execBloodLeakZeroing( void ) { BLOOD_LEAK_ZEROING_STATE_T prevState = bloodLeakZeroingStatus.bloodLeakZeroingState; + DIALYSIS_STATE_T dialysisState = currentDialysisState; 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; @@ -1482,7 +1456,7 @@ break; case BLD_ZEROING_COMPLETE: - bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingCompleteState(); + bloodLeakZeroingStatus.bloodLeakZeroingState = handleBloodLeakZeroingCompleteState( &dialysisState ); break; default: @@ -1496,6 +1470,8 @@ setCurrent4thLevelState( (U32)bloodLeakZeroingStatus.bloodLeakZeroingState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, prevState, bloodLeakZeroingStatus.bloodLeakZeroingState ) } + + return dialysisState; } /*********************************************************************//** @@ -1510,7 +1486,6 @@ { bloodLeakZeroingStatus.hasBloodLeakZeroingBeenRequested = TRUE; bloodLeakZeroingStatus.isZeroingRequestedFromTreatmentStop = isRequestFromTreatmentStop; - bloodLeakZeroingStatus.dialysisState = ¤tDialysisState; } /*********************************************************************//** @@ -1604,8 +1579,8 @@ 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 ); + bloodLeakZeroingStatus.DPiToBLDFlushedVolML += ( measuredDPiMLPM * TASK_GENERAL_INTERVAL ) / (F32)( SEC_PER_MIN * MS_PER_SECOND ); + status = ( ( bloodLeakZeroingStatus.DPiToBLDFlushedVolML - DPI_TO_BLD_VOLUME_ML ) < NEARLY_ZERO ? TRUE : FALSE ); return status; }