Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r89fb8ae8b3e451cb37ccd05b6ba9b92e89820f35 -r6b870cd0699bb3ee22b93981d51373a6c2d56162 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 89fb8ae8b3e451cb37ccd05b6ba9b92e89820f35) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 6b870cd0699bb3ee22b93981d51373a6c2d56162) @@ -22,6 +22,7 @@ #include "DialOutFlow.h" #include "ModeTreatment.h" #include "OperationModes.h" +#include "TaskGeneral.h" #include "TreatmentStop.h" #include "Valves.h" @@ -30,9 +31,15 @@ * @{ */ +// ********** private definitions ********** + +/// Maximum time in this mode before blood sitting warning given (in general task intervals). +static const U32 MAX_TIME_BLOOD_SITTING = ( ( 5 * SEC_PER_MIN * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ); + // ********** private data ********** static TREATMENT_STOP_STATE_T currentTxStopState; ///< Current treatment stop state. +static U32 bloodSittingTimerCtr; ///< Timer counter tracks time in this mode while blood is sitting. // ********** private function prototypes ********** @@ -50,6 +57,7 @@ void initTreatmentStop( void ) { currentTxStopState = TREATMENT_STOP_RECIRC_STATE; + bloodSittingTimerCtr = 0; } /*********************************************************************//** @@ -124,6 +132,13 @@ *************************************************************************/ void execTreatmentStop( void ) { + // Ensure we do not sit in stopped state for too long + if ( ++bloodSittingTimerCtr > MAX_TIME_BLOOD_SITTING ) + { + activateAlarmNoData( ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RINSEBACK ); + } + + // Execute treatment stop sub-mode state machine switch ( currentTxStopState ) { case TREATMENT_STOP_RECIRC_STATE: