From 4fcf1fa022928aac99899ef9f5a863a259969f22 Mon Sep 17 00:00:00 2001 From: gobbo_a Date: Thu, 13 Apr 2017 11:05:05 +0200 Subject: [PATCH] Closedown --- devices/CurrentCamera.properties | 16 ++-- devices/Phase.properties | 8 +- plugins/SchottkyScan.form | 2 +- plugins/SchottkyScan.java | 3 +- plugins/WireScan.form | 112 +++++++++++++---------- plugins/WireScan.java | 151 +++++++++++++++++++++---------- script/Devices/WireScanner.py | 2 +- script/Diagnostics/WireScan.py | 2 +- script/RFscan/GunScan.py | 1 + script/RFscan/SchottkyScan.py | 5 +- 10 files changed, 185 insertions(+), 117 deletions(-) diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 4bd7284..e61ba78 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,7 +1,7 @@ -#Thu Apr 13 08:26:37 CEST 2017 +#Thu Apr 13 10:44:59 CEST 2017 colormap=Flame -colormapAutomatic=true -colormapMax=1500.0 +colormapAutomatic=false +colormapMax=3000.0 colormapMin=0.0 flipHorizontally=false flipVertically=false @@ -17,13 +17,13 @@ roiHeight=-1 roiWidth=-1 roiX=0 roiY=0 -rotation=270.0 +rotation=0.0 rotationCrop=false scale=1.0 serverURL=localhost\:10000 -spatialCalOffsetX=-1057.0 -spatialCalOffsetY=-1420.0 -spatialCalScaleX=-8.51063829787234 -spatialCalScaleY=-8.559201141226819 +spatialCalOffsetX=-1057.4895329398094 +spatialCalOffsetY=-1420.5549062527236 +spatialCalScaleX=-8.510638153514359 +spatialCalScaleY=-8.235817137431614 spatialCalUnits=mm transpose=false diff --git a/devices/Phase.properties b/devices/Phase.properties index 018cca3..ccf1bd1 100644 --- a/devices/Phase.properties +++ b/devices/Phase.properties @@ -1,8 +1,8 @@ -#Wed Jun 22 15:13:23 CEST 2016 +#Thu Apr 13 10:29:45 CEST 2017 maxValue=0.0 minValue=0.0 offset=0.0 -precision=0 -resolution=0.001 +precision=3 +resolution=1.0 scale=1.0 -unit=DEG +unit=deg diff --git a/plugins/SchottkyScan.form b/plugins/SchottkyScan.form index bac7a43..1e6e9ea 100644 --- a/plugins/SchottkyScan.form +++ b/plugins/SchottkyScan.form @@ -24,7 +24,7 @@ - + diff --git a/plugins/SchottkyScan.java b/plugins/SchottkyScan.java index 8d4f973..a373e2a 100644 --- a/plugins/SchottkyScan.java +++ b/plugins/SchottkyScan.java @@ -347,7 +347,8 @@ public class SchottkyScan extends Panel { private void buttonSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetActionPerformed try { - String cmd = "caput('SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE', -" + spinnerPhaseRef.getValue() + ")"; + double phaseOffset = -((Double)spinnerPhaseRef.getValue()); + String cmd = "caput('SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE', " + phaseOffset + ")"; cmd += "; " + "caput('SINEG01-RSYS:CMD-LOAD-CALIB-BEAM', 1)"; evalAsync(cmd).handle((ret, ex) -> { if (ex != null){ diff --git a/plugins/WireScan.form b/plugins/WireScan.form index 26bfb26..5cfb175 100644 --- a/plugins/WireScan.form +++ b/plugins/WireScan.form @@ -17,7 +17,7 @@ - + @@ -70,7 +70,9 @@ - + + + @@ -78,58 +80,63 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - @@ -271,5 +278,10 @@ + + + + + diff --git a/plugins/WireScan.java b/plugins/WireScan.java index 38e80f4..ddf6591 100644 --- a/plugins/WireScan.java +++ b/plugins/WireScan.java @@ -4,6 +4,12 @@ import ch.psi.pshell.device.Device; import ch.psi.pshell.epics.Epics; +import ch.psi.pshell.plot.LinePlotSeries; +import ch.psi.pshell.plot.Plot; +import ch.psi.pshell.scan.Scan; +import ch.psi.pshell.scan.ScanListener; +import ch.psi.pshell.scan.ScanRecord; +import ch.psi.pshell.ui.App; import ch.psi.pshell.ui.Panel; import ch.psi.pshell.ui.Plugin; import ch.psi.utils.State; @@ -15,15 +21,23 @@ import javax.swing.DefaultComboBoxModel; * */ public class WireScan extends Panel { + final String[] seriesNames = new String[]{"bpm1_x", "bpm1_y", "bpm1_q", "bpm2_x", "bpm2_y", "bpm2_q"}; + LinePlotSeries[] series = new LinePlotSeries[seriesNames.length]; public WireScan() { - initComponents(); + initComponents(); + for (int i=0; i< seriesNames.length; i++){ + plot.addSeries(new LinePlotSeries(seriesNames[i])); + } + plot.getAxis(Plot.AxisId.X).setLabel(""); + plot.getAxis(Plot.AxisId.Y).setLabel("Position"); + plot.setLegendVisible(true); } //Overridable callbacks @Override public void onInitialize(int runCount) { - try { + try { DefaultComboBoxModel model = new DefaultComboBoxModel(); eval("run('Devices/Elements')", true); List ret = (List) ((Plugin)this).eval("get_wire_scans()", true); @@ -46,7 +60,10 @@ public class WireScan extends Panel { for (String scan: ret){ model.addElement(scan); } - comboBpm3.setModel(model); + comboBpm3.setModel(model); + if (App.hasArgument("ws")){ + comboWireScan.setSelectedItem(App.getArgumentValue("ws")); + } } catch (Exception ex) { showException(ex); @@ -71,7 +88,37 @@ public class WireScan extends Panel { protected void doUpdate() { } + + //Plot management + ScanListener scanListener = new ScanListener() { + @Override + public void onScanStarted(Scan scan, String plotTitle) { + if ("WireScan".equals(getContext().getExecutionPars().getName())) { + for (LinePlotSeries s : series){ + s.clear(); + } + } + } + @Override + public void onNewRecord(Scan scan, ScanRecord record) { + System.out.println( (Double) record.getValues()[1]); + if ("WireScan".equals(getContext().getExecutionPars().getName())) { + double position = (Double) record.getValues()[1]; + for (int i=0; i< series.length; i++){ + plot.addSeries(new LinePlotSeries(seriesNames[i])); + series[i].appendData(position,(Double) record.getValues()[4 + i]); + + } + } + } + + @Override + public void onScanEnded(Scan scan, Exception ex) { + getContext().removeScanListener(this); + } + }; + @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -99,6 +146,7 @@ public class WireScan extends Panel { spinnerVel = new javax.swing.JSpinner(); spinnerCycles = new javax.swing.JSpinner(); panelStatus = new ch.psi.pshell.swing.DeviceValuePanel(); + plot = new ch.psi.pshell.plot.LinePlotJFree(); comboWireScan.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -175,6 +223,8 @@ public class WireScan extends Panel { spinnerCycles.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1)); + plot.setTitle(""); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -222,7 +272,9 @@ public class WireScan extends Panel { .addGap(8, 8, 8) .addComponent(spinnerCycles)))) .addComponent(panelStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) - .addContainerGap(23, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 451, Short.MAX_VALUE) + .addGap(11, 11, 11)) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel10, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8, jLabel9}); @@ -231,48 +283,51 @@ public class WireScan extends Panel { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(comboWireScan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(comboSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel2)) - .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel6) - .addComponent(jLabel7) - .addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(spinnerStart, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel8) - .addComponent(jLabel9) - .addComponent(spinnerVel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerCycles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(textBpm1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel4) - .addComponent(textBpm2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel5) - .addComponent(comboBpm3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLabel10) - .addComponent(panelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(buttonAbort) - .addComponent(buttonScan) - .addComponent(buttonMoveStart)) - .addContainerGap(48, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(comboWireScan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(comboSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6) + .addComponent(jLabel7) + .addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(spinnerStart, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8) + .addComponent(jLabel9) + .addComponent(spinnerVel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerCycles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(textBpm1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(textBpm2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5) + .addComponent(comboBpm3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 95, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel10) + .addComponent(panelStatus, 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(buttonAbort) + .addComponent(buttonScan) + .addComponent(buttonMoveStart))) + .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)) + .addContainerGap()) ); }// //GEN-END:initComponents @@ -315,7 +370,8 @@ public class WireScan extends Panel { parameters.add(spinnerEnd.getValue()); parameters.add(spinnerCycles.getValue()); parameters.add(spinnerVel.getValue()); - parameters.add(comboBpm3.getSelectedItem().toString().isEmpty() ? null: comboBpm3.getSelectedItem().toString()); + parameters.add(comboBpm3.getSelectedItem().toString().isEmpty() ? null: comboBpm3.getSelectedItem().toString()); + getContext().addScanListener(scanListener); try { runAsync("Diagnostics/WireScan", parameters).handle((ret, ex) -> { if (ex != null) { @@ -326,7 +382,7 @@ public class WireScan extends Panel { }); } catch (Exception ex) { showException(ex); - } + } }//GEN-LAST:event_buttonScanActionPerformed private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed @@ -363,6 +419,7 @@ public class WireScan extends Panel { private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private ch.psi.pshell.swing.DeviceValuePanel panelStatus; + private ch.psi.pshell.plot.LinePlotJFree plot; private javax.swing.JSpinner spinnerCycles; private javax.swing.JSpinner spinnerEnd; private javax.swing.JSpinner spinnerStart; diff --git a/script/Devices/WireScanner.py b/script/Devices/WireScanner.py index 2d959bb..4011a0e 100644 --- a/script/Devices/WireScanner.py +++ b/script/Devices/WireScanner.py @@ -129,7 +129,7 @@ class WireScanner(WireScanInfo): caputq(self.prefix + ":SCAN_WIRE", 1) def doClose(self): - WireScanState.doClose(self) + WireScanInfo.doClose(self) self.motor.close() self.motor_bs_readback.close() self.wire_velocity.close() diff --git a/script/Diagnostics/WireScan.py b/script/Diagnostics/WireScan.py index 287863c..4981596 100644 --- a/script/Diagnostics/WireScan.py +++ b/script/Diagnostics/WireScan.py @@ -3,7 +3,7 @@ is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before c run("Devices/Elements") run("Devices/WireScanner") -BPM_SENSORS = {"x":"X1", "y":"Y1", "q":"Q1"} +BPM_SENSORS = {} #{"x":"X1", "y":"Y1", "q":"Q1"} #Paramter parsing if is_panel: diff --git a/script/RFscan/GunScan.py b/script/RFscan/GunScan.py index bab94b4..e56c160 100644 --- a/script/RFscan/GunScan.py +++ b/script/RFscan/GunScan.py @@ -25,6 +25,7 @@ phase.config.maxValue = 180.0 phase.config.resolution = 0.25 phase.initialize() +#kill_camtool() check_camtool() camtool.start("SINBD01-DSCR010") wait_camtool_message() diff --git a/script/RFscan/SchottkyScan.py b/script/RFscan/SchottkyScan.py index 7183ced..0d31970 100644 --- a/script/RFscan/SchottkyScan.py +++ b/script/RFscan/SchottkyScan.py @@ -18,7 +18,7 @@ phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE", "SINEG01-RSYS phase.config.minValue =-180.0 phase.config.maxValue = 180.0 phase.config.precision = 3 -phase.config.resolution = 0.1 +phase.config.resolution = 1.0 phase.config.save() phase.initialize() #st = Stream("ICTstream", dispatcher) @@ -30,9 +30,7 @@ phase0 = phase.read() print phase0 -add_device(phase, True) -""" try: qb = create_averager(q, nb, 0.100) r = lscan(phase, (qb), start, stop, step, latency=lat) @@ -52,4 +50,3 @@ index_max = y.index(max(y)) phase_ref = x[index_max] - 80 set_return(phase_ref) -""" \ No newline at end of file