Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -rebfb8019ba74b6c614051d1bfd13ee186c9138fd -racf165d4bdd93d15f77e12e4cef3af7d6fb322ca --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision ebfb8019ba74b6c614051d1bfd13ee186c9138fd) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision acf165d4bdd93d15f77e12e4cef3af7d6fb322ca) @@ -43,10 +43,13 @@ #define RINSEBACK_FLOW_RATE_ADJ_ML_MIN 25 ///< Adjustment amount (in mL/min) to apply when user requests increase/decrease in flow rate. #define MIN_RINSEBACK_FLOW_RATE_ML_MIN 50 ///< Minimum rinseback flow rate (in mL/min). #define MAX_RINSEBACK_FLOW_RATE_ML_MIN 150 ///< Maximum rinseback flow rate (in mL/min). + +#ifndef DISABLE_PUMP_FLOW_CHECKS /// Maximum rinseback volume measured by independent means (as % of target). static const F32 MAX_RINSEBACK_SAFETY_VOLUME_ML = ( TARGET_RINSEBACK_VOLUME_ML * 1.2 ); /// Minimum rinseback volume measured by independent means (as % of target). static const F32 MIN_RINSEBACK_SAFETY_VOLUME_ML = ( TARGET_RINSEBACK_VOLUME_ML * 0.8 ); +#endif /// Interval at which rinseback progress is to be published to UI. static const U32 RINSEBACK_DATA_PUBLISH_INTERVAL = ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); @@ -66,7 +69,7 @@ static F32 cumulativeRinsebackVolume_mL; ///< Total cumulative rinseback volume (in mL). static F32 targetRinsebackVolumePlusAdditional_mL; ///< Target rinseback volume w/ additional volume(s) added (in mL). static F32 additionalRinsebackVolume_mL; ///< Total volume (in mL) delivered so far for additional volume request. -static U32 rinsebackMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent rinseback volume check. +static S32 rinsebackMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent rinseback volume check. static U32 rinsebackLastMotorCount; ///< The last BP motor encoder count read for independent rinseback volume check. static F32 rinsebackVolumeDelivered_Safety; ///< The cumulative independent rinseback volume (in mL) calculated so far. static U32 rinsebackAdditionalTimerCtr; ///< Timer counter for duration of an additional rinseback delivery. @@ -179,7 +182,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 @@ -306,6 +309,7 @@ // From moment we start rinseback, we consider blood side of dialyzer no longer fully primed setBloodIsPrimed( FALSE ); result = RINSEBACK_RUN_STATE; + sendTreatmentLogEventData( MID_TREATMENT_RINSE_BACK_EVENT, 0.0, 0.0 ); } // Has user requested to return to treatment? else if ( TRUE == backToTreatmentRequested ) @@ -338,17 +342,14 @@ static RINSEBACK_STATE_T handleRinsebackRunState( void ) { RINSEBACK_STATE_T result = RINSEBACK_RUN_STATE; - U32 bldPumpMotorCount = getBloodPumpMotorCount(); - U32 bldPumpMotorDelta = u32DiffWithWrap( rinsebackLastMotorCount, bldPumpMotorCount ); // Reset rinseback t/o rinsebackTimerCtr = 0; // Update rinseback volume delivered so far cumulativeRinsebackVolume_mL += ( getMeasuredBloodFlowRate() * RINSEBACK_FLOW_INTEGRATOR ); // update independent calculated safety volume delivered so far - rinsebackMotorCount += bldPumpMotorDelta; - rinsebackLastMotorCount = bldPumpMotorCount; + rinsebackMotorCount = u32BiDiffWithWrap( rinsebackLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; rinsebackVolumeDelivered_Safety = ( (F32)rinsebackMotorCount * VOLUME_PER_BP_MOTOR_REV_ML ); // TODO - include upstream pressure compensation to this calc // Has user requested to end rinseback? @@ -374,7 +375,7 @@ // Check for empty saline bag if ( TRUE == isSalineBagEmpty() ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_EMPTY_SALINE_BAG, 0.0 ); // TODO - give data supporting empty bag detection + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_EMPTY_SALINE_BAG, getMeasuredArterialPressure() ); setupForRinsebackStopOrPause(); result = RINSEBACK_PAUSED_STATE; } @@ -535,7 +536,7 @@ // Check for empty saline bag if ( TRUE == isSalineBagEmpty() ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_EMPTY_SALINE_BAG, 0.0 ); // TODO - give data supporting empty bag detection + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_EMPTY_SALINE_BAG, getMeasuredArterialPressure() ); setupForRinsebackStopOrPause(); result = RINSEBACK_STOP_STATE; } @@ -697,7 +698,7 @@ { BOOL result = FALSE; - if ( ( rinsebackRate_mL_min + RINSEBACK_FLOW_RATE_ADJ_ML_MIN ) >= MIN_RINSEBACK_FLOW_RATE_ML_MIN ) + if ( ( rinsebackRate_mL_min - RINSEBACK_FLOW_RATE_ADJ_ML_MIN ) >= MIN_RINSEBACK_FLOW_RATE_ML_MIN ) { if ( RINSEBACK_RUN_STATE == rinsebackState ) {