Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r120487ddf3e3d69d1de5094d5252c037588e2ed8 -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 120487ddf3e3d69d1de5094d5252c037588e2ed8) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -42,6 +42,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 FLUID_TYPE_T fluidType; ///< Fluid type assigned based on user selection. +static U32 modality; ///< Modality from the treatment initiation. // ********** private function prototypes ********** @@ -59,6 +61,8 @@ { currentStandbyState = STANDBY_START_STATE; treatStartReqReceived = FALSE; + fluidType = FLUID_TYPE_UNKNOWN; + modality = TREATMENT_MODALITY_HD_SALINE_FLUID; } /*********************************************************************//** @@ -269,17 +273,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). + *************************************************************************/ +U32 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. + *************************************************************************/ +U32 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 @@ -290,20 +344,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 ) @@ -321,6 +382,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/Modes/ModeStandby.h =================================================================== diff -u -r395522dffef1348e176564925656012f529c1910 -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 395522dffef1348e176564925656012f529c1910) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -32,6 +32,13 @@ // ********** public definitions ********** +/// Payload record structure for a treatment initiation request +typedef struct +{ + U32 command; ///< Command code (Cancel=0, Initiate=1) + U32 modality; ///< Treatment modality selected by user (ignored on cancel) +} INITIATE_TREATMENT_REQUEST_PAYLOAD_T; + // ********** public function prototypes ********** void initStandbyMode( void ); // Initialize this unit @@ -41,6 +48,10 @@ BOOL signalUserInitiateTreatment( MESSAGE_T *message ); // User has initiated/cancelled treatment workflow void signalAlarmActionToStandbyMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Standby mode +void setFluidType( U32 modality ); // Set a specific fluid type +U32 getFluidType( void ); // Get a specific fluid type +U32 getModality( void ); // Get a specific modality + /**@}*/ #endif Index: firmware/App/Modes/StateTxPaused.c =================================================================== diff -u -rda286decac70b8da5b369ccca36c05fb5bdb7c73 -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision da286decac70b8da5b369ccca36c05fb5bdb7c73) +++ firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -22,6 +22,7 @@ #include "DDInterface.h" #include "FluidBolus.h" #include "Messaging.h" +#include "ModeStandby.h" #include "ModeTreatment.h" //#include "NVDataMgmt.h" #include "OperationModes.h" @@ -353,12 +354,8 @@ { BOOL result = FALSE; - if ( TUBE_SET_TYPE_HDF == getTubeSetType() ) + if ( FLUID_TYPE_SALINE == getFluidType() ) { - result = ( TRUE == getDialysateGoodToDeliverStatus() ) ? TRUE : FALSE; - } - else - { result = ( TRUE != isBloodRecircBlocked() ) ? TRUE : FALSE; } Index: firmware/App/Services/StateServices/FluidBolus.c =================================================================== diff -u -rda286decac70b8da5b369ccca36c05fb5bdb7c73 -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Services/StateServices/FluidBolus.c (.../FluidBolus.c) (revision da286decac70b8da5b369ccca36c05fb5bdb7c73) +++ firmware/App/Services/StateServices/FluidBolus.c (.../FluidBolus.c) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -21,6 +21,7 @@ #include "FluidBolus.h" #include "Messaging.h" #include "Pressures.h" +#include "ModeStandby.h" #include "ModeTreatment.h" #include "StateTxBloodPrime.h" #include "StateTxDialysis.h" @@ -44,7 +45,7 @@ // ********** private data ********** static FLUID_BOLUS_STATE_T currentFluidBolusState; ///< Current fluid bolus state -static FLUID_BOLUS_MEDIUM_T currentFluidBolusMedium; ///< Current fluid bolus medium +static FLUID_TYPE_T fluidType; ///< Fluid type for bolus static U32 fluidBolusBroadCastTimerCtr; ///< Broadcast Timer counter static BOOL fluidBolusStartRequested; ///< Flag indicates a fluid bolus start has been requested by user. static BOOL fluidBolusAbortRequested; ///< Flag indicates a fluid bolus abort has been requested by user. @@ -81,7 +82,7 @@ void initFluidBolus( void ) { currentFluidBolusState = FLUID_BOLUS_IDLE_STATE; - currentFluidBolusMedium = getFluidBolusMedium(); + fluidType = getFluidType(); fluidBolusBroadCastTimerCtr = FLUID_BOLUS_DATA_PUB_INTERVAL - 10; // setup to stagger publish from other broadcasters targetBloodFlowMLPM = 0; totalFluidVolumeDelivered_mL = 0.0F; @@ -155,27 +156,6 @@ /*********************************************************************//** * @brief - * The getFluidBolusMedium function determines the fluid bolus medium based - * on the installed tube set type. - * @details \b Inputs: none - * @details \b Outputs: none - * @return FLUID_BOLUS_MEDIUM_SUBSTITUTE for HDF tubing set, - * FLUID_BOLUS_MEDIUM_SALINE otherwise. - *************************************************************************/ -FLUID_BOLUS_MEDIUM_T getFluidBolusMedium( void ) -{ - FLUID_BOLUS_MEDIUM_T medium = FLUID_BOLUS_MEDIUM_SALINE; - - if ( TUBE_SET_TYPE_HDF == getTubeSetType() ) - { - medium = FLUID_BOLUS_MEDIUM_SUBSTITUTE; - } - - return medium; -} - -/*********************************************************************//** - * @brief * The isFluidBolusActive function determines whether a fluid bolus is * currently being delivered. * @details \b Inputs: currentFluidBolusState @@ -333,7 +313,7 @@ setValvePosition( H1_VALV, VALVE_POSITION_C_CLOSE ); setValvePosition( H19_VALV, VALVE_POSITION_B_OPEN ); - if ( FLUID_BOLUS_MEDIUM_SALINE == currentFluidBolusMedium ) + if ( FLUID_TYPE_SALINE == fluidType ) { setBloodPumpTargetFlowRate( targetBloodFlowMLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); } @@ -371,7 +351,7 @@ updateFluidBolusVolumeDelivered(); - if ( FLUID_BOLUS_MEDIUM_SALINE == currentFluidBolusMedium ) + if ( FLUID_TYPE_SALINE == fluidType ) { // Check for empty saline bag per arterial line pressure if ( TRUE == isSalineBagEmpty() ) Index: firmware/App/Services/StateServices/FluidBolus.h =================================================================== diff -u -r0b025cea0b0f290ea44714a8fae6d71ea05088b9 -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Services/StateServices/FluidBolus.h (.../FluidBolus.h) (revision 0b025cea0b0f290ea44714a8fae6d71ea05088b9) +++ firmware/App/Services/StateServices/FluidBolus.h (.../FluidBolus.h) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -60,7 +60,6 @@ void setBolusPermitted( BOOL permitted ); FLUID_BOLUS_STATE_T getCurrentFluidBolusState( void ); -FLUID_BOLUS_MEDIUM_T getFluidBolusMedium( void ); BOOL isFluidBolusActive( void ); void signalStartFluidBolus( U32 flowRate ); Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -rda286decac70b8da5b369ccca36c05fb5bdb7c73 -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision da286decac70b8da5b369ccca36c05fb5bdb7c73) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -368,4 +368,39 @@ return currentTubeSetType; } +/*********************************************************************//** + * @brief + * The validateTubeSetType function validates the current installed tube set type + * based on modality. + * @details \b Alarm: + * @details \b Inputs: none + * @details \b Outputs: none + * @return none. + *************************************************************************/ +void validateTubeSetType( void ) +{ + U32 modality = getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_MODALITY ); + BOOL misMatch = FALSE; + + if ( TREATMENT_MODALITY_HDF_ONLINE_FLUID == modality ) + { + if ( TUBE_SET_TYPE_HDF != currentTubeSetType ) + { + misMatch = TRUE; + } + } + else + { + if ( TREATMENT_MODALITY_HD_SALINE_FLUID != currentTubeSetType ) + { + misMatch = TRUE; + } + } + + if ( TRUE == misMatch ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_TUBE_SET_MISMATCH, modality, (U32)currentTubeSetType ); + } +} + /**@}*/ Index: firmware/App/Services/StateServices/TubeSetInstall.h =================================================================== diff -u -r4c35d4de9fd7fccaf7aa4adb9a68115e823adf64 -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Services/StateServices/TubeSetInstall.h (.../TubeSetInstall.h) (revision 4c35d4de9fd7fccaf7aa4adb9a68115e823adf64) +++ firmware/App/Services/StateServices/TubeSetInstall.h (.../TubeSetInstall.h) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -53,8 +53,9 @@ BOOL isTubeSetInstallComplete( void ); // Returns True once auto-load finished successfully BOOL handleAutoLoadRequest( MESSAGE_T *message ); // Handle UI auto-load confirmation request -void setTubeSetType( TUBE_SET_TYPE_T type ); // Set the current installed tube set type +void setTubeSetType( TUBE_SET_TYPE_T type ); // Set the current installed tube set type TODO: Call this after implementing bar code logic TUBE_SET_TYPE_T getTubeSetType( void ); // Get the current installed tube set type +void validateTubeSetType( void ); // Validate tube set type with the modality TODO: call this after implementing bar code logic and setting the tube set type /**@}*/ Index: firmware/App/Services/TxParams.c =================================================================== diff -u -ra12f3ce494cd2a18aee31659c17d8a619fc70f7d -rc2951f468ebc19160ee9af14cc9c35bc16121889 --- firmware/App/Services/TxParams.c (.../TxParams.c) (revision a12f3ce494cd2a18aee31659c17d8a619fc70f7d) +++ firmware/App/Services/TxParams.c (.../TxParams.c) (revision c2951f468ebc19160ee9af14cc9c35bc16121889) @@ -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" @@ -109,7 +110,7 @@ /// Treatment parameter properties including data type, range limits and default values. static const TREATMENT_PARAMS_PROPERTIES_T TREAT_PARAMS_PROPERTIES[ NUM_OF_TREATMENT_PARAMS ] = { // type min max default - { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=2}, {.uInt=0} }, // TREATMENT_PARAM_TREATMENT_MODALITY + { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=3}, {.uInt=0} }, // TREATMENT_PARAM_TREATMENT_MODALITY { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=2}, {.uInt=0} }, // TREATMENT_PARAM_HDF_DILUTION { 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 @@ -573,11 +574,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; @@ -730,12 +731,13 @@ *************************************************************************/ static BOOL checkTreatmentParamsDependencies( U32 *reasons ) { - BOOL result = TRUE; - U32 txDur = stagedParams[ TREATMENT_PARAM_TREATMENT_DURATION ].uInt; - U32 hepST = stagedParams[ TREATMENT_PARAM_HEPARIN_DELIVERY_DURATION ].uInt; - 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; + BOOL result = TRUE; + U32 txDur = stagedParams[ TREATMENT_PARAM_TREATMENT_DURATION ].uInt; + U32 hepST = stagedParams[ TREATMENT_PARAM_HEPARIN_DELIVERY_DURATION ].uInt; + 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; + U32 modality = stagedParams[ TREATMENT_PARAM_TREATMENT_MODALITY ].uInt; // Variable to validate acid conversion factor consistency U32 acidType = stagedParams[ TREATMENT_PARAM_ACID_CONCENTRATE ].uInt; @@ -766,6 +768,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; }