Index: firmware/App/Services/TDInterface.c =================================================================== diff -u -r623587d96bf6c0bafd3ff94d47f8c783b4b999f0 -re91d5fb68c811626c1c7786c5ca3d89bcdc63447 --- firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision 623587d96bf6c0bafd3ff94d47f8c783b4b999f0) +++ firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision e91d5fb68c811626c1c7786c5ca3d89bcdc63447) @@ -52,9 +52,26 @@ #define TD_ACID_TYPE_MIN ( 0U ) ///< TD Min acid type index #define TD_ACID_TYPE_MAX ( (U32)( NUM_OF_ACID_TYPE - 1U ) ) ///< TD Max acid type index -#define TD_BICARB_TYPE_MIN ( 0U ) ///< TD Min bicarb type index -#define TD_BICARB_TYPE_MAX ( (U32)( NUM_OF_BICARB_TYPE - 1U ) ) ///< TD Max bicarb type index +#define TD_SODIUM_MIN ( 130U ) ///< TD Min acid type index +#define TD_SODIUM_MAX ( 155U ) ///< TD Max acid type index +#define TD_BICARBONATE_MIN ( 20U ) ///< TD Min acid type index +#define TD_BICARBONATE_MAX ( 40U ) ///< TD Max acid type index + +#define BICARBONATE_CONVERSION_FACTOR 0.07337F ///< Bicarbonate conversion factor mS/cm per mmol/L + +/// Acid concentration conversion factors for each acid type +const F32 ACID_CONVERSION_FACTOR[ NUM_OF_ACID_TYPE - 1 ] = { 0.11192F, + 0.11313F, + 0.11435F, + 0.0F, + 0.0F, + 0.0F, + 0.0F, + 0.0F, + 0.0F, + 0.0F }; + /// Enumeration of TD Treatment Overrides typedef enum TD_Treatment_Override { @@ -77,8 +94,10 @@ static OVERRIDE_F32_T tdDialysateFlowrate; ///< TD Dialysate flow rate static OVERRIDE_F32_T tdUFRate; ///< TD ultrafiltration rate static OVERRIDE_F32_T tdDialysateTemp; ///< TD Target Dialysate Temperature -static OVERRIDE_U32_T tdAcidType; ///< TD Acid type -static OVERRIDE_U32_T tdBicarbType; ///< TD Bicarb type +static OVERRIDE_F32_T tdAcidConvFactor; ///< TD Acid conversion factor +static OVERRIDE_F32_T tdBicarbConvFactor; ///< TD Bicarb conversion factor +static OVERRIDE_U32_T tdSodium; ///< TD Sodium concentrate +static OVERRIDE_U32_T tdBicarbonate; ///< TD Bicarbonate concentrate // ********** private function prototypes ********** @@ -115,15 +134,25 @@ tdDialysateTemp.ovInitData = TD_DIALYSATE_TEMP_MIN_DEGC; tdDialysateTemp.override = OVERRIDE_RESET; - tdAcidType.data = TD_ACID_TYPE_MIN; - tdAcidType.ovData = TD_ACID_TYPE_MIN; - tdAcidType.ovInitData = TD_ACID_TYPE_MIN; - tdAcidType.override = OVERRIDE_RESET; + tdAcidConvFactor.data = 0.0F; + tdAcidConvFactor.ovData = 0.0F; + tdAcidConvFactor.ovInitData = ACID_CONVERSION_FACTOR[ TD_ACID_TYPE_MIN ]; + tdAcidConvFactor.override = OVERRIDE_RESET; - tdBicarbType.data = TD_BICARB_TYPE_MIN; - tdBicarbType.ovData = TD_BICARB_TYPE_MIN; - tdBicarbType.ovInitData = TD_BICARB_TYPE_MIN; - tdBicarbType.override = OVERRIDE_RESET; + tdBicarbConvFactor.data = 0.0F; + tdBicarbConvFactor.ovData = 0.0F; + tdBicarbConvFactor.ovInitData = BICARBONATE_CONVERSION_FACTOR; + tdBicarbConvFactor.override = OVERRIDE_RESET; + + tdSodium.data = 0.0F; + tdSodium.ovData = 0.0F; + tdSodium.ovInitData = TD_SODIUM_MIN; + tdSodium.override = OVERRIDE_RESET; + + tdBicarbonate.data = 0.0F; + tdBicarbonate.ovData = 0.0F; + tdBicarbonate.ovInitData = TD_BICARBONATE_MIN; + tdBicarbonate.override = OVERRIDE_RESET; } /**********************************************************************//** @@ -283,15 +312,17 @@ * The setTDAcidAndBicarbType function sets the acid and bicarb types to be * used in dialysate generation. * @details \b Inputs: none - * @details \b Outputs: tdAcidType,tdBicarbType + * @details \b Outputs: tdAcidConvFactor,tdBicarbConvFactor * @param acid which is the type of acid * @param bicarb which is the type of bicarb * @return none *************************************************************************/ -void setTDAcidAndBicarbType( U32 acid, U32 bicarb ) +void setTDAcidAndBicarbType( F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ) { - tdAcidType.data = (DD_ACID_TYPES_T)acid; - tdBicarbType.data = (DD_BICARB_TYPES_T)bicarb; + tdAcidConvFactor.data = acidConvFactor; + tdBicarbConvFactor.data = bicarbConvFactor; + tdSodium.data = sodium; + tdBicarbonate.data = bicarbonate; } /*********************************************************************//** @@ -346,39 +377,66 @@ return tdDialyzerBypass; } - /****************************************************************************** * @brief - * The getTDAcidConcentrateType function gets the latest Acid concentrate - * type. - * @details \b Inputs: tdAcidType + * The getTDAcidConversionFactor function gets the latest Acid concentrate + * conversion factor. + * @details \b Inputs: tdAcidConvFactor * @details \b Outputs: None * @return Latest acid concentrate type. . ******************************************************************************/ -DD_ACID_TYPES_T getTDAcidConcentrateType( void ) +F32 getTDAcidConversionFactor( void ) { - U32 value = getU32OverrideValue( &tdAcidType ); + F32 value = getF32OverrideValue( &tdAcidConvFactor ); - return (DD_ACID_TYPES_T)value; + return value; } /*********************************************************************//** * @brief - * The getTDBicarbConcentrateType function gets the latest Bicarb concentrate - * type. - * @details \b Inputs: tdBicarbType + * The getTDBicarbConversionFactor function gets the latest Bicarb concentrate + * conversion factor. + * @details \b Inputs: tdBicarbConvFactor * @details \b Outputs: none * @return Latest bicarb concentrate type. *************************************************************************/ -DD_BICARB_TYPES_T getTDBicarbConcentrateType( void ) +F32 getTDBicarbConversionFactor( void ) { - U32 value = getU32OverrideValue( &tdBicarbType ); + F32 value = getF32OverrideValue( &tdBicarbConvFactor ); - return (DD_BICARB_TYPES_T)value; + return value; } +/****************************************************************************** + * @brief + * The getTDSodiumConcentration function gets the Sodium concentration. + * @details \b Inputs: tdSodium + * @details \b Outputs: None + * @return Latest sodium concentration. + ******************************************************************************/ +U32 getTDSodiumConcentration( void ) +{ + U32 value = getU32OverrideValue( &tdSodium ); + + return value; +} + /*********************************************************************//** * @brief + * The getTDBicarbonateConcentration function gets the latest bicarbonate concentration + * @details \b Inputs: tdBicarbonate + * @details \b Outputs: none + * @return Latest bicarbonate concentration. + *************************************************************************/ +U32 getTDBicarbonateConcentration( void ) +{ + U32 value = getU32OverrideValue( &tdBicarbonate ); + + return value; +} + +/*********************************************************************//** + * @brief * The handlePreGenDialysateRequestMsg function handles a pre gen dailysate * delivery request from TD to perform required self test and priming process. * @details Inputs: none @@ -422,7 +480,8 @@ // Update Temperature, Acid/Bicarb type and dialysate rate for pregen process. setTDDialysateFlowrate( startPreGenRequest.dialRate ); setTDTargetDialysateTemperature( startPreGenRequest.dialTemp ); - setTDAcidAndBicarbType( startPreGenRequest.acidType, startPreGenRequest.bicarbType ); + setTDAcidAndBicarbType( startPreGenRequest.acidConvFactor, startPreGenRequest.bicarbConvFactor, + startPreGenRequest.sodium, startPreGenRequest.bicarbonate ); } else if ( DD_MODE_PREG == ddMode ) { @@ -478,7 +537,8 @@ setTDTargetDialysateTemperature( startTxRequest.dialTemp ); // Set concentrate types, Bypass dialyzer - setTDAcidAndBicarbType( startTxRequest.acidType, startTxRequest.bicarbType ); + setTDAcidAndBicarbType( startTxRequest.acidConvFactor, startTxRequest.bicarbConvFactor, + startTxRequest.sodium, startTxRequest.bicarbonate ); setTDDialyzerBypass( startTxRequest.bypassDialyzer ); // start dialysate generation @@ -506,7 +566,8 @@ setTDTargetDialysateTemperature( startTxRequest.dialTemp ); // Set concentrate types, Bypass dialyzer - setTDAcidAndBicarbType( startTxRequest.acidType, startTxRequest.bicarbType ); + setTDAcidAndBicarbType( startTxRequest.acidConvFactor, startTxRequest.bicarbConvFactor, + startTxRequest.sodium, startTxRequest.bicarbonate ); setTDDialyzerBypass( startTxRequest.bypassDialyzer ); // Signal to update treatement parameters @@ -560,12 +621,13 @@ result = f32Override( message, &tdDialysateTemp ); break; + // TODO change acid and bicarb types to convFactor and add Sodium and Bicarbonate case TD_TREATMENT_OVERRIDE_ACID_TYPE: - result = u32Override( message,&tdAcidType,TD_ACID_TYPE_MIN,TD_ACID_TYPE_MAX ); + result = f32Override( message, &tdAcidConvFactor); break; case TD_TREATMENT_OVERRIDE_BICARB_TYPE: - result = u32Override( message,&tdBicarbType,TD_BICARB_TYPE_MIN,TD_BICARB_TYPE_MAX ); + result = f32Override( message, &tdBicarbConvFactor); break; default: