Industrial control system automatic test method and system based on script language

By designing an automatic testing method for industrial control systems based on scripting language, we solve the problems in the existing technology of complex test case writing, difficulty in covering all input combinations in manual testing, and low testing efficiency. We achieve an efficient and flexible testing process and improve testing efficiency. efficiency and coverage.

CN119336005AInactive Publication Date: 2025-01-21SHANGHAI PUDONG SOFTWARE PLATFORM CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411886162.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-01-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the testing of industrial control system, the existing technology has problems such as complex writing of test cases, difficulty in manual testing covering all input combinations, and inefficient testing.

Method used

An automatic test method for industrial control systems based on script language is designed, which is executed through the automated test system, including designing automatic test script language, writing test scripts, compiling scripts, executing tests and generating test reports. The script language supports basic statements and control statements, and can define functions such as input, output, looping, and conditional judgment.

Benefits of technology

Through this method, the difficulty of writing test scripts is significantly reduced, testing efficiency is improved, the test case writing process is simplified, testers' workload is reduced, and test coverage and adaptability are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336005A_ABST
    Figure CN119336005A_ABST
Patent Text Reader

Abstract

The invention provides a script language-based industrial control system automatic test method, which comprises the following steps of: compiling a compiled test script based on a design automatic test script language to generate a test case set; executing the test cases in the test case set, and generating result data by the tested control system; and the automatic test software compares the result data with the expected output data to generate a test report. The invention also provides an automatic test system. Through the self-defined test script, a tester can quickly compile the test script according to actual requirements without depending on complex tools and processes, so that the test efficiency can be improved, and the test method is easier to maintain and expand.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software testing. Background Art

[0002] In industrial control systems, when unexpected inputs appear in the industrial control system, unexpected outputs may occur, causing damage to industrial control equipment. Therefore, industrial control systems must be fully tested before being installed on industrial equipment. It is best to exhaust all combinations of inputs to test whether unexpected outputs will occur. Traditional testing methods usually rely on fixed test processes and complex test configurations, which have significant limitations in dealing with ever-changing production needs and diverse industrial control scenarios.

[0003] Traditional industrial control system testing is usually carried out manually or semi-automatically. Testers need to manually configure and operate the system to simulate various work scenarios according to the predetermined test process. This method is not only inefficient, but also prone to inaccurate test results due to human factors. In addition, as the complexity of industrial control systems increases, manual testing is difficult to cover all possible operation scenarios, which can easily lead to potential system vulnerabilities not being discovered in time.

[0004] Although the emergence of automated testing tools has improved testing efficiency to a certain extent, most existing automated testing tools rely on graphical interfaces or pre-set script templates, lacking flexibility and scalability. These tools can often only handle specific types of testing tasks and are difficult to adapt to the needs of complex industrial control systems. For example, when the system configuration changes, testers need to rewrite or modify a large number of test scripts, increasing the workload of test maintenance.

[0005] The automated testing method based on scripting language provides a new idea for solving the above problems. By introducing scripting language, testers can quickly write test scripts according to actual needs without relying on complex tools and processes. This method can significantly reduce the difficulty of writing test scripts, improve testing efficiency, and is easier to maintain and expand.

[0006] Although scripting languages ​​have been widely used in other fields, the development of related technologies in the automated testing of industrial control systems is still relatively lagging. At present, some industrial control system manufacturers have begun to try to use scripting languages ​​for testing, but due to the lack of unified standards and interfaces, most of these methods are in the experimental stage and have not yet formed a mature solution.

[0007] In addition, the application of existing scripting language-based testing methods in industrial control systems is often limited to simple functional testing, and it is difficult to achieve comprehensive testing of system stability, performance, etc. Therefore, it is urgent to develop a more complete scripting language-based industrial control system automatic testing method to improve the comprehensiveness and adaptability of the test. Summary of the invention

[0008] The present invention provides an automatic testing method for an industrial control system based on a scripting language, so as to solve the problems in the prior art that test cases are complicated to write, manual testing is difficult to cover all input combinations, and the testing efficiency is low.

[0009] In a first aspect, the present invention provides an automatic testing method for an industrial control system based on a scripting language, wherein the automatic testing method is executed based on an automatic testing system, wherein the automatic testing system comprises a computer, wherein automatic testing software is installed on the computer, wherein the computer is connected to an input / output interface simulator via a USB interface or an Ethernet interface, and an IO interface and a control bus of a control system under test are connected to the input / output interface simulator, wherein the automatic testing method comprises the following steps:

[0010] Step S1, designing automatic test script language:

[0011] The automatic test script language includes basic statements and control statements, the basic statements include input statements, expected output statements, setting statements, and comment statements, and the control statements include input set statements, bus input set statements, expected output set statements, bus expected output set statements, and loop statements;

[0012] Step S2, write a test script:

[0013] According to specific test requirements, write test scripts in the automatic testing software, define various input conditions and expected outputs through script writing, and then generate test cases;

[0014] Step S3, compile the test script:

[0015] In the automated testing system, compiling scripts to generate a test case set;

[0016] Step S4, perform the test:

[0017] The automated test system sequentially executes the test cases in the test case set, and sends the corresponding test instructions to the input-output interface simulator via a USB or network port; the input-output interface simulator sends a signal to the control system under test according to a timing sequence preset by the instruction; the input-output interface simulator regularly collects the output signal of the control system under test, and sends it to the automatic test software on the computer of the automated test system;

[0018] Step S5, result comparison and report generation:

[0019] The automated test system receives the output result data of the control system under test, and compares it with the expected output data of the control system under test. If the two match, the test passes; if not, the test fails; the test results are automatically written into the test report.

[0020] Furthermore, in step S4, the input-output interface simulator determines whether the input signal holding time of the test case has been reached; if the input signal holding time has not been reached, the output signal of the control system under test continues to be collected at regular intervals and sent to the automated testing system; if the input signal holding time has been reached, it is determined whether the test case set has been executed, and if there are still test cases that have not been executed, the next test case is executed; if the test case set has been executed, a test report is generated and the test is completed.

[0021] Furthermore, the input statement includes:

[0022] (1)KeepInTime = xx;

[0023] This statement is a hold time statement for inputting hold time assignment. Among them, xx is the hold time value, and its time unit is set in the InTimeUnit language name. When compiling the automatic test script language, if the hold time statement before the current KeepInTime statement is KeepOutTime, and the cumulative value of the previous KeepInTime is not equal to the cumulative value of KeepOutTime, the value of the KeepOutTime statement should be added with the difference, so that the cumulative value of KeepOutTime is equal to the cumulative value of KeepInTime.

[0024] (2) Kin(n)=b8b7b6b5b4b3b2b1;

[0025] This statement assigns values ​​to switch inputs. Eight switch inputs form a group, n is the group number, each group consists of 8 characters, each character represents one switch input, and the characters are limited to "0", "1", "r", and "f". "0" and "1" represent the state of the switch input. "r" is assigned 0 and 1 in sequence, and "f" is assigned 1 and 0 in sequence.

[0026] (3) Ain(n)=xx;

[0027] This statement assigns a value to analog input, n is the analog serial number, xx is the analog value, and xx can be expressed in three ways. The first is a specific value; the second is in the form of "[a,s,b)" or "[a,s,b]" or "(a,s,b)", which means that from a to b, all values ​​are listed with a step length of s, "[" means including a, "(" means not including a, "]" means including b, and ")" means not including b; the third is in the form of "p[a,s,b)" or "p[a,s,b]" or "p(a,s,b)", which means that from a to b, all values ​​are listed and arranged in a step length of s, "[" means including a, "(" means not including a, "]" means including b, and ")" means not including b.

[0028] (4) CanRx(n)=xx,...,xx;

[0029] This statement is the CAN bus input data, n is the CAN bus serial number, xx is the single-byte data;

[0030] (5) RS485Rx(n)=xx,...,xx;

[0031] This statement is the RS485 bus input data, n is the RS485 bus serial number, xx is the single-byte data.

[0032] Furthermore, the expected output statement includes:

[0033] (1)KeepOutTime = xx;

[0034] This statement assigns the expected output hold time and is a hold time statement; xx is the hold time value, and its time unit is set in the OutTimeUnit language name; when compiling the automatic test script language, if the current KeepOutTime statement is followed by a KeepInTime statement, and the current KeepOutTime cumulative value is not equal to the previous KeepInTime cumulative value, the value of the current KeepOutTime statement should be added to the difference, so that the KeepOutTime cumulative value is equal to the KeepInTime cumulative value;

[0035] (2)Kout(n)=b8b7b6b5b4b3b2b1;

[0036] This statement is the expected output value of the switch quantity. 8 expected outputs of the switch quantity form a group. n is the group number. Each group consists of 8 characters. Each character represents the expected output of 1 switch quantity. The characters are limited to "0", "1", and "x". "0" or "1" represents the expected output value of the switch quantity. x means that the actual output of the switch quantity "0" or "1" is in line with expectations.

[0037] (3) Aout(n)=yy;

[0038] This statement is the expected output value of the analog quantity, n is the analog quantity serial number, yy is the expected output value of the analog quantity, and yy has two ways of expression. The first is a specific value; the second is the character "x", which means that any value meets the expected output;

[0039] (4) CanTx(n)=yy,yy,...,yy;

[0040] CAN bus expected output data, n is the CAN bus serial number, yy is single-byte data, yy has two representations. The first is a specific value; the second is the character "x", indicating that any value meets the expected output;

[0041] (5) RS485Tx(n)=yy,yy,...,yy;

[0042] RS485 bus expected output data, n is the RS485 bus serial number, yy is single-byte data, yy has two representations. The first is a specific value; the second is the character "x", indicating that any value meets the expected output.

[0043] Furthermore, the setting statement includes:

[0044] (1) InTimeUnit = xx;

[0045] This statement is used to set the unit of input hold time. xx is the unit symbol, including "min", "s", "100ms", "10ms", "ms";

[0046] (2) OutTimeUnit = xx;

[0047] This statement is used to set the unit of the expected output holding time; xx is the unit symbol, including "min", "s", "100ms", "10ms", and "ms";

[0048] The comment statement includes:

[0049] The words after “ / / ” are comments.

[0050] Furthermore, the input set statement includes:

[0051] In (

[0053] KeepInTime = xx;

[0054] Kin(1)=b8b7b6b5b4b3b2b1;

[0055] Ain(1)=xx; ...... )

[0058] Assign all input combinations in order, and the holding time of each combination input is the holding time assigned in the set;

[0059] The bus input set statement includes:

[0060] BusRx (

[0062] CanRx(1)=xx,...,xx; ......

[0064] CanRx(n)=xx,...,xx;

[0065] RS485Rx(1)=xx,...,xx; ......

[0067] RS485Rx(n)=xx,...,xx; )

[0069] The above statement is the bus input collection statement block.

[0070] Furthermore, the expected output set statement includes:

[0071] Out (

[0073] KeepOutTime = xx;

[0074] Kout(1)=b8b7b6b5b4b3b2b1;

[0075] Aout(1)=yy; ...... )

[0078] Assign all expected outputs in sequence, and the output holding time is the holding time of the values ​​assigned in the set;

[0079] The bus expected output set statement includes:

[0080] BusTx (

[0082] CanTx(n)=xx,...,xx; ......

[0084] CanTx(n)=xx,...,xx;

[0085] RS485Tx(n)=xx,...,xx; ......

[0087] RS485Tx(n)=xx,...,xx; )

[0089] The above statements are the bus expected output collection statement block.

[0090] Furthermore, the loop statement includes:

[0091] EachIn (

[0093] KeepInTime = xx;

[0094] Kin(1)=b8b7b6b5b4b3b2b1;

[0095] Ain(1)=xx; ...... )

[0098] {

[0099] Out();

[0100] EachIn()

[0101] {

[0102] Out();

[0103] } ......

[0105] }

[0106] The inputs are assigned in sequence, and the input hold time is the hold time of the values ​​assigned in the EachIn collection. All input combinations are looped to assign the expected outputs in the {} statement block. Loop statements can be nested.

[0107] In a second aspect, the present invention provides an automatic testing system for an industrial control system based on a scripting language, the automatic testing system comprising: a memory, a processor, and one or more programs stored in the memory and executable on the processor, the one or more programs being configured to implement the automatic testing method as described above.

[0108] In a third aspect, the present invention provides a storage medium, characterized in that one or more programs are stored on the storage medium, and the one or more programs can be executed by one or more processors to implement the automatic testing method as described above.

[0109] The present invention proposes an automatic testing method for industrial control systems based on scripting languages, a corresponding system, and a storage medium. A general testing framework is constructed for industrial control systems, and a special automatic testing scripting language is designed, thereby solving the problems of insufficient testing flexibility and high maintenance difficulty in the prior art. The scripting language adopts simple basic statements and control statements, supports the definition of functions such as input, output, loop, and conditional judgment, and enables the test script to flexibly respond to different testing requirements. Using the automatic testing scripting language designed by the present invention, testers can write test scripts according to specific testing requirements, define various input conditions and expected outputs through simple script writing, and then generate test cases. By simplifying the writing process of test cases, the test cycle is greatly shortened, and the workload of testers is reduced. The method of the present invention can not only adapt to different types of testing requirements, but also dynamically adjust the test process and configuration through scripts, greatly improving the test efficiency and test coverage. BRIEF DESCRIPTION OF THE DRAWINGS

[0110] Other features, purposes and advantages of the embodiments of the present invention will become more apparent through the following detailed description of non-limiting embodiments in conjunction with the accompanying drawings. In the accompanying drawings:

[0111] Figure 1 An industrial control system automatic test system based on a scripting language according to an embodiment of the present invention is shown.

[0112] Figure 2 A schematic block diagram of the process of an automatic testing method for an industrial control system based on a scripting language according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0113] The present invention is further described below in conjunction with the embodiments, but it should not be understood that the above subject matter of the present invention is limited to the following embodiments; without departing from the above technical ideas of the present invention, various substitutions and changes are made according to the common technical knowledge and customary means in the field, which should be included in the protection scope of the present invention; it should also be noted that the embodiments and features in the embodiments of the present disclosure can be combined with each other without conflict. The embodiments of the present disclosure will be described in detail below with reference to the drawings and in conjunction with the embodiments.

[0114] like Figure 1As shown, an embodiment of the present application provides an automatic testing method for industrial control systems based on a scripting language to solve the problems in the prior art that test cases are complicated to write, manual testing is difficult to cover all input combinations, and testing efficiency is low. The automatic testing method for industrial control systems based on a scripting language of the present invention is executed based on an automated testing system, the automated testing system includes a computer, automatic testing software is installed on the computer, the computer is connected to an input-output interface simulator via a USB interface or an Ethernet interface, and the IO interface and control bus of the control system under test are connected to the input-output interface simulator.

[0115] like Figure 2 As shown, an automatic testing method for an industrial control system based on a scripting language provided in an embodiment of the present application specifically includes the following steps:

[0116] Step S1, designing automatic test script language:

[0117] In one or more embodiments, an automatic test script language is designed or defined for the control system under test, and the automatic test script language includes basic statements and control statements. The basic statements include one or more of input statements, expected output statements, setting statements, and comment statements. The control statements include one or more of input set statements, bus input set statements, expected output set statements, bus expected output set statements, and loop statements.

[0118] Step S2, write a test script:

[0119] According to specific test requirements, a test script is written in the automatic testing software, or a test script is written in other editing software. Through script writing, various input conditions and expected outputs are defined, and test cases are generated.

[0120] Step S3, compile the test script:

[0121] In the automated testing system, the test scripts are compiled to generate a test case set.

[0122] Step S4, perform the test:

[0123] The automated testing system sequentially executes the test cases in the test case set, and sends the corresponding test instructions to the input-output interface simulator via a USB or network port; the input-output interface simulator generates a preset timing sending signal according to the test instruction, and sends it to the control system under test; the control system under test executes the timing sending signal, and generates corresponding output result data; the input-output interface simulator periodically collects the output signal containing the output result data output by the control system under test, and sends it to the automatic testing software on the computer of the automated testing system.

[0124] In one or more embodiments, the input-output interface simulator determines whether the input signal holding time of the test case has been reached; if the input signal holding time has not been reached, the output signal of the control system under test continues to be collected at a regular interval and sent to the automated testing system; if the input signal holding time has been reached, it is determined whether all test cases in the test case set have been executed, and if there is at least one test case that has not been executed, the next test case is executed; if the test case set has been executed, the input-output interface simulator can send a notification signal to the automated testing system so that the automated testing system generates a test report.

[0125] Step S5, result comparison and report generation:

[0126] The automated testing system receives the output result data of the control system under test, and compares it with the expected output data of the control system under test; if the output result data of each test case matches the corresponding expected output result, the test passes; if the output result data of at least one test case does not match the corresponding expected output result, the test fails; the automated testing system automatically writes the test results into a test report to generate a test report.

[0127] In this embodiment, the automatic test software compares the output signal of the control system under test with the expected result, thereby determining whether its function is consistent with the expected result, thereby achieving the purpose of automatic testing. The automatic test software can achieve the purpose of regression testing by repeatedly executing the script.

[0128] In a specific embodiment, in order to improve the efficiency of test case writing, the automatic test script language designed or defined includes:

[0129] 1. Input statement:

[0130] (1)KeepInTime = xx;

[0131] This statement is a hold time statement for inputting hold time assignment. Among them, xx is the hold time value, and its time unit is set in the InTimeUnit statement. When compiling the automatic test script language, if the hold time statement before the current KeepInTime statement is KeepOutTime, and the cumulative value of the previous KeepInTime is not equal to the cumulative value of KeepOutTime, the value of the KeepOutTime statement should be added with the difference, so that the cumulative value of KeepOutTime is equal to the cumulative value of KeepInTime.

[0132] Function: Input state maintenance time, the next state can be input only when the time is up. In this way, only when the input changes, you need to write the corresponding input script, making the script more concise and efficient.

[0133] (2) Kin(n)=b8b7b6b5b4b3b2b1;

[0134] It is a switch input statement. 8 switch inputs are a group. n is the group number. Each group consists of 8 characters. Each character represents a switch input. The characters are limited to "0", "1", "r", and "f". "0" and "1" represent the switch input status. "r" is assigned 0 and 1 in sequence, and "f" is assigned 1 and 0 in sequence.

[0135] Function: Assign values ​​to the nth group of 8 switch inputs of the object under test. In other implementations, the nth group of 16, 32, etc., of multiple switch inputs of the object under test may be assigned values.

[0136] (3) Ain(n)=xx;

[0137] is an analog quantity input statement, n is the analog quantity serial number, xx is the analog quantity value, and xx has three representations. The first is a specific value; the second is in the form of "[a,s,b)" or "[a,s,b]" or "(a,s,b)", which means that from a to b, all values ​​are listed with a step length of s, "[" means including a, "(" means not including a, "]" means including b, and ")" means not including b; the third is in the form of "p[a,s,b)" or "p[a,s,b]" or "p(a,s,b)", which means that from a to b, all values ​​are listed and arranged in a step length of s, "[" means including a, "(" means not including a, "]" means including b, and ")" means not including b.

[0138] Function: Assign a value to the nth analog input of the object being measured.

[0139] (4) CanRx(n)=xx,...,xx;

[0140] This statement is the CAN bus input data, n is the CAN bus serial number, and xx is single-byte data.

[0141] Function: Send data to the nth CAN bus of the object under test.

[0142] (5) RS485Rx(n)=xx,...,xx;

[0143] This statement is the RS485 bus input data, n is the RS485 bus serial number, xx is the single-byte data.

[0144] Function: Send data to the nth group of RS485 bus of the object under test.

[0145] 2. Expected output statement:

[0146] (1)KeepOutTime = xx;

[0147] This statement assigns the expected output hold time and is a hold time statement. xx is the hold time value, and its time unit is set in the OutTimeUnit language name. When compiling the automatic test script language, if the current KeepOutTime statement is followed by a KeepInTime statement, and the current KeepOutTime cumulative value is not equal to the previous KeepInTime cumulative value, the value of the current KeepOutTime statement should be added to the difference, so that the current KeepOutTime cumulative value is equal to the previous KeepInTime cumulative value.

[0148] Function: Expected maintenance time of a certain output. When there may be multiple output states within the input maintenance time, multiple expected outputs can be listed and the maintenance time of each expected output can be specified.

[0149] (2)Kout(n)=b8b7b6b5b4b3b2b1;

[0150] This statement is the expected output value of the switch quantity. 8 expected outputs of the switch quantity form a group. n is the group number. Each group consists of 8 characters. Each character represents the expected output of 1 switch quantity. The characters are limited to "0", "1", and "x". "0" or "1" represents the expected output value of the switch quantity. x means that the actual output of the switch quantity "0" or "1" is in line with expectations.

[0151] Function: Assign values ​​to the expected output of the nth group of 8 switch quantities of the object under test.

[0152] (3) Aout(n)=yy;

[0153] This statement is the expected output value of the analog quantity, n is the analog quantity serial number, yy is the expected output value of the analog quantity, and yy has two ways of expression. The first is a specific value; the second is the character "x", which means that any value meets the expected output;

[0154] Function: Expected output of the nth analog quantity of the object under test.

[0155] (4) CanTx(n)=yy,yy,...,yy;

[0156] CAN bus expected output data, n is the CAN bus serial number, yy is single-byte data, yy has two representations. The first is a specific value; the second is the character "x", indicating that any value meets the expected output;

[0157] Function: The expected output data of the nth group of CAN bus of the object under test.

[0158] (5) RS485Tx(n)=yy,yy,...,yy;

[0159] RS485 bus expected output data, n is the RS485 bus serial number, yy is single-byte data, yy has two representations. The first is a specific value; the second is the character "x", indicating that any value meets the expected output.

[0160] Function: The expected output data of the nth group of RS485 bus of the measured object.

[0161] 3. Set the statement:

[0162] (1) InTimeUnit = xx;

[0163] This statement is used to set the unit of input hold time. xx is the unit symbol, which can be "min", "s", "100ms", "10ms", or "ms".

[0164] Function: Enter the unit of holding time. You can set different time units according to the real-time requirements of the object being measured, while meeting the real-time accuracy and keeping the script concise and easy to read.

[0165] (2) OutTimeUnit = xx;

[0166] This statement is used to set the unit of the expected output hold time. xx is the unit symbol, which can be "min", "s", "100ms", "10ms", or "ms".

[0167] Function: The unit of expected input holding time. Different time units can be set according to the real-time requirements of the object being measured, while meeting the real-time accuracy and keeping the script concise and easy to read.

[0168] 4. Comment statements:

[0169] The words after “ / / ” are comments.

[0170] 5. Enter the collection statement:

[0171] In (

[0173] KeepInTime = xx;

[0174] Kin(1)=b8b7b6b5b4b3b2b1;

[0175] Ain(1)=xx; ...... )

[0178] All input combinations are assigned in sequence, and the hold time of each combination input is the hold time assigned in the set.

[0179] Function: The input collection statement brings together all the various switch and analog inputs to make the script more concise and readable.

[0180] 6. Bus input collection statement:

[0181] BusRx (

[0183] CanRx(1)=xx,...,xx; ......

[0185] CanRx(n)=xx,...,xx;

[0186] RS485Rx(1)=xx,...,xx; ......

[0188] RS485Rx(n)=xx,...,xx; )

[0190] Bus input statement block.

[0191] Function: The bus input collection statement brings together all the various bus inputs to make the script more concise and readable.

[0192] 7. Expected output collection statement:

[0193] Out (

[0195] KeepOutTime = xx;

[0196] Kout(1)=b8b7b6b5b4b3b2b1;

[0197] Aout(1)=yy; ...... )

[0200] All expected output combinations are assigned in sequence, and the holding time of each combined output is the holding time assigned in the set.

[0201] Function: The expected output collection statement brings together all the expected outputs of various switch quantities and analog quantities, making the script more concise and readable.

[0202] 8. Bus expected output collection statement:

[0203] BusTx (

[0205] CanTx(n)=xx,...,xx; ......

[0207] CanTx(n)=xx,...,xx;

[0208] RS485Tx(n)=xx,...,xx; ......

[0210] RS485Tx(n)=xx,...,xx; )

[0212] The statement block of the expected output of the bus.

[0213] Function: The bus expected output collection statement brings together all the various bus expected outputs to make the script more concise and readable.

[0214] 9. Loop statement:

[0215] EachIn (

[0217] KeepInTime = xx;

[0218] Kin(1)=b8b7b6b5b4b3b2b1;

[0219] Ain(1)=xx; ...... )

[0222] {

[0223] Out();

[0224] EachIn()

[0225] {

[0226] Out();

[0227] } ......

[0229] }

[0230] All input combinations are assigned in order. The holding time of each combination input is the holding time assigned in the EachIn set. All input combinations are looped to assign the expected output in the {} statement block. Loop statements can be nested.

[0231] Function: Loop statements allow scripts to be combined flexibly, improving script writing efficiency.

[0232] In a specific embodiment, taking the washing machine controller test as an example, a test script is written, assuming that the switch input Kin(1) of the washing machine controller has (the sequence of the tested objects corresponds to the bits of the switch input, for example, the first bit of the switch input represents the power switch button, the second bit represents the wash button, and the fourth bit represents the stop button, etc.):

[0233] (1) Ki1: Power switch button

[0234] (2) Ki2: Washing button

[0235] (3) Ki3: Dehydration button

[0236] (4) Ki4: Stop button

[0237] Analog inputs are:

[0238] (1) Ain(1): water level

[0239] The switch output Kout(1) is (the sequence of the measured objects corresponds to the bits of the switch output. For example, the first bit of the switch output indicates power supply, the second bit indicates water addition, and the sixth bit indicates dehydration, etc.):

[0240] (1) Ko1: Power supply

[0241] (2) Ko2: Add water

[0242] (3) Ko3: Washing forward

[0243] (4) Ko4: Washing reversal

[0244] (5) Ko5: Drainage

[0245] (6) Ko6: Dehydration

[0246] The specific script is as follows:

[0247] InTimeUnit = 10ms; / / The pulse width of a key is usually in the hundreds of milliseconds level, so set it to 10ms OutTimeUnit = 10ms; In / / Turn on the power switch ( KeepInTime = 1; / / Set the input hold time to 1*10ms Kin(1)=r000 0000; / / Press the [Power] button, and the power button will output a rising edge pulse KeepInTime = 30; / / The power output remains high for 30*10ms Kin(1) = f000 0000; / / Release the [Power] button, and the power button will output a falling edge pulse KeepInTime = 30; / / Power on Ain(1) = 0x00; / / Water level is zero ) Out ( KeepOutTime = 34; / / (1+1+30+1+1=34)*10ms Kout(1) = 0000 00xx; / / Before releasing the [Power] button, the power switch is still in the off state KeepOutTime = r; / / The total output hold time should be equal to the total input hold time. r is the remaining hold time Kout(1) = 1000 00xx; / / Power on, expected output hold time = 30*10ms ) In / / Start washing ( KeepInTime = 1; / / Set the input hold time to 1*10ms Kin(1)=r000 0000; / / Press the [Wash] button, and the Wash button will output a rising edge pulse KeepInTime = 30; / / Washing output maintains high level for 30*10ms Kin(1) = f000 0000; / / Release the [Wash] button, and the Wash button will output a falling edge pulse KeepInTime = 30; / / Washing starts Ain(1) = 0x00; / / Water level is zero ) Out ( KeepOutTime = 34; / / (1+1+30+1+1=34)*10ms Kout(1) = 0000 00xx; / / Washing has not started before the [Wash] button is released KeepOutTime = r; / / The total output hold time should be equal to the total input hold time. r is the remaining hold time Kout(1) = 1000 00xx; / / Prepare to start adding water for washing, the motor is still stopped at this time ) EachIn / / Add water, the motor is reversed ( KeepInTime = 30; / / Add water in units of 30*10ms, and the water level will increase gradually Ain(1) = [0x00, 0x01, 0x80]; / / The water level increases from zero to 0x80, with a step size of 1 ) Out { Kout(1) = 1100 00xx; / / Step 1: Add water, the motor stops for 5 seconds Kout(1) = 1110 00xx; / / Step 2: Add water, the motor rotates forward for 5 seconds Kout(1) = 1100 00xx; / / Step 3: Add water, the motor stops for 5 seconds Kout(1) = 1101 00xx; / / Step 4: Add water, the motor reverses for 5 seconds, and returns to step 1... until the accumulated input time } EachIn / / Washing, motor forward and reverse ( KeepInTime = 30000; / / After adding water, wash for 30000*10ms=300s=5min ) Out { Kout(1) = 1000 00xx; / / Step 1: Stop the motor for 5 seconds Kout(1) = 1010 00xx; / / Step 2: The motor rotates forward for 5 seconds Kout(1) = 1000 00xx; / / Step 3: Stop the motor for 5 seconds Kout(1) = 1001 00xx; / / Step 4: The motor reverses for 5 seconds, and returns to step 1... until the accumulated input time } In / / drain ( KeepInTime = 30; / / Drainage is in units of 30*10ms, and the water level gradually decreases Ain(1) = [0x80, 0x01, 0x00]; / / The water level decreases from 0x80 to zero, with a step size of 1 ) Out ( Kout(1) = 1000 10xx; / / drain ) In / / Dehydration ( KeepInTime = 6000; / / After draining, dehydrate for 6000*10ms=60s=1min ) Out ( Kout(1) = 1000 11xx; / / Dehydration ) Kout(1) = 1000 00xx; / / After dehydration, turn off drainage and dehydration output

[0248] The present invention also discloses an automatic testing system for an industrial control system based on a scripting language, the automatic testing system comprising: a memory, a processor, and one or more programs stored in the memory and executable on the processor, the one or more programs being configured to implement the method described in an embodiment of the present invention.

[0249] The present invention further discloses a storage medium, on which one or more programs are stored. The one or more programs can be executed by one or more processors to implement the method described in the embodiment of the present invention.

[0250] The above description is only a preferred embodiment of the present invention and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present invention is not limited to the technical solutions formed by the specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the above features are replaced with (but not limited to) the technical features with similar functions disclosed in the embodiments of the present invention.

Claims

1. An automatic testing method for industrial control systems based on scripting language, characterized in that: The automatic testing method is performed based on an automatic testing system, the automatic testing system includes a computer, the automatic testing software is installed on the computer, the computer is connected to an input-output interface simulator via a USB interface or an Ethernet interface, and the control system under test is connected to the input-output interface simulator. The automatic testing method includes the following steps: Step S1, designing automatic test script language: The automatic test script language includes basic statements and control statements, the basic statements include one or more of input statements, expected output statements, setting statements, and comment statements, and the control statements include one or more of input set statements, bus input set statements, expected output set statements, bus expected output set statements, and loop statements; Step S2, write a test script: Write test scripts according to specific test requirements, define various input conditions and expected outputs through test script writing, and then generate test cases; Step S3, compile the test script: In the automated testing system, compiling test scripts to generate a test case set; Step S4, perform the test: The automated test system sequentially executes the test cases in the test case set, and sends the corresponding test instructions to the input-output interface simulator via a USB or network port; the input-output interface simulator generates a preset timing transmission signal according to the test instruction, and sends the timing transmission signal to the control system under test; the input-output interface simulator regularly collects the output signal containing the output result data output by the control system under test, and determines whether the input signal holding time of the test case has been reached; if the input signal holding time has not been reached, the output signal of the control system under test continues to be regularly collected, and the output signal is sent to the automated test system; Step S5, result comparison and report generation: The automated test system receives the output result data of the control system under test, and compares it with the expected output data of the control system under test. If the two match, the test passes; if not, the test fails; the test results are automatically written into the test report.

2. The method for automatic testing of industrial control systems based on scripting language according to claim 1, characterized in that: In step S4, the input-output interface simulator is used to determine whether the test case set has been executed when the input signal holding time is reached, and if there are test cases that have not been executed, the next test case is executed; If the test case set is executed, a test report is generated and the test is completed.

3. The method for automatic testing of industrial control systems based on scripting language according to claim 1, characterized in that: The input statement includes an input holding time corresponding to the object under test, and the input holding time has a time unit. The automated testing system performs compilation calculation based on the assignment of the input holding time and the corresponding time unit; the automated testing system is used to determine whether the previous compiled object of the current input holding time is the first expected output holding time. If so, the automated testing system also determines whether the first cumulative value of the previous input holding time up to the current input holding time is not equal to the second cumulative value up to the first expected output holding time. If so, the automated testing system adds the difference between the first cumulative value and the second cumulative value to the first expected output holding time to obtain a third cumulative value, so that the third cumulative value up to the first expected output holding time is equal to the first cumulative value of the previous input holding time up to the current input holding time; The input statement also includes a switch value input corresponding to the measured object, the switch value input includes one or more switch value values ​​having a first preset number, wherein the value of each switch value is one of "0", "1", "r", and "f", "0" and "1" represent the switch value input state, "r" is assigned values ​​of 0 and 1 in sequence, and "f" is assigned values ​​of 1 and 0 in sequence; The input statement also includes analog quantity input, the analog quantity input includes one or more analog quantities, the analog quantity is a specific value or a range value, wherein the range value includes a first value, a second value and a step size; The input statement also includes bus input data corresponding to the object under test, the bus input data includes first bus input data and second bus input data, and each bus input data includes one or more single-byte data.

4. The method for automatic testing of industrial control systems based on scripting language according to claim 1, characterized in that: The expected output statement includes an expected output holding time corresponding to the object under test, and the expected output holding time has a time unit. The automated testing system performs compilation calculation based on the assignment of the expected output holding time and the corresponding time unit; the automated testing system is used to determine whether the next compiled object after the current expected output holding time is the input holding time. If so, the automated testing system also determines whether the fourth cumulative value up to the current expected output holding time is not equal to the fifth cumulative value of the previous input holding time up to the current expected output holding time. If so, the automated testing system adds the difference between the fifth cumulative value and the fourth cumulative value to the current expected output holding time to obtain a sixth cumulative value, so that the sixth cumulative value up to the current expected output holding time is equal to the fourth cumulative value of the previous input holding time up to the current expected output holding time; The expected output statement also includes an expected output of the switch value corresponding to the measured object, and the switch value input includes one or more switch value values ​​having a second predicted number, wherein the value of each switch value is one of "0", "1", and "x", "0" or "1" represents the expected output value of the switch value, and x represents that the actual output of the switch value "0" or "1" is consistent with the expectation; The expected output statement also includes an expected analog output, wherein the expected analog output includes one or more analog quantities, wherein the analog quantity is a specific value or a first preset value, wherein the first preset value indicates that any value meets the expected output; The expected output statement also includes bus expected output data corresponding to the object under test, and the bus expected output data includes first bus expected output data and second bus expected output data. Each bus input data includes one or more data, and each data is a single-byte data or a second preset value, wherein the second preset value indicates that any value meets the expected output.

5. The method for automatic testing of industrial control systems based on scripting language according to claim 1, characterized in that: The setting statement includes a unit for setting the input holding time, and the unit for setting the input holding time is one of "min", "s", "100ms", "10ms" or "ms"; The setting statement also includes a unit for setting the expected output holding time; the unit for setting the expected output holding time includes one of "min", "s", "100ms", "10ms" or "ms"; The comment statement includes " / / " followed by the comment.

6. The method for automatic testing of industrial control systems based on scripting language according to claim 3 is characterized in that: The input set statement includes one or more input combinations of the input holding time, switch input, and analog input; The bus input set statement includes an input combination of one or more of the first bus input data and the second bus input data.

7. The method for automatic testing of industrial control systems based on scripting language according to claim 4 is characterized in that: The expected output set statement includes one or more input combinations of the expected output holding time, the expected output of the switch quantity, and the expected output of the analog quantity; The bus expected output set statement includes an input combination of one or more of the first bus expected output data and the second bus expected output data.

8. The method for automatic testing of industrial control systems based on scripting language according to claim 1, characterized in that: The loop statement includes a combination of one or more input statements and one or more expected output statements. The one or more input statements are used to determine the holding time of the combination and control the one or more expected output statements to be executed in a sequence loop. The loop statement can be nested.

9. An industrial control system automatic test system based on scripting language, characterized in that: The automatic testing system comprises: a memory, a processor, and one or more programs stored in the memory and executable on the processor, wherein the one or more programs are configured to implement the automatic testing method according to any one of claims 1 to 8.

10. A storage medium, characterized in that: One or more programs are stored on the storage medium, and the one or more programs can be executed by one or more processors to implement the automatic testing method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Improved test manager for industrial automation controllers

    CN107957712A

  • Industrial automatic test and control system

    CN112162921A

  • Configurable general IO test system based on Zynq

    CN214896581U

  • Methods and apparatus to manage testing of a process control system

    US20110054643A1

  • Testing framework for control devices

    WO2009105889A1