File size: 2,650 Bytes
7b6d659
 
 
 
 
 
 
5bc736c
7b6d659
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5c9b711
 
 
 
 
7b6d659
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5c9b711
 
 
7b6d659
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from pathlib import Path

import pandas as pd
import streamlit as st

from queries.process_ue_capability import SHEET_ORDER, parse_uecap_files, to_excel_bytes

st.title(":material/memory: UE Capability Parser")
st.markdown(
    """
Parse UE Capability text exports (`.txt`) from drive-test/log tools (Actix/TEMS-like decoded RRC trees)
and extract useful 3GPP info:
- Bands by RAT (LTE, WCDMA/UTRA, GSM/GERAN, NR when present)
- Features and category fields
- CA / combination structures
- Release explicit + inferred (rules-based)
"""
)


samples_dir = Path(__file__).resolve().parents[1] / "samples"
sample_uecap = samples_dir / "ue_capability.txt"

if sample_uecap.exists():
    st.download_button(
        label="Download UE capability sample",
        data=sample_uecap.read_bytes(),
        file_name=sample_uecap.name,
        mime="text/plain",
    )

uploaded_files = st.file_uploader(
    "Upload one or multiple UE capability text files",
    type=["txt"],
    accept_multiple_files=True,
)

enable_volte_assessment = st.checkbox(
    "Enable VoLTE assessment",
    value=True,
    help="Compute VoLTE confidence score and supporting evidence.",
)

if st.button("Process", type="primary", disabled=not uploaded_files):
    try:
        payload = [(f.name, f.read()) for f in uploaded_files]
        with st.spinner("Parsing UE capability exports..."):
            sheets = parse_uecap_files(
                payload,
                enable_volte_assessment=enable_volte_assessment,
            )
            excel_bytes = to_excel_bytes(sheets)
        st.session_state["uecap_sheets"] = sheets
        st.session_state["uecap_excel"] = excel_bytes
        st.success(f"Processed {len(uploaded_files)} file(s).")
    except Exception as error:
        st.error(f"Parsing failed: {error}")

sheets: dict[str, pd.DataFrame] | None = st.session_state.get("uecap_sheets")
excel_bytes: bytes | None = st.session_state.get("uecap_excel")

if sheets:
    visible_sheets = [name for name in SHEET_ORDER if name != "Benchmark_CA_Diff"]
    tabs = st.tabs(visible_sheets)
    for tab, sheet_name in zip(tabs, visible_sheets):
        with tab:
            df = sheets.get(sheet_name, pd.DataFrame())
            if df is None or df.empty:
                st.info("No data extracted for this sheet.")
            else:
                st.dataframe(df, use_container_width=True)

if excel_bytes:
    st.download_button(
        label="Download UE capability Excel",
        data=excel_bytes,
        file_name="UE_Capability_Parsed.xlsx",
        mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        type="primary",
    )