diff --git a/plugins/Kollimators.form b/plugins/Kollimators.form
index 4da660a..fda487f 100644
--- a/plugins/Kollimators.form
+++ b/plugins/Kollimators.form
@@ -25,7 +25,7 @@
-
+
@@ -106,7 +106,7 @@
-
+
@@ -208,13 +208,13 @@
-
+
-
+
diff --git a/plugins/Kollimators.java b/plugins/Kollimators.java
index 0319fd0..df5dab5 100644
--- a/plugins/Kollimators.java
+++ b/plugins/Kollimators.java
@@ -1,19 +1,10 @@
-import ch.psi.jcae.Channel;
-import ch.psi.jcae.ChannelException;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.epics.ChannelString;
import ch.psi.utils.State;
-import gov.aps.jca.CAException;
-import gov.aps.jca.Context;
-import gov.aps.jca.JCALibrary;
import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.swing.JTextField;
/*
@@ -49,8 +40,8 @@ public class Kollimators extends javax.swing.JPanel {
public void animate(String deviceName) {
g_deviceName = deviceName;
jLabelDeviceName.setText(deviceName);
- connectString(deviceName+":STA:2", jTextSta);
- connect(deviceName+":DIST:2", jTextDist);
+ connectString(deviceName+":STA:2", jTextSta); //for Strings
+ connect(deviceName+":DIST:2", jTextDist); //for Numbers
connect(deviceName+":IST1:1", jTextIst1);
connect(deviceName+":IST2:1", jTextIst2);
connect(deviceName+":REF1:1", jTextRef1);
@@ -136,20 +127,7 @@ public class Kollimators extends javax.swing.JPanel {
System.out.println(ex.toString());
}
}
-
- public void onStateChange(State state, State former) {
- }
- public void onExecutedFile(String fileName, Object result) {
- }
-
- //Callback to perform update - in event thread
- protected void doUpdate() {
- }
-
- private void monitorChannel(ChannelDouble channel, Object textField){
- }
-
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@@ -177,7 +155,7 @@ public class Kollimators extends javax.swing.JPanel {
jLabel8 = new javax.swing.JLabel();
jLabelDeviceName = new javax.swing.JLabel();
jButtonReconnect = new javax.swing.JButton();
- jButton1 = new javax.swing.JButton();
+ jButtonStopMotor = new javax.swing.JButton();
jLabel1.setText("STA:");
@@ -221,11 +199,11 @@ public class Kollimators extends javax.swing.JPanel {
}
});
- jButton1.setText("Stop motor");
- jButton1.setToolTipText("Immediately stop the collimator motor");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
+ jButtonStopMotor.setText("Stop motor");
+ jButtonStopMotor.setToolTipText("Immediately stop the collimator motor");
+ jButtonStopMotor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
+ jButtonStopMotorActionPerformed(evt);
}
});
@@ -241,7 +219,7 @@ public class Kollimators extends javax.swing.JPanel {
.addGroup(layout.createSequentialGroup()
.addComponent(jButtonReconnect)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton1)
+ .addComponent(jButtonStopMotor)
.addGap(0, 0, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -308,7 +286,7 @@ public class Kollimators extends javax.swing.JPanel {
.addComponent(jLabel8)
.addComponent(jTextRes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonReconnect)
- .addComponent(jButton1))
+ .addComponent(jButtonStopMotor))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
@@ -318,15 +296,15 @@ public class Kollimators extends javax.swing.JPanel {
animate(g_deviceName);
}//GEN-LAST:event_jButtonReconnectActionPerformed
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+ private void jButtonStopMotorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonStopMotorActionPerformed
// TODO add your handling code here:
stopMotor();
- }//GEN-LAST:event_jButton1ActionPerformed
+ }//GEN-LAST:event_jButtonStopMotorActionPerformed
//
// Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
private javax.swing.JButton jButtonReconnect;
+ private javax.swing.JButton jButtonStopMotor;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
diff --git a/script/local.py b/script/local.py
index 33c061c..f7c087a 100644
--- a/script/local.py
+++ b/script/local.py
@@ -35,6 +35,34 @@ class TestingTool:
return None
+ def getName(self):
+ """
+ get test name
+ """
+ return self.testName
+
+
+ def getPlotName(self):
+ """
+ get test plot name
+ """
+ return self.deviceName + ' - ' + self.testName
+
+
+ def getDeviceName(self):
+ """
+ get device name
+ """
+ return self.deviceName
+
+
+ def getPath(self):
+ """
+ get test path
+ """
+ return self.testPath
+
+
def log(self, text):
"""
Print/log information
diff --git a/script/tests/templates/testTemplate.py b/script/tests/templates/testTemplate.py
index 3f545da..8886acf 100644
--- a/script/tests/templates/testTemplate.py
+++ b/script/tests/templates/testTemplate.py
@@ -14,14 +14,14 @@ def startTest(testName, DEVICE, params):
# by default, assume the test failed.
ret = 'Test failed'
status = False
- # plot name to be given to the scan. Use: scan.setPlotName(plotName).
- plotName = DEVICE + ' - ' + testName
# put the whole custom code under try/catch.
try:
# get the path of this script.
testPath = inspect.getfile(inspect.currentframe())
# init the testing tool class. It can be sued in the following ways:
test = TestingTool(testName, testPath, DEVICE, params)
+ # plot name to be given to the scan. Use: scan.setPlotName(plotName).
+ plotName = test.getPlotName()
################ END OF Init #####################
######### WRITE YOUR CODE HERE BELOW #############
@@ -32,36 +32,31 @@ def startTest(testName, DEVICE, params):
-----------------------------------
GETTING INPUTS:
-----------------------------------
- If needed, the following global variables are available:
- testPath string, path of this test file
- testName string, name of this test
- DEVICE string, device for which the test must run (typically it is the beginning of a process variable name)
+ If needed, the following methods are available:
+
+ test.getPath() string, path of this test file
+ test.getName() string, name of this test
+ test.getDeviceName() string, device for which the test must run (typically it is the beginning of a process variable name)
+ test.getPlotName() string, name to be given to the plot when using setPlotName(). Example: scan.setPlotName(test.getPlotName())
-----------------------------------
GETTING TEST PARAMETERS:
-----------------------------------
- if you need to get parameters for the test, use (casting may be necessary):
+ if you need to get parameters for the test, use:
+
myParamValue = test.getParam('myParamName')
- getParam is added automatically, one per parameter, when creating the new test.
+
+ the calls to getParam are added to the code automatically, one per parameter, when creating the new test.
+ NOTE: Casting may be necessary.
See the test config for the list of parameters specific to the test.
-----------------------------------
SETTING OUTPUTS:
-----------------------------------
When the test has ended (error or success), this method must be called in order to return to pshell:
- test.sendFeedback(ret,success) method that ends the testing script and gives the report to the calling application.
- ret string, a text summarizing the result of the test.
- success bool, True = test successful.
- Examples:
-
- whenever the code must quit (i.e. after an error), you must end with the following:
- ret = 'here is some info on what failed on the test' # This is your return message
- success = False # The test did not complete successfully
- test.sendFeedback(ret, success) # Return to pshell
-
- whenever the code is finished successfully, you must end with the following:
- ret = 'here is some info on the success of the test' # This is your return message
- success = True # The test complete successfully
- test.sendFeedback(ret, success) # Return to pshell
+ test.sendFeedback(ret,success)
+
+ ret string, a text summarizing the result of the test.
+ success bool, True = test successful. False = test failed.
-----------------------------------
LOG INFO:
-----------------------------------
@@ -72,8 +67,8 @@ def startTest(testName, DEVICE, params):
########## Example (can be removed) ######
# print the list of parameters passed. If any error, stop and send feedback.
- test.log("Example - Test name: " + testName)
- test.log("Example - Device name: " + DEVICE)
+ test.log("Example - Test name: " + test.getName())
+ test.log("Example - Device name: " + test.getDeviceName() )
try:
test.log("Running test with the following parameters:")
test.log(params)
@@ -91,15 +86,15 @@ def startTest(testName, DEVICE, params):
# initialise plot tab with 2 plots: pass here the axis names:
scan = ManualScan(['sample'], ['Motor Status (MSTA)', 'Motor Position (VAL)'])
# set plot name(tab title):
- scan.setPlotName(plotName)
+ scan.setPlotName(test.getPlotName())
# start plots. See further below how to add points to the plots (scan):
scan.start()
try:
# set up connection to channels. "type" of data can be "d" (= double), "l" (= long).
- pv_motor_msta = Channel(DEVICE + ':MOTOR.MSTA', type='d')
- pv_motor_val = Channel(DEVICE + ':MOTOR.VAL' , type='d')
- pv_motor_com = Channel(DEVICE + ':COM:2' , type='d')
+ pv_motor_msta = Channel(test.getDeviceName() + ':MOTOR.MSTA', type='d')
+ pv_motor_val = Channel(test.getDeviceName() + ':MOTOR.VAL' , type='d')
+ pv_motor_com = Channel(test.getDeviceName() + ':COM:2' , type='d')
except:
# prepare return information: return text:
ret = 'Unable to create channel - ' + traceback.format_exc()
diff --git a/script/tests/tests.properties b/script/tests/tests.properties
index 85ef784..f9732c9 100644
--- a/script/tests/tests.properties
+++ b/script/tests/tests.properties
@@ -1,5 +1,5 @@
#TestingList for pshell: configuration properties
-#Tue Jan 12 08:03:52 CET 2016
+#Wed Jan 13 14:54:05 CET 2016
customPanel=Kollimators
-showEnabledTestsOnly=
+showEnabledTestsOnly=true
listFilter=LabTests2
diff --git a/script/tests/tests/sad/sdd/.config b/script/tests/tests/sad/sdd/.config
new file mode 100644
index 0000000..98c1513
--- /dev/null
+++ b/script/tests/tests/sad/sdd/.config
@@ -0,0 +1,4 @@
+#Tue Jan 12 09:17:43 CET 2016
+name=sdd
+parameters=examplePar1\:2\:This is the parameter n.1 with unit [unit];examplePar2\:4.5\:This is the parameter n.2 with unit [unit];
+description=ad
diff --git a/script/tests/tests/sad/sdd/help.html b/script/tests/tests/sad/sdd/help.html
new file mode 100644
index 0000000..97ef6ab
--- /dev/null
+++ b/script/tests/tests/sad/sdd/help.html
@@ -0,0 +1,15 @@
+
+
+
+Description
+ad
+Parameters
+examplePar1 This is the parameter n.1 with unit [unit]
+examplePar2 This is the parameter n.2 with unit [unit]
+
+Contact
+Marco Boccioli
+Tel. 3078
+
+
+
diff --git a/script/tests/tests/sad/sdd/sdd.py b/script/tests/tests/sad/sdd/sdd.py
new file mode 100644
index 0000000..06ad5d3
--- /dev/null
+++ b/script/tests/tests/sad/sdd/sdd.py
@@ -0,0 +1,149 @@
+# Test name: sdd
+# ad
+# Copyright (c) 2015 Paul Scherrer Institute. All rights reserved.
+
+###### Init - DO NOT MODIFY THE CODE BELOW ######
+global sys, inspect, os, traceback
+import sys, inspect, os, traceback
+
+
+def startTest(testName, DEVICE, params):
+ """
+ Main method running the test
+ """
+ # by default, assume the test failed
+ ret = 'Test failed'
+ status = False
+ # plot name to be given to the scan. Use: scan.setPlotName(plotName)
+ plotName = DEVICE + ' - ' + testName
+ # put the whole custom code under try/catch
+ try:
+ # get the path of this script
+ testPath = inspect.getfile(inspect.currentframe())
+ # init the testing tool class. It can be sued in the following ways:
+ test = TestingTool(testName, testPath, DEVICE, params)
+
+################ END OF Init #####################
+######### WRITE YOUR CODE HERE BELOW #############
+
+ """
+ All the code in this section ###..YOUR CODE..### can be modified/deleted.
+ It must be indented to the same level as this comment
+ -----------------------------------
+ GETTING INPUTS:
+ If needed, the following variables are available:
+ testPath string, path of this test file
+ testName string, name of this test
+ DEVICE string, device for which the test must run (typically it is the beginning of a process variable name)
+ -----------------------------------
+ GETTING TEST PARAMETERS:
+ if you need to get parameters for the test, use (casting may be necessary):
+ myParamValue = test.getParam('myParamName')
+ see the test config for the list of parameters specific to the test.
+ -----------------------------------
+ SETTING OUTPUTS:
+ ret string, a text summarizing the result of the test. It must be set before the end of your code.
+ success bool, True = test successful. It must be set before the end of your code.
+ test.sendFeedback(ret,success) method that ends the testing script and gives the report to the calling application.
+ Examples:
+
+ whenever the code must quit (i.e. after an error), you must end with:
+ ret = 'here is some info on what failed on the test'
+ success = False
+ test.sendFeedback(ret, success)
+
+ whenever the code is finished successfully, you must end with:
+ ret = 'here is some info on the success of the test'
+ success = True
+ test.sendFeedback(ret, success)
+ -----------------------------------
+ LOG INFO:
+ when some information must be shown on the log, use:
+ test.log('test to log')
+ """
+
+ ########## Example (can be removed) ######
+ # print the list of parameters passed. If any error, stop and send feedback
+ test.log("Example - Test name: " + testName)
+ test.log("Example - Device name: " + DEVICE)
+ try:
+ test.log("Running test with the following parameters:")
+ test.log(params)
+ # If present, use the parameters here below for your test script. You might need to change the casting
+ examplePar1 = float(test.getParam('examplePar1')) ; examplePar2 = float(test.getParam('examplePar2')) ;
+ except:
+ ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
+ success = False
+ test.sendFeedback(ret, success)
+ return
+
+ # loop to read channels for a while and plot the channels values.
+ # initialise plot tab with 2 plots
+ scan = ManualScan(['sample'], ['Motor Status (MSTA)', 'Motor Position (VAL)'])
+ # set plot name(tab title)
+ scan.setPlotName(plotName)
+ # start plots. See further below how to add points to the plots
+ scan.start()
+
+ # IMPORTANT: if the test failed, write the report into the variables ret and success.
+ # for example, write the following:
+ ret = "Example - Error, the test failed because...."
+ success = False
+ # set up connection to channels. "type" of data can be "d" (= double), "l" (= long)
+ try:
+ pv_motor_msta = Channel(DEVICE + ':MOTOR.MSTA', type='d')
+ pv_motor_val = Channel(DEVICE + ':MOTOR.VAL', type='d')
+ except:
+ # prepare return information: return text
+ ret = 'Unable to create channel - ' + traceback.format_exc()
+ # prepare return information: return success
+ success = False
+ # send return information
+ test.sendFeedback(ret, success)
+ return
+ # take 100 samples of the channels
+ for sample in range(0, 100):
+ readback1 = sample #the x axis
+ sleep(0.1) # Settling time
+ # get value
+ motor_msta = pv_motor_msta.get()
+ # get value
+ motor_val = pv_motor_val.get()
+ # add values to plot
+ scan.append([readback1], [readback1], [motor_msta, motor_val])
+
+ # Closing channels
+ pv_motor_msta.close()
+ pv_motor_val.close()
+
+ # IMPORTANT: if the test was successful, write the report into the variables ret and success.
+ # for example, write the following:
+ ret = "Example - Test successful, here some detail: ..."
+ success = True
+ test.sendFeedback(ret, success)
+ # once the test is finished, no need to do anything. The code below yours will do the rest.
+ ################ End of Example ##########
+
+################ END OF YOUR CODE ################
+###### Final - DO NOT MODIFY THE CODE BELOW ######
+
+ # just in case the feedback was forgotten
+ test.sendFeedback(ret, success)
+ except (KeyboardInterrupt):
+ # user stop error handler
+ ret = 'Test stopped by user.'
+ success = False
+ test.sendFeedback(ret, success)
+ except:
+ # generic error handler
+ ret = traceback.format_exc()
+ success = False
+ test.sendFeedback(ret, success)
+
+
+# launch the test
+startTest(test, device, parameters)
+
+################ END OF Final ####################
+#### IF NEEDED, ADD YOUR FUNCTIONS HERE BELOW ####
+# def yourCustomFunction: