Index: firmware/App/Controllers/Ultrafiltration.c =================================================================== diff -u -r94789b2f2324d5901685b6ff7b6224d4af3a0276 -r60e6185c2c5df195ccb6b603f30548779b4f05c4 --- firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision 94789b2f2324d5901685b6ff7b6224d4af3a0276) +++ firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision 60e6185c2c5df195ccb6b603f30548779b4f05c4) @@ -37,6 +37,7 @@ #define COMP_SLOPE -0.000376F ///< UF Temperature compensation slope factor #define COMP_INTERCEPT 1.007269F ///< UF temperature compensation intercept factor #define ZERO_RATE 0.0F ///< Zero value. +#define UF_VOLUME_ML_PER_ML_MIN_PER_TASK ( (F32)TASK_GENERAL_INTERVAL / ( (F32)MS_PER_SECOND * (F32)SEC_PER_MIN ) ) // ********** private data ********** @@ -47,6 +48,7 @@ static U32 ufDataPublicationTimerCounter; ///< Used to schedule ultrafiltration data publication to CAN bus. static BOOL isUFRateUpdated; ///< flag indicating to update UF rate needed. static OVERRIDE_U32_T ufDataPublishInterval; ///< Ultrafiltration data publish interval. +static F32 ufVolumeDeliveredMl; ///< Accumulated UF volume delivered in mL. // ********** private function prototypes ********** @@ -75,6 +77,7 @@ compUFrate = getTDUFRate(); ufDataPublicationTimerCounter = 0; isUFRateUpdated = FALSE; + ufVolumeDeliveredMl = 0.0F; } /*********************************************************************//** @@ -122,6 +125,11 @@ // Calculate UF volume and determine UF pause/run updateUFRequest(); + if ( ( DD_UF_RUNNING == ufExecState ) && ( compUFrate > ZERO_RATE ) ) + { + ufVolumeDeliveredMl += compUFrate * UF_VOLUME_ML_PER_ML_MIN_PER_TASK; + } + // execute current ultrafiltration exec state switch ( ufExecState ) { @@ -230,6 +238,30 @@ /*********************************************************************//** * @brief + * The resetUFVolumeDelivered function resets the accumulated UF volume. + * @details \b Inputs: none + * @details \b Outputs: ufVolumeDeliveredMl + * @return none + *************************************************************************/ +void resetUFVolumeDelivered( void ) +{ + ufVolumeDeliveredMl = 0.0F; +} + +/*********************************************************************//** + * @brief + * The getUFVolumeDeliveredLiters function returns accumulated UF volume. + * @details \b Inputs: ufVolumeDeliveredMl + * @details \b Outputs: none + * @return UF volume delivered in liters. + *************************************************************************/ +F32 getUFVolumeDeliveredLiters( void ) +{ + return ufVolumeDeliveredMl / (F32)ML_PER_LITER; +} + +/*********************************************************************//** + * @brief * The UpdateUFCompensation function updates the ultrafiltration rate * based on the dialysate temperature compensation. * @details \b Inputs: D4 and D50 temperature @@ -304,6 +336,7 @@ data.ufRate = getTDUFRate(); data.compUFrate = compUFrate; data.isUFRequested = (U32)isUltrafiltrationRequested; + data.ufVolumeDeliveredMl = ufVolumeDeliveredMl; broadcastData( MSG_ID_DD_UF_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( UF_DATA_T ) );