Implement hardware locks
This commit is contained in:
parent
a40cb9b9f6
commit
8292ebf7c7
10 changed files with 268 additions and 170 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue