Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -rcc4f8440e8ad7fa8f2ced2467d922be7422c344c -r49533d4870aa10c1b20406dd5c013567fe854694 --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision cc4f8440e8ad7fa8f2ced2467d922be7422c344c) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 49533d4870aa10c1b20406dd5c013567fe854694) @@ -7,8 +7,8 @@ * * @file Rinseback.c * -* @author (last) Dara Navaei -* @date (last) 03-Mar-2022 +* @author (last) Michael Garthwaite +* @date (last) 09-Mar-2022 * * @author (original) Sean Nash * @date (original) 20-Jan-2021 @@ -37,10 +37,11 @@ // ********** private definitions ********** -#define TUBING_RINSEBACK_VOLUME_ML 80.0 ///< Target rinseback volume to deliver back to the patient (in mL). -#define MAX_TOTAL_ADDITIONAL_RINSEBACK_VOLUME_ML 300.0 ///< Maximum total additional rinseback volume allowed : all additionals (in mL). -#define MAX_RINSEBACK_VOLUME_ERROR_ML 60.0 ///< Maximum error in total additional rinseback volume (20% of total). -#define TARGET_ADDITIONAL_RINSEBACK_VOLUME_ML 10.0 ///< Target rinseback volume for an additional volume request (in mL). +#define TUBING_RINSEBACK_VOLUME_ML 80.0F ///< Target rinseback volume to deliver back to the patient (in mL). +#define DEFAULT_RINSEBACK_VOLUME_ML 300.0F ///< Default rinseback volume (in mL). +#define MAX_TOTAL_ADDITIONAL_RINSEBACK_VOLUME_ML 300.0F ///< Maximum total additional rinseback volume allowed : all additionals (in mL). +#define MAX_RINSEBACK_VOLUME_ERROR_ML 60.0F ///< Maximum error in total additional rinseback volume (20% of total). +#define TARGET_ADDITIONAL_RINSEBACK_VOLUME_ML 10.0F ///< Target rinseback volume for an additional volume request (in mL). #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). @@ -56,7 +57,7 @@ /// Maximum time allowed for each additional rinseback volume delivery. static const U32 MAX_RINSEBACK_ADDITIONAL_TIME = ( 20 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ); /// Multiplier to convert flow (mL/min) into volume (mL) for period of general task interval. -static const F32 RINSEBACK_FLOW_INTEGRATOR = 1.0 / (F32)( SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); +static const F32 RINSEBACK_FLOW_INTEGRATOR = 1.0F / (F32)( SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); // ********** private data ********** @@ -135,7 +136,7 @@ totalAdditionalRinsebackVolume_mL = 0.0; rinsebackAdditionalTimerCtr = 0; rinsebackPublishTimerCtr = 0; - rinsebackTargetVolume_mL = 300.0; + rinsebackTargetVolume_mL = DEFAULT_RINSEBACK_VOLUME_ML; resetRinsebackFlags(); } @@ -328,11 +329,14 @@ // Has user requested rinseback start? if ( TRUE == startRinsebackRequested ) { + if ( isTreatmentCompleted() != TRUE ) + { + sendTreatmentLogEventData( MID_TREATMENT_RINSE_BACK_EVENT, 0.0, rinsebackRate_mL_min ); + } setupForRinsebackDelivery( rinsebackRate_mL_min ); // 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 ) @@ -402,13 +406,17 @@ result = RINSEBACK_PAUSED_STATE; } // Is rinseback taking too long? - else if ( ( fabs( expectedRinsebackVolume_mL - getRinsebackVolume() ) > MAX_RINSEBACK_VOLUME_ERROR_ML ) && - ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMP_FLOW_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) ) + else if ( fabs( expectedRinsebackVolume_mL - getRinsebackVolume() ) > MAX_RINSEBACK_VOLUME_ERROR_ML ) { - setRinsebackIsCompleted( TRUE ); - setupForRinsebackStopOrPause(); - activateAlarmNoData( ALARM_ID_RINSEBACK_VOLUME_CHECK_FAILURE ); - result = RINSEBACK_STOP_STATE; +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMP_FLOW_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + setRinsebackIsCompleted( TRUE ); + setupForRinsebackStopOrPause(); + activateAlarmNoData( ALARM_ID_RINSEBACK_VOLUME_CHECK_FAILURE ); + result = RINSEBACK_STOP_STATE; + } } // Otherwise, continue rinseback else @@ -994,7 +1002,7 @@ } // Scale to seconds countdown /= ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); - + data.isCompleted = FALSE; data.targetRinsebackVolumeMl = rinsebackTargetVolume_mL; rinsebackPublishTimerCtr = 0; // If we have completed rinseback, timeout is no longer in force - indicate by zeroing timeout. Also include any additionals to target. @@ -1011,7 +1019,10 @@ } data.timeout = timeout; data.countdown = countdown; - data.unused = 0.0; // TODO - remove when UI no longer looks for this field + if ( data.deliveredRinsebackVolumeMl >= rinsebackTargetVolume_mL ) + { + data.isCompleted = TRUE; + } broadcastData( MSG_ID_HD_RINSEBACK_PROGRESS, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( RINSEBACK_DATA_PAYLOAD_T ) ); } }