summaryrefslogtreecommitdiff
path: root/dashboard_website/db.py
diff options
context:
space:
mode:
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():