major fixes
This commit is contained in:
@@ -33,22 +33,23 @@ class MotorTweak(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, rec_name, short_name, **kwargs):
|
||||
def connect_motor(self, rec_name, **kwargs):
|
||||
# TODO: DO NOT USE Motor base class, but reduce to the only really needed PV: s.a. class QopticZoom(object)
|
||||
# TODO: have a own motor Class as class SimMotor:
|
||||
m = Motor(motor_base)
|
||||
label=kwargs['label']
|
||||
self._label=label
|
||||
m = Motor(rec_name)
|
||||
m.get_position()
|
||||
self._ignore_limits = m.HLM == m.LLM # if both high/low limits are equal they are meaningless
|
||||
self._motor = m
|
||||
m._short_name = short_name
|
||||
self._rec_name = rec_name
|
||||
|
||||
for attr in ['RTYP', 'JVEL', 'HLS', 'LLS', 'TWV', 'RBV', 'VAL', 'LVIO', 'HLM', 'LLM']:
|
||||
@@ -96,6 +97,7 @@ class MotorTweak(QWidget, Ui_MotorTweak):
|
||||
def set_val(self, **kw):
|
||||
v = kw['char_value']
|
||||
_log.debug('updating VAL = {}'.format(v))
|
||||
self._val=float(v) # rewrite in case of tweaking
|
||||
self._drive_val.setText(v)
|
||||
|
||||
|
||||
@@ -187,7 +189,7 @@ class MotorTweak(QWidget, Ui_MotorTweak):
|
||||
'''
|
||||
field = kw['motor_field']
|
||||
src = kw['source_field']
|
||||
kw['alias'] = self.short_name
|
||||
kw['alias'] = self._label
|
||||
if field != src:
|
||||
return
|
||||
if field == 'VAL':
|
||||
@@ -243,7 +245,7 @@ class MotorTweak(QWidget, Ui_MotorTweak):
|
||||
def contextMenuEvent(self, event):
|
||||
m = self._motor
|
||||
menu = QMenu(self)
|
||||
menu.setTitle(self.short_name)
|
||||
menu.setTitle(self._label)
|
||||
|
||||
lockmotor = QAction('lock motor', menu, checkable=True)
|
||||
lockmotor.setChecked(self._locked)
|
||||
@@ -336,7 +338,7 @@ class MotorTweak(QWidget, Ui_MotorTweak):
|
||||
|
||||
for k in source:
|
||||
target[k] = source[k].format(
|
||||
short_name=self.short_name,
|
||||
label=self._label,
|
||||
precision=m.PREC,
|
||||
units=m.units)
|
||||
try:
|
||||
|
||||
@@ -22,14 +22,13 @@ _log = logging.getLogger(__name__)
|
||||
#logger.setLevel(logging.INFO)
|
||||
|
||||
class SimMotor:
|
||||
def __init__(self,rec_name, short_name):
|
||||
def __init__(self,rec_name):
|
||||
self._llm = -10
|
||||
self._hlm = 10
|
||||
self._prec = 5
|
||||
self._twv = 0.1
|
||||
self._units = 'mm'
|
||||
self._pos = 3.1415
|
||||
self._short_name=short_name
|
||||
self._rec_name=rec_name
|
||||
|
||||
class SimMotorTweak(QWidget, Ui_MotorTweak):
|
||||
@@ -48,17 +47,19 @@ class SimMotorTweak(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, rec_name, short_name, *args, **kwargs):
|
||||
self.label.setToolTip('{} => {}'.format(rec_name, short_name))
|
||||
self._motor=m=SimMotor(rec_name, short_name)
|
||||
def connect_motor(self, rec_name, **kwargs):
|
||||
label=kwargs['label']
|
||||
self._label=label
|
||||
self.label.setToolTip('{} => {}'.format(rec_name, label))
|
||||
self._motor=m=SimMotor(rec_name)
|
||||
self.set_motor_validator()
|
||||
self._drive_val.setText(str(m._pos))
|
||||
self._drive_val.returnPressed.connect(self.move_abs)
|
||||
@@ -107,7 +108,7 @@ class SimMotorTweak(QWidget, Ui_MotorTweak):
|
||||
m._pos += dist
|
||||
if delay:
|
||||
sleep(delay)
|
||||
_log.debug('{} rel move => {}'.format(m._short_name, dist))
|
||||
_log.debug('{} rel move => {} {:5.4g}'.format(self._label, dist,m._pos))
|
||||
self.update_label()
|
||||
self.emit_signals(source_field='VAL')
|
||||
|
||||
@@ -149,9 +150,9 @@ class SimMotorTweak(QWidget, Ui_MotorTweak):
|
||||
if assert_position:
|
||||
wait=True
|
||||
if drive is None:
|
||||
_log.debug('{} abs target from widget'.format(m._short_name))
|
||||
_log.debug('{} abs target from widget'.format(self._label))
|
||||
drive = float(self._drive_val.text())
|
||||
_log.debug('{} abs move => {}'.format(m._short_name, drive))
|
||||
_log.debug('{} abs move => {}'.format(self._label, drive))
|
||||
m._pos=drive
|
||||
self.update_label()
|
||||
self.emit_signals(source_field='VAL')
|
||||
@@ -225,7 +226,7 @@ class SimMotorTweak(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)
|
||||
@@ -292,7 +293,7 @@ class SimMotorTweak(QWidget, Ui_MotorTweak):
|
||||
|
||||
for k in source:
|
||||
target[k] = source[k].format(
|
||||
short_name=m._short_name,
|
||||
label=self._label,
|
||||
precision=m._prec,
|
||||
units=m._units)
|
||||
self.label.setText(target[self._label_style].format(rbv=m._pos))
|
||||
|
||||
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user