Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r046ffdda014e511363b04ed523eb3399a3eb4ad0 -rd6775171de59386445ffdf70d6b32bcdfc1db07e --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 046ffdda014e511363b04ed523eb3399a3eb4ad0) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision d6775171de59386445ffdf70d6b32bcdfc1db07e) @@ -45,6 +45,8 @@ static TD_STANDBY_STATE_T currentStandbyState; ///< Current state (sub-mode) of standby mode. static BOOL treatStartReqReceived; ///< Flag indicates user has requested initiation of a treatment. static BOOL homingInitiated; ///< Flag indicates actuators have been homed. +static FLUID_TYPE_T fluidType; ///< Fluid type assigned based on user selection. +static U32 modality; ///< Modality from the treatment initiation. // ********** private function prototypes ********** @@ -63,6 +65,8 @@ currentStandbyState = STANDBY_START_STATE; treatStartReqReceived = FALSE; homingInitiated = FALSE; + fluidType = FLUID_TYPE_UNKNOWN; + modality = TREATMENT_MODALITY_HD_SALINE_FLUID; } /*********************************************************************//** @@ -280,17 +284,67 @@ // Start treatment workflow with pretreatment mode requestNewOperationMode( MODE_PRET ); treatStartReqReceived = FALSE; + // Set fluid type + setFluidType( modality ); } return state; } /*********************************************************************//** * @brief + * The setFluidType function sets the fluid type based on the user's + * treatment selection from the home screen. + * @details \b Inputs: none + * @details \b Outputs: fluidType + * @param type Fluid type selected by user (saline or substitution fluid). + * @return none + *************************************************************************/ +void setFluidType( U32 modality ) +{ + if ( TREATMENT_MODALITY_HD_SALINE_FLUID == modality ) + { + fluidType = FLUID_TYPE_SALINE; + } + else + { + // For HDF and HD_ONLINE_FLUID + fluidType = FLUID_TYPE_SUBSTITUTE; + } +} + +/*********************************************************************//** + * @brief + * The getFluidType function returns the current fluid type assigned + * based on the user's treatment selection. + * @details \b Inputs: none + * @details \b Outputs: none + * @return Current fluid type (saline or substitution fluid). + *************************************************************************/ +FLUID_TYPE_T getFluidType( void ) +{ + return fluidType; +} + +/*********************************************************************//** + * @brief + * The getModality function returns the treatment modality received from + * the UI at treatment initiation. + * @details \b Inputs: modality + * @details \b Outputs: none + * @return Treatment modality selected by the user on the home screen. + *************************************************************************/ +TREATMENT_TYPE_T getModality( void ) +{ + return modality; +} + +/*********************************************************************//** + * @brief * The signalUserInitiateTreatment function handles user initiation of a * treatment. * @details \b Inputs: none - * @details \b Outputs: treatStartReqReceived + * @details \b Outputs: treatStartReqReceived, modality * @param message initiate/reject treatment workflow message from UI which * includes the command code (0=cancel, 1=initiate). * @return TRUE if signal accepted, FALSE if not @@ -301,20 +355,27 @@ U32 cmd = 0; TD_OP_MODE_T mode = getCurrentOperationMode(); REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NONE; + INITIATE_TREATMENT_REQUEST_PAYLOAD_T request; UI_RESPONSE_PAYLOAD_T response; // Verify message payload length is valid - if ( sizeof( U32 ) == message->hdr.payloadLen ) + if ( sizeof( INITIATE_TREATMENT_REQUEST_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &cmd, message->payload, sizeof( U32 ) ); + memcpy( &request, message->payload, sizeof( INITIATE_TREATMENT_REQUEST_PAYLOAD_T ) ); + cmd = request.command; + if ( USER_COMMAND_INITIATE == cmd ) { // Verify TD is in standby mode waiting for treatment start request if ( ( mode != MODE_STAN ) || ( STANDBY_WAIT_FOR_TREATMENT_STATE != currentStandbyState ) ) { rejReason = REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; } + else if ( request.modality >= NUM_OF_TREATMENT_MODALITY_TYPES ) + { + rejReason = REQUEST_REJECT_REASON_INVALID_COMMAND; + } #ifndef TEST_UI_ONLY // Verify DD is communicating with HD else if ( isDDCommunicating() != TRUE ) @@ -332,6 +393,8 @@ // If request to start treatment not rejected, set flag to initiate treatment workflow result = TRUE; treatStartReqReceived = TRUE; + // Save modality to set later + modality = request.modality; } } else if ( USER_COMMAND_CANCEL == cmd ) Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -r4ea39ac34ede5011de1954b7c58761df25120fcf -rd6775171de59386445ffdf70d6b32bcdfc1db07e --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 4ea39ac34ede5011de1954b7c58761df25120fcf) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision d6775171de59386445ffdf70d6b32bcdfc1db07e) @@ -7,8 +7,8 @@ * * @file AlarmMgmtSWFaults.h * -* @author (last) Praneeth Bunne -* @date (last) 04-Jun-2026 +* @author (last) Sean Nash +* @date (last) 01-Jul-2026 * * @author (original) Sean Nash * @date (original) 01-Aug-2024 @@ -196,7 +196,9 @@ SW_FAULT_ID_MODE_POST_TREATMENT_INVALID_STATE1 = 165, SW_FAULT_ID_MODE_POST_TX_AUTO_EJECT_INVALID_STATE = 166, SW_FAULT_ID_INVALID_FLUID_BOLUS_STATE = 167, - SW_FAULT_ID_INVALID_TUBE_SET_TYPE = 168, + SW_FAULT_ID_PRE_TX_RECIRC_INVALID_STATE = 168, + SW_FAULT_ID_TD_VALVES_INVALID_VALVE2 = 169, + SW_FAULT_ID_INVALID_TUBE_SET_TYPE = 170, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/TxParams.c =================================================================== diff -u -r5cc57a6d8eb3721811a2d6ace3176b7074c52fe8 -rd6775171de59386445ffdf70d6b32bcdfc1db07e --- firmware/App/Services/TxParams.c (.../TxParams.c) (revision 5cc57a6d8eb3721811a2d6ace3176b7074c52fe8) +++ firmware/App/Services/TxParams.c (.../TxParams.c) (revision d6775171de59386445ffdf70d6b32bcdfc1db07e) @@ -21,6 +21,7 @@ #include "BloodFlow.h" #include "Buttons.h" #include "Messaging.h" +#include "ModeStandby.h" #include "ModeTreatment.h" #include "ModePreTreat.h" #include "OperationModes.h" @@ -575,11 +576,11 @@ switch ( txType ) { - case TREATMENT_MODALITY_HDF: + case TREATMENT_MODALITY_HDF_ONLINE_FLUID: result = FALSE; break; - case TREATMENT_MODALITY_HD: + case TREATMENT_MODALITY_HD_SALINE_FLUID: result = ( ( ( param == TREATMENT_PARAM_HDF_DILUTION ) || ( param == TREATMENT_PARAM_SUBST_FLUID_VOLUME ) ) ? TRUE : FALSE ); break; @@ -738,6 +739,7 @@ F32 hepDR = stagedParams[ TREATMENT_PARAM_HEPARIN_DELIVERY_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; + TREATMENT_TYPE_T modality = (TREATMENT_TYPE_T)stagedParams[ TREATMENT_PARAM_TREATMENT_MODALITY ].uInt; // Variable to validate acid conversion factor consistency U32 acidType = stagedParams[ TREATMENT_PARAM_ACID_CONCENTRATE ].uInt; @@ -768,6 +770,13 @@ result = FALSE; } + // Verify Rx entered modality with the treatment initiation modality + if ( modality != getModality() ) + { + reasons[ TREATMENT_PARAM_TREATMENT_MODALITY ] = REQUEST_REJECT_REASON_MODALITY_MISMATCH; + result = FALSE; + } + return result; }