iStillWaters commited on
Commit
52d0b0d
·
verified ·
1 Parent(s): ca669da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -28
app.py CHANGED
@@ -68,6 +68,11 @@ def load_css():
68
  display: none !important;
69
  }
70
 
 
 
 
 
 
71
  /* Compact number inputs */
72
  .stNumberInput > label {
73
  display: none !important;
@@ -77,6 +82,11 @@ def load_css():
77
  margin-bottom: 0 !important;
78
  }
79
 
 
 
 
 
 
80
  .stNumberInput input {
81
  font-size: 0.9rem !important;
82
  padding: 0.3rem !important;
@@ -152,7 +162,7 @@ def load_css():
152
  position: relative;
153
  width: 180px;
154
  height: 180px;
155
- margin: 1rem auto;
156
  display: flex;
157
  align-items: center;
158
  justify-content: center;
@@ -360,7 +370,7 @@ def load_css():
360
  border-radius: 30px;
361
  text-transform: uppercase;
362
  letter-spacing: 2px;
363
- margin-top: 0.5rem;
364
  }
365
 
366
  .badge-healthy {
@@ -592,6 +602,20 @@ def main():
592
  # Parameter Input Section
593
  st.markdown("### 📊 Engine Parameters")
594
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595
  # Create 2 rows of 3 parameters each
596
  col1, col2, col3 = st.columns(3)
597
 
@@ -603,13 +627,17 @@ def main():
603
  # Manual input and slider in columns
604
  rpm_col1, rpm_col2 = st.columns([1, 2])
605
  with rpm_col1:
606
- rpm_input = st.number_input("", 0, 2500, 750, 50, label_visibility="collapsed", key="rpm_input")
607
  with rpm_col2:
608
- rpm = st.slider("", 0, 2500, rpm_input, 50, label_visibility="collapsed", key="rpm")
 
 
 
 
 
 
609
 
610
- # Sync the values
611
- if rpm != rpm_input:
612
- rpm = rpm_input
613
 
614
  st.markdown(f'<div class="param-value">{rpm}</div>', unsafe_allow_html=True)
615
  st.plotly_chart(create_circular_gauge(rpm, 2500, "RPM", "#00d4ff"), use_container_width=True, key="gauge_rpm")
@@ -622,12 +650,16 @@ def main():
622
 
623
  fuel_col1, fuel_col2 = st.columns([1, 2])
624
  with fuel_col1:
625
- fuel_input = st.number_input("", 0.0, 25.0, 6.2, 0.1, label_visibility="collapsed", key="fuel_input")
626
  with fuel_col2:
627
- fuel_p = st.slider("", 0.0, 25.0, fuel_input, 0.1, label_visibility="collapsed", key="fuel")
628
 
629
- if fuel_p != fuel_input:
630
- fuel_p = fuel_input
 
 
 
 
631
 
632
  st.markdown(f'<div class="param-value">{fuel_p:.1f} Bar</div>', unsafe_allow_html=True)
633
  st.plotly_chart(create_circular_gauge(fuel_p, 25, "Fuel", "#ff6b35", "Bar"), use_container_width=True, key="gauge_fuel")
@@ -640,12 +672,16 @@ def main():
640
 
641
  oil_p_col1, oil_p_col2 = st.columns([1, 2])
642
  with oil_p_col1:
643
- oil_p_input = st.number_input("", 0.0, 10.0, 3.16, 0.1, label_visibility="collapsed", key="oil_p_input")
644
  with oil_p_col2:
645
- lub_oil_p = st.slider("", 0.0, 10.0, oil_p_input, 0.1, label_visibility="collapsed", key="oil_p")
 
 
 
 
 
646
 
647
- if lub_oil_p != oil_p_input:
648
- lub_oil_p = oil_p_input
649
 
650
  st.markdown(f'<div class="param-value">{lub_oil_p:.2f} Bar</div>', unsafe_allow_html=True)
651
  st.plotly_chart(create_circular_gauge(lub_oil_p, 10, "Oil", "#ffaa00", "Bar"), use_container_width=True, key="gauge_oil_p")
@@ -661,12 +697,16 @@ def main():
661
 
662
  coolant_t_col1, coolant_t_col2 = st.columns([1, 2])
663
  with coolant_t_col1:
664
- coolant_t_input = st.number_input("", 0.0, 200.0, 80.0, 1.0, label_visibility="collapsed", key="coolant_temp_input")
665
  with coolant_t_col2:
666
- coolant_temp = st.slider("", 0.0, 200.0, coolant_t_input, 1.0, label_visibility="collapsed", key="coolant_temp")
667
 
668
- if coolant_temp != coolant_t_input:
669
- coolant_temp = coolant_t_input
 
 
 
 
670
 
671
  st.markdown(f'<div class="param-value">{coolant_temp:.1f} °C</div>', unsafe_allow_html=True)
672
  st.plotly_chart(create_circular_gauge(coolant_temp, 200, "Temp", "#ff3366", "°C"), use_container_width=True, key="gauge_coolant_t")
@@ -679,12 +719,16 @@ def main():
679
 
680
  coolant_p_col1, coolant_p_col2 = st.columns([1, 2])
681
  with coolant_p_col1:
682
- coolant_p_input = st.number_input("", 0.0, 10.0, 2.16, 0.1, label_visibility="collapsed", key="coolant_p_input")
683
  with coolant_p_col2:
684
- coolant_p = st.slider("", 0.0, 10.0, coolant_p_input, 0.1, label_visibility="collapsed", key="coolant_p")
 
 
 
 
 
685
 
686
- if coolant_p != coolant_p_input:
687
- coolant_p = coolant_p_input
688
 
689
  st.markdown(f'<div class="param-value">{coolant_p:.2f} Bar</div>', unsafe_allow_html=True)
690
  st.plotly_chart(create_circular_gauge(coolant_p, 10, "Coolant P", "#00ff88", "Bar"), use_container_width=True, key="gauge_coolant_p")
@@ -697,12 +741,16 @@ def main():
697
 
698
  oil_t_col1, oil_t_col2 = st.columns([1, 2])
699
  with oil_t_col1:
700
- oil_t_input = st.number_input("", 0.0, 150.0, 80.0, 1.0, label_visibility="collapsed", key="oil_temp_input")
701
  with oil_t_col2:
702
- lub_oil_t = st.slider("", 0.0, 150.0, oil_t_input, 1.0, label_visibility="collapsed", key="oil_temp")
 
 
 
 
 
703
 
704
- if lub_oil_t != oil_t_input:
705
- lub_oil_t = oil_t_input
706
 
707
  st.markdown(f'<div class="param-value">{lub_oil_t:.1f} °C</div>', unsafe_allow_html=True)
708
  st.plotly_chart(create_circular_gauge(lub_oil_t, 150, "Oil Temp", "#a855f7", "°C"), use_container_width=True, key="gauge_oil_t")
@@ -757,6 +805,7 @@ def main():
757
  {prob*100:.1f}% Failure Risk
758
  </div>
759
  </div>
 
760
  """, unsafe_allow_html=True)
761
 
762
  # Status badge
@@ -821,10 +870,11 @@ def main():
821
  Awaiting Analysis
822
  </div>
823
  </div>
 
824
  """, unsafe_allow_html=True)
825
 
826
  st.markdown(f"""
827
- <div style="text-align: center; margin-top: 2rem;">
828
  <p style="font-family: 'Rajdhani', sans-serif; color: #8b95a5; font-size: 1.1rem;">
829
  Configure engine parameters above and click "ANALYZE ENGINE STATUS"
830
  </p>
 
68
  display: none !important;
69
  }
70
 
71
+ /* Hide the container/bar above sliders */
72
+ .stSlider > div[data-baseweb="slider"] > div:first-child {
73
+ display: none !important;
74
+ }
75
+
76
  /* Compact number inputs */
77
  .stNumberInput > label {
78
  display: none !important;
 
82
  margin-bottom: 0 !important;
83
  }
84
 
85
+ /* Hide bars above number inputs */
86
+ .stNumberInput > div > div:first-child {
87
+ display: none !important;
88
+ }
89
+
90
  .stNumberInput input {
91
  font-size: 0.9rem !important;
92
  padding: 0.3rem !important;
 
162
  position: relative;
163
  width: 180px;
164
  height: 180px;
165
+ margin: 1rem auto 3rem auto;
166
  display: flex;
167
  align-items: center;
168
  justify-content: center;
 
370
  border-radius: 30px;
371
  text-transform: uppercase;
372
  letter-spacing: 2px;
373
+ margin-top: 1rem;
374
  }
375
 
376
  .badge-healthy {
 
602
  # Parameter Input Section
603
  st.markdown("### 📊 Engine Parameters")
604
 
605
+ # Initialize session state for parameter values if not exists
606
+ if 'rpm_val' not in st.session_state:
607
+ st.session_state.rpm_val = 750
608
+ if 'fuel_val' not in st.session_state:
609
+ st.session_state.fuel_val = 6.2
610
+ if 'oil_p_val' not in st.session_state:
611
+ st.session_state.oil_p_val = 3.16
612
+ if 'coolant_t_val' not in st.session_state:
613
+ st.session_state.coolant_t_val = 80.0
614
+ if 'coolant_p_val' not in st.session_state:
615
+ st.session_state.coolant_p_val = 2.16
616
+ if 'oil_t_val' not in st.session_state:
617
+ st.session_state.oil_t_val = 80.0
618
+
619
  # Create 2 rows of 3 parameters each
620
  col1, col2, col3 = st.columns(3)
621
 
 
627
  # Manual input and slider in columns
628
  rpm_col1, rpm_col2 = st.columns([1, 2])
629
  with rpm_col1:
630
+ rpm_input = st.number_input("", 0, 2500, st.session_state.rpm_val, 50, label_visibility="collapsed", key="rpm_input")
631
  with rpm_col2:
632
+ rpm_slider = st.slider("", 0, 2500, st.session_state.rpm_val, 50, label_visibility="collapsed", key="rpm_slider")
633
+
634
+ # Update session state based on which changed
635
+ if rpm_input != st.session_state.rpm_val:
636
+ st.session_state.rpm_val = rpm_input
637
+ elif rpm_slider != st.session_state.rpm_val:
638
+ st.session_state.rpm_val = rpm_slider
639
 
640
+ rpm = st.session_state.rpm_val
 
 
641
 
642
  st.markdown(f'<div class="param-value">{rpm}</div>', unsafe_allow_html=True)
643
  st.plotly_chart(create_circular_gauge(rpm, 2500, "RPM", "#00d4ff"), use_container_width=True, key="gauge_rpm")
 
650
 
651
  fuel_col1, fuel_col2 = st.columns([1, 2])
652
  with fuel_col1:
653
+ fuel_input = st.number_input("", 0.0, 25.0, st.session_state.fuel_val, 0.1, label_visibility="collapsed", key="fuel_input")
654
  with fuel_col2:
655
+ fuel_slider = st.slider("", 0.0, 25.0, st.session_state.fuel_val, 0.1, label_visibility="collapsed", key="fuel_slider")
656
 
657
+ if fuel_input != st.session_state.fuel_val:
658
+ st.session_state.fuel_val = fuel_input
659
+ elif fuel_slider != st.session_state.fuel_val:
660
+ st.session_state.fuel_val = fuel_slider
661
+
662
+ fuel_p = st.session_state.fuel_val
663
 
664
  st.markdown(f'<div class="param-value">{fuel_p:.1f} Bar</div>', unsafe_allow_html=True)
665
  st.plotly_chart(create_circular_gauge(fuel_p, 25, "Fuel", "#ff6b35", "Bar"), use_container_width=True, key="gauge_fuel")
 
672
 
673
  oil_p_col1, oil_p_col2 = st.columns([1, 2])
674
  with oil_p_col1:
675
+ oil_p_input = st.number_input("", 0.0, 10.0, st.session_state.oil_p_val, 0.1, label_visibility="collapsed", key="oil_p_input")
676
  with oil_p_col2:
677
+ oil_p_slider = st.slider("", 0.0, 10.0, st.session_state.oil_p_val, 0.1, label_visibility="collapsed", key="oil_p_slider")
678
+
679
+ if oil_p_input != st.session_state.oil_p_val:
680
+ st.session_state.oil_p_val = oil_p_input
681
+ elif oil_p_slider != st.session_state.oil_p_val:
682
+ st.session_state.oil_p_val = oil_p_slider
683
 
684
+ lub_oil_p = st.session_state.oil_p_val
 
685
 
686
  st.markdown(f'<div class="param-value">{lub_oil_p:.2f} Bar</div>', unsafe_allow_html=True)
687
  st.plotly_chart(create_circular_gauge(lub_oil_p, 10, "Oil", "#ffaa00", "Bar"), use_container_width=True, key="gauge_oil_p")
 
697
 
698
  coolant_t_col1, coolant_t_col2 = st.columns([1, 2])
699
  with coolant_t_col1:
700
+ coolant_t_input = st.number_input("", 0.0, 200.0, st.session_state.coolant_t_val, 1.0, label_visibility="collapsed", key="coolant_temp_input")
701
  with coolant_t_col2:
702
+ coolant_t_slider = st.slider("", 0.0, 200.0, st.session_state.coolant_t_val, 1.0, label_visibility="collapsed", key="coolant_temp_slider")
703
 
704
+ if coolant_t_input != st.session_state.coolant_t_val:
705
+ st.session_state.coolant_t_val = coolant_t_input
706
+ elif coolant_t_slider != st.session_state.coolant_t_val:
707
+ st.session_state.coolant_t_val = coolant_t_slider
708
+
709
+ coolant_temp = st.session_state.coolant_t_val
710
 
711
  st.markdown(f'<div class="param-value">{coolant_temp:.1f} °C</div>', unsafe_allow_html=True)
712
  st.plotly_chart(create_circular_gauge(coolant_temp, 200, "Temp", "#ff3366", "°C"), use_container_width=True, key="gauge_coolant_t")
 
719
 
720
  coolant_p_col1, coolant_p_col2 = st.columns([1, 2])
721
  with coolant_p_col1:
722
+ coolant_p_input = st.number_input("", 0.0, 10.0, st.session_state.coolant_p_val, 0.1, label_visibility="collapsed", key="coolant_p_input")
723
  with coolant_p_col2:
724
+ coolant_p_slider = st.slider("", 0.0, 10.0, st.session_state.coolant_p_val, 0.1, label_visibility="collapsed", key="coolant_p_slider")
725
+
726
+ if coolant_p_input != st.session_state.coolant_p_val:
727
+ st.session_state.coolant_p_val = coolant_p_input
728
+ elif coolant_p_slider != st.session_state.coolant_p_val:
729
+ st.session_state.coolant_p_val = coolant_p_slider
730
 
731
+ coolant_p = st.session_state.coolant_p_val
 
732
 
733
  st.markdown(f'<div class="param-value">{coolant_p:.2f} Bar</div>', unsafe_allow_html=True)
734
  st.plotly_chart(create_circular_gauge(coolant_p, 10, "Coolant P", "#00ff88", "Bar"), use_container_width=True, key="gauge_coolant_p")
 
741
 
742
  oil_t_col1, oil_t_col2 = st.columns([1, 2])
743
  with oil_t_col1:
744
+ oil_t_input = st.number_input("", 0.0, 150.0, st.session_state.oil_t_val, 1.0, label_visibility="collapsed", key="oil_temp_input")
745
  with oil_t_col2:
746
+ oil_t_slider = st.slider("", 0.0, 150.0, st.session_state.oil_t_val, 1.0, label_visibility="collapsed", key="oil_temp_slider")
747
+
748
+ if oil_t_input != st.session_state.oil_t_val:
749
+ st.session_state.oil_t_val = oil_t_input
750
+ elif oil_t_slider != st.session_state.oil_t_val:
751
+ st.session_state.oil_t_val = oil_t_slider
752
 
753
+ lub_oil_t = st.session_state.oil_t_val
 
754
 
755
  st.markdown(f'<div class="param-value">{lub_oil_t:.1f} °C</div>', unsafe_allow_html=True)
756
  st.plotly_chart(create_circular_gauge(lub_oil_t, 150, "Oil Temp", "#a855f7", "°C"), use_container_width=True, key="gauge_oil_t")
 
805
  {prob*100:.1f}% Failure Risk
806
  </div>
807
  </div>
808
+ <div style="height: 10px;"></div>
809
  """, unsafe_allow_html=True)
810
 
811
  # Status badge
 
870
  Awaiting Analysis
871
  </div>
872
  </div>
873
+ <div style="height: 10px;"></div>
874
  """, unsafe_allow_html=True)
875
 
876
  st.markdown(f"""
877
+ <div style="text-align: center; margin-top: 1rem;">
878
  <p style="font-family: 'Rajdhani', sans-serif; color: #8b95a5; font-size: 1.1rem;">
879
  Configure engine parameters above and click "ANALYZE ENGINE STATUS"
880
  </p>