File size: 1,725 Bytes
5d0388c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import streamlit as st
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import time

# Display the dashboard with metrics and visualizations
def display_dashboard(df):
    st.subheader("πŸ“Š System Summary")

    col1, col2, col3 = st.columns(3)

    col1.metric("Total Poles", df.shape[0])
    col2.metric("🚨 Red Alerts", df[df['Alert Level'] == "Red"].shape[0])
    col3.metric("⚑ Power Issues", df[df['Power Sufficient'] == "No"].shape[0])

    # Heatmap with Faults Visualization
    st.subheader("πŸ“ˆ Pole Signal Heatmap with Fault Zones")
    
    # Create random data for the heatmap (replace with your simulation data)
    data = np.random.rand(10, 10)
    fault_x, fault_y = np.random.randint(0, 10), np.random.randint(0, 10)
    
    # Show initial heatmap
    fig, ax = plt.subplots(figsize=(8, 6))
    sns.heatmap(data, annot=True, cmap="coolwarm", ax=ax)
    
    # Show a red dot if there's a fault
    ax.plot(fault_y, fault_x, 'ro', markersize=10)  # Red dot for fault location
    
    st.pyplot(fig)

# Function to simulate blinking red dot and alert
def display_fault_alert(fault_x, fault_y):
    st.error(f"Fault detected at Zone ({fault_x}, {fault_y}). Red alert triggered!")
    
    # Simulate blinking red dot effect
    for _ in range(5):
        fig, ax = plt.subplots(figsize=(8, 6))
        sns.heatmap(np.random.rand(10, 10), annot=True, cmap="coolwarm", ax=ax)  # Draw heatmap
        
        # Plot blinking red dot at fault location
        ax.plot(fault_y, fault_x, 'ro', markersize=10)
        
        # Display updated plot
        st.pyplot(fig)
        time.sleep(0.5)  # Wait for 0.5 seconds to simulate blinking
        ax.clear()  # Clear previous plot