This commit is contained in:
boccioli_m
2015-08-28 07:58:35 +02:00
parent 88894e7890
commit fc64356e5e
8 changed files with 278 additions and 338 deletions

View File

@@ -44,34 +44,32 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel4" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="txtTestSuite" min="-2" pref="513" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel5" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="txtTestName" min="-2" pref="513" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel7" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="0" max="-2" attributes="0"/>
<Component id="lblParams" alignment="0" max="-2" attributes="0"/>
<Component id="lblDescr" alignment="0" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="jScrollPane3" min="-2" pref="513" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jScrollPane3" pref="513" max="32767" attributes="0"/>
<Component id="txtTestName" alignment="0" pref="513" max="32767" attributes="0"/>
<Component id="jComboBoxTestSuites" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="513" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jButtonGenerate" min="-2" pref="188" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="513" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<Component id="jButtonGenerate" alignment="1" min="-2" pref="188" max="-2" attributes="0"/>
<Component id="lblName" alignment="0" max="-2" attributes="0"/>
<Component id="lblSuite" alignment="0" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
@@ -82,33 +80,41 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtTestName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtTestSuite" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblSuite" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jComboBoxTestSuites" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane3" min="-2" pref="81" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<Component id="lblDescr" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<Component id="lblParams" min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="180" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButtonGenerate" min="-2" pref="33" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel4">
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Name *"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblSuite">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
@@ -116,19 +122,20 @@
<Property name="text" type="java.lang.String" value="Test Case/Suite *"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtTestSuite">
<Component class="javax.swing.JLabel" name="lblParams">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Test Parameters"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Component class="javax.swing.JLabel" name="lblDescr">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Test Name *"/>
<Property name="text" type="java.lang.String" value="Description *"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtTestName">
@@ -138,6 +145,37 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="jComboBoxTestSuites">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="txtTestDescription">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
@@ -188,46 +226,6 @@
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Test Parameters"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Test Description *"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="txtTestDescription">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButtonGenerate">
<Properties>
<Property name="text" type="java.lang.String" value="Generate"/>

View File

@@ -45,13 +45,15 @@ public class NewTest extends javax.swing.JPanel {
/**
* Creates new form TestingListDetails
*/
private String sType;
public NewTest() {
initComponents();
}
public NewTest(String hDetails) {
initComponents();
fillComponents();
sType = hDetails;
fillComponents(sType);
}
/**
@@ -66,16 +68,16 @@ public class NewTest extends javax.swing.JPanel {
jPopupMenuTable = new javax.swing.JPopupMenu();
jMenuItemAddRow = new javax.swing.JMenuItem();
jMenuItemReleteRow = new javax.swing.JMenuItem();
jLabel4 = new javax.swing.JLabel();
txtTestSuite = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
lblName = new javax.swing.JLabel();
lblSuite = new javax.swing.JLabel();
lblParams = new javax.swing.JLabel();
lblDescr = new javax.swing.JLabel();
txtTestName = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTableParams = new javax.swing.JTable();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jComboBoxTestSuites = new javax.swing.JComboBox();
jScrollPane3 = new javax.swing.JScrollPane();
txtTestDescription = new javax.swing.JTextArea();
jScrollPane1 = new javax.swing.JScrollPane();
jTableParams = new javax.swing.JTable();
jButtonGenerate = new javax.swing.JButton();
jMenuItemAddRow.setText("Add Row");
@@ -94,16 +96,28 @@ public class NewTest extends javax.swing.JPanel {
});
jPopupMenuTable.add(jMenuItemReleteRow);
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel4.setText("Test Case/Suite *");
lblName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
lblName.setText("Name *");
txtTestSuite.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
lblSuite.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
lblSuite.setText("Test Case/Suite *");
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel5.setText("Test Name *");
lblParams.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
lblParams.setText("Test Parameters");
lblDescr.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
lblDescr.setText("Description *");
txtTestName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jScrollPane3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestDescription.setColumns(20);
txtTestDescription.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestDescription.setLineWrap(true);
txtTestDescription.setRows(5);
jScrollPane3.setViewportView(txtTestDescription);
jTableParams.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jTableParams.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
@@ -129,20 +143,6 @@ public class NewTest extends javax.swing.JPanel {
jTableParams.getColumnModel().getColumn(1).setMaxWidth(100);
}
jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel7.setText("Test Parameters");
jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel8.setText("Test Description *");
jScrollPane3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestDescription.setColumns(20);
txtTestDescription.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestDescription.setLineWrap(true);
txtTestDescription.setRows(5);
jScrollPane3.setViewportView(txtTestDescription);
jButtonGenerate.setText("Generate");
jButtonGenerate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -156,27 +156,25 @@ public class NewTest extends javax.swing.JPanel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtTestSuite, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel8))
.addComponent(lblParams)
.addComponent(lblDescr))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
.addComponent(txtTestName, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
.addComponent(jComboBoxTestSuites, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jButtonGenerate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addComponent(lblName)
.addComponent(lblSuite))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
@@ -184,30 +182,29 @@ public class NewTest extends javax.swing.JPanel {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(lblName)
.addComponent(txtTestName, 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(jLabel4)
.addComponent(txtTestSuite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblSuite)
.addComponent(jComboBoxTestSuites, 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.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addComponent(lblDescr))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(lblParams)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jButtonGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateActionPerformed
// TODO add your handling code here:
if(checkDataFields())
{
if(checkDataFields()){
generateTestFiles();
}
}//GEN-LAST:event_jButtonGenerateActionPerformed
@@ -234,7 +231,6 @@ public class NewTest extends javax.swing.JPanel {
model.removeRow(row);
}
}//GEN-LAST:event_jMenuItemReleteRowActionPerformed
public static Path TESTS_DEVICES_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "devices");
public static Path TESTS_TESTS_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "tests");
@@ -243,17 +239,40 @@ public class NewTest extends javax.swing.JPanel {
public static String TESTS_HELP_FILENAME = "help.html";
public static Path TEMPLATES_HELP_FILEPATH = Paths.get(".", "home", "script", "tests","templates","helpTemplate.html");
public static Path TEMPLATES_TESTSCRIPT_FILEPATH = Paths.get(".", "home", "script", "tests","templates","testTemplate.py");
public static Path TEMPLATES_CONFIG_FILEPATH = Paths.get(".", "home", "script", "tests","templates","template.config");
public static Path TEMPLATES_TESTCONFIG_FILEPATH = Paths.get(".", "home", "script", "tests","templates","testTemplate.config");
public static Path TEMPLATES_DEVICECONFIG_FILEPATH = Paths.get(".", "home", "script", "tests","templates","deviceTemplate.config");
public static String ALLOWED_CHARS = "[a-zA-Z0-9._\\-\\]\\[(){} ]*";
/**
* fill table with example parameters
* @param newType the new can be Device or Test.
*/
private void fillComponents() {
private void fillComponents(String newType) {
if(newType == "Device"){
this.lblDescr.setText(newType + " "+ this.lblDescr.getText());
this.lblName.setText(newType + " "+ this.lblName.getText());
lblParams.setVisible(false);
jTableParams.setVisible(false);
jScrollPane1.setVisible(false);
}
//fill test suites combo box
File testsFolder = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString()).toFile();
if (testsFolder.exists() && testsFolder.isDirectory()) {
File[] listOfTests = testsFolder.listFiles();
for (File listOfTest : listOfTests) {
if (listOfTest.isDirectory()) {
this.jComboBoxTestSuites.addItem(listOfTest.getName().toString());
}
}
}
this.jComboBoxTestSuites.setEditable(true);
this.jComboBoxTestSuites.setSelectedItem(null);
//fill parameters table
InputStream ist = null;
try {
Properties propTest = new Properties();
File configFile = TEMPLATES_CONFIG_FILEPATH.toFile();
File configFile = TEMPLATES_TESTCONFIG_FILEPATH.toFile();
ist = new FileInputStream(configFile);
propTest.load(ist);
String testParams = propTest.getProperty("parameters");
@@ -276,16 +295,16 @@ public class NewTest extends javax.swing.JPanel {
jTableParams.setModel(model);
}
} catch (FileNotFoundException ex) {
SwingUtils.showMessage(this, "fillComponents()", "Cannot find file " + TEMPLATES_CONFIG_FILEPATH.toString());
SwingUtils.showMessage(this, "fillComponents()", "Cannot find file " + TEMPLATES_TESTCONFIG_FILEPATH.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
SwingUtils.showMessage(this, "fillComponents()", "Cannot read file " + TEMPLATES_CONFIG_FILEPATH.toString());
SwingUtils.showMessage(this, "fillComponents()", "Cannot read file " + TEMPLATES_TESTCONFIG_FILEPATH.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
ist.close();
} catch (IOException ex) {
SwingUtils.showMessage(this, "fillComponents()", "Cannot close file " + TEMPLATES_CONFIG_FILEPATH.toString());
SwingUtils.showMessage(this, "fillComponents()", "Cannot close file " + TEMPLATES_TESTCONFIG_FILEPATH.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
@@ -339,14 +358,14 @@ public class NewTest extends javax.swing.JPanel {
//check compulsory data fields
if(this.txtTestName.getText().isEmpty() ||
this.txtTestDescription.getText().isEmpty() ||
this.txtTestSuite.getText().isEmpty()){
this.jComboBoxTestSuites.getSelectedItem().toString().isEmpty()){
SwingUtils.showMessage(this, "checkDataFields()",
"Please fill-in all compulsory fields (marked with *)");
return false;
}
if(!(txtTestName.getText().matches(ALLOWED_CHARS) &&
txtTestDescription.getText().matches(ALLOWED_CHARS) &&
txtTestSuite.getText().matches(ALLOWED_CHARS)
jComboBoxTestSuites.getSelectedItem().toString().matches(ALLOWED_CHARS)
)){
SwingUtils.showMessage(this, "checkDataFields()",
"Please remove forbidden chars: only letters, numbers, parenthesis are allowed");
@@ -376,10 +395,17 @@ public class NewTest extends javax.swing.JPanel {
public void generateTestFiles(){
HashMap hmTestParams = (HashMap) getParametersFromTable();
generateTestFiles(this.txtTestName.getText(),
this.txtTestDescription.getText(),
this.txtTestSuite.getText(),
hmTestParams);
if(sType.equals("Device")){
generateDeviceFiles(this.txtTestName.getText(),
this.txtTestDescription.getText(),
this.jComboBoxTestSuites.getSelectedItem().toString(),
hmTestParams);
}else{
generateTestFiles(this.txtTestName.getText(),
this.txtTestDescription.getText(),
this.jComboBoxTestSuites.getSelectedItem().toString(),
hmTestParams);
}
}
public void generateTestFiles(String sTestName,
@@ -415,7 +441,8 @@ public class NewTest extends javax.swing.JPanel {
}
//generate test files inside test dir
if (!generateTestConfig(testDir,
if (!generateTestConfig(TEMPLATES_TESTCONFIG_FILEPATH,
testDir,
sTestName,
sTestDescription,
sTestSuite,
@@ -436,6 +463,43 @@ public class NewTest extends javax.swing.JPanel {
SwingUtils.showMessage(this, "generateTestFiles()", "Cannot find tests default directory " + TESTS_TESTS_DEFAULT_DIR.toString());
}
}
public void generateDeviceFiles(String sTestName,
String sTestDescription,
String sTestSuite,
HashMap hmTestParams){
if (TESTS_DEVICES_DEFAULT_DIR.toFile().isDirectory()) {
//new device directory inside tests suite dir
Path testDir = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(),sTestName);
if( testDir.toFile().isDirectory()){
//device already exists: ask to overwrite
OptionResult res = SwingUtils.showOption(this, "Overwrite Device?", "Device already exists. Overwrite with this new one?", OptionType.YesNo);
if (res == OptionResult.No){
return;
}
}else{
boolean success = testDir.toFile().mkdirs();
if (!success) {
// Directory creation failed
SwingUtils.showMessage(this, "generateTestFiles()", "Cannot create directory " + testDir.toString());
return;
}
}
//generate device files inside device dir
if (!generateTestConfig(TEMPLATES_DEVICECONFIG_FILEPATH,
testDir,
sTestName,
sTestDescription,
sTestSuite,
hmTestParams)) return;
SwingUtils.showMessage(this, "Test generated", "Test "+sTestName+" successfully generated in \n"+testDir.toString());
}else{
SwingUtils.showMessage(this, "generateTestFiles()", "Cannot find tests default directory " + TESTS_TESTS_DEFAULT_DIR.toString());
}
}
public boolean generateTestScript(Path testDir,
String sTestName,
@@ -465,8 +529,8 @@ public class NewTest extends javax.swing.JPanel {
}
}
replaceParameters(path,
new String[]{"$testName","$testDescription","#$testParameters"},
new String[]{sTestName,sTestDescription,sSyntaxGetTestParameters});
new String[]{"$testName", "$testDescription","$testSuite","#$testParameters"},
new String[]{sTestName, sTestDescription,sTestSuite,sSyntaxGetTestParameters});
success = true;
} catch (IOException ex) {
SwingUtils.showMessage(this, "generateTestScript()", "Cannot copy file " + ex.toString());
@@ -475,7 +539,8 @@ public class NewTest extends javax.swing.JPanel {
return success;
}
public boolean generateTestConfig(Path testDir,
public boolean generateTestConfig(Path templateDir,
Path testDir,
String sTestName,
String sTestDescription,
String sTestSuite,
@@ -487,7 +552,7 @@ public class NewTest extends javax.swing.JPanel {
if(Files.exists(path)){
Files.delete(path);
}
Files.copy(TEMPLATES_CONFIG_FILEPATH, path);
Files.copy(templateDir, path);
File configFile = path.toFile();
//Loop among the test parameters and generate variable assignement syntax for python
String sTestParameters = "";
@@ -502,16 +567,23 @@ public class NewTest extends javax.swing.JPanel {
//build the python code for getting the test parameter
sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ;
}
}
String content = "#Test configuration\n";
content +=("\nname=" + sTestName);
content +=("\ndescription=" + sTestDescription);
content +=("\nparameters=" + sTestParameters);
OutputStream is = new FileOutputStream(configFile);
Charset charset = StandardCharsets.UTF_8;
Files.write(path, content.getBytes(charset));
is.write(content.getBytes());
is.close();
}
FileInputStream in = new FileInputStream(configFile);
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream(configFile);
if(sType.equals("Devices")){
props.setProperty("name", sTestName);
props.setProperty("description", sTestDescription);
props.setProperty("parameters", sTestParameters);
}else{
props.setProperty("name", sTestName);
props.setProperty("description", sTestDescription);
props.setProperty("tests", sTestSuite);
}
props.store(out, null);
out.close();
success = true;
} catch (FileNotFoundException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Cannot find file: " + ex.toString());
@@ -590,18 +662,18 @@ public class NewTest extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonGenerate;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JComboBox jComboBoxTestSuites;
private javax.swing.JMenuItem jMenuItemAddRow;
private javax.swing.JMenuItem jMenuItemReleteRow;
private javax.swing.JPopupMenu jPopupMenuTable;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JTable jTableParams;
private javax.swing.JLabel lblDescr;
private javax.swing.JLabel lblName;
private javax.swing.JLabel lblParams;
private javax.swing.JLabel lblSuite;
private javax.swing.JTextArea txtTestDescription;
private javax.swing.JTextField txtTestName;
private javax.swing.JTextField txtTestSuite;
// End of variables declaration//GEN-END:variables
}

View File

@@ -39,6 +39,16 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItemNewTestActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItemNewDevice">
<Properties>
<Property name="text" type="java.lang.String" value="New Device..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItemNewDeviceActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator2">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItemOpenLog">
<Properties>
<Property name="text" type="java.lang.String" value="Open Log"/>

View File

@@ -334,6 +334,8 @@ public class TestingList extends Panel {
jSeparator1 = new javax.swing.JPopupMenu.Separator();
jMenuAdvanced = new javax.swing.JMenu();
jMenuItemNewTest = new javax.swing.JMenuItem();
jMenuItemNewDevice = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
jMenuItemOpenLog = new javax.swing.JMenuItem();
jPopupMenuConfigs = new javax.swing.JPopupMenu();
jScrollPane2 = new javax.swing.JScrollPane();
@@ -376,6 +378,15 @@ public class TestingList extends Panel {
});
jMenuAdvanced.add(jMenuItemNewTest);
jMenuItemNewDevice.setText("New Device...");
jMenuItemNewDevice.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemNewDeviceActionPerformed(evt);
}
});
jMenuAdvanced.add(jMenuItemNewDevice);
jMenuAdvanced.add(jSeparator2);
jMenuItemOpenLog.setText("Open Log");
jMenuItemOpenLog.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -669,9 +680,14 @@ public class TestingList extends Panel {
private void jMenuItemNewTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewTestActionPerformed
// TODO add your handling code here:
openNewTestEditor();
openNewTestEditor("Test");
}//GEN-LAST:event_jMenuItemNewTestActionPerformed
private void jMenuItemNewDeviceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewDeviceActionPerformed
// TODO add your handling code here:
openNewTestEditor("Device");
}//GEN-LAST:event_jMenuItemNewDeviceActionPerformed
//<editor-fold defaultstate="collapsed" desc="Witget Variables declaration">
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonMoveDown;
@@ -683,6 +699,7 @@ public class TestingList extends Panel {
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuShowSelectedTests;
private javax.swing.JMenu jMenuAdvanced;
private javax.swing.JMenuItem jMenuItemNewDevice;
private javax.swing.JMenuItem jMenuItemNewTest;
private javax.swing.JMenuItem jMenuItemOpenLog;
private javax.swing.JMenuItem jMenuItemReload;
@@ -693,6 +710,7 @@ public class TestingList extends Panel {
private javax.swing.JPopupMenu jPopupMenuOptions;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JTable jTable1;
// End of variables declaration//GEN-END:variables
//</editor-fold>
@@ -722,15 +740,14 @@ public class TestingList extends Panel {
}
}
public void openNewTestEditor(){
public void openNewTestEditor(String type){
try {
// NewTest nt = new NewTest();
// nt.setVisible(true);
JDialog dlg = new JDialog(getView(), "New Test", true);
//create a class to visualise the details panel
String sDetails = "";
Class testingListDetailsClass = getController().getClassByName("NewTest");
JPanel detailsPanel = (JPanel) testingListDetailsClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{sDetails});
JPanel detailsPanel = (JPanel) testingListDetailsClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{type});
dlg.getContentPane().add(detailsPanel);
//dlg.add(new TestingListDetails());

View File

@@ -40,7 +40,7 @@
<Component id="jScrollPane1" alignment="0" pref="513" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="jPanel1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jButtonOk" alignment="1" min="-2" pref="96" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jScrollPane4" pref="317" max="32767" attributes="0"/>
@@ -87,18 +87,16 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="192" max="32767" attributes="0"/>
<EmptySpace min="0" pref="216" max="32767" attributes="0"/>
</Group>
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jScrollPane4" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButtonOk" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane4" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -313,47 +311,14 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
<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="jButtonOk" min="-2" pref="96" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButtonCancel" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButtonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButtonOk" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButtonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButtonOk">
<Properties>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOkActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButtonOk">
<Properties>
<Property name="text" type="java.lang.String" value="Save"/>
<Property name="toolTipText" type="java.lang.String" value="Save parameters values"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOkActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -82,8 +82,6 @@ public class TestingListDetails extends javax.swing.JPanel {
txtTestDescription = new javax.swing.JTextArea();
jScrollPane4 = new javax.swing.JScrollPane();
jEditorPaneHelp = new javax.swing.JEditorPane();
jPanel1 = new javax.swing.JPanel();
jButtonCancel = new javax.swing.JButton();
jButtonOk = new javax.swing.JButton();
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
@@ -174,35 +172,14 @@ public class TestingListDetails extends javax.swing.JPanel {
jEditorPaneHelp.setDropMode(javax.swing.DropMode.INSERT);
jScrollPane4.setViewportView(jEditorPaneHelp);
jButtonCancel.setText("Cancel");
jButtonOk.setText("Ok");
jButtonOk.setText("Save");
jButtonOk.setToolTipText("Save parameters values");
jButtonOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonOkActionPerformed(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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonOk, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonCancel)
.addComponent(jButtonOk))
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -228,7 +205,7 @@ public class TestingListDetails extends javax.swing.JPanel {
.addComponent(jScrollPane3)
.addComponent(jScrollPane2)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)))
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButtonOk, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
.addContainerGap())
@@ -266,13 +243,12 @@ public class TestingListDetails extends javax.swing.JPanel {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
.addGap(0, 192, Short.MAX_VALUE))
.addGap(0, 216, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane4)
.addContainerGap())))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonOk))
.addComponent(jScrollPane4))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
@@ -411,20 +387,22 @@ public class TestingListDetails extends javax.swing.JPanel {
sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ;
}
}
FileOutputStream out = new FileOutputStream(path.toFile());
FileInputStream in = new FileInputStream(path.toFile());
Properties props = new Properties();
props.load(in);
in.close();
props.setProperty("parameters", "sTestParameters");
FileOutputStream out = new FileOutputStream(path.toFile());
props.setProperty("parameters", sTestParameters);
props.store(out, null);
out.close();
success = true;
} catch (FileNotFoundException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Cannot find file: " + ex.toString());
success = false;
} catch (IOException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Problem with file aaccess: " + ex.toString());
success = false;
}
return success;
}
@@ -437,7 +415,6 @@ public class TestingListDetails extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonCancel;
private javax.swing.JButton jButtonOk;
private javax.swing.JEditorPane jEditorPaneHelp;
private javax.swing.JLabel jLabel1;
@@ -447,7 +424,6 @@ public class TestingListDetails extends javax.swing.JPanel {
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;

View File

@@ -1,7 +0,0 @@
name=Monitor Movement
description=Monitor the movements during the specified time interval. No commands are sent.
#optional parameters. Description is compulsory. Syntax:
#parameters=<parameter1Name>:<parameter1Value>:<Parameter 1 description>[;<parameter2Name>:<parameter2Value>:<Parameter 2 description>]
parameters=monitorTime:40:Monitor time interval [s]

View File

@@ -1,91 +0,0 @@
###### DO NOT MODIFY THE CODE BELOW ######
def startTest(testName, DEVICE, params):
#get the path of this script
testPath = inspect.getfile(inspect.currentframe())
#by default, failed
ret = 'Test failed'
status = False
#plot name to be given to the scan. Use: scan.setPlotName(plotName)
plotName = DEVICE + ' - ' + testName
###### WRITE YOUR CODE HERE BELOW #######
#get parameters from the calling interface
print_log(testName, DEVICE, 'testpath: ' + testPath )
print_log(testName, DEVICE, 'parameters:' + str( params) )
print_log(testName, DEVICE, 'device: ' + DEVICE )
scan = ManualScan(['time'], ['idMotorStep', 'idPotiPosition', 'idPotiRef1Position','idMotorStep-idPotiPosition'] , [0.0], [30.0], [20])
scan.setPlotName(plotName)
scan.start()
#Creating channels: dimension 1
try:
idCom = Channel(DEVICE+':COM:2', type = 'd') #current position as from motor step counter [mm]
idMotorStep = Channel(DEVICE+':IST3:2', type = 'd') #current position as from motor step counter [mm]
idPotiPosFromBeam = Channel(DEVICE+':IST1:2', type = 'd') #current position from beam as from potentiometer [mm]
idPotiPosition = Channel(DEVICE+':IST2:1', type = 'd') #current position as from potentiometer [mm]
idPotiRef1Position = Channel(DEVICE+':REF1:1', type = 'd') #R1 position as from potentiometer [mm]
idPotiRef2Position = Channel(DEVICE+':REF2:1', type = 'd') #R2 position as from potentiometer [mm]
except:
sendFeedback(testPath, testName, DEVICE, 'Unable to create channel - ' + traceback.format_exc(), False)
#raise Exception('Unable to create channel - ' + traceback.format_exc())
return
monitorTime=40 #seconds
print_log(testName, DEVICE, 'Monitoring movement for ' + str(monitorTime) + 's')
#scan quickly the output during some seconds
detector4 = idPotiPosition.get()
detector6 = idPotiRef2Position.get()
timeElapsed=0
while timeElapsed<(monitorTime*10):
#Detector time
detector1 = float(java.lang.System.currentTimeMillis())
detector2 = idMotorStep.get()
detector3 = idPotiPosFromBeam.get()
detector4 = idPotiPosition.get()
detector5 = idPotiRef1Position.get()
detector6 = idPotiRef2Position.get()
diff1 = detector2-detector4
scan.append ([detector1], [detector1], [detector2, detector4, detector5, diff1])
sleep( 0.1 ) # Settling time
timeElapsed=timeElapsed+1
#Closing channels
idCom.close()
idMotorStep.close()
idPotiPosFromBeam.close()
idPotiPosition.close()
idPotiRef1Position.close()
idPotiRef2Position.close()
print_log(testName, DEVICE, 'End of Monitoring')
ret = 'End of Monitoring'
status = True
########## END OF YOUR CODE ###########
###### DO NOT MODIFY THE CODE BELOW ######
sendFeedback(testPath, testName, DEVICE, ret, status)
#prepare and send feedback to calling tool
def sendFeedback(testPath, testName, DEVICE, returnString, testPassed):
print_log(testName, DEVICE, 'End of test. Result:')
print_log(testName, DEVICE, 'Test path: ' + testPath)
print_log(testName, DEVICE, 'Test name: ' + testName )
print_log(testName, DEVICE, 'Device: ' + DEVICE)
print_log(testName, DEVICE, 'Test passed: ' + str(testPassed))
print_log(testName, DEVICE, 'Return string: ' + returnString)
ret = [testPath, DEVICE, returnString, testPassed]
set_return(ret)
def print_log(testName, DEVICE, text):
time.ctime()
now = time.strftime('%Y.%m.%d %H:%M:%S')
print now + ' ' + DEVICE + ' - ' + testName + ': ' + text
import sys, inspect, os, traceback
#get test arguments
DEVICE = device
testName = test
params = parameters
#launch the test
startTest(testName, DEVICE, params)