Startup
This commit is contained in:
@@ -19,6 +19,10 @@ class WireScanInfo(DeviceBase):
|
||||
self.on_status_change(None)
|
||||
self.initialize()
|
||||
|
||||
self.home_offsets = []
|
||||
for s in ("W1X_U0_SP", "W1Y_U0_SP", "W2X_U0_SP", "W2Y_U0_SP", "FOIL_U0_SP"):
|
||||
self.home_offsets.append(caget(self.prefix + ":" +s, 'd'))
|
||||
|
||||
def on_status_change(self, val):
|
||||
try:
|
||||
if self.status_channels[0].get() == 1:
|
||||
@@ -55,15 +59,38 @@ class WireScanInfo(DeviceBase):
|
||||
self.curr_cycl.close()
|
||||
for c in self.status_channels:
|
||||
c.close()
|
||||
|
||||
def get_wire_pos(self, pos_motor):
|
||||
if (pos_motor is None) or math.isnan(pos_motor):
|
||||
return [pos_motor] * 4
|
||||
w1x = (pos_motor - self.home_offsets[0]) / -(math.sqrt(2))
|
||||
w1y = (pos_motor - self.home_offsets[1]) / (math.sqrt(2))
|
||||
w2x = (pos_motor - self.home_offsets[2]) / -(math.sqrt(2))
|
||||
w2y = (pos_motor - self.home_offsets[3]) / (math.sqrt(2))
|
||||
return [w1x, w1y, w2x, w2y]
|
||||
|
||||
|
||||
def newScanInfoDevice(name, prefix):
|
||||
def new_scan_info_device(name, prefix):
|
||||
return WireScanInfo(name, prefix)
|
||||
|
||||
|
||||
def get_wire_pos(wire_scanner, pos):
|
||||
return wire_scanner.get_wire_pos(pos)
|
||||
|
||||
def get_scan_selection(scan_type, index = 0):
|
||||
if scan_type == WireScanner.WireX1: return WireScanner.W1X
|
||||
if scan_type == WireScanner.WireY1: return WireScanner.W1Y
|
||||
if scan_type == WireScanner.WireX2: return WireScanner.W2X
|
||||
if scan_type == WireScanner.WireY2: return WireScanner.W2Y
|
||||
if scan_type == WireScanner.Set1: return WireScanner.W1X if (index==0) else WireScanner.W1Y
|
||||
if scan_type == WireScanner.Set2: return WireScanner.W2X if (index==0) else WireScanner.W2Y
|
||||
return None
|
||||
|
||||
class WireScanner(WireScanInfo):
|
||||
|
||||
ScanType = [WireX1, WireY1, WireX2, WireY2, Set1, Set2] = ['X1', 'Y1', 'X2', 'Y2', 'Set1', 'Set2']
|
||||
Selection = [Garage, W1X, W1Y, W2X, W2Y, Foil] = "GARAGE", "W1X", "W1Y", "W2X", "W2Y", "FOIL"
|
||||
|
||||
def __init__(self, prefix, sel = None, start=None , end=None, cycles=None, velocity=None, continuous = None):
|
||||
def __init__(self, prefix, scan_range, cycles=None, velocity=None, continuous = None):
|
||||
WireScanInfo.__init__(self, "Wire Scan " + prefix, prefix)
|
||||
self.motor = ch.psi.pshell.epics.Motor("WireScanner motor", self.prefix + ":MOTOR_1")
|
||||
self.motor.uploadConfig()
|
||||
@@ -80,14 +107,10 @@ class WireScanner(WireScanInfo):
|
||||
self.range = None
|
||||
self.start = None
|
||||
self.end = None
|
||||
self.scan_range = scan_range;
|
||||
if sel is not None:
|
||||
self.set_selection(sel)
|
||||
|
||||
#Setting parameters
|
||||
if start is not None:
|
||||
self.start.write(float(start))
|
||||
if end is not None:
|
||||
self.end.write(float(end))
|
||||
if velocity is not None:
|
||||
self.wire_velocity.write(float(velocity))
|
||||
if cycles is not None:
|
||||
@@ -97,8 +120,7 @@ class WireScanner(WireScanInfo):
|
||||
|
||||
self.readback = self.motor_bs_readback.get()
|
||||
self.cycles = self.nb_cycles.get()
|
||||
self.velocity = self.wire_velocity.get()
|
||||
self.scan_range = [self.start.get(), self.end.get()]
|
||||
self.velocity = self.wire_velocity.get()
|
||||
self.initialize()
|
||||
|
||||
#def on_readback_change(self, val):
|
||||
@@ -113,7 +135,16 @@ class WireScanner(WireScanInfo):
|
||||
self.range = Channel(self.prefix + ":" + self.selection + "_RANGE_SP")
|
||||
self.start = Channel(self.prefix + ":" + self.selection + "_START_SP")
|
||||
self.end = Channel(self.prefix + ":" + self.selection + "_END_SP")
|
||||
self.wire_sel.put(WireScanner.Selection.index(sel))
|
||||
self.wire_sel.put(WireScanner.Selection.index(sel))
|
||||
|
||||
#Setting parameters
|
||||
if start is not None:
|
||||
if sel in ["W1X", "W2X"]: self.start.write(float(self.scan_range[0]))
|
||||
if sel in ["W1Y", "W2Y"]: self.start.write(float(self.scan_range[2]))
|
||||
if end is not None:
|
||||
if sel in ["W1X", "W2X"]: self.end.write(float(self.scan_range[1]))
|
||||
if sel in ["W1Y", "W2Y"]: self.end.write(float(self.scan_range[3]))
|
||||
|
||||
|
||||
def abort(self):
|
||||
caputq(self.prefix + ":ABORT.PROC", 1)
|
||||
@@ -127,6 +158,16 @@ class WireScanner(WireScanInfo):
|
||||
def scan(self):
|
||||
self.cycles = self.nb_cycles.get()
|
||||
caputq(self.prefix + ":SCAN_WIRE", 1)
|
||||
|
||||
def get_sel_wire_pos(self, pos_motor=None):
|
||||
if pos_motor is None:
|
||||
pos_motor = self.motor_bs_readback.get()
|
||||
wire_pos = self.get_wire_pos(pos_motor)
|
||||
if self.selection == WireScanner.W1X: return wire_pos[0]
|
||||
if self.selection == WireScanner.W1Y: return wire_pos[1]
|
||||
if self.selection == WireScanner.W2X: return wire_pos[2]
|
||||
if self.selection == WireScanner.W2Y: return wire_pos[3]
|
||||
return float('nan')
|
||||
|
||||
def doClose(self):
|
||||
WireScanInfo.doClose(self)
|
||||
|
||||
Reference in New Issue
Block a user