pvplot 0.7.0__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pvplot-0.7.0 → pvplot-1.0.0}/PKG-INFO +1 -1
- pvplot-1.0.0/config/pvplot_PeakSimulator.py +48 -0
- pvplot-1.0.0/config.py +48 -0
- pvplot-1.0.0/config_proposal.py +40 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/pvplot/__main__.py +2 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/pvplot/helptxt.py +1 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/pvplot/pvplot.py +153 -161
- {pvplot-0.7.0 → pvplot-1.0.0}/pyproject.toml +1 -1
- {pvplot-0.7.0 → pvplot-1.0.0}/LICENSE +0 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/README.md +0 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/cad_epics/__init__.py +0 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/cad_epics/epics.py +0 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/pvplot/__init__.py +0 -0
- {pvplot-0.7.0 → pvplot-1.0.0}/pvplot/pvplot_tmp.py +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
""" Pvplot configuration for litePeakSimulator, serving port 9710 at localhost.
|
|
2
|
+
The command line to start litePeakSimulator:
|
|
3
|
+
python3 -m liteserver.device.litePeakSimulator -ilo -p9710
|
|
4
|
+
"""
|
|
5
|
+
configFormat='pvplot'
|
|
6
|
+
TITLE="PeakSimulator"
|
|
7
|
+
|
|
8
|
+
""" The following variables are not handled yet:
|
|
9
|
+
YES = 1
|
|
10
|
+
POLLPERIOD = 0
|
|
11
|
+
MINPOLLPERIOD = 0
|
|
12
|
+
POLLBEFOREASYNC = 1
|
|
13
|
+
AVERAGETYPE = none
|
|
14
|
+
LOGFORMAT = logger
|
|
15
|
+
LOGPERIODSEC = 0
|
|
16
|
+
LOGMETHOD = 'continuous'
|
|
17
|
+
LOGDESCRIPTION = ""
|
|
18
|
+
LOGCORRELATION = 'NOTREQUIRED'
|
|
19
|
+
FILLDATA = YES
|
|
20
|
+
LOGTREEPATH = '/operations/app_store/RunData/currentFill/'
|
|
21
|
+
PREFERREDLOGDISPLAY = Snapshot
|
|
22
|
+
XLABEL = "Time (us)"
|
|
23
|
+
YLABEL = "V"
|
|
24
|
+
DATASTAMPTYPE = 'WCTPERIOD'
|
|
25
|
+
WCTCORRPERIOD_MSEC = 1000
|
|
26
|
+
WCTCORRWINDOW_MSEC = 1000
|
|
27
|
+
SYNCHRONIZED = 0
|
|
28
|
+
YMINAUTOSCALE = 2
|
|
29
|
+
YMAXAUTOSCALE = 2
|
|
30
|
+
YLOGAXIS = 0
|
|
31
|
+
Y2LABEL = ""
|
|
32
|
+
Y2MINAUTOSCALE = 2
|
|
33
|
+
Y2MAXAUTOSCALE = 2
|
|
34
|
+
Y2LOGAXIS = 0
|
|
35
|
+
ERRORBARS = 0
|
|
36
|
+
FONTTYPE = 'Medium'
|
|
37
|
+
KEEPPREVIOUS = 0
|
|
38
|
+
"""
|
|
39
|
+
dev='L:localhost;9710:dev1:'
|
|
40
|
+
|
|
41
|
+
DOCKS = [
|
|
42
|
+
{'YMax':f'device({dev}yMax)',
|
|
43
|
+
'YMin':f'device({dev}yMin)',
|
|
44
|
+
'Y[10]':f'device({dev}y[500])',
|
|
45
|
+
},
|
|
46
|
+
{'YvsX':(f'device({dev}x)',f'device({dev}y)'),
|
|
47
|
+
}
|
|
48
|
+
]
|
pvplot-1.0.0/config.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
""" Pvplot configuration for litePeakSimulator, serving port 9710 at localhost.
|
|
2
|
+
The command line to start litePeakSimulator:
|
|
3
|
+
python3 -m liteserver.device.litePeakSimulator -ilo -p9710
|
|
4
|
+
"""
|
|
5
|
+
configFormat='pvplot'
|
|
6
|
+
TITLE="PeakSimulator"
|
|
7
|
+
|
|
8
|
+
""" The following variables are not handled yet:
|
|
9
|
+
YES = 1
|
|
10
|
+
POLLPERIOD = 0
|
|
11
|
+
MINPOLLPERIOD = 0
|
|
12
|
+
POLLBEFOREASYNC = 1
|
|
13
|
+
AVERAGETYPE = none
|
|
14
|
+
LOGFORMAT = logger
|
|
15
|
+
LOGPERIODSEC = 0
|
|
16
|
+
LOGMETHOD = 'continuous'
|
|
17
|
+
LOGDESCRIPTION = ""
|
|
18
|
+
LOGCORRELATION = 'NOTREQUIRED'
|
|
19
|
+
FILLDATA = YES
|
|
20
|
+
LOGTREEPATH = '/operations/app_store/RunData/currentFill/'
|
|
21
|
+
PREFERREDLOGDISPLAY = Snapshot
|
|
22
|
+
XLABEL = "Time (us)"
|
|
23
|
+
YLABEL = "V"
|
|
24
|
+
DATASTAMPTYPE = 'WCTPERIOD'
|
|
25
|
+
WCTCORRPERIOD_MSEC = 1000
|
|
26
|
+
WCTCORRWINDOW_MSEC = 1000
|
|
27
|
+
SYNCHRONIZED = 0
|
|
28
|
+
YMINAUTOSCALE = 2
|
|
29
|
+
YMAXAUTOSCALE = 2
|
|
30
|
+
YLOGAXIS = 0
|
|
31
|
+
Y2LABEL = ""
|
|
32
|
+
Y2MINAUTOSCALE = 2
|
|
33
|
+
Y2MAXAUTOSCALE = 2
|
|
34
|
+
Y2LOGAXIS = 0
|
|
35
|
+
ERRORBARS = 0
|
|
36
|
+
FONTTYPE = 'Medium'
|
|
37
|
+
KEEPPREVIOUS = 0
|
|
38
|
+
"""
|
|
39
|
+
dev='L:localhost;9710:dev1:'
|
|
40
|
+
|
|
41
|
+
DOCKS = [
|
|
42
|
+
{'YMax':f'device({dev}yMax)',
|
|
43
|
+
'YMin':f'device({dev}yMin)',
|
|
44
|
+
'Y[10]':f'device({dev}y[500])',
|
|
45
|
+
},
|
|
46
|
+
{'YvsX':(f'device({dev}x)',f'device({dev}y)'),
|
|
47
|
+
}
|
|
48
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
configFormat='pvplot'
|
|
2
|
+
TITLE="Blue Injection Scope"
|
|
3
|
+
POLLPERIOD 0
|
|
4
|
+
MINPOLLPERIOD 0
|
|
5
|
+
POLLBEFOREASYNC 1
|
|
6
|
+
AVERAGETYPE none
|
|
7
|
+
LOGFORMAT logger
|
|
8
|
+
LOGPERIODSEC 0
|
|
9
|
+
LOGMETHOD continuous
|
|
10
|
+
LOGDESCRIPTION ""
|
|
11
|
+
LOGCORRELATION NOTREQUIRED
|
|
12
|
+
FILLDATA YES
|
|
13
|
+
LOGTREEPATH /operations/app_store/RunData/currentFill/
|
|
14
|
+
PREFERREDLOGDISPLAY Snapshot
|
|
15
|
+
XLABEL "Time (us)"
|
|
16
|
+
YLABEL "kV (at 1 V/div)"
|
|
17
|
+
DATASTAMPTYPE WCTPERIOD
|
|
18
|
+
WCTCORRPERIOD_MSEC 1000
|
|
19
|
+
WCTCORRWINDOW_MSEC 1000
|
|
20
|
+
SYNCHRONIZED 0
|
|
21
|
+
YMINAUTOSCALE 2
|
|
22
|
+
YMAXAUTOSCALE 2
|
|
23
|
+
YLOGAXIS 0
|
|
24
|
+
Y2LABEL ""
|
|
25
|
+
Y2MINAUTOSCALE 2
|
|
26
|
+
Y2MAXAUTOSCALE 2
|
|
27
|
+
Y2LOGAXIS 0
|
|
28
|
+
ERRORBARS 0
|
|
29
|
+
FONTTYPE Medium
|
|
30
|
+
KEEPPREVIOUS 0
|
|
31
|
+
SNAPREFRESHMODE 2
|
|
32
|
+
SNAPSUBCYCLES 1 2 3 4 5 6 7 8 9 10
|
|
33
|
+
|
|
34
|
+
dev='tek5Scope.inject7W_blu:'
|
|
35
|
+
|
|
36
|
+
#STATIC Time= 1.e6*device(tek5Scope.inject7W_blu:tAxis[*])
|
|
37
|
+
DOCKS =
|
|
38
|
+
[
|
|
39
|
+
{f'Module{i}':f'device({dev}c{i}WaveforM:value[*])*a+b' for i in [1,2,3,4]}
|
|
40
|
+
]
|
|
@@ -17,6 +17,8 @@ def main():
|
|
|
17
17
|
"Prefix, which will be added to all data objects, e.g: 'L:localhost:dev1:'")
|
|
18
18
|
#TODO:parser.add_argument('-H', '--histogram', help=\
|
|
19
19
|
# 'Plot the space-separated parameters as histograms')
|
|
20
|
+
parser.add_argument('-f', '--file', help=
|
|
21
|
+
'Configuration file')
|
|
20
22
|
parser.add_argument('-l', '--limit', type=int, default=1048576,
|
|
21
23
|
help='Upper limit for number of points to store')
|
|
22
24
|
parser.add_argument('-s', '--sleepTime', type=float, default=0.1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""Plotting package for EPICS PVs, ADO and LITE parameters.
|
|
3
3
|
"""
|
|
4
|
-
__version__ = '
|
|
4
|
+
__version__ = 'v1.0.0 2024-07-26'# configuration file, shortcuts,
|
|
5
5
|
#TODO: if backend times out the gui is not responsive
|
|
6
6
|
#TODO: move Add Dataset to Dataset options
|
|
7
7
|
#TODO: add dataset arithmetics
|
|
@@ -17,6 +17,7 @@ from pyqtgraph import dockarea
|
|
|
17
17
|
from functools import partial
|
|
18
18
|
from collections import deque
|
|
19
19
|
import traceback
|
|
20
|
+
from importlib import import_module
|
|
20
21
|
|
|
21
22
|
#````````````````````````````Constants````````````````````````````````````````
|
|
22
23
|
X,Y = 0,1
|
|
@@ -102,7 +103,6 @@ def get_pv(adopar:str, prop='value'):
|
|
|
102
103
|
return val, ts
|
|
103
104
|
|
|
104
105
|
def change_plotOption(curveName,color=None,width=None,symbolSize=None,scolor=None):
|
|
105
|
-
printv('change_plotOption color,width,size,color: '+str((color,width,symbolSize,scolor)))
|
|
106
106
|
dataset = MapOfDatasets.dtsDict[curveName]
|
|
107
107
|
if color != None:
|
|
108
108
|
prop = 'color'
|
|
@@ -135,27 +135,6 @@ def split_slice(parNameSlice):
|
|
|
135
135
|
vslice = (r0, int(vrange[1]))
|
|
136
136
|
return devParSlice[0], vslice
|
|
137
137
|
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
138
|
-
|
|
139
|
-
def new_dock(dataset):
|
|
140
|
-
docks = [x.split('.')[0] for x in MapOfDatasets.dtsDict]
|
|
141
|
-
i = 0
|
|
142
|
-
while '#'+str(i) in docks: i += 1
|
|
143
|
-
v = '#'+str(i)+' '+dataset
|
|
144
|
-
printv('adding plot: '+str(v))
|
|
145
|
-
|
|
146
|
-
def close_dock(dname):
|
|
147
|
-
"""remove datasets and curves and close the dock widget"""
|
|
148
|
-
print('closing dock '+dname)
|
|
149
|
-
for curveName in MapOfDatasets.dtsDict.keys():
|
|
150
|
-
printv('looking: '+curveName)
|
|
151
|
-
dock = curveName.split('.')[0]
|
|
152
|
-
if dock == dname:
|
|
153
|
-
printv('removing: '+curveName)
|
|
154
|
-
MapOfDatasets.remove(curveName)
|
|
155
|
-
printv('MapOfDatasets.dtsDict: '+str(MapOfDatasets.dtsDict))
|
|
156
|
-
PVPlot.mapOfDocks[dname].close()
|
|
157
|
-
del PVPlot.mapOfPlotWidgets[dname]
|
|
158
|
-
|
|
159
138
|
def update_data():
|
|
160
139
|
""" called on QtCore.qTimer() event to update plots."""
|
|
161
140
|
tstart = timer()
|
|
@@ -188,30 +167,25 @@ def get_statistics():
|
|
|
188
167
|
txt += f'{key},\t{v["xrange"]},\t{v["mean"]},\t{v["std"]}\n'
|
|
189
168
|
return txt
|
|
190
169
|
|
|
191
|
-
def set_legend(
|
|
170
|
+
def set_legend(dockNum:int, state:bool):
|
|
192
171
|
if state: # legend enabled
|
|
193
|
-
printv('add
|
|
194
|
-
widget = PVPlot.mapOfPlotWidgets[
|
|
172
|
+
printv(f'add legends to dock{dockNum}')
|
|
173
|
+
widget = PVPlot.mapOfPlotWidgets[dockNum]
|
|
195
174
|
listOfItems = widget.getPlotItem().listDataItems()
|
|
196
175
|
l = pg.LegendItem((100,60), offset=(70,30)) # args are (size, offset)
|
|
197
176
|
l.setParentItem(widget.graphicsItem())
|
|
198
|
-
PVPlot.legend[
|
|
177
|
+
PVPlot.legend[dockNum] = l
|
|
199
178
|
for item in listOfItems:
|
|
200
179
|
iname = item.name()
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
ltxt = txt.rsplit(':',1)[-1]
|
|
204
|
-
if '[' in txt:
|
|
205
|
-
ltxt = ':'.join(txt.rsplit(':',2)[-2:])
|
|
206
|
-
printv('set_legend: '+iname+' par: '+ltxt)
|
|
207
|
-
l.addItem(item, ltxt)
|
|
180
|
+
printv(f'set_legend {iname} in dock{dockNum}')
|
|
181
|
+
l.addItem(item, iname)
|
|
208
182
|
else: # legend disabled
|
|
209
|
-
printv('remove legend from '
|
|
183
|
+
printv(f'remove legend from dock{dockNum}')
|
|
210
184
|
try:
|
|
211
|
-
PVPlot.legend[
|
|
212
|
-
del PVPlot.legend[
|
|
185
|
+
PVPlot.legend[dockNum].scene().removeItem(PVPlot.legend[dockNum])
|
|
186
|
+
del PVPlot.legend[dockNum]
|
|
213
187
|
except Exception as e:
|
|
214
|
-
printe('failed to remove legend '+
|
|
188
|
+
printe('failed to remove legend '+dockNum+':'+str(e))
|
|
215
189
|
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
|
216
190
|
#```````````````````````````DateAxis class: time scale for bottom plot scale``
|
|
217
191
|
class DateAxis(pg.AxisItem):
|
|
@@ -241,7 +215,8 @@ class DateAxis(pg.AxisItem):
|
|
|
241
215
|
class Dataset():
|
|
242
216
|
""" dataset storage, keeps everything what is necessary to plot the curve.
|
|
243
217
|
"""
|
|
244
|
-
def __init__(self,name,paramAndCount):
|
|
218
|
+
def __init__(self, dockNum:int, name, paramAndCount):
|
|
219
|
+
self.dockNum = dockNum
|
|
245
220
|
self.name = name
|
|
246
221
|
self.adoPars = paramAndCount # list of max 2 of (adoPar,count)
|
|
247
222
|
self.plotItem = None # plotting object PlotDataItem
|
|
@@ -249,7 +224,6 @@ class Dataset():
|
|
|
249
224
|
self.width = 1 # pen width
|
|
250
225
|
self.lastTimePlotted = 0.
|
|
251
226
|
self.lastTimeUpdated = 0.
|
|
252
|
-
self.timestampReported = 0 # time of the last title update
|
|
253
227
|
self.plotWidget = None
|
|
254
228
|
self.viewBox = None
|
|
255
229
|
# members for stripchart plot
|
|
@@ -273,49 +247,40 @@ class Dataset():
|
|
|
273
247
|
self.statistics = {}
|
|
274
248
|
|
|
275
249
|
# ``````````````````` Add plotItem ``````````````````````````````````````
|
|
276
|
-
|
|
277
|
-
printv('plotItem for: '+str([s for s in self.adoPars])+', name:'+str(
|
|
250
|
+
#dockNum = name.split('.')[0]
|
|
251
|
+
printv('plotItem for: '+str([s for s in self.adoPars])+', name:'+str(dockNum))
|
|
278
252
|
initialWidth = 16
|
|
279
253
|
self.data = [np.empty(initialWidth),np.empty(initialWidth)]# [X,U] data storage
|
|
280
254
|
self.dataPtr = 0
|
|
281
255
|
count = self.adoPars[0][1] #
|
|
282
256
|
printv(f'adoPars,count: {self.adoPars,count}')
|
|
283
|
-
|
|
284
|
-
# create plotItem with proper pen
|
|
285
|
-
lineNumber = 0
|
|
286
|
-
try: lineNumber = int(name.split('.')[1])
|
|
287
|
-
except: pass
|
|
288
257
|
isCorrelationPlot = len(self.adoPars) >= 2
|
|
289
|
-
self.pen = pg.mkPen(lineNumber)
|
|
290
|
-
if self.adoPars[0][0] == '':
|
|
291
|
-
printv('no dataset - no plotItem')
|
|
292
|
-
else:
|
|
293
|
-
self.plotItem = pg.PlotDataItem(name=name, pen=self.pen)
|
|
294
258
|
|
|
295
259
|
# assign the plotwidget
|
|
296
|
-
if
|
|
260
|
+
if dockNum in PVPlot.mapOfPlotWidgets:
|
|
297
261
|
# dock already exist, use the existing plotwidget
|
|
298
|
-
self.plotWidget = PVPlot.mapOfPlotWidgets[
|
|
262
|
+
self.plotWidget = PVPlot.mapOfPlotWidgets[dockNum]
|
|
299
263
|
self.viewBox = self.plotWidget.getViewBox()
|
|
300
264
|
else:
|
|
301
|
-
# new dock need to be created
|
|
265
|
+
# viewbox for new dock need to be created
|
|
302
266
|
# create vewBox with plotwidget
|
|
303
|
-
self.viewBox = CustomViewBox(
|
|
267
|
+
self.viewBox = CustomViewBox(dockNum, self)
|
|
304
268
|
self.viewBox.setMouseMode(self.viewBox.RectMode)
|
|
305
269
|
self.viewBox.sigRangeChangedManually.connect(self.xrangeChanged)
|
|
306
|
-
printv('Creating new dock
|
|
270
|
+
printv(f'Creating new dock{dockNum}')
|
|
307
271
|
title = None
|
|
308
272
|
if count == 1 and not isCorrelationPlot:
|
|
309
273
|
self.plotWidget = pg.PlotWidget(title=title, viewBox=self.viewBox,
|
|
310
274
|
axisItems={'bottom':DateAxis(orientation='bottom')})
|
|
311
275
|
self.timeAxis = True
|
|
312
|
-
if
|
|
313
|
-
|
|
276
|
+
if dockNum != 0:
|
|
277
|
+
self.plotWidget.setXLink(PVPlot.mapOfPlotWidgets[0])
|
|
314
278
|
else:
|
|
315
279
|
self.plotWidget = pg.PlotWidget(title=title, viewBox=self.viewBox)
|
|
316
280
|
#self.plotWidget.showGrid(True,True)
|
|
317
|
-
PVPlot.mapOfPlotWidgets[
|
|
318
|
-
PVPlot.mapOfDocks[
|
|
281
|
+
PVPlot.mapOfPlotWidgets[dockNum] = self.plotWidget
|
|
282
|
+
PVPlot.mapOfDocks[dockNum].addWidget(self.plotWidget)
|
|
283
|
+
printv(f'docks: {PVPlot.mapOfDocks.keys()}, widgets: {PVPlot.mapOfPlotWidgets.keys()}')
|
|
319
284
|
if isCorrelationPlot:
|
|
320
285
|
self.plotWidget.setLabel('bottom',self.adoPars[1][0])
|
|
321
286
|
elif count == 1:
|
|
@@ -333,6 +298,14 @@ class Dataset():
|
|
|
333
298
|
r = [float(i) for i in v[0].split(':')]
|
|
334
299
|
func(*r)
|
|
335
300
|
|
|
301
|
+
# create plotItem with proper pen
|
|
302
|
+
lineNumber = len(PVPlot.mapOfPlotWidgets[self.dockNum].getPlotItem().listDataItems())
|
|
303
|
+
self.pen = pg.mkPen(lineNumber)
|
|
304
|
+
if self.adoPars[0][0] == '':
|
|
305
|
+
printv('no dataset - no plotItem')
|
|
306
|
+
else:
|
|
307
|
+
self.plotItem = pg.PlotDataItem(name=name, pen=self.pen)
|
|
308
|
+
|
|
336
309
|
if self.plotItem:
|
|
337
310
|
self.plotWidget.addItem(self.plotItem)
|
|
338
311
|
self.lastTimePlotted = 0.
|
|
@@ -504,46 +477,43 @@ class Dataset():
|
|
|
504
477
|
class MapOfDatasets():
|
|
505
478
|
"""Global dictionary of Datasets, provides safe methods to add and remove
|
|
506
479
|
the datasets"""
|
|
507
|
-
dtsDict = {}
|
|
480
|
+
dtsDict = {} #{curveName:dataset,,,}
|
|
508
481
|
|
|
509
|
-
def add(
|
|
482
|
+
def add(dockNum:int, mapOfCurves):
|
|
510
483
|
"""add new datasets, the adoPars is the space delimited string of
|
|
511
484
|
source ado:parameters."""
|
|
512
|
-
printv(f'>MapOfDatasets.add({
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
pnameAndCount = [];
|
|
519
|
-
alist = token.split(',')
|
|
520
|
-
#alist = alist[:2] # we cannot handle more than 2 curves in correlation plot
|
|
521
|
-
if len(alist) == 0:
|
|
522
|
-
#MapOfDatasets.dtsDict[dname] = Dataset(dname,[('',0)])
|
|
523
|
-
#print(f'added dataset {str(MapOfDatasets.dtsDict[dname])}')
|
|
524
|
-
print(f'Logic error: MapOfDatasets({adoPars})')
|
|
525
|
-
sys.exit(1)
|
|
485
|
+
printv(f'>MapOfDatasets.add({dockNum, mapOfCurves})')
|
|
486
|
+
for i, kv in enumerate(mapOfCurves.items()):
|
|
487
|
+
curveName,devList = kv
|
|
488
|
+
printv(f'curveName: {curveName,devList}')
|
|
489
|
+
if isinstance(devList,str):
|
|
490
|
+
devList = [devList]
|
|
526
491
|
else:
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
492
|
+
devList = list(devList)
|
|
493
|
+
devList.reverse()
|
|
494
|
+
pnameAndCount = []
|
|
495
|
+
for adoPar in devList:
|
|
496
|
+
printv(f'adoPar: {adoPar}')
|
|
497
|
+
if adoPar.startswith('device('):
|
|
498
|
+
e = adoPar.index(')')
|
|
499
|
+
rest = adoPar[e+1:]# it could be arithmetics
|
|
500
|
+
adoPar = adoPar[7:e]
|
|
501
|
+
try:
|
|
502
|
+
printv(f'check if {adoPar}, is alive')
|
|
503
|
+
valts = get_pv(adoPar) # check if parameter is alive
|
|
504
|
+
if valts is None:
|
|
505
|
+
printw('Could not add {adoPar}')
|
|
506
|
+
return 2
|
|
507
|
+
except Exception as e:
|
|
508
|
+
printw(f'Exception in getting parameter {adoPar}: {e}')
|
|
509
|
+
return 1
|
|
510
|
+
val,ts = valts
|
|
511
|
+
try: count = len(val)
|
|
512
|
+
except: count = 1
|
|
513
|
+
pnameAndCount.append((adoPar,count))
|
|
514
|
+
printv('adding '+str(pnameAndCount)+' to datasets['+curveName+']')
|
|
515
|
+
MapOfDatasets.dtsDict[curveName] = Dataset(dockNum, curveName, pnameAndCount)
|
|
516
|
+
printv(f'MapOfDatasets: {[(k,v.adoPars) for k ,v in MapOfDatasets.dtsDict.items()]}')
|
|
547
517
|
return 0
|
|
548
518
|
|
|
549
519
|
def remove(name):
|
|
@@ -552,7 +522,7 @@ class MapOfDatasets():
|
|
|
552
522
|
dataset.plotWidget.removeItem(dataset.plotItem)
|
|
553
523
|
del MapOfDatasets.dtsDict[dataset.name]
|
|
554
524
|
|
|
555
|
-
class PopupWindow(QW.QWidget):
|
|
525
|
+
class PopupWindow(QW.QWidget):
|
|
556
526
|
""" This "window" is a QWidget. If it has no parent, it
|
|
557
527
|
will appear as a free-floating window as we want.
|
|
558
528
|
Note: The created window will not be closed on app exit.
|
|
@@ -573,12 +543,12 @@ class PopupWindow(QW.QWidget):
|
|
|
573
543
|
class CustomViewBox(pg.ViewBox):
|
|
574
544
|
""" defines actions, activated on the right mouse click in the dock
|
|
575
545
|
"""
|
|
576
|
-
def __init__(self,
|
|
577
|
-
#self.
|
|
546
|
+
def __init__(self, dockNum:int, dataset):
|
|
547
|
+
#self.dockNum = kwds['name'] # cannot use name due to an issue in demo
|
|
578
548
|
#del kwds['name'] # the name in ViewBox.init fails in demo
|
|
579
|
-
self.
|
|
549
|
+
self.dockNum = dockNum
|
|
580
550
|
self.dataset = dataset# master dataset, it defines horizontal axis
|
|
581
|
-
#print('CustomViewBox: '+str(self.
|
|
551
|
+
#print('CustomViewBox: '+str(self.dockNum))
|
|
582
552
|
|
|
583
553
|
# call the init method of the parent class
|
|
584
554
|
super(CustomViewBox, self).__init__()
|
|
@@ -607,9 +577,9 @@ class CustomViewBox(pg.ViewBox):
|
|
|
607
577
|
if self.menu:
|
|
608
578
|
printv('menu exist')
|
|
609
579
|
return self.menu
|
|
610
|
-
printv('getContextMenus for '+str(self.
|
|
580
|
+
printv('getContextMenus for '+str(self.dockNum))
|
|
611
581
|
self.menu = ViewBoxMenu(self)
|
|
612
|
-
self.menu.setTitle(
|
|
582
|
+
self.menu.setTitle(f'dock{self.dockNum} options..')
|
|
613
583
|
|
|
614
584
|
# unzoom last
|
|
615
585
|
unzoom = self.menu.addAction("&UnZoom")
|
|
@@ -687,7 +657,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
687
657
|
|
|
688
658
|
def cursorAction(self, direction):
|
|
689
659
|
angle = {'Vertical':90, 'Horizontal':0}[direction]
|
|
690
|
-
pwidget = PVPlot.mapOfPlotWidgets[self.
|
|
660
|
+
pwidget = PVPlot.mapOfPlotWidgets[self.dockNum]
|
|
691
661
|
vid = {'Vertical':0, 'Horizontal':1}[direction]
|
|
692
662
|
vr = pwidget.getPlotItem().viewRange()
|
|
693
663
|
#print(f'vid: {vid,vr[vid]}')
|
|
@@ -704,7 +674,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
704
674
|
def cursorPositionChanged(self, cursor):
|
|
705
675
|
pos = cursor.value()
|
|
706
676
|
horizontal = cursor.angle == 0.
|
|
707
|
-
pwidget = PVPlot.mapOfPlotWidgets[self.
|
|
677
|
+
pwidget = PVPlot.mapOfPlotWidgets[self.dockNum]
|
|
708
678
|
viewRange = pwidget.getPlotItem().viewRange()[horizontal]
|
|
709
679
|
if pos > viewRange[1]:
|
|
710
680
|
pwidget.removeItem(cursor)
|
|
@@ -715,21 +685,21 @@ class CustomViewBox(pg.ViewBox):
|
|
|
715
685
|
def changed_datasetOptions(self):
|
|
716
686
|
"""Dialog Plotting Options"""
|
|
717
687
|
dlg = QW.QDialog()
|
|
718
|
-
dlg.setWindowTitle("Dataset
|
|
688
|
+
dlg.setWindowTitle(f"Dataset of dock{self.dockNum}")
|
|
719
689
|
dlg.setWindowModality(QtCore.Qt.ApplicationModal)
|
|
720
690
|
dlgSize = 500,200
|
|
721
691
|
dlg.setMinimumSize(*dlgSize)
|
|
722
692
|
rowCount,columnCount = 0,6
|
|
723
693
|
tbl = QW.QTableWidget(rowCount, columnCount, dlg)
|
|
724
|
-
tbl.setHorizontalHeaderLabels(['
|
|
725
|
-
for column,width in ((1,30),(3,
|
|
694
|
+
tbl.setHorizontalHeaderLabels(['Name','PV','Color','Width','Symbol','Size','Color'])
|
|
695
|
+
for column,width in ((0,50),(1,100),(2,30),(3,80),(4,40),(5,80)): # change column widths
|
|
726
696
|
tbl.setColumnWidth(column, width)
|
|
727
697
|
tbl.setShowGrid(False)
|
|
728
698
|
tbl.setSizeAdjustPolicy(
|
|
729
699
|
QW.QAbstractScrollArea.AdjustToContents)
|
|
730
700
|
tbl.resize(*dlgSize)
|
|
731
701
|
|
|
732
|
-
listOfItems = PVPlot.mapOfPlotWidgets[self.
|
|
702
|
+
listOfItems = PVPlot.mapOfPlotWidgets[self.dockNum].getPlotItem().listDataItems()
|
|
733
703
|
for row,dataitem in enumerate(listOfItems):
|
|
734
704
|
tbl.insertRow(row)
|
|
735
705
|
curveName = dataitem.name()
|
|
@@ -738,16 +708,15 @@ class CustomViewBox(pg.ViewBox):
|
|
|
738
708
|
adoparName = dataset.adoPars[0][0]
|
|
739
709
|
|
|
740
710
|
printv(f'dataset:{adoparName}')
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
tbl.setItem(row, 0, item)
|
|
711
|
+
tbl.setItem(row, 0, QW.QTableWidgetItem(curveName))
|
|
712
|
+
tbl.setItem(row, 1, QW.QTableWidgetItem(adoparName))
|
|
744
713
|
|
|
745
714
|
# color button for line
|
|
746
715
|
colorButton = pg.ColorButton(color=dataset.pen.color())
|
|
747
716
|
colorButton.setObjectName(curveName)
|
|
748
717
|
colorButton.sigColorChanging.connect(lambda x:
|
|
749
718
|
change_plotOption(str(self.sender().objectName()),color=x.color()))
|
|
750
|
-
tbl.setCellWidget(row,
|
|
719
|
+
tbl.setCellWidget(row, 2, colorButton)
|
|
751
720
|
|
|
752
721
|
# slider for changing the line width
|
|
753
722
|
widthSlider = QW.QSlider()
|
|
@@ -757,14 +726,14 @@ class CustomViewBox(pg.ViewBox):
|
|
|
757
726
|
widthSlider.setValue(1)
|
|
758
727
|
widthSlider.valueChanged.connect(lambda x:
|
|
759
728
|
change_plotOption(str(self.sender().objectName()),width=x))
|
|
760
|
-
tbl.setCellWidget(row,
|
|
729
|
+
tbl.setCellWidget(row, 3, widthSlider)
|
|
761
730
|
|
|
762
731
|
# symbol, selected from a comboBox
|
|
763
732
|
self.symbol = QW.QComboBox() # TODO: why self?
|
|
764
733
|
for symbol in ' ostd+x': self.symbol.addItem(symbol)
|
|
765
734
|
self.symbol.setObjectName(curveName)
|
|
766
735
|
self.symbol.currentIndexChanged.connect(self.set_symbol)
|
|
767
|
-
tbl.setCellWidget(row,
|
|
736
|
+
tbl.setCellWidget(row, 4, self.symbol)
|
|
768
737
|
|
|
769
738
|
# slider for changing the line width
|
|
770
739
|
symbolSizeSlider = QW.QSlider()
|
|
@@ -774,14 +743,14 @@ class CustomViewBox(pg.ViewBox):
|
|
|
774
743
|
symbolSizeSlider.setValue(1)
|
|
775
744
|
symbolSizeSlider.valueChanged.connect(lambda x:
|
|
776
745
|
change_plotOption(str(self.sender().objectName()),symbolSize=x))
|
|
777
|
-
tbl.setCellWidget(row,
|
|
746
|
+
tbl.setCellWidget(row, 5, symbolSizeSlider)
|
|
778
747
|
|
|
779
748
|
# color button for symbol
|
|
780
749
|
symbolColorButton = pg.ColorButton(color=dataset.pen.color())
|
|
781
750
|
symbolColorButton.setObjectName(curveName)
|
|
782
751
|
symbolColorButton.sigColorChanging.connect(lambda x:
|
|
783
752
|
change_plotOption(str(self.sender().objectName()),scolor=x.color()))
|
|
784
|
-
tbl.setCellWidget(row,
|
|
753
|
+
tbl.setCellWidget(row, 6,symbolColorButton)
|
|
785
754
|
dlg.exec_()
|
|
786
755
|
|
|
787
756
|
def set_symbol(self, x):
|
|
@@ -803,7 +772,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
803
772
|
pass
|
|
804
773
|
|
|
805
774
|
def set_label(self,side,labelGui):
|
|
806
|
-
dock,label = self.
|
|
775
|
+
dock,label = self.dockNum,str(labelGui.text())
|
|
807
776
|
printv('changed_label '+side+': '+str((dock,label)))
|
|
808
777
|
PVPlot.mapOfPlotWidgets[dock].setLabel(side,label, units='')
|
|
809
778
|
# it might be useful to return the prompt back:
|
|
@@ -811,8 +780,7 @@ class CustomViewBox(pg.ViewBox):
|
|
|
811
780
|
|
|
812
781
|
def set_legend(self, state):
|
|
813
782
|
state = (state==QtCore.Qt.Checked)
|
|
814
|
-
|
|
815
|
-
set_legend(self.dockName, state)
|
|
783
|
+
set_legend(self.dockNum, state)
|
|
816
784
|
|
|
817
785
|
def set_stop(self, state):
|
|
818
786
|
PVPlot.stop(state == QtCore.Qt.Checked)
|
|
@@ -871,29 +839,27 @@ def callback(args):
|
|
|
871
839
|
printv(f'axis={axis}, units={units}, scale={scale}')
|
|
872
840
|
PVPlot.scaleUnits[axis][Scale] = scale
|
|
873
841
|
|
|
874
|
-
def add_curves(
|
|
842
|
+
def add_curves(dockNum:int, curveMap:str):
|
|
875
843
|
# if dock name is new then create new dock, otherwise extend the
|
|
876
844
|
# existing one with new curve
|
|
877
845
|
|
|
878
|
-
curves = [x for x in MapOfDatasets.dtsDict]
|
|
879
|
-
docks = [x.split('.')[0] for x in curves]
|
|
846
|
+
#curves = [x for x in MapOfDatasets.dtsDict]
|
|
847
|
+
#docks = [x.split('.')[0] for x in curves]
|
|
848
|
+
curves = MapOfDatasets.dtsDict.keys()
|
|
849
|
+
docks = PVPlot.mapOfDocks.keys()
|
|
880
850
|
printv(f'>addcurves curves,docks:{curves,docks}')
|
|
881
|
-
if
|
|
882
|
-
printv('
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
printv('adding new dock '+dock)
|
|
889
|
-
PVPlot.mapOfDocks[dock] = dockarea.Dock(dock, size=(500,200), hideTitle=True)
|
|
890
|
-
if dock == '#0':
|
|
891
|
-
PVPlot.dockArea.addDock(PVPlot.mapOfDocks[dock], 'right', closable=True)
|
|
851
|
+
if dockNum not in docks:
|
|
852
|
+
printv(f'adding new dock{dockNum}')
|
|
853
|
+
PVPlot.mapOfDocks[dockNum] = dockarea.Dock(str(dockNum),
|
|
854
|
+
size=(500,200), hideTitle=True)
|
|
855
|
+
if dockNum == 0:
|
|
856
|
+
PVPlot.dockArea.addDock(PVPlot.mapOfDocks[dockNum], 'right',
|
|
857
|
+
closable=True)
|
|
892
858
|
else:
|
|
893
|
-
PVPlot.dockArea.addDock(PVPlot.mapOfDocks[
|
|
894
|
-
'top', PVPlot.mapOfDocks[
|
|
895
|
-
if MapOfDatasets.add(
|
|
896
|
-
printe('in add_curves:
|
|
859
|
+
PVPlot.dockArea.addDock(PVPlot.mapOfDocks[dockNum],
|
|
860
|
+
'top', PVPlot.mapOfDocks[0], closable=True) #TODO:closable does not work
|
|
861
|
+
if MapOfDatasets.add(dockNum, curveMap):
|
|
862
|
+
printe(f'in add_curves: {dockNum, curveMap}')
|
|
897
863
|
|
|
898
864
|
def excepthook(exc_type, exc_value, exc_tb):
|
|
899
865
|
"""To uncover exceptions, missed in Qt"""
|
|
@@ -903,10 +869,33 @@ def excepthook(exc_type, exc_value, exc_tb):
|
|
|
903
869
|
QtWidgets.QApplication.quit()
|
|
904
870
|
# or QtWidgets.QApplication.exit(0)
|
|
905
871
|
|
|
872
|
+
class tmpClass():
|
|
873
|
+
DOCKS = [{}]
|
|
874
|
+
|
|
875
|
+
def parse_input_parameters(pargs):
|
|
876
|
+
fn = pargs.file
|
|
877
|
+
print(f'fn:`{fn}`')
|
|
878
|
+
if fn:
|
|
879
|
+
print(f'importing {fn}')
|
|
880
|
+
try:
|
|
881
|
+
ConfigModule = import_module(fn)
|
|
882
|
+
configFormat = ConfigModule.configFormat
|
|
883
|
+
except ModuleNotFoundError as e:
|
|
884
|
+
printe(f'Trying to import {fn}: {e}')
|
|
885
|
+
sys.exit(0)
|
|
886
|
+
return ConfigModule
|
|
887
|
+
else:
|
|
888
|
+
for parm in pargs.parms.split():
|
|
889
|
+
parms = (pargs.prefix+parm).split(',')
|
|
890
|
+
if len(parms) == 2:
|
|
891
|
+
parms = (parms[0],pargs.prefix+parms[1])
|
|
892
|
+
tmpClass.DOCKS[0][parm] = parms
|
|
893
|
+
return tmpClass
|
|
894
|
+
|
|
906
895
|
class PVPlot():
|
|
907
896
|
pargs = None
|
|
908
|
-
mapOfDocks = {}
|
|
909
897
|
mapOfPlotWidgets = {}
|
|
898
|
+
mapOfDocks = {}
|
|
910
899
|
padding = 0.1
|
|
911
900
|
scaleUnits = [[1,'Sample'],[1,'Count']]
|
|
912
901
|
subscribedParMap = {}
|
|
@@ -938,8 +927,6 @@ class PVPlot():
|
|
|
938
927
|
pg.setConfigOption('background', 'w')
|
|
939
928
|
pg.setConfigOption('foreground', 'k')
|
|
940
929
|
|
|
941
|
-
PVPlot.qWin.setWindowTitle(f'pvplot {pargs.parms}')
|
|
942
|
-
|
|
943
930
|
# Shortcuts
|
|
944
931
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+H"), PVPlot.qWin)
|
|
945
932
|
shortcut.activated.connect(PVPlot.actionHelp)
|
|
@@ -947,27 +934,26 @@ class PVPlot():
|
|
|
947
934
|
shortcut.activated.connect(partial(PVPlot.actionStop,True))
|
|
948
935
|
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+Q"), PVPlot.qWin)
|
|
949
936
|
shortcut.activated.connect(partial(PVPlot.actionStop,False))
|
|
950
|
-
|
|
951
|
-
|
|
937
|
+
shortcut = QW.QShortcut(QtGui.QKeySequence("Ctrl+U"), PVPlot.qWin)
|
|
938
|
+
shortcut.activated.connect(PVPlot.actionUnzoom)
|
|
952
939
|
from . import helptxt
|
|
953
940
|
PVPlot.helptxt = helptxt.txt
|
|
954
941
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
add_curves('#0', pargs.parms)
|
|
942
|
+
configModule = parse_input_parameters(pargs)
|
|
943
|
+
try: title = configModule.TITLE
|
|
944
|
+
except: title = f'pvplot {pargs.parms}'
|
|
945
|
+
PVPlot.qWin.setWindowTitle(title)
|
|
946
|
+
dockList = configModule.DOCKS
|
|
947
|
+
for dockNum,curveMap in enumerate(dockList):
|
|
948
|
+
printv(f'add_curves to dock{dockNum}, {curveMap}')
|
|
949
|
+
add_curves(dockNum, curveMap)
|
|
950
|
+
|
|
965
951
|
if len(MapOfDatasets.dtsDict) == 0:
|
|
966
952
|
printe(f'No datasets created')
|
|
967
953
|
sys.exit(1)
|
|
968
954
|
|
|
969
|
-
for
|
|
970
|
-
set_legend(
|
|
955
|
+
for dockNum in PVPlot.mapOfDocks:
|
|
956
|
+
set_legend(dockNum, True)
|
|
971
957
|
|
|
972
958
|
# Subscriptions. Only LITE system is supported.
|
|
973
959
|
if pargs.xscale is not None:
|
|
@@ -1004,19 +990,25 @@ class PVPlot():
|
|
|
1004
990
|
print('Application exited')
|
|
1005
991
|
sys.exit(ret)
|
|
1006
992
|
|
|
1007
|
-
def actionStop(state:bool):
|
|
1008
|
-
print(f'actionStop {state}')
|
|
1009
|
-
PVPlot.stop(state)
|
|
1010
|
-
|
|
1011
993
|
def stop(state):
|
|
1012
|
-
print(f'>PVPlot.stop {state}')
|
|
1013
994
|
PVPlot.stopped = state
|
|
1014
995
|
if state == True:
|
|
1015
996
|
PVPlot.qTimer.stop()
|
|
1016
997
|
else:
|
|
1017
998
|
PVPlot.qTimer.start(int(PVPlot.pargs.sleepTime*1000))
|
|
1018
999
|
|
|
1000
|
+
#``````````Shorthcut handlers
|
|
1019
1001
|
def actionHelp():
|
|
1020
1002
|
PVPlot.helpWin = PopupWindow()
|
|
1021
1003
|
PVPlot.helpWin.label.setText(PVPlot.helptxt)
|
|
1022
1004
|
PVPlot.helpWin.show()
|
|
1005
|
+
|
|
1006
|
+
def actionStop(state:bool):
|
|
1007
|
+
PVPlot.stop(state)
|
|
1008
|
+
|
|
1009
|
+
def actionUnzoom():
|
|
1010
|
+
md = PVPlot.mapOfDocks
|
|
1011
|
+
docks = md.keys()
|
|
1012
|
+
for dockNum in docks:
|
|
1013
|
+
vb = PVPlot.mapOfPlotWidgets[dockNum].getPlotItem().getViewBox()
|
|
1014
|
+
vb.unzoom()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|