Skip to content

Commit

Permalink
implement basic cycle logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lgactna committed Jul 21, 2020
1 parent 95a0827 commit a3a39e8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
Binary file modified src/main/python/__pycache__/streamoverlay.cpython-38.pyc
Binary file not shown.
52 changes: 47 additions & 5 deletions src/main/python/main.py
Expand Up @@ -163,7 +163,7 @@ def __init__(self, parent, ip, port):
#self.client.open(QtCore.QUrl("ws://echo.websocket.org"))
self.client.pong.connect(self.onPong)
#on a successful connection, immediately send the identification message
self.client.connected.connect(self.send_init_message)
self.client.updating.connect(self.send_init_message)

self.client.textMessageReceived.connect(self.message_received)

Expand Down Expand Up @@ -678,7 +678,7 @@ def update_data(self):
self.temperature_label.setText(global_states.queue[0]["sensor_data"][1])
self.humiditity_label.setText(global_states.queue[0]["sensor_data"][0])
if global_states.queue[0]["fitbit_data"][0] == "--":
self.body_presence_label.setText("Fitbit is not connected.")
self.body_presence_label.setText("Fitbit is not updating.")
self.bpm_label.setText(global_states.queue[0]["fitbit_data"][0])
elif global_states.queue[0]["fitbit_data"][0] == "0":
self.body_presence_label.setText("Body is not currently present on Fitbit.")
Expand Down Expand Up @@ -766,13 +766,55 @@ def __init__(self):
super().__init__()
self.ui = Ui_OverlayWindow()
self.ui.setupUi(self)
self.ui.start_updating_button.clicked.connect(self.start_anim)
self.ui.start_updating_button.clicked.connect(self.toggle_updating)
self.ui.help_button.clicked.connect(self.test_boxes)

self.updating = False
self.cycle_index = 0
#self.aboutToQuit.connect(self.quitting)
#self.ui.test_icon.setPixmap(QtGui.QPixmap('C:/Users/Kisun/Desktop/ui-new/src/main/resources/flag-test.svg'))
#self.ui.test_icon.setPixmap(QtGui.QPixmap('flag.png'))
def start_anim(self):
global_states.main_timer.timeout.connect(self.update_labels)
def closeEvent(self, event):
if self.updating:
global_states.main_timer.timeout.disconnect(self.update_labels)
logging.debug("Auto-disconnected global_states.main_timer.timeout signal on close.")
# close window
event.accept()
def toggle_updating(self):
if not self.updating:
global_states.main_timer.timeout.connect(self.update_labels)
logging.debug("animation toggle on")
self.updating = True
else:
global_states.main_timer.timeout.disconnect(self.update_labels)
logging.debug("animation toggle off")
self.updating = False
def update_labels(self):

#any additional calcs..

#figure out what data should appear on the lower-left next based on checked boxes
states = [self.ui.environmental_checkbox.isChecked(),self.ui.athelete_checkbox.isChecked(),self.ui.data_read_checkbox.isChecked(),self.ui.cumulative_position_checkbox.isChecked(),self.ui.gps_checkbox.isChecked()]
if any(states):
for i in range(1,6):
if states[(self.cycle_index+i)%5]:
self.cycle_index = (self.cycle_index+i)%5
print("cycled to index %s"%self.cycle_index)
break
else:
#what behavior should occur here?
print("all boxes unchecked")

#update everything else
self.ui.next_obstacle_label.setText(str(global_states.queue[0]["timestamp"]))
print("updated labels at%s"%math.floor(time.time()))
def test_boxes(self):
#correct athlete - athelete
states = [self.ui.environmental_checkbox.isChecked(),self.ui.athelete_checkbox.isChecked(),self.ui.data_read_checkbox.isChecked(),self.ui.cumulative_position_checkbox.isChecked(),self.ui.gps_checkbox.isChecked()]
for i in range(1,6):
if states[(self.cycle_index+i)%5]:
self.cycle_index = (self.cycle_index+i)%5
print("cycled to index %s"%self.cycle_index)

class PreferencesWindow(QtWidgets.QMainWindow,Ui_PreferencesWindow):
def __init__(self):
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/base/log.txt
Expand Up @@ -2,3 +2,23 @@
2020-07-19 16:43:03,069 - INFO - Started randomized data generation.
2020-07-19 16:43:42,339 - INFO - Started randomized data generation.
2020-07-19 16:52:39,928 - INFO - Started randomized data generation.
2020-07-21 14:53:42,958 - INFO - Started randomized data generation.
2020-07-21 15:01:12,085 - INFO - Started randomized data generation.
2020-07-21 15:13:44,517 - INFO - Started randomized data generation.
2020-07-21 15:20:48,327 - INFO - Started randomized data generation.
2020-07-21 15:21:15,252 - DEBUG - animation toggle on
2020-07-21 15:21:17,637 - INFO - Started randomized data generation.
2020-07-21 15:22:21,187 - INFO - Started randomized data generation.
2020-07-21 15:22:25,588 - DEBUG - animation toggle on
2020-07-21 15:22:30,522 - DEBUG - animation toggle on
2020-07-21 15:23:19,508 - INFO - Started randomized data generation.
2020-07-21 15:23:23,103 - DEBUG - animation toggle on
2020-07-21 15:23:31,658 - DEBUG - animation toggle off
2020-07-21 15:23:35,667 - DEBUG - animation toggle on
2020-07-21 15:23:38,937 - DEBUG - Auto-disconnected global_states.main_timer.timeout signal.
2020-07-21 15:47:37,922 - INFO - Started randomized data generation.
2020-07-21 15:47:40,160 - DEBUG - animation toggle on
2020-07-21 15:47:44,703 - DEBUG - Auto-disconnected global_states.main_timer.timeout signal on close.
2020-07-21 15:48:20,929 - INFO - Started randomized data generation.
2020-07-21 15:48:23,474 - DEBUG - animation toggle on
2020-07-21 15:48:58,649 - DEBUG - Auto-disconnected global_states.main_timer.timeout signal on close.

0 comments on commit a3a39e8

Please sign in to comment.