WIP
This commit is contained in:
@@ -24,8 +24,12 @@ import pyqtgraph as pg
|
||||
from ecmcPvDataItem import *
|
||||
from ecmcParseAxisStatusWord import *
|
||||
|
||||
import os
|
||||
|
||||
# Allow buffering of 10s data, need to add setting for this
|
||||
xMaxTime = 10
|
||||
caqtdmAxisExpertPanelName = "ecmcAxisExpert_v1.ui"
|
||||
caqtdmExe ="/usr/local/bin/caqtdm"
|
||||
|
||||
# List of pv names
|
||||
pvlist = [ 'BuffSze',
|
||||
@@ -58,14 +62,12 @@ pvAnalog = ['PosAct-Arr',
|
||||
'Stat-Arr']
|
||||
|
||||
pvAnaPLotsDefaultEnabled = ['PosAct-Arr',
|
||||
'PosSet-Arr',
|
||||
'PosErr-Arr']
|
||||
'PosSet-Arr']
|
||||
|
||||
pvBinPLotsDefaultEnabled = ['enable',
|
||||
'enabled',
|
||||
'busy',
|
||||
'attarget',
|
||||
'moving']
|
||||
'attarget']
|
||||
pvBinBlock = ['instartup',
|
||||
'inrealtime',
|
||||
'axisType',
|
||||
@@ -83,7 +85,7 @@ pvFistAxisIndexName = 'MCU-Cfg-AX-FrstObjId'
|
||||
pvNextAxisIndexNamePart1 = 'MCU-Cfg-AX'
|
||||
pvNextAxisIndexNamePart2 = '-NxtObjId'
|
||||
|
||||
pvmiddlestring='Plg-Mtn'
|
||||
pvmiddlestring=':Plg-Mtn'
|
||||
|
||||
class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
def __init__(self,prefix="IOC_TEST:",mtnPluginId=0):
|
||||
@@ -188,7 +190,8 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
|
||||
# Check connection and read sample rate
|
||||
pvSampleRate = epics.PV(self.pvPrefixStr + pvmiddlestring + str(int(self.mtnPluginId))+ '-SmpHz-RB')
|
||||
connected = pvSampleRate.wait_for_connection(timeout = 2)
|
||||
print(self.pvPrefixStr + pvmiddlestring + str(int(self.mtnPluginId))+ '-SmpHz-RB')
|
||||
connected = pvSampleRate.wait_for_connection(timeout = 3)
|
||||
if connected:
|
||||
print('Connected to ecmc')
|
||||
self.offline = False
|
||||
@@ -200,7 +203,8 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
else:
|
||||
print('Not Connected')
|
||||
self.offline = True
|
||||
self.pause = True
|
||||
self.pause = True
|
||||
self.sampleRate = 1000
|
||||
|
||||
self.sampleRateValid = True
|
||||
|
||||
@@ -242,37 +246,58 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
self.plotItemBinary.setFixedHeight(150)
|
||||
self.plotItemBinary.setMouseEnabled(y=False)
|
||||
self.plotItemBinary.setLabel('bottom', 'Time [s]')
|
||||
|
||||
self.pauseBtn = QPushButton(text = 'pause')
|
||||
self.pauseBtn.setFixedSize(100, 50)
|
||||
self.pauseBtn.clicked.connect(self.pauseBtnAction)
|
||||
self.pauseBtn.setStyleSheet("background-color: green")
|
||||
#self.pauseBtn.setEnabled(False)
|
||||
#self.pauseBtn.setVisible(False)
|
||||
|
||||
self.openBtn = QPushButton(text = 'open data')
|
||||
self.openBtn.setFixedSize(100, 50)
|
||||
self.openBtn.clicked.connect(self.openBtnAction)
|
||||
self.openBtn.setEnabled(False)
|
||||
self.openBtn.setVisible(False)
|
||||
|
||||
self.saveBtn = QPushButton(text = 'save data')
|
||||
self.saveBtn.setFixedSize(100, 50)
|
||||
self.saveBtn.clicked.connect(self.saveBtnAction)
|
||||
self.saveBtn.setEnabled(False)
|
||||
self.saveBtn.setVisible(False)
|
||||
|
||||
self.enableBtn = QPushButton(text = 'enable Mtn')
|
||||
self.enableBtn.setFixedSize(100, 50)
|
||||
self.enableBtn.clicked.connect(self.enableBtnAction)
|
||||
self.triggBtn = QPushButton(text = 'trigg Mtn')
|
||||
self.triggBtn.setFixedSize(100, 50)
|
||||
self.triggBtn.setEnabled(False)
|
||||
self.triggBtn.setVisible(False)
|
||||
|
||||
self.triggBtn.clicked.connect(self.triggBtnAction)
|
||||
self.zoomBtn = QPushButton(text = 'auto zoom')
|
||||
self.zoomBtn.setFixedSize(100, 50)
|
||||
self.zoomBtn.clicked.connect(self.zoomBtnAction)
|
||||
self.zoomBtn.setEnabled(False)
|
||||
self.zoomBtn.setVisible(False)
|
||||
|
||||
self.modeCombo = QComboBox()
|
||||
self.modeCombo.setFixedSize(100, 50)
|
||||
self.modeCombo.currentIndexChanged.connect(self.newModeIndexChanged)
|
||||
self.modeCombo.addItem("CONT")
|
||||
self.modeCombo.addItem("TRIGG")
|
||||
self.modeCombo.setEnabled(False)
|
||||
self.modeCombo.setVisible(False)
|
||||
|
||||
self.progressBar = QProgressBar()
|
||||
self.progressBar.reset()
|
||||
self.progressBar.setMinimum(0)
|
||||
self.progressBar.setMaximum(100) #100%
|
||||
self.progressBar.setValue(0)
|
||||
self.progressBar.setFixedHeight(20)
|
||||
|
||||
self.progressBar.setEnabled(False)
|
||||
self.progressBar.setVisible(False)
|
||||
|
||||
# Fix layout
|
||||
self.setGeometry(300, 300, 1200, 900)
|
||||
|
||||
@@ -367,17 +392,23 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
frameMotion = QFrame(self)
|
||||
layoutMotionGrid = QGridLayout()
|
||||
frameMotion.setLayout(layoutMotionGrid)
|
||||
|
||||
self.btnMotorRecord = QPushButton(text = 'Motor Record')
|
||||
self.btnMotorRecord.clicked.connect(self.openMotorRecordPanel)
|
||||
self.btnMotorRecord.setFixedSize(100, 50)
|
||||
self.btnMotorRecord.setFixedSize(150, 50)
|
||||
layoutMotionGrid.addWidget(self.btnMotorRecord,0,0)
|
||||
|
||||
self.btnCaQTDmAxisExpert = QPushButton(text = 'caqtdm ecmc Axis')
|
||||
self.btnCaQTDmAxisExpert.clicked.connect(self.openCaQTDmAxisExpert)
|
||||
self.btnCaQTDmAxisExpert.setFixedSize(150, 50)
|
||||
layoutMotionGrid.addWidget(self.btnCaQTDmAxisExpert,1,0)
|
||||
|
||||
label = QLabel('Axis id:')
|
||||
self.cmbBxSelectAxis = QComboBox()
|
||||
self.cmbBxSelectAxis.currentIndexChanged.connect(self.changeAxisIndex)
|
||||
|
||||
layoutMotionGrid.addWidget(label,1,0)
|
||||
layoutMotionGrid.addWidget(self.cmbBxSelectAxis,1,1)
|
||||
layoutMotionGrid.addWidget(label,2,0)
|
||||
layoutMotionGrid.addWidget(self.cmbBxSelectAxis,2,1)
|
||||
|
||||
|
||||
layoutVertMain.addWidget(frameMotion)
|
||||
@@ -432,10 +463,14 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
QCoreApplication.processEvents()
|
||||
|
||||
def sig_cb_PosAct_Arr(self,value):
|
||||
if self.pause:
|
||||
return
|
||||
if(np.size(value)) > 0:
|
||||
self.MtnYDataValid = True
|
||||
|
||||
def sig_cb_Time_Arr(self,value):
|
||||
if self.pause:
|
||||
return
|
||||
if(np.size(value)) > 0:
|
||||
self.MtnXDataValid = True
|
||||
self.plotAll()
|
||||
@@ -467,13 +502,13 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
if id >= 0:
|
||||
self.cmbBxSelectAxis.setCurrentIndex(id)
|
||||
|
||||
axisPrefixPvName = self.pvPrefixStr + pvAxisPrefixNamePart1 + str(int(value)) + pvAxisPrefixNamePart2
|
||||
axisPrefixPvName = self.pvPrefixStr + ":" + pvAxisPrefixNamePart1 + str(int(value)) + pvAxisPrefixNamePart2
|
||||
prefixPV = epics.PV(axisPrefixPvName)
|
||||
axisPrefix = prefixPV.get()
|
||||
if axisPrefix is not None:
|
||||
self.axisPrefix = axisPrefix
|
||||
self.axisPrefix = axisPrefix.rstrip(':')
|
||||
|
||||
axisNamePvName = self.pvPrefixStr + pvAxisNamePart1 + str(int(value)) + pvAxisNamePart2
|
||||
axisNamePvName = self.pvPrefixStr + ":" + pvAxisNamePart1 + str(int(value)) + pvAxisNamePart2
|
||||
namePV = epics.PV(axisNamePvName)
|
||||
axisName = namePV.get()
|
||||
if axisName is not None:
|
||||
@@ -488,6 +523,8 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
return
|
||||
|
||||
def sig_cb_Stat_Arr(self,value):
|
||||
if self.pause:
|
||||
return
|
||||
|
||||
data = self.parseAxisStatWd.convert(value)
|
||||
self.addStatWdData(data)
|
||||
@@ -521,7 +558,7 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
self.plotBinary()
|
||||
|
||||
def readAxisList(self):
|
||||
axIdPV = epics.PV(self.pvPrefixStr + pvFistAxisIndexName)
|
||||
axIdPV = epics.PV(self.pvPrefixStr + ":" + pvFistAxisIndexName)
|
||||
axId = axIdPV.get()
|
||||
if axId is None:
|
||||
print('ERROR: First Axis Index PV not found.')
|
||||
@@ -532,7 +569,7 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
|
||||
while axId >= 0:
|
||||
# Get next axis id
|
||||
pvName = self.pvPrefixStr + pvNextAxisIndexNamePart1 + str(int(axId)) + pvNextAxisIndexNamePart2
|
||||
pvName = self.pvPrefixStr + ":" + pvNextAxisIndexNamePart1 + str(int(axId)) + pvNextAxisIndexNamePart2
|
||||
axIdPV = epics.PV(pvName)
|
||||
axId = axIdPV.get()
|
||||
|
||||
@@ -544,10 +581,22 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
self.pvItems['AxCmd-RB'].pvPut(self.cmbBxSelectAxis.currentData(), use_complete=True)
|
||||
|
||||
def openMotorRecordPanel(self,xxx):
|
||||
self.dialog = MotorPanel(self,self.axisPrefix ,self.axisName)
|
||||
self.dialog.resize(500, 900)
|
||||
self.dialog = MotorPanel(self,self.axisPrefix + ':' ,self.axisName)
|
||||
self.dialog.resize(500, 900)
|
||||
self.dialog.show()
|
||||
|
||||
def openCaQTDmAxisExpert(self,xxx):
|
||||
# caqtdm -macro "IOC=$I,SYS=$S,Axis=$A" ecmcAxisExpert_v1.ui
|
||||
caqtdmString = caqtdmExe + " -macro "
|
||||
caqtdmMacros = "SYS=" + self.axisPrefix
|
||||
caqtdmMacros += ",IOC=" + self.axisPrefix
|
||||
caqtdmMacros += ",Axis=" + self.axisName
|
||||
|
||||
caqtdmString+= "\"" + caqtdmMacros + "\"" + " " + caqtdmAxisExpertPanelName
|
||||
print(caqtdmString)
|
||||
#subprocess.call(caqtdmString)
|
||||
os.system(caqtdmString)
|
||||
|
||||
###### Widget callbacks
|
||||
def pauseBtnAction(self):
|
||||
self.pause = not self.pause
|
||||
@@ -815,9 +864,9 @@ class ecmcMtnMainGui(QtWidgets.QDialog):
|
||||
def printOutHelp():
|
||||
print("ecmcMtnMainGui: Plots waveforms of Mtn data (updates on Y data callback). ")
|
||||
print("python ecmcMtnMainGui.py <prefix> <mtnId>")
|
||||
print("<prefix>: Ioc prefix ('IOC_TEST:')")
|
||||
print("<prefix>: Ioc prefix ('IOC_TEST')")
|
||||
print("<mtnId> : Id of mtn plugin ('0')")
|
||||
print("example : python ecmcMotionMainGui.py 'IOC_TEST:' '0'")
|
||||
print("example : python ecmcMotionMainGui.py 'IOC_TEST' '0'")
|
||||
print("Will connect to Pvs: <prefix>Plg-Mtn<mtnId>-*")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user