Implement hardware locks

This commit is contained in:
Joel Collins 2019-01-24 12:11:01 +00:00
parent a40cb9b9f6
commit 8292ebf7c7
10 changed files with 268 additions and 170 deletions

View file

@ -67,6 +67,7 @@ class LongRunningAPI(MicroscopeViewPlugin):
# Extract a values from the JSON payload.
time_to_run = payload.param('time', default=10, convert=int)
# Attach the long-running method as a microscope task
try:
task = self.microscope.task.start(self.plugin.long_running, time_to_run)
return jsonify(task.state), 202

View file

@ -39,10 +39,12 @@ class Plugin(MicroscopePlugin):
print("Starting a long-running task...")
n_array = []
for _ in range(t_run):
n_array.append(random.random())
time.sleep(1)
print("Acquiring camera lock...")
with self.microscope.camera.lock:
for _ in range(t_run):
n_array.append(random.random())
time.sleep(1)
print("Long-running task finished!")
print("Long-running task finished! Releasing lock.")
return n_array