Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r5b3be58e0b2dc2ffce534363f85023d03ca561ba -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 5b3be58e0b2dc2ffce534363f85023d03ca561ba) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -102,6 +102,8 @@ static SALINE_BOLUS_STATE_T handleSalineBolusInProgressState( DIALYSIS_STATE_T *dialysisState ); static SALINE_BOLUS_STATE_T handleSalineBolusMaxDeliveredState( DIALYSIS_STATE_T *dialysisState ); +static void startHeparinPump( void ); + static void checkUFAccuracyAndVolume( void ); static void updateUFVolumes( void ); @@ -201,7 +203,8 @@ setDialInPumpTargetFlowRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); #endif setDialOutPumpTargetRate( setDialysateFlowRate + (S32)setUFRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - // TODO - Heparin pump + // Start Heparin pump as appropriate + startHeparinPump(); // Tell DG to start heating dialysate cmdStartDGTrimmerHeater(); @@ -215,6 +218,40 @@ /*********************************************************************//** * @brief + * The startHeparinPump function sets the syringe pump running as appropriate + * when starting/resuming dialysis sub-mode. + * @details Inputs: Heparin treatment parameters, treatment time remaining + * @details Outputs: Syringe pump started/stopped as appropriate + * @return none + *************************************************************************/ +static void startHeparinPump( void ) +{ + U32 preStop = getTreatmentParameterU32( TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME ); + 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 if Heparin should be stopped at this stage of treatment + if ( ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ) && ( getTreatmentTimeRemainingSecs() > preStop ) ) + { + // If not done with bolus, start/resume bolus + if ( ( bolusVol > 0.0 ) && ( getSyringePumpVolumeDelivered() < bolusVol ) ) + { + startHeparinBolus(); // TODO - check return status + } + // Otherwise, start/resume continuous delivery + else + { + startHeparinContinuous(); // TODO - check return status + } + } + else + { + stopSyringePump(); + } +} + +/*********************************************************************//** + * @brief * The setDialysisParams function sets the dialysis treatment parameters. * This function should be called prior to beginning dialysis treatment * and when the user changes one or more parameters during treatment.