Requests from Didier

This commit is contained in:
2022-09-27 11:17:24 +02:00
parent be6ea297fd
commit de5fb0677e
8 changed files with 70 additions and 27 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
#Fri Jun 17 06:58:23 CEST 2022
#Tue Sep 27 11:07:44 CEST 2022
bins=1000
min=11400.0
max=11200.0
min=11501.94250320649
max=11601.94250320649
precision=-1
description=null
numberOfSamples=10000
+2 -2
View File
@@ -1,5 +1,5 @@
#Fri Jun 17 06:58:23 CEST 2022
measures=10
#Tue Sep 27 10:25:33 CEST 2022
measures=100
precision=-1
description=null
interval=-1
+8 -3
View File
@@ -8,6 +8,7 @@ import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.plot.LinePlotJFree;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.Convert;
import ch.psi.utils.State;
@@ -32,13 +33,16 @@ public class PSSS extends Panel {
volatile boolean updatingPlot;
volatile boolean updatingImage;
volatile boolean updatingDevices;
final Color PLOT_BACKGROUND =Color.WHITE;
Color PLOT_BACKGROUND =Color.WHITE;
final Font TICK_LABEL_FONT = new Font("Arial", 0, 14);
public PSSS() {
initComponents();
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
if (App.hasArgument("pltb")){
PLOT_BACKGROUND = null;
}
renderer.setMode(RendererMode.Stretch);
plot.setPlotBackgroundColor(PLOT_BACKGROUND);
history.setPlotBackgroundColor(PLOT_BACKGROUND);
@@ -63,8 +67,9 @@ public class PSSS extends Panel {
pipelineServer = (PipelineServer) getDevice("cam_server");
((LinePlotJFree)histogramGeneratorPanelCenter.getPlot()).setLegendVisible(true);
((LinePlotJFree)histogramGeneratorFwhm.getPlot()).setLegendVisible(true);
histogramGeneratorPanelCenter.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
histogramGeneratorFwhm.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
//histogramGeneratorPanelCenter.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
//histogramGeneratorFwhm.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
//setImageEnabled(true);
tabStateChanged(null);
+2 -1
View File
@@ -38,7 +38,7 @@ import ch.psi.pshell.core.InlineDevice as InlineDevice
import ch.psi.pshell.data.DataSlice as DataSlice
import ch.psi.pshell.data.PlotDescriptor as PlotDescriptor
import ch.psi.pshell.data.Table as Table
import ch.psi.pshell.data.Provider as Provider
import ch.psi.pshell.data.Provider as DataProvider
import ch.psi.pshell.data.ProviderHDF5 as ProviderHDF5
import ch.psi.pshell.data.ProviderText as ProviderText
import ch.psi.pshell.data.ProviderCSV as ProviderCSV
@@ -238,6 +238,7 @@ import ch.psi.pshell.scan.ScanAbortedException as ScanAbortedException
import ch.psi.pshell.bs.BsScan
import ch.psi.pshell.bs.Stream as Stream
import ch.psi.pshell.bs.Provider as Provider
import ch.psi.pshell.bs.ProviderConfig.SocketType as SocketType
import ch.psi.pshell.bs.Dispatcher as Dispatcher
import ch.psi.pshell.bs.Scalar as Scalar
import ch.psi.pshell.bs.Waveform as Waveform
+12 -5
View File
@@ -214,6 +214,7 @@ def cscan(writables, readables, start, end, steps, latency=0.0, time=None, relat
time (float, seconds): if not None then speeds are set according to time.
relative (bool, optional): if true, start and end positions are relative to current.
passes(int, optional): number of passes
zigzag(bool, optional): if true writables invert direction on each pass.
pars(keyworded variable length arguments, optional): scan optional named arguments:
- title(str, optional): plotting window name.
- before_read (function(positions, scan), optional): called on each step, before sampling.
@@ -262,6 +263,7 @@ def hscan(config, writable, readables, start, end, steps, passes=1, zigzag=False
end(float): final positions of writables.
steps(int or float): number of scan steps (int) or step size (float).
passes(int, optional): number of passes
zigzag(bool, optional): if true writables invert direction on each pass.
pars(keyworded variable length arguments, optional): scan optional named arguments:
- title(str, optional): plotting window name.
- after_read (function(record, scan), optional): callback on each step, after sampling.
@@ -286,16 +288,18 @@ def oscan(ioc, prefix, writable, readables, start, end, steps, integration_time,
"""OTF scan based on crlogic
Args:
ioc(string): Crlogic ioc
source(string): Crlogic ioc (if zmq==True) or data channel name (zmq==False).
prefix(string): Crlogic prefix
writable(Writable): A cslogic positioner
readables(list of Readable): List of crlogic sensors
start(float): start positions of writable.
end(float): final positions of writables.
steps(int or float): number of scan steps (int) or step size (float).
passes(int, optional): number of passes
steps(float) : size of scan step
integration_time(float)
additional_backlash(float, optional)
passes(int, optional): number of passes
zigzag(bool, optional): if true writables invert direction on each pass.
zmq(bool, optional): if true receives data from ioc through zmq stream, otherwise with a channel monitor.
pars(keyworded variable length arguments, optional): scan optional named arguments:
- title(str, optional): plotting window name.
- after_read (function(record, scan), optional): callback on each step, after sampling.
@@ -311,11 +315,14 @@ def oscan(ioc, prefix, writable, readables, start, end, steps, integration_time,
"""
config = {}
config["class"] = "ch.psi.pshell.crlogic.CrlogicScan"
config["ioc"] = ioc
if zmq:
config["ioc"] = source
else:
config["channel"] = source
config["prefix"] = prefix
config["integrationTime"] = integration_time
config["additionalBacklash"] = additional_backlash
return hscan(config, writable, readables, start, end, steps, **pars)
return hscan(config, writable, readables, start, end, float(steps), **pars)
def bscan(stream, records, timeout = None, passes=1, **pars):
"""BS Scan: records all values in a beam synchronous stream.
+1
View File
@@ -15,6 +15,7 @@ def on_command_finished(info): pass
def on_session_started(id): pass
def on_session_finished(id): pass
def on_change_data_path(path): pass
def on_system_restart(): pass
###################################################################################################
+28 -4
View File
@@ -17,6 +17,7 @@ import functools
import socket
import numpy
import traceback
import ctypes
from jep import jproxy
#TODO
@@ -58,6 +59,16 @@ from ch.psi.utils import Arr
__THREAD_EXEC_RESULT__=None
###################################################################################################
#Default empty callbacks
###################################################################################################
def on_command_started(info): pass
def on_command_finished(info): pass
def on_session_started(id): pass
def on_session_finished(id): pass
def on_change_data_path(path): pass
def on_system_restart(): pass
###################################################################################################
#Type conversion and checking
###################################################################################################
@@ -255,7 +266,7 @@ from ch.psi.pshell.core import InlineDevice as InlineDevice
from ch.psi.pshell.data import DataSlice as DataSlice
from ch.psi.pshell.data import PlotDescriptor as PlotDescriptor
from ch.psi.pshell.data import Table as Table
from ch.psi.pshell.data import Provider as Provider
from ch.psi.pshell.data import Provider as DataProvider
from ch.psi.pshell.data import ProviderHDF5 as ProviderHDF5
from ch.psi.pshell.data import ProviderText as ProviderText
from ch.psi.pshell.data import ProviderCSV as ProviderCSV
@@ -2815,6 +2826,14 @@ def on_ctrl_cmd(cmd):
#print ("Control command: ", cmd)
pass
def on_close(parent_thread):
on_abort(parent_thread)
def on_abort(parent_thread):
tid=parent_thread.ident
exception = KeyboardInterrupt
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(exception))
if __name__ == "__main__":
#Handle control command server
if ("ctrl_cmd_socket" in globals()) and (ctrl_cmd_socket is not None):
@@ -2839,9 +2858,14 @@ if __name__ == "__main__":
except socket.timeout:
continue
cmd =msg.decode('UTF-8')
on_ctrl_cmd(cmd)
if cmd=="exit":
quit=True
if cmd=="close":
quit=True
on_close(parent_thread)
elif cmd=="abort":
on_abort(parent_thread)
else:
on_ctrl_cmd(cmd)
ctrl_cmd_socket.sendto("ack".encode('UTF-8'), add)
finally:
print("Quitting control command task")
+14 -9
View File
@@ -65,8 +65,8 @@ def plot_psss(p, h=None, average = None):
# Setup figures
if p.getNumberOfSeries()==0:
p.addSeries(LinePlotSeries("spectrum"))
p.addSeries(LinePlotSeries("average"))
p.addSeries(LinePlotSeries("spectrum", Color.RED))
p.addSeries(LinePlotSeries("average", Color.BLUE))
p.setLegendVisible(True)
p.getAxis(LinePlot.AxisId.X)
p.getAxis(LinePlot.AxisId.X).setLabel("Energy [eV]")
@@ -114,17 +114,22 @@ def plot_psss(p, h=None, average = None):
if h:
if h.getNumberOfSeries()==0:
h.addSeries(TimePlotSeries("centre"))
h.addSeries(TimePlotSeries("Energy spread SS",2))
h.addSeries(TimePlotSeries("Energy spread cum avg",2))
h.addSeries(TimePlotSeries("Energy spread SS",Color.RED, 2))
h.addSeries(TimePlotSeries("Energy spread cum avg", Color.BLUE, 2))
h.addSeries(TimePlotSeries("centre", Color.GREEN.darker(), 1))
h.setLegendVisible(True)
h.setTimeAxisLabel("")
h.getAxis(Timeplot.AxisId.Y1).setLabel("Central energy [eV]")
#h.getAxis(TimePlot.AxisId.Y1).setLabel("Central energy [eV]")
histo_center.config.min = center - 50
histo_center.config.max = center + 50
histo_center.config.save()
per_mil = (fwhm/center)*1e3
per_mil_avg = psss_fwhm_avg.take()
h.getSeries(0).appendData(center)
h.getSeries(1).appendData(per_mil)
h.getSeries(2).appendData(per_mil_avg)
h.getSeries(0).appendData(per_mil)
h.getSeries(1).appendData(per_mil_avg)
h.getSeries(2).appendData(center)
return center,fwhm
ovmin, ovmax, ovavg = None, None, None