pvplot 1.0.0__tar.gz → 1.2.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pvplot
3
- Version: 1.0.0
3
+ Version: 1.2.3
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
@@ -3,9 +3,13 @@ The command line to start litePeakSimulator:
3
3
  python3 -m liteserver.device.litePeakSimulator -ilo -p9710
4
4
  """
5
5
  configFormat='pvplot'
6
+
6
7
  TITLE="PeakSimulator"
8
+ XLABEL = "Time (us)"
9
+ YLABEL = "V"
10
+ POINTS = 1000# data arrays will be rolled over after accumulating this number of points
7
11
 
8
- """ The following variables are not handled yet:
12
+ """ The following attributes are not handled yet:
9
13
  YES = 1
10
14
  POLLPERIOD = 0
11
15
  MINPOLLPERIOD = 0
@@ -19,8 +23,6 @@ LOGCORRELATION = 'NOTREQUIRED'
19
23
  FILLDATA = YES
20
24
  LOGTREEPATH = '/operations/app_store/RunData/currentFill/'
21
25
  PREFERREDLOGDISPLAY = Snapshot
22
- XLABEL = "Time (us)"
23
- YLABEL = "V"
24
26
  DATASTAMPTYPE = 'WCTPERIOD'
25
27
  WCTCORRPERIOD_MSEC = 1000
26
28
  WCTCORRWINDOW_MSEC = 1000
@@ -36,10 +38,11 @@ ERRORBARS = 0
36
38
  FONTTYPE = 'Medium'
37
39
  KEEPPREVIOUS = 0
38
40
  """
41
+
39
42
  dev='L:localhost;9710:dev1:'
40
43
 
41
44
  DOCKS = [
42
- {'YMax':f'device({dev}yMax)',
45
+ {'YMax':f'{dev}yMax',# without device()
43
46
  'YMin':f'device({dev}yMin)',
44
47
  'Y[10]':f'device({dev}y[500])',
45
48
  },
@@ -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('-c','--configDir',default='/operations/app_store/pvplot',
21
+ help='Configuration directory')
20
22
  parser.add_argument('-f', '--file', help=
21
23
  'Configuration file')
22
24
  parser.add_argument('-l', '--limit', type=int, default=1048576,
@@ -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__ = 'v1.0.0 2024-07-26'# configuration file, shortcuts,
4
+ __version__ = 'v1.2.3 2024-07-29'# fix: config-less plotting
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
@@ -24,12 +24,12 @@ X,Y = 0,1
24
24
  Scale,Units = 0,1
25
25
  #````````````````````````````Helper methods```````````````````````````````````
26
26
  def printTime(): return time.strftime("%m%d:%H%M%S")
27
- def printi(msg): print((f'INFO_PP@{printTime()}: '+msg))
28
- def printw(msg): print((f'WARN_PP@{printTime()}: '+msg))
29
- def printe(msg): print((f'ERR_PP@{printTime()}: '+msg))
27
+ def printi(msg): print((f'INFO_PVP@{printTime()}: '+msg))
28
+ def printw(msg): print((f'WARN_PVP@{printTime()}: '+msg))
29
+ def printe(msg): print((f'ERR_PVP@{printTime()}: '+msg))
30
30
  def _printv(msg, level=0):
31
31
  if PVPlot.pargs.verbose > level:
32
- print((f'DBG{level}_PP@{printTime()}: '+msg))
32
+ print((f'DBG{level}_PVP@{printTime()}: '+msg))
33
33
  def printv(msg): _printv(msg, 0)
34
34
  def printvv(msg): _printv(msg, 1)
35
35
 
@@ -281,12 +281,22 @@ class Dataset():
281
281
  PVPlot.mapOfPlotWidgets[dockNum] = self.plotWidget
282
282
  PVPlot.mapOfDocks[dockNum].addWidget(self.plotWidget)
283
283
  printv(f'docks: {PVPlot.mapOfDocks.keys()}, widgets: {PVPlot.mapOfPlotWidgets.keys()}')
284
- if isCorrelationPlot:
285
- self.plotWidget.setLabel('bottom',self.adoPars[1][0])
286
- elif count == 1:
287
- self.plotWidget.setLabel('bottom','time', units='date', unitPrefix='')
284
+
285
+ c = PVPlot.config
286
+ if c is None: xl,yl = 'LabelX','LabelY'
287
+ else: xl,yl = c.XLABEL,c.YLABEL
288
+ #print(f'd:{self.dockNum}, X,Y: {xl,yl}')
289
+ if self.dockNum == 0 and yl != 'LabelY':
290
+ self.plotWidget.setLabel('left', yl)
291
+ if self.dockNum == 0 and xl != 'LabelX':
292
+ self.plotWidget.setLabel('bottom', xl)
288
293
  else:
289
- self.plotWidget.setLabel('bottom',PVPlot.scaleUnits[X][Units])
294
+ if isCorrelationPlot:
295
+ self.plotWidget.setLabel('bottom',self.adoPars[1][0])
296
+ elif count == 1:
297
+ self.plotWidget.setLabel('bottom','time', units='date', unitPrefix='')
298
+ else:
299
+ self.plotWidget.setLabel('bottom',PVPlot.scaleUnits[X][Units])
290
300
 
291
301
  # set X and Y ranges
292
302
  rangeMap = {X: (PVPlot.pargs.xrange, self.plotWidget.setXRange),
@@ -428,8 +438,8 @@ class Dataset():
428
438
  self.dataPtr = ptr
429
439
 
430
440
  # re-alocate arrays,if necessary
431
- #print(f'ptr: {ptr,self.data[Y].shape[0]}')
432
- if (ptr <= PVPlot.pargs.limit/2) & (ptr >= self.data[Y].shape[0]):
441
+ if (ptr >= self.data[Y].shape[0]):
442
+ #print(f'realllocate: ptr: {ptr,self.data[Y].shape[0]}')
433
443
  tmp = self.data
434
444
  self.data = [np.empty(self.data[Y].shape[0] * 2),
435
445
  np.empty(self.data[Y].shape[0] * 2)]
@@ -493,6 +503,7 @@ class MapOfDatasets():
493
503
  devList.reverse()
494
504
  pnameAndCount = []
495
505
  for adoPar in devList:
506
+ adoPar = adoPar.lstrip()#remove leading whitespaces
496
507
  printv(f'adoPar: {adoPar}')
497
508
  if adoPar.startswith('device('):
498
509
  e = adoPar.index(')')
@@ -691,8 +702,10 @@ class CustomViewBox(pg.ViewBox):
691
702
  dlg.setMinimumSize(*dlgSize)
692
703
  rowCount,columnCount = 0,6
693
704
  tbl = QW.QTableWidget(rowCount, columnCount, dlg)
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
705
+ tbl.setHorizontalHeaderLabels(
706
+ ['Name','PV','Color','Width','Symbol','Size'])
707
+ widths = ( 50, 100, 30, 80, 40, 80)
708
+ for column,width in enumerate(widths):
696
709
  tbl.setColumnWidth(column, width)
697
710
  tbl.setShowGrid(False)
698
711
  tbl.setSizeAdjustPolicy(
@@ -704,20 +717,21 @@ class CustomViewBox(pg.ViewBox):
704
717
  tbl.insertRow(row)
705
718
  curveName = dataitem.name()
706
719
  printv(f'curveName:{curveName}')
720
+ col = 0
707
721
  dataset = MapOfDatasets.dtsDict[curveName]
708
722
  adoparName = dataset.adoPars[0][0]
709
-
723
+ tbl.setItem(row, col, QW.QTableWidgetItem(curveName))
724
+ col+=1
710
725
  printv(f'dataset:{adoparName}')
711
- tbl.setItem(row, 0, QW.QTableWidgetItem(curveName))
712
- tbl.setItem(row, 1, QW.QTableWidgetItem(adoparName))
713
-
726
+ tbl.setItem(row, col, QW.QTableWidgetItem(adoparName))
727
+ col+=1
714
728
  # color button for line
715
729
  colorButton = pg.ColorButton(color=dataset.pen.color())
716
730
  colorButton.setObjectName(curveName)
717
731
  colorButton.sigColorChanging.connect(lambda x:
718
732
  change_plotOption(str(self.sender().objectName()),color=x.color()))
719
- tbl.setCellWidget(row, 2, colorButton)
720
-
733
+ tbl.setCellWidget(row, col, colorButton)
734
+ col+=1
721
735
  # slider for changing the line width
722
736
  widthSlider = QW.QSlider()
723
737
  widthSlider.setObjectName(curveName)
@@ -726,15 +740,15 @@ class CustomViewBox(pg.ViewBox):
726
740
  widthSlider.setValue(1)
727
741
  widthSlider.valueChanged.connect(lambda x:
728
742
  change_plotOption(str(self.sender().objectName()),width=x))
729
- tbl.setCellWidget(row, 3, widthSlider)
730
-
743
+ tbl.setCellWidget(row, col, widthSlider)
744
+ col+=1
731
745
  # symbol, selected from a comboBox
732
746
  self.symbol = QW.QComboBox() # TODO: why self?
733
747
  for symbol in ' ostd+x': self.symbol.addItem(symbol)
734
748
  self.symbol.setObjectName(curveName)
735
749
  self.symbol.currentIndexChanged.connect(self.set_symbol)
736
- tbl.setCellWidget(row, 4, self.symbol)
737
-
750
+ tbl.setCellWidget(row, col, self.symbol)
751
+ col+=1
738
752
  # slider for changing the line width
739
753
  symbolSizeSlider = QW.QSlider()
740
754
  symbolSizeSlider.setObjectName(curveName)
@@ -743,14 +757,14 @@ class CustomViewBox(pg.ViewBox):
743
757
  symbolSizeSlider.setValue(1)
744
758
  symbolSizeSlider.valueChanged.connect(lambda x:
745
759
  change_plotOption(str(self.sender().objectName()),symbolSize=x))
746
- tbl.setCellWidget(row, 5, symbolSizeSlider)
747
-
760
+ tbl.setCellWidget(row, col, symbolSizeSlider)
761
+ col+=1
748
762
  # color button for symbol
749
763
  symbolColorButton = pg.ColorButton(color=dataset.pen.color())
750
764
  symbolColorButton.setObjectName(curveName)
751
765
  symbolColorButton.sigColorChanging.connect(lambda x:
752
766
  change_plotOption(str(self.sender().objectName()),scolor=x.color()))
753
- tbl.setCellWidget(row, 6,symbolColorButton)
767
+ tbl.setCellWidget(row, col,symbolColorButton)
754
768
  dlg.exec_()
755
769
 
756
770
  def set_symbol(self, x):
@@ -847,7 +861,7 @@ def add_curves(dockNum:int, curveMap:str):
847
861
  #docks = [x.split('.')[0] for x in curves]
848
862
  curves = MapOfDatasets.dtsDict.keys()
849
863
  docks = PVPlot.mapOfDocks.keys()
850
- printv(f'>addcurves curves,docks:{curves,docks}')
864
+ printv(f'>addcurves curves {curveMap} to {curves,docks}')
851
865
  if dockNum not in docks:
852
866
  printv(f'adding new dock{dockNum}')
853
867
  PVPlot.mapOfDocks[dockNum] = dockarea.Dock(str(dockNum),
@@ -866,22 +880,22 @@ def excepthook(exc_type, exc_value, exc_tb):
866
880
  tb = "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
867
881
  print("error caught!:")
868
882
  print("error message:\n", tb)
869
- QtWidgets.QApplication.quit()
870
- # or QtWidgets.QApplication.exit(0)
883
+ QApplication.quit()
884
+ # or QApplication.exit(0)
871
885
 
872
886
  class tmpClass():
873
887
  DOCKS = [{}]
874
888
 
875
889
  def parse_input_parameters(pargs):
876
890
  fn = pargs.file
877
- print(f'fn:`{fn}`')
878
891
  if fn:
879
- print(f'importing {fn}')
892
+ sys.path.append(pargs.configDir)
893
+ printv(f'importing {fn}')
880
894
  try:
881
895
  ConfigModule = import_module(fn)
882
896
  configFormat = ConfigModule.configFormat
883
897
  except ModuleNotFoundError as e:
884
- printe(f'Trying to import {fn}: {e}')
898
+ printe(f'Trying to import {pargs.configDir}/{fn}: {e}')
885
899
  sys.exit(0)
886
900
  return ConfigModule
887
901
  else:
@@ -893,6 +907,7 @@ def parse_input_parameters(pargs):
893
907
  return tmpClass
894
908
 
895
909
  class PVPlot():
910
+ config = None
896
911
  pargs = None
897
912
  mapOfPlotWidgets = {}
898
913
  mapOfDocks = {}
@@ -914,7 +929,7 @@ class PVPlot():
914
929
 
915
930
  def start():
916
931
  pargs = PVPlot.pargs
917
- print(f'pargs: {PVPlot.pargs}')
932
+ printv(f'pargs: {PVPlot.pargs}')
918
933
 
919
934
  try: os.environ["QT_SCALE_FACTOR"] = str(pargs.zoomin)
920
935
  except: pass
@@ -939,14 +954,35 @@ class PVPlot():
939
954
  from . import helptxt
940
955
  PVPlot.helptxt = helptxt.txt
941
956
 
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)
957
+ #``````````process configuration file
958
+ if pargs.file is not None:
959
+ PVPlot.config = parse_input_parameters(pargs)
960
+
961
+ try: pargs.limit = PVPlot.config.POINTS
962
+ except: pass
963
+
964
+ try: title = PVPlot.config.TITLE
965
+ except: title = title = f'pvplot {pargs.parms}'
966
+ PVPlot.qWin.setWindowTitle(title)
967
+ dockList = PVPlot.config.DOCKS
968
+ for dockNum,curveMap in enumerate(dockList):
969
+ printv(f'add_curves to dock{dockNum}, {curveMap}')
970
+ add_curves(dockNum, curveMap)
971
+ #,,,,,,,,,,
972
+ else:
973
+ if pargs.dock:
974
+ for par in pargs.dock:
975
+ dockNum = par[0][0]
976
+ adopar = par[0][1:].lstrip()
977
+ add_curves(dockNum, {adopar:adopar})
978
+ else:
979
+ # plots for the main dock
980
+ if not ',' in pargs.parms:
981
+ for parName in pargs.parms.split():
982
+ add_curves(0, {parName:pargs.prefix+parName})
983
+ else:
984
+ x,y = pargs.parms.split(',')
985
+ add_curves(0, {f'{y} vs {x}': (pargs.prefix+x, pargs.prefix+y)})
950
986
 
951
987
  if len(MapOfDatasets.dtsDict) == 0:
952
988
  printe(f'No datasets created')