Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary fixes for some trigger and saving issues #29

Merged
merged 6 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion brunoise/external_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def send(self, data):
poller = zmq.Poller()
poller.register(zmq_socket, zmq.POLLIN)
duration = None
if poller.poll(1000):
if poller.poll(5000):
duration = zmq_socket.recv_json()
zmq_socket.close()

Expand Down
4 changes: 4 additions & 0 deletions brunoise/objective_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def get_position(self):
except pyvisa.VisaIOError:
print(f"Error get position axes number {self.axes} ")
return None

def send_command(self, command):
# "MO": motor on, "MF": off
self.execute_motor(self.axes + command)

def move_abs(self, coordinate):
coordinate = str(coordinate)
Expand Down
7 changes: 6 additions & 1 deletion brunoise/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self):
super().__init__()
self.name = "scanning"
self.aspect_ratio = Param(1.0, (0.2, 5.0))
self.voltage = Param(3.0, (0.2, 4.0))
self.voltage = Param(3.0, (0.2, 5.0))
self.framerate = Param(2.0, (0.1, 10.0))
self.reset_shutter = Param(False)
self.binning = Param(10, (1, 50))
Expand Down Expand Up @@ -196,6 +196,7 @@ def start_experiment(self, first_plane=True):
self.send_save_params()
self.saver.saving_signal.set()
self.experiment_start_event.set()
self.motors["z"].send_command("MF")
return True

def end_experiment(self, force=False):
Expand All @@ -204,7 +205,9 @@ def end_experiment(self, force=False):
if not force and self.save_status.i_z + 1 < self.save_status.target_params.n_z:
self.advance_plane()
else:
sleep(0.2)
self.saver.saving_signal.clear()
self.motors["z"].send_command("MO")
if self.pause_after:
self.pause_scanning()
else:
Expand All @@ -225,6 +228,7 @@ def pause_scanning(self):
self.paused = True

def advance_plane(self):
self.motors["z"].send_command("MO")
self.motors["z"].move_rel(self.experiment_settings.dz / 1000)
sleep(0.2)
self.start_experiment(first_plane=False)
Expand Down Expand Up @@ -256,6 +260,7 @@ def get_image(self):
and self.save_status.i_t + 1 == self.save_status.target_params.n_t
):
self.end_experiment()
self.save_status.i_t = -5
self.save_queue.put(images)
self.timestamp_queue.put(t)
return images
Expand Down
12 changes: 11 additions & 1 deletion brunoise/streaming_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import yagmail
from PIL import Image
import os
import time


@dataclass
Expand Down Expand Up @@ -100,7 +101,16 @@ def save_loop(self):
i_received += 1
except Empty:
pass


t_end = time.time()
while time.time() - t_end < 5:
try:
frame = self.data_queue.get(timeout=0.01)
self.fill_dataset(frame)
break
except Empty:
pass

if self.i_block > 0:
self.finalize_dataset()
if self.save_parameters.notification_email != "None":
Expand Down