major fixes

This commit is contained in:
2023-05-24 17:37:51 +02:00
parent 6712251b9d
commit 523a154cd7
7 changed files with 107 additions and 76 deletions

View File

@@ -88,6 +88,7 @@ import pyqtUsrObj as UsrGO
from epics_widgets.MotorTweak import MotorTweak
from epics_widgets.SmaractMotorTweak import SmaractMotorTweak
from epics_widgets.SimMotorTweak import SimMotorTweak
# from epics import caput, caget # TODO: shutter
ts.log('Import part 5/8:')
import numpy as np
np.set_printoptions(suppress=True,linewidth=196)
@@ -811,22 +812,22 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
self.move_post_tube("out")
bl.move(pos)
def get_tweaker(self, rec, alias=None, label=None, mtype="epics_motor", layout=None, **kwargs):
def get_tweaker(self, rec, mtype=0, **kwargs):
app = QApplication.instance()
sim=app._args.sim
if mtype == "epics_motor":
if mtype == 0: # default epics motor record
if sim&0x10:
m=SimMotorTweak()
m_tw=SimMotorTweak()
else:
m = MotorTweak()
else:
m_tw=MotorTweak()
elif mtype==1: # smaract motor record
if sim&0x20:
m=SimMotorTweak()
m_tw=SimMotorTweak()
else:
m = SmaractMotorTweak()
m.connect_motor(rec, label, **kwargs)
self.tweakers[alias] = m
return m
m_tw=SmaractMotorTweak()
m_tw.connect_motor(rec, **kwargs)
self.tweakers[kwargs['alias']] = m_tw
return m_tw
def build_post_tube_tandem_tweaker(self):
block = QWidget()
@@ -922,8 +923,8 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
but.clicked.connect(f(v))
c.layout().addWidget(but, 0, i)
widgets = [
self.get_tweaker(f"{pfx}1", alias="colli_x", label="colli X", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}2", alias="colli_y", label="colli Y", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}1", alias="colli_x", label="colli X", mtype=1,),
self.get_tweaker(f"{pfx}2", alias="colli_y", label="colli Y", mtype=1,),
c,
]
qutilities.add_item_to_toolbox(toolbox,"Collimator",widget_list=widgets)
@@ -931,11 +932,11 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
def build_group_posttube(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[1]
widgets = [
self.get_tweaker(f"{pfx}4", alias="tube_usx", label="upstream X", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}6", alias="tube_usy", label="upstream Y", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}5", alias="tube_dsx", label="downstream X", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}7", alias="tube_dsy", label="downstream Y", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}8", alias="tube_z", label="tube Z", mtype="smaract_motor"),
self.get_tweaker(f"{pfx}4", alias="tube_usx", label="upstream X", mtype=1,),
self.get_tweaker(f"{pfx}6", alias="tube_usy", label="upstream Y", mtype=1,),
self.get_tweaker(f"{pfx}5", alias="tube_dsx", label="downstream X", mtype=1,),
self.get_tweaker(f"{pfx}7", alias="tube_dsy", label="downstream Y", mtype=1,),
self.get_tweaker(f"{pfx}8", alias="tube_z", label="tube Z", mtype=1),
]
c = QWidget()
c.setLayout(QGridLayout())
@@ -962,8 +963,8 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
def build_group_xeye(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[1]
widgets=[
self.get_tweaker(f"{pfx}14", alias="xeye_x", label="X", mtype="smaract_motor"),
self.get_tweaker(f"{pfx}15", alias="xeye_y", label="Y", mtype="smaract_motor"),
self.get_tweaker(f"{pfx}14", alias="xeye_x", label="X", mtype=1),
self.get_tweaker(f"{pfx}15", alias="xeye_y", label="Y", mtype=1),
]
qutilities.add_item_to_toolbox(toolbox,"X-Ray Eye",widget_list=widgets)
@@ -1539,6 +1540,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
app=QApplication.instance()
steps = [
# lambda: sample_selection.tell.set_current(30.0),
lambda:self.move_detector("out"),
lambda: self.move_collimator("out"),
lambda:self.move_detector("out"),
lambda:self.move_post_tube("out"),
@@ -2158,6 +2160,16 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
return
dlg.setLabelText("Homing and get ready");dlg+=5
sp.homing() # homing if needed
# TODO: shutter
# open laser shutter
# caput("SLAAR02-LMOT-M262:MOT.VAL", 1)
# time.sleep(4)
# TODO: shutter
# open fast shutter
#caput("SARES30-LTIM01-EVR0:RearUniv0-Ena-SP", 1)
sp.run() # start motion program
sp.wait_armed() # wait until motors are at first position
#time.sleep(1.0) # wait armed does not wor yet ?!?
@@ -2186,6 +2198,14 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
plt.show(block=False)
#plt.show(block=True)
# TODO: shutter
# clos fast shutter
# caput("SARES30-LTIM01-EVR0:RearUniv0-Ena-SP", 0)
# TODO: shutter
# close laser shutter
# caput("SLAAR02-LMOT-M262:MOT.VAL", 40)
def esc_run_steps(self, steps, title, esc_state):
self._esc_state ="busy"
with pg.ProgressDialog(title, 0, len(steps)) as dlg:
@@ -3034,10 +3054,10 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
toolbox,
"Slits",
widget_list=[
self.get_tweaker(f"{pfx}10", alias="slit_right", label="left", mtype="smaract_motor", ),
self.get_tweaker(f"{pfx}11", alias="slit_left", label="right", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}12", alias="slit_bottom", label="bottom", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}13",alias="slit_top",label="top",mtype="smaract_motor",),
self.get_tweaker(f"{pfx}10", alias="slit_right", label="left", mtype=1, ),
self.get_tweaker(f"{pfx}11", alias="slit_left", label="right", mtype=1,),
self.get_tweaker(f"{pfx}12", alias="slit_bottom", label="bottom", mtype=1,),
self.get_tweaker(f"{pfx}13",alias="slit_top",label="top",mtype=1,),
],
)