Improve dashboard UX: connect instruments before tests, clarify simulation controls, show error messages
This commit is contained in:
@@ -203,21 +203,23 @@ def display_controls() -> None:
|
|||||||
"""Display simulation control panel in sidebar."""
|
"""Display simulation control panel in sidebar."""
|
||||||
st.sidebar.header("Simulation Controls")
|
st.sidebar.header("Simulation Controls")
|
||||||
|
|
||||||
|
st.sidebar.info("🔧 Physics engine is always running in the background. Use the button below to start/stop chart updates.")
|
||||||
|
|
||||||
# Start/Stop button
|
# Start/Stop button
|
||||||
if st.session_state.running:
|
if st.session_state.running:
|
||||||
if st.sidebar.button(
|
if st.sidebar.button(
|
||||||
"Stop Simulation", type="primary", use_container_width=True
|
"⏸️ Pause Charts", type="primary", width="stretch"
|
||||||
):
|
):
|
||||||
st.session_state.running = False
|
st.session_state.running = False
|
||||||
else:
|
else:
|
||||||
if st.sidebar.button(
|
if st.sidebar.button(
|
||||||
"Start Simulation", type="primary", use_container_width=True
|
"▶️ Start Charts", type="primary", width="stretch"
|
||||||
):
|
):
|
||||||
st.session_state.running = True
|
st.session_state.running = True
|
||||||
st.session_state.last_update = time.time()
|
st.session_state.last_update = time.time()
|
||||||
|
|
||||||
# Reset button
|
# Reset button
|
||||||
if st.sidebar.button("Reset", use_container_width=True):
|
if st.sidebar.button("Reset", width="stretch"):
|
||||||
# Stop server and restart
|
# Stop server and restart
|
||||||
server: SimulationServer = st.session_state.server
|
server: SimulationServer = st.session_state.server
|
||||||
loop = asyncio.new_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
@@ -580,7 +582,7 @@ def test_execution_page() -> None:
|
|||||||
if st.button(
|
if st.button(
|
||||||
"Run Test",
|
"Run Test",
|
||||||
type="primary",
|
type="primary",
|
||||||
use_container_width=True,
|
width="stretch",
|
||||||
disabled=st.session_state.test_running,
|
disabled=st.session_state.test_running,
|
||||||
):
|
):
|
||||||
st.session_state.test_running = True
|
st.session_state.test_running = True
|
||||||
@@ -602,6 +604,16 @@ def test_execution_page() -> None:
|
|||||||
runner: TestRunner = st.session_state.test_runner
|
runner: TestRunner = st.session_state.test_runner
|
||||||
instruments: InstrumentSet = st.session_state.instruments
|
instruments: InstrumentSet = st.session_state.instruments
|
||||||
|
|
||||||
|
# Connect instruments before running test
|
||||||
|
try:
|
||||||
|
instruments.chamber.transport.connect() # type: ignore[attr-defined]
|
||||||
|
instruments.psu.transport.connect() # type: ignore[attr-defined]
|
||||||
|
instruments.dmm.transport.connect() # type: ignore[attr-defined]
|
||||||
|
except Exception as e:
|
||||||
|
st.error(f"Failed to connect to instruments: {e}")
|
||||||
|
st.session_state.test_running = False
|
||||||
|
st.stop()
|
||||||
|
|
||||||
# Run the test
|
# Run the test
|
||||||
run_id = runner.run_test(
|
run_id = runner.run_test(
|
||||||
test=selected_test,
|
test=selected_test,
|
||||||
@@ -629,9 +641,9 @@ def test_execution_page() -> None:
|
|||||||
col1, col2, col3 = st.columns(3)
|
col1, col2, col3 = st.columns(3)
|
||||||
with col1:
|
with col1:
|
||||||
status_color = {"PASSED": "🟢", "FAILED": "🔴", "ERROR": "🟡"}.get(
|
status_color = {"PASSED": "🟢", "FAILED": "🔴", "ERROR": "🟡"}.get(
|
||||||
run.status.value, "⚪"
|
run.status.value.upper(), "⚪"
|
||||||
)
|
)
|
||||||
st.metric("Status", f"{status_color} {run.status.value}")
|
st.metric("Status", f"{status_color} {run.status.value.upper()}")
|
||||||
with col2:
|
with col2:
|
||||||
if run.completed_at and run.started_at:
|
if run.completed_at and run.started_at:
|
||||||
duration = (run.completed_at - run.started_at).total_seconds()
|
duration = (run.completed_at - run.started_at).total_seconds()
|
||||||
@@ -642,6 +654,12 @@ def test_execution_page() -> None:
|
|||||||
results = repository.get_results(st.session_state.test_run_id)
|
results = repository.get_results(st.session_state.test_run_id)
|
||||||
st.metric("Results", len(results))
|
st.metric("Results", len(results))
|
||||||
|
|
||||||
|
# Show error/warning message for non-PASSED tests
|
||||||
|
if run.status.value.upper() == "ERROR":
|
||||||
|
st.error("⚠️ Test encountered an error during execution. Check the detailed results below or the terminal output for error messages.")
|
||||||
|
elif run.status.value.upper() == "FAILED":
|
||||||
|
st.warning("⚠️ Test completed but one or more results failed to meet specifications.")
|
||||||
|
|
||||||
# Show detailed results
|
# Show detailed results
|
||||||
if results:
|
if results:
|
||||||
st.markdown("#### Detailed Results")
|
st.markdown("#### Detailed Results")
|
||||||
@@ -757,7 +775,7 @@ def results_viewer_page() -> None:
|
|||||||
# Use data editor for row selection
|
# Use data editor for row selection
|
||||||
edited_df = st.data_editor(
|
edited_df = st.data_editor(
|
||||||
df,
|
df,
|
||||||
use_container_width=True,
|
width="stretch",
|
||||||
hide_index=True,
|
hide_index=True,
|
||||||
column_config={
|
column_config={
|
||||||
"Select": st.column_config.CheckboxColumn(
|
"Select": st.column_config.CheckboxColumn(
|
||||||
@@ -850,7 +868,7 @@ def results_viewer_page() -> None:
|
|||||||
).properties(
|
).properties(
|
||||||
height=300
|
height=300
|
||||||
)
|
)
|
||||||
st.altair_chart(chart, use_container_width=True)
|
st.altair_chart(chart, width="stretch")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
st.caption(f"No time-series measurement data available ({e})")
|
st.caption(f"No time-series measurement data available ({e})")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user