Closedown

This commit is contained in:
sfop
2017-01-24 11:05:33 +01:00
parent 8fdb0dadaf
commit 45fe3cb594
3 changed files with 144 additions and 23 deletions
+70 -7
View File
@@ -21,10 +21,13 @@
<Component id="buttonStart" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
<Component id="buttonAbort" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace min="0" pref="411" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="plot" pref="393" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@@ -36,10 +39,17 @@
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="plot" pref="383" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="plot" pref="383" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -139,7 +149,7 @@
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerLatency" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -217,5 +227,58 @@
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Output"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerPhaseRef" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerPhaseRef" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="116" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Ref Pjase:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerPhaseRef">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="360.0" minimum="-45.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerPhaseRefStateChanged"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
+72 -14
View File
@@ -10,6 +10,7 @@ import ch.psi.pshell.scan.ScanRecord;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.ui.Plugin;
import ch.psi.utils.State;
import java.awt.Color;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -22,6 +23,7 @@ public class ShottkyScan extends Panel {
public ShottkyScan() {
initComponents();
plot.addSeries(series);
plot.getAxis(Plot.AxisId.X).setLabel("Phase");
plot.getAxis(Plot.AxisId.Y).setLabel("Charge");
}
@@ -72,8 +74,7 @@ public class ShottkyScan extends Panel {
ScanListener scanListener = new ScanListener() {
@Override
public void onScanStarted(Scan scan, String plotTitle) {
if ("ShottkyScan".equals(getContext().getExecutionPars().getName())){
plot.removeMarker(null);
if ("ShottkyScan".equals(getContext().getExecutionPars().getName())){
series.clear();
}
}
@@ -81,7 +82,7 @@ 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], (Double)record.getValues()[0]);
series.appendData((Double)record.getPositions()[0], ((Number)record.getValues()[0]).doubleValue());
}
}
@@ -110,6 +111,9 @@ public class ShottkyScan extends Panel {
jLabel4 = new javax.swing.JLabel();
spinnerStart = new javax.swing.JSpinner();
plot = new ch.psi.pshell.plot.LinePlotJFree();
jPanel2 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
spinnerPhaseRef = new javax.swing.JSpinner();
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
@@ -209,11 +213,44 @@ public class ShottkyScan extends Panel {
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
plot.setTitle("");
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Output"));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel7.setText("Ref Pjase:");
spinnerPhaseRef.setModel(new javax.swing.SpinnerNumberModel(0.0d, -45.0d, 360.0d, 1.0d));
spinnerPhaseRef.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerPhaseRefStateChanged(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerPhaseRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(spinnerPhaseRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(116, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -223,9 +260,11 @@ public class ShottkyScan extends Panel {
.addComponent(buttonStart)
.addGap(27, 27, 27)
.addComponent(buttonAbort)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 411, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.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)
.addContainerGap())
@@ -238,9 +277,14 @@ public class ShottkyScan extends Panel {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE))
.addGap(18, 18, 18)
.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))
@@ -250,6 +294,8 @@ public class ShottkyScan extends Panel {
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
//((Plugin)this).
plot.removeMarker(null);
spinnerPhaseRef.setValue(0.0);
ArrayList parameters = new ArrayList();
parameters.add(spinnerStart.getValue());
parameters.add(spinnerStop.getValue());
@@ -258,18 +304,18 @@ public class ShottkyScan extends Panel {
parameters.add(spinnerLatency.getValue());
try {
//How to get a callback on the end of execution
/*
runAsync("RFscan/ShottkyScan", parameters).handle((ret, ex) -> {
if (ex != null){
getLogger().info("Exception executing scan: " + ex);
} else {
getLogger().info("Success executing scan ret:" + ret);
spinnerPhaseRef.setValue(ret);
}
return null;
return ret;
});
*/
runAsync("RFscan/ShottkyScan", parameters);
//runAsync("RFscan/ShottkyScan", parameters);
} catch (Exception ex) {
showException(ex);
}
@@ -284,6 +330,15 @@ public class ShottkyScan extends Panel {
}
}//GEN-LAST:event_buttonAbortActionPerformed
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);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_spinnerPhaseRefStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonStart;
@@ -292,9 +347,12 @@ public class ShottkyScan extends Panel {
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerLatency;
private javax.swing.JSpinner spinnerPhaseRef;
private javax.swing.JSpinner spinnerSamples;
private javax.swing.JSpinner spinnerStart;
private javax.swing.JSpinner spinnerStep;
+2 -2
View File
@@ -47,5 +47,5 @@ caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset)
y = r.getReadable(0)
x = r.getPositions(0)
y = [v.mean for v in y]
index_max = y.indexOf(max(y))
_=x[index_max]
index_max = y.index(max(y))
set_return(x[index_max])