-
Notifications
You must be signed in to change notification settings - Fork 11
/
BeamInfoMockup.py
133 lines (107 loc) · 4.36 KB
/
BeamInfoMockup.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""
[Name] BeamInfo
[Description]
BeamInfo hardware object is used to define final beam size and shape.
It can include aperture, slits and/or other beam definer (lenses or other eq.)
[Emited signals]
beamInfoChanged
[Included Hardware Objects]
-----------------------------------------------------------------------
| name | signals | functions
-----------------------------------------------------------------------
aperture_hwobj apertureChanged
slits_hwobj
beam_definer_hwobj
-----------------------------------------------------------------------
"""
import logging
from HardwareRepository.BaseHardwareObjects import Equipment
class BeamInfoMockup(Equipment):
def __init__(self, *args):
Equipment.__init__(self, *args)
self.beam_size_slits = [9999, 9999]
self.beam_size_aperture = [9999, 9999]
self.beam_size_definer = [9999, 9999]
self.beam_position = [300, 300]
self.beam_info_dict = {}
def init(self):
self.aperture_hwobj = self.getObjectByRole("aperture")
if self.aperture_hwobj is not None:
self.connect(self.aperture_hwobj,
"diameterIndexChanged",
self.aperture_diameter_changed)
self.slits_hwobj = self.getObjectByRole("slits")
if self.slits_hwobj is not None:
self.connect(self.slits_hwobj,
"gapSizeChanged",
self.slits_gap_changed)
self.emit("beamPosChanged", (self.beam_position, ))
def aperture_diameter_changed(self, name, size):
self.beam_size_aperture = [size, size]
self.aperture_pos_name = name
self.evaluate_beam_info()
self.emit_beam_info_change()
def slits_gap_changed(self, size):
self.beam_size_slits = size
self.evaluate_beam_info()
self.emit_beam_info_change()
def get_beam_position(self):
return self.beam_position
def set_beam_position(self, beam_x, beam_y):
self.beam_position = [beam_x, beam_y]
self.emit("beamPosChanged", (self.beam_position, ))
def get_beam_info(self):
return self.evaluate_beam_info()
def get_beam_size(self):
"""
Description: returns beam size in microns
Returns: list with two integers
"""
self.evaluate_beam_info()
return float(self.beam_info_dict["size_x"]), \
float(self.beam_info_dict["size_y"])
def get_beam_shape(self):
self.evaluate_beam_info()
return self.beam_info_dict["shape"]
def get_slits_gap(self):
self.evaluate_beam_info()
return self.beam_size_slits
def set_slits_gap(self, width_microns, height_microns):
if self.slits_hwobj:
self.slits_hwobj.set_gap("Hor", width_microns / 1000.0)
self.slits_hwobj.set_gap("Ver", height_microns / 1000.0)
def evaluate_beam_info(self):
"""
Description: called if aperture, slits or focusing has been changed
Returns: dictionary, {size_x: 0.1, size_y: 0.1, shape: "rectangular"}
"""
size_x = min(self.beam_size_aperture[0],
self.beam_size_slits[0],
self.beam_size_definer[0])
size_y = min(self.beam_size_aperture[1],
self.beam_size_slits[1],
self.beam_size_definer[1])
self.beam_info_dict["size_x"] = size_x
self.beam_info_dict["size_y"] = size_y
if tuple(self.beam_size_aperture) < tuple(self.beam_size_slits):
self.beam_info_dict["shape"] = "ellipse"
else:
self.beam_info_dict["shape"] = "rectangular"
return self.beam_info_dict
def emit_beam_info_change(self):
if self.beam_info_dict["size_x"] != 9999 and \
self.beam_info_dict["size_y"] != 9999:
self.emit("beamSizeChanged", ((self.beam_info_dict["size_x"],\
self.beam_info_dict["size_y"]), ))
self.emit("beamInfoChanged", (self.beam_info_dict, ))
def get_beam_divergence_hor(self):
return 0
def get_beam_divergence_ver(self):
return 0
def get_aperture_pos_name(self):
if self.aperture_hwobj:
return self.aperture_hwobj.get_current_pos_name()
def get_focus_mode(self):
return
def get_shape(self):
return self.beam_info_dict["shape"]