Index: firmware/App/Modes/TreatmentRecirc.c =================================================================== diff -u -r4151ee46ace3cc66b6b7c0f276040889fe0d75e6 -rf66a94fdd645d2146e828fd760960849d1ac05c6 --- firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 4151ee46ace3cc66b6b7c0f276040889fe0d75e6) +++ firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision f66a94fdd645d2146e828fd760960849d1ac05c6) @@ -36,6 +36,8 @@ /// Alarm if re-circulation is running for this much time. TODO - finalize these times w/ Systems #define RECIRC_TIMEOUT_MS ( ( 15 * 60 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) +/// Re-circulation status broadcast interval. +#define RECIRC_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Target flow rate for re-circulation of saline on blood-side circuit. #define RECIRC_BP_FLOW_RATE_ML_MIN 100 @@ -44,6 +46,7 @@ static TREATMENT_RECIRC_STATE_T treatmentRecircState; ///< Current state of the treatment re-circulate sub-mode. 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 recircStopRequested; ///< Flag indicates alarm requesting to stop rinseback. static BOOL recircReconnectRequested; ///< Flag indicates user requesting re-circulate stop so they can re-connect. @@ -66,6 +69,8 @@ static BOOL handleRecircResumeUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); static BOOL handleRecircEndTreatmentUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); +static void publishTreatmentRecircData( void ); + /*********************************************************************//** * @brief * The initTreatmentRecirc function initializes the Treatment Re-circulate sub-mode @@ -78,6 +83,7 @@ { treatmentRecircState = TREATMENT_RECIRC_RECIRC_STATE; recircTimerCtr = 0; + recircPublishTimerCtr = 0; resetTreatmentRecircFlags(); } @@ -177,7 +183,7 @@ *************************************************************************/ void execTreatmentRecirc( void ) { - // count time in this sub-mode + // Count time in this sub-mode recircTimerCtr++; switch ( treatmentRecircState ) @@ -197,6 +203,9 @@ // Re-circulate flags should be handled by now - reset in case not handled by current state resetTreatmentRecircFlags(); + + // Broadcast recirc status + publishTreatmentRecircData(); } /*********************************************************************//** @@ -454,4 +463,24 @@ return treatmentRecircState; } +/*********************************************************************//** + * @brief + * The publishTreatmentRecircData function publishes recirc progress to UI + * at 1 Hz interval. + * @details Inputs: recircPublishTimerCtr, recircTimerCtr + * @details Outputs: recirc data published + * @return none + *************************************************************************/ +static void publishTreatmentRecircData( void ) +{ + if ( ++recircPublishTimerCtr >= RECIRC_DATA_PUBLISH_INTERVAL ) + { + U32 timeout = RECIRC_TIMEOUT_MS / TASK_GENERAL_INTERVAL; + U32 countdown = ( recircTimerCtr >= RECIRC_TIMEOUT_MS ? 0 : ( RECIRC_TIMEOUT_MS - recircTimerCtr ) / TASK_GENERAL_INTERVAL ); + + recircPublishTimerCtr = 0; + broadcastRecircData( timeout, countdown ); + } +} + /**@}*/