Spaces:
Sleeping
Sleeping
Update modules/simulator.py
Browse files- modules/simulator.py +11 -5
modules/simulator.py
CHANGED
|
@@ -6,7 +6,7 @@ def simulate_data(n=10, faults=True):
|
|
| 6 |
today = datetime.date.today()
|
| 7 |
poles = [f"Pole_{i+1:03}" for i in range(n)]
|
| 8 |
|
| 9 |
-
#
|
| 10 |
sites = {
|
| 11 |
"Hyderabad": (17.3850, 78.4867),
|
| 12 |
"Gadwal": (16.2356, 77.7956),
|
|
@@ -39,11 +39,15 @@ def simulate_data(n=10, faults=True):
|
|
| 39 |
if cam == "Offline": anomaly.append("Camera Offline")
|
| 40 |
if sufficient == "No": anomaly.append("Power Insufficient")
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
alert = "Yellow"
|
| 45 |
-
|
|
|
|
| 46 |
alert = "Red"
|
|
|
|
| 47 |
|
| 48 |
data.append({
|
| 49 |
"Pole ID": pole,
|
|
@@ -59,8 +63,10 @@ def simulate_data(n=10, faults=True):
|
|
| 59 |
"Tilt (°)": tilt,
|
| 60 |
"Vibration (g)": vib,
|
| 61 |
"Anomalies": "; ".join(anomaly) if anomaly else "None",
|
| 62 |
-
"Alert Level": alert
|
|
|
|
| 63 |
})
|
| 64 |
|
| 65 |
return pd.DataFrame(data)
|
| 66 |
|
|
|
|
|
|
| 6 |
today = datetime.date.today()
|
| 7 |
poles = [f"Pole_{i+1:03}" for i in range(n)]
|
| 8 |
|
| 9 |
+
# Coordinates for sites
|
| 10 |
sites = {
|
| 11 |
"Hyderabad": (17.3850, 78.4867),
|
| 12 |
"Gadwal": (16.2356, 77.7956),
|
|
|
|
| 39 |
if cam == "Offline": anomaly.append("Camera Offline")
|
| 40 |
if sufficient == "No": anomaly.append("Power Insufficient")
|
| 41 |
|
| 42 |
+
if len(anomaly) == 0:
|
| 43 |
+
alert = "Green"
|
| 44 |
+
alert_weight = 1
|
| 45 |
+
elif len(anomaly) == 1:
|
| 46 |
alert = "Yellow"
|
| 47 |
+
alert_weight = 2
|
| 48 |
+
else:
|
| 49 |
alert = "Red"
|
| 50 |
+
alert_weight = 3
|
| 51 |
|
| 52 |
data.append({
|
| 53 |
"Pole ID": pole,
|
|
|
|
| 63 |
"Tilt (°)": tilt,
|
| 64 |
"Vibration (g)": vib,
|
| 65 |
"Anomalies": "; ".join(anomaly) if anomaly else "None",
|
| 66 |
+
"Alert Level": alert,
|
| 67 |
+
"Alert Weight": alert_weight
|
| 68 |
})
|
| 69 |
|
| 70 |
return pd.DataFrame(data)
|
| 71 |
|
| 72 |
+
|