Files
saresb/script/test/demo_histogram3.py
gac-bernina 3edd5ecda9
2024-02-19 16:44:57 +01:00

51 lines
1.7 KiB
Python

import ch.psi.utils.swing.SwingUtils as SwingUtils
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
import ch.psi.pshell.swing.HistogramGeneratorPanel as HistogramGeneratorPanel
from collections import OrderedDict
import javax.swing.border.TitledBorder as TitledBorder
import javax.swing.JPanel as JPanel
import javax.swing.BoxLayout as BoxLayout
import java.awt.Dimension as Dimension
CAMERA_NAMES = ["SARES20-PROF141-M1"]
CHANNELS = ["intensity",
"x_center_of_mass",
"x_fwhm",
"x_rms",
"x_fit_amplitude",
"x_fit_mean",
"x_fit_offset",
"x_fit_standard_deviation",
"x_profile"
]
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
panels = OrderedDict()
for camera_name in CAMERA_NAMES:
cam_server.start(camera_name + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
dev = cam_server.stream.getChild(channel)
hist = HistogramGenerator(camera_name + ":" + channel, dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
pn = HistogramGeneratorPanel()
pn.border=TitledBorder(hist.name)
pn.setShowTitle(True)
pn.setDevice(hist)
pn.setPreferredSize(Dimension(800,150))
panels[hist.name]=pn
pn = JPanel()
pn.layout = BoxLayout(pn, BoxLayout.Y_AXIS)
for k in panels.keys():
pn.add(panels[k])
dlg = SwingUtils.showDialog(None, "Histograms", None, pn)
while(True):
time.sleep(1)