Closedown

This commit is contained in:
sfop
2016-09-07 19:04:49 +02:00
parent c931b9713b
commit 2ebcdf46be
6 changed files with 80 additions and 45 deletions

View File

@@ -1,4 +1,3 @@
#SINEG01-DBPM340:Q=ch.psi.pshell.device.Averager|SINEG01-DBPM340:Q|||true
gun_solenoid=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:I-SET SINEG01-MSOL130:I-READ|||true
gun_phase=ch.psi.pshell.epics.Positioner|SINEG01-RSYS:SET-BEAM-PHASE SINEG01-RSYS:GET-BEAM-PHASE|||true
#SINSB01_phase=ch.psi.pshell.epics.Positioner|VA-SINSB01-RSYS100:SET-BEAM-PHASE VA-SINSB01-RSYS100:GET-BEAM-PHASE|||true
@@ -24,3 +23,4 @@ gsy=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:Y_SP SINEG01-MSOL130:Y|||true
gsrx=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:ROT_X_SP SINEG01-MSOL130:ROT_X|||true
gsry=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:ROT_Y_SP SINEG01-MSOL130:ROT_Y|||true
#camtool=Camtool|SINEG01-DSCR190||-500|
#SINEG01-DBPM340:Q=ch.psi.pshell.device.Averager|SINEG01-DBPM340:Q|||true

View File

@@ -1,13 +1,13 @@
#Wed Sep 07 14:25:45 CEST 2016
#Wed Sep 07 15:48:15 CEST 2016
colormap=Temperature
colormapAutomatic=true
colormapMax=2475.851
colormapMin=2189.861
flipHorizontally=true
colormapMax=25.102
colormapMin=12.575
flipHorizontally=false
flipVertically=true
grayscale=false
imageHeight=1628
imageWidth=1280
imageHeight=1200
imageWidth=1246
invert=false
rescaleFactor=1.0
rescaleOffset=0.0
@@ -18,9 +18,9 @@ roiY=0
rotation=0.0
rotationCrop=true
scale=1.0
spatialCalOffsetX=-1251.0
spatialCalOffsetY=-1504.0
spatialCalScaleX=0.008333333333333333
spatialCalScaleY=0.004081632653061225
spatialCalOffsetX=-1191.0
spatialCalOffsetY=-1176.0
spatialCalScaleX=0.014285714285714285
spatialCalScaleY=0.020833333333333332
spatialCalUnits=mm
transpose=false

View File

@@ -1,4 +1,4 @@
#Thu Sep 01 09:58:11 CEST 2016
#Wed Sep 07 15:31:33 CEST 2016
colormap=Grayscale
colormapAutomatic=true
colormapMax=30000.0
@@ -6,8 +6,8 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=1628
imageWidth=1280
imageHeight=0
imageWidth=0
invert=false
offsetX=0.0
offsetY=0.0

View File

@@ -1,4 +1,4 @@
#Thu Sep 01 09:58:11 CEST 2016
#Wed Sep 07 15:31:33 CEST 2016
colormap=Grayscale
colormapAutomatic=true
colormapMax=255.0
@@ -6,8 +6,8 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=1680
imageWidth=1744
imageHeight=0
imageWidth=0
invert=false
offsetX=0.0
offsetY=0.0

View File

@@ -31,6 +31,7 @@ import ch.psi.pshell.imaging.Pen;
import ch.psi.pshell.imaging.Renderer;
import ch.psi.pshell.imaging.Renderer.Profile;
import ch.psi.pshell.imaging.RendererListener;
import ch.psi.pshell.imaging.Source;
import ch.psi.pshell.imaging.Utils;
import ch.psi.pshell.scripting.InterpreterResult;
import ch.psi.pshell.scripting.ScriptManager;
@@ -83,27 +84,50 @@ public class Cameras extends Panel {
@Override
public void onInitialize(int runCount) {
comboCameras.setEnabled(false);
cameraConfigFiles = IO.listFiles(configFolder, new String[]{"json"});
Arrays.sort(cameraConfigFiles, (a, b) -> a.compareTo(b));
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (File file : cameraConfigFiles) {
String prefix = IO.getPrefix(file);
if (!prefix.startsWith("#")) {
model.addElement(prefix);
}
}
comboCameras.setModel(model);
comboCameras.setEnabled(true);
comboCameras.setSelectedItem(-1);
if (model.getSize() > 0) {
try {
//setCamera((String)comboCameras.getSelectedItem());
if (App.hasArgument("cam")) {
comboCameras.setSelectedItem(App.getArgumentValue("cam"));
if (App.hasArgument("s")){
renderer.setDevice((Source)getDevice("image"));
renderer.setAutoScroll(true);
((Source)getDevice("image")).addListener(new ImageListener() {
@Override
public void onImage(Object o, BufferedImage bi, Data data) {
if (bi == null) {
fitOv = null;
} else {
Overlay[] profile = renderer.getProfileOverlays();
profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(bi) : null;
renderer.updateOverlays(profile, fitOv);
fitOv = profile;
}
}
@Override
public void onError(Object o, Exception excptn) {
}
}
);
} else {
cameraConfigFiles = IO.listFiles(configFolder, new String[]{"json"});
Arrays.sort(cameraConfigFiles, (a, b) -> a.compareTo(b));
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (File file : cameraConfigFiles) {
String prefix = IO.getPrefix(file);
if (!prefix.startsWith("#")) {
model.addElement(prefix);
}
} catch (Exception ex) {
ex.printStackTrace();
}
comboCameras.setModel(model);
comboCameras.setEnabled(true);
comboCameras.setSelectedItem(-1);
if (model.getSize() > 0) {
try {
//setCamera((String)comboCameras.getSelectedItem());
if (App.hasArgument("cam")) {
comboCameras.setSelectedItem(App.getArgumentValue("cam"));
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
startTimer(2000);
}
@@ -284,9 +308,19 @@ public class Cameras extends Panel {
protected void onTimer() {
textState.setText((camera == null) ? "" : camera.getState().toString());
buttonConfig.setEnabled(camera != null);
if (App.hasArgument("s")){
System.out.println("Refresh");
try {
((Source)getDevice("image")).initialize();
} catch (IOException ex) {
Logger.getLogger(Cameras.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(Cameras.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Pen fitPen = new Pen(new Color(0, 192, 0));
Pen fitPen = new Pen(new Color(0, 192, 0), 2);
Overlay[] getFitOverlays(BufferedImage img){
Overlays.Polyline hpoly = null;
Overlays.Polyline vpoly = null;
@@ -297,7 +331,7 @@ public class Cameras extends Panel {
if (profile.hasVertical()) {
try {
int[] sum = Utils.integrateVertically(img);
int[] x = Arr.indexesInt(sum.length);
int[] x = Arr.indexesInt(sum.length);
double[] gaussian = fitGaussian(sum, x);
if (gaussian!=null){
System.out.println("Norm: " + gaussian[0] + " Mean: " + gaussian[1] + " Sigma: " + gaussian[2]);
@@ -305,12 +339,13 @@ public class Cameras extends Panel {
double[] fit = getFitFunction(gaussian, x);
int[] y = new int[x.length];
for (int i = 0; i < x.length; i++) {
y[i] = (int) (img.getHeight() - 1 - (((double) fit[i]) / 255 / factor)/2);
System.out.println("x=" + x[i] , "y=" + y[i], "f=" + fit[i]);
y[i] = (int) (img.getHeight() - 1 - (((double) fit[i]) / 255 / factor));
}
vpoly = new Overlays.Polyline(fitPen, x, y);
} else {
System.out.println("Fit failure");
}
} catch (Exception ex) {
ex.printStackTrace();
}
@@ -325,7 +360,7 @@ System.out.println("x=" + x[i] , "y=" + y[i], "f=" + fit[i]);
int[] y = new int[x.length];
for (int i = 0; i < x.length; i++) {
y[i] = (int) (((double) fit[i]) / 255 / factor)/2;
y[i] = (int) (((double) fit[i]) / 255 / factor);
}
hpoly = new Overlays.Polyline(fitPen, y, x);
}
@@ -365,7 +400,6 @@ double[] fitGaussianScript(int[] y, int[] x){
double[]fitGaussian(int[] y, int[] x){
try{
ScriptManager sm = Controller.getInstance().getScriptManager();
ArrayProperties pY = ArrayProperties.get(y);
GaussianCurveFitter fitter = GaussianCurveFitter.create().withStartPoint(new double[]{(pY.max-pY.min)/2,x[pY.maxIndex],1.0}).withMaxIterations(1000);
ArrayList<WeightedObservedPoint>values = new ArrayList<>();

View File

@@ -13,9 +13,10 @@ import datetime
knob = Channel("SINEG01-RSYS:SET-BEAM-PHASE", 'd', alias = "RF phase")
instrument = Channel("SINEG01-DICT215:CHARGE", 'd', alias = "Bunch Charge (ICT)")
lscan(knob, [instrument], -120., 60., 10.,2.0)
r = lscan(knob, [instrument], -120., 60., 10.,2.0)
#elog("Title", "" , get_plot_snapshots())
elog("SchottkyICT", "Data file: " + get_context().path + "\n\n" + r.print() , get_plot_snapshots())
#use_bpm = True
#