Index: firmware/App/Modes/TreatmentRecirc.c =================================================================== diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 --- firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304) +++ firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6) @@ -34,8 +34,10 @@ // ********** private definitions ********** -/// Alarm if re-circulation is running for this much time. TODO - finalize these times w/ Systems +/// Maximum time allowed to be in recirculation sub-mode. static const U32 RECIRC_TIMEOUT = ( ( 15 * SEC_PER_MIN * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ); +/// Warn user they need to reconnect to system and resume their treatment soon. +static const U32 RECIRC_WARNING_TIMEOUT = ( ( 13 * SEC_PER_MIN * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ); /// Re-circulation status broadcast interval. static const U32 RECIRC_DATA_PUBLISH_INTERVAL = ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); /// Target flow rate for re-circulation of saline on blood-side circuit. @@ -47,6 +49,7 @@ static U32 recircTimerCtr; ///< Timer counter (in GP task intervals) counts time spent in re-circulation sub-mode. static U32 recircPublishTimerCtr; ///< Timer counter (in GP task intervals) counts time to next status broadcast. +static BOOL recircTimeoutWarningGiven; ///< Flag indicates 10 minute warning has been given to user. static BOOL recircReconnectRequested; ///< Flag indicates user requesting re-circulate stop so they can re-connect. static BOOL recircBackToTreatmenRequested; ///< Flag indicates user requesting to go back to treatment (confirming re-connected). @@ -84,6 +87,7 @@ recircTimerCtr = 0; recircPublishTimerCtr = 0; resetTreatmentRecircFlags(); + recircTimeoutWarningGiven = FALSE; } /*********************************************************************//** @@ -236,8 +240,14 @@ else if ( recircTimerCtr > RECIRC_TIMEOUT ) { signalGoToTreatmentStopped(); + clearAlarm( ALARM_ID_HD_TREATMENT_RECIRC_TIMEOUT_WARNING ); activateAlarmNoData( ALARM_ID_TREATMENT_RECIRC_TIMEOUT_ALARM ); } + else if ( ( recircTimeoutWarningGiven != TRUE ) && ( RECIRC_WARNING_TIMEOUT == recircTimerCtr ) ) + { + recircTimeoutWarningGiven = TRUE; + activateAlarmNoData( ALARM_ID_HD_TREATMENT_RECIRC_TIMEOUT_WARNING ); + } return result; } @@ -276,6 +286,11 @@ signalGoToTreatmentStopped(); activateAlarmNoData( ALARM_ID_TREATMENT_RECIRC_TIMEOUT_ALARM ); } + else if ( ( recircTimeoutWarningGiven != TRUE ) && ( recircTimerCtr > RECIRC_WARNING_TIMEOUT ) ) + { + recircTimeoutWarningGiven = TRUE; + activateAlarmNoData( ALARM_ID_HD_TREATMENT_RECIRC_TIMEOUT_WARNING ); + } return result; } @@ -462,11 +477,13 @@ { if ( ++recircPublishTimerCtr >= RECIRC_DATA_PUBLISH_INTERVAL ) { - U32 timeout = RECIRC_TIMEOUT / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); - U32 countdown = ( recircTimerCtr >= RECIRC_TIMEOUT ? 0 : ( RECIRC_TIMEOUT - recircTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); + TREATMENT_RECIRC_PAYLOAD_T data; + data.timeout = RECIRC_TIMEOUT / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); + data.countdown = ( recircTimerCtr >= RECIRC_TIMEOUT ? 0 : ( RECIRC_TIMEOUT - recircTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); + recircPublishTimerCtr = 0; - broadcastRecircData( timeout, countdown ); + broadcastData( MSG_ID_HD_RECIRC_PROGRESS, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( TREATMENT_RECIRC_PAYLOAD_T ) ); } }