Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -rce9145f506c3b7b970285bf2ab2e464b66f83bab -r027a8c7ac2a20cae3304dd6d72d54a1edbc19820 --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision ce9145f506c3b7b970285bf2ab2e464b66f83bab) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 027a8c7ac2a20cae3304dd6d72d54a1edbc19820) @@ -8,7 +8,7 @@ * @file TubeSetInstall.c * * @author (last) Praneeth Bunne -* @date (last) 04-Jun-2026 +* @date (last) 26-Jun-2026 * * @author (original) Praneeth Bunne * @date (original) 01-May-2026 @@ -52,6 +52,8 @@ static TUBE_SET_INSTALL_STATE_T previousInstallState; ///< Previous tube set install sub-state static TUBE_SET_INSTALL_STATE_T currentInstallState; ///< Current tubing set install sub-state +static TUBE_SET_TYPE_T currentTubeSetType; ///< Current installed tube set type + // ********** private function prototypes ********** static TUBE_SET_INSTALL_STATE_T handleAwaitTubesetConfirmationState( void ); ///< Handle Await Tubset Install Confirmation sub-state @@ -78,6 +80,7 @@ bloodPumpTimerCounter = 0; bpLastHome = TRUE; bpLeftHomeTimerCounter = 0; + currentTubeSetType = TUBE_SET_TYPE_UNKNOWN; } /*********************************************************************//** @@ -124,8 +127,8 @@ if ( previousInstallState != currentInstallState ) { - previousInstallState = currentInstallState; SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_SUB_STATE_CHANGE, previousInstallState, currentInstallState ); + previousInstallState = currentInstallState; } } @@ -418,4 +421,71 @@ return result; } +/*********************************************************************//** +* The setTubeSetType function sets the current installed tube set type. + * @details \b Alarms: ALARM_ID_TD_SOFTWARE_FAULT if tube set is invalid type + * @details \b Inputs: none + * @details \b Outputs: currentTubeSetType + * @param type Tube set type determined from barcode scan. + * @return none + *************************************************************************/ +void setTubeSetType( TUBE_SET_TYPE_T type ) +{ + if ( type < NUM_OF_TUBE_SET_TYPES ) + { + currentTubeSetType = type; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_TUBE_SET_TYPE, (U32)type ); + } +} + +/*********************************************************************//** + * @brief + * The getTubeSetType function returns the current installed tube set type. + * @details \b Inputs: currentTubeSetType + * @details \b Outputs: none + * @return Current installed tube set type. + *************************************************************************/ +TUBE_SET_TYPE_T getTubeSetType( void ) +{ + 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 ); + } +} + /**@}*/