slaclab / pydm

Python Display Manager
http://slaclab.github.io/pydm/
Other
113 stars 77 forks source link

Plots: number of points supplied by a PV #608

Closed prjemian closed 2 years ago

prjemian commented 4 years ago

How can I configure any of the plots to get its number of points to be plotted from a PV value?

Screens for the synApps sscan record use this feature. Also, some of the screens in the calc module use this.

hhslepicka commented 4 years ago

@prjemian what kind of plot?

The waveform plot will work properly following the number of elements but other than that, we don't have yet a plot which offers the number of points to be tweaked by a PV.

For the TimePlot we could probably easily expose some of the properties via the Rules mechanism and that would allow you to achieve that.

Attn. @mattgibbs , our plot specialist.

prjemian commented 4 years ago

A waveform plot is easy since it tells you how many points to plot. Some other plots take the number of points from an integer PV. Looks like for now, that feature is not mappable.

What's the default number of points? 1200? In the translator, looks like the default number of points should replace when a PV is supplied.

prjemian commented 4 years ago

Guidance here: https://epics.anl.gov/EpicsDocumentation/ExtensionsManuals/MEDM/MEDM.html#CartesianPlot

Look for table titled Kinds of XY Traces

prjemian commented 2 years ago

https://github.com/slaclab/pydm/blob/01c5326d9f57dc34aafa02bde807c4654d1fa00c/pydm/widgets/scatterplot.py#L202-L203

https://github.com/slaclab/pydm/blob/01c5326d9f57dc34aafa02bde807c4654d1fa00c/pydm/widgets/scatterplot.py#L32-L34

prjemian commented 2 years ago

Perhaps there is a possibility to tie a PV to the _bufferSize attribute? Would need some additional work...

Hmm, this is interesting: https://github.com/slaclab/pydm/blob/01c5326d9f57dc34aafa02bde807c4654d1fa00c/pydm/widgets/scatterplot.py#L206-L222

Could _bufferSize be refactored into a bufferSize property with setter and getter?

prjemian commented 2 years ago

Looking further, bufferSize is handled a bit differently in timeplot.py, where it is a property of the display and there is a defined constant for MINIMUM_BUFFER_SIZE.

(dev-pydm) zorinvm@zorin22:~/Documents/projects/slaclab/pydm$ git grep BUFFER_SIZE
pydm/tests/widgets/test_timeplot.py:from ...widgets.timeplot import TimePlotCurveItem, PyDMTimePlot, TimeAxisItem, MINIMUM_BUFFER_SIZE, DEFAULT_BUFFER_SIZE
pydm/tests/widgets/test_timeplot.py:    assert pydm_timeplot_curve_item._bufferSize == MINIMUM_BUFFER_SIZE
pydm/tests/widgets/test_timeplot.py:    (0, MINIMUM_BUFFER_SIZE),
pydm/tests/widgets/test_timeplot.py:    (-5, MINIMUM_BUFFER_SIZE),
pydm/tests/widgets/test_timeplot.py:    (MINIMUM_BUFFER_SIZE + 1, MINIMUM_BUFFER_SIZE + 1)
pydm/tests/widgets/test_timeplot.py:    assert pydm_timeplot_curve_item.getBufferSize() == MINIMUM_BUFFER_SIZE
pydm/tests/widgets/test_timeplot.py:    assert pydm_timeplot_curve_item.getBufferSize() == DEFAULT_BUFFER_SIZE
pydm/widgets/archiver_time_plot.py:DEFAULT_ARCHIVE_BUFFER_SIZE = 18000
pydm/widgets/archiver_time_plot.py:        self._archiveBufferSize = DEFAULT_ARCHIVE_BUFFER_SIZE
pydm/widgets/archiver_time_plot.py:        if self._archiveBufferSize != DEFAULT_ARCHIVE_BUFFER_SIZE:
pydm/widgets/archiver_time_plot.py:            self._archiveBufferSize = DEFAULT_ARCHIVE_BUFFER_SIZE
pydm/widgets/archiver_time_plot.py:            return DEFAULT_ARCHIVE_BUFFER_SIZE
pydm/widgets/timeplot.py:MINIMUM_BUFFER_SIZE = 2
pydm/widgets/timeplot.py:DEFAULT_BUFFER_SIZE = 18000
pydm/widgets/timeplot.py:        self._bufferSize = MINIMUM_BUFFER_SIZE
pydm/widgets/timeplot.py:            self._bufferSize = max(int(value), MINIMUM_BUFFER_SIZE)
pydm/widgets/timeplot.py:        if self._bufferSize != DEFAULT_BUFFER_SIZE:
pydm/widgets/timeplot.py:            self._bufferSize = DEFAULT_BUFFER_SIZE
pydm/widgets/timeplot.py:        self._bufferSize = DEFAULT_BUFFER_SIZE
pydm/widgets/timeplot.py:            self._bufferSize = max(int(value), MINIMUM_BUFFER_SIZE)
pydm/widgets/timeplot.py:        if self._bufferSize != DEFAULT_BUFFER_SIZE:
pydm/widgets/timeplot.py:            self._bufferSize = DEFAULT_BUFFER_SIZE
prjemian commented 2 years ago

Could _bufferSize be refactored into a bufferSize property with setter and getter?

It could but rather should be similar to the use timeplot.py, where bufferSize is tied to a user-interface property: https://github.com/slaclab/pydm/blob/01c5326d9f57dc34aafa02bde807c4654d1fa00c/pydm/widgets/timeplot.py#L676

prjemian commented 2 years ago

The real question is: How to extend the existing interface (which obtains the bufferSize from a QtCore.Property) to use an EPICS PV if such is defined and the channel is connected? This would apply to ScatterPlotCurveItem and TimePlotCurveItem, ... :

(dev-pydm) zorinvm@zorin22:~/Documents/projects/slaclab/pydm$ git grep "class " | grep "Item("
pydm/widgets/archiver_time_plot.py:class ArchivePlotCurveItem(TimePlotCurveItem):
pydm/widgets/baseplot.py:class BasePlotCurveItem(PlotDataItem):
pydm/widgets/baseplot.py:class BasePlotAxisItem(AxisItem):
pydm/widgets/scatterplot.py:class ScatterPlotCurveItem(BasePlotCurveItem):
pydm/widgets/timeplot.py:class TimePlotCurveItem(BasePlotCurveItem):
pydm/widgets/timeplot.py:class TimeAxisItem(AxisItem):
pydm/widgets/waveformplot.py:class WaveformCurveItem(BasePlotCurveItem):

Just *CurveItem, not *AxisItem