from lume_epics.client.controller import Controller
from lume_model.utils import load_variables
from lume_epics.client.widgets.plots import ImagePlot
from lume_epics.client.widgets.controls import build_sliders
from lume_epics.client.controller import Controller
from bokeh.io import output_notebook, show
from bokeh import palettes
from bokeh.layouts import column, row
from bokeh.models import LinearColorMapper
prefix = "test"
variable_filename = "files/simple_demo_variables.pickle"
# load bokeh
output_notebook()
# load variables
input_variables, output_variables = load_variables(variable_filename)
# use all input variables for slider
# prepare as list for rendering
input_variables = list(input_variables.values())
# select our image output variable to render
output_variables = [output_variables["output1"]]
# build sliders for the command process variable database
controller = Controller("ca") # can also use channel access
sliders = build_sliders(input_variables, controller, prefix)
# create image plot
image_plot = ImagePlot(output_variables, controller, prefix)
pal = palettes.viridis(256)
color_mapper = LinearColorMapper(palette=pal, low=0, high=256)
image_plot.build_plot(color_mapper=color_mapper)
# Set up image update callback
def image_update_callback():
image_plot.update()
# function for rendering the application in the bokeh server
def render_app(doc):
doc.title = "Demo App"
doc.add_root(
column(
row(column([slider.bokeh_slider for slider in sliders], width=200), column(image_plot.plot, width=150, height=150))
)
)
doc.add_periodic_callback(image_update_callback, 250)
# add callbacks to update slider values
for slider in sliders:
doc.add_periodic_callback(slider.update, 250)
show(render_app)