Browse Source

Code cleaning

master
Carlos Reding 1 year ago
parent
commit
a02d8d4876
3 changed files with 12 additions and 12 deletions
  1. 9
    8
      puppeteer/__init__.py
  2. 0
    1
      puppeteer/_core.py
  3. 3
    3
      pupuicon/_corelib.py

+ 9
- 8
puppeteer/__init__.py View File

@@ -53,7 +53,7 @@ def Controller(USR_INSTRUCTIONS, Connection, cancel_switch, ConnectionStatus,
Protocol = SetProtocol(with_device=Box, filters=user_filters,
and_wavelenghts=USR_INSTRUCTIONS.user_wavelengths,
well_number=96, protocol_name='default_protocol')
BoxQueue.put([Protocol, USR_INSTRUCTIONS.QueueFile]) # Export `Protocol' before Run begins.
BoxQueue.put([Box, Protocol, USR_INSTRUCTIONS.QueueFile]) # Export `Protocol' before Run begins.
# Run Protocol. `Connection' is no longer a dependency of this method as
# the log messages produced interfere with the GUI during a protocol run.
Protocol.Run(assay_length=USR_INSTRUCTIONS.length,
@@ -172,19 +172,20 @@ def ExportData(Protocol, ProcessData, QueueFile, Connection, Status,
# House keeping. Always. Test or not.
house_keeper(Protocol._dir_info, QueueFile, Connection, BUFFER_SIZE)

def CancelProtocol():
def CancelProtocol(with_device=None, Connection=None, ConnectionStatus=None):
"""
Cancels a running protocol with IMMEDIATE effect. The use of flags with
multithreading cannot cancel a running protocol until the next iteration
be it within a minute or an hour. `CancelProtocol' soft-restarts the
light modulator and, therefore, protocols are cancelled immediately.
"""
# Stop hardware
# Protocol._device._camera.close()
# Protocol._device._heater.stop()
# Protocol._device._servo.stop()
# Protocol._device._light_panel.stop()
# Restart it all...
Box = with_device
# Stop hardware. Fixes heating being left on. Note that Connection and
# ConnectionStatus are set to `None', meaning no logs will be reported back
# to the GUI.
if Box is not None:
Box.terminate_device(Connection, ConnectionStatus)
# Restart server (workaround, as python won't recognise BASH functions).
LiMO_Path = "/home/client/.srv/"
Routine=".cancel_protocol.sh"
subprocess.call(["bash", "-c", LiMO_Path + Routine])

+ 0
- 1
puppeteer/_core.py View File

@@ -855,7 +855,6 @@ class SetProtocol:
servo_state = self._device.set_filter(flt, current_pwm=servo_state)
# self._data_acquisition(light_range, current_time, flt,
# wavelength, singleRead)
print("Time between reads: " + str(round(t.time() - warmup_init_t, 3)) + "s.")
self._data_acquisition_triplicate(light_range, current_time, flt,
wavelength, singleRead)
if flt == "Filter_2":

+ 3
- 3
pupuicon/_corelib.py View File

@@ -153,17 +153,17 @@ class NetworkOperator():
This snippet handles short packages (<BUFFER_SIZE) to allow the
handshake between server and client.
"""
return Stream
return Stream
else:
"""
This other snippet handles larger packages (>=BUFFER_SIZE) to
allow the transmission of actual data, like, say, a protocol.
"""
while Stream:
while Stream:
Buffer = Connection.recv(BUFFER_SIZE)
Stream += Buffer
if len(Buffer) < BUFFER_SIZE : break
return Stream
return Stream

def _retrieve_protocol(self, ProtocolSize, Connection, BUFFER_SIZE):
"""

Loading…
Cancel
Save