Skip to content

Commit

Permalink
Fixed Alerts to display once. Moved timestamp.
Browse files Browse the repository at this point in the history
Alerts should only display once now since it uses status flags rather
than a distance "window". Timestamp logic was moved to the Alerts class.
  • Loading branch information
jtchia99 committed Jul 7, 2013
1 parent 07e49dc commit ffce221
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion display/gui/tkinter_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ def update(self):
self.clear()

def displayAlert(self, alert_text):
self.label_text.set(alert_text)
ts = datetime.datetime.now().strftime("%H:%M:%S ")
self.label_text.set(ts + alert_text)
self.expire_time = (datetime.datetime.now() +
datetime.timedelta(seconds=ALERT_DURATION))

Expand Down
22 changes: 14 additions & 8 deletions display/tactical/tactical.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@ def update(self):
self.displayTarget(target)

# Display alerts
# TODO Cleanup
# TODO Change timestamp to only show time of entering/exiting
if distance((0, 0), target.pos) >= 10 and distance((0, 0), target.pos) < 10.3:
ts = datetime.now().strftime("%H:%M:%S")
self.data_proc.tca.ui.displayAlert(ts + " Target has left the Alert zone")
elif distance((0, 0), target.pos) >= 5 and distance((0, 0), target.pos) < 5.3:
ts = datetime.now().strftime("%H:%M:%S")
self.data_proc.tca.ui.displayAlert(ts + " Target entered the Alert zone")
# TODO Cleanup logic
if distance((0, 0), target.pos) < 5:
target.left_safe = False
elif distance((0, 0), target.pos) < 10:
target.left_alert = False

if distance((0, 0), target.pos) >= 10 and target.left_alert == False:
self.data_proc.tca.ui.displayAlert("Target has left the Alert zone")
target.left_alert = True
target.left_safe = True
elif distance((0, 0), target.pos) >= 5 and target.left_safe == False:
self.data_proc.tca.ui.displayAlert("Target entered the Alert zone")
target.left_alert = False
target.left_safe = True

def updateCalibration(self, message):
if message == 1:
Expand Down
2 changes: 2 additions & 0 deletions processors/data/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def __init__(self, pos):
self.first_turn = False
self.second_turn = False
self.max_velocity = None
self.left_safe = None
self.left_alert = None

def update(self, pos):
# TODO Reimplement
Expand Down

0 comments on commit ffce221

Please sign in to comment.