From cfd321ca3f943a7ece8fd50cd21cc281ee4b68f2 Mon Sep 17 00:00:00 2001 From: sfop Date: Tue, 21 Mar 2017 16:09:56 +0100 Subject: [PATCH] Startup --- devices/CurrentCamera.properties | 26 ++- devices/cam1.properties | 6 +- devices/cam2.properties | 8 +- devices/camtool.properties | 4 +- plugins/ScreenPanel.form | 248 +++++++++++++------- plugins/ScreenPanel.java | 386 +++++++++++++++++++++---------- script/test/CamtoolBug.py | 6 + 7 files changed, 454 insertions(+), 230 deletions(-) create mode 100644 script/test/CamtoolBug.py diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 753932a..3c9bcc4 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,27 +1,29 @@ -#Fri Mar 17 11:16:21 CET 2017 -colormap=Temperature -colormapAutomatic=false -colormapMax=NaN -colormapMin=NaN +#Tue Mar 21 16:07:28 CET 2017 +colormap=Flame +colormapAutomatic=true +colormapMax=1323.0 +colormapMin=0.0 flipHorizontally=false flipVertically=false grayscale=false -imageHeight=1200 -imageWidth=1246 +imageHeight=2160 +imageWidth=2560 invert=false +regionStartX=1 +regionStartY=1 rescaleFactor=1.0 rescaleOffset=0.0 roiHeight=-1 roiWidth=-1 roiX=0 roiY=0 -rotation=0.0 +rotation=270.0 rotationCrop=false scale=1.0 serverURL=localhost\:10000 -spatialCalOffsetX=-327.26264532238156 -spatialCalOffsetY=-605.5045783900576 -spatialCalScaleX=-26.761820720381525 -spatialCalScaleY=-26.595745478002502 +spatialCalOffsetX=-1056.0 +spatialCalOffsetY=-1419.0 +spatialCalScaleX=-8.51063829787234 +spatialCalScaleY=-8.559201141226819 spatialCalUnits=mm transpose=false diff --git a/devices/cam1.properties b/devices/cam1.properties index 77ecb1f..9f61706 100644 --- a/devices/cam1.properties +++ b/devices/cam1.properties @@ -1,5 +1,5 @@ -#Tue Feb 14 10:49:34 CET 2017 -colormap=Grayscale +#Tue Mar 21 12:18:16 CET 2017 +colormap=Temperature colormapAutomatic=true colormapMax=30000.0 colormapMin=0.0 @@ -11,6 +11,8 @@ imageWidth=1280 invert=false offsetX=0.0 offsetY=0.0 +regionStartX=865 +regionStartY=267 rescaleFactor=1.0 rescaleOffset=0.0 roiHeight=-1 diff --git a/devices/cam2.properties b/devices/cam2.properties index dd86cb4..13f8ce4 100644 --- a/devices/cam2.properties +++ b/devices/cam2.properties @@ -1,4 +1,4 @@ -#Tue Feb 14 10:49:34 CET 2017 +#Tue Mar 21 12:18:16 CET 2017 colormap=Grayscale colormapAutomatic=true colormapMax=255.0 @@ -11,6 +11,8 @@ imageWidth=1744 invert=false offsetX=0.0 offsetY=0.0 +regionStartX=433 +regionStartY=241 rescaleFactor=1.0 rescaleOffset=0.0 roiHeight=-1 @@ -24,7 +26,7 @@ scaleX=1.0 scaleY=1.0 spatialCalOffsetX=NaN spatialCalOffsetY=NaN -spatialCalScaleX=NaN -spatialCalScaleY=NaN +spatialCalScaleX=433.0 +spatialCalScaleY=241.0 spatialCalUnits=mm transpose=false diff --git a/devices/camtool.properties b/devices/camtool.properties index b80f0d4..b9db5da 100644 --- a/devices/camtool.properties +++ b/devices/camtool.properties @@ -1,4 +1,4 @@ -#Thu Mar 16 17:37:12 CET 2017 +#Tue Mar 21 12:06:25 CET 2017 colormap=Temperature colormapAutomatic=true colormapMax=578.797 @@ -18,7 +18,7 @@ roiY=0 rotation=0.0 rotationCrop=false scale=1.0 -spatialCalOffsetX=16859.947265625 +spatialCalOffsetX=8751.115234375 spatialCalOffsetY=16276.595703125 spatialCalScaleX=-26.761820720381525 spatialCalScaleY=-26.595744663521685 diff --git a/plugins/ScreenPanel.form b/plugins/ScreenPanel.form index 9bc51eb..96f341e 100644 --- a/plugins/ScreenPanel.form +++ b/plugins/ScreenPanel.form @@ -188,9 +188,9 @@ - + - + @@ -210,8 +210,8 @@ + - @@ -243,12 +243,12 @@ - + - + - + @@ -256,12 +256,12 @@ - + - + - + @@ -454,31 +454,33 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -487,71 +489,34 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -631,6 +596,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/ScreenPanel.java b/plugins/ScreenPanel.java index 4ad6bb6..51b09f5 100644 --- a/plugins/ScreenPanel.java +++ b/plugins/ScreenPanel.java @@ -45,6 +45,7 @@ import ch.psi.pshell.swing.ValueSelection.ValueSelectionListener; import ch.psi.utils.Arr; import ch.psi.utils.ArrayProperties; import ch.psi.utils.Convert; +import ch.psi.utils.TcpClient; import ch.psi.utils.swing.Editor.EditorDialog; import ch.psi.utils.swing.MainFrame; import ch.psi.utils.swing.SwingUtils.OptionResult; @@ -58,6 +59,7 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; import java.io.FileInputStream; +import java.net.ServerSocket; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -103,6 +105,8 @@ public class ScreenPanel extends Panel { Overlay errorOverlay; boolean requestCameraListUpdate; Integer localServerPort; + Process privateServer; + String serverUrl; Double getCamtoolDouble(String name) { return (Double) Convert.toDouble(((Camtool) camera).getValue(name)); @@ -176,16 +180,25 @@ public class ScreenPanel extends Panel { } catch (Exception ex) { ex.printStackTrace(); } - } + } if (App.hasArgument("priv_srv")) { - localServerPort = 1000; + try { + try(ServerSocket s = new ServerSocket(0)){ + localServerPort = s.getLocalPort(); + } + } catch (Exception ex) { + ex.printStackTrace(); + } } if (App.hasArgument("srv_port")) { localServerPort = Integer.valueOf(App.getArgumentValue("srv_port")); } + if (App.hasArgument("srv_url")) { + serverUrl = App.getArgumentValue("srv_url"); + } if (App.hasArgument("calc")) { useCamtoolStats = false; @@ -213,6 +226,7 @@ public class ScreenPanel extends Panel { @Override public void onSelectionFinished(Renderer renderer, Overlay overlay) { try { + renderer.setShowReticle(false); Rectangle roi = overlay.isFixed() ? renderer.toImageCoord(overlay.getBounds()) : overlay.getBounds(); if (((Camtool) camera).isRoiEnabled()) { int[] cur = ((Camtool) camera).getRoi(); @@ -222,7 +236,7 @@ public class ScreenPanel extends Panel { } } catch (Exception ex) { } finally { - renderer.removeListener(this); + renderer.removeListener(this); } } @@ -241,10 +255,11 @@ public class ScreenPanel extends Panel { renderer.abortSelection(); if (camera instanceof Camtool) { try { + renderer.setShowReticle(false); ((Camtool) camera).resetRoi(); } catch (IOException ex) { showException(ex); - } + } } }); @@ -298,14 +313,64 @@ public class ScreenPanel extends Panel { buttonCamtool.setSelected(!direct); buttonDirect.setSelected(direct); } + if (App.hasArgument("priv_srv")) { + try { + System.out.println("Starting camtool server on port: " + localServerPort); + //Was creating sub-processes which cannot be destroyed. + //String cmd = "cam_server"; + //cmd = "source /opt/gfa/python\n" + cmd; + //privateServer = Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd}); + String cmd = "/opt/gfa/python-3.5/2.4.1/bin/python /opt/gfa/python-3.5/latest/bin/cam_server"; + cmd = cmd + " -p " + localServerPort + " -b " + CONFIG_FOLDER; + privateServer = Runtime.getRuntime().exec(cmd); + //System.out.println("pid = " + Sys.getPid(privateServer)); + long start = System.currentTimeMillis(); + while (true){ + try (TcpClient c = new TcpClient("localhost", localServerPort)){ + try{ + c.connect(); + System.out.println("Connected to camtool server on port: " + localServerPort); + break; + } catch (Exception ex){ + } + } + Thread.sleep(10); + if ((System.currentTimeMillis() - start) > 5000){ + errorOverlay = new Text(renderer.getPenErrorText(), "Error connecting to server at port " + localServerPort , new Font("Verdana", Font.PLAIN, 12), new Point(20, 20)); + renderer.addOverlay(errorOverlay); + break; + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + @Override public void onStop() { - if (camera != null) { - camera.close(); - camera = null; - } + try{ + if (camera != null) { + camera.close(); + camera = null; + } + if (privateServer!=null){ + System.out.println("Closing camtool server"); + //int pid = Sys.getPid(privateServer); + privateServer.destroyForcibly(); + //if (pid>0){ + // System.out.println("Killing pid = " + pid); + // Runtime.getRuntime().exec("kill " + pid); + // + //} + privateServer = null; + } + } catch (Exception ex) { + ex.printStackTrace(); + } super.onStop(); } @@ -365,7 +430,7 @@ public class ScreenPanel extends Panel { DefaultComboBoxModel getCameraListFromCamtool() throws IOException, InterruptedException { DefaultComboBoxModel model = new DefaultComboBoxModel(); - Camtool camtool = (localServerPort != null) ? new Camtool(CAMERA_DEVICE_NAME, "localhost:"+localServerPort) : new Camtool(CAMERA_DEVICE_NAME); + Camtool camtool = newCamtool(); try { camtool.initialize(); List cameras = camtool.getCameras(); @@ -379,6 +444,13 @@ public class ScreenPanel extends Panel { } return model; } + + Camtool newCamtool(){ + if (serverUrl!=null){ + return new Camtool(CAMERA_DEVICE_NAME, serverUrl); + } + return (localServerPort != null) ? new Camtool(CAMERA_DEVICE_NAME, "localhost:"+localServerPort) : new Camtool(CAMERA_DEVICE_NAME); + } boolean updatingCameraSelection; @@ -414,16 +486,22 @@ public class ScreenPanel extends Panel { } } + final Object lockOverlays = new Object(); + void manageFit(BufferedImage bi, Data data) { Overlay[] fo = ((bi == null) || (!showFit)) ? null : getFitOverlays(data); - renderer.updateOverlays(fo, fitOv); - fitOv = fo; + synchronized(lockOverlays){ + renderer.updateOverlays(fo, fitOv); + fitOv = fo; + } } void manageUserOverlays(BufferedImage bi, Data data) { Overlay[] fo = (bi == null) ? null : getUserOverlays(data); - renderer.updateOverlays(fo, userOv); - userOv = fo; + synchronized(lockOverlays){ + renderer.updateOverlays(fo, userOv); + userOv = fo; + } } @Override @@ -523,7 +601,6 @@ public class ScreenPanel extends Panel { void setCamera(String cameraName) throws IOException, InterruptedException { System.out.println("Setting camera: " + cameraName + " [" + (buttonCamtool.isSelected() ? "camtool" : "direct") + "]"); - //renderer.removeOverlay(errorOverlay); parseUserOverlays(); errorOverlay = null; buttonGrabBackground.setEnabled(false); @@ -569,9 +646,8 @@ public class ScreenPanel extends Panel { Path configFile = Paths.get(CONFIG_FOLDER, cameraName + ".json"); cameraConfigJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null; - if (buttonCamtool.isSelected()) { - //camera = new Camtool(CAMTOOL_DEVICE_NAME, "gfa-lc6-64:8080"); - camera = new Camtool(CAMERA_DEVICE_NAME); + if (buttonCamtool.isSelected()) { + camera = newCamtool(); camera.getConfig().flipHorizontally = false; camera.getConfig().flipVertically = false; camera.getConfig().rotation = 0.0; @@ -610,7 +686,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; @@ -635,26 +711,32 @@ public class ScreenPanel extends Panel { buttonGrabBackground.setEnabled(true); ((Camtool) camera).startReceiver(); + } else { + if (camera.getConfig() instanceof PsiCamera.PsiCameraConfig){ + if (camera.getConfig().isCalibrated()){ + camera.getConfig().spatialCalOffsetX += ((PsiCamera.PsiCameraConfig)camera.getConfig()).regionStartX; + camera.getConfig().spatialCalOffsetY += ((PsiCamera.PsiCameraConfig)camera.getConfig()).regionStartY; + } + } + if (polling <= 0) { + camera.setMonitored(true); + } else { + camera.setPolling(polling); + } } buttonReticle.setEnabled(camera.getConfig().isCalibrated()); - camera.getConfig().save(); - polling = -250; - if (polling <= 0) { - camera.setMonitored(true); - } else { - camera.setPolling(-polling); - } + camera.getConfig().save(); renderer.setDevice(camera); renderer.setAutoScroll(true); renderer.setMarker(marker); - firstImage = true; + imageSize = null; camera.addListener(new ImageListener() { @Override public void onImage(Object o, BufferedImage bi, Data data) { if (bi != null) { - if (firstImage) { + if ((imageSize== null) || imageSize.width!=bi.getWidth() || imageSize.height!=bi.getHeight()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { @@ -664,7 +746,7 @@ public class ScreenPanel extends Panel { checkReticle(); } }); - firstImage = false; + imageSize = new Dimension (bi.getWidth(), bi.getHeight()); } renderer.setProfileSize(Math.min(bi.getWidth(), bi.getHeight())); } @@ -709,6 +791,7 @@ public class ScreenPanel extends Panel { //checkReticle(); onTimer(); } + onChangeColormap(null); if (changed) { comboScreen.setModel(new DefaultComboBoxModel()); @@ -757,7 +840,7 @@ public class ScreenPanel extends Panel { } - volatile Boolean firstImage; + volatile Dimension imageSize; void checkReticle() { if ((renderer.getDevice() != null) && (camera != null) && (camera.getConfig().isCalibrated()) && buttonReticle.isSelected()) { @@ -828,6 +911,12 @@ public class ScreenPanel extends Panel { case Temperature: buttonTemperature.setSelected(true); break; + case Flame: + buttonFlame.setSelected(true); + break; + case Inverted: + buttonInverted.setSelected(true); + break; default: buttonGroup2.clearSelection(); @@ -892,7 +981,7 @@ public class ScreenPanel extends Panel { } textState.setText((camera == null) ? "" : camera.getState().toString()); - buttonConfig.setEnabled(camera != null); + buttonArgs.setEnabled(camera != null); if (App.hasArgument("s")) { try { ((Source) getDevice("image")).initialize(); @@ -1471,9 +1560,9 @@ public class ScreenPanel extends Panel { textState = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); comboCameras = new javax.swing.JComboBox(); - buttonSetup = new javax.swing.JButton(); - jLabel1 = new javax.swing.JLabel(); buttonConfig = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + buttonArgs = new javax.swing.JButton(); buttonStop = new javax.swing.JButton(); renderer = new ch.psi.pshell.imaging.Renderer(); jPanel4 = new javax.swing.JPanel(); @@ -1485,9 +1574,6 @@ public class ScreenPanel extends Panel { buttonZoom05 = new javax.swing.JRadioButton(); buttonZoom2 = new javax.swing.JRadioButton(); jPanel2 = new javax.swing.JPanel(); - buttonGrayscale = new javax.swing.JRadioButton(); - buttonRainbow = new javax.swing.JRadioButton(); - buttonTemperature = new javax.swing.JRadioButton(); buttonFullRange = new javax.swing.JRadioButton(); buttonManual = new javax.swing.JRadioButton(); jLabel3 = new javax.swing.JLabel(); @@ -1496,6 +1582,12 @@ public class ScreenPanel extends Panel { spinnerMax = new javax.swing.JSpinner(); buttonAutomatic = new javax.swing.JRadioButton(); checkHistogram = new javax.swing.JCheckBox(); + jPanel8 = new javax.swing.JPanel(); + buttonInverted = new javax.swing.JRadioButton(); + buttonFlame = new javax.swing.JRadioButton(); + buttonTemperature = new javax.swing.JRadioButton(); + buttonRainbow = new javax.swing.JRadioButton(); + buttonGrayscale = new javax.swing.JRadioButton(); jPanel5 = new javax.swing.JPanel(); buttonCamtool = new javax.swing.JRadioButton(); buttonDirect = new javax.swing.JRadioButton(); @@ -1610,19 +1702,19 @@ public class ScreenPanel extends Panel { } }); - buttonSetup.setText("Setup"); - buttonSetup.addActionListener(new java.awt.event.ActionListener() { + buttonConfig.setText("Config"); + buttonConfig.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonSetupActionPerformed(evt); + buttonConfigActionPerformed(evt); } }); jLabel1.setText("Camera:"); - buttonConfig.setText("Config"); - buttonConfig.addActionListener(new java.awt.event.ActionListener() { + buttonArgs.setText("Setup"); + buttonArgs.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonConfigActionPerformed(evt); + buttonArgsActionPerformed(evt); } }); @@ -1641,12 +1733,12 @@ public class ScreenPanel extends Panel { .addGap(0, 0, 0) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(comboCameras, 0, 178, Short.MAX_VALUE) + .addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonArgs) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonConfig) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonSetup) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonStop) .addGap(18, 18, 18) .addComponent(jLabel2) @@ -1655,7 +1747,7 @@ public class ScreenPanel extends Panel { .addGap(0, 0, 0)) ); - jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfig, buttonSetup, buttonStop}); + jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonArgs, buttonConfig, buttonStop}); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -1666,8 +1758,8 @@ public class ScreenPanel extends Panel { .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(buttonArgs) .addComponent(buttonConfig) - .addComponent(buttonSetup) .addComponent(buttonStop)) .addGap(0, 0, 0)) ); @@ -1784,30 +1876,6 @@ public class ScreenPanel extends Panel { jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Colormap")); - buttonGroup2.add(buttonGrayscale); - buttonGrayscale.setText("Grayscale"); - buttonGrayscale.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - buttonGroup2.add(buttonRainbow); - buttonRainbow.setText("Rainbow"); - buttonRainbow.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - - buttonGroup2.add(buttonTemperature); - buttonTemperature.setText("Temperature"); - buttonTemperature.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - onChangeColormap(evt); - } - }); - buttonGroup3.add(buttonFullRange); buttonFullRange.setText("Full range"); buttonFullRange.addActionListener(new java.awt.event.ActionListener() { @@ -1861,31 +1929,106 @@ public class ScreenPanel extends Panel { } }); + buttonGroup2.add(buttonInverted); + buttonInverted.setText("Inverted"); + buttonInverted.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonFlame); + buttonFlame.setText("Flame"); + buttonFlame.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonTemperature); + buttonTemperature.setText("Temperature"); + buttonTemperature.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonRainbow); + buttonRainbow.setText("Rainbow"); + buttonRainbow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + buttonGroup2.add(buttonGrayscale); + buttonGrayscale.setText("Grayscale"); + buttonGrayscale.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onChangeColormap(evt); + } + }); + + javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); + jPanel8.setLayout(jPanel8Layout); + jPanel8Layout.setHorizontalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup() + .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonGrayscale) + .addComponent(buttonInverted)) + .addGap(20, 20, 20)) + .addComponent(buttonFlame)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonTemperature) + .addComponent(buttonRainbow))) + .addGap(0, 0, 0)) + ); + jPanel8Layout.setVerticalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addComponent(buttonGrayscale) + .addGap(0, 0, 0) + .addComponent(buttonInverted) + .addGap(0, 0, 0) + .addComponent(buttonFlame) + .addGap(0, 0, 0) + .addComponent(buttonRainbow) + .addGap(0, 0, 0) + .addComponent(buttonTemperature) + .addGap(0, 0, 0)) + ); + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(jLabel4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonAutomatic) - .addComponent(buttonFullRange) - .addComponent(buttonManual) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(checkHistogram) - .addComponent(buttonTemperature) - .addComponent(buttonRainbow) - .addComponent(buttonGrayscale)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(checkHistogram) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonAutomatic) + .addComponent(buttonFullRange) + .addComponent(buttonManual) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4) + .addComponent(jLabel3)) + .addGap(2, 2, 2) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); @@ -1894,28 +2037,25 @@ public class ScreenPanel extends Panel { jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() - .addGap(4, 4, 4) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(buttonAutomatic) - .addComponent(buttonGrayscale)) - .addGap(0, 0, 0) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(buttonFullRange) - .addComponent(buttonRainbow)) - .addGap(0, 0, 0) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(buttonManual) - .addComponent(buttonTemperature)) + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(buttonAutomatic) + .addGap(0, 0, 0) + .addComponent(buttonFullRange) + .addGap(0, 0, 0) + .addComponent(buttonManual) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(spinnerMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel4) - .addComponent(spinnerMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(checkHistogram)) - .addContainerGap()) + .addComponent(checkHistogram)) ); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Source")); @@ -2166,7 +2306,7 @@ public class ScreenPanel extends Panel { } }//GEN-LAST:event_comboCamerasActionPerformed - private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed + private void buttonArgsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonArgsActionPerformed try { if (camera != null) { TextEditor editor = new TextEditor(); @@ -2181,9 +2321,9 @@ public class ScreenPanel extends Panel { } catch (Exception ex) { showException(ex); } - }//GEN-LAST:event_buttonConfigActionPerformed + }//GEN-LAST:event_buttonArgsActionPerformed - private void buttonSetupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetupActionPerformed + private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed try { if (camera != null) { this.showDeviceConfigDialog(camera, false); @@ -2191,7 +2331,7 @@ public class ScreenPanel extends Panel { } catch (Exception ex) { showException(ex); } - }//GEN-LAST:event_buttonSetupActionPerformed + }//GEN-LAST:event_buttonConfigActionPerformed private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed try { @@ -2320,18 +2460,19 @@ public class ScreenPanel extends Panel { ColormapSource source = (ColormapSource) camera; Color colorReticule = new Color(16, 16, 16); Color colorMarker = new Color(128, 128, 128); - if (buttonGrayscale.isSelected()) { + if (buttonGrayscale.isSelected() || buttonInverted.isSelected()) { colorReticule = new Color(0, 192, 0); colorMarker = new Color(64, 255, 64); - source.getConfig().colormap = Colormap.Grayscale; - } - if (buttonTemperature.isSelected()) { + source.getConfig().colormap = buttonGrayscale.isSelected() ? Colormap.Grayscale : Colormap.Inverted; + } else if (buttonFlame.isSelected()) { + colorReticule = new Color(0, 192, 0); + colorMarker = new Color(64, 255, 64); + source.getConfig().colormap = Colormap.Flame; + } else if (buttonTemperature.isSelected()) { source.getConfig().colormap = Colormap.Temperature; - } - if (buttonRainbow.isSelected()) { + } else if (buttonRainbow.isSelected()) { source.getConfig().colormap = Colormap.Rainbow; } - renderer.setPenReticle(new Pen(colorReticule)); renderer.setPenProfile(new Pen(colorReticule, 0)); renderer.setPenMarker(new Pen(colorMarker, 2)); @@ -2516,11 +2657,13 @@ public class ScreenPanel extends Panel { }//GEN-LAST:event_buttonStopActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonArgs; private javax.swing.JRadioButton buttonAutomatic; private javax.swing.JRadioButton buttonCamtool; private javax.swing.JButton buttonConfig; private javax.swing.JRadioButton buttonDirect; private javax.swing.JToggleButton buttonFit; + private javax.swing.JRadioButton buttonFlame; private javax.swing.JRadioButton buttonFullRange; private javax.swing.JButton buttonGrabBackground; private javax.swing.JRadioButton buttonGrayscale; @@ -2528,13 +2671,13 @@ public class ScreenPanel extends Panel { private javax.swing.ButtonGroup buttonGroup2; private javax.swing.ButtonGroup buttonGroup3; private javax.swing.ButtonGroup buttonGroup4; + private javax.swing.JRadioButton buttonInverted; private javax.swing.JRadioButton buttonManual; private javax.swing.JToggleButton buttonMarker; private javax.swing.JToggleButton buttonPause; private javax.swing.JRadioButton buttonRainbow; private javax.swing.JToggleButton buttonReticle; private javax.swing.JToggleButton buttonSave; - private javax.swing.JButton buttonSetup; private javax.swing.JButton buttonStop; private javax.swing.JRadioButton buttonTemperature; private javax.swing.JRadioButton buttonZoom025; @@ -2560,6 +2703,7 @@ public class ScreenPanel extends Panel { private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; private javax.swing.JProgressBar jProgressBar1; private javax.swing.JPanel panelScreen; private javax.swing.JPanel panelScreen1; diff --git a/script/test/CamtoolBug.py b/script/test/CamtoolBug.py new file mode 100644 index 0000000..b48b0af --- /dev/null +++ b/script/test/CamtoolBug.py @@ -0,0 +1,6 @@ +class AnalogInput(ReadonlyRegisterBase): + def doRead(self): + return camtool.getValue("gr_y_fit_offset") + +add_device(AnalogInput("tst"), True) +tst.setPolling(10) \ No newline at end of file