Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r96377d3f1e16d6f8a48fddbe9f645f9e2fd68478 -r78fe8ab743ad4c64144421662960757a29b9b0b0 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 96377d3f1e16d6f8a48fddbe9f645f9e2fd68478) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 78fe8ab743ad4c64144421662960757a29b9b0b0) @@ -29,10 +29,12 @@ // ********** private data ********** -static TD_PRE_TREATMENT_MODE_STATE_T currentPreTreatmentState = TD_PRE_TREATMENT_CONFIRM_RX_STATE; ///< Current Pre-Treatment sub-state +static TD_PRE_TREATMENT_MODE_STATE_T currentPreTreatmentState; ///< Current Pre-Treatment sub-state // ********** private function prototypes ********** +static TD_PRE_TREATMENT_MODE_STATE_T handleRxState( void ); ///< Handle Confirm Rx state during Pre-Treatment + /*********************************************************************//** * @brief * The initPreTreatmentMode function initializes the Pre-Treatment mode. @@ -135,7 +137,7 @@ * The handleRxState function executes the Confirm Rx pre-treatment step. * @details Inputs: none * @details Outputs: Requests transition to Treatment mode when the prescription - * is valid and confirmed; otherwise remains in Confirm Rx. + * is valid and confirmed otherwise remains in Confirm Rx. * @return next Pre-Treatment mode sub-state. *************************************************************************/ static TD_PRE_TREATMENT_MODE_STATE_T handleRxState( void ) @@ -156,4 +158,3 @@ } /**@}*/ - Index: firmware/App/Modes/ModePreTreat.h =================================================================== diff -u -r96377d3f1e16d6f8a48fddbe9f645f9e2fd68478 -r78fe8ab743ad4c64144421662960757a29b9b0b0 --- firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision 96377d3f1e16d6f8a48fddbe9f645f9e2fd68478) +++ firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision 78fe8ab743ad4c64144421662960757a29b9b0b0) @@ -35,8 +35,6 @@ U32 transitionToPreTreatmentMode( void ); // Prepares for transition to pre-treatment mode U32 execPreTreatmentMode( void ); // Execute the pre-treatment mode state machine (call from OperationModes) -static TD_PRE_TREATMENT_MODE_STATE_T handleRxState( void ); // Handle Confirm Rx step during Pre-Treatment - /**@}*/ #endif Index: firmware/App/Services/TxParams.c =================================================================== diff -u -r96377d3f1e16d6f8a48fddbe9f645f9e2fd68478 -r78fe8ab743ad4c64144421662960757a29b9b0b0 --- firmware/App/Services/TxParams.c (.../TxParams.c) (revision 96377d3f1e16d6f8a48fddbe9f645f9e2fd68478) +++ firmware/App/Services/TxParams.c (.../TxParams.c) (revision 78fe8ab743ad4c64144421662960757a29b9b0b0) @@ -21,7 +21,7 @@ #include "Buttons.h" #include "Messaging.h" #include "ModeTreatment.h" -#include "ModePreTreatment.h" +#include "ModePreTreat.h" #include "OperationModes.h" #include "Pressures.h" #include "StateTxDialysis.h" @@ -57,6 +57,13 @@ 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 { @@ -139,7 +146,6 @@ static BOOL validTreatParamsReceived = FALSE; ///< Flag indicates user has provided treatment parameters. static BOOL treatParamsConfirmed = FALSE; ///< Flag indicates user has confirmed the treatment parameters. -static BOOL treatParamsRejected = FALSE; ///< Flag indicates user has rejected the treatment parameters. // ********** private function prototypes ********** @@ -162,7 +168,6 @@ { validTreatParamsReceived = FALSE; treatParamsConfirmed = FALSE; - treatParamsRejected = FALSE; resetAllTreatmentParameters(); } @@ -196,20 +201,6 @@ /*********************************************************************//** * @brief - * The getTreatParamsRejected function reports whether the current - * Treatment Parameters have been rejected by the user. - * @details Inputs: none - * @details Outputs: none - * @return TRUE if the current Treatment Parameters are rejected, - * FALSE otherwise. - *************************************************************************/ -BOOL getTreatParamsRejected( void ) -{ - return treatParamsRejected; -} - -/*********************************************************************//** - * @brief * The validateAndSetTreatmentParameters function validates received * treatment parameters. * @details \b Message \b Sent: MSG_ID_TD_RESP_TREATMENT_PARAMS_TO_VALIDATE @@ -348,34 +339,28 @@ * confirmation flag signaling user has confirmed or rejected treatment * parameters. * @details \b Inputs: none - * @details \b Outputs: treatParamsConfirmed, treatParamsRejected + * @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 result = FALSE; - BOOL confirmed = FALSE; - - if ( sizeof( BOOL ) == message->hdr.payloadLen ) - { - memcpy( &confirmed, message->payload, sizeof( BOOL ) ); - - if ( TRUE == confirmed ) - { - treatParamsConfirmed = TRUE; - treatParamsRejected = FALSE; - } - else - { - treatParamsConfirmed = FALSE; - treatParamsRejected = TRUE; - } - result = TRUE; - } - - return result; + 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(); + } } /*********************************************************************//** @@ -433,7 +418,7 @@ { if ( FALSE == isTreatmentParamInRange( param, stagedParams[ param ] ) ) { - reasons[ param ] = REQUEST_REJECT+_REASON_PARAM_OUT_OF_RANGE; + reasons[ param ] = REQUEST_REJECT_REASON_PARAM_OUT_OF_RANGE; result = FALSE; } else @@ -522,6 +507,58 @@ 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; +} + /**@}*/ Index: firmware/App/Services/TxParams.h =================================================================== diff -u -r96377d3f1e16d6f8a48fddbe9f645f9e2fd68478 -r78fe8ab743ad4c64144421662960757a29b9b0b0 --- firmware/App/Services/TxParams.h (.../TxParams.h) (revision 96377d3f1e16d6f8a48fddbe9f645f9e2fd68478) +++ firmware/App/Services/TxParams.h (.../TxParams.h) (revision 78fe8ab743ad4c64144421662960757a29b9b0b0) @@ -15,34 +15,85 @@ * ***************************************************************************/ -#ifndef APP_SERVICES_TX_PARAMS_H_ -#define APP_SERVICES_TX_PARAMS_H_ +#ifndef __TX_PARAMS_H__ +#define __TX_PARAMS_H__ #include "TDCommon.h" #include "TDDefs.h" #include "Utilities.h" /** * @defgroup TxParams TxParams - * @brief Treatment parameters unit provides validation and confirmation handling for treatment parameters from the UI. + * @brief Treatment parameters unit provides validation + * and confirmation handling for treatment parameters from the UI. * * @addtogroup TxParams * @{ */ +// ********** public definitions ********** + +#define MIN_PRESSURE_ALARM_LIMIT_DELTA_MMHG ( 30 ) ///< Minimum pressure alarm limit delta (in mmHg) +#define MAX_UF_RATE_ML_MIN ( 2000.01F / (F32)MIN_PER_HOUR ) ///< Maximum ultrafiltration rate (in mL/min). Added small decimal to prevent float round off issues. +#define MIN_UF_RATE_ML_MIN ( 0.0F ) ///< Minimum ultrafiltration rate (in mL/min). +#define MAX_UF_VOLUME_ML ( 8 * ML_PER_LITER ) ///< Maximum ultrafiltration volume (in mL). + +/// Record structure for a treatment parameters payload from UI. +typedef struct +{ + U32 bloodFlowRate_mL_min; ///< User set blood flow rate (in mL/min) + U32 dialysateFlowRate_mL_min; ///< User set dialysate flow rate (in mL/min) + U32 treatmentDuration_min; ///< User set treatment duration (in min) + U32 salineBolusVolume_mL; ///< User set saline bolus volume (in mL) + U32 hepStopTime_min; ///< User set Heparin stop time (in min) + U32 hepType; ///< User set Heparin type option + U32 acidConcentrate; ///< User set acid concentrate option + U32 bicarbConcentrate; ///< User set bicarbonate concentrate option + U32 dialyzerType; ///< User set dialyzer type option + U32 bpInterval_min; ///< User set blood pressure measurement interval (in min) + U32 rinsebackFlowRate_mL_min; ///< User set rinseback flow rate (in mL/min) + U32 rinsebackVolume_mL; ///< User set rinseback volume (in mL) + S32 arterialPressureLimitWindow_mmHg; ///< User set alarm limit window for arterial pressure (in mmHg) + S32 venousPressureLimitWindow_mmHg; ///< User set alarm limit window for venous pressure (in mmHg) + S32 venousPressureLimitAsymmetric_mmHg; ///< User set alarm limit asymmetric for venous pressure (in mmHg) + S32 tmpLimitWindow_mmHg; ///< User set alarm limit window for trans-membrane pressure (in mmHg) + F32 dialysateTemperature_degC; ///< User set dialysate temperature (in deg C) + F32 hepDispenseRate_mL_hr; ///< User set Heparin dispense rate (in mL/hr) + F32 hepBolusVolume_mL; ///< User set Heparin bolus volume (in mL) +} TREATMENT_PARAMS_DATA_PAYLOAD_T; + +/// Record structure for reporting all current treatment parameters to Dialin +typedef struct +{ + TREATMENT_PARAMS_DATA_PAYLOAD_T treatment_parameters; ///< Record structure of treatment parameters + F32 uFVolume_L; ///< Current ultrafiltration volume (in L). +} CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T; + +/// Payload record structure for treatment parameter range broadcast messages. +typedef struct +{ + U32 minTreatmentTime; ///< Minimum treatment duration (in minutes) + U32 maxTreatmentTime; ///< Maximum treatment duration (in minutes) + F32 minUFVolume; ///< Minimum ultrafiltration volume (in mL) + F32 maxUFVolume; ///< Maximum ultrafiltration volume (in mL) + U32 minDialRate; ///< Minimum dialysate flow rate (in mL/min) + U32 maxDialRate; ///< Maximum dialysate flow rate (in mL/min) +} TREATMENT_PARAM_RANGE_BROADCAST_PAYLOAD_T; + // ********** public function prototypes **************** void resetTreatmentParameters( void ); // Reset all parameters to defaults -void signalUserConfirmTreatmentParameters( MESSAGE_T *message ); // Process UI confirm/reject Treatment Parameters +BOOL signalUserConfirmTreatmentParameters( MESSAGE_T *message ); // Process UI confirm/reject Treatment parameters BOOL validateAndSetTreatmentParameters( MESSAGE_T *message ); // Validate Treatment Parameters received from UI BOOL validateAndSetUFVolume( MESSAGE_T *message ); // Validate UF volume received from UI BOOL getValidTreatParamsReceived( void ); // Determine whether valid Treatment Parameters exist BOOL getTreatParamsConfirmed( void ); // Determine whether user confirmed the parameters -BOOL getTreatParamsRejected( void ); // Determine whether user rejected the parameters +U32 getDialyzerBloodVolume( DIALYZER_TYPE_T dialyzer ); // Get the blood side volume for a given dialyzer type +U32 getDialyzerDialysateVolume( DIALYZER_TYPE_T dialyzer ); // Get the dialysate side volume for a given dialyzer type + /**@}*/ #endif -