-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlapfinder.py
69 lines (55 loc) · 2.23 KB
/
overlapfinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from small_lab_gui.helper import bokeh_gui_helper as bgh
from small_lab_gui.helper import bokeh_plot_helper as bph
from small_lab_gui.axes.linear_axis_remote import linear_axis_controller_remote
from small_lab_gui.axes.linear_axis_remote import linear_axis_remote
import bokeh
import bokeh.layouts
import bokeh.plotting
class overlap_gui():
def __init__(self, doc, delayer):
self.running = bgh.running()
self.title = 'Overlap Finder'
# measurement thread
self.cont_readout = None
# bokeh doc for callback
self.doc = doc
# delay piezo
self.delayer = delayer
self.offset_slider = bokeh.models.widgets.Slider(
start=0, end=250, value=0, step=1., title="Piezo Position")
# arrange layout
self.inputs = bokeh.layouts.widgetbox(self.offset_slider)
self.layout = bokeh.layouts.row(self.inputs)
# callback
self.offset_slider.on_change('value', self.move_piezo)
def move_piezo(self, attr, old_val, new_val):
# in case this measurement is running, do nothing
if self.running.am_i_running(self):
pass
# in case a different measurement is running, do nothing
elif self.running.is_running():
pass
# otherwise request piezo move
else:
self.running.now_running(self)
self.delayer.abs_move(new_val)
self.running.now_stopped()
def close(self):
pass
class tof_session_handler(bgh.bokeh_gui_session_handler):
def open_session(self, doc):
# connect to movement server piezo axis
movement_server = linear_axis_controller_remote()
piezo = linear_axis_remote(movement_server, 'experimental_target_x')
# alignment tab
overlapgui = overlap_gui(doc=doc, delayer=piezo)
self.title = 'Overlapfinder'
self.tabs = [
{'layout': overlapgui.layout, 'title': overlapgui.title}]
# this list is auto-closed, all close functions of the added objects
# are called at session destruction
self.close_list.append(overlapgui)
self.close_list.append(piezo)
print('start overlapfinder')
# start the server
bgh.bokeh_gui_helper(tof_session_handler(), 5026)