Closedown
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#Fri Aug 26 12:30:16 CEST 2016
|
||||
#Fri Aug 26 15:33:45 CEST 2016
|
||||
colormap=Grayscale
|
||||
colormapAutomatic=false
|
||||
colormapMax=255.0
|
||||
@@ -16,7 +16,7 @@ roiWidth=-1
|
||||
roiX=0
|
||||
roiY=0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
rotationCrop=true
|
||||
scale=1.0
|
||||
spatialCalOffsetX=NaN
|
||||
spatialCalOffsetY=NaN
|
||||
|
||||
@@ -23,14 +23,16 @@
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboCameras" pref="348" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboCameras" pref="290" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonConfig" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
|
||||
<Component id="textState" pref="131" max="32767" attributes="0"/>
|
||||
<Component id="textState" min="-2" pref="120" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -43,6 +45,7 @@
|
||||
<Component id="comboCameras" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="textState" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonConfig" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="renderer" pref="342" max="32767" attributes="0"/>
|
||||
@@ -79,5 +82,13 @@
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonConfig">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Config"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonConfigActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -11,15 +11,21 @@ import ch.psi.pshell.imaging.ImageListener;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.IO;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.ConfigDialog;
|
||||
import ch.psi.utils.swing.StandardDialog;
|
||||
import ch.psi.pshell.epics.PsiCamera;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.imaging.Data;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -28,11 +34,13 @@ public class Cameras extends Panel {
|
||||
|
||||
public Cameras() {
|
||||
initComponents();
|
||||
renderer.setPersistenceFile(Paths.get(getController().getSetup().getContextPath(), "Renderer_Cameras.bin"));
|
||||
}
|
||||
|
||||
final String configFolder= "/afs/psi.ch/intranet/SF/Applications/config/camtool";
|
||||
File[] cameraConfigFiles = new File[0];
|
||||
PsiCamera camera;
|
||||
String cameraName;
|
||||
CameraConfig config;
|
||||
|
||||
//Overridable callbacks
|
||||
@@ -134,8 +142,9 @@ public class Cameras extends Panel {
|
||||
try{
|
||||
Path configFile= Paths.get(configFolder, cameraName + ".json");
|
||||
String json = new String(Files.readAllBytes(configFile));
|
||||
this.cameraName=cameraName;
|
||||
//SwingUtils.showMessage(null, "", json);
|
||||
camera = new PsiCamera(cameraName, cameraName);
|
||||
camera = new PsiCamera("CurrentCamera", cameraName);
|
||||
try{
|
||||
config = (CameraConfig) JsonSerializer.decode(json, CameraConfig.class);
|
||||
camera.getConfig().flipHorizontally = config.getMirrorX();
|
||||
@@ -155,9 +164,14 @@ public class Cameras extends Panel {
|
||||
config = null;
|
||||
showException(ex);
|
||||
}
|
||||
camera.getConfig().save();
|
||||
camera.getConfig().save();
|
||||
camera.initialize();
|
||||
camera.setMonitored(true);
|
||||
|
||||
renderer.setDevice(camera);
|
||||
renderer.setShowReticle(true);
|
||||
renderer.setAutoScroll(true);
|
||||
|
||||
camera.addListener(renderer);
|
||||
camera.addListener(new ImageListener() {
|
||||
@Override
|
||||
public void onImage(Object o, BufferedImage bi, Data data) {
|
||||
@@ -170,8 +184,7 @@ public class Cameras extends Panel {
|
||||
public void onError(Object o, Exception excptn) {
|
||||
}
|
||||
});
|
||||
renderer.setShowReticle(true);
|
||||
camera.initialize();
|
||||
|
||||
|
||||
} finally{
|
||||
onTimer();
|
||||
@@ -181,6 +194,7 @@ public class Cameras extends Panel {
|
||||
@Override
|
||||
protected void onTimer() {
|
||||
textState.setText((camera==null) ? "" : camera.getState().toString());
|
||||
buttonConfig.setEnabled(camera!=null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -192,6 +206,7 @@ public class Cameras extends Panel {
|
||||
comboCameras = new javax.swing.JComboBox();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
textState = new javax.swing.JTextField();
|
||||
buttonConfig = new javax.swing.JButton();
|
||||
|
||||
jLabel1.setText("Camera:");
|
||||
|
||||
@@ -208,6 +223,13 @@ public class Cameras extends Panel {
|
||||
textState.setDisabledTextColor(new java.awt.Color(0, 0, 0));
|
||||
textState.setEnabled(false);
|
||||
|
||||
buttonConfig.setText("Config");
|
||||
buttonConfig.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonConfigActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -219,12 +241,14 @@ public class Cameras extends Panel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboCameras, 0, 348, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(comboCameras, 0, 290, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonConfig)
|
||||
.addGap(10, 10, 10)
|
||||
.addComponent(jLabel2)
|
||||
.addGap(4, 4, 4)
|
||||
.addComponent(textState, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)))
|
||||
.addGap(26, 26, 26))
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -234,7 +258,8 @@ public class Cameras extends Panel {
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonConfig))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
|
||||
.addGap(6, 6, 6))
|
||||
@@ -246,14 +271,37 @@ public class Cameras extends Panel {
|
||||
|
||||
private void comboCamerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCamerasActionPerformed
|
||||
try{
|
||||
String camera = (String) comboCameras.getSelectedItem();
|
||||
setCamera(camera);
|
||||
setCamera((String) comboCameras.getSelectedItem());
|
||||
} catch(Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_comboCamerasActionPerformed
|
||||
|
||||
private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed
|
||||
try{
|
||||
final ConfigDialog dlg = new ConfigDialog((Frame) getTopLevelAncestor(), false);
|
||||
dlg.setTitle("Device Configuration: " + cameraName);
|
||||
dlg.setConfig(camera.getConfig());
|
||||
dlg.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
dlg.setListener((StandardDialog sd, boolean accepted) -> {
|
||||
if (sd.getResult()) {
|
||||
try {
|
||||
camera.getConfig().save();
|
||||
} catch (IOException ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
dlg.setVisible(true);
|
||||
SwingUtils.centerComponent(getTopLevelAncestor(), dlg);
|
||||
dlg.requestFocus();
|
||||
} catch(Exception ex){
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonConfigActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonConfig;
|
||||
private javax.swing.JComboBox comboCameras;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
|
||||
Reference in New Issue
Block a user