pvplot 0.5.3__tar.gz → 0.6.1__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.
Files changed (34) hide show
  1. {pvplot-0.5.3 → pvplot-0.6.1}/PKG-INFO +1 -1
  2. pvplot-0.6.1/pvplot/__init__.py +1 -0
  3. pvplot-0.6.1/pvplot/__main__.py +52 -0
  4. pvplot-0.5.3/pvplot/__main__.py → pvplot-0.6.1/pvplot/pvplot.py +137 -177
  5. {pvplot-0.5.3 → pvplot-0.6.1}/pyproject.toml +1 -1
  6. pvplot-0.5.3/pvplot/__init__.py +0 -0
  7. {pvplot-0.5.3 → pvplot-0.6.1}/LICENSE +0 -0
  8. {pvplot-0.5.3 → pvplot-0.6.1}/README.md +0 -0
  9. {pvplot-0.5.3 → pvplot-0.6.1}/cad_epics/__init__.py +0 -0
  10. {pvplot-0.5.3 → pvplot-0.6.1}/cad_epics/epics.py +0 -0
  11. {pvplot-0.5.3 → pvplot-0.6.1}/fallback/__main__.py +0 -0
  12. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteaccess/.__init__.py.swp +0 -0
  13. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteaccess/__init__.py +0 -0
  14. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteaccess/liteCNS.py +0 -0
  15. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteaccess/liteaccess.py +0 -0
  16. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/__init__.py +0 -0
  17. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/__init__.py +0 -0
  18. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/helpers.py +0 -0
  19. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/i2c.py +0 -0
  20. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteCNSserver.py +0 -0
  21. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteGQ.py +0 -0
  22. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteLabjack.py +0 -0
  23. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteMCUFEC.py +0 -0
  24. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/litePeakSimulator.py +0 -0
  25. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteScaler.py +0 -0
  26. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteUSBCam.py +0 -0
  27. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteUvcCam.py +0 -0
  28. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteVGM.py +0 -0
  29. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/liteWLM.py +0 -0
  30. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/device/senstation.py +0 -0
  31. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/liteAccess.py +0 -0
  32. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/liteCNS.py +0 -0
  33. {pvplot-0.5.3 → pvplot-0.6.1}/ln/liteserver/liteserver.py +0 -0
  34. {pvplot-0.5.3 → pvplot-0.6.1}/tmp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pvplot
3
- Version: 0.5.3
3
+ Version: 0.6.1
4
4
  Summary: Plotting tool for EPICS PVs, ADO and LITE parameters
5
5
  Project-URL: Homepage, https://github.com/ASukhanov/pvplot
6
6
  Project-URL: Bug Tracker, https://github.com/ASukhanov/pvplot/issues
@@ -0,0 +1 @@
1
+ from .pvplot import __version__, PVPlot
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env python3
2
+ """Dynamic plotting tool for control system frameworks.
3
+ Frameworks supported: EPICS, ADO, LiteServer.
4
+ The framework is distinguished by adding a prefix to Process Variable names:
5
+ 'E:' - for EPICS, 'L:" - for LiteServer.
6
+ """
7
+ import sys,os
8
+ from . import pvplot
9
+
10
+ def main():
11
+ import argparse
12
+ global pargs
13
+ parser = argparse.ArgumentParser(description=__doc__
14
+ ,formatter_class=argparse.ArgumentDefaultsHelpFormatter
15
+ ,epilog=(f'pvplot: {pvplot.__version__}'))
16
+ parser.add_argument('-a', '--ado', default='L:localhost:dev1', help=\
17
+ 'Default Device/ADO name. Useful for plotting parameters from single device.')
18
+ parser.add_argument('-s', '--sleepTime', type=float, default=0.1,
19
+ help='sleep time between data delivery [s]')
20
+ parser.add_argument('-v', '--verbose', nargs='*', help=\
21
+ 'Show more log messages (-vv: show even more).')
22
+ parser.add_argument('-x', '--xscale', help=\
23
+ 'Parameter, which provides dynamic scale for X-axis')
24
+ parser.add_argument('-X', '--xrange', help=\
25
+ 'Fixed range of X axis, e.g: -x10:20')
26
+ parser.add_argument('-y', '--yscale', help=\
27
+ 'Parameter, which provides dynamic scale for Y-axis')
28
+ parser.add_argument('-Y', '--yrange', help=\
29
+ 'Fixed range of Y axis, e.g: -y1000:4095')
30
+ parser.add_argument('-z', '--zoomin', type=float, default=1., help=\
31
+ 'Zoom the application window by a factor')
32
+ parser.add_argument('-#','--dock', action='append', nargs='*',
33
+ help='''plot the ADO parameter in a specified dock, i.e: to plot the
34
+ scrolling plot in dock#1 and correlation plot in dock#2:
35
+ -#0yMax -#1yMin''')
36
+ parser.add_argument('parms', nargs = '?', default='yMax yMin',
37
+ help='''For stripchart: space-separated list, for correlation plot: comma-separated list of PVs.''')
38
+ pargs = parser.parse_args()
39
+ PVPlot = pvplot.PVPlot
40
+ PVPlot.pargs = pargs
41
+ print(f'pargs:{PVPlot.pargs}')
42
+ if pargs.ado != '':
43
+ pargs.ado += ':'
44
+
45
+ #``````````````arrange keyboard interrupt to kill the program from terminal.
46
+ import signal
47
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
48
+
49
+ PVPlot.start()
50
+
51
+ if __name__ == "__main__":
52
+ main()
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env python3
2
- """Plotting tool for EPICS PVs, ADO and LITE parameters.
2
+ """Plotting package for EPICS PVs, ADO and LITE parameters.
3
3
  """
4
- __version__ = 'v0.5.3 2023-08-26'# Fix timeout in get_pv
4
+ __version__ = 'v0.6.1 2023-08-27'# pargs.zoomin is supported
5
5
 
6
6
  #TODO: add_curves is not correct for multiple curves
7
7
  #TODO: move Add Dataset to Dataset options
8
8
  #TODO: if docks are stripcharts then zooming should be synchronized
9
9
  #TODO: add dataset arithmetics
10
10
 
11
- import sys, time, os
11
+ import sys, os, time
12
12
  timer = time.perf_counter
13
13
  import numpy as np
14
14
  from qtpy import QtWidgets as QW, QtGui, QtCore
@@ -19,43 +19,18 @@ from pyqtgraph.graphicsItems.ViewBox.ViewBoxMenu import ViewBoxMenu
19
19
  from pyqtgraph import dockarea
20
20
  from functools import partial
21
21
 
22
- #````````````````````````````Globals``````````````````````````````````````````
23
- MaxCurvesPerPlot = 10
24
- gMapOfDocks = {}
25
- pargs = None
26
- gMapOfPlotWidgets = {}
27
- Padding = 0.1
28
-
29
- # the --zoom should be handled prior to QtWidgets.QApplication
30
- for i,argv in enumerate(sys.argv):
31
- if argv.startswith('-z'):
32
- zoom = argv[2:]
33
- if zoom == '':
34
- zoom = sys.argv[i+1]
35
- print(f'zoom: `{zoom}`')
36
- os.environ["QT_SCALE_FACTOR"] = zoom
37
- break
38
- qApp = QApplication([])
39
-
40
- gTimer = QtCore.QTimer()
41
- gWin = QMainWindow()
42
- gArea = dockarea.DockArea()
22
+ #````````````````````````````Constants````````````````````````````````````````
43
23
  X,Y = 0,1
44
24
  Scale,Units = 0,1
45
- gScaleUnits = [[1,'Sample'],[1,'Count']]
46
- subscribedParMap = {}
47
- # temporary globals
48
- gPerfmon = False # option for performance monitoring
49
- #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
50
25
  #````````````````````````````Helper methods```````````````````````````````````
51
26
  def printTime(): return time.strftime("%m%d:%H%M%S")
52
- def printi(msg): print((f'INF_PvP@{printTime()}: '+msg))
53
- def printw(msg): print((f'WRN_PvP@{printTime()}: '+msg))
54
- def printe(msg): print((f'ERR_PvP@{printTime()}: '+msg))
27
+ def printi(msg): print((f'INF_PP@{printTime()}: '+msg))
28
+ def printw(msg): print((f'WRN_PP@{printTime()}: '+msg))
29
+ def printe(msg): print((f'ERR_PP@{printTime()}: '+msg))
55
30
  def _printv(msg, level=0):
56
- if pargs.verbose is None:
31
+ if PVPlot.pargs.verbose is None:
57
32
  return
58
- if len(pargs.verbose) >= level:
33
+ if len(PVPlot.pargs.verbose) >= level:
59
34
  print((f'DBG{level}_PP@{printTime()}: '+msg))
60
35
  def printv(msg): _printv(msg, 0)
61
36
  def printvv(msg): _printv(msg, 1)
@@ -99,35 +74,40 @@ except Exception as e:
99
74
  def cprint(msg):
100
75
  print('cprint:'+msg)
101
76
 
102
- gAccess = {'E:':(EPICSAccess,2), 'L:':(LITEAccess,2)}
103
77
  def get_pv(adopar:str, prop='value'):
78
+ #print(f'>get_pv {adopar}')
104
79
  adopar, vslice = split_slice(adopar)
105
- access = gAccess.get(adopar[:2], (ADOAccess,0))
106
- access,prefixLength = gAccess.get(adopar[:2], (ADOAccess,0))
80
+ access = PVPlot.access.get(adopar[:2], (ADOAccess,0))
81
+ access,prefixLength = PVPlot.access.get(adopar[:2], (ADOAccess,0))
107
82
  if access is None:
108
83
  printe(f'No access method for {adopar}')
109
84
  sys.exit(1)
110
- pvTuple = tuple(adopar[prefixLength:].rsplit(':',1))
111
- rd = access.get(pvTuple)[pvTuple]
112
- #print(f'get_pv: {val}')
113
- val = rd['value']
114
- try:
115
- shape = val.shape
116
- if len(shape) > 2:
117
- printe(f'2+dimensional arrays not supported for {dev,par}')
118
- return None
119
- except:
120
- # val does not have attribute shape
121
- pass
122
85
  try:
123
- ts = rd['timestamp']# EPICS and LITE
124
- except: # ADO
125
- ts = rd['timestampSeconds'] + rd['timestampNanoSeconds']*1.e-9
126
-
127
- #printv(f"get_pv {adopar}: {rd['value']} {vslice}")
128
- if vslice is not None:
129
- val = val[vslice[0]:vslice[1]]
130
- return val, ts
86
+ pvTuple = tuple(adopar[prefixLength:].rsplit(':',1))
87
+ rd = access.get(pvTuple)[pvTuple]
88
+ #print(f'get_pv: {val}')
89
+ val = rd['value']
90
+ try:
91
+ shape = val.shape
92
+ if len(shape) > 2:
93
+ printe(f'2+dimensional arrays not supported for {dev,par}')
94
+ return None
95
+ except:
96
+ # val does not have attribute shape
97
+ pass
98
+ try:
99
+ ts = rd['timestamp']# EPICS and LITE
100
+ except: # ADO
101
+ ts = rd['timestampSeconds'] + rd['timestampNanoSeconds']*1.e-9
102
+
103
+ #printv(f"get_pv {adopar}: {rd['value']} {vslice}")
104
+ if vslice is not None:
105
+ val = val[vslice[0]:vslice[1]]
106
+ return val, ts
107
+ except Exception as e:
108
+ printe(f'Cannot get({pvTuple}): {e}')
109
+ sys.exit(1)
110
+ return None
131
111
 
132
112
  def change_plotOption(curveName,color=None,width=None,symbolSize=None,scolor=None):
133
113
  printv('change_plotOption color,width,size,color: '+str((color,width,symbolSize,scolor)))
@@ -181,14 +161,15 @@ def close_dock(dname):
181
161
  printv('removing: '+curveName)
182
162
  MapOfDatasets.remove(curveName)
183
163
  printv('MapOfDatasets.dtsDict: '+str(MapOfDatasets.dtsDict))
184
- gMapOfDocks[dname].close()
185
- del gMapOfPlotWidgets[dname]
164
+ PVPlot.mapOfDocks[dname].close()
165
+ del PVPlot.mapOfPlotWidgets[dname]
186
166
 
187
167
  def update_data():
188
168
  """ called on QtCore.QTimer() event to update plots."""
189
169
  tstart = timer()
190
170
  for curveName,dataset in MapOfDatasets.dtsDict.items():
191
171
  curvePars = dataset.adoPars
172
+ #printvv(f'dataset: {curvePars}')#: {dataset.data}')
192
173
  dock = curveName.split('.')[0]
193
174
  yd,ts = None,None
194
175
  try:
@@ -213,7 +194,7 @@ def update_data():
213
194
  if l > 1:
214
195
  # the plot is array plot
215
196
  y = np.array(yd)
216
- x = np.arange(len(yd))*gScaleUnits[X][Scale]
197
+ x = np.arange(len(yd))*PVPlot.scaleUnits[X][Scale]
217
198
  else:
218
199
  # the plot is scrolling or correlation plot
219
200
  ptr = dataset.dataPtr
@@ -265,19 +246,18 @@ def update_data():
265
246
  symbolSize = dataset.symbolSize,
266
247
  #TODO:pxMode = dataset.pxMode,
267
248
  )
268
- if gPerfmon:
249
+ if PVPlot.perfmon:
269
250
  v = timer()-tstart
270
251
  print('update time:'+str(timer()-tstart))
271
252
 
272
- gLegend = {}# unfortunately we have to keep track of legends
273
253
  def set_legend(dockName:str, state:bool):
274
254
  if state: # legend enabled
275
255
  printv('add legend for '+str(dockName))
276
- widget = gMapOfPlotWidgets[dockName]
256
+ widget = PVPlot.mapOfPlotWidgets[dockName]
277
257
  listOfItems = widget.getPlotItem().listDataItems()
278
258
  l = pg.LegendItem((100,60), offset=(70,30)) # args are (size, offset)
279
259
  l.setParentItem(widget.graphicsItem())
280
- gLegend[dockName] = l
260
+ PVPlot.legend[dockName] = l
281
261
  '''# it should be a better way to iterate for curves in the widget
282
262
  for curveName,dataset in MapOfDatasets.dtsDict.items():
283
263
  if dockName in curveName:
@@ -295,8 +275,8 @@ def set_legend(dockName:str, state:bool):
295
275
  else: # legend disabled
296
276
  printv('remove legend from '+dockName)
297
277
  try:
298
- gLegend[dockName].scene().removeItem(gLegend[dockName])
299
- del gLegend[dockName]
278
+ PVPlot.legend[dockName].scene().removeItem(PVPlot.legend[dockName])
279
+ del PVPlot.legend[dockName]
300
280
  except Exception as e:
301
281
  printe('failed to remove legend '+dockName+':'+str(e))
302
282
  #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
@@ -378,9 +358,9 @@ class Dataset():
378
358
  #self.plotItem = pg.PlotCurveItem(name=name, pen=self.pen)
379
359
 
380
360
  # assign the plotwidget
381
- if dock in gMapOfPlotWidgets:
361
+ if dock in PVPlot.mapOfPlotWidgets:
382
362
  # dock already exist, use the existing plotwidget
383
- self.plotWidget = gMapOfPlotWidgets[dock]
363
+ self.plotWidget = PVPlot.mapOfPlotWidgets[dock]
384
364
  else:
385
365
  # new dock need to be created
386
366
  # create vewBox with plotwidget
@@ -393,22 +373,22 @@ class Dataset():
393
373
  self.plotWidget = pg.PlotWidget(title=title, viewBox=self.viewBox,
394
374
  axisItems={'bottom':DateAxis(orientation='bottom')})
395
375
  if dock != '#0':
396
- self.plotWidget.setXLink(gMapOfPlotWidgets['#0'])
376
+ self.plotWidget.setXLink(PVPlot.mapOfPlotWidgets['#0'])
397
377
  else:
398
378
  self.plotWidget = pg.PlotWidget(title=title, viewBox=self.viewBox)
399
379
  #self.plotWidget.showGrid(True,True)
400
- gMapOfPlotWidgets[dock] = self.plotWidget
401
- gMapOfDocks[dock].addWidget(self.plotWidget)
380
+ PVPlot.mapOfPlotWidgets[dock] = self.plotWidget
381
+ PVPlot.mapOfDocks[dock].addWidget(self.plotWidget)
402
382
  if isCorrelationPlot:
403
383
  self.plotWidget.setLabel('bottom',self.adoPars[1][0])
404
384
  elif count == 1:
405
385
  self.plotWidget.setLabel('bottom','time', units='date', unitPrefix='')
406
386
  else:
407
- self.plotWidget.setLabel('bottom',gScaleUnits[X][Units])
387
+ self.plotWidget.setLabel('bottom',PVPlot.scaleUnits[X][Units])
408
388
 
409
389
  # set X and Y ranges
410
- rangeMap = {X: (pargs.xrange, self.plotWidget.setXRange),
411
- Y: (pargs.yrange, self.plotWidget.setYRange)}
390
+ rangeMap = {X: (PVPlot.pargs.xrange, self.plotWidget.setXRange),
391
+ Y: (PVPlot.pargs.yrange, self.plotWidget.setYRange)}
412
392
  for axis,v in rangeMap.items():
413
393
  r,func = v
414
394
  if r is None:
@@ -439,7 +419,7 @@ class Dataset():
439
419
  def shift_viewXRange(self):
440
420
  if self.viewBox.state['autoRange'][X]:
441
421
  return
442
- dx = self.viewXSize*Padding
422
+ dx = self.viewXSize*PVPlot.padding
443
423
  self.viewXRange[0] += dx
444
424
  self.viewXRange[1] += dx
445
425
  #print(f'>shift_viewXRange: {self.viewXRange[0], self.viewXRange[1]}')
@@ -470,8 +450,8 @@ class MapOfDatasets():
470
450
  alist.reverse()
471
451
  #print(f'alist: {alist}')
472
452
  for adoPar in alist:
473
- ap = pargs.ado+adoPar
474
- #print(f'>get {ap}, {pargs.ado}')
453
+ ap = PVPlot.pargs.ado+adoPar
454
+ #print(f'>get {ap}, {PVPlot.pargs.ado}')
475
455
  try:
476
456
  valts = get_pv(ap) # check if parameter is alive
477
457
  if valts is None:
@@ -588,7 +568,7 @@ class CustomViewBox(pg.ViewBox):
588
568
  sleepTimeMenu = self.menu.addMenu('Sleep&Time')
589
569
  sleepTimeAction = QW.QWidgetAction(sleepTimeMenu)
590
570
  sleepTimeWidget = QW.QDoubleSpinBox()
591
- sleepTimeWidget.setValue(pargs.sleepTime)
571
+ sleepTimeWidget.setValue(PVPlot.pargs.sleepTime)
592
572
  sleepTimeWidget.setRange(0.001,100)
593
573
  sleepTimeWidget.setSuffix(' s')
594
574
  sleepTimeWidget.setSingleStep(.1)
@@ -599,7 +579,7 @@ class CustomViewBox(pg.ViewBox):
599
579
 
600
580
  def cursorAction(self, direction):
601
581
  angle = {'Vertical':90, 'Horizontal':0}[direction]
602
- pwidget = gMapOfPlotWidgets[self.dockName]
582
+ pwidget = PVPlot.mapOfPlotWidgets[self.dockName]
603
583
  vid = {'Vertical':0, 'Horizontal':1}[direction]
604
584
  vr = pwidget.getPlotItem().viewRange()
605
585
  #print(f'vid: {vid,vr[vid]}')
@@ -615,7 +595,7 @@ class CustomViewBox(pg.ViewBox):
615
595
  def cursorPositionChanged(self, cursor):
616
596
  pos = cursor.value()
617
597
  horizontal = cursor.angle == 0.
618
- pwidget = gMapOfPlotWidgets[self.dockName]
598
+ pwidget = PVPlot.mapOfPlotWidgets[self.dockName]
619
599
  viewRange = pwidget.getPlotItem().viewRange()[horizontal]
620
600
  if pos > viewRange[1]:
621
601
  pwidget.removeItem(cursor)
@@ -640,7 +620,7 @@ class CustomViewBox(pg.ViewBox):
640
620
  QW.QAbstractScrollArea.AdjustToContents)
641
621
  tbl.resize(*dlgSize)
642
622
 
643
- listOfItems = gMapOfPlotWidgets[self.dockName].getPlotItem().listDataItems()
623
+ listOfItems = PVPlot.mapOfPlotWidgets[self.dockName].getPlotItem().listDataItems()
644
624
  for row,dataitem in enumerate(listOfItems):
645
625
  tbl.insertRow(row)
646
626
  curveName = dataitem.name()
@@ -716,7 +696,7 @@ class CustomViewBox(pg.ViewBox):
716
696
  def set_label(self,side,labelGui):
717
697
  dock,label = self.dockName,str(labelGui.text())
718
698
  printv('changed_label '+side+': '+str((dock,label)))
719
- gMapOfPlotWidgets[dock].setLabel(side,label, units='')
699
+ PVPlot.mapOfPlotWidgets[dock].setLabel(side,label, units='')
720
700
  # it might be useful to return the prompt back:
721
701
  #labelGui.setText('LabelX' if side=='bottom' else 'LabelY')
722
702
 
@@ -727,15 +707,15 @@ class CustomViewBox(pg.ViewBox):
727
707
 
728
708
  def set_stop(self, state):
729
709
  if state == QtCore.Qt.Checked:
730
- gTimer.stop()
710
+ PVPlot.qtimer.stop()
731
711
  else:
732
- gTimer.start(int(pargs.sleepTime*1000))
712
+ PVPlot.qtimer.start(int(PVPlot.pargs.sleepTime*1000))
733
713
 
734
714
  def set_sleepTime(self, itemData):
735
715
  #print('setting SleepTime to: '+str(itemData))
736
- pargs.sleepTime = itemData
737
- gTimer.stop()
738
- gTimer.start(int(pargs.sleepTime*1000))
716
+ PVPlot.pargs.sleepTime = itemData
717
+ PVPlot.qtimer.stop()
718
+ PVPlot.qtimer.start(int(PVPlot.pargs.sleepTime*1000))
739
719
 
740
720
  def unzoom(self):
741
721
  self.rangestack.pop()
@@ -751,12 +731,12 @@ def callback(args):
751
731
  for hostDev, pardict in args.items():
752
732
  for par in pardict:
753
733
  try:
754
- axis,units = subscribedParMap[(hostDev,par)]
734
+ axis,units = PVPlot.subscribedParMap[(hostDev,par)]
755
735
  except:
756
736
  continue
757
737
  scale = pardict[par]['value'][0]
758
738
  print(f'axis={axis}, units={units}, scale={scale}')
759
- gScaleUnits[axis][Scale] = scale
739
+ PVPlot.scaleUnits[axis][Scale] = scale
760
740
 
761
741
  def add_curves(dock:str, adopars:str):
762
742
  # if dock name is new then create new dock, otherwise extend the
@@ -775,102 +755,82 @@ def add_curves(dock:str, adopars:str):
775
755
  #print(f'adding new curve {dock}')
776
756
  else:
777
757
  #print('adding new plot '+dock)
778
- gMapOfDocks[dock] = dockarea.Dock(dock, size=(500,200), hideTitle=True)
758
+ PVPlot.mapOfDocks[dock] = dockarea.Dock(dock, size=(500,200), hideTitle=True)
779
759
  if dock == '#0':
780
- gArea.addDock(gMapOfDocks[dock], 'right', closable=True)
760
+ PVPlot.dockArea.addDock(PVPlot.mapOfDocks[dock], 'right', closable=True)
781
761
  else:
782
- gArea.addDock(gMapOfDocks[dock],
783
- 'top', gMapOfDocks['#0'], closable=True) #TODO:closable does not work
762
+ PVPlot.dockArea.addDock(PVPlot.mapOfDocks[dock],
763
+ 'top', PVPlot.mapOfDocks['#0'], closable=True) #TODO:closable does not work
784
764
  if MapOfDatasets.add(dock, adopars):
785
765
  printe('in add_curves: '+str((dock, adopars)))
786
766
  #printv(f'datasets:{MapOfDatasets.dtsDict.keys()}')
787
-
788
- def main():
789
- import argparse
790
- global pargs
791
- parser = argparse.ArgumentParser(description=__doc__
792
- ,formatter_class=argparse.ArgumentDefaultsHelpFormatter
793
- ,epilog=(f'pvplot: {__version__}'))
794
- parser.add_argument('-a', '--ado', default='', help=\
795
- 'Default Device/ADO name. Useful for plotting parameters from single device.')
796
- parser.add_argument('-s', '--sleepTime', type=float, default=1,
797
- help='sleep time between data delivery [s]')
798
- parser.add_argument('-v', '--verbose', nargs='*', help=\
799
- 'Show more log messages (-vv: show even more).')
800
- parser.add_argument('-x', '--xscale', help=\
801
- 'Parameter, which provides dynamic scale for X-axis')
802
- parser.add_argument('-X', '--xrange', help=\
803
- 'Fixed range of X axis, e.g: -x10:20')
804
- parser.add_argument('-y', '--yscale', help=\
805
- 'Parameter, which provides dynamic scale for Y-axis')
806
- parser.add_argument('-Y', '--yrange', help=\
807
- 'Fixed range of Y axis, e.g: -y1000:4095')
808
- parser.add_argument('-z', '--zoomin', help=\
809
- 'Zoom the application window by a factor')
810
- parser.add_argument('-#','--dock', action='append', nargs='*',
811
- help='''plot the ADO parameter in a specified dock, i.e: to plot the
812
- scrolling plot in dock#1 and correlation plot in dock#2:
813
- -#0simple.test:sinM -#1simple.test:degM,simple.test:sinM ''')
814
- parser.add_argument('parms', nargs = '?',#nargs='*',
815
- default='simple.test:sinM am_simple.0:sinM simple.test:degM',
816
- help='''String with space-separated parameters, e.g.
817
- 'simple.test:sinM am_simple.0:sinM simple.test:degM' ''')
818
- pargs = parser.parse_args()
819
- #print(f'pargs:{pargs}')
820
- if pargs.ado != '':
821
- pargs.ado += ':'
822
-
823
- #``````````````arrange keyboard interrupt to kill the program
824
- import signal
825
- signal.signal(signal.SIGINT, signal.SIG_DFL)
826
-
827
- #````````````````````````````Initialize Gui```````````````````````````````````
828
- gWin.setCentralWidget(gArea)
829
- gWin.resize(1000,500)
830
- gWin.setWindowTitle(f'pvplot {pargs.parms}')
831
- ## Switch to using white background and black foreground
832
- pg.setConfigOption('background', 'w')
833
- pg.setConfigOption('foreground', 'k')
834
- layout = QGridLayout()
835
-
836
- # Subscriptions. Only LITE system is supported.
837
- if pargs.xscale is not None:
838
- hostDev,par = (pargs.ado[2:-1],pargs.xscale)
839
- print(f'subscribing: {hostDev,par}')
840
- info = LITEAccess.info((hostDev,par))
841
- print(f'info of {hostDev,par}: {info}')
842
- units = info[par]['units']
843
- gScaleUnits[X] = [info[par]['value'][0], units]
844
- LITEAccess.subscribe(callback, (hostDev,par))
845
- subscribedParMap[(hostDev,par)] = [X, units]
846
- #print(f'SubParMap: {subscribedParMap}')
847
-
848
- # plots for other docks
849
- if pargs.dock:
850
- for par in pargs.dock:
851
- dock = par[0][0]
852
- adopar = par[0][1:].lstrip()
853
- dock = '#'+dock
854
- add_curves(dock, adopar)
855
- else:
856
- # plots for the main dock
857
- add_curves('#0', pargs.parms)
858
767
 
859
- for dock in gMapOfDocks:
860
- set_legend(str(dock), True)
768
+ class PVPlot():
769
+ pargs = None
770
+ mapOfDocks = {}
771
+ mapOfPlotWidgets = {}
772
+ padding = 0.1
773
+ scaleUnits = [[1,'Sample'],[1,'Count']]
774
+ subscribedParMap = {}
775
+ perfmon = False # option for performance monitoring
776
+ legend = {}# unfortunately we have to keep track of legends
777
+ access = {'E:':(EPICSAccess,2), 'L:':(LITEAccess,2)}
778
+ qWin = None
779
+ dockArea = None
780
+
781
+ def start():
782
+ pargs = PVPlot.pargs
783
+
784
+ try: os.environ["QT_SCALE_FACTOR"] = str(pargs.zoomin)
785
+ except: pass
786
+ qApp = QApplication([])
787
+ qTimer = QtCore.QTimer()
788
+ PVPlot.qWin = QMainWindow()
789
+ PVPlot.dockArea = dockarea.DockArea()
790
+ PVPlot.qWin.setCentralWidget(PVPlot.dockArea)
791
+ PVPlot.qWin.resize(1000,500)
792
+ ## Switch to using white background and black foreground
793
+ pg.setConfigOption('background', 'w')
794
+ pg.setConfigOption('foreground', 'k')
795
+
796
+ PVPlot.qWin.setWindowTitle(f'pvplot {pargs.parms}')
797
+
798
+ # plots for other docks
799
+ if pargs.dock:
800
+ for par in pargs.dock:
801
+ dock = par[0][0]
802
+ adopar = par[0][1:].lstrip()
803
+ dock = '#'+dock
804
+ add_curves(dock, adopar)
805
+ else:
806
+ # plots for the main dock
807
+ add_curves('#0', pargs.parms)
808
+
809
+ for dock in PVPlot.mapOfDocks:
810
+ set_legend(str(dock), True)
811
+
812
+ # Subscriptions. Only LITE system is supported.
813
+ if pargs.xscale is not None:
814
+ hostDev,par = (pargs.ado[2:-1],pargs.xscale)
815
+ print(f'subscribing: {hostDev,par}')
816
+ info = LITEAccess.info((hostDev,par))
817
+ print(f'info of {hostDev,par}: {info}')
818
+ units = info[par]['units']
819
+ scaleUnits[X] = [info[par]['value'][0], units]
820
+ LITEAccess.subscribe(callback, (hostDev,par))
821
+ subscribedParMap[(hostDev,par)] = [X, units]
822
+ #print(f'SubParMap: {subscribedParMap}')
861
823
 
862
- update_data()
824
+ update_data()
863
825
 
864
- ## Start a timer to rapidly update the plot in pw
865
- gTimer.timeout.connect(update_data)
866
- gTimer.start(int(pargs.sleepTime*1000))
826
+ ## Start a timer to rapidly update the plot in pw
827
+ qTimer.timeout.connect(update_data)
828
+ qTimer.start(int(pargs.sleepTime*1000))
867
829
 
868
- gWin.show()
869
- gWin.resize(640,480)
830
+ PVPlot.qWin.show()
831
+ PVPlot.qWin.resize(640,480)
870
832
 
871
- # start GUI
872
- qApp.instance().exec_()
873
- print('Application exit')
833
+ # start GUI
834
+ qApp.instance().exec_()
835
+ print('Application exit')
874
836
 
875
- if __name__ == "__main__":
876
- main()
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pvplot"
7
- version = "0.5.3"
7
+ version = "0.6.1"
8
8
  authors = [
9
9
  { name="Andrei Sukhanov", email="cyxandr@gmail.com" },
10
10
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes