"""LI LLRF Custom Widgets."""
import numpy as np
from qtpy.QtGui import QColor
from qtpy.QtCore import Qt, QSize
from qtpy.QtWidgets import QPushButton, QGridLayout, \
QWidget, QHBoxLayout
import qtawesome as _qta
from siriuspy.envars import VACA_PREFIX as _VACA_PREFIX
from .. import util as _util
from ..widgets import SiriusTimePlot, SiriusWaveformPlot, \
SiriusConnectionSignal as _ConnSignal
[docs]
class GraphIvsQ(QWidget):
"""Show the I&Q Chart based on IxQ or Time"""
def __init__(
self, parent=None, dev=None,
prop='Time', main_dev='', channel='CH1', prefix=''):
"""."""
super().__init__(parent=parent)
self.prefix = prefix
self.main_dev = main_dev
self.dev = dev
self.prop = prop
self.channel = channel
self._setupui()
def _setupui(self):
"""."""
channels = {}
lay1 = QGridLayout()
self.setLayout(lay1)
graph = SiriusWaveformPlot(self)
graph.setObjectName('graph')
graph.setStyleSheet('#graph {min-height: 15em; min-width: 20em;}')
graph.maxRedrawRate = 2
graph.mouseEnabledX = True
graph.setShowXGrid(True)
graph.setShowYGrid(True)
graph.setBackgroundColor(QColor(_util.get_appropriate_color('LI')))
graph.setShowLegend(True)
graph.setAutoRangeX(False)
graph.setAutoRangeY(False)
graph.plotItem.showButtons()
graph.setAxisColor(QColor(0, 0, 0))
axx = graph.plotItem.getAxis('right')
axx.setVisible(True)
axx.setTicks([])
axx.setWidth(0)
axx = graph.plotItem.getAxis('top')
axx.setVisible(True)
axx.setTicks([])
axx.setHeight(0)
basename = self.prefix + self.main_dev + self.dev
if self.prop == 'IvsQ':
chart_title = "I & Q Fasor"
lblAxis = ["Q", "I"]
channels = {
'Data': {
'X': basename + ':GET_' + self.channel + '_I',
'Y': basename + ':GET_' + self.channel + '_Q'
},
'Setpoint': {
'X': basename + ':GET_' + self.channel + '_SETTING_I',
'Y': basename + ':GET_' + self.channel + '_SETTING_Q'
}
}
graph.setMinXRange(-1.0)
graph.setMaxXRange(1.0)
graph.setMinYRange(-1.0)
graph.setMaxYRange(1.0)
else:
chart_title = "I & Q Waveform"
lblAxis = ["I & Q", "Time"]
channels = {
'Data': {
'X': None,
'Y': basename + ':WF_ADC' + self.channel[2] + '_I'
},
'Setpoint': {
'X': None,
'Y': basename + ':WF_ADC' + self.channel[2] + '_Q'
}
}
graph.setYLabels([lblAxis[0]])
graph.setXLabels([lblAxis[1]])
graph.setPlotTitle(chart_title)
opts = dict(
y_channel=channels['Data']['Y'],
x_channel=channels['Data']['X'],
name='Data',
color='red',
redraw_mode=2,
lineStyle=1,
lineWidth=3,
symbol='o',
symbolSize=10)
graph.addChannel(**opts)
if ((self.prop != 'IvsQ') or (self.channel == 'CH1')):
opts = dict(
y_channel=channels['Setpoint']['Y'],
x_channel=channels['Setpoint']['X'],
name='Setpoint',
color='blue',
redraw_mode=2,
lineStyle=1,
lineWidth=3,
symbol='o',
symbolSize=10)
graph.addChannel(**opts)
lay1.addWidget(graph, 0, 0)
[docs]
class GraphTime(QWidget):
"""Show the graphs of Amplitude, Phase and Diff Data"""
def __init__(
self, parent=None, dev='', prop='Amp', main_dev='', channel='CH1', prefix=''):
"""."""
super().__init__(parent=parent)
self.prefix = prefix
self.main_dev = main_dev
self.dev = dev
self.prop = prop
self.channel = channel
self._setupui()
def _setupui(self):
"""."""
chart_name = self.prop
basename = self.prefix + self.main_dev + self.dev
lay1 = QGridLayout()
self.setLayout(lay1)
graph = SiriusTimePlot(self)
graph.setObjectName('graph')
graph.setStyleSheet('#graph {min-height: 15em; min-width: 20em;}')
graph.timeSpan = 120 # [s]
graph.maxRedrawRate = 2
graph.setShowXGrid(True)
graph.setShowYGrid(True)
graph.setBackgroundColor(QColor(_util.get_appropriate_color('LI')))
graph.setShowLegend(True)
graph.plotItem.showButtons()
graph.setAxisColor(QColor(0, 0, 0))
graph.setXLabels(["Time"])
axx = graph.plotItem.getAxis('right')
axx.setVisible(True)
axx.setTicks([])
axx.setWidth(0)
axx = graph.plotItem.getAxis('top')
axx.setVisible(True)
axx.setTicks([])
axx.setHeight(0)
if self.prop == 'Amp':
chart_name = 'Amplitude'
chname = basename + ':GET_' + self.channel + '_AMP'
elif self.prop == 'Pha':
chart_name = 'Phase'
chname = basename + ':GET_' + self.channel + '_PHASE'
elif self.prop == 'Diff':
chart_name = 'Phase Diff'
chname = basename + ':GET_PHASE_DIFF'
else:
raise ValueError('channel not define for property '+self.prop)
graph.setPlotTitle(chart_name)
graph.setYLabels([chart_name])
opts = dict(
y_channel=chname,
name='Data',
color='black',
lineStyle=1,
lineWidth=3,
symbol='o',
symbolSize=10)
graph.addYChannel(**opts)
lay1.addWidget(graph, 0, 0)
[docs]
class GraphWave(QWidget):
"""Show the graphs of Pulse Amplitude, Pulse Phase and Raw Data."""
def __init__(
self, parent=None, dev='', prop='Amp', main_dev='', channel='CH1', prefix=''):
"""."""
super().__init__(parent=parent)
self.prefix = prefix
self.main_dev = main_dev
self.dev = dev
self.prop = prop
self.channel = channel
self._setupui()
def _setupui(self):
"""."""
chart_name = self.prop
basename = self.prefix + self.main_dev + self.dev
lay1 = QGridLayout()
self.setLayout(lay1)
graph = SiriusWaveformPlot(self)
graph.setObjectName('graph')
graph.setStyleSheet('#graph {min-height: 15em; min-width: 20em;}')
graph.maxRedrawRate = 2
graph.setShowXGrid(True)
graph.setShowYGrid(True)
graph.setBackgroundColor(QColor(_util.get_appropriate_color('LI')))
graph.setShowLegend(True)
graph.plotItem.showButtons()
graph.setAxisColor(QColor(0, 0, 0))
graph.setXLabels(["Time"])
axx = graph.plotItem.getAxis('right')
axx.setVisible(True)
axx.setTicks([])
axx.setWidth(0)
axx = graph.plotItem.getAxis('top')
axx.setVisible(True)
axx.setTicks([])
axx.setHeight(0)
if self.prop == 'PAmp':
chart_name = 'Amplitude Waveform'
chname = basename + ':WF_' + self.channel + 'AMP'
elif self.prop == 'PPha':
chart_name = 'Phase Waveform'
chname = basename + ':WF_' + self.channel + 'PHASE'
elif self.prop == 'Raw':
chart_name = 'Raw Data'
chname = basename + ':WF_ADC9'
else:
raise ValueError('channel not define for property '+self.prop)
graph.setPlotTitle(chart_name)
graph.setYLabels([chart_name])
opts = dict(
y_channel=chname,
name='Data',
color='black',
lineStyle=1,
lineWidth=3,
symbol='o',
symbolSize=10)
graph.addChannel(**opts)
lay1.addWidget(graph, 0, 0)