Spaces:
Sleeping
Sleeping
import streamlit as st | |
from modules.simulator import simulate_data | |
from modules.filters import apply_filters | |
from modules.visuals import display_dashboard, display_charts, display_map_heatmap | |
from modules.scheduler import get_latest_data | |
from datetime import datetime | |
# Set page config as the first Streamlit command | |
st.set_page_config(page_title="Vedavathi Smart Pole Monitoring", layout="wide") | |
# Inject CSS for blinking red dots with enhanced animation | |
st.markdown(""" | |
<style> | |
.blinking-red { | |
animation: pulse 1s infinite; | |
} | |
@keyframes pulse { | |
0% { opacity: 1; transform: scale(1); } | |
50% { opacity: 0.3; transform: scale(1.3); } | |
100% { opacity: 1; transform: scale(1); } | |
} | |
</style> | |
""", unsafe_allow_html=True) | |
st.title("π‘ Vedavathi Smart Pole Monitoring - PoC Simulator") | |
st.sidebar.header("π οΈ Simulation Controls") | |
num_poles = 50 # Fixed number of poles | |
st.sidebar.write(f"Number of Poles: {num_poles}") | |
simulate_faults = st.sidebar.checkbox("Simulate Random Faults", value=True) | |
# Get latest data from scheduler | |
df, last_update = get_latest_data(num_poles, simulate_faults) | |
st.write(f"Last Data Update: {last_update.strftime('%Y-%m-%d %H:%M:%S')} (Updates every 6 hours)") | |
st.sidebar.header("π Filter Data") | |
alert_filter = st.sidebar.multiselect("Alert Level", ["Green", "Yellow", "Red"], default=["Green", "Yellow", "Red"]) | |
cam_filter = st.sidebar.selectbox("Camera Status", ["All", "Online", "Offline"], index=0) | |
location_filter = st.sidebar.multiselect("Location", ["Hyderabad", "Gadwal", "Kurnool", "Bangalore"], default=["Hyderabad", "Gadwal", "Kurnool", "Bangalore"]) | |
filtered_df = apply_filters(df, alert_filter, cam_filter, location_filter) | |
# Create tabs for each location | |
tabs = st.tabs(["Hyderabad", "Gadwal", "Kurnool", "Bangalore"]) | |
locations = ["Hyderabad", "Gadwal", "Kurnool", "Bangalore"] | |
for tab, location in zip(tabs, locations): | |
with tab: | |
location_df = filtered_df[filtered_df["Location"] == location] | |
if not location_df.empty: | |
display_dashboard(location_df, location) | |
st.subheader(f"π Pole Monitoring Table - {location}") | |
st.dataframe(location_df[["PoleID", "RFID", "Timestamp", "AlertLevel", "Anomalies", "CameraStatus", "SolarGen(kWh)", "WindGen(kWh)", "Tilt(Β°)", "Vibration(g)"]], use_container_width=True) | |
st.subheader(f"πΊοΈ Alert Map - {location}") | |
display_map_heatmap(location_df, location) | |
st.subheader(f"π Energy and Sensor Charts - {location}") | |
display_charts(location_df) | |
else: | |
st.warning(f"No poles found for {location} with the current filters.") |