From dee1df0de541a93555445126d62e0e59345ea81d Mon Sep 17 00:00:00 2001 From: sfop Date: Thu, 1 Dec 2016 16:30:24 +0100 Subject: [PATCH] Startup --- config/jcae.properties | 4 +- devices/CurrentCamera.properties | 16 +++---- plugins/Correlation.form | 27 +++++++++--- plugins/Correlation.java | 71 ++++++++++++++++++++----------- script/Correlation/Correlation.py | 30 +++++++------ 5 files changed, 95 insertions(+), 53 deletions(-) diff --git a/config/jcae.properties b/config/jcae.properties index 784f82b..73d5e00 100755 --- a/config/jcae.properties +++ b/config/jcae.properties @@ -1,8 +1,8 @@ -#Fri Nov 11 11:14:32 CET 2016 +#Thu Dec 01 11:20:18 CET 2016 ch.psi.jcae.ContextFactory.addressList=172.26.0.255 172.26.2.255 172.26.8.255 172.26.16.255 172.26.24.255 172.26.32.255 172.26.40.255 172.26.120.255 ch.psi.jcae.ContextFactory.maxArrayBytes=50000000 ch.psi.jcae.ChannelFactory.retries=1 -ch.psi.jcae.ChannelFactory.timeout=500 +ch.psi.jcae.ChannelFactory.timeout=750 ch.psi.jcae.impl.DefaultChannelService.retries=4 ch.psi.jcae.impl.DefaultChannelService.timeout=1000 ch.psi.jcae.ContextFactory.serverPort= diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index a07ec9f..f2105d3 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,13 +1,13 @@ -#Mon Nov 28 15:14:50 CET 2016 +#Thu Dec 01 14:38:26 CET 2016 colormap=Temperature colormapAutomatic=true colormapMax=0.0 colormapMin=0.0 -flipHorizontally=true +flipHorizontally=false flipVertically=true grayscale=false -imageHeight=2160 -imageWidth=2560 +imageHeight=1200 +imageWidth=1246 invert=false rescaleFactor=1.0 rescaleOffset=0.0 @@ -18,9 +18,9 @@ roiY=0 rotation=0.0 rotationCrop=false scale=1.0 -spatialCalOffsetX=-1280.0 -spatialCalOffsetY=-1075.0 -spatialCalScaleX=-8.823529411764707 -spatialCalScaleY=-8.83489784649365 +spatialCalOffsetX=-630.0 +spatialCalOffsetY=-612.0 +spatialCalScaleX=-26.761819803746654 +spatialCalScaleY=-26.595744680851062 spatialCalUnits=mm transpose=false diff --git a/plugins/Correlation.form b/plugins/Correlation.form index 4b68be9..5ce1397 100644 --- a/plugins/Correlation.form +++ b/plugins/Correlation.form @@ -71,6 +71,8 @@ + + @@ -95,6 +97,8 @@ + + @@ -104,9 +108,11 @@ - - - + + + + + @@ -121,7 +127,7 @@ - + @@ -193,7 +199,7 @@ - + @@ -220,6 +226,17 @@ + + + + + + + + + + + diff --git a/plugins/Correlation.java b/plugins/Correlation.java index 98a2983..77b45cc 100644 --- a/plugins/Correlation.java +++ b/plugins/Correlation.java @@ -70,25 +70,28 @@ public class Correlation extends Panel { } catch (Exception ex){ textCorrelation.setText(""); } - - try{ - List pars = (List)getController().getInterpreterVariable("pars_lin"); - //textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0)))); - textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0))); - } catch (Exception ex){ - textLinear.setText(""); - } - - try{ - List pars = (List)getController().getInterpreterVariable("pars_quad"); - //textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0)))); - textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0))); - //textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0))); - - } catch (Exception ex){ - textQuadratic.setText(""); - } + if (checkLinear.isSelected()){ + try{ + List pars = (List)getController().getInterpreterVariable("pars_lin"); + //textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0)))); + textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0))); + } catch (Exception ex){ + textLinear.setText(""); + } + } + + if (checkQuadratic.isSelected()){ + try{ + List pars = (List)getController().getInterpreterVariable("pars_quad"); + //textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0)))); + textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0))); + //textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0))); + + } catch (Exception ex){ + textQuadratic.setText(""); + } + } } @Override @@ -107,6 +110,9 @@ public class Correlation extends Panel { textDevY.setEnabled(state==State.Ready); spinnerInterval.setEnabled(state==State.Ready); spinnerWindow.setEnabled(state==State.Ready); + checkBS.setEnabled(state==State.Ready); + checkLinear.setEnabled(state==State.Ready); + checkQuadratic.setEnabled(state==State.Ready); if ((former==State.Initializing) && (state == State.Ready)){ if (App.hasArgument("start")) { @@ -152,6 +158,8 @@ public class Correlation extends Panel { textLinear = new javax.swing.JTextField(); jLabel7 = new javax.swing.JLabel(); textQuadratic = new javax.swing.JTextField(); + checkLinear = new javax.swing.JCheckBox(); + checkQuadratic = new javax.swing.JCheckBox(); plot.setTitle(""); @@ -184,7 +192,7 @@ public class Correlation extends Panel { textCorrelation.setEditable(false); textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER); - checkBS.setText("Beam Synchronous"); + checkBS.setText("Beam synchronous"); jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel6.setText("Liner fit:"); @@ -198,6 +206,11 @@ public class Correlation extends Panel { textQuadratic.setEditable(false); textQuadratic.setHorizontalAlignment(javax.swing.JTextField.CENTER); + checkLinear.setSelected(true); + checkLinear.setText("Linear fit"); + + checkQuadratic.setText("Quadratic fit"); + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( @@ -221,7 +234,9 @@ public class Correlation extends Panel { .addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(checkBS) .addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE) - .addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)) + .addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE) + .addComponent(checkLinear) + .addComponent(checkQuadratic)) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -249,6 +264,8 @@ public class Correlation extends Panel { .addComponent(jLabel2) .addComponent(textDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkBS) + .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) @@ -256,9 +273,11 @@ public class Correlation extends Panel { .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(checkBS) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE) + .addGap(18, 18, 18) + .addComponent(checkLinear) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkQuadratic) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) @@ -270,7 +289,7 @@ public class Correlation extends Panel { .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(jLabel7) .addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE) .addComponent(buttonStart) .addGap(45, 45, 45)) ); @@ -313,6 +332,8 @@ public class Correlation extends Panel { args.put("interval", spinnerInterval.getValue()); args.put("window", spinnerWindow.getValue()); args.put("bs", checkBS.isSelected()); + args.put("linear_fit", checkLinear.isSelected()); + args.put("quadratic_fit", checkQuadratic.isSelected()); args.put("p", plot); runAsync("Correlation/Correlation", args).handle((ok, ex) -> { @@ -332,6 +353,8 @@ public class Correlation extends Panel { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonStart; private javax.swing.JCheckBox checkBS; + private javax.swing.JCheckBox checkLinear; + private javax.swing.JCheckBox checkQuadratic; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; diff --git a/script/Correlation/Correlation.py b/script/Correlation/Correlation.py index 1e0addf..ff679bf 100644 --- a/script/Correlation/Correlation.py +++ b/script/Correlation/Correlation.py @@ -30,6 +30,8 @@ if get_context().source == CommandSource.ui: window = 40 p = plot(None)[0] bs = True + linear_fit = True + quadratic_fit = True #print dx #print dy corr = None @@ -141,20 +143,20 @@ try: p.removeMarker(marker) marker = p.addMarker(x2+res, p.AxisId.X, s, p.getBackground()) marker.setLabelPaint(STDOUT_COLOR) - - #Calculate, print and plot linear fit - pars_lin = (a0,a1) = fit_polynomial(ay, ax, 1) - #print "Fit lin a1:" , a1, " a0:",a0 - y1 = poly(x1, pars_lin) - y2 = poly(x2, pars_lin) - plot_line(p, x1, y1, x2, y2, width = 2, color = Color.BLUE, name = "Fit Linear") - - #Calculate, print and plot quadratic fit - pars_quad = (a0,a1,a2) = fit_polynomial(ay, ax, 2) - #print "Fit quad a2:" , a2, "a1:" , a1, " a0:",a0 - fitted_quad_function = PolynomialFunction(pars_quad) - ax = frange(x1, x2, res, True) - plot_function(p, fitted_quad_function, "Fit Quadratic", ax, color=Color.GREEN) + if linear_fit: + #Calculate, print and plot linear fit + pars_lin = (a0,a1) = fit_polynomial(ay, ax, 1) + #print "Fit lin a1:" , a1, " a0:",a0 + y1 = poly(x1, pars_lin) + y2 = poly(x2, pars_lin) + plot_line(p, x1, y1, x2, y2, width = 2, color = Color.BLUE, name = "Fit Linear") + if quadratic_fit: + #Calculate, print and plot quadratic fit + pars_quad = (a0,a1,a2) = fit_polynomial(ay, ax, 2) + #print "Fit quad a2:" , a2, "a1:" , a1, " a0:",a0 + fitted_quad_function = PolynomialFunction(pars_quad) + ax = frange(x1, x2, res, True) + plot_function(p, fitted_quad_function, "Fit Quadratic", ax, color=Color.GREEN) if bs != True: time.sleep(interval) finally: