Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r04f72c18f15a3d7ab960fccea7b99cf93fd9a409 -rb0b3522f2bd0b5b20ecbfd53c8f55b0e646ffa11 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 04f72c18f15a3d7ab960fccea7b99cf93fd9a409) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision b0b3522f2bd0b5b20ecbfd53c8f55b0e646ffa11) @@ -43,6 +43,7 @@ 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. static F32 refUFVolume; ///< Current reference volume for ultrafiltration (Where should we be w/r/t ultrafiltration). static F32 measUFVolume; ///< Current total measured volume for ultrafiltration (Where are we w/r/t ultrafiltration). @@ -64,7 +65,7 @@ // ********** private function prototypes ********** static DIALYSIS_STATE_T handleDialysisUltrafiltrationState( void ); -static DIALYSIS_STATE_T handleDialysisSolutionInfusionState( void ); +static DIALYSIS_STATE_T handleDialysisSalineBolusState( void ); static UF_STATE_T handleUFStartState( void ); static UF_STATE_T handleUFPausedState( void ); @@ -89,6 +90,7 @@ { currentDialysisState = DIALYSIS_START_STATE; currentUFState = UF_START_STATE; + currentSalineBolusState = SALINE_BOLUS_STATE_IDLE; refUFVolume = 0.0; measUFVolume = 0.0; @@ -168,12 +170,17 @@ *************************************************************************/ void startDialysis( void ) { + // set last UF timestamp so UF ref is resumed from this time lastUFTimeStamp = getMSTimerCount(); + // send dialysate outlet pump latest UF volumes setDialOutUFVolumes( refUFVolume, measUFVolume ); + // restart pumps setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialInPumpTargetFlowRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialOutPumpTargetRate( setDialysateFlowRate + (S32)setUFRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // TODO - Heparin pump + // tell DG to start heating dialysate + cmdStartDGTrimmerHeater(); } /*********************************************************************//** @@ -188,9 +195,13 @@ *************************************************************************/ void stopDialysis( void ) { + // stop pumps setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + // TODO - stop Heparin pump + // tell DG to stop heating dialysate + cmdStopDGTrimmerHeater(); } /*********************************************************************//** @@ -221,6 +232,19 @@ /*********************************************************************//** * @brief + * The getSalineBolusState function gets the current saline bolus state. + * @details + * Inputs : currentSalineBolusState + * Outputs : none + * @return currentSalineBolusState + *************************************************************************/ +SALINE_BOLUS_STATE_T getSalineBolusState( void ) +{ + return currentSalineBolusState; +} + +/*********************************************************************//** + * @brief * The getUltrafiltrationVolumeCollected function gets the current ultrafiltration * volume collected so far for current treatment. * @details @@ -360,7 +384,7 @@ break; case DIALYSIS_SALINE_BOLUS_STATE: - currentDialysisState = handleDialysisSolutionInfusionState(); + currentDialysisState = handleDialysisSalineBolusState(); break; default: @@ -417,11 +441,11 @@ * The handleDialysisSolutionInfusionState function handles the solution * infustion state of the Dialysis state machine. * @details - * Inputs : TBD - * Outputs : TBD + * Inputs : currentSalineBolusState + * Outputs : currentSalineBolusState * @return next Dialysis state. *************************************************************************/ -static DIALYSIS_STATE_T handleDialysisSolutionInfusionState( void ) +static DIALYSIS_STATE_T handleDialysisSalineBolusState( void ) { DIALYSIS_STATE_T result = DIALYSIS_SALINE_BOLUS_STATE;