Browse Source

Code clean

master
Carlos Reding 1 year ago
parent
commit
b5e5dd6738
1 changed files with 7 additions and 24 deletions
  1. 7
    24
      srv_controller.py

+ 7
- 24
srv_controller.py View File

@@ -2,8 +2,7 @@

import threading, sys, time, queue
from puppeteer import Controller, HardwareTest, TemperatureTest,\
ProtocolTest, ExportData, QueueStatus, CancelProtocol,\
CameraRepetitions
ProtocolTest, ExportData, QueueStatus, CancelProtocol
from pupuicon import InitNetwork, NetworkOperator

# Hack
@@ -11,15 +10,13 @@ from pupuicon import InitNetwork, NetworkOperator
sys.modules['translator'] = sys.modules['pupuicon.translator']
del sys.modules['pupuicon.translator']

# Create `cancel' and `gui' switches. Default to FALSE.
# Create `cancel', `gui', and `protocol_status` switches. Default to FALSE.
cancel_switch = threading.Event()
gui_status = threading.Event()
protocol_status = threading.Event()
# Check for presence of queueFile after restarting LiMO, set `protocol_status'
# accordingly:

Replicates, LagReplicates = CameraRepetitions()

# This will forever try to re-start server in case of error.
while True:
try:
print("GUI status is: " + str(gui_status.is_set()))
@@ -69,7 +66,7 @@ while True:
except AttributeError:
# __module__ attribute does not exist, therefore
# GUI.command does not contain a protocol.
# GUI.command does not contain protocol/grab information.
print("User says: " + GUI.command + ".")
if GUI.command == "Close Connection":
Box_Socket.Socket.close()
@@ -89,10 +86,10 @@ while True:
elif GUI.command == "Abort Protocol":
# Turn hardware OFF before cancelling!! otherwise things
# like HEATER can be left ON.
Box._stop()
Box.join()
print("Cancel Protocol.")
if 'LiMO' in locals():
Box._stop()
Box.join()
CancelProtocol(with_device=LiMO)
else:
# This steps allows to restart LiMO without anything running.
@@ -113,7 +110,7 @@ while True:
# GUI _always_ expects something coming back.
# By returning a message, the interface won't stall.
Box_Socket.Connection.sendall(str("::IDLE::").encode())
except (ConnectionResetError, BrokenPipeError, OSError) as err: # This will forever (unsuccessfully) try to start server
except (ConnectionResetError, BrokenPipeError, OSError) as err:
Box_Socket.Socket.close()
print("GUI status was: " + str(gui_status.is_set()))
gui_status.clear() # GUI status -> FALSE, disconnect user.
@@ -121,17 +118,3 @@ while True:
print(err)
print("\nRestarting server.")

"""
TODO:
- Implement logs to deal with potential problems reported by users. [DONE]
- Export data when process_data=False (send over network) [TODO: issues with threading...] [DONE]
- Retrieve Queue and initiate protocol automatically if LiMO's power breaks. [DONE]
MISSING FIELDS in LIF file:
- panel_type (guess from 'nmwavelengthsOfFiltersInstalled'?)
- device calibration
- number of wells
- well calibration
- protocol name (guess from 'readsDirectory'?) [NOT NEEDED]
- notes [NOT NEEDED]
- export metadata [DONE/ NOT NEEDED]
"""

Loading…
Cancel
Save