forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MinidiffAperture.py
42 lines (31 loc) · 1.43 KB
/
MinidiffAperture.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
from HardwareRepository.HardwareObjects import MultiplePositions
import logging
class MinidiffAperture(MultiplePositions.MultiplePositions):
def __init__(self, *args, **kwargs):
MultiplePositions.MultiplePositions.__init__(self, *args, **kwargs)
def getApertureCoef(self):
current_pos = self.getPosition()
for position in self["positions"]:
if position.getProperty("name") == current_pos:
aperture_coef = position.getProperty("aperture_coef")
return aperture_coef
return 1
def getApertureSize(self):
current_pos = self.getPosition()
for position in self["positions"]:
if position.getProperty("name") == current_pos:
aperture_size = float(position.getProperty("aperture_size"))
if aperture_size > 1:
# aperture size in microns
return (aperture_size/1000.0, aperture_size/1000.0)
else:
# aperture size in millimeters
return (aperture_size, aperture_size)
return (9999, 9999)
def connectNotify(self, signal):
if signal == "apertureChanged":
self.checkPosition()
def checkPosition(self, *args):
pos = MultiplePositions.MultiplePositions.checkPosition(self, *args)
self.emit("apertureChanged", (self.getApertureSize(),))
return pos