From 0e578e44e861d95f4bc3d78848bd55b3b07bdcd7 Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Fri, 29 May 2015 15:50:37 +0200 Subject: [PATCH] Closedown --- plugins/TestingPanel.form | 105 ++++++++++++++++++++++ plugins/TestingPanel.java | 179 ++++++++++++++++++++++++++++++++++++++ script/args.py | 5 ++ 3 files changed, 289 insertions(+) create mode 100644 plugins/TestingPanel.form create mode 100644 plugins/TestingPanel.java create mode 100644 script/args.py diff --git a/plugins/TestingPanel.form b/plugins/TestingPanel.form new file mode 100644 index 0000000..5748e78 --- /dev/null +++ b/plugins/TestingPanel.form @@ -0,0 +1,105 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/TestingPanel.java b/plugins/TestingPanel.java new file mode 100644 index 0000000..2cb2dc3 --- /dev/null +++ b/plugins/TestingPanel.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. + */ + +import ch.psi.pshell.dev.Motor; +import ch.psi.pshell.swing.MotorPanel; +import ch.psi.utils.swing.MonitoredPanel; +import ch.psi.pshell.ui.Panel; +import ch.psi.utils.swing.SwingUtils; +import ch.psi.wsaf.ApplicationStateException; +import ch.psi.wsaf.TaskRunningException; +import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JPanel; + +/** + * + */ +public class TestingPanel extends Panel { + + @Override + protected JPanel create() { + return new NetbeansPluginPanel(); + } + MotorPanel motorPanel; + public class NetbeansPluginPanel extends MonitoredPanel { + + public NetbeansPluginPanel() { + initComponents(); + motorPanel = new MotorPanel(); + panel.add(motorPanel); + + Motor motor = (Motor) TestingPanel.this.getDevice("motor"); + motorPanel.setDevice(motor); + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonExecute = new javax.swing.JButton(); + buttonAbort = new javax.swing.JButton(); + jButton1 = new javax.swing.JButton(); + check = new javax.swing.JCheckBox(); + spinner = new javax.swing.JSpinner(); + panel = new javax.swing.JPanel(); + + buttonExecute.setText("Execute"); + buttonExecute.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonExecuteActionPerformed(evt); + } + }); + + buttonAbort.setText("Abort"); + buttonAbort.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonAbortActionPerformed(evt); + } + }); + + jButton1.setText("My button"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + check.setText("Var1"); + + spinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10, 1)); + + panel.setLayout(new java.awt.BorderLayout()); + + 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(31, 31, 31) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton1) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(check) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(buttonExecute, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGap(99, 99, 99) + .addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, 306, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(162, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(27, 27, 27) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(buttonExecute) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonAbort) + .addGap(55, 55, 55) + .addComponent(check)) + .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1) + .addContainerGap(205, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed + try { + //Run script + //run("test1"); + + //Alternatives to run script with arguments + + /* + eval("start = 22.0"); + eval("end = 32.0"); + eval("step = 10"); + run("test11"); + */ + + /* + HashMap args = new HashMap(); + args.put("start", 12.0); + args.put("end", 52.0); + args.put("step", 10); + run("test11", args); + */ + + //eval("run('test11', locals = {'start':10.0, 'end':50.0, 'step':40})"); + + evalAsync("run('test11', locals = {'start':10.0, 'end':50.0, 'step':40})"); + + + } catch (Exception ex) { + SwingUtils.showException(this, ex); + } + }//GEN-LAST:event_buttonExecuteActionPerformed + + private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed + abort(); + }//GEN-LAST:event_buttonAbortActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + try { + boolean var1 = check.isSelected(); + int var2 = (Integer)spinner.getValue(); + + HashMap args = new HashMap(); + args.put("relative", var1); + args.put("steps", var2); + run("args", args); + + + //evalAsync("run('args', locals = {'relative':" + (var1 ? "True" :"False") + ", 'steps':" + var2 + "})"); + + } catch (Exception ex) { + SwingUtils.showException(this, ex); + } + + }//GEN-LAST:event_jButton1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonAbort; + private javax.swing.JButton buttonExecute; + private javax.swing.JCheckBox check; + private javax.swing.JButton jButton1; + private javax.swing.JPanel panel; + private javax.swing.JSpinner spinner; + // End of variables declaration//GEN-END:variables +} +} diff --git a/script/args.py b/script/args.py new file mode 100644 index 0000000..579bb76 --- /dev/null +++ b/script/args.py @@ -0,0 +1,5 @@ +""" +Arguments example +""" + +a= lscan(inp, (sin,out,arr), 0, 40, steps, 0.2, relative, context = "Scan1")