This commit is contained in:
gobbo_a
2016-09-29 15:16:37 +02:00
parent 8b7d06f6cf
commit 9111b9a815
6 changed files with 168 additions and 57 deletions

View File

@@ -1,10 +1,10 @@
#Wed Sep 28 09:24:26 CEST 2016
colormap=Grayscale
#Thu Sep 29 15:13:32 CEST 2016
colormap=Temperature
colormapAutomatic=true
colormapMax=0.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
flipVertically=true
grayscale=false
imageHeight=1200
imageWidth=1246
@@ -18,9 +18,9 @@ roiY=0
rotation=0.0
rotationCrop=true
scale=1.0
spatialCalOffsetX=NaN
spatialCalOffsetY=NaN
spatialCalScaleX=NaN
spatialCalScaleY=NaN
spatialCalOffsetX=-630.0
spatialCalOffsetY=-612.0
spatialCalScaleX=26.761819803746654
spatialCalScaleY=-26.595744680851062
spatialCalUnits=mm
transpose=false

View File

@@ -1,4 +1,4 @@
#Thu Sep 08 08:33:51 CEST 2016
#Thu Sep 29 08:47:56 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 08 08:33:52 CEST 2016
#Thu Sep 29 08:47:56 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

@@ -2,6 +2,7 @@
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import java.awt.Component;
@@ -20,7 +21,14 @@ public class Correlation extends Panel {
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
super.onInitialize(runCount);
this.startTimer(100, 10);
if (App.hasArgument("dx")) {
textDevX.setText(App.getArgumentValue("dx"));
}
if (App.hasArgument("dy")) {
textDevY.setText(App.getArgumentValue("dy"));
}
}
@Override

View File

@@ -75,7 +75,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="renderer" pref="122" max="32767" attributes="0"/>
<Component id="renderer" pref="514" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@@ -272,14 +272,18 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="pauseSelection" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="panelScreen" alignment="0" max="32767" attributes="0"/>
<Component id="panelScreen1" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel5" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -296,7 +300,9 @@
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="65" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="pauseSelection" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -773,6 +779,11 @@
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.swing.ValueSelection" name="pauseSelection">
<Properties>
<Property name="decimals" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@@ -11,6 +11,7 @@ import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.imaging.ImageListener;
import ch.psi.utils.State;
import ch.psi.utils.IO;
import ch.psi.utils.Chrono;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.utils.swing.TextEditor;
import ch.psi.pshell.epics.PsiCamera;
@@ -18,10 +19,7 @@ import ch.psi.pshell.epics.Camtool;
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.epics.ArraySource;
import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.epics.ChannelDoubleArray;
import ch.psi.pshell.epics.ChannelInteger;
import ch.psi.pshell.epics.ChannelIntegerArray;
import ch.psi.pshell.epics.DiscretePositioner;
import ch.psi.pshell.epics.Epics;
import ch.psi.pshell.imaging.Colormap;
@@ -34,10 +32,14 @@ import ch.psi.pshell.imaging.Overlay;
import ch.psi.pshell.imaging.Overlays;
import ch.psi.pshell.imaging.Overlays.Text;
import ch.psi.pshell.imaging.Pen;
import ch.psi.pshell.imaging.Renderer;
import ch.psi.pshell.imaging.RendererListener;
import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.imaging.Source;
import ch.psi.pshell.scripting.InterpreterResult;
import ch.psi.pshell.scripting.ScriptManager;
import ch.psi.pshell.swing.ValueSelection;
import ch.psi.pshell.swing.ValueSelection.ValueSelectionListener;
import ch.psi.utils.Arr;
import ch.psi.utils.ArrayProperties;
import ch.psi.utils.Convert;
@@ -70,6 +72,23 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
*/
public class ScreenPanel extends Panel {
final String configFolder = "/afs/psi.ch/intranet/SF/Applications/config/camtool";
File[] cameraConfigFiles = new File[0];
ArraySource camera;
String cameraName;
String cameraConfigJson;
CameraConfig config;
int polling = 1000;
Overlay marker = null;
JDialog histogramDialog;
DiscretePositioner screen;
DiscretePositioner filter;
boolean showFit;
final ArrayList<Data> imageBuffer = new ArrayList();
int imageBufferLenght = 0;
Text imageBufferOverlay;
public ScreenPanel() {
initComponents();
renderer.setPersistenceFile(Paths.get(getController().getSetup().getContextPath(), "Renderer_Cameras.bin"));
@@ -90,9 +109,46 @@ public class ScreenPanel extends Panel {
ex.printStackTrace();
}
}
if (App.hasArgument("buf")) {
try {
imageBufferLenght = Integer.valueOf(App.getArgumentValue("buf"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
renderer.setProfileNormalized(true);
renderer.setShowProfileLimits(true);
showFit = buttonFit.isSelected();
if (imageBufferLenght>1){
renderer.addListener(new RendererListener() {
@Override
public void onImage(Renderer renderer, Object origin, BufferedImage image, Data data) {
if (data!=null){
synchronized(imageBuffer){
imageBuffer.add(data);
if (imageBuffer.size() > imageBufferLenght){
imageBuffer.remove(0);
}
}
}
}
});
}
pauseSelection.setVisible(false);
pauseSelection.setMinValue(1);
pauseSelection.addListener(new ValueSelectionListener() {
@Override
public void onValueChanged(ValueSelection origin, double value, boolean editing){
if (editing && (value>=1) && (value<=imageBuffer.size())){
updatePause();
}
}
});
imageBufferOverlay = new Text(renderer.getPenErrorText(), "", new Font("Verdana", Font.PLAIN, 12), new Point(-100, 20));
imageBufferOverlay.setFixed(true);
imageBufferOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_RIGHT);
}
@Override
@@ -105,19 +161,6 @@ public class ScreenPanel extends Panel {
}
}
final String configFolder = "/afs/psi.ch/intranet/SF/Applications/config/camtool";
File[] cameraConfigFiles = new File[0];
ArraySource camera;
String cameraName;
String cameraConfigJson;
CameraConfig config;
int polling = 1000;
Overlay marker = null;
JDialog histogramDialog;
DiscretePositioner screen;
DiscretePositioner filter;
boolean showFit;
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
@@ -128,13 +171,7 @@ public class ScreenPanel extends Panel {
((Source) getDevice("image")).addListener(new ImageListener() {
@Override
public void onImage(Object o, BufferedImage bi, Data data) {
if ((bi == null) || (!showFit)) {
fitOv = null;
} else {
Overlay[] fo = getFitOverlays(data);
renderer.updateOverlays(fo, fitOv);
fitOv = fo;
}
manageFit(bi, data);
}
@Override
@@ -169,6 +206,12 @@ public class ScreenPanel extends Panel {
startTimer(1000);
}
void manageFit(BufferedImage bi, Data data){
Overlay[] fo = ((bi == null) || (!showFit)) ? null : getFitOverlays(data);
renderer.updateOverlays(fo, fitOv);
fitOv = fo;
}
@Override
public void onStateChange(State state, State former) {
@@ -325,7 +368,7 @@ public class ScreenPanel extends Panel {
camera.getConfig().spatialCalOffsetX = config.getCalOffsetX();
camera.getConfig().spatialCalOffsetY = config.getCalOffsetY();
camera.getConfig().spatialCalScaleX = config.getScaleX();
camera.getConfig().spatialCalScaleY = config.getScaleY();
camera.getConfig().spatialCalScaleY = - config.getScaleY();
} catch (Exception ex) {
camera.getConfig().spatialCalOffsetX = Double.NaN;
camera.getConfig().spatialCalOffsetY = Double.NaN;
@@ -343,7 +386,7 @@ public class ScreenPanel extends Panel {
camera.getConfig().spatialCalOffsetX = ((Camtool) camera).calOffX.read();
camera.getConfig().spatialCalOffsetY = ((Camtool) camera).calOffY.read();
camera.getConfig().spatialCalScaleX = ((Camtool) camera).calScaleX.read();
camera.getConfig().spatialCalScaleY = ((Camtool) camera).calScaleY.read();
camera.getConfig().spatialCalScaleY = - ((Camtool) camera).calScaleY.read();
} catch (Exception ex) {
System.err.println(ex.getMessage());
camera.getConfig().spatialCalOffsetX = 0.0;
@@ -368,7 +411,7 @@ public class ScreenPanel extends Panel {
camera.addListener(new ImageListener() {
@Override
public void onImage(Object o, BufferedImage bi, Data data) {
public void onImage(Object o, BufferedImage bi, Data data) {
if (firstImage && (bi!=null)){
if ((renderer.getMode()==RendererMode.Zoom) || (renderer.getMode()==RendererMode.Fixed)){
SwingUtilities.invokeLater(new Runnable() {
@@ -551,6 +594,16 @@ public class ScreenPanel extends Panel {
Logger.getLogger(ScreenPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (renderer.isPaused() != buttonPause.isSelected()){
buttonPause.setSelected(renderer.isPaused());
buttonPauseActionPerformed(null);
}
if (renderer.getShowReticle()!= buttonReticle.isSelected()){
buttonReticle.setSelected(renderer.getShowReticle());
}
if ((renderer.getMarker()==null) && buttonMarker.isSelected()){
buttonMarker.setSelected(false);
}
updateZoom();
updateColormap();
buttonSave.setSelected(renderer.isSnapshotDialogVisible());
@@ -640,6 +693,8 @@ public class ScreenPanel extends Panel {
text = new Overlays.Text(fitPen,
String.format("x = %f \n y = %f" , data.getX((int) Math.round(xMean)), data.getY((int) Math.round(yMean))),
new Font(Font.MONOSPACED, 0, 14), new Point(20,20));
text.setFixed(true);
text.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
}
return new Overlay[]{hpoly, vpoly, cross, text};
@@ -990,6 +1045,20 @@ public class ScreenPanel extends Panel {
renderer.setViewPosition(topleft);
}
}
void updatePause(){
int index = ((int)pauseSelection.getValue())-1;
synchronized(imageBuffer){
if (index<imageBuffer.size()){
Data data = imageBuffer.get(index);
BufferedImage image = camera.generateImage(data);
renderer.setImage(null, image, data);
imageBufferOverlay.update(Chrono.getTimeStr(data.getTimestamp(), "HH:mm:ss.SSS"));
manageFit(image, data);
}
}
}
////////
@SuppressWarnings("unchecked")
@@ -1046,6 +1115,7 @@ public class ScreenPanel extends Panel {
panelScreen1 = new javax.swing.JPanel();
valueFilter = new ch.psi.pshell.swing.DeviceValuePanel();
comboFilter = new javax.swing.JComboBox();
pauseSelection = new ch.psi.pshell.swing.ValueSelection();
setPreferredSize(new java.awt.Dimension(873, 600));
@@ -1206,7 +1276,7 @@ public class ScreenPanel extends Panel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 602, Short.MAX_VALUE)
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
@@ -1216,7 +1286,7 @@ public class ScreenPanel extends Panel {
.addContainerGap()
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
@@ -1542,18 +1612,23 @@ public class ScreenPanel extends Panel {
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pauseSelection.setDecimals(0);
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(panelScreen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelScreen1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(pauseSelection, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addComponent(panelScreen, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelScreen1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -1568,7 +1643,9 @@ public class ScreenPanel extends Panel {
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(65, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pauseSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@@ -1640,14 +1717,25 @@ public class ScreenPanel extends Panel {
private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed
try {
renderer.removeOverlay(imageBufferOverlay);
if (camera != null) {
if (buttonPause.isSelected()) {
renderer.pause();
} else {
renderer.resume();
synchronized(imageBuffer){
if (buttonPause.isSelected()) {
renderer.pause();
} else {
imageBuffer.clear();
renderer.resume();
}
pauseSelection.setVisible(buttonPause.isSelected() && (imageBuffer.size()>0));
if (pauseSelection.isVisible()){
renderer.addOverlay(imageBufferOverlay);
pauseSelection.setMaxValue(imageBuffer.size());
pauseSelection.setValue(imageBuffer.size());;
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
showException(ex);
}
}//GEN-LAST:event_buttonPauseActionPerformed
@@ -1775,6 +1863,9 @@ public class ScreenPanel extends Panel {
source.getConfig().colormapMax = buttonFullRange.isSelected() ? Double.NaN : (Integer) spinnerMax.getValue();
source.getConfig().save();
source.refresh();
if (buttonPause.isSelected()){
updatePause();
}
}
} catch (Exception ex) {
showException(ex);
@@ -1905,6 +1996,7 @@ public class ScreenPanel extends Panel {
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JPanel panelScreen;
private javax.swing.JPanel panelScreen1;
private ch.psi.pshell.swing.ValueSelection pauseSelection;
private ch.psi.pshell.imaging.Renderer renderer;
private javax.swing.JSpinner spinnerMax;
private javax.swing.JSpinner spinnerMin;