Update app.py
Browse files
app.py
CHANGED
|
@@ -358,7 +358,7 @@ def main():
|
|
| 358 |
# --- HORIZONTAL LAYOUT: LEFT (INPUTS) | RIGHT (ANALYSIS) ---
|
| 359 |
left_col, right_col = st.columns([1, 1.5])
|
| 360 |
|
| 361 |
-
# ========== LEFT COLUMN: PARAMETER INPUTS ==========
|
| 362 |
with left_col:
|
| 363 |
st.markdown('<div class="section-title">📊 Engine Parameters</div>', unsafe_allow_html=True)
|
| 364 |
|
|
@@ -372,132 +372,129 @@ def main():
|
|
| 372 |
'oil_temp': {'warning_high': 110, 'critical_high': 130}
|
| 373 |
}
|
| 374 |
|
| 375 |
-
#
|
| 376 |
-
|
| 377 |
-
st.markdown('<div class="param-header"><span class="param-icon">⚡</span><span class="param-name">Engine RPM</span></div>', unsafe_allow_html=True)
|
| 378 |
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
st.session_state.rpm
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 399 |
-
st.markdown('<div class="param-header"><span class="param-icon">⛽</span><span class="param-name">Fuel Pressure (Bar)</span></div>', unsafe_allow_html=True)
|
| 400 |
-
|
| 401 |
-
input_col1, input_col2 = st.columns([1, 3])
|
| 402 |
-
with input_col1:
|
| 403 |
-
fuel_num = st.number_input("", 0.0, 25.0, value=st.session_state.fuel_p, step=0.1, key="fuel_num", label_visibility="collapsed")
|
| 404 |
-
with input_col2:
|
| 405 |
-
fuel_sld = st.slider("", 0.0, 25.0, value=st.session_state.fuel_p, step=0.1, key="fuel_sld", label_visibility="collapsed")
|
| 406 |
-
|
| 407 |
-
if fuel_num != st.session_state.fuel_p:
|
| 408 |
-
st.session_state.fuel_p = fuel_num
|
| 409 |
-
st.rerun()
|
| 410 |
-
elif fuel_sld != st.session_state.fuel_p:
|
| 411 |
-
st.session_state.fuel_p = fuel_sld
|
| 412 |
-
st.rerun()
|
| 413 |
-
|
| 414 |
-
st.markdown(f'<div class="param-value-display" style="color: #ff6b35;">{st.session_state.fuel_p:.1f}</div>', unsafe_allow_html=True)
|
| 415 |
-
st.plotly_chart(create_gauge(st.session_state.fuel_p, 25, "#ff6b35"), use_container_width=True, config={'displayModeBar': False})
|
| 416 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 417 |
-
|
| 418 |
-
# --- OIL PRESSURE ---
|
| 419 |
-
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 420 |
-
st.markdown('<div class="param-header"><span class="param-icon">🛢️</span><span class="param-name">Oil Pressure (Bar)</span></div>', unsafe_allow_html=True)
|
| 421 |
-
|
| 422 |
-
input_col1, input_col2 = st.columns([1, 3])
|
| 423 |
-
with input_col1:
|
| 424 |
-
oil_p_num = st.number_input("", 0.0, 10.0, value=st.session_state.oil_p, step=0.1, key="oil_p_num", label_visibility="collapsed")
|
| 425 |
-
with input_col2:
|
| 426 |
-
oil_p_sld = st.slider("", 0.0, 10.0, value=st.session_state.oil_p, step=0.1, key="oil_p_sld", label_visibility="collapsed")
|
| 427 |
-
|
| 428 |
-
if oil_p_num != st.session_state.oil_p:
|
| 429 |
-
st.session_state.oil_p = oil_p_num
|
| 430 |
-
st.rerun()
|
| 431 |
-
elif oil_p_sld != st.session_state.oil_p:
|
| 432 |
-
st.session_state.oil_p = oil_p_sld
|
| 433 |
-
st.rerun()
|
| 434 |
-
|
| 435 |
-
st.markdown(f'<div class="param-value-display" style="color: #ffaa00;">{st.session_state.oil_p:.2f}</div>', unsafe_allow_html=True)
|
| 436 |
-
st.plotly_chart(create_gauge(st.session_state.oil_p, 10, "#ffaa00"), use_container_width=True, config={'displayModeBar': False})
|
| 437 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 438 |
-
|
| 439 |
-
# --- COOLANT TEMP ---
|
| 440 |
-
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 441 |
-
st.markdown('<div class="param-header"><span class="param-icon">🌡️</span><span class="param-name">Coolant Temp (°C)</span></div>', unsafe_allow_html=True)
|
| 442 |
-
|
| 443 |
-
input_col1, input_col2 = st.columns([1, 3])
|
| 444 |
-
with input_col1:
|
| 445 |
-
coolant_t_num = st.number_input("", 0.0, 200.0, value=st.session_state.coolant_temp, step=1.0, key="coolant_t_num", label_visibility="collapsed")
|
| 446 |
-
with input_col2:
|
| 447 |
-
coolant_t_sld = st.slider("", 0.0, 200.0, value=st.session_state.coolant_temp, step=1.0, key="coolant_t_sld", label_visibility="collapsed")
|
| 448 |
-
|
| 449 |
-
if coolant_t_num != st.session_state.coolant_temp:
|
| 450 |
-
st.session_state.coolant_temp = coolant_t_num
|
| 451 |
-
st.rerun()
|
| 452 |
-
elif coolant_t_sld != st.session_state.coolant_temp:
|
| 453 |
-
st.session_state.coolant_temp = coolant_t_sld
|
| 454 |
-
st.rerun()
|
| 455 |
-
|
| 456 |
-
st.markdown(f'<div class="param-value-display" style="color: #ff3366;">{st.session_state.coolant_temp:.1f}</div>', unsafe_allow_html=True)
|
| 457 |
-
st.plotly_chart(create_gauge(st.session_state.coolant_temp, 200, "#ff3366"), use_container_width=True, config={'displayModeBar': False})
|
| 458 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 459 |
-
|
| 460 |
-
# --- COOLANT PRESSURE ---
|
| 461 |
-
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 462 |
-
st.markdown('<div class="param-header"><span class="param-icon">💧</span><span class="param-name">Coolant Pressure (Bar)</span></div>', unsafe_allow_html=True)
|
| 463 |
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
st.rerun()
|
| 473 |
-
elif coolant_p_sld != st.session_state.coolant_p:
|
| 474 |
-
st.session_state.coolant_p = coolant_p_sld
|
| 475 |
-
st.rerun()
|
| 476 |
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
oil_t_num = st.number_input("", 0.0, 150.0, value=st.session_state.oil_temp, step=1.0, key="oil_t_num", label_visibility="collapsed")
|
| 488 |
-
with input_col2:
|
| 489 |
-
oil_t_sld = st.slider("", 0.0, 150.0, value=st.session_state.oil_temp, step=1.0, key="oil_t_sld", label_visibility="collapsed")
|
| 490 |
|
| 491 |
-
|
| 492 |
-
st.
|
| 493 |
-
st.
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
|
| 502 |
# ========== RIGHT COLUMN: ANALYSIS ==========
|
| 503 |
with right_col:
|
|
|
|
| 358 |
# --- HORIZONTAL LAYOUT: LEFT (INPUTS) | RIGHT (ANALYSIS) ---
|
| 359 |
left_col, right_col = st.columns([1, 1.5])
|
| 360 |
|
| 361 |
+
# ========== LEFT COLUMN: PARAMETER INPUTS (2x3 GRID) ==========
|
| 362 |
with left_col:
|
| 363 |
st.markdown('<div class="section-title">📊 Engine Parameters</div>', unsafe_allow_html=True)
|
| 364 |
|
|
|
|
| 372 |
'oil_temp': {'warning_high': 110, 'critical_high': 130}
|
| 373 |
}
|
| 374 |
|
| 375 |
+
# ROW 1: RPM and FUEL
|
| 376 |
+
row1_col1, row1_col2 = st.columns(2)
|
|
|
|
| 377 |
|
| 378 |
+
with row1_col1:
|
| 379 |
+
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 380 |
+
st.markdown('<div class="param-header"><span class="param-icon">⚡</span><span class="param-name">Engine RPM</span></div>', unsafe_allow_html=True)
|
| 381 |
+
|
| 382 |
+
input_col1, input_col2 = st.columns([1, 3])
|
| 383 |
+
with input_col1:
|
| 384 |
+
rpm_num = st.number_input("", 0, 2500, value=st.session_state.rpm, step=50, key="rpm_num", label_visibility="collapsed")
|
| 385 |
+
with input_col2:
|
| 386 |
+
rpm_sld = st.slider("", 0, 2500, value=st.session_state.rpm, step=50, key="rpm_sld", label_visibility="collapsed")
|
| 387 |
+
|
| 388 |
+
# Update session state from whichever changed
|
| 389 |
+
if rpm_num != st.session_state.rpm:
|
| 390 |
+
st.session_state.rpm = rpm_num
|
| 391 |
+
if rpm_sld != st.session_state.rpm:
|
| 392 |
+
st.session_state.rpm = rpm_sld
|
| 393 |
+
|
| 394 |
+
st.markdown(f'<div class="param-value-display" style="color: #00d4ff;">{st.session_state.rpm}</div>', unsafe_allow_html=True)
|
| 395 |
+
st.plotly_chart(create_gauge(st.session_state.rpm, 2500, "#00d4ff"), use_container_width=True, config={'displayModeBar': False}, key="g_rpm")
|
| 396 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
|
| 398 |
+
with row1_col2:
|
| 399 |
+
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 400 |
+
st.markdown('<div class="param-header"><span class="param-icon">⛽</span><span class="param-name">Fuel Pressure (Bar)</span></div>', unsafe_allow_html=True)
|
| 401 |
+
|
| 402 |
+
input_col1, input_col2 = st.columns([1, 3])
|
| 403 |
+
with input_col1:
|
| 404 |
+
fuel_num = st.number_input("", 0.0, 25.0, value=st.session_state.fuel_p, step=0.1, key="fuel_num", label_visibility="collapsed")
|
| 405 |
+
with input_col2:
|
| 406 |
+
fuel_sld = st.slider("", 0.0, 25.0, value=st.session_state.fuel_p, step=0.1, key="fuel_sld", label_visibility="collapsed")
|
| 407 |
+
|
| 408 |
+
if fuel_num != st.session_state.fuel_p:
|
| 409 |
+
st.session_state.fuel_p = fuel_num
|
| 410 |
+
if fuel_sld != st.session_state.fuel_p:
|
| 411 |
+
st.session_state.fuel_p = fuel_sld
|
| 412 |
+
|
| 413 |
+
st.markdown(f'<div class="param-value-display" style="color: #ff6b35;">{st.session_state.fuel_p:.1f}</div>', unsafe_allow_html=True)
|
| 414 |
+
st.plotly_chart(create_gauge(st.session_state.fuel_p, 25, "#ff6b35"), use_container_width=True, config={'displayModeBar': False}, key="g_fuel")
|
| 415 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 416 |
|
| 417 |
+
# ROW 2: OIL PRESSURE and COOLANT TEMP
|
| 418 |
+
row2_col1, row2_col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
|
| 420 |
+
with row2_col1:
|
| 421 |
+
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 422 |
+
st.markdown('<div class="param-header"><span class="param-icon">🛢️</span><span class="param-name">Oil Pressure (Bar)</span></div>', unsafe_allow_html=True)
|
| 423 |
+
|
| 424 |
+
input_col1, input_col2 = st.columns([1, 3])
|
| 425 |
+
with input_col1:
|
| 426 |
+
oil_p_num = st.number_input("", 0.0, 10.0, value=st.session_state.oil_p, step=0.1, key="oil_p_num", label_visibility="collapsed")
|
| 427 |
+
with input_col2:
|
| 428 |
+
oil_p_sld = st.slider("", 0.0, 10.0, value=st.session_state.oil_p, step=0.1, key="oil_p_sld", label_visibility="collapsed")
|
| 429 |
+
|
| 430 |
+
if oil_p_num != st.session_state.oil_p:
|
| 431 |
+
st.session_state.oil_p = oil_p_num
|
| 432 |
+
if oil_p_sld != st.session_state.oil_p:
|
| 433 |
+
st.session_state.oil_p = oil_p_sld
|
| 434 |
+
|
| 435 |
+
st.markdown(f'<div class="param-value-display" style="color: #ffaa00;">{st.session_state.oil_p:.2f}</div>', unsafe_allow_html=True)
|
| 436 |
+
st.plotly_chart(create_gauge(st.session_state.oil_p, 10, "#ffaa00"), use_container_width=True, config={'displayModeBar': False}, key="g_oil_p")
|
| 437 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 438 |
|
| 439 |
+
with row2_col2:
|
| 440 |
+
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 441 |
+
st.markdown('<div class="param-header"><span class="param-icon">🌡️</span><span class="param-name">Coolant Temp (°C)</span></div>', unsafe_allow_html=True)
|
| 442 |
+
|
| 443 |
+
input_col1, input_col2 = st.columns([1, 3])
|
| 444 |
+
with input_col1:
|
| 445 |
+
coolant_t_num = st.number_input("", 0.0, 200.0, value=st.session_state.coolant_temp, step=1.0, key="coolant_t_num", label_visibility="collapsed")
|
| 446 |
+
with input_col2:
|
| 447 |
+
coolant_t_sld = st.slider("", 0.0, 200.0, value=st.session_state.coolant_temp, step=1.0, key="coolant_t_sld", label_visibility="collapsed")
|
| 448 |
+
|
| 449 |
+
if coolant_t_num != st.session_state.coolant_temp:
|
| 450 |
+
st.session_state.coolant_temp = coolant_t_num
|
| 451 |
+
if coolant_t_sld != st.session_state.coolant_temp:
|
| 452 |
+
st.session_state.coolant_temp = coolant_t_sld
|
| 453 |
+
|
| 454 |
+
st.markdown(f'<div class="param-value-display" style="color: #ff3366;">{st.session_state.coolant_temp:.1f}</div>', unsafe_allow_html=True)
|
| 455 |
+
st.plotly_chart(create_gauge(st.session_state.coolant_temp, 200, "#ff3366"), use_container_width=True, config={'displayModeBar': False}, key="g_coolant_t")
|
| 456 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 457 |
|
| 458 |
+
# ROW 3: COOLANT PRESSURE and OIL TEMP
|
| 459 |
+
row3_col1, row3_col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
|
| 460 |
|
| 461 |
+
with row3_col1:
|
| 462 |
+
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 463 |
+
st.markdown('<div class="param-header"><span class="param-icon">💧</span><span class="param-name">Coolant Pressure (Bar)</span></div>', unsafe_allow_html=True)
|
| 464 |
+
|
| 465 |
+
input_col1, input_col2 = st.columns([1, 3])
|
| 466 |
+
with input_col1:
|
| 467 |
+
coolant_p_num = st.number_input("", 0.0, 10.0, value=st.session_state.coolant_p, step=0.1, key="coolant_p_num", label_visibility="collapsed")
|
| 468 |
+
with input_col2:
|
| 469 |
+
coolant_p_sld = st.slider("", 0.0, 10.0, value=st.session_state.coolant_p, step=0.1, key="coolant_p_sld", label_visibility="collapsed")
|
| 470 |
+
|
| 471 |
+
if coolant_p_num != st.session_state.coolant_p:
|
| 472 |
+
st.session_state.coolant_p = coolant_p_num
|
| 473 |
+
if coolant_p_sld != st.session_state.coolant_p:
|
| 474 |
+
st.session_state.coolant_p = coolant_p_sld
|
| 475 |
+
|
| 476 |
+
st.markdown(f'<div class="param-value-display" style="color: #00ff88;">{st.session_state.coolant_p:.2f}</div>', unsafe_allow_html=True)
|
| 477 |
+
st.plotly_chart(create_gauge(st.session_state.coolant_p, 10, "#00ff88"), use_container_width=True, config={'displayModeBar': False}, key="g_coolant_p")
|
| 478 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 479 |
|
| 480 |
+
with row3_col2:
|
| 481 |
+
st.markdown('<div class="param-card">', unsafe_allow_html=True)
|
| 482 |
+
st.markdown('<div class="param-header"><span class="param-icon">🔥</span><span class="param-name">Oil Temp (°C)</span></div>', unsafe_allow_html=True)
|
| 483 |
+
|
| 484 |
+
input_col1, input_col2 = st.columns([1, 3])
|
| 485 |
+
with input_col1:
|
| 486 |
+
oil_t_num = st.number_input("", 0.0, 150.0, value=st.session_state.oil_temp, step=1.0, key="oil_t_num", label_visibility="collapsed")
|
| 487 |
+
with input_col2:
|
| 488 |
+
oil_t_sld = st.slider("", 0.0, 150.0, value=st.session_state.oil_temp, step=1.0, key="oil_t_sld", label_visibility="collapsed")
|
| 489 |
+
|
| 490 |
+
if oil_t_num != st.session_state.oil_temp:
|
| 491 |
+
st.session_state.oil_temp = oil_t_num
|
| 492 |
+
if oil_t_sld != st.session_state.oil_temp:
|
| 493 |
+
st.session_state.oil_temp = oil_t_sld
|
| 494 |
+
|
| 495 |
+
st.markdown(f'<div class="param-value-display" style="color: #a855f7;">{st.session_state.oil_temp:.1f}</div>', unsafe_allow_html=True)
|
| 496 |
+
st.plotly_chart(create_gauge(st.session_state.oil_temp, 150, "#a855f7"), use_container_width=True, config={'displayModeBar': False}, key="g_oil_t")
|
| 497 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 498 |
|
| 499 |
# ========== RIGHT COLUMN: ANALYSIS ==========
|
| 500 |
with right_col:
|