Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r6b870cd0699bb3ee22b93981d51373a6c2d56162 -r3135defd5053f5724eac7375ffd56ad1d129d5ae --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 6b870cd0699bb3ee22b93981d51373a6c2d56162) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 3135defd5053f5724eac7375ffd56ad1d129d5ae) @@ -22,6 +22,7 @@ #include "DialOutFlow.h" #include "ModeTreatment.h" #include "OperationModes.h" +#include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TreatmentStop.h" #include "Valves.h" @@ -35,17 +36,22 @@ /// 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 ); +/// Treatment stop status broadcast interval. +static const U32 TREATMENT_STOP_DATA_PUBLISH_INTERVAL = ( 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. +static U32 stopPublishTimerCtr; ///< Timer counter (in GP task intervals) counts time to next status broadcast. // ********** private function prototypes ********** static TREATMENT_STOP_STATE_T handleTreatmentStopRecircState( void ); static TREATMENT_STOP_STATE_T handleTreatmentStopNoRecircState( void ); +static void publishTreatmentStopData( void ); + /*********************************************************************//** * @brief * The initTreatmentStop function initializes the Treatment Stop sub-mode @@ -58,6 +64,7 @@ { currentTxStopState = TREATMENT_STOP_RECIRC_STATE; bloodSittingTimerCtr = 0; + stopPublishTimerCtr = 0; } /*********************************************************************//** @@ -153,6 +160,9 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_TREATMENT_STOP_INVALID_STATE, currentTxStopState ); break; } + + // Broadcast treatment stop status + publishTreatmentStopData(); } /*********************************************************************//** @@ -208,4 +218,24 @@ return currentTxStopState; } +/*********************************************************************//** + * @brief + * The publishTreatmentStopData function publishes treatment stop progress to UI + * at 1 Hz interval. + * @details Inputs: stopPublishTimerCtr, bloodSittingTimerCtr + * @details Outputs: treatment stop data published + * @return none + *************************************************************************/ +static void publishTreatmentStopData( void ) +{ + if ( ++stopPublishTimerCtr >= TREATMENT_STOP_DATA_PUBLISH_INTERVAL ) + { + U32 timeout = MAX_TIME_BLOOD_SITTING / TASK_GENERAL_INTERVAL; + U32 countdown = ( bloodSittingTimerCtr >= MAX_TIME_BLOOD_SITTING ? 0 : ( MAX_TIME_BLOOD_SITTING - bloodSittingTimerCtr ) / TASK_GENERAL_INTERVAL ); + + stopPublishTimerCtr = 0; + broadcastTreatmentStopData( timeout, countdown ); + } +} + /**@}*/