Index: firmware/App/Services/DDInterface.c =================================================================== diff -u -rda59fa4a98dbc11c37677e92a66aa940d251678f -r52787cd53986cfd0abb7e674bf096898e5070f9a --- firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision da59fa4a98dbc11c37677e92a66aa940d251678f) +++ firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 52787cd53986cfd0abb7e674bf096898e5070f9a) @@ -7,8 +7,8 @@ * * @file DDInterface.c * -* @author (last) Raghu Kallala -* @date (last) 01-May-2026 +* @author (last) Varshini Nagabooshanam +* @date (last) 15-Jun-2026 * * @author (original) Sean Nash * @date (original) 01-Aug-2024 @@ -40,6 +40,7 @@ static DD_OP_MODE_T ddCurrentOpMode; ///< Current DD operation mode. static U32 ddSubMode; ///< Current state (sub-mode) of current DD operation mode. static F32 dialysatePressure; ///< Current dialysate pressure reported by DD. +static F32 ddUFVolumeDeliveredLiters; ///< Latest UF volume delivered reported by DD (L). static BOOL ddStartCommandSent; ///< Flag indicates command to start DD has been sent. static BOOL ddStarted; ///< Flag indicates whether we have commanded the DD to start or stop. static BOOL isDialysateGoodtoDeliver; ///< Flag indicating whether dialysate is good to deliver. @@ -72,6 +73,7 @@ ddCurrentOpMode = DD_MODE_INIT; ddSubMode = 0; dialysatePressure = 0.0F; + ddUFVolumeDeliveredLiters = 0.0F; isDialysateGoodtoDeliver = FALSE; ddOpModeDataFreshFlag = FALSE; @@ -115,11 +117,12 @@ dialysateDeliveryCmdSet.dialRate = 0.0F; dialysateDeliveryCmdSet.ufRate = 0.0F; dialysateDeliveryCmdSet.dialTemp = 0.0F; - dialysateDeliveryCmdSet.bypassDialyzer = TRUE; + dialysateDeliveryCmdSet.genDialysateState = DD_GEND_DIALYSATE_BYPASS_STATE; dialysateDeliveryCmdSet.acidConvFactor = 0.0F; dialysateDeliveryCmdSet.bicarbConvFactor = 0.0F; dialysateDeliveryCmdSet.sodium = 0; dialysateDeliveryCmdSet.bicarbonate = 0; + dialysateDeliveryCmdSet.substitutionRate = 0.0F; } /**********************************************************************//** @@ -279,6 +282,43 @@ /*********************************************************************//** * @brief + * The setUFData function stores the latest DD ultrafiltration broadcast data. + * @details \b Inputs: message payload + * @details \b Outputs: ddUFVolumeDeliveredLiters + * @param message Pointer to the DD UF data broadcast message + * @return TRUE if message handled successfully, FALSE if not + *************************************************************************/ +BOOL setUFData( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_UF_DATA_T payload; + + memcpy( &payload, &message->payload[ 0 ], sizeof( DD_UF_DATA_T ) ); + + if ( message->hdr.payloadLen == sizeof( DD_UF_DATA_T ) ) + { + ddUFVolumeDeliveredLiters = payload.ufVolumeDeliveredMl / (F32)ML_PER_LITER; + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getDDUFVolumeDeliveredLiters function gets the latest DD-reported UF + * volume delivered. + * @details \b Inputs: ddUFVolumeDeliveredLiters + * @details \b Outputs: none + * @return Latest UF volume delivered in liters. + *************************************************************************/ +F32 getDDUFVolumeDeliveredLiters( void ) +{ + return ddUFVolumeDeliveredLiters; +} + +/*********************************************************************//** + * @brief * The getDialysatePressure function gets the latest reported dialysate * pressure. * @details \b Inputs: dialysatePressure @@ -382,25 +422,27 @@ * @param qd Target dialysate flow rate (Qd). * @param quf Target ultrafiltration rate (Quf) (in mL/min). * @param dialTemp Target dialysate temperature in deg C. - * @param bypass Flag indicating whether dialyzer should be bypassed. + * @param genDialysateState Requested DD gen dialysate sub-state (DD_GEND_MODE_STATE_T). * @param acidConvFactor Conversion factor for the acid used. * @param bicarbConvFactor Conversion factor for the bicarbonate used. * @param sodium Level of sodium used in mEq/L. * @param bicarbonate Level of bicarbonate used in mEq/L. * @return none *************************************************************************/ -void cmdStartGenerateDialysate( F32 qd, F32 quf, F32 dialTemp, BOOL bypass, F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ) +void cmdStartGenerateDialysate( F32 qd, F32 quf, F32 dialTemp, U32 genDialysateState, F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ) { - dialysateDeliveryCmdSet.start = TRUE; - dialysateDeliveryCmdSet.dialRate = qd; - dialysateDeliveryCmdSet.ufRate = quf; - dialysateDeliveryCmdSet.dialTemp = dialTemp; - dialysateDeliveryCmdSet.bypassDialyzer = bypass; - dialysateDeliveryCmdSet.acidConvFactor = acidConvFactor; - dialysateDeliveryCmdSet.bicarbConvFactor = bicarbConvFactor; - dialysateDeliveryCmdSet.sodium = sodium; - dialysateDeliveryCmdSet.bicarbonate = bicarbonate; + dialysateDeliveryCmdSet.start = TRUE; + dialysateDeliveryCmdSet.dialRate = qd; + dialysateDeliveryCmdSet.ufRate = quf; + dialysateDeliveryCmdSet.dialTemp = dialTemp; + dialysateDeliveryCmdSet.genDialysateState = genDialysateState; + dialysateDeliveryCmdSet.acidConvFactor = acidConvFactor; + dialysateDeliveryCmdSet.bicarbConvFactor = bicarbConvFactor; + dialysateDeliveryCmdSet.sodium = sodium; + dialysateDeliveryCmdSet.bicarbonate = bicarbonate; + dialysateDeliveryCmdSet.substitutionRate = 0.0F; + #ifndef TEST_UI_ONLY sendMessage( MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&dialysateDeliveryCmdSet), sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); #endif @@ -459,20 +501,19 @@ /*********************************************************************//** * @brief - * The cmdBypassDialyzer function sends a generate dialysate command to the DD - * with a given flag indicating whether dialyzer should be bypassed. + * The cmdSetGenDialysateState function sends a generate dialysate command to + * the DD with a requested gen dialysate sub-state. * @details \b Inputs: none * @details \b Outputs: dialysateDeliveryCmdSet - * @details \b Message \b Sent: Continue generate dialysate command w/ new - * dialyzer bypass flag. - * @param bypass Flag indicating whether dialyzer should be bypassed. + * @details \b Message \b Sent: Continue generate dialysate command w/ new sub-state. + * @param genDialysateState Requested DD gen dialysate sub-state. * @return none *************************************************************************/ -void cmdBypassDialyzer( BOOL bypass ) +void cmdSetGenDialysateState( U32 genDialysateState ) { if ( TRUE == dialysateDeliveryCmdSet.start ) { - dialysateDeliveryCmdSet.bypassDialyzer = bypass; + dialysateDeliveryCmdSet.genDialysateState = genDialysateState; #ifndef TEST_UI_ONLY sendMessage( MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&dialysateDeliveryCmdSet), sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); #endif @@ -485,6 +526,23 @@ /*********************************************************************//** * @brief + * The cmdBypassDialyzer function sends a generate dialysate command to the DD + * requesting bypass or delivery sub-state. + * @details \b Inputs: none + * @details \b Outputs: dialysateDeliveryCmdSet + * @details \b Message \b Sent: Continue generate dialysate command w/ new sub-state. + * @param bypass Flag indicating whether dialyzer should be bypassed. + * @return none + *************************************************************************/ +void cmdBypassDialyzer( BOOL bypass ) +{ + U32 genDialysateState = ( TRUE == bypass ) ? DD_GEND_DIALYSATE_BYPASS_STATE : DD_GEND_DIALYSATE_DELIVERY_STATE; + + cmdSetGenDialysateState( genDialysateState ); +} + +/*********************************************************************//** + * @brief * The cmdStopGenerateDialysate function sends a stop generate dialysate command * to the DD. DD will transition back to standby mode. * @details \b Inputs: none @@ -597,7 +655,33 @@ // } } +/*********************************************************************//** + * @brief + * The cmdSubstitutionRate function sends a generate dialysate command to + * the DD with a given substitution (D92) pump rate for HDF / HD-online + * fluid bolus delivery. + * @details \b Message \b Sent: MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA + * @details \b Inputs: none + * @details \b Outputs: dialysateDeliveryCmdSet + * @param qs Target substitution flow rate (mL/min) + * @return none + *************************************************************************/ +void cmdSubstitutionRate( F32 qs ) +{ + if ( TRUE == dialysateDeliveryCmdSet.start ) + { + dialysateDeliveryCmdSet.substitutionRate = qs; +#ifndef TEST_UI_ONLY + sendMessage( MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&dialysateDeliveryCmdSet), sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); +#endif + } + else + { + // TODO - s/w fault? + } +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/