diff --git a/config/harmonic_scan_offsets.properties b/config/harmonic_scan_offsets.properties index 292ff6b..3bc8169 100644 --- a/config/harmonic_scan_offsets.properties +++ b/config/harmonic_scan_offsets.properties @@ -1,2 +1,2 @@ -#Thu Jun 18 08:54:10 CEST 2020 -Au_C+=2.0 18.06.20 08\:54 +#Thu Jun 18 09:33:46 CEST 2020 +Au_C+=10.0 18.06.20 09\:33 diff --git a/config/plugins.properties b/config/plugins.properties index 9e7a742..925fe4d 100755 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -1,3 +1,6 @@ +HarmonicScan.java=disabled +Sven.java=disabled +ScreenPanel6.java=disabled AthosScreens-1.0.0.jar=disabled Eiger.java=disabled AthosCameras.java=disabled diff --git a/config/variables.properties b/config/variables.properties index 8deef25..ef2baf2 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,2 +1,2 @@ -#Wed Jun 17 11:25:33 CEST 2020 -FileSequentialNumber=333 +#Thu Jun 18 09:33:47 CEST 2020 +FileSequentialNumber=340 diff --git a/plugins/HarmonicScan.form b/plugins/HarmonicScan.form index b5b483f..dc1c966 100644 --- a/plugins/HarmonicScan.form +++ b/plugins/HarmonicScan.form @@ -34,10 +34,10 @@ - - - - + + + + @@ -66,14 +66,15 @@ - - + + + - - - + + + @@ -88,34 +89,31 @@ - + + + - - - + + + - - - - - - + + + - + - - - + @@ -166,6 +164,7 @@ + @@ -178,6 +177,7 @@ + @@ -190,6 +190,7 @@ + @@ -279,20 +280,20 @@ - - + + - + - + - + @@ -304,7 +305,7 @@ - + @@ -315,7 +316,7 @@ - + @@ -359,7 +360,7 @@ - + @@ -381,6 +382,7 @@ + diff --git a/plugins/HarmonicScan.java b/plugins/HarmonicScan.java index e53c20e..45b945f 100644 --- a/plugins/HarmonicScan.java +++ b/plugins/HarmonicScan.java @@ -33,9 +33,9 @@ public class HarmonicScan extends Panel { @Override public void onInitialize(int runCount) { super.onInitialize(runCount); - try{ - setElement(); - } catch (Exception ex){ + try { + setElement(); + } catch (Exception ex) { SwingUtils.showException(this, ex); } } @@ -45,7 +45,7 @@ public class HarmonicScan extends Panel { super.onStart(); loadConfig(); } - + @Override public void onStateChange(State state, State former) { setEnabled(state == State.Ready); @@ -62,7 +62,7 @@ public class HarmonicScan extends Panel { Path getOffsetTableFile() { return Paths.get(getContext().getSetup().getConfigPath(), "harmonic_scan_offsets.properties"); } - + @Override public void setEnabled(boolean value) { buttonExecute.setEnabled(value); @@ -97,85 +97,90 @@ public class HarmonicScan extends Panel { throw new IOException("Invalid file format: " + tokens.length); } spinnerEnergy.setValue(Double.valueOf(tokens[0].trim())); - + getOffsetTable(); } - + void setPolarizarion() throws IOException { getOffsetTable(); - } - - - String getOffsetEntry(){ + } + + String getOffsetEntry() { String element = comboElement.getSelectedItem().toString().trim(); - String polarization = comboPolarizarion.getSelectedItem().toString().trim(); + String polarization = comboPolarizarion.getSelectedItem().toString().trim(); return element + "_" + polarization; } - + EditorDialog dlgConfig; - void editEnergyTable() throws IOException{ - if ((dlgConfig==null) || (!dlgConfig.isShowing())){ + + void editEnergyTable() throws IOException { + if ((dlgConfig == null) || (!dlgConfig.isShowing())) { String[] columns = new String[]{"Element", "Energy"}; Class[] types = new Class[]{String.class, Double.class}; - DsvEditor editor = new DsvEditor(columns , types, " "); - dlgConfig = editor.getDialog(getView(),false); + DsvEditor editor = new DsvEditor(columns, types, " "); + dlgConfig = editor.getDialog(getView(), false); editor.load(getEnergyTableFile().toString()); editor.setTitle("Harmonic Scan Energy Table"); } - dlgConfig.setSize(640, 320); - showWindow(dlgConfig); + dlgConfig.setSize(640, 320); + showWindow(dlgConfig); } - - void getOffsetTable() throws IOException{ + + void getOffsetTable() throws IOException { textLastOffset.setText(""); textTimestamp.setText(""); - try{ + try { Properties prop = new Properties(); - prop.load(new FileInputStream(getOffsetTableFile().toFile())); + prop.load(new FileInputStream(getOffsetTableFile().toFile())); String val = prop.getProperty(getOffsetEntry()); - if ((val!=null)&& !val.isEmpty()){ + if ((val != null) && !val.isEmpty()) { String[] tokens = val.split(" "); if (tokens.length != 3) { throw new IOException("Invalid file format: " + tokens.length); } textLastOffset.setText(Double.valueOf(tokens[0].trim()).toString()); - textTimestamp.setText(tokens[1].trim() + " " + tokens[2].trim()); + textTimestamp.setText(tokens[1].trim() + " " + tokens[2].trim()); } - } catch (FileNotFoundException ex){ - + } catch (FileNotFoundException ex) { + } } - - void setOffsetTable(double offset) throws IOException{ + + void setOffsetTable(double offset) throws IOException { Properties prop = new Properties(); - String timestamp = Chrono.getTimeStr(System.currentTimeMillis(), "dd.MM.YY HH:mm") ; - prop.setProperty(getOffsetEntry(), offset + " " + timestamp ); - try (FileOutputStream out = new FileOutputStream(getOffsetTableFile().toFile())) { + String timestamp = Chrono.getTimeStr(System.currentTimeMillis(), "dd.MM.YY HH:mm"); + prop.setProperty(getOffsetEntry(), offset + " " + timestamp); + try ( FileOutputStream out = new FileOutputStream(getOffsetTableFile().toFile())) { prop.store(out, null); - } - - + } + textLastOffset.setText(String.valueOf(offset)); - textTimestamp.setText(timestamp); + textTimestamp.setText(timestamp); } - - + void run() throws ContextStateException { + textScanReturn.setText(""); + buttonApply.setEnabled(false); + HashMap args = new HashMap(); args.put("ID_ENERGY", (Double) spinnerEnergy.getValue()); args.put("HALFWIDTH", (Double) spinnerHalfwidth.getValue()); args.put("STEP", (Double) spinnerStep.getValue()); args.put("MODE ", comboPolarizarion.getSelectedItem().toString()); - - runAsync("HarmonicScan", args).handle((ret, ex)-> { - if ((ex == null) && (ret!=null)){ - textScanReturn.setText(String.valueOf(ret)); - } - return ret; - }); - } + runAsync("HarmonicScan", args).handle((ret, ex) -> { + if ((ex == null) && (ret != null)) { + textScanReturn.setText(String.valueOf(ret)); + try { + Double val = (Double) ret; + buttonApply.setEnabled(true); + } catch (Exception e) { + } + } + return ret; + }); + } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -235,14 +240,17 @@ public class HarmonicScan extends Panel { } }); + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel1.setText("Energy"); spinnerEnergy.setModel(new javax.swing.SpinnerNumberModel(700.0d, 0.0d, 9999.0d, 1.0d)); + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel2.setText("Halfwidth:"); spinnerHalfwidth.setModel(new javax.swing.SpinnerNumberModel(10.0d, 0.0d, 9999.0d, 1.0d)); + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); jLabel3.setText("Step:"); spinnerStep.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.0d, 9999.0d, 1.0d)); @@ -259,9 +267,10 @@ public class HarmonicScan extends Panel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(comboElement, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonConfigure, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(comboPolarizarion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(80, 80, 80) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonConfigure) + .addGap(18, 18, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING) @@ -271,38 +280,38 @@ public class HarmonicScan extends Panel { .addComponent(spinnerHalfwidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(20, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfigure, comboElement, comboPolarizarion}); jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerEnergy, spinnerHalfwidth, spinnerStep}); + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3}); + jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(comboElement, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10) .addComponent(jLabel1) - .addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonConfigure)) + .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonConfigure)) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(31, 31, 31) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(spinnerHalfwidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(spinnerHalfwidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(comboPolarizarion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel11))) + .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel11) - .addComponent(comboPolarizarion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(150, 150, 150)) + .addContainerGap(9, Short.MAX_VALUE)) ); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control")); @@ -361,7 +370,7 @@ public class HarmonicScan extends Panel { } }); - jLabel6.setText("Current:"); + jLabel6.setText("Current Offset:"); valueOffset.setDeviceName("pol_offset"); @@ -371,6 +380,7 @@ public class HarmonicScan extends Panel { textScanReturn.setHorizontalAlignment(javax.swing.JTextField.CENTER); buttonApply.setText("Apply"); + buttonApply.setEnabled(false); buttonApply.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonApplyActionPerformed(evt); @@ -392,20 +402,22 @@ public class HarmonicScan extends Panel { .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(textLastOffset, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) + .addComponent(textLastOffset, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE) .addComponent(textTimestamp)) .addGap(18, 18, 18) .addComponent(buttonSet)) - .addComponent(valueOffset, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(valueOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(textScanReturn, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textScanReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(buttonApply))) - .addContainerGap(138, Short.MAX_VALUE)) + .addContainerGap(132, Short.MAX_VALUE)) ); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonApply, buttonSet}); + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textLastOffset, textScanReturn, textTimestamp, valueOffset}); + jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() @@ -413,7 +425,7 @@ public class HarmonicScan extends Panel { .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(valueOffset, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) + .addGap(18, 18, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(textLastOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -422,7 +434,7 @@ public class HarmonicScan extends Panel { .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(textTimestamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) + .addGap(18, 18, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(textScanReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7) @@ -445,9 +457,9 @@ public class HarmonicScan extends Panel { layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) @@ -456,7 +468,6 @@ public class HarmonicScan extends Panel { private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed try { - textScanReturn.setText(""); run(); } catch (Exception ex) { SwingUtils.showException(this, ex); @@ -467,7 +478,7 @@ public class HarmonicScan extends Panel { try { abort(); } catch (InterruptedException ex) { - SwingUtils.showException(this, ex); + SwingUtils.showException(this, ex); } }//GEN-LAST:event_buttonAbortActionPerformed @@ -478,7 +489,7 @@ public class HarmonicScan extends Panel { SwingUtils.showException(this, ex); } }//GEN-LAST:event_comboElementActionPerformed - + private void buttonConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigureActionPerformed try { editEnergyTable(); @@ -488,15 +499,15 @@ public class HarmonicScan extends Panel { }//GEN-LAST:event_buttonConfigureActionPerformed private void buttonSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetActionPerformed - + try { - String ret = SwingUtils.getString(this, "Enter persisted value for " + getOffsetEntry(), textLastOffset.getText()); - if ((ret!=null) && (!ret.trim().isEmpty()) ){ - setOffsetTable(Double.valueOf(ret)); - } + String ret = SwingUtils.getString(this, "Enter persisted value for " + getOffsetEntry(), textLastOffset.getText()); + if ((ret != null) && (!ret.trim().isEmpty())) { + setOffsetTable(Double.valueOf(ret)); + } } catch (Exception ex) { SwingUtils.showException(this, ex); - } + } }//GEN-LAST:event_buttonSetActionPerformed private void comboPolarizarionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPolarizarionActionPerformed @@ -508,7 +519,11 @@ public class HarmonicScan extends Panel { }//GEN-LAST:event_comboPolarizarionActionPerformed private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed - // TODO add your handling code here: + try { + setOffsetTable(Double.valueOf(textScanReturn.getText())); + } catch (Exception ex) { + SwingUtils.showException(this, ex); + } }//GEN-LAST:event_buttonApplyActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/script/HarmonicScan.py b/script/HarmonicScan.py index e24dbd2..2c1349f 100644 --- a/script/HarmonicScan.py +++ b/script/HarmonicScan.py @@ -21,10 +21,12 @@ try: if MODE == "LH": set_pol_lin(0.0) elif MODE == "LV": - set_pol_lin(90.0) + set_pol_lin(90.0) + current_offset = pol_offset.take() else: sensors = [sin, energy] + current_offset = 0.0 ret = lscan(energy, sensors, ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, latency = 0.3) @@ -32,8 +34,8 @@ try: ydata = ret.getReadable(0) ymin = min(ydata) e0 = xdata[ydata.index(min(ydata))] - new_offset =ID_ENERGY – e0 + pol_offset.take() - print "E0=",xminmin," ymin=",ymin," Offset=",new_offset + new_offset =ID_ENERGY - e0 + current_offset + print "E0=",e0," ymin=",ymin," Offset=",new_offset set_return(new_offset)