Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r97915871fe011bc235c7a7f3c8690ee95ae637ea -r33bc23fb61c47f863824c5209857125ed18781a9 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 97915871fe011bc235c7a7f3c8690ee95ae637ea) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 33bc23fb61c47f863824c5209857125ed18781a9) @@ -56,6 +56,7 @@ static TREATMENT_STOP_STATE_T handleTreatmentStopAlarmsAndSignals( TREATMENT_STOP_STATE_T state ); static TREATMENT_STOP_STATE_T handleTreatmentStopDialysateRecircState( void ); static TREATMENT_STOP_STATE_T handleTreatmentStopBloodRecircState( void ); +static void handleTreatmentStopBloodSittingTimer( void ); static void publishTreatmentStopData( void ); @@ -152,8 +153,8 @@ static void setupForBloodRecirculationState( void ) { // Close VBA and VBV valves to bypass patient for blood recirculation - setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBA, VALVE_POSITION_B_OPEN ); + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); // Ensure syringe pump is stopped stopSyringePump(); // Start blood pump at re-circulate flow rate @@ -213,20 +214,6 @@ *************************************************************************/ void execTreatmentStop( void ) { - // Ensure we do not sit in stopped state for too long (if blood in line) - if ( getRinsebackCompleted() != TRUE ) - { - 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 ); - } - } - // Execute treatment stop sub-mode state machine switch ( currentTxStopState ) { @@ -335,6 +322,8 @@ { TREATMENT_STOP_STATE_T result = TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE; + handleTreatmentStopBloodSittingTimer(); + result = handleTreatmentStopAlarmsAndSignals(result); return result; @@ -369,13 +358,44 @@ { TREATMENT_STOP_STATE_T result = TREATMENT_STOP_NO_RECIRC_STATE; + handleTreatmentStopBloodSittingTimer(); + result = handleTreatmentStopAlarmsAndSignals(result); return result; } /*********************************************************************//** * @brief + * The handleTreatmentStopBloodSittingTimer function handles the no re-circ + * blood timer. It should only be called when Blood is NOT circulating. + * Increments and checks for warning and alarm timeouts. + * @details Inputs: none + * @details Outputs: none + * @return next treatment stop state + *************************************************************************/ +static void handleTreatmentStopBloodSittingTimer( void ) +{ + // Ensure we do not sit in stopped state for too long (if blood in line) + if ( getRinsebackCompleted() != TRUE ) + { + 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 ); + } + } + else + { + bloodSittingTimerCtr = 0; + } +} +/*********************************************************************//** + * @brief * The getCurrentTreatmentStopState function returns the current state of the * treatment stop sub-mode. * @details Inputs: currentTxStopState @@ -401,15 +421,18 @@ { TREATMENT_STOP_PAYLOAD_T data; - data.timeout = MAX_TIME_BLOOD_SITTING / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); + // Set to zero so UI will not update unless needed below + data.timeout = 0; + data.countdown = 0; + if ( getRinsebackCompleted() != TRUE ) { - data.countdown = ( bloodSittingTimerCtr >= MAX_TIME_BLOOD_SITTING ? 0 : ( MAX_TIME_BLOOD_SITTING - bloodSittingTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); + if (0 < bloodSittingTimerCtr) + { + data.timeout = MAX_TIME_BLOOD_SITTING / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); + 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; broadcastData( MSG_ID_HD_TREATMENT_STOP_TIMER_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( TREATMENT_STOP_PAYLOAD_T ) ); }