Index: firmware/App/Modes/PreTreatmentRecirc.c =================================================================== diff -u -r1f91b5a53bda942b0967817bbd5e68a499dbf816 -r75e1ae332d1446dddf9b8d4ce6e8317449c57d67 --- firmware/App/Modes/PreTreatmentRecirc.c (.../PreTreatmentRecirc.c) (revision 1f91b5a53bda942b0967817bbd5e68a499dbf816) +++ firmware/App/Modes/PreTreatmentRecirc.c (.../PreTreatmentRecirc.c) (revision 75e1ae332d1446dddf9b8d4ce6e8317449c57d67) @@ -22,6 +22,8 @@ #include "DGInterface.h" #include "PreTreatmentRecirc.h" #include "Switches.h" +#include "SystemCommMessages.h" +#include "Timers.h" #include "Valves.h" /** @@ -31,14 +33,19 @@ // ********** private definitions ********** -#define BLOOD_PUMP_RECIRC_FLOW_RATE 100 ///< Blood pump flow rate during recirculation in mL/min. -/// TODO: Restore to 100 when DPi flow control is fixed. -#define DIALYSATE_PUMP_RECIRC_FLOW_RATE 250 ///< Dialysate pump flow rate during recirculation in mL/min. +#define BLOOD_PUMP_RECIRC_FLOW_RATE 100 ///< Blood pump flow rate during recirculation in mL/min. +// TODO: Restore to 100 when DPi flow control is fixed. +#define DIALYSATE_PUMP_RECIRC_FLOW_RATE 250 ///< Dialysate pump flow rate during recirculation in mL/min. +#define WARNING_MEDIUM_PRIME_COMPLETED_TIME_MS ( 90 * 60 * MS_PER_SECOND ) ///< Pre-Treatment recirc time before medium priority warning in min. +#define WARNING_HIGH_PRIME_COMPLETED_TIME_MS ( 120 * 60 * MS_PER_SECOND ) ///< Pre-Treatment recirc time before high priority alarm in min. // ********** private data ********** -static HD_PRE_TREATMENT_RECIRC_STATE_T currentPreTreatmentRecircState; ///< Current state of the pre-treatment recirculate state machine. -static BOOL recircResumeRequested; ///< Flag indicates alarm requesting to resume pre-treatment recirculate. +static HD_PRE_TREATMENT_RECIRC_STATE_T currentPreTreatmentRecircState; ///< Current state of the pre-treatment recirculate state machine. +static BOOL recircResumeRequested; ///< Flag indicates alarm requesting to resume pre-treatment recirculate. +static U32 preTxRecircStartTime; ///< Time pre-treatment re-circulate state started. +static BOOL recircTOWarningGiven; ///< Flag indicates 90 minute warning given. +static BOOL recircTOAlarmGiven; ///< Flag indicates 2 hour alarm triggered. // ********** private function prototypes ********** @@ -58,6 +65,9 @@ void initPreTreatmentRecirc( void ) { currentPreTreatmentRecircState = PRE_TREATMENT_RECIRC_STATE; + preTxRecircStartTime = getMSTimerCount(); + recircTOWarningGiven = FALSE; + recircTOAlarmGiven = FALSE; resetPreTreatmentRecircFlags(); } @@ -87,6 +97,14 @@ { HD_PRE_TREATMENT_RECIRC_STATE_T priorSubState = currentPreTreatmentRecircState; + // Alarm if 2 hours recirculating + if ( ( recircTOAlarmGiven != TRUE ) && ( TRUE == didTimeout( preTxRecircStartTime, WARNING_HIGH_PRIME_COMPLETED_TIME_MS ) ) ) + { + recircTOAlarmGiven = TRUE; + clearAlarm( ALARM_ID_PRIME_COMPLETED_MEDIUM ); + activateAlarmNoData( ALARM_ID_PRIME_COMPLETED_HIGH ); + } + // execute pre-treatment recirculate state machine switch ( currentPreTreatmentRecircState ) { @@ -193,6 +211,14 @@ { HD_PRE_TREATMENT_RECIRC_STATE_T state = PRE_TREATMENT_RECIRC_STATE; + // Warn user if 90 minutes recirculating + if ( ( recircTOWarningGiven != TRUE ) && ( TRUE == didTimeout( preTxRecircStartTime, WARNING_MEDIUM_PRIME_COMPLETED_TIME_MS ) ) ) + { + recircTOWarningGiven = TRUE; + clearAlarm( ALARM_ID_PRIME_COMPLETED_LOW_PRIORITY ); + activateAlarmNoData( ALARM_ID_PRIME_COMPLETED_MEDIUM ); + } + if ( TRUE == doesAlarmStatusIndicateStop() ) { signalDialOutPumpHardStop();