/************************************************************************** * * Copyright (c) 2025-2025 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file TxParams.c * * @author (last) Sean * @date (last) 26-Nov-2025 * * @author (original) Sean * @date (original) 17-Nov-2025 * ***************************************************************************/ #include "AirPump.h" #include "AirTrap.h" #include "BloodFlow.h" #include "Buttons.h" #include "Messaging.h" #include "ModeTreatment.h" #include "ModePreTreat.h" #include "OperationModes.h" #include "Pressures.h" #include "StateTxDialysis.h" #include "Switches.h" #include "TDCommon.h" #include "TxParams.h" #include "Utilities.h" #include "Valve3Way.h" #include "Valves.h" /** * @addtogroup TxParams * @{ */ // ********** private definitions ********** #define MAX_HEPARIN_VOLUME_ML 10.0F ///< Maximum heparin volume ( in mL ) #define NO_HEPARIN_PRE_STOP_TIME_SET 0 ///< Zero value indicates no Heparin pre-stop time was set by user #define NO_HEPARIN_TYPE_SET 0xFFFFFFFF ///< UI will send this value for Heparin type if Heparin not used #define INSTIT_CHEM_DISINFECT_ENABLE_RANGE 1 ///< Institutional record chemical disinfect enable/disable allowable range #define SYRINGE_PUMP_PRIME_VOLUME_ML 0.353F ///< Target syringe prime volume (in mL). TODO- move these to syringe pump controller when implemented #define SYRINGE_PUMP_FILL_VOLUME_OFFSET_ML 0.8F ///< Advised fill volume offset due to HW variance. /// Record for range and default of treatment parameters. typedef struct { CRITICAL_DATA_TYPES_T dataType; ///< Data type for the treatment parameter CRITICAL_DATAS_T min; ///< Minimum of range CRITICAL_DATAS_T max; ///< Maximum of range CRITICAL_DATAS_T def; ///< Default value } TREATMENT_PARAMS_PROPERTIES_T; /// Dialyzer volume data record structure. typedef struct { U32 bloodVolume; ///< Blood volume of the dialyzer in mL. U32 dialysateVolume; ///< Dialysate volume of the dialyzer in mL. } DIALYZER_VOLUME_DATA_T; /// Record structure for adjustable treatment parameters typedef struct { U32 bloodFlowRate_mL_min; ///< Original blood flow rate (in mL/min) set by user before treatment start U32 dialysateFlowRate_mL_min; ///< Original dialysate flow rate (in mL/min) set by user before treatment start U32 treatmentDuration_min; ///< Original treatment duration (in min) set by user before treatment start S32 arterialPressureLimitWindow_mmHg; ///< Original alarm limit window for arterial pressure (in mmHg) set by user before treatment start S32 venousPressureLimitWindow_mmHg; ///< Original alarm limit window for venous pressure (in mmHg) set by user before treatment start S32 venousPressureLimitAsymmetric_mmHg; ///< Original alarm limit asymmetric for venous pressure (in mmHg) set by user before treatment start S32 tmpLimitWindow_mmHg; ///< Original alarm limit window for trans-membrane pressure (in mmHg) set by user before treatment start F32 uFVolume_L; ///< Original ultrafiltration volume (in L) set by user before treatment start } ADJ_TREATMENT_PARAMS_T; #pragma pack(push, 1) /// Record structure for response to validate Tx params typedef struct { BOOL accepted; ///< Command accepted. U32 reason[ NUM_OF_TREATMENT_PARAMS - 1 ]; ///< Rejection reason codes; 1 for each parameter. } TREATMENT_PARAMS_VAL_RESP_DATA_PAYLOAD_T; /// Record structure for response to validate ultrafiltration volume typedef struct { BOOL accepted; ///< Command accepted. U32 rejReason; ///< Rejection reason code (if rejected). F32 ufVolumeMl; ///< Validated ultrafiltration volume (in mL). } UF_VOLUME_VAL_RESP_DATA_PAYLOAD_T; /// Record structure for set treatment parameter Dialin message. typedef struct { U32 paramID; ///< Treatment parameter ID. CRITICAL_DATAS_T value; ///< Set value. } DIALIN_SET_TX_PARAM_PAYLOAD_T; #pragma pack(pop) // ********** private data ********** static const TREATMENT_PARAMS_PROPERTIES_T TREAT_PARAMS_PROPERTIES[ NUM_OF_TREATMENT_PARAMS ] = { // type min max default { CRITICAL_DATA_TYPE_U32, {.uInt=50}, {.uInt=500}, {.uInt=50} }, // TREATMENT_PARAM_BLOOD_FLOW { CRITICAL_DATA_TYPE_U32, {.uInt=50}, {.uInt=600}, {.uInt=50} }, // TREATMENT_PARAM_DIALYSATE_FLOW { CRITICAL_DATA_TYPE_U32, {.uInt=60}, {.uInt=480}, {.uInt=60} }, // TREATMENT_PARAM_TREATMENT_DURATION { CRITICAL_DATA_TYPE_U32, {.uInt=100}, {.uInt=300}, {.uInt=100} }, // TREATMENT_PARAM_SALINE_BOLUS_VOLUME { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=480}, {.uInt=0} }, // TREATMENT_PARAM_HEPARIN_STOP_TIME { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=0}, {.uInt=0} }, // TREATMENT_PARAM_HEPARIN_TYPE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=2}, {.uInt=0} }, // TREATMENT_PARAM_ACID_CONCENTRATE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=0}, {.uInt=0} }, // TREATMENT_PARAM_BICARB_CONCENTRATE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=6}, {.uInt=0} }, // TREATMENT_PARAM_DIALYZER_TYPE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=60}, {.uInt=0} }, // TREATMENT_PARAM_BP_MEAS_INTERVAL { CRITICAL_DATA_TYPE_U32, {.uInt=100}, {.uInt=300}, {.uInt=200} }, // TREATMENT_PARAM_RINSEBACK_FLOW_RATE { CRITICAL_DATA_TYPE_U32, {.uInt=200}, {.uInt=400}, {.uInt=300} }, // TREATMENT_PARAM_RINSEBACK_VOLUME { CRITICAL_DATA_TYPE_S32, {.sInt=120}, {.sInt=200}, {.sInt=120} }, // TREATMENT_PARAM_ART_PRES_LIMIT_WINDOW { CRITICAL_DATA_TYPE_S32, {.sInt=100}, {.sInt=200}, {.sInt=100} }, // TREATMENT_PARAM_VEN_PRES_LIMIT_WINDOW { CRITICAL_DATA_TYPE_S32, {.sInt=20}, {.sInt=35}, {.sInt=20} }, // TREATMENT_PARAM_VEN_PRES_LIMIT_ASYMMETRIC { CRITICAL_DATA_TYPE_S32, {.sInt=40}, {.sInt=100}, {.sInt=40} }, // TREATMENT_PARAM_TMP_PRES_LIMIT_WINDOW { CRITICAL_DATA_TYPE_F32, {.sFlt=35.0}, {.sFlt=38.0}, {.sFlt=37.0} }, // TREATMENT_PARAM_DIALYSATE_TEMPERATURE { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=1.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_HEPARIN_DISPENSE_RATE { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=2.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=8.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_UF_VOLUME }; /// Dialyzer volumes (blood and dialysate) table in mL for each type of dialyzer. const DIALYZER_VOLUME_DATA_T dialyzerVolumeTable[ NUM_OF_DIALYZER_TYPES ] = { { 82, 170 }, // DIALYZER_TYPE_BBRAUN_PRO_13H { 100, 200 }, // DIALYZER_TYPE_BBRAUN_PRO_16H { 120, 257 }, // DIALYZER_TYPE_BBRAUN_PRO_19H { 87, 233 }, // DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F160NRE { 102, 280 }, // DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F180NRE { 113, 348 }, // DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F200NRE { 142, 304 } }; // DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F250NRE // Current treatment parameter values static CRITICAL_DATA_T treatmentParameters[ NUM_OF_TREATMENT_PARAMS ]; ///< Treatment parameters. static CRITICAL_DATAS_T stagedParams[ NUM_OF_TREATMENT_PARAMS ]; ///< Temporary staged treatment parameters for validation and awaiting user confirmation. // Original treatment parameter values (for those that can be changed during treatment) static ADJ_TREATMENT_PARAMS_T origTreatmentParams; ///< Originally set (before treatment) treatment parameters. static BOOL validTreatParamsReceived = FALSE; ///< Flag indicates user has provided treatment parameters. static BOOL treatParamsConfirmed = FALSE; ///< Flag indicates user has confirmed the treatment parameters. // ********** private function prototypes ********** static void extractTreatmentParamsFromPayload( TREATMENT_PARAMS_DATA_PAYLOAD_T payload ); static BOOL checkTreatmentParamsInRange( U32 *reasons ); static BOOL checkTreatmentParamsDependencies( U32 *reasons ); static void sendTreatmentParamsResponse( BOOL paramsAreInvalid, U32 *reasons ); static void resetAllTreatmentParameters( void ); /*********************************************************************//** * @brief * The resetTreatmentParameters function resets the Treatment Parameters * session flags and parameter values. * @details Inputs: none * @details Outputs: validTreatParamsReceived, treatParamsConfirmed, * treatParamsRejected cleared and parameters reset. * @return none *************************************************************************/ void resetTreatmentParameters( void ) { validTreatParamsReceived = FALSE; treatParamsConfirmed = FALSE; resetAllTreatmentParameters(); } /*********************************************************************//** * @brief * The getValidTreatParamsReceived function reports whether a valid set * of Treatment Parameters has been staged. * @details Inputs: validTreatParamsReceived * @details Outputs: none * @return TRUE if valid parameters are available, FALSE otherwise. **************************************************************************/ BOOL getValidTreatParamsReceived( void ) { return validTreatParamsReceived; } /*********************************************************************//** * @brief * The getTreatParamsConfirmed function reports whether the current * Treatment Parameters have been confirmed by the user. * @details Inputs: treatParamsConfirmed * @details Outputs: none * @return TRUE if the current Treatment Parameters are confirmed, * FALSE otherwise. *************************************************************************/ BOOL getTreatParamsConfirmed( void ) { return treatParamsConfirmed; } /*********************************************************************//** * @brief * The validateAndSetTreatmentParameters function validates received * treatment parameters. * @details \b Message \b Sent: MSG_ID_TD_RESP_TREATMENT_PARAMS_TO_VALIDATE * @details \b Message \b Sent: MSG_ID_TD_TREATMENT_PARAM_RANGES if params are valid * @details \b Inputs: none * @details \b Outputs: stagedParams[], validTreatParamsReceived * @param message set message from UI which includes the user set treatment * parameters record. * @return TRUE if received treatment parameters are valid, FALSE if not *************************************************************************/ BOOL validateAndSetTreatmentParameters( MESSAGE_T *message ) { BOOL paramsAreInvalid = TRUE; BOOL paramsAreInRange, paramsAreConsistent; BOOL result = FALSE; TREATMENT_PARAMS_DATA_PAYLOAD_T params; U32 rejReasons[ NUM_OF_TREATMENT_PARAMS ]; // Initialize reject reasons to zeroes memset( (U08*)&rejReasons[0], 0, sizeof( U32 ) * NUM_OF_TREATMENT_PARAMS ); // Verify message payload length is valid if ( sizeof( TREATMENT_PARAMS_DATA_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( ¶ms, message->payload, sizeof( TREATMENT_PARAMS_DATA_PAYLOAD_T ) ); // Check the received arterial and venous pressure values from the UI to be checked and capped against the min and max // values in the institutional record // checkPressureParamsRange( ¶ms ); // TODO // Extract treatment parameters from given payload to staging array so we can more easily work with them extractTreatmentParamsFromPayload( params ); // Range check each treatment parameter paramsAreInRange = checkTreatmentParamsInRange( &rejReasons[0] ); // Validate dependencies paramsAreConsistent = checkTreatmentParamsDependencies( &rejReasons[0] ); // Determine overall validity of received treatment parameters if ( ( TRUE == paramsAreInRange ) && ( TRUE == paramsAreConsistent ) ) { paramsAreInvalid = FALSE; validTreatParamsReceived = TRUE; } // Respond to set treatment parameters request message sendTreatmentParamsResponse( paramsAreInvalid, &rejReasons[0] ); // Send initial adjustable ranges to UI so UF volume range will be known when UF volume prompted for later if ( TRUE == validTreatParamsReceived ) { U32 setTxDuration = stagedParams[ TREATMENT_PARAM_TREATMENT_DURATION ].uInt; TREATMENT_PARAM_RANGE_BROADCAST_PAYLOAD_T payload; payload.minTreatmentTime = treatmentParameters[ TREATMENT_PARAM_TREATMENT_DURATION ].minimum.uInt; payload.maxTreatmentTime = treatmentParameters[ TREATMENT_PARAM_TREATMENT_DURATION ].maximum.uInt; payload.minUFVolume = 0.0F; payload.maxUFVolume = MIN( (F32)setTxDuration * MAX_UF_RATE_ML_MIN, (F32)MAX_UF_VOLUME_ML ); payload.minDialRate = treatmentParameters[ TREATMENT_PARAM_DIALYSATE_FLOW ].minimum.uInt; payload.maxDialRate = treatmentParameters[ TREATMENT_PARAM_DIALYSATE_FLOW ].maximum.uInt; sendMessage( MSG_ID_TD_TREATMENT_PARAM_RANGES, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&payload), sizeof( TREATMENT_PARAM_RANGE_BROADCAST_PAYLOAD_T ) ); } result = ( TRUE == paramsAreInvalid ? FALSE : TRUE ); } return result; } /*********************************************************************//** * @brief * The validateAndSetUFVolume function validates received ultrafiltration * volume treatment parameter. * @details \b Message \b Sent: MSG_ID_TD_RESP_ULTRAFILTRATION_VOLUME_TO_VALIDATE * @details \b Inputs: none * @details \b Outputs: none * @param message set message from UI which includes the user set ultrafiltration * volume (in mL). * @return TRUE if received UF volume parameter is valid, FALSE if not *************************************************************************/ BOOL validateAndSetUFVolume( MESSAGE_T *message ) { BOOL accepted = FALSE; REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NONE; F32 uFVolumeMl; F32 uFVolumeL; if ( sizeof( F32 ) == message->hdr.payloadLen ) { UF_VOLUME_VAL_RESP_DATA_PAYLOAD_T respPayload; memcpy( &uFVolumeMl, message->payload, sizeof( F32 ) ); uFVolumeL = uFVolumeMl / (F32)ML_PER_LITER; accepted = setTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME, uFVolumeL ); if ( TRUE == accepted ) { U32 treatmentDuration = getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION ); if ( treatmentDuration > 0U ) { F32 uFRate = uFVolumeMl / (F32)treatmentDuration; if ( ( uFRate > MAX_UF_RATE_ML_MIN ) || ( uFRate < MIN_UF_RATE_ML_MIN ) ) { accepted = FALSE; rejReason = REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE; } } else { accepted = FALSE; rejReason = REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_MINIMUM; } } else { rejReason = REQUEST_REJECT_REASON_UF_VOLUME_OUT_OF_RANGE; } // respond to UI uFVolumeL = getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ); uFVolumeMl = uFVolumeL * (F32)ML_PER_LITER; respPayload.accepted = accepted; respPayload.rejReason = rejReason; respPayload.ufVolumeMl = uFVolumeMl; sendMessage( MSG_ID_TD_RESP_ULTRAFILTRATION_VOLUME_TO_VALIDATE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&respPayload), sizeof( UF_VOLUME_VAL_RESP_DATA_PAYLOAD_T ) ); } return accepted; } /*********************************************************************//** * @brief * The signalUserConfirmationOfTreatmentParameters function sets the user * confirmation flag signaling user has confirmed or rejected treatment * parameters. * @details \b Inputs: none * @details \b Outputs: treatParamsConfirmed * @param message confirmation message from UI which includes the user * confirmation or rejection. * @return TRUE if confirmation/rejection accepted, FALSE if not *************************************************************************/ BOOL signalUserConfirmTreatmentParameters( MESSAGE_T *message ) { BOOL confirmed = FALSE; if ( sizeof( BOOL ) == message->hdr.payloadLen ) { memcpy( &confirmed, message->payload, sizeof( BOOL ) ); } if ( TRUE == confirmed ) { // ModePreTreat uses this via getTreatParamsConfirmed() treatParamsConfirmed = TRUE; } else { // Rejected – clear session resetTreatmentParameters(); } } /*********************************************************************//** * @brief * The resetAllTreatmentParameters function resets treatment parameters * to default values. * @details \b Inputs: none * @details \b Outputs: All treatment parameters reset to default values * and original and staged treatment parameters reset to zero. * @return none *************************************************************************/ static void resetAllTreatmentParameters( void ) { TREATMENT_PARAM_T param; for ( param = TREATMENT_PARAM_FIRST_UINT; param < NUM_OF_TREATMENT_PARAMS; param++ ) { // Set type, range, and default value for each treatment parameter treatmentParameters[ param ].typ = TREAT_PARAMS_PROPERTIES[ param ].dataType; treatmentParameters[ param ].minimum = TREAT_PARAMS_PROPERTIES[ param ].min; treatmentParameters[ param ].maximum = TREAT_PARAMS_PROPERTIES[ param ].max; treatmentParameters[ param ].defValue = TREAT_PARAMS_PROPERTIES[ param ].def; resetCriticalData( &treatmentParameters[ param ] ); // Set staged parameter values to zero stagedParams[ param ].uInt = 0; } // Zero original parameter values origTreatmentParams.bloodFlowRate_mL_min = 0; origTreatmentParams.dialysateFlowRate_mL_min = 0; origTreatmentParams.treatmentDuration_min = 0; origTreatmentParams.arterialPressureLimitWindow_mmHg = 0; origTreatmentParams.venousPressureLimitWindow_mmHg = 0; origTreatmentParams.venousPressureLimitAsymmetric_mmHg = 0; origTreatmentParams.tmpLimitWindow_mmHg = 0; origTreatmentParams.uFVolume_L = 0.0F; } /*********************************************************************//** * @brief * The checkTreatmentParamsInRange function checks whether received * treatment parameters are in range. * @details \b Inputs: stagedParams[] * @details \b Outputs: reasons[] * @param reasons Pointer to array of reject reason codes for each parameter * @return TRUE if treatment parameters are in range, FALSE if not *************************************************************************/ static BOOL checkTreatmentParamsInRange( U32 *reasons ) { BOOL result = TRUE; TREATMENT_PARAM_T param; // Range check treatment parameters up to (but not including) UF volume for ( param = TREATMENT_PARAM_FIRST_UINT; param < TREATMENT_PARAM_UF_VOLUME; param++ ) { if ( FALSE == isTreatmentParamInRange( param, stagedParams[ param ] ) ) { reasons[ param ] = REQUEST_REJECT_REASON_PARAM_OUT_OF_RANGE; result = FALSE; } else { reasons[ param ] = REQUEST_REJECT_REASON_NONE; } } return result; } /*********************************************************************//** * @brief * The checkTreatmentParamsDependencies function checks dependencies between * received treatment parameters. * @details \b Inputs: stagedParams[] * @details \b Outputs: reasons[] * @param reasons Pointer to array of reject reason codes for each parameter * @return TRUE if treatment parameter dependencies are ok, FALSE if not *************************************************************************/ static BOOL checkTreatmentParamsDependencies( U32 *reasons ) { BOOL result = TRUE; U32 txDur = stagedParams[ TREATMENT_PARAM_TREATMENT_DURATION ].uInt; U32 hepST = stagedParams[ TREATMENT_PARAM_HEPARIN_STOP_TIME ].uInt; F32 hepDR = stagedParams[ TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ].sFlt; F32 hepBV = stagedParams[ TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ].sFlt; F32 txVol = hepBV + ( hepDR * ( hepST / (F32)SEC_PER_MIN ) ) + SYRINGE_PUMP_PRIME_VOLUME_ML + SYRINGE_PUMP_FILL_VOLUME_OFFSET_ML; // Verify Heparin stop time is only set if Heparin dispense rate is set if ( ( hepST > 0 ) && ( hepDR < NEARLY_ZERO ) ) { reasons[ TREATMENT_PARAM_HEPARIN_STOP_TIME ] = REQUEST_REJECT_REASON_HEPARIN_STOP_TIME_WITH_NO_DISPENSE; result = FALSE; } // Verify Heparin stop time does not exceed Tx duration else if ( hepST > txDur ) { reasons[ TREATMENT_PARAM_HEPARIN_STOP_TIME ] = REQUEST_REJECT_REASON_HEPARIN_STOP_TIME_EXCEEDS_DURATION; result = FALSE; } // Verify Heparin stop time does not exceed max 10 mL Heparin volume else if ( txVol > MAX_HEPARIN_VOLUME_ML ) { reasons[ TREATMENT_PARAM_HEPARIN_STOP_TIME ] = REQUEST_REJECT_REASON_HEPARIN_VOLUME_EXCEEDS_10_ML; result = FALSE; } return result; } /*********************************************************************//** * @brief * The extractTreatmentParamsFromPayload function extracts the individual * treatment parameters received from the UI into a staging array where * they will be validated and stay until user confirms them. * @details \b Inputs: none * @details \b Outputs: stagedParams[] * @param payload message payload record containing received treatment parameters * @return none *************************************************************************/ static void extractTreatmentParamsFromPayload( TREATMENT_PARAMS_DATA_PAYLOAD_T payload ) { // Pull treatment parameters into data array so we can more easily work with them memcpy( &stagedParams[0], &payload, sizeof(TREATMENT_PARAMS_DATA_PAYLOAD_T) ); } /*********************************************************************//** * @brief * The sendTreatmentParamsResponse function responds to the treatment parameters * received from the UI. An over-all ok/rejected flag as well as individual reject * reason codes for each parameter are provided back to the UI. * @details \b Message \b Sent: MSG_ID_TD_RESP_TREATMENT_PARAMS_TO_VALIDATE * @details \b Inputs : none * @details \b Outputs : Response to treatment parameters message constructed and sent. * @param rejected 1 if rejected, 0 if parameters ok * @param reasons array of reject reason codes for each parameter (0=not rejected) * @return none *************************************************************************/ static void sendTreatmentParamsResponse( BOOL rejected, U32 *reasons ) { TREATMENT_PARAMS_VAL_RESP_DATA_PAYLOAD_T payload; payload.accepted = ( TRUE == rejected ? FALSE : TRUE ); memcpy( &payload.reason[0], &reasons[0], sizeof( TREATMENT_PARAMS_DATA_PAYLOAD_T ) ); sendMessage( MSG_ID_TD_RESP_TREATMENT_PARAMS_TO_VALIDATE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&payload), sizeof( TREATMENT_PARAMS_VAL_RESP_DATA_PAYLOAD_T ) ); } /*********************************************************************//** * @brief * The getDialyzerBloodVolume function gets the blood side volume (in mL) * for a given dialyzer type. * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given dialyzer type is invalid * @details \b Inputs : dialyzerVolumeTable[] * @details \b Outputs : none * @param dialyzer The type of dialyzer to get the blood side volume for * @return The blood side volume for the given dialyzer type *************************************************************************/ U32 getDialyzerBloodVolume( DIALYZER_TYPE_T dialyzer ) { U32 result = 0; if ( dialyzer < NUM_OF_DIALYZER_TYPES ) { result = dialyzerVolumeTable[ dialyzer ].bloodVolume; } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_DIALYZER_TYPE_INVALID1, (U32)dialyzer ) } return result; } /*********************************************************************//** * @brief * The getDialyzerDialysateVolume function gets the dialysate side volume (in mL) * for a given dialyzer type. * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given dialyzer type is invalid * @details \b Inputs : dialyzerVolumeTable[] * @details \b Outputs : none * @param dialyzer The type of dialyzer to get the dialysate side volume for * @return The dialysate side volume for the given dialyzer type *************************************************************************/ U32 getDialyzerDialysateVolume( DIALYZER_TYPE_T dialyzer ) { U32 result = 0; if ( dialyzer < NUM_OF_DIALYZER_TYPES ) { result = dialyzerVolumeTable[ dialyzer ].dialysateVolume; } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_DIALYZER_TYPE_INVALID2, (U32)dialyzer ) } return result; } /**@}*/