summaryrefslogtreecommitdiff
path: root/dashboard_website/db.py
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2023-11-08 12:25:43 -0500
committerAnson Bridges <bridges.anson@gmail.com>2023-11-08 12:25:43 -0500
commit63d57c7f57de281934726ecdc43e27b6da99be06 (patch)
treea9690f5d69960b916259bb64a2789b810b3f1616 /dashboard_website/db.py
parent6b9d2b694821e63da8a9db47a97ce9cc6d807a4b (diff)
dashboard changes - routing in router.py
Diffstat (limited to 'dashboard_website/db.py')
-rw-r--r--dashboard_website/db.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/dashboard_website/db.py b/dashboard_website/db.py
index 450360c..a071671 100644
--- a/dashboard_website/db.py
+++ b/dashboard_website/db.py
@@ -1,9 +1,10 @@
# stores and manages clue DB
# also manages currently available bike teams
+import router
import csv, time
# time since last ping before deactivating/deleting
-BIKE_TIMEOUT = 180
+BIKE_TIMEOUT = 60
BIKE_DELETE = 1800 # time before bike deletes itself
# data structures
@@ -34,7 +35,7 @@ class Clue(Point):
self.latitude = lat
self.name = name
self.info = info
- self.status = status # UNVISITED | VISITED
+ self.status = status # UNVISITED | ASSIGNED | VISITED
def visit(self):
self.status = "VISITED"
@@ -54,6 +55,7 @@ class Bike(Point):
self.name = name
self.last_contact = time.time()
self.target = "N/A"
+ self.route_to_next = [] # list of coords if target isnt' N/A
self.status = status # ACTIVE | INACTIVE
def setTarget(self, clue_name):
@@ -66,6 +68,7 @@ class Bike(Point):
def checkStatus(self):
if time.time() - self.last_contact > BIKE_TIMEOUT:
self.status = "INACTIVE"
+ self.target = "N/A"
if time.time() - self.last_contact > BIKE_DELETE:
return -1
return 0
@@ -83,10 +86,15 @@ class Bike(Point):
homeBase = Point(42.340226, -71.088395) # krentzman, can be changed on dashboard
clues = []
bikes = []
+assigned_clues = []
clues_last_changed = time.time()
home_last_changed = time.time()
-
+# called every time a node is added
+# a bike is added/removed
+# determines/assigns clusters, and assigns routes to bikes
+def updateRoutes():
+ clusters = router.getClusters(bikes, clues, homeBase)
# interface functions
def getTime():