Added a long running task to schema example
This commit is contained in:
parent
54dcee0083
commit
e91e58daa3
3 changed files with 47 additions and 19 deletions
|
|
@ -4,7 +4,7 @@ import os
|
|||
import json
|
||||
from openflexure_microscope.plugins import MicroscopePlugin
|
||||
|
||||
from .api import DoAPI
|
||||
from .api import DoAPI, TaskAPI
|
||||
|
||||
HERE = os.path.dirname(os.path.realpath(__file__))
|
||||
SCHEMA_PATH = os.path.join(HERE, "schema.json")
|
||||
|
|
@ -20,6 +20,7 @@ class ExamplePlugin(MicroscopePlugin):
|
|||
|
||||
api_views = {
|
||||
'/do': DoAPI,
|
||||
'/task': TaskAPI
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -30,6 +31,8 @@ class ExamplePlugin(MicroscopePlugin):
|
|||
self.val_select = "Most"
|
||||
self.val_unused = "I'm an unused string, here to confuse the form parsing"
|
||||
|
||||
self.run_time = 5
|
||||
|
||||
def set_values(self, val_int, val_str, val_radio, val_check, val_select, val_disposable):
|
||||
"""
|
||||
Demonstrate a plugin with schema
|
||||
|
|
@ -57,4 +60,13 @@ class ExamplePlugin(MicroscopePlugin):
|
|||
'val_check': self.val_check,
|
||||
'val_select': self.val_select,
|
||||
'val_unused': self.val_unused
|
||||
}
|
||||
}
|
||||
|
||||
def generate_random_numbers_for_a_while(self, run_time: int):
|
||||
self.run_time = run_time
|
||||
vals = []
|
||||
for _ in range(run_time):
|
||||
vals.append(random.random())
|
||||
time.sleep(1)
|
||||
|
||||
return vals
|
||||
Loading…
Add table
Add a link
Reference in a new issue