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

@@ -36,31 +36,33 @@ class SmaractMotorTweak(QWidget, Ui_MotorTweak):
self._locked = False
self._label_style = 'basic'
self._templates_source = {
'basic': '<b>{short_name}</b> <font color="#080">{{rbv:.{precision}f}} {units}</font>',
'small': '<small>{short_name} <font size="small" color="#080">{{rbv:.{precision}f}} {units}</font><small>',
'2 lines': '<b>{short_name}</b><br><font size="small" color="#080">{{rbv:.{precision}f}} {units}</font>',
'busy': '<b>{short_name}</b> <font color="#080">{{rbv:.{precision}f}} {units}</font>'
'basic': '<b>{label}</b> <font color="#080">{{rbv:.{precision}f}} {units}</font>',
'small': '<small>{label} <font size="small" color="#080">{{rbv:.{precision}f}} {units}</font><small>',
'2 lines': '<b>{label}</b><br><font size="small" color="#080">{{rbv:.{precision}f}} {units}</font>',
'busy': '<b>{label}</b> <font color="#080">{{rbv:.{precision}f}} {units}</font>'
}
self._templates = {}
def connect_motor(self, motor_base, short_name=None, *args, **kwargs):
def connect_motor(self, rec_name, **kwargs):
# TODO: DO NOT USE so many PVs, but reduce to the only really needed PV: s.a. class QopticZoom(object)
self._pvname = motor_base+':DRIVE'
self._pv_name = PV(motor_base+':NAME')
self._pv_drive = PV(motor_base+':DRIVE')
self._pv_readback = PV(motor_base+':MOTRBV')
self._pv_tweak_r = PV(motor_base+':TWR.PROC')
self._pv_tweak_f = PV(motor_base+':TWF.PROC')
self._pv_tweak_val = PV(motor_base+':TWV')
self._pv_status = PV(motor_base + ':STATUS')
self._pv_home_f = PV(motor_base + ':FRM_FORW.PROC')
self._pv_home_b = PV(motor_base + ':FRM_BACK.PROC')
self._pv_is_homed = PV(motor_base + ':GET_HOMED')
self._pv_llm = PV(motor_base + ':LLM')
self._pv_hlm = PV(motor_base + ':HLM')
label=kwargs['label']
self._label=label
self._pvname = rec_name+':DRIVE'
self._pv_name = PV(rec_name+':NAME')
self._pv_drive = PV(rec_name+':DRIVE')
self._pv_readback = PV(rec_name+':MOTRBV')
self._pv_tweak_r = PV(rec_name+':TWR.PROC')
self._pv_tweak_f = PV(rec_name+':TWF.PROC')
self._pv_tweak_val = PV(rec_name+':TWV')
self._pv_status = PV(rec_name + ':STATUS')
self._pv_home_f = PV(rec_name + ':FRM_FORW.PROC')
self._pv_home_b = PV(rec_name + ':FRM_BACK.PROC')
self._pv_is_homed = PV(rec_name + ':GET_HOMED')
self._pv_llm = PV(rec_name + ':LLM')
self._pv_hlm = PV(rec_name + ':HLM')
self.label.setToolTip('{} => {}'.format(motor_base, self._pv_name.get()))
self.label.setToolTip('{} => {}'.format(rec_name, self._pv_name.get()))
try:
self._prec = kwargs['prec']
@@ -73,9 +75,6 @@ class SmaractMotorTweak(QWidget, Ui_MotorTweak):
self._units = 'mm'
self._ignore_limits = self._pv_llm.get() == self._pv_hlm.get() # if both high/low limits are equal they are meaningless
if not short_name:
short_name = self._pv_name.value
self.short_name = short_name
self.set_motor_validator()
self._drive_val.setText(self._pv_drive.get(as_string=True))
@@ -169,9 +168,9 @@ class SmaractMotorTweak(QWidget, Ui_MotorTweak):
if assert_position:
wait=True
if drive is None:
logger.debug('{} abs target from widget'.format(self.short_name))
logger.debug('{} abs target from widget'.format(self._label))
drive = float(self._drive_val.text())
logger.debug('{} abs move => {}'.format(self.short_name, drive))
logger.debug('{} abs move => {}'.format(self._label, drive))
self._pv_drive.put(drive)
if wait:
self.wait()
@@ -243,7 +242,7 @@ class SmaractMotorTweak(QWidget, Ui_MotorTweak):
prec = self._prec
menu = QMenu(self)
menu.setTitle(self.short_name)
menu.setTitle(self._label)
lockmotor = QAction('lock motor', menu, checkable=True)
lockmotor.setChecked(self._locked)
@@ -309,7 +308,7 @@ class SmaractMotorTweak(QWidget, Ui_MotorTweak):
for k in source:
target[k] = source[k].format(
short_name=self.short_name,
label=self._label,
precision=self._prec,
units=self._units)
self.label.setText(target[self._label_style].format(rbv=self._pv_readback.get()))