Index: firmware/App/HDCommon.h =================================================================== diff -u -r85a680de4306aa033b1dc1f386fa5fa0a25cf73b -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision 85a680de4306aa033b1dc1f386fa5fa0a25cf73b) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -49,6 +49,7 @@ // #define DISABLE_PUMP_SPEED_CHECKS 1 // Do not error on HD pump speed checks // #define DISABLE_PUMP_DIRECTION_CHECKS 1 // Do not error on HD pump direction checks // #define DISABLE_SALINE_BOLUS_CHECKS 1 // Do not error on HD saline bolus checks +// #define DISABLE_SYRINGE_PUMP 1 // Disable syringe pump functionality #define DISABLE_PRESSURE_CHECKS 1 // Do not error on HD pressure checks // #define DISABLE_UF_ALARMS 1 // Do not error on HD ultrafiltration checks #define DISABLE_VALVE_ALARMS 1 // Do not error on HD valve position Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -r70d33c50c8c3fd987f39eaa1f3b294860d569830 -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -23,6 +23,7 @@ #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "OperationModes.h" +#include "SyringePump.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Utilities.h" @@ -150,7 +151,8 @@ // Ensure dialysate outlet and Heparin pumps are stopped signalDialOutPumpHardStop(); - // TODO - stop Heparin pump + stopSyringePump(); + // start blood and dialysate inlet pumps setBloodPumpTargetFlowRate( BLOOD_PRIME_INIT_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); 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. Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r1afd5c87ef15399998a743c2ebcafe2cc03bd363 -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 1afd5c87ef15399998a743c2ebcafe2cc03bd363) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -226,6 +226,21 @@ /*********************************************************************//** * @brief + * The getTreatmentTimeRemainingSecs function determines the number of seconds + * remaining in the treatment. + * @details Inputs: presTreatmentTimeSecs, treatmentTimeMS + * @details Outputs: none + * @return The number of seconds remaining in the treatment. + *************************************************************************/ +U32 getTreatmentTimeRemainingSecs( void ) +{ + U32 result = CALC_TREAT_TIME_REMAINING_IN_SECS(); + + return result; +} + +/*********************************************************************//** + * @brief * The getRinsebackCompleted function determines whether a rinseback has been * completed (indicating blood-side circuit should be primarily saline). * @details Inputs: rinsebackDone Index: firmware/App/Modes/ModeTreatment.h =================================================================== diff -u -re23087e0c17f6ea81d60641fdb52121a8dd5a099 -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision e23087e0c17f6ea81d60641fdb52121a8dd5a099) +++ firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -95,6 +95,7 @@ TREATMENT_STATE_T getTreatmentState( void ); // Determine the current treatment sub-mode (state) BOOL isTreatmentCompleted( void ); // Determine whether the treatment has completed +U32 getTreatmentTimeRemainingSecs( void ); // Determine number of seconds remaining in the treatment BOOL getRinsebackCompleted( void ); // Determine whether a rinseback has been completed void setRinsebackIsCompleted( BOOL flag ); // Set whether a rinseback has been completed (T blocks rinseback option) BOOL getBloodIsPrimed( void ); // Determine whether the blood-side circuit of the dialyzer has been primed with blood Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -r70d33c50c8c3fd987f39eaa1f3b294860d569830 -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -179,7 +179,7 @@ // Ensure all pumps except DPi stopped signalBloodPumpHardStop(); signalDialOutPumpHardStop(); - // TODO - stop Heparin pump + stopSyringePump(); endAirTrapControl(); // Re-circulate dialysate side of dialyzer w/ heating to maintain temperature Index: firmware/App/Modes/TreatmentEnd.c =================================================================== diff -u -r8c00197ce69e80f1967aa3f2eb36beb3573f36f3 -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision 8c00197ce69e80f1967aa3f2eb36beb3573f36f3) +++ firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -120,7 +120,7 @@ // Ensure all pumps except BP stopped signalDialInPumpHardStop(); signalDialOutPumpHardStop(); - // TODO - stop Heparin pump + stopSyringePump(); setBloodPumpTargetFlowRate( TX_END_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // Continue air trap control Index: firmware/App/Modes/TreatmentRecirc.c =================================================================== diff -u -r47d58f4762e487f2aa13affba3deccc6d2ae324f -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 47d58f4762e487f2aa13affba3deccc6d2ae324f) +++ firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -121,6 +121,8 @@ // Start blood pump at re-circulate flow rate setBloodPumpTargetFlowRate( RECIRC_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + // Ensure syringe pump is stopped + stopSyringePump(); // Start air trap control startAirTrapControl(); // *Note - Dialysate pump should already be re-circulating from rinseback sub-mode Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r47d58f4762e487f2aa13affba3deccc6d2ae324f -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 47d58f4762e487f2aa13affba3deccc6d2ae324f) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) @@ -85,7 +85,7 @@ // Ensure all pumps except DPi stopped signalBloodPumpHardStop(); signalDialOutPumpHardStop(); - // TODO - stop Heparin pump + stopSyringePump(); // Start out assuming we re-circulate dialysate while stopped setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP );