DSatishchandra commited on
Commit
a5e4641
Β·
verified Β·
1 Parent(s): e0b4591

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -46
app.py CHANGED
@@ -1,59 +1,40 @@
1
  import streamlit as st
 
 
2
  from modules.simulator import simulate_data
3
  from modules.filters import apply_filters
4
- from modules.visuals import display_dashboard, display_charts, display_map_heatmap
5
- from modules.scheduler import get_latest_data
6
- from datetime import datetime
7
 
8
- # Set page config as the first Streamlit command
9
  st.set_page_config(page_title="Vedavathi Smart Pole Monitoring", layout="wide")
 
10
 
11
- # Inject CSS for blinking red dots with enhanced animation
12
- st.markdown("""
13
- <style>
14
- .blinking-red {
15
- animation: pulse 1s infinite;
16
- }
17
- @keyframes pulse {
18
- 0% { opacity: 1; transform: scale(1); }
19
- 50% { opacity: 0.3; transform: scale(1.3); }
20
- 100% { opacity: 1; transform: scale(1); }
21
- }
22
- </style>
23
- """, unsafe_allow_html=True)
24
-
25
- st.title("πŸ“‘ Vedavathi Smart Pole Monitoring - PoC Simulator")
26
-
27
  st.sidebar.header("πŸ› οΈ Simulation Controls")
28
- num_poles = 50 # Fixed number of poles
29
- st.sidebar.write(f"Number of Poles: {num_poles}")
30
  simulate_faults = st.sidebar.checkbox("Simulate Random Faults", value=True)
31
 
32
- # Get latest data from scheduler
33
- df, last_update = get_latest_data(num_poles, simulate_faults)
34
- st.write(f"Last Data Update: {last_update.strftime('%Y-%m-%d %H:%M:%S')} (Updates every 6 hours)")
35
 
 
36
  st.sidebar.header("πŸ“‚ Filter Data")
37
  alert_filter = st.sidebar.multiselect("Alert Level", ["Green", "Yellow", "Red"], default=["Green", "Yellow", "Red"])
38
  cam_filter = st.sidebar.selectbox("Camera Status", ["All", "Online", "Offline"], index=0)
39
- location_filter = st.sidebar.multiselect("Location", ["Hyderabad", "Gadwal", "Kurnool", "Ballari"], default=["Hyderabad", "Gadwal", "Kurnool", "Ballari"])
40
-
41
- filtered_df = apply_filters(df, alert_filter, cam_filter, location_filter)
42
-
43
- # Create tabs for each location
44
- tabs = st.tabs(["Hyderabad", "Gadwal", "Kurnool", "Ballari"])
45
- locations = ["Hyderabad", "Gadwal", "Kurnool", "Ballari"]
46
-
47
- for tab, location in zip(tabs, locations):
48
- with tab:
49
- location_df = filtered_df[filtered_df["Location"] == location]
50
- if not location_df.empty:
51
- display_dashboard(location_df, location)
52
- st.subheader(f"πŸ“‹ Pole Monitoring Table - {location}")
53
- st.dataframe(location_df[["PoleID", "RFID", "Timestamp", "AlertLevel", "Anomalies", "CameraStatus", "SolarGen(kWh)", "WindGen(kWh)", "Tilt(Β°)", "Vibration(g)"]], use_container_width=True)
54
- st.subheader(f"πŸ—ΊοΈ Alert Map - {location}")
55
- display_map_heatmap(location_df, location)
56
- st.subheader(f"πŸ“Š Energy and Sensor Charts - {location}")
57
- display_charts(location_df)
58
- else:
59
- st.warning(f"No poles found for {location} with the current filters.")
 
1
  import streamlit as st
2
+ import folium
3
+ from folium.plugins import HeatMap
4
  from modules.simulator import simulate_data
5
  from modules.filters import apply_filters
6
+ from modules.visuals import display_dashboard, display_charts, display_heatmap
 
 
7
 
8
+ # Set the page configuration
9
  st.set_page_config(page_title="Vedavathi Smart Pole Monitoring", layout="wide")
10
+ st.title("πŸ“‘ Vedavathi Smart Pole Monitoring - Heatmap Dashboard")
11
 
12
+ # Sidebar - Controls for simulation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  st.sidebar.header("πŸ› οΈ Simulation Controls")
14
+ num_poles = st.sidebar.slider("Number of Poles", min_value=5, max_value=50, value=10)
 
15
  simulate_faults = st.sidebar.checkbox("Simulate Random Faults", value=True)
16
 
17
+ # Simulate data
18
+ df = simulate_data(num_poles, simulate_faults)
 
19
 
20
+ # Sidebar - Filters for the data
21
  st.sidebar.header("πŸ“‚ Filter Data")
22
  alert_filter = st.sidebar.multiselect("Alert Level", ["Green", "Yellow", "Red"], default=["Green", "Yellow", "Red"])
23
  cam_filter = st.sidebar.selectbox("Camera Status", ["All", "Online", "Offline"], index=0)
24
+
25
+ # Apply filters on the simulated data
26
+ filtered_df = apply_filters(df, alert_filter, cam_filter)
27
+
28
+ # Display Dashboard Metrics
29
+ display_dashboard(df)
30
+
31
+ # Display the Heatmap
32
+ st.subheader("πŸ“ Pole Locations Heatmap")
33
+ display_heatmap(filtered_df)
34
+
35
+ # Display Pole Monitoring Table
36
+ st.subheader("πŸ“‹ Pole Monitoring Table")
37
+ st.dataframe(filtered_df, use_container_width=True)
38
+
39
+ # Display charts for data
40
+ display_charts(df)