diff --git a/config/config.properties b/config/config.properties index 415535c..c28e09f 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,4 +1,4 @@ -#Tue Oct 17 16:31:19 CEST 2017 +#Thu Oct 19 15:24:58 CEST 2017 autoSaveScanData=true createSessionFiles=false dataFilesCreation=true @@ -16,7 +16,7 @@ hostName=null imageSourcesFile={config}/imaging.properties instanceName= logDaysToLive=5 -logLevel=Warning +logLevel=Info logLevelConsole=Warning logPath={logs}/{date}_{time} scanStreamerPort=-1 @@ -29,7 +29,7 @@ terminalEnabled=true terminalPort=3579 userAuthenticator=ch.psi.pshell.security.LdapAuthenticator | ldap\://d.psi.ch | d.psi.ch | users.psi userManagement=true -versionTrackingEnabled=false +versionTrackingEnabled=true versionTrackingLogin= versionTrackingManual=false versionTrackingRemote=https\://git.psi.ch/pshell_config/ncs.git diff --git a/plugins/TestingList.java b/plugins/TestingList.java index 15a3a83..d97c475 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -56,6 +56,7 @@ import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JMenuItem; import javax.swing.RowFilter; +import javax.swing.UIManager; import javax.swing.filechooser.FileSystemView; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableModel; @@ -346,7 +347,8 @@ public class TestingList extends Panel { } catch (Exception ex) { getLogger().severe(ex.getMessage()); } - loadProperties(); + loadProperties(); + } @@ -1570,7 +1572,7 @@ public class TestingList extends Panel { * @return status of run button. True = tests launching sequence is running */ public boolean isTestRunAllowed() { - return (this.jButtonRun.getToolTipText().equals("Stop tests") && pendingTestsCount() > 0); + return (this.jButtonRun.getToolTipText().equals("Stop tests") && countPendingTests() > 0); } /** @@ -1733,18 +1735,34 @@ public class TestingList extends Panel { logger.log(Level.SEVERE, "Cant find Test: " + testPath + " in table."); } //check if there are still pending tests. If not, set the status of the tool to Stopped. - if (pendingTestsCount() == 0 && runningTestsCount() == 0) { + if (countPendingTests() == 0 && countRunningTests() == 0) { setToStopped(); } + updateResultSummary(); return rowD; } + + /** + * show a summary icon indicating if all tests succeeded + * or if at least one failed + */ + public void updateResultSummary() { + ImageIcon summaryIcon = null; + if(countFailureTests()>0){ + summaryIcon = TestStatus.FAILURE.Icon(); + } else if(countSuccessTests()>0){ + summaryIcon = TestStatus.SUCCESS.Icon(); + } + //System.out.println("successful: "+countSuccessTests() + " Failed: "+countSuccessTests() ); + setIcon(jTable1, COL.ICON.ordinal(), summaryIcon, ""); + } /** * return the amount of tests currently in Pending state * * @return int counter of pending tests */ - public int pendingTestsCount() { + public int countPendingTests() { return testsStatusCount(TestStatus.PENDING); } @@ -1753,7 +1771,7 @@ public class TestingList extends Panel { * * @return int counter of running tests */ - public int runningTestsCount() { + public int countRunningTests() { return testsStatusCount(TestStatus.RUNNING); } @@ -1762,10 +1780,19 @@ public class TestingList extends Panel { * * @return int counter of successful tests */ - public int successTestsCount() { + public int countSuccessTests() { return testsStatusCount(TestStatus.SUCCESS); } + /** + * return the amount of tests currently in Failure state + * + * @return int counter of failed tests + */ + public int countFailureTests() { + return testsStatusCount(TestStatus.FAILURE); + } + /** * returns the amount of tests currently in "status" state * @@ -1775,15 +1802,16 @@ public class TestingList extends Panel { private int testsStatusCount(TestStatus status) { String sStatus; boolean bSelected; - int iPendingTestsCount = 0; + int iTestsCount = 0; for (int row = 0; row < jTable1.getRowCount(); row++) { bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal()); sStatus = jTable1.getValueAt(row, COL.STATUS.ordinal()).toString(); - if (bSelected && sStatus == status.toString()) { - iPendingTestsCount++; + //System.out.println("sStatus: " +sStatus); + if (bSelected && sStatus.equals(status.toString())) { + iTestsCount++; } } - return iPendingTestsCount; + return iTestsCount; } /** @@ -1895,6 +1923,7 @@ public class TestingList extends Panel { jTable1.setValueAt(sStatus, row, COL.STATUS.ordinal()); jTable1.setValueAt(sStart, row, COL.STARTSEQUENCE.ordinal()); } + updateResultSummary(); } /** @@ -2283,7 +2312,7 @@ public class TestingList extends Panel { //String testPath = FilenameUtils.separatorsToSystem(TESTS_TESTS_DEFAULT_DIR + testSuite + "/" + testName + "/" + testName + ".py"); String testPath = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString(); String devicePath = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(), deviceName, deviceName + ".config").toString(); - System.out.println("Path = " + testPath); + //System.out.println("Path = " + testPath); Object rowData[] = new Object[]{false, "", sDate, deviceName, devicePath, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon}; //vedify that this test is not already in the table int totalRows = model.getRowCount(); @@ -2690,4 +2719,51 @@ public class TestingList extends Panel { SwingUtils.showMessage(this, "loadListFilter()", ex.toString()); } } + + + + + /** + * for putting an icon and text to a table header + */ + public class iconRenderer extends DefaultTableCellRenderer{ + public Component getTableCellRendererComponent(javax.swing.JTable table, + Object obj,boolean isSelected, boolean hasFocus, int row, + int column) { + txtIcon i = (txtIcon)obj; + if (obj == i) { + setIcon(i.imageIcon); + setText(i.txt); + } + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + setHorizontalAlignment(javax.swing.JLabel.CENTER); + return this; + } + } + /** + * for putting an icon and text to a table header + */ + public class txtIcon { + String txt; + ImageIcon imageIcon; + txtIcon(String text, ImageIcon icon) { + txt = text; + imageIcon = icon; + } + } + + /** + * put an icon and text to a table header + * + * @param table the table where the header is + * @param col_index column index of the table header where to put the icon + * @param icon the icon to put to the header + * @param name the text to put to the header + */ + public void setIcon(javax.swing.JTable table, int col_index, ImageIcon icon,String name){ + table.getTableHeader().getColumnModel().getColumn(col_index).setHeaderRenderer(new iconRenderer()); + table.getColumnModel().getColumn(col_index).setHeaderValue(new txtIcon(name, icon)); + table.updateUI(); + } + } diff --git a/script/local.py b/script/local.py index 8cc9c8e..943dc6d 100644 --- a/script/local.py +++ b/script/local.py @@ -22,6 +22,7 @@ class TestingTool: self.testName = testName self.testPath = testPath self.testParams = testParams + self.log('\n'+'='*80) def getParam(self, paramName): """ @@ -91,11 +92,14 @@ class TestingTool: params = the JSON object with the parameters passed by pshell """ columnsFormat = '{0:17} {1:>20} {2}' + self.log('-'*80) self.log(columnsFormat.format("Parameter", "Value", "Description")) + self.log('-'*80) for key in self.testParams.keys(): self.log(columnsFormat.format(key, self.testParams[key]['value'], self.testParams[key]['description'])) + self.log('-'*80) def sendFeedback(self, returnString, testPassed): @@ -157,9 +161,7 @@ class Interlock: import binascii udp = UDPDatagram() msg = self._msgWrite() - print 'setInterlockMode', binascii.hexlify(msg) - modebytes = array('B', mode) - msg.extend(modebytes) + msg.extend(array('B', mode)) print 'setInterlockMode', binascii.hexlify(msg) if not udp.send(msg): return False @@ -172,7 +174,7 @@ class Interlock: msg = self._msgRead() print 'getInterlockMode', binascii.hexlify(msg) rcv = udp.send(msg) - print 'getInterlockMode', binascii.hexlify(rcv) + #print 'getInterlockMode', binascii.hexlify(rcv) return rcv def masterReset(self): @@ -190,7 +192,7 @@ class UDPDatagram: class for receiving and sending a udp message """ import socket - # the constructor + def __init__(self): # communication with interlock server self.serverPort = 0xBB1B # interlock server @@ -209,7 +211,7 @@ class UDPDatagram: try: # get the ip address and send print 'here should sendto:', self.serverName, self.serverPort - print 'message: ', message, binascii.hexlify(message) + print 'message: ', binascii.hexlify(message) #self.sock.sendto(message, (self.serverName, self.serverPort)) #except socket.error, msg: except : @@ -245,4 +247,5 @@ class UDPDatagram: def send(self, message): self._listenInit() self._sendUDP(message) - return self._listen() \ No newline at end of file + return self._listen() + \ No newline at end of file diff --git a/script/tests/config/rps-test b/script/tests/config/rps-test index fbf68ec..4f5068d 100644 Binary files a/script/tests/config/rps-test and b/script/tests/config/rps-test differ diff --git a/script/tests/devices/AMA1/.config b/script/tests/devices/AMA1/.config new file mode 100644 index 0000000..fc7fe9d --- /dev/null +++ b/script/tests/devices/AMA1/.config @@ -0,0 +1,5 @@ +#Wed Oct 18 15:07:43 CEST 2017 +name=AMA1 +tests=RPS Tests Interlocklilmits +parameters=ilkInExpectedValS&"0x91DD"&"[hex] Interlock Input expected value for small values of magnet";magnetCh&"AMA1\:SOL\:1"&"Magnet epics channel";ilkInCh&"J102025\:REG\:R\:6"&"Interlock Input epics channel";ilkInExpectedValIni&"0x1DDD"&"[hex] Interlock Input expected initial value";ilkOutExpectedValL&"0x0000"&"[hex] Interlock Output expected value for large values of magnet";magnetEndVal&"50000"&"[int] magnet final value for scan sequence";ilkOutCh&"J102025\:REG\:R\:3"&"Interlock Output epics channel";ilkOutExpectedValIni&"0x0000"&"[hex] Interlock Output expected initial value";ilkOutExpectedValS&"0x000C"&"[hex] Interlock Output expected value for small values of magnet";magnetInitVal&"0"&"[int] magnet initial value for scan sequence";setGetDelay&"1"&"[s] delay between set and get";mode&"2,IQCOM,$GNT2,1,DIA"&"operating mode"; +description=Ablenkungsmagnet AMA1 diff --git a/script/tests/devices/bis-BMA1/.config b/script/tests/devices/bis-BMA1/.config index 423ad64..9fbf4a2 100644 --- a/script/tests/devices/bis-BMA1/.config +++ b/script/tests/devices/bis-BMA1/.config @@ -1,5 +1,5 @@ -#Mon Oct 16 14:56:01 CEST 2017 +#Wed Oct 18 10:54:10 CEST 2017 name=bis-BMA1 tests=RPS Tests Betriebsmode +parameters=mode&"2,IQCOM,$BMA1,1,DIAG"&"operating mode";expectedVal14&"0x0000"&"[hex] Expected value for channels 1-4";expectedVal58&"0x0000"&"[hex] Expected value for channels 5-8"; description=rps section till BMA1 -parameters=mode&"2,IQCOM,$BMA1,1,DIAG"&"operating mode";channel&"PXXF\:VAL\:3"&"ssp";expectedVal14&"0x0000"&"[hex] Expected value for channels 1-4";expectedVal58&"0x0000"&"[hex] Expected value for channels 5-8";setGetDelay&"1000"&"[ms] delay between set and get"; diff --git a/script/tests/devices/bis-BME1/.config b/script/tests/devices/bis-BME1/.config index 577e049..a8d8e5c 100644 --- a/script/tests/devices/bis-BME1/.config +++ b/script/tests/devices/bis-BME1/.config @@ -1,5 +1,5 @@ -#Fri Oct 13 11:25:53 CEST 2017 +#Wed Oct 18 10:54:16 CEST 2017 name=bis-BME1 tests=RPS Tests Betriebsmode -parameters=channel&"PXXF\:VAL\:2"&"rps channel";mode&"2,IQCOM,$BME1,1,DIA"&"betriebsmode"; description=rps section till BMA1 +parameters=mode&"2,IQCOM,$BME1,1,DIA"&"betriebsmode";expectedVal14&"0x0000"&"[hex] Expected value for channels 1-4";expectedVal58&"0x0000"&"[hex] Expected value for channels 5-8"; diff --git a/script/tests/tests.properties b/script/tests/tests.properties index f85a64f..b2f1ca5 100644 --- a/script/tests/tests.properties +++ b/script/tests/tests.properties @@ -1,5 +1,5 @@ #TestingList for pshell: configuration properties -#Wed Oct 18 09:16:48 CEST 2017 +#Thu Oct 19 16:17:05 CEST 2017 customPanel= showEnabledTestsOnly=true listFilter=rps-test diff --git a/script/tests/tests/PS Tests/test without ioc/.config b/script/tests/tests/PS Tests/test without ioc/.config index 8a49b21..8d51818 100644 --- a/script/tests/tests/PS Tests/test without ioc/.config +++ b/script/tests/tests/PS Tests/test without ioc/.config @@ -1,4 +1,4 @@ -#Wed Sep 16 16&17&06 CEST 2015 +#Wed Sep 16 16"&"17"&"06 CEST 2015 name=test without ioc description=test that does not use any connection to IOC. It is useful to test pure pshell graphical features. -parameters=repeatTimes&3&how many times the test is repeated;howManySamples&50&How many samples are plotted;delayBetweenSampleS&0.05&delay [s] between two samples; +parameters=repeatTimes&"3"&"how many times the test is repeated";howManySamples&"50"&"How many samples are plotted";delayBetweenSampleS&"0.05"&"delay [s] between two samples"; diff --git a/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/.config b/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/.config index 9675194..390438b 100644 --- a/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/.config +++ b/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/.config @@ -1,4 +1,4 @@ #Mon Oct 16 14:28:18 CEST 2017 name=Betriebsmode description=Verify that the different RPS Modes give correct Outputs on the RPS modules -parameters=mode&"2,IQCOM,$BMA1,1,DIA"&"vla";channel&"PXXF\:VAL\:3"&"ssp";expectedVal14&"0x0000"&"[hex] Expected value for channels 1-4";expectedVal58&"0x0000"&"[hex] Expected value for channels 5-8";setGetDelay&"1000"&"[ms] delay between set and get"; +parameters=mode&"2,IQCOM,$BMA1,1,DIA"&"vla";rpsCh14&"J102003:REG:R:3"&"rps channel 1-4";rpsCh58&"J102003:REG:R:34"&"rps channel 5-8";expectedVal14&"0x0000"&"[hex] Expected value for channels 1-4";expectedVal58&"0x0000"&"[hex] Expected value for channels 5-8";setGetDelay&"1"&"[s] delay between set and get"; diff --git a/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/Betriebsmode.py b/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/Betriebsmode.py index ccaccd2..c950c51 100644 --- a/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/Betriebsmode.py +++ b/script/tests/tests/RPS Tests Betriebsmode/Betriebsmode/Betriebsmode.py @@ -1,4 +1,4 @@ -# Test name: Betriebsmode +# Test name: Betriebsmode (old caRPSTest test #1) # betriebsmode # Copyright (c) 2015 Paul Scherrer Institute. All rights reserved. @@ -62,18 +62,19 @@ def startTest(testName, DEVICE, params): test.log('text to log') """ - ########## Example (can be removed) ###### # print the list of parameters passed. If any error, stop and send feedback. - print("") - test.log("========================================================================") test.log("Test " + test.getName() + " for " + test.getDeviceName() ) try: test.log("Running test with the following parameters:") test.printParams() - # If present, use the parameters here below for your test script. - # These parameters were automatically generated: you might need to change the casting. - channel = (test.getParam('channel')) ; mode = (test.getParam('mode')) ; expectedVal14 = (test.getParam('expectedVal14')) ; expectedVal58 = (test.getParam('expectedVal58')) ; setGetDelay = (test.getParam('setGetDelay')) ; + # fetch paramenters + rpsChName14 = (test.getParam('rpsCh14')) + rpsChName58 = (test.getParam('rpsCh58')) + expectedVal14 = (test.getParam('expectedVal14')) + expectedVal58 = (test.getParam('expectedVal58')) + mode = (test.getParam('mode')) + setGetDelay = float(test.getParam('setGetDelay')) ; except: import traceback # test failed, write the report into the variables ret and success and send feedback: @@ -83,16 +84,53 @@ def startTest(testName, DEVICE, params): return # now try with data from real device: this part will most probably fail: correct the PV names with existing ones. + rpsMask14 = 0x4440 # mask for outputs 2-4 + rpsMask58 = 0x0004 # mask for output 5 + ilk = Interlock() + ilk.setInterlockMode(mode) + sleep(setGetDelay) + ilk.masterReset() + sleep(setGetDelay) + modeRead = ilk.getInterlockMode(); + if not modeRead: + ret = 'No mode received' + success = False + test.sendFeedback(ret, success) + return + try: + modePresent = modeRead.index(mode) + except: + modePresent = -1 + ret = 'Could not set mode ' + mode + success = False + test.sendFeedback(ret, success) + return try: - ilk = Interlock() - ilk.masterReset() - ilk.setInterlockMode(mode) # set up connection to channels. "type" of data can be "d" (= double), "l" (= long). - #rpsChannel = Channel(channel , type='d') + # outputs 1-4 + rpsCh14 = Channel(rpsChName14, type='d') + # outputs 5-8 + rpsCh58 = Channel(rpsChName58, type='d') + + rpsVal14 = rpsCh14.get() + rpsVal58 = rpsCh58.get() + + success = True + if ((rpsVal14 & rpsMask14) == expectedVal14): + ret = 'Interlocks outputs (1-4) of ' + rpsChName14 + ': ' + rpsVal14 + ' as expected' + else: + ret = 'Interlocks outputs (1-4) of ' + rpsChName14 + ': ' + rpsVal14 + ' was expected: ' + expectedVal14 + success = False + + if ((rpsVal58 & rpsMask58) == expectedVal58): + ret = ret + '\nInterlocks outputs (5-8) of ' + rpsChName58 + ': ' + rpsVal58 + ' as expected' + else: + ret = ret + '\nInterlocks outputs (5-8) of ' + rpsChName58 + ': ' + rpsVal58 + ' was expected: ' + expectedVal58 + success = False except: import traceback # prepare return information: return text: - ret = 'Unable to create channel - ' + traceback.format_exc() + ret = 'Unable to connect to channel - ' + traceback.format_exc() # prepare return information: return success: success = False # send return information: @@ -100,14 +138,10 @@ def startTest(testName, DEVICE, params): return # Closing channels: all channels that were opened with Channel() must be closed before exit: - #rpsChannel.close() + rpsCh14.close() + rpsCh58.close() - # IMPORTANT: if the test was successful, write the report into the variables ret and success. - # for example, write the following: - ret = "" - success = True # 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 ###### diff --git a/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/.config b/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/.config new file mode 100644 index 0000000..cb621ab --- /dev/null +++ b/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/.config @@ -0,0 +1,4 @@ +#Wed Oct 18 14:59:58 CEST 2017 +name=RPSlimits +parameters= +description=Verify that for different modes, the RPS behaves correctly when scanning the current settings of the Ablenkungsmagnet diff --git a/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/RPSlimits.py b/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/RPSlimits.py new file mode 100644 index 0000000..cbe8a8e --- /dev/null +++ b/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/RPSlimits.py @@ -0,0 +1,191 @@ +# Test name: Interlocklimits +# Interlock Limits for Ablenksmagnet +# 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 + # 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: + test = TestingTool(testName, testPath, DEVICE, params) + +################ END OF Init ##################### +######### WRITE YOUR CODE HERE BELOW ############# + + """ + All the code in this section # WRITE YOUR CODE HERE BELOW # is just an example and can be modified/deleted. + It must be indented to the same level as this comment. + ----------------------------------- + GETTING INPUTS: + ----------------------------------- + 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 setPlotTitle(). Example: scan.setPlotTitle(test.getPlotName()) + ----------------------------------- + GETTING TEST PARAMETERS: + ----------------------------------- + if you need to get parameters for the test, use: + + myParamValue = test.getParam('myParamName') + + 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) + + ret string, a text summarizing the result of the test. + success bool, True = test successful. False = test failed. + ----------------------------------- + LOG INFO: + ----------------------------------- + when some information must be shown on the log on pshell, use the following line: + test.log('text to log') + """ + + ########## Example (can be removed) ###### + + # print the list of parameters passed. If any error, stop and send feedback. + test.log("Test " + test.getName() + " for " + test.getDeviceName() ) + try: + test.log("Running test with the following parameters:") + test.printParams() + ret = 'aha!' + success = True + test.sendFeedback(ret, success) + return + # fetch parameters + mode = (test.getParam('mode')) + ilkInExpectedValS = (test.getParam('ilkInExpectedValS')) + magnetChName = (test.getParam('magnetCh')) + ilkInChName = (test.getParam('ilkInCh')) + ilkInExpectedValIni = (test.getParam('ilkInExpectedValIni')) + ilkOutExpectedValL = (test.getParam('ilkOutExpectedValL')) + magnetEndVal = int(test.getParam('magnetEndVal')) + ilkOutChName = (test.getParam('ilkOutCh')) + ilkOutExpectedValIni = (test.getParam('ilkOutExpectedValIni')) + ilkOutExpectedValS = (test.getParam('ilkOutExpectedValS')) + magnetInitVal = int(test.getParam('magnetInitVal')) + setGetDelay = float(test.getParam('setGetDelay')) + except: + import traceback + # test failed, write the report into the variables ret and success and send feedback: + ret = 'Could not retrieve testing parameters - ' + traceback.format_exc() + success = False + test.sendFeedback(ret, success) + return + + rpsMask14 = 0x4440 # mask for outputs 2-4 + rpsMask58 = 0x0004 # mask for output 5 + ilk = Interlock() + ilk.setInterlockMode(mode) + sleep(setGetDelay) + ilk.masterReset() + # loop to read channels for a while and plot the channels values. + # initialise plot tab with 3 plots: + scan = ManualScan(['units'], ['Magnet', 'Interlock-In', 'Interlock-Out']) + # set plot name(tab title): + scan.setPlotTitle(test.getPlotName()) + # start plots. See further below how to add points to the plots (scan): + scan.start() + # now try with data from real device: this part will most probably fail: correct the PV names with existing ones. + try: + # set up connection to channels. "type" of data can be "d" (= double), "l" (= long). + #magnetCh = Channel(magnetChName , type='d') + #ilkInCh = Channel(ilkInChName , type='d') + #ilkOutCh = Channel(ilkOutChName , type='d') + print magnetChName + except: + import traceback + # 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 + # check RPS status + #ilkInVal = ilkInCh.get() + #ilkOutVal = ilkOutCh.get() + ilkInVal = ilkInExpectedValIni #delete!! + ilkOutVal = ilkOutExpectedValIni #delete!! + if (ilkInVal == ilkInExpectedValIni): + test.log(ilkInChName + ' ok') + else: + ret = ilkInChName + ' wrong - expected: ' + ilkInExpectedValIni + ' got: ' + ilkInVal + success = False + return + if ((ilkOutVal & 0x000C) == ilkOutExpectedValIni): + test.log(ilkOutChName + ' ok') + else: + ret = ilkOutChName + ' wrong - expected: ' + ilkOutExpectedValIni + ' got: ' + (ilkOutVal & 0x000C) + success = False + return + + # start scan of magnet + # inject a sinus into the plot, as example + from math import sin + for sample in range(magnetInitVal, magnetEndVal, 10): + readback1 = sample #the x axis. + sleep(0.01) # settling time. + # get value (it is translated to a caget): + magnetVal = sample + # get value: + ilkInVal = sin(float(sample)/10.0)*10.0-10.0 + ilkOutVal = ilkInVal*0.5+10 + # add values to plot: + scan.append([readback1], [readback1], [magnetVal, ilkInVal, ilkOutVal]) + + #magnetCh.close() + #ilkInCh.close() + #ilkOutCh.close() + + ret = "Example - Test successful, here some detail: ..." + success = True + ################ 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. + import traceback + ret = 'Test stopped by user.' + success = False + test.sendFeedback(ret, success) + except: + # generic error handler. + import traceback + 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 #### +# Indent to end left +# def yourCustomFunction: diff --git a/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/help.html b/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/help.html new file mode 100644 index 0000000..c05d24a --- /dev/null +++ b/script/tests/tests/RPS Tests Interlocklilmits/RPSlimits/help.html @@ -0,0 +1,26 @@ + + +
+ilkInExpectedValS | [hex] Interlock Input expected value for small values of magnet |
magnetCh | Magnet epics channel |
ilkInCh | Interlock Input epics channel |
ilkInExpectedValIni | [hex] Interlock Input expected initial value |
ilkOutExpectedValL | [hex] Interlock Output expected value for large values of magnet |
magnetEndVal | [int] magnet final value for scan sequence |
ilkOutCh | Interlock Output epics channel |
ilkOutExpectedValIni | [hex] Interlock Output expected initial value |
ilkOutExpectedValS | [hex] Interlock Output expected value for small values of magnet |
magnetInitVal | [int] magnet initial value for scan sequence |
setGetDelay | [s] delay between set and get |