Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r844f98879b7425c207b58562e623ab960adbc357 -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 844f98879b7425c207b58562e623ab960adbc357) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * -* @file TreatmentStop.c +* @file TreatmentStop.c * -* @author (last) Sean Nash -* @date (last) 24-Sep-2020 +* @author (last) Sean Nash +* @date (last) 19-Aug-2021 * -* @author (original) Sean -* @date (original) 15-Jan-2020 +* @author (original) Sean +* @date (original) 15-Jan-2020 * ***************************************************************************/ @@ -68,7 +68,7 @@ { currentTxStopState = TREATMENT_STOP_RECIRC_STATE; bloodSittingTimerCtr = 0; - stopPublishTimerCtr = 0; + stopPublishTimerCtr = TREATMENT_STOP_DATA_PUBLISH_INTERVAL; } /*********************************************************************//** @@ -140,16 +140,19 @@ *************************************************************************/ void execTreatmentStop( void ) { - // Ensure we do not sit in stopped state for too long - if ( ++bloodSittingTimerCtr > WARN_TIME_BLOOD_SITTING ) + // Ensure we do not sit in stopped state for too long (if blood in line) + if ( getRinsebackCompleted() != TRUE ) { - activateAlarmNoData( ALARM_ID_BLOOD_SITTING_WARNING ); + if ( ++bloodSittingTimerCtr > WARN_TIME_BLOOD_SITTING ) + { + activateAlarmNoData( ALARM_ID_BLOOD_SITTING_WARNING ); + } + if ( bloodSittingTimerCtr > MAX_TIME_BLOOD_SITTING ) + { + // Activate the alarm + activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_NO_RINSEBACK ); + } } - if ( bloodSittingTimerCtr > MAX_TIME_BLOOD_SITTING ) - { - // Activate the alarm - activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_NO_RINSEBACK ); - } // Execute treatment stop sub-mode state machine switch ( currentTxStopState ) @@ -236,11 +239,19 @@ { if ( ++stopPublishTimerCtr >= getU32OverrideValue( &treatmentStopPublishInterval ) ) { - U32 timeout = MAX_TIME_BLOOD_SITTING / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); - U32 countdown = ( bloodSittingTimerCtr >= MAX_TIME_BLOOD_SITTING ? 0 : ( MAX_TIME_BLOOD_SITTING - bloodSittingTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); + TREATMENT_STOP_PAYLOAD_T data; + data.timeout = MAX_TIME_BLOOD_SITTING / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); + if ( getRinsebackCompleted() != TRUE ) + { + data.countdown = ( bloodSittingTimerCtr >= MAX_TIME_BLOOD_SITTING ? 0 : ( MAX_TIME_BLOOD_SITTING - bloodSittingTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); + } + else + { + data.countdown = 0; + } stopPublishTimerCtr = 0; - broadcastTreatmentStopData( timeout, countdown ); + broadcastData( MSG_ID_HD_TREATMENT_STOP_TIMER_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( TREATMENT_STOP_PAYLOAD_T ) ); } }