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; +} + /**@}*/