From 4fb0999efc45ad981fbf599f30b532192c8fc71e Mon Sep 17 00:00:00 2001 From: x03daop Date: Tue, 21 Jul 2015 15:13:50 +0200 Subject: [PATCH] Startup --- config/plugins.properties | 2 +- plugins/PhotonEnergy.form | 561 ++++++++++++++++++++++++++++++++ plugins/PhotonEnergy.java | 661 ++++++++++++++++++++++++++++++++++++++ script/PhotonEnergy.py | 18 ++ 4 files changed, 1241 insertions(+), 1 deletion(-) create mode 100644 plugins/PhotonEnergy.form create mode 100644 plugins/PhotonEnergy.java create mode 100644 script/PhotonEnergy.py diff --git a/config/plugins.properties b/config/plugins.properties index 6cd47b36..52c072e2 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -1,4 +1,4 @@ -#Wed Jul 15 18:01:23 CEST 2015 +./home/plugins/PhotonEnergy.java=enabled ./home/plugins/HoloScan.java=enabled ./home/plugins/ManipulatorScan.java=enabled ./home/plugins/XPSSpectrum.java=enabled diff --git a/plugins/PhotonEnergy.form b/plugins/PhotonEnergy.form new file mode 100644 index 00000000..859c3a17 --- /dev/null +++ b/plugins/PhotonEnergy.form @@ -0,0 +1,561 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/PhotonEnergy.java b/plugins/PhotonEnergy.java new file mode 100644 index 00000000..69ca0b09 --- /dev/null +++ b/plugins/PhotonEnergy.java @@ -0,0 +1,661 @@ +/* + * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. + */ + +import ch.psi.pshell.scan.Scan; +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.Component; +import java.util.ArrayList; +import java.util.HashMap; +import javax.swing.JCheckBox; + +/** + * + */ +public class PhotonEnergy extends Panel { + + public PhotonEnergy() { + initComponents(); + } + boolean running; + + //Overridable callbacks + @Override + public void onStart() { + super.onStart(); + getController().addScanListener(scanListener); + } + + @Override + public void onStop() { + super.onStop(); + getController().removeScanListener(scanListener); + } + + @Override + public void onInitialize(int runCount) { + updateTable(); + } + + ScanListener scanListener = new ScanListener() { + @Override + public void onScanStarted(Scan scan, String string) { + if (running) { + table.setRowSelectionInterval(0, 0); + SwingUtils.scrollToVisible(table, 0, 0); + } + } + + @Override + public void onNewRecord(Scan scan, ScanRecord rec) { + if (running) { + int index = rec.index + 1; + if (index < table.getRowCount()) { + table.setRowSelectionInterval(index, index); + SwingUtils.scrollToVisible(table, index, 0); + } + } + } + + @Override + public void onScanEnded(Scan scan, Exception ex) { + if (running) { + table.clearSelection(); + } + } + }; + + @Override + public void onStateChange(State state, State former) { + setEnabled(isEnabled()); + if (!state.isProcessing()) { + running = false; + } + } + + @Override + public void onExecutedFile(String fileName, Object result) { + } + + @Override + public void setEnabled(boolean value) { + super.setEnabled(value); + buttonAbort.setEnabled(value && getState().isInitialized()); + + boolean enableControls = (value && (getState() == State.Ready)); + for (Component c : panelSensors.getComponents()) { + c.setEnabled(enableControls); + } + for (Component c : panelPositioner.getComponents()) { + c.setEnabled(enableControls); + } + + table.setEnabled(enableControls); + buttonStart.setEnabled(enableControls); + spinnerLow.setEnabled(enableControls && radioSwept.isSelected()); + spinnerHigh.setEnabled(enableControls && radioSwept.isSelected()); + spinnerCenter.setEnabled(enableControls && radioFixed.isSelected()); + } + + Double[][] getVector() { + ArrayList ret = new ArrayList<>(); + Double start = (Double) spinnerStart.getValue(); + Double end = (Double) spinnerEnd.getValue(); + Double stepSize = (Double) spinnerStep.getValue(); + Double low = (Double) spinnerLow.getValue(); + Double center = (Double) spinnerCenter.getValue(); + Double high = (Double) spinnerHigh.getValue(); + + if (end > start) { + int step = 0; + Double energy = start; + do { + if (energy > end) { + energy = end; + } + + if (radioSwept.isSelected()) { + if (radioCfs.isSelected()) { + ret.add(new Double[]{energy, low, high}); + } else { + ret.add(new Double[]{energy, low + (stepSize * step), high + (stepSize * step)}); + } + } else { + if (radioCfs.isSelected()) { + ret.add(new Double[]{energy, center}); + } else { + ret.add(new Double[]{energy, center + (stepSize * step)}); + } + } + + step++; + energy += stepSize; + } while (energy <= end); + } + return ret.toArray(new Double[0][0]); + } + + void updateTable() { + String[] titles = radioSwept.isSelected() ? new String[]{"Eph", "Elow", "Ehigh"} : new String[]{"Eph", "Ecenter"}; + table.setModel(new javax.swing.table.DefaultTableModel(getVector(), titles) { + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + }); + } + + void startScan() throws Exception { + HashMap args = new HashMap<>(); + ArrayList sensors = new ArrayList(); + for (Component c : panelSensors.getComponents()) { + if ((c instanceof JCheckBox) && ((JCheckBox) c).isSelected()) { + sensors.add(c.getName()); + } + } + args.put("SENSORS", sensors); + args.put("VECTOR", getVector()); + args.put("LATENCY", (Double) spinnerLatency.getValue()); + runAsync("PhotonEnergy", args); + running = true; + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + buttonGroup2 = new javax.swing.ButtonGroup(); + panelPositioner = new javax.swing.JPanel(); + radioCis = new javax.swing.JRadioButton(); + radioCfs = new javax.swing.JRadioButton(); + jLabel3 = new javax.swing.JLabel(); + spinnerLatency = new javax.swing.JSpinner(); + radioSwept = new javax.swing.JRadioButton(); + radioFixed = new javax.swing.JRadioButton(); + jLabel4 = new javax.swing.JLabel(); + spinnerStart = new javax.swing.JSpinner(); + jLabel5 = new javax.swing.JLabel(); + spinnerEnd = new javax.swing.JSpinner(); + spinnerStep = new javax.swing.JSpinner(); + jLabel6 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + table = new javax.swing.JTable(); + jLabel7 = new javax.swing.JLabel(); + spinnerCenter = new javax.swing.JSpinner(); + spinnerLow = new javax.swing.JSpinner(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + spinnerHigh = new javax.swing.JSpinner(); + panelSensors = new javax.swing.JPanel(); + checkImage = new javax.swing.JCheckBox(); + checkImageIntegration = new javax.swing.JCheckBox(); + checkSpectrum = new javax.swing.JCheckBox(); + checkCounts1 = new javax.swing.JCheckBox(); + checkTotalCount = new javax.swing.JCheckBox(); + checkCounts2 = new javax.swing.JCheckBox(); + checkCounts3 = new javax.swing.JCheckBox(); + checkCounts4 = new javax.swing.JCheckBox(); + checkCurrent = new javax.swing.JCheckBox(); + checkCur1 = new javax.swing.JCheckBox(); + checkCur2 = new javax.swing.JCheckBox(); + checkCur3 = new javax.swing.JCheckBox(); + buttonScientaSetup = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + buttonStart = new javax.swing.JButton(); + buttonAbort = new javax.swing.JButton(); + + panelPositioner.setBorder(javax.swing.BorderFactory.createTitledBorder("Acquisition")); + + buttonGroup1.add(radioCis); + radioCis.setSelected(true); + radioCis.setText("Constant Initial State"); + radioCis.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioCisActionPerformed(evt); + } + }); + + buttonGroup1.add(radioCfs); + radioCfs.setText("Constant Final State"); + radioCfs.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioCisActionPerformed(evt); + } + }); + + jLabel3.setText("Latency(s):"); + + spinnerLatency.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 10.0d, 0.1d)); + + buttonGroup2.add(radioSwept); + radioSwept.setSelected(true); + radioSwept.setText("Swept"); + radioSwept.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioSweptActionPerformed(evt); + } + }); + + buttonGroup2.add(radioFixed); + radioFixed.setText("Fixed"); + radioFixed.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioSweptActionPerformed(evt); + } + }); + + jLabel4.setText("Eph Start"); + + spinnerStart.setModel(new javax.swing.SpinnerNumberModel(100.0d, 0.0d, 1000.0d, 50.0d)); + spinnerStart.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerEnergyChanged(evt); + } + }); + + jLabel5.setText("Eph End"); + + spinnerEnd.setModel(new javax.swing.SpinnerNumberModel(200.0d, 0.0d, 1000.0d, 50.0d)); + spinnerEnd.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerEnergyChanged(evt); + } + }); + + spinnerStep.setModel(new javax.swing.SpinnerNumberModel(50.0d, 1.0d, 1000.0d, 10.0d)); + spinnerStep.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerEnergyChanged(evt); + } + }); + + jLabel6.setText("Eph Step"); + + table.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + + } + )); + table.getTableHeader().setReorderingAllowed(false); + jScrollPane1.setViewportView(table); + + jLabel7.setText("E center:"); + + spinnerCenter.setModel(new javax.swing.SpinnerNumberModel(50.0d, 0.0d, 1000.0d, 10.0d)); + spinnerCenter.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerEnergyChanged(evt); + } + }); + + spinnerLow.setModel(new javax.swing.SpinnerNumberModel(50.0d, 0.0d, 1000.0d, 10.0d)); + spinnerLow.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerEnergyChanged(evt); + } + }); + + jLabel8.setText("E low:"); + + jLabel9.setText("E high:"); + + spinnerHigh.setModel(new javax.swing.SpinnerNumberModel(100.0d, 0.0d, 1000.0d, 10.0d)); + spinnerHigh.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerEnergyChanged(evt); + } + }); + + javax.swing.GroupLayout panelPositionerLayout = new javax.swing.GroupLayout(panelPositioner); + panelPositioner.setLayout(panelPositionerLayout); + panelPositionerLayout.setHorizontalGroup( + panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelPositionerLayout.createSequentialGroup() + .addContainerGap() + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(radioCfs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPositionerLayout.createSequentialGroup() + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(panelPositionerLayout.createSequentialGroup() + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(panelPositionerLayout.createSequentialGroup() + .addComponent(jLabel6) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(panelPositionerLayout.createSequentialGroup() + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(panelPositionerLayout.createSequentialGroup() + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(radioCis) + .addComponent(radioSwept)) + .addGap(0, 76, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPositionerLayout.createSequentialGroup() + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelPositionerLayout.createSequentialGroup() + .addComponent(radioFixed) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPositionerLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(spinnerCenter, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerLow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerHigh, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + + panelPositionerLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerCenter, spinnerEnd, spinnerHigh, spinnerLow, spinnerStart, spinnerStep}); + + panelPositionerLayout.setVerticalGroup( + panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelPositionerLayout.createSequentialGroup() + .addContainerGap() + .addComponent(radioSwept) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(spinnerLow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(spinnerHigh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel9)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(radioFixed) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(spinnerCenter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7)) + .addGap(18, 18, 18) + .addComponent(radioCis) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(radioCfs) + .addGap(18, 18, 18) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6) + .addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGap(18, 18, 18) + .addGroup(panelPositionerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + panelSensors.setBorder(javax.swing.BorderFactory.createTitledBorder("Sensors")); + + checkImage.setSelected(true); + checkImage.setText("Scienta Image"); + checkImage.setToolTipText(""); + checkImage.setContentAreaFilled(false); + checkImage.setName("det.dataMatrix"); // NOI18N + + checkImageIntegration.setSelected(true); + checkImageIntegration.setText("Scienta Image Integration"); + checkImageIntegration.setToolTipText(""); + checkImageIntegration.setContentAreaFilled(false); + checkImageIntegration.setName("integration"); // NOI18N + + checkSpectrum.setSelected(true); + checkSpectrum.setText("Scienta Spectrum"); + checkSpectrum.setName("scienta.spectrum"); // NOI18N + + checkCounts1.setText("Counts Region 1"); + checkCounts1.setName("countsr1"); // NOI18N + + checkTotalCount.setSelected(true); + checkTotalCount.setText("Total Counts"); + checkTotalCount.setName("sinp"); // NOI18N + + checkCounts2.setText("Counts Region 2"); + checkCounts2.setName("countsr2"); // NOI18N + + checkCounts3.setText("Counts Region 3"); + checkCounts3.setName("countsr3"); // NOI18N + + checkCounts4.setText("Counts Region 4"); + checkCounts4.setName("countsr4"); // NOI18N + + checkCurrent.setText("Current"); + checkCurrent.setName("current"); // NOI18N + + checkCur1.setText("Cur 1"); + checkCur1.setName("cur1"); // NOI18N + + checkCur2.setText("Cur 2"); + checkCur2.setName("cur2"); // NOI18N + + checkCur3.setText("Cur 3"); + checkCur3.setName("cur3"); // NOI18N + + buttonScientaSetup.setText("Scienta Setup"); + buttonScientaSetup.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonScientaSetupActionPerformed(evt); + } + }); + + javax.swing.GroupLayout panelSensorsLayout = new javax.swing.GroupLayout(panelSensors); + panelSensors.setLayout(panelSensorsLayout); + panelSensorsLayout.setHorizontalGroup( + panelSensorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelSensorsLayout.createSequentialGroup() + .addContainerGap() + .addGroup(panelSensorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonScientaSetup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(panelSensorsLayout.createSequentialGroup() + .addGroup(panelSensorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(checkImage) + .addComponent(checkImageIntegration) + .addComponent(checkSpectrum) + .addComponent(checkCounts1) + .addComponent(checkTotalCount) + .addComponent(checkCounts2) + .addComponent(checkCounts3) + .addComponent(checkCurrent) + .addComponent(checkCur1) + .addComponent(checkCur2) + .addComponent(checkCur3) + .addComponent(checkCounts4)) + .addGap(0, 52, Short.MAX_VALUE))) + .addContainerGap()) + ); + panelSensorsLayout.setVerticalGroup( + panelSensorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelSensorsLayout.createSequentialGroup() + .addContainerGap() + .addComponent(checkImage) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkImageIntegration) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkSpectrum) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkTotalCount) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCounts1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCounts2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCounts3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCounts4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCurrent) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCur1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCur2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkCur3) + .addGap(18, 65, Short.MAX_VALUE) + .addComponent(buttonScientaSetup) + .addContainerGap(58, Short.MAX_VALUE)) + ); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control")); + + buttonStart.setText("Start"); + buttonStart.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonStartActionPerformed(evt); + } + }); + + buttonAbort.setText("Abort"); + buttonAbort.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonAbortActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonStart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(buttonStart) + .addGap(18, 18, 18) + .addComponent(buttonAbort) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(panelSensors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(panelPositioner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jPanel3, panelPositioner, panelSensors}); + + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panelPositioner, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(panelSensors, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void buttonScientaSetupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScientaSetupActionPerformed + try { + showDevicePanel("scienta"); + } catch (Exception ex) { + SwingUtils.showException(this, ex); + } + }//GEN-LAST:event_buttonScientaSetupActionPerformed + + private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed + try { + startScan(); + } catch (Exception ex) { + SwingUtils.showException(this, ex); + } + }//GEN-LAST:event_buttonStartActionPerformed + + private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed + abort(); + }//GEN-LAST:event_buttonAbortActionPerformed + + private void radioCisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioCisActionPerformed + setEnabled(isEnabled()); + updateTable(); + }//GEN-LAST:event_radioCisActionPerformed + + private void radioSweptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioSweptActionPerformed + setEnabled(isEnabled()); + updateTable(); + }//GEN-LAST:event_radioSweptActionPerformed + + private void spinnerEnergyChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerEnergyChanged + updateTable(); + }//GEN-LAST:event_spinnerEnergyChanged + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonAbort; + private javax.swing.ButtonGroup buttonGroup1; + private javax.swing.ButtonGroup buttonGroup2; + private javax.swing.JButton buttonScientaSetup; + private javax.swing.JButton buttonStart; + private javax.swing.JCheckBox checkCounts1; + private javax.swing.JCheckBox checkCounts2; + private javax.swing.JCheckBox checkCounts3; + private javax.swing.JCheckBox checkCounts4; + private javax.swing.JCheckBox checkCur1; + private javax.swing.JCheckBox checkCur2; + private javax.swing.JCheckBox checkCur3; + private javax.swing.JCheckBox checkCurrent; + private javax.swing.JCheckBox checkImage; + private javax.swing.JCheckBox checkImageIntegration; + private javax.swing.JCheckBox checkSpectrum; + private javax.swing.JCheckBox checkTotalCount; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JPanel panelPositioner; + private javax.swing.JPanel panelSensors; + private javax.swing.JRadioButton radioCfs; + private javax.swing.JRadioButton radioCis; + private javax.swing.JRadioButton radioFixed; + private javax.swing.JRadioButton radioSwept; + private javax.swing.JSpinner spinnerCenter; + private javax.swing.JSpinner spinnerEnd; + private javax.swing.JSpinner spinnerHigh; + private javax.swing.JSpinner spinnerLatency; + private javax.swing.JSpinner spinnerLow; + private javax.swing.JSpinner spinnerStart; + private javax.swing.JSpinner spinnerStep; + private javax.swing.JTable table; + // End of variables declaration//GEN-END:variables +} diff --git a/script/PhotonEnergy.py b/script/PhotonEnergy.py new file mode 100644 index 00000000..1a0f6361 --- /dev/null +++ b/script/PhotonEnergy.py @@ -0,0 +1,18 @@ +""" +Arguments: + +VECTOR (Double[][], Scan verctor: Eph,Elow,Ehigh or Eph,Ecenter) +SENSORS (list) +LATENCY (double) +""" + +set_preference(Preference.PLOT_TYPES,{'integration':1}); + +if len(VECTOR[0]) == 2: + #FIXED + writables = (pe, scienta.centerEnergy) +else: + #SWEPT + writables = (pe, scienta.lowEnergy, scienta.highEnergy) + +vscan(writables, SENSORS, VECTOR, True, LATENCY,False, before_read=trig_scienta)