-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from jacquelinegarrahan/doc-cleanup
Create prod example and fix controller pvaccess bug
- Loading branch information
Showing
6 changed files
with
169 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from bokeh.io import curdoc | ||
from bokeh import palettes | ||
from bokeh.layouts import column, row | ||
from bokeh.models import LinearColorMapper, Div | ||
|
||
from lume_epics.client.controller import Controller | ||
from lume_model.utils import variables_from_yaml | ||
from lume_epics.utils import config_from_yaml | ||
|
||
from lume_epics.client.widgets.plots import ImagePlot, Striptool | ||
from lume_epics.client.widgets.tables import ValueTable | ||
from lume_epics.client.widgets.controls import build_sliders, EntryTable | ||
from lume_epics.client.controller import Controller | ||
from pathlib import Path | ||
|
||
variable_path = Path(__file__).parent / "variables.yml" | ||
|
||
with variable_path.open() as f: | ||
input_variables, output_variables = variables_from_yaml(f) | ||
|
||
# load epics configuration | ||
epics_path = Path(__file__).parent / "epics_config.yml" | ||
|
||
with epics_path.open() as f: | ||
epics_config = config_from_yaml(f) | ||
|
||
# create controller from epics config | ||
controller = Controller(epics_config) | ||
|
||
# prepare as list for rendering | ||
input_variables = list(input_variables.values()) | ||
output_variables = list(output_variables.values()) | ||
|
||
input_value_table = ValueTable(input_variables, controller) | ||
output_value_table = ValueTable(output_variables, controller) | ||
|
||
title_div = Div( | ||
text=f"<b>LCLS ampl sum: Last update {controller.last_update}</b>", | ||
style={ | ||
"font-size": "150%", | ||
"color": "#3881e8", | ||
"text-align": "center", | ||
"width": "100%", | ||
}, | ||
) | ||
|
||
|
||
def update_div_text(): | ||
global controller | ||
title_div.text = f"<b>LCLS ampl sum: Last update {controller.last_update}</b>" | ||
|
||
|
||
# render | ||
curdoc().title = "LCLS ampl" | ||
curdoc().add_root( | ||
column( | ||
row(column(title_div)), | ||
row(input_value_table.table, output_value_table.table), | ||
) | ||
) | ||
|
||
# must add refresh callbacks | ||
curdoc().add_periodic_callback(input_value_table.update, 250) | ||
curdoc().add_periodic_callback(output_value_table.update, 250) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
input_variables: | ||
klys_li24_11: | ||
pvname: KLYS:LI24:11:AMPL | ||
protocol: ca | ||
serve: false | ||
|
||
klys_li24_21: | ||
pvname: KLYS:LI24:21:AMPL | ||
protocol: ca | ||
serve: false | ||
|
||
klys_li24_31: | ||
pvname: KLYS:LI24:31:AMPL | ||
protocol: ca | ||
serve: false | ||
|
||
klys_li24_41: | ||
pvname: KLYS:LI24:41:AMPL | ||
protocol: ca | ||
serve: false | ||
|
||
klys_li24_51: | ||
pvname: KLYS:LI24:51:AMPL | ||
protocol: ca | ||
serve: false | ||
|
||
output_variables: | ||
summation: | ||
pvname: sample:summation | ||
protocol: pva |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import numpy as np | ||
from lume_model.models import BaseModel | ||
from lume_model.utils import variables_from_yaml | ||
from lume_epics.utils import config_from_yaml | ||
from lume_epics.epics_server import Server | ||
from pathlib import Path | ||
|
||
|
||
class AmplSummationModel(BaseModel): | ||
def __init__(self): | ||
|
||
variable_path = Path(__file__).parent / "variables.yml" | ||
|
||
with variable_path.open() as f: | ||
input_variables, output_variables = variables_from_yaml(f) | ||
|
||
self.input_variables = input_variables | ||
self.output_variables = output_variables | ||
|
||
def evaluate(self, input_variables): | ||
|
||
summation = sum([var.value for var in input_variables.values()]) | ||
self.output_variables["summation"].value = summation | ||
|
||
return self.output_variables | ||
|
||
|
||
if __name__ == "__main__": | ||
# load epics configuration | ||
epics_path = Path(__file__).parent / "epics_config.yml" | ||
|
||
with epics_path.open() as f: | ||
epics_config = config_from_yaml(f) | ||
|
||
server = Server( | ||
AmplSummationModel, | ||
epics_config, | ||
) | ||
# monitor = False does not loop in main thread | ||
server.start(monitor=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
input_variables: | ||
klys_li24_11: | ||
type: scalar | ||
default: 1 # will be dropped in later lume-epics iter | ||
range: [0, 100] # will be dropped in later lume-epics iter | ||
|
||
klys_li24_21: | ||
type: scalar | ||
default: 1 # will be dropped in later lume-epics iter | ||
range: [0, 100] # will be dropped in later lume-epics iter | ||
|
||
klys_li24_31: | ||
type: scalar | ||
default: 1 # will be dropped in later lume-epics iter | ||
range: [0, 100] # will be dropped in later lume-epics iter | ||
|
||
klys_li24_41: | ||
type: scalar | ||
default: 1 # will be dropped in later lume-epics iter | ||
range: [0, 100] # will be dropped in later lume-epics iter | ||
|
||
klys_li24_51: | ||
type: scalar | ||
default: 1 # will be dropped in later lume-epics iter | ||
range: [0, 100] # will be dropped in later lume-epics iter | ||
|
||
output_variables: | ||
summation: | ||
type: scalar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters