Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -r00f9e708bd590c51dc8a83b59ed5d31a4e0b80b8 -rf66a94fdd645d2146e828fd760960849d1ac05c6 --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 00f9e708bd590c51dc8a83b59ed5d31a4e0b80b8) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision f66a94fdd645d2146e828fd760960849d1ac05c6) @@ -924,7 +924,8 @@ * @brief * The publishRinsebackData function publishes rinseback progress to UI * at 1 Hz interval. - * @details Inputs: rinsebackPublishTimerCtr + * @details Inputs: rinsebackPublishTimerCtr, rinsebackTimerCtr, rinsebackState, + * cumulativeRinsebackVolume_mL, rinsebackRate_mL_min * @details Outputs: rinseback data published * @return none *************************************************************************/ @@ -933,11 +934,20 @@ if ( ++rinsebackPublishTimerCtr >= RINSEBACK_DATA_PUBLISH_INTERVAL ) { RINSEBACK_DATA_PAYLOAD_T data; + U32 timeout = MAX_RINSEBACK_TIME / TASK_GENERAL_INTERVAL; + U32 countdown = ( rinsebackTimerCtr >= MAX_RINSEBACK_TIME ? 0 : ( MAX_RINSEBACK_TIME - rinsebackTimerCtr ) / TASK_GENERAL_INTERVAL ); rinsebackPublishTimerCtr = 0; + // If we have completed rinseback, timeout is no longer in force + if ( ( rinsebackState > RINSEBACK_PAUSED_STATE ) && ( cumulativeRinsebackVolume_mL >= TARGET_RINSEBACK_VOLUME_ML ) ) + { + timeout = 0; + } data.targetRinsebackVolumeMl = TARGET_RINSEBACK_VOLUME_ML; data.deliveredRinsebackVolumeMl = cumulativeRinsebackVolume_mL; data.rinsebackFlowRateMlMin = rinsebackRate_mL_min; + data.timeout = timeout; + data.countdown = countdown; broadcastRinsebackData( data ); } } Index: firmware/App/Modes/Rinseback.h =================================================================== diff -u -r00f9e708bd590c51dc8a83b59ed5d31a4e0b80b8 -rf66a94fdd645d2146e828fd760960849d1ac05c6 --- firmware/App/Modes/Rinseback.h (.../Rinseback.h) (revision 00f9e708bd590c51dc8a83b59ed5d31a4e0b80b8) +++ firmware/App/Modes/Rinseback.h (.../Rinseback.h) (revision f66a94fdd645d2146e828fd760960849d1ac05c6) @@ -42,6 +42,8 @@ F32 targetRinsebackVolumeMl; F32 deliveredRinsebackVolumeMl; U32 rinsebackFlowRateMlMin; + U32 timeout; + U32 countdown; } RINSEBACK_DATA_PAYLOAD_T; #pragma pack(pop) 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 ); + } +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rc46815918e7cf33e8736f180094843758f1e21b2 -rf66a94fdd645d2146e828fd760960849d1ac05c6 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c46815918e7cf33e8736f180094843758f1e21b2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision f66a94fdd645d2146e828fd760960849d1ac05c6) @@ -1222,6 +1222,36 @@ /***********************************************************************//** * @brief + * The broadcastRecircData function constructs a treatment re-circ data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: treatment re-circ data msg constructed and queued + * @param timeout re-circulation timeout (in sec) + * @param countdown re-circulation timeout count down (in sec) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastRecircData( U32 timeout, U32 countdown ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RECIRC_PROGRESS; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &timeout, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; + +} + +/***********************************************************************//** + * @brief * The broadcastBloodPrimeData function constructs a blood prime data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rc46815918e7cf33e8736f180094843758f1e21b2 -rf66a94fdd645d2146e828fd760960849d1ac05c6 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision c46815918e7cf33e8736f180094843758f1e21b2) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision f66a94fdd645d2146e828fd760960849d1ac05c6) @@ -251,6 +251,9 @@ // MSG_ID_HD_RINSEBACK_PROGRESS BOOL broadcastRinsebackData( RINSEBACK_DATA_PAYLOAD_T data ); +// MSG_ID_HD_RECIRC_PROGRESS +BOOL broadcastRecircData( U32 timeout, U32 countdown ); + // MSG_ID_HD_BLOOD_PRIME_PROGRESS BOOL broadcastBloodPrimeData( BLOOD_PRIME_DATA_PAYLOAD_T data );