wip
This commit is contained in:
@@ -160,8 +160,40 @@ class WndMainRIXS(QWidget):
|
||||
w.clicked.connect(lambda val, w=w:self.OnEnergyChanged(w, val))
|
||||
lg.addWidget(w, row, 2)
|
||||
row+=1
|
||||
|
||||
w=QPushButton('sync motors')
|
||||
w.clicked.connect(self.btnSyncMotors)
|
||||
lv.addWidget(w)
|
||||
self.show()
|
||||
|
||||
def btnSyncMotors(self):
|
||||
#reads the epics motor and updates the vizualization
|
||||
_log.info('')
|
||||
app=QApplication.instance()
|
||||
dev=app._dev
|
||||
pv_rbv=dev._pvDict['rbv']
|
||||
geo=dev._geo
|
||||
for k,v in pv_rbv.items():
|
||||
if v.connected:
|
||||
geo[k]=v.get()
|
||||
else:
|
||||
_log.warning(f'pv {k} not connected')
|
||||
return
|
||||
dev.motor2geometry()
|
||||
dev.setGeometry(dev._geo)
|
||||
try:
|
||||
wndCld=app._wndVisualize
|
||||
except AttributeError as e:
|
||||
pass
|
||||
else:
|
||||
wndCld.updateDevice(dev)
|
||||
try:
|
||||
wndCld=app._wndVars
|
||||
except AttributeError as e:
|
||||
pass
|
||||
else:
|
||||
wndCld.updateDevice(dev)
|
||||
|
||||
def OnOpenChildWnd(self,wnd):
|
||||
app=QApplication.instance()
|
||||
if wnd=='Visualize':
|
||||
@@ -934,23 +966,19 @@ class WndVars(QWidget):
|
||||
if pv.connected:
|
||||
v=pv.get(as_string=True)
|
||||
else:
|
||||
v=t
|
||||
v=m
|
||||
w=QLineEdit(v,objectName=m)
|
||||
w.setToolTip(desc)
|
||||
l.addWidget(w, i,1)
|
||||
|
||||
v=f"<font color='#808080'>{t}</font>"
|
||||
v=f"<font color='#808080'>{m}</font>"
|
||||
w=QLabel(v,objectName=m)
|
||||
l.addWidget(w, i, 2)
|
||||
#pv=pvd[rcNm]
|
||||
|
||||
w=QPushButton('sync motors')
|
||||
w.clicked.connect(self.btnSyncMotors)
|
||||
l.addWidget(w, i+1, 1)
|
||||
|
||||
w=QPushButton('move motors')
|
||||
w.clicked.connect(self.btnMoveMotors)
|
||||
l.addWidget(w, i+2, 1)
|
||||
l.addWidget(w, i+1, 1)
|
||||
|
||||
|
||||
|
||||
@@ -983,72 +1011,61 @@ class WndVars(QWidget):
|
||||
val=v
|
||||
pv_rbv=dev._pvDict['rbv']
|
||||
pv=pv_rbv[k]
|
||||
rbv=pv.get()
|
||||
if pv.connected:
|
||||
rbv=pv.get()
|
||||
else:
|
||||
rbv=None
|
||||
_log.debug(f'change: {key}:{val}:{rbv}')
|
||||
grpMot=self._wdGrpMotor
|
||||
wLe=grpMot.findChild(QLineEdit, key)
|
||||
if wLe is not None:
|
||||
wCb=grpMot.findChild(QCheckBox, key)
|
||||
wLb=grpMot.findChild(QLabel, key)
|
||||
#TODO:
|
||||
if val is None:
|
||||
v=f"<font color='#606060'>{rbv:.5g}</font>"
|
||||
v=f"<font color='#606060'>{rbv}</font>"
|
||||
else:
|
||||
wLe.setText(f'{val:.3f}') # {v:.6g}
|
||||
d=abs(val-rbv)
|
||||
b=bool(d>0.001)
|
||||
wCb.setChecked(b)
|
||||
if b:
|
||||
c='ff8080'
|
||||
if rbv is None:
|
||||
v=f"<font color='#606060'>{rbv}</font>"
|
||||
else:
|
||||
c='60a060'
|
||||
v=f"<font color='#{c}'>{rbv:.5g} ({d:+.5g})</font>"
|
||||
d=abs(val-rbv)
|
||||
b=bool(d>0.001)
|
||||
wCb.setChecked(b)
|
||||
if b:
|
||||
c='ff8080'
|
||||
else:
|
||||
c='60a060'
|
||||
v=f"<font color='#{c}'>{rbv:.5g} ({d:+.5g})</font>"
|
||||
wLb.setText(v)
|
||||
|
||||
def btnMoveMotors(self):
|
||||
grpMot=self._wdGrpMotor
|
||||
lg=grpMot.layout()
|
||||
col=lg.columnCount()
|
||||
eDevs=self._epicsDevDct
|
||||
|
||||
for k,eDev in eDevs.items():
|
||||
wCb=grpMot.findChild(QCheckBox, k)
|
||||
if wCb.isChecked():
|
||||
wLe=grpMot.findChild(QLineEdit, k)
|
||||
v=float(wLe.text())
|
||||
if eDev is not None:
|
||||
_log.info(f'move motor {k} to {v}')
|
||||
if type(eDev)==SimEpicsDevice:
|
||||
eDev.VAL=v # move motor #comment out for safety
|
||||
self.update_label(key=k,val=v)
|
||||
else:
|
||||
#eDev.VAL=v # move motor #comment out for safety
|
||||
pass
|
||||
|
||||
def btnSyncMotors(self):
|
||||
#reads the epics motor and updates the vizualization
|
||||
_log.info('')
|
||||
app=QApplication.instance()
|
||||
dev=app._dev
|
||||
pv_rbv=dev._pvDict['rbv']
|
||||
try:
|
||||
pv_val=dev._pvDict['val']
|
||||
except KeyError as e:
|
||||
pv_val=dev._pvDict['val']=dict()
|
||||
|
||||
geo=dev._geo
|
||||
for k,v in pv_rbv.items():
|
||||
geo[k]=v.get()
|
||||
|
||||
dev.motor2geometry()
|
||||
dev.setGeometry(dev._geo)
|
||||
try:
|
||||
wndCld=app._wndVisualize
|
||||
except AttributeError as e:
|
||||
pass
|
||||
else:
|
||||
wndCld.updateDevice(dev)
|
||||
try:
|
||||
wndCld=app._wndVars
|
||||
except AttributeError as e:
|
||||
pass
|
||||
else:
|
||||
wndCld.updateDevice(dev)
|
||||
|
||||
grpMot=self._wdGrpMotor
|
||||
lg=grpMot.layout()
|
||||
col=lg.columnCount()
|
||||
row=lg.rowCount()
|
||||
for r in range(row-1): # -1 because last one is a button
|
||||
wCb=lg.itemAtPosition(r, 0)
|
||||
if wCb is None:
|
||||
continue
|
||||
wCb=wCb.widget()
|
||||
if wCb.isChecked():
|
||||
m=wCb.objectName()
|
||||
try:
|
||||
pv=pv_val[m]
|
||||
except KeyError as e:
|
||||
pvn=RIXSdevice._prefix+'MOT_'+m.upper()+'.VAL'
|
||||
pv=pv_val[m]=epics.get_pv(pvn)#,connection_callback=self.OnConnectionChange,callback=self.OnValueChange)
|
||||
pv.put(geo[m])
|
||||
|
||||
|
||||
# ->>>> https://pyepics.github.io/pyepics/devices.html >>> USE THIS
|
||||
|
||||
Reference in New Issue
Block a user