Fix jwt-token
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
"""
|
||||
Realistic Drone Detection Test Script
|
||||
Simulates realistic drone scenarios with persistent tracking, RSSI changes, and real-world patterns.
|
||||
Fetches existing devices from the API and simulates drone detections around them.
|
||||
"""
|
||||
|
||||
import requests
|
||||
@@ -15,30 +16,8 @@ from datetime import datetime, timedelta
|
||||
API_BASE_URL = "http://selfservice.cqers.com/drones/api"
|
||||
# Alternative for local testing: "http://localhost:3002/api"
|
||||
|
||||
# Device configurations (simulating different detector devices)
|
||||
DEVICES = [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Arlanda Airport Detector",
|
||||
"lat": 59.6519,
|
||||
"lon": 17.9186,
|
||||
"coverage_radius": 8.0 # km
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Musk Naval Base Detector",
|
||||
"lat": 59.2753,
|
||||
"lon": 18.2649,
|
||||
"coverage_radius": 6.0 # km
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Royal Castle Detector",
|
||||
"lat": 59.3268,
|
||||
"lon": 18.0717,
|
||||
"coverage_radius": 4.0 # km
|
||||
}
|
||||
]
|
||||
# Global variable to store devices fetched from API
|
||||
DEVICES = []
|
||||
|
||||
# Realistic drone types with characteristics
|
||||
DRONE_TYPES = {
|
||||
@@ -49,6 +28,37 @@ DRONE_TYPES = {
|
||||
5: {"name": "Surveillance", "max_speed": 40, "typical_rssi": -75, "freq": [2400, 5800]}
|
||||
}
|
||||
|
||||
def fetch_devices():
|
||||
"""Fetch active devices from the API"""
|
||||
global DEVICES
|
||||
try:
|
||||
response = requests.get(f"{API_BASE_URL}/devices/map")
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
api_devices = data.get('data', [])
|
||||
|
||||
# Convert API device format to simulator format
|
||||
DEVICES = []
|
||||
for device in api_devices:
|
||||
DEVICES.append({
|
||||
"id": device["id"],
|
||||
"name": device["name"],
|
||||
"lat": float(device["geo_lat"]),
|
||||
"lon": float(device["geo_lon"]),
|
||||
"coverage_radius": 5.0 # Default 5km coverage radius
|
||||
})
|
||||
|
||||
print(f"✅ Fetched {len(DEVICES)} active devices from API")
|
||||
for device in DEVICES:
|
||||
print(f" - {device['name']} at ({device['lat']:.4f}, {device['lon']:.4f})")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to fetch devices: {response.status_code}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"❌ Error fetching devices: {e}")
|
||||
return False
|
||||
|
||||
class DroneSimulator:
|
||||
def __init__(self):
|
||||
self.active_drones = {} # Track persistent drones
|
||||
@@ -346,6 +356,16 @@ def main():
|
||||
print("🚁 Realistic Drone Detection Simulator")
|
||||
print("=" * 50)
|
||||
|
||||
# Fetch devices from API first
|
||||
print("📡 Fetching active devices from API...")
|
||||
if not fetch_devices():
|
||||
print("❌ Cannot fetch devices from API. Please check if the system is running.")
|
||||
return
|
||||
|
||||
if len(DEVICES) == 0:
|
||||
print("❌ No active devices found. Please add some detector devices first.")
|
||||
return
|
||||
|
||||
# Test API connectivity
|
||||
if not test_api_health():
|
||||
print("Cannot connect to API. Please check if the system is running.")
|
||||
|
||||
Reference in New Issue
Block a user