Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -rebfb8019ba74b6c614051d1bfd13ee186c9138fd -rd3b7ae356aae29c99cb039713a2e120fdbce5a9c --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision ebfb8019ba74b6c614051d1bfd13ee186c9138fd) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision d3b7ae356aae29c99cb039713a2e120fdbce5a9c) @@ -66,7 +66,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 +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 @@ -338,17 +338,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 +371,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 + activateAlarmNoData( ALARM_ID_EMPTY_SALINE_BAG ); setupForRinsebackStopOrPause(); result = RINSEBACK_PAUSED_STATE; } @@ -535,7 +532,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; }