Closedown
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
<Font name="Tahoma" size="15" style="0"/>
|
||||
</Property>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" postCode="jTable1.getTableHeader().setReorderingAllowed(false);">
|
||||
<Connection code="new javax.swing.table.DefaultTableModel(
 new Object [][] {

 },
 new String [] {
 "Select", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Test Help", "Start", "Last Test Result", "Status", ""
 }
) {
 Class[] types = new Class [] {
 java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, javax.swing.Icon.class
 };
 boolean[] canEdit = new boolean [] {
 true, false, false, false, false, false, false, false, false, false, true, false, false, false
 };

 public Class getColumnClass(int columnIndex) {
 return types [columnIndex];
 }

 public boolean isCellEditable(int rowIndex, int columnIndex) {
 return canEdit [columnIndex];
 }
}" type="code"/>
|
||||
<Connection code="new javax.swing.table.DefaultTableModel(
 new Object [][] {

 },
 new String [] {
 "Select", "Start", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Test Help", "Last Test Result", "Status", ""
 }
) {
 Class[] types = new Class [] {
 java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, javax.swing.Icon.class
 };
 boolean[] canEdit = new boolean [] {
 true, true, false, false, false, false, false, false, false, false, false, false, false, false
 };

 public Class getColumnClass(int columnIndex) {
 return types [columnIndex];
 }

 public boolean isCellEditable(int rowIndex, int columnIndex) {
 return canEdit [columnIndex];
 }
}" type="code"/>
|
||||
</Property>
|
||||
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
|
||||
<TableColumnModel selectionModel="0"/>
|
||||
|
||||
@@ -74,7 +74,7 @@ public class TestingList extends Panel {
|
||||
* @param exception
|
||||
*/
|
||||
@Override
|
||||
protected void onExecutedFile(String fileName, Object result, Throwable exception) {
|
||||
protected void onExecutedFile(String fileName, Object result) {
|
||||
int iCurrentTestPos = 0;
|
||||
try {
|
||||
Object ret = eval("ret");
|
||||
@@ -133,16 +133,16 @@ public class TestingList extends Panel {
|
||||
*/
|
||||
public enum COL {
|
||||
CHECK (0),
|
||||
TIME (1),
|
||||
DEVICENAME (2),
|
||||
DEVICEDESCR (3),
|
||||
TESTSUITE (4),
|
||||
TESTNAME (5),
|
||||
TESTPATH (6),
|
||||
TESTPARAMS (7),
|
||||
TESTDESCR (8),
|
||||
TESTHELP (9),
|
||||
STARTSEQUENCE (10),
|
||||
STARTSEQUENCE(1),
|
||||
TIME (2),
|
||||
DEVICENAME (3),
|
||||
DEVICEDESCR (4),
|
||||
TESTSUITE (5),
|
||||
TESTNAME (6),
|
||||
TESTPATH (7),
|
||||
TESTPARAMS (8),
|
||||
TESTDESCR (9),
|
||||
TESTHELP (10),
|
||||
RESULT (11),
|
||||
STATUS (12),
|
||||
ICON (13);
|
||||
@@ -318,14 +318,14 @@ public class TestingList extends Panel {
|
||||
|
||||
},
|
||||
new String [] {
|
||||
"Select", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Test Help", "Start", "Last Test Result", "Status", ""
|
||||
"Select", "Start", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Test Help", "Last Test Result", "Status", ""
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, javax.swing.Icon.class
|
||||
};
|
||||
boolean[] canEdit = new boolean [] {
|
||||
true, false, false, false, false, false, false, false, false, false, true, false, false, false
|
||||
true, true, false, false, false, false, false, false, false, false, false, false, false, false
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
@@ -442,6 +442,7 @@ public class TestingList extends Panel {
|
||||
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
|
||||
if(this.jButtonRun.getToolTipText().equals("Run selected tests")){
|
||||
setButtonToStart();
|
||||
updateStatus();
|
||||
executeTest(0);
|
||||
}
|
||||
else{
|
||||
@@ -726,16 +727,20 @@ public class TestingList extends Panel {
|
||||
String sStart;
|
||||
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
|
||||
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
|
||||
sStart = String.valueOf(jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal()));
|
||||
if (bSelected) {
|
||||
sStatus = TestStatus.PENDING.toString();
|
||||
icon = TestStatus.PENDING.Icon();
|
||||
if(sStart == "") sStart = StartSequence.START_SEQ_AFTER.toString();
|
||||
} else {
|
||||
sStatus = TestStatus.DISABLED.toString();
|
||||
icon = TestStatus.DISABLED.Icon();
|
||||
sStart = "";
|
||||
}
|
||||
jTable1.setValueAt(bSelected, row, COL.CHECK.ordinal());
|
||||
jTable1.setValueAt(icon, row, COL.ICON.ordinal());
|
||||
jTable1.setValueAt(sStatus, row, COL.STATUS.ordinal());
|
||||
jTable1.setValueAt(sStart, row, COL.STARTSEQUENCE.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,18 +808,20 @@ public class TestingList extends Panel {
|
||||
int[] selectedTestsRows = {};
|
||||
//scan through the table starting from 'position' and execute the first selected test found
|
||||
int row = position;
|
||||
if (row >=0 && row <= jTable1.getRowCount()-1 ) {
|
||||
for(row = position ; row <= jTable1.getRowCount()-1 ; row++){
|
||||
if (row >=0 && row < jTable1.getRowCount() ) {
|
||||
for(row = position ; row < jTable1.getRowCount() ; row++){
|
||||
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
|
||||
sStartSequence = jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal()).toString();
|
||||
sStatus = jTable1.getValueAt(row, COL.STATUS.ordinal()).toString();
|
||||
//collect tests to be launched in parallel
|
||||
//the test must be: selected, set as start with previous, pending.
|
||||
//alternatively, the test must be: selected, first of the list.
|
||||
System.out.println(String.valueOf(row) +"\t"+ String.valueOf(bSelected) +"\t"+ String.valueOf(selectedTestsRows.length) +"\t"+ sStartSequence +"\t"+ sStatus);
|
||||
|
||||
if( bSelected &&
|
||||
(selectedTestsRows.length == 0 || //the test must be: selected, first of the list.
|
||||
(sStartSequence.equals(StartSequence.START_SEQ_TOGETHER.toString()) && //or the test must be: selected, set as start with previous, pending.
|
||||
sStatus.equals(TestStatus.PENDING.toString()) ))){
|
||||
sStatus.equals(TestStatus.PENDING.toString()) ))){
|
||||
selectedTestsRows = append(selectedTestsRows, row);
|
||||
} else if (bSelected && //if this test must be executed...
|
||||
selectedTestsRows.length > 0 && //but there are already tests to be executed in parallel....
|
||||
@@ -822,8 +829,10 @@ public class TestingList extends Panel {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bSelected) { //at least one test is selected: launch it (or them)
|
||||
executeParallelTestsGroup(selectedTestsRows);
|
||||
if (selectedTestsRows.length > 0) { //at least one test is selected: launch it (or them)
|
||||
if (executeParallelTestsGroup(selectedTestsRows) < 0){ //last execution did not find a test file. Continue with next execution
|
||||
executeTest(position+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!bSelected){ //No test to play. Stop
|
||||
@@ -832,20 +841,23 @@ public class TestingList extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
private void executeParallelTestsGroup(int[] rowsToExecute){
|
||||
//start all the tests in the rowsToExecute
|
||||
private int executeParallelTestsGroup(int[] rowsToExecute){
|
||||
HashMap args = new HashMap();
|
||||
int iRet = -1;
|
||||
for(int row: rowsToExecute){
|
||||
//build the .py test file path
|
||||
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
|
||||
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
|
||||
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
|
||||
String sTestPath = jTable1.getValueAt(row, COL.TESTPATH.ordinal()).toString();
|
||||
HashMap mParameters = buildParametersMap(String.valueOf(jTable1.getValueAt(row, COL.TESTPARAMS.ordinal())));
|
||||
System.out.println(String.valueOf(row) +"\t"+ sDeviceName +"\t"+ sTestName +"\t"+ sTestCaseName +"\t"+ String.valueOf(rowsToExecute.length));
|
||||
try{
|
||||
File f = new File(sTestPath);
|
||||
if(!f.exists() || f.isDirectory()){
|
||||
logger.log(Level.SEVERE, "Cannot find test script: " + sTestPath);
|
||||
showResult(sDeviceName, sTestPath, "Cannot find test script: " + sTestPath, TestStatus.FAILURE.toString());
|
||||
iRet = -1;
|
||||
continue;
|
||||
}
|
||||
showResult(sDeviceName, sTestPath, "Test running", TestStatus.RUNNING.toString());
|
||||
@@ -860,6 +872,7 @@ public class TestingList extends Panel {
|
||||
logger.log(Level.INFO, "Running Test '" + sTestName + "'. No parameters found.");
|
||||
}
|
||||
runAsync(sTestPath, args);
|
||||
iRet = 0;
|
||||
} catch (Exception ex) {
|
||||
SwingUtils.showMessage(this, "executeTest()", ex.toString());
|
||||
logger.log(Level.SEVERE, ex.toString());
|
||||
@@ -867,6 +880,7 @@ public class TestingList extends Panel {
|
||||
setButtonToStop();
|
||||
}
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -920,7 +934,7 @@ public class TestingList extends Panel {
|
||||
ImageIcon icon = null;// new ImageIcon(getClass().getResource("/icons/button_pause-16px.png"));
|
||||
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
|
||||
String testPath = FilenameUtils.separatorsToSystem(TESTS_TESTS_DEFAULT_DIR + testSuite + "/" + testName + "/" + testName + ".py");
|
||||
model.addRow(new Object[]{false, sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, StartSequence.START_SEQ_AFTER.toString(), "", "Pending", icon});
|
||||
model.addRow(new Object[]{false, "", sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon});
|
||||
jTable1.setModel(model);
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
#TODO: Set the diplay names of positioners and detectors
|
||||
#ManualScan(writables, readables, start = None, end = None, steps = None, relative = False)
|
||||
|
||||
#by default, failed
|
||||
ret = 'Test failed'
|
||||
status = False
|
||||
|
||||
scan = ManualScan(['time'], ['SetVA', 'ActualVA', 'ActualIA'] , [0.0], [30.0], [20])
|
||||
scan.start()
|
||||
|
||||
#Creating channels: dimension 1
|
||||
#Ramp rate
|
||||
SetRamp = Channel(DEVICE + ':Set-RampA', type = 'd')
|
||||
#SetRamp = Channel('pw84:ai', type = 'd')
|
||||
#LinearPositioner SetVA
|
||||
SetVA = Channel(DEVICE + ':Set-VA', type = 'd')
|
||||
#SetVA = Channel('pw84:ai', type = 'd')
|
||||
#Timestamp time
|
||||
#ScalarDetector ActualVA
|
||||
ActualVA = Channel(DEVICE + ':Actual-VA', type = 'd')
|
||||
#ActualVA = Channel('pw84:ai', type = 'd')
|
||||
#ScalarDetector ActualIA
|
||||
ActualIA = Channel(DEVICE + ':Actual-IA', type = 'd')
|
||||
#ActualIA = Channel('pw84:ai', type = 'd')
|
||||
|
||||
#Init
|
||||
SetRamp.put(10.0, timeout=None)
|
||||
|
||||
#set voltage to 0
|
||||
print 'Ramping down power supply to 0V'
|
||||
SetVA.put(0.0, timeout=None)
|
||||
|
||||
#wait up to 2 minutes for voltage to be ~0
|
||||
for setpoint1 in frange(0.0, 120.0, 1.0, True):
|
||||
detector2 = ActualVA.get()
|
||||
if detector2 <= 1.0:
|
||||
break
|
||||
sleep(0.5)
|
||||
|
||||
#Dimension 1
|
||||
#LinearPositioner SetVA
|
||||
print 'Ramping up power supply'
|
||||
for setpoint1 in frange(0.0, 30.0, 5.0, True):
|
||||
if setpoint1 > 50.0 or setpoint1 < 0.0:
|
||||
break
|
||||
SetVA.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
|
||||
readback1 = SetVA.get()
|
||||
if abs(readback1 - setpoint1) > 0.9 : # TODO: Check accuracy
|
||||
raise Exception('SetVA could not be set to the value ' + str(setpoint1))
|
||||
ret = 'SetVA could not be set to the value ' + str(setpoint1) + '(measured value: '+str(readback1)+')'
|
||||
status = False
|
||||
break
|
||||
#scan quickly the output during some seconds
|
||||
for setpoint2 in range(0, 20):
|
||||
#Detector time
|
||||
detector1 = float(java.lang.System.currentTimeMillis())
|
||||
#Detector ActualVA
|
||||
detector2 = ActualVA.get()
|
||||
detector3 = ActualIA.get()
|
||||
#scan.append ([setpoint1], [readback1], [detector1, detector2])
|
||||
#append(setpoints, positions, values)
|
||||
scan.append ([detector1], [detector1], [readback1, detector2, detector3])
|
||||
sleep( 0.1 ) # Settling time
|
||||
ret = 'Test completed'
|
||||
status = True
|
||||
|
||||
#reset output to 0V
|
||||
SetVA.put(0.0, timeout=None)
|
||||
#Closing channels
|
||||
SetVA.close()
|
||||
ActualVA.close()
|
||||
ActualIA.close()
|
||||
|
||||
|
||||
|
||||
scan.end()
|
||||
Reference in New Issue
Block a user