This commit is contained in:
gac-S_Changer
2018-04-23 08:18:18 +02:00
parent e48acd85b9
commit cdb602b7c7
20 changed files with 854 additions and 116 deletions

223
plugins/Expert.form Normal file
View File

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonMount" min="-2" pref="106" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="checkFirst" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spinnerSample" linkSize="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerPuck" linkSize="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerSegment" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonEnableAll" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="buttonReleasePsys" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonReleaseLocal" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<EmptySpace pref="373" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
<Component id="buttonEnableAll" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonReleaseLocal" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonReleasePsys" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonMount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerSegment" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerPuck" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="checkFirst" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerSample" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonEnableAll">
<Properties>
<Property name="text" type="java.lang.String" value="Enable All"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonEnableAllActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMount">
<Properties>
<Property name="text" type="java.lang.String" value="Mount"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMountActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Segment:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerSegment">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" maximum="6" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Puck:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerPuck">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" maximum="5" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Sample:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerSample">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" maximum="16" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkFirst">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="First mount"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<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="Robot"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace pref="59" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonEnable" linkSize="4" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="buttonDisable" linkSize="4" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="75" max="32767" 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"/>
<Component id="buttonEnable" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonDisable" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonEnable">
<Properties>
<Property name="text" type="java.lang.String" value="Enable"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonEnableActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonDisable">
<Properties>
<Property name="text" type="java.lang.String" value="Disable"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonDisableActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonReleaseLocal">
<Properties>
<Property name="text" type="java.lang.String" value="Release Local"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonReleaseLocalActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonReleasePsys">
<Properties>
<Property name="text" type="java.lang.String" value="Release PSYS"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonReleasePsysActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

283
plugins/Expert.java Normal file
View File

@@ -0,0 +1,283 @@
/*
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.core.Context;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class Expert extends Panel {
public Expert() {
initComponents();
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
void execute(String statement){
execute(statement, false);
}
void execute(String statement, boolean background){
try {
evalAsync(statement, background).handle((ret, ex) -> {
if (ex != null){
showException((Exception)ex);
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}
void execute(String script, Object args){
try {
runAsync(script, args).handle((ret, ex) -> {
if (ex != null){
showException((Exception)ex);
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonEnableAll = new javax.swing.JButton();
buttonMount = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
spinnerSegment = new javax.swing.JSpinner();
jLabel2 = new javax.swing.JLabel();
spinnerPuck = new javax.swing.JSpinner();
jLabel3 = new javax.swing.JLabel();
spinnerSample = new javax.swing.JSpinner();
checkFirst = new javax.swing.JCheckBox();
jPanel1 = new javax.swing.JPanel();
buttonEnable = new javax.swing.JButton();
buttonDisable = new javax.swing.JButton();
buttonReleaseLocal = new javax.swing.JButton();
buttonReleasePsys = new javax.swing.JButton();
buttonEnableAll.setText("Enable All");
buttonEnableAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonEnableAllActionPerformed(evt);
}
});
buttonMount.setText("Mount");
buttonMount.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMountActionPerformed(evt);
}
});
jLabel1.setText("Segment:");
spinnerSegment.setModel(new javax.swing.SpinnerNumberModel(1, 1, 6, 1));
jLabel2.setText("Puck:");
spinnerPuck.setModel(new javax.swing.SpinnerNumberModel(1, 1, 5, 1));
jLabel3.setText("Sample:");
spinnerSample.setModel(new javax.swing.SpinnerNumberModel(1, 1, 16, 1));
checkFirst.setSelected(true);
checkFirst.setText("First mount");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Robot"));
buttonEnable.setText("Enable");
buttonEnable.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonEnableActionPerformed(evt);
}
});
buttonDisable.setText("Disable");
buttonDisable.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonDisableActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(59, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonEnable)
.addComponent(buttonDisable))
.addContainerGap(75, Short.MAX_VALUE))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDisable, buttonEnable});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(buttonEnable)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonDisable)
.addContainerGap())
);
buttonReleaseLocal.setText("Release Local");
buttonReleaseLocal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonReleaseLocalActionPerformed(evt);
}
});
buttonReleasePsys.setText("Release PSYS");
buttonReleasePsys.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonReleasePsysActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonMount, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(checkFirst)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonEnableAll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(buttonReleasePsys)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonReleaseLocal)))))
.addContainerGap(373, Short.MAX_VALUE))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerPuck, spinnerSample, spinnerSegment});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(buttonEnableAll)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonReleaseLocal)
.addComponent(buttonReleasePsys))
.addGap(18, 18, 18)
.addComponent(jPanel1, 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(buttonMount)
.addComponent(jLabel1)
.addComponent(spinnerSegment, 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(jLabel2)
.addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(checkFirst))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(24, 24, 24))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonEnableAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEnableAllActionPerformed
execute("enable_power()");
}//GEN-LAST:event_buttonEnableAllActionPerformed
private void buttonMountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMountActionPerformed
String cmd = checkFirst.isSelected() ? "firstmount" : "mount";
execute("robot.start_task('" + cmd + "'," + spinnerSegment.getValue() + "," + spinnerPuck.getValue() + "," + spinnerSample.getValue() + ")");
checkFirst.setSelected(false);
}//GEN-LAST:event_buttonMountActionPerformed
private void buttonEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEnableActionPerformed
execute("robot.enable()");
}//GEN-LAST:event_buttonEnableActionPerformed
private void buttonDisableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDisableActionPerformed
execute("robot.disable()");
}//GEN-LAST:event_buttonDisableActionPerformed
private void buttonReleaseLocalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleaseLocalActionPerformed
execute("release_local()");
}//GEN-LAST:event_buttonReleaseLocalActionPerformed
private void buttonReleasePsysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReleasePsysActionPerformed
execute("release_psys()");
}//GEN-LAST:event_buttonReleasePsysActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonDisable;
private javax.swing.JButton buttonEnable;
private javax.swing.JButton buttonEnableAll;
private javax.swing.JButton buttonMount;
private javax.swing.JButton buttonReleaseLocal;
private javax.swing.JButton buttonReleasePsys;
private javax.swing.JCheckBox checkFirst;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JSpinner spinnerPuck;
private javax.swing.JSpinner spinnerSample;
private javax.swing.JSpinner spinnerSegment;
// End of variables declaration//GEN-END:variables
}

Binary file not shown.