From f1cad82bdaa8b588e4d5a7445ae2aa810a76773f Mon Sep 17 00:00:00 2001 From: sfop Date: Tue, 14 Feb 2017 15:22:02 +0100 Subject: [PATCH] Closedown --- plugins/ShottkyScan.form | 44 ++++++++++++++---------------- plugins/ShottkyScan.java | 59 +++++++++++++++++++++++++--------------- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/plugins/ShottkyScan.form b/plugins/ShottkyScan.form index 750981b..12ca642 100644 --- a/plugins/ShottkyScan.form +++ b/plugins/ShottkyScan.form @@ -17,19 +17,18 @@ - - - - - - - - - - - - + + + + + + + + + + + @@ -39,20 +38,17 @@ - - - - - + + + + + - - - - + @@ -240,14 +236,14 @@ - + - + - + diff --git a/plugins/ShottkyScan.java b/plugins/ShottkyScan.java index 7d4e38a..eaddbe8 100644 --- a/plugins/ShottkyScan.java +++ b/plugins/ShottkyScan.java @@ -2,6 +2,10 @@ * Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved. */ +import ch.psi.pshell.device.Averager; +import ch.psi.pshell.device.DescStatsDouble; +import ch.psi.pshell.plot.LinePlotErrorSeries; +import ch.psi.pshell.plot.LinePlotJFree; import ch.psi.pshell.plot.LinePlotSeries; import ch.psi.pshell.plot.Plot; import ch.psi.pshell.scan.Scan; @@ -9,6 +13,7 @@ import ch.psi.pshell.scan.ScanListener; import ch.psi.pshell.scan.ScanRecord; import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; +import ch.psi.utils.swing.SwingUtils; import java.awt.Color; import java.util.ArrayList; @@ -16,10 +21,11 @@ import java.util.ArrayList; * */ public class ShottkyScan extends Panel { - LinePlotSeries series = new LinePlotSeries("Values"); + LinePlotErrorSeries series = new LinePlotErrorSeries("Values"); public ShottkyScan() { initComponents(); + plot.setStyle(LinePlotJFree.Style.ErrorY); plot.addSeries(series); plot.getAxis(Plot.AxisId.X).setLabel("Phase"); plot.getAxis(Plot.AxisId.Y).setLabel("Charge"); @@ -74,7 +80,8 @@ public class ShottkyScan extends Panel { @Override public void onNewRecord(Scan scan, ScanRecord record) { if ("ShottkyScan".equals(getContext().getExecutionPars().getName())){ - series.appendData((Double)record.getPositions()[0], ((Number)record.getValues()[0]).doubleValue()); + series.appendData((Double)record.getPositions()[0], ((DescStatsDouble)record.getValues()[0]).getMean(), + ((DescStatsDouble)record.getValues()[0]).getStdev()); } } @Override @@ -232,7 +239,7 @@ public class ShottkyScan extends Panel { jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap(25, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addComponent(jLabel7) @@ -241,6 +248,9 @@ public class ShottkyScan extends Panel { .addComponent(buttonSet, javax.swing.GroupLayout.Alignment.TRAILING)) .addContainerGap()) ); + + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonSet, spinnerPhaseRef}); + jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() @@ -258,17 +268,16 @@ public class ShottkyScan extends Panel { layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonStart) - .addGap(27, 27, 27) - .addComponent(buttonAbort) - .addGap(0, 411, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() + .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(buttonStart) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonAbort)) .addComponent(jPanel1, 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)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE) .addContainerGap()) ); @@ -279,17 +288,15 @@ public class ShottkyScan extends Panel { .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) - .addGap(18, 18, 18)) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, 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) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonStart) - .addComponent(buttonAbort)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonStart) + .addComponent(buttonAbort))) + .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(17, 17, 17)) ); }// //GEN-END:initComponents @@ -332,7 +339,7 @@ public class ShottkyScan extends Panel { private void spinnerPhaseRefStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerPhaseRefStateChanged try { plot.removeMarker(null); - plot.addMarker((Double)spinnerPhaseRef.getValue(), Plot.AxisId.X, "Ref Phase",Color.BLUE); + plot.addMarker((Double)spinnerPhaseRef.getValue(), Plot.AxisId.X, "Ref Phase",Color.GREEN); } catch (Exception ex) { showException(ex); } @@ -340,8 +347,16 @@ public class ShottkyScan extends Panel { private void buttonSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetActionPerformed try { - //caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", spinnerPhaseRef.value) - //caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM", 1) + String cmd = "caput('SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET', " + spinnerPhaseRef.getValue() + ")"; + cmd += "; " + "caput('SINEG01-RSYS:CMD-LOAD-CALIB-BEAM', 1)"; + evalAsync(cmd).handle((ret, ex) -> { + if (ex != null){ + showException((Exception)ex); + } else { + SwingUtils.showMessage(this, "Success", "Success setting ref phase"); + } + return ret; + }); } catch (Exception ex) { showException(ex); }