Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions experiment/template/eVOLVER.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class EvolverNamespace(BaseNamespace):
start_time = None
use_blank = False
OD_initial = None
start_countdown = 7

def on_connect(self, *args):
print("Connected to eVOLVER as client")
Expand All @@ -58,6 +59,10 @@ def on_broadcast(self, data):
elapsed_time = round((time.time() - self.start_time) / 3600, 4)
logger.debug('elapsed time: %.4f hours' % elapsed_time)
print("{0}: {1} Hours".format(EXP_NAME, elapsed_time))

if self.start_countdown > 0:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a ternary operator so it's a little more clean.

self.start_countdown -= 1

# are the calibrations in yet?
if not self.check_for_calibrations():
logger.warning('calibration files still missing, skipping custom '
Expand Down Expand Up @@ -97,8 +102,11 @@ def on_broadcast(self, data):
for param in temp_cal['params']:
self.save_data(data['data'].get(param, []), elapsed_time,
VIALS, param + '_raw')
# run custom functions
self.custom_functions(data, VIALS, elapsed_time)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want nothing to happen until this countdown is finished? I feel like the countdown should be used within the custom functions - this way it can be up to the logic within the function to decide how it wants to handle the restart.

if self.start_countdown <= 0:
# run custom functions
self.custom_functions(data, VIALS, elapsed_time)
else:
logger.info("Waiting for start countdown")
# save variables
self.save_variables(self.start_time, self.OD_initial)

Expand Down Expand Up @@ -611,6 +619,7 @@ def get_options():
filename=options.log_name,
level=level)

EVOLVER_NS.start_countdown = 7
reset_connection_timer = time.time()
while True:
try:
Expand Down Expand Up @@ -639,6 +648,7 @@ def get_options():
# no need to have something like "restart_chemo" here
# with the new server logic
socketIO.connect()
EVOLVER_NS.start_countdown = 7
break
except KeyboardInterrupt:
print('Second Ctrl-C detected, shutting down')
Expand Down