Automatic testing method, system, equipment and medium for PLC (Programmable Logic Controller) program and PLC lower hardware

Through the automated testing system, the problems of low efficiency and high cost of traditional PLC testing methods are solved, and automated testing of PLC functions, performance and protocol consistency are realized, reducing time costs and improving testing efficiency.

CN119087898APending Publication Date: 2024-12-06ANHUI GREEN BOAT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310650524.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-04
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

Traditional PLC testing methods rely on real hardware and manual operations, resulting in high testing costs and low efficiency, especially in long-term stability testing.

Method used

Provide automatic testing methods for PLC programs and underlying hardware. Through the automated system, the written test cases are imported into the use case library, and the MODBUS protocol is used to communicate with the PLC program, automatically execute test cases, collect execution results and generate reports to realize the functions of PLC. , automated testing of performance and protocol consistency.

Benefits of technology

It realizes automation of PLC testing, reduces personnel time investment, improves testing efficiency, reduces time costs, can conduct unattended testing, automatically judges equipment functions and protocol consistency, counts performance data and outputs test reports.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119087898A_ABST
    Figure CN119087898A_ABST
Patent Text Reader

Abstract

The invention provides an automatic test method, system, equipment and medium for a PLC program and PLC lower hardware, and the method comprises the following steps: starting a debugging module of the PLC program, selecting screened PLC test cases from a case library by a software starting unit to form a test case list, and traversing the list to complete the execution of the test cases; automatic execution is started, and an execution result collection unit generates a pcap file by monitoring an externally exposed protocol point location of a PLC software layer and capturing an interactive network data packet; analyzing the pcap file so as to obtain all interactive modbus communication data packets; and finally, the report generation unit generates report results of the plc in stability, protocol consistency and performance. According to the method, the PLC is tested in the aspects of function, performance and protocol consistency in an automatic mode, and a tester only needs to maintain a test case, so that the time investment of the tester during long-time stable operation is effectively reduced, and the PLC testing efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of PLC program testing, and in particular to an automatic testing method, system, equipment and medium for a PLC program and PLC lower hardware. Background Art

[0002] PLC is a power line communication technology, which is widely used in computer networks, communications, smart furniture, medical and health care, mechanical automation and other industries. In recent years, with the continuous growth of bandwidth demand, broadband access technologies including ADSL and PLC technology have developed rapidly, especially PLC technology, which makes full use of the most popular power network resources, has fast construction speed and low investment, and can access the Internet at high speed through the laid power line without wiring. It has unparalleled advantages over other methods, so it has received widespread attention.

[0003] PLC testing includes protocol consistency testing, functional testing, performance testing, interoperability testing, stability testing, etc. The specific testing process is determined by the test system executing the corresponding test cases. Among them, in the traditional testing methods of protocol consistency, functional testing, and interoperability testing, real hardware devices are usually used to cooperate with the device to be tested and to perform tests manually. For example, to determine whether a device meets expectations during the execution of an action, it is necessary to build corresponding test equipment in the test environment, and to trigger the pre-installed hardware of the action. During the execution of the action, people use subjective judgment to determine whether the device function meets expectations and whether the protocol is consistent. Using the above method, the testing cost is high and the efficiency is relatively low. Once it involves long-term stability testing, the testing method has great limitations, resulting in low efficiency and high cost. Summary of the invention

[0004] The present invention aims to provide a method, system, device and medium for automatically testing a PLC program and PLC lower hardware to overcome the above problems or at least partially solve the above problems.

[0005] To achieve the above object, the technical solution of the present invention is specifically implemented as follows:

[0006] The present invention provides an automatic testing method for a PLC program and PLC lower hardware, comprising the following steps:

[0007] Import the written PLC test cases into the case library of the PLC automatic test system, and import the soft component definitions involved in the PLC software program into the soft component list;

[0008] Start the debugging module of the PLC program. The software startup unit will select the screened PLC test cases from the test case library to form a test case list, and complete the execution of the test cases by traversing the list;

[0009] Start the automatic execution. When each test case is executed, the execution result collection unit monitors the protocol points exposed by the PLC software layer, obtains the point status and records the time b, so as to monitor the test case execution results and the hardware execution results, and capture the interactive network data packets to produce pcap files;

[0010] After all use cases are executed, the pcap file is parsed to obtain all interactive modbus communication data packets;

[0011] Finally, the report generation unit combines the execution status of each use case and the execution time of the soft component to generate a report on the stability, protocol consistency and performance of the PLC.

[0012] As a further solution of the present invention, the prepared PLC test cases are logically associated with soft elements in the PLC software program.

[0013] As a further solution of the present invention, when the execution of the test case is completed by traversing the list, each time a test case is traversed, the software startup unit will send the test case to the element query unit, and query whether the element of the execution step exists through the query logic of the element query unit.

[0014] As a further solution of the present invention, when querying whether the element of the execution step exists through the query logic of the element query unit:

[0015] If the element exists, the element information is sent to the element control unit, which performs relevant UI operations such as clicking, sliding, and inputting. After the element operation is completed, the time a is recorded and sent to the PLC result collection unit for record and storage;

[0016] If the element does not exist, slide the view of the entire PLC program debugging module until the element is found;

[0017] If the object is still not found after the view slides, the failure of the use case execution is recorded, and the soft component information is marked and sent to the PLC result collection unit for record and storage.

[0018] As a further solution of the present invention, when the software startup unit sends the test case to the element query unit, the soft component information associated with the test steps in the test case is assembled into an xpath based on the xpath query logic of the element query unit.

[0019] As a further solution of the present invention, the execution result collection unit establishes a communication connection with the PLC logic controller based on the MODBUS communication protocol.

[0020] The automatic testing system for PLC program and PLC lower hardware is characterized in that it includes a PLC main testing module for automatically testing the PLC program, the PLC main testing module communicates with a PLC programming controller that can program the PLC program through the MODBUS protocol, and the PLC programming controller is communicatively connected with the PLC lower hardware through a power line.

[0021] As a further solution of the present invention, the PLC main test module includes a use case library, a soft element list, a software startup unit, an element control unit, an element query unit, an execution result collection unit and a report production unit;

[0022] The test case library is used to store the prepared PLC test cases;

[0023] The soft component list is used to store the software component definitions designed in the PLC program;

[0024] The software startup unit is used to start the debugging module of the PLC program and select the screened test cases from the test case library to form a test case list;

[0025] The element control unit is used for clicking, sliding, and inputting related UI operations;

[0026] The element query unit queries whether the element of the execution step exists through query logic;

[0027] The execution result collection unit is used to monitor the execution results of the test cases and the execution results of the hardware;

[0028] The report production unit generates a PLC report result based on the execution status of each use case and the execution time of the soft element.

[0029] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor;

[0030] Import the written PLC test cases into the case library of the PLC automatic test system, and import the soft component definitions involved in the PLC software program into the soft component list, where the execution steps in the written test cases will be logically associated with the soft components;

[0031] Start the debugging module of the PLC program, and after the debugging module of the PLC program is started, the software startup unit selects the screened test cases from the case library to form a test case list, and completes the execution of the test cases by traversing the list;

[0032] The report generation unit generates a report on the stability, protocol consistency and performance of the PLC based on the execution status of each use case and the execution time of the soft element.

[0033] A computer-readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor;

[0034] Import the written PLC test cases into the case library of the PLC automatic test system, and import the soft component definitions involved in the PLC software program into the soft component list, where the execution steps in the written test cases will be logically associated with the soft components;

[0035] Start the debugging module of the PLC program, and after the debugging module of the PLC program is started, the software startup unit selects the screened test cases from the case library to form a test case list, and completes the execution of the test cases by traversing the list;

[0036] The report generation unit generates a report on the stability, protocol consistency and performance of the PLC based on the execution status of each use case and the execution time of the soft element.

[0037] The present invention provides an automatic testing method, system, device and medium for PLC program and PLC lower hardware, and the beneficial effects are:

[0038] The PLC function, performance, and protocol consistency tests are carried out in an automated manner. Testers only need to maintain the test cases, which effectively reduces the time investment of personnel during long-term stable operation and greatly improves the efficiency of PLC testing.

[0039] It can realize unattended operation, and judge whether the action execution of hardware equipment meets expectations by automatically obtaining execution results, and automatically obtain protocols in the process to judge whether there are inconsistencies in the protocols. In addition, during the execution process, the execution time of hardware actions will be collected based on the protocol layer to realize performance statistics. After the test is completed, the corresponding test report will be automatically output according to the execution results of each use case. Testers only need to be responsible for the development and maintenance of test cases. Through this system, the time cost of PLC testing can be effectively reduced in terms of functional effectiveness, protocol consistency, and performance testing of PLC, as well as the testing efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0041] Figure 1 The figure is a flow chart of the method of the present invention.

[0042] Figure 2 It is a system block diagram of the present invention.

[0043] In the figure: 1. PLC main test module; 2. PLC programming controller; 3. PLC lower hardware. DETAILED DESCRIPTION

[0044] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0045] See also Figure 1 The automatic testing method of the PLC program and the PLC lower hardware provided by the embodiment of the present invention comprises the following steps:

[0046] Import the written PLC test cases into the case library of the PLC automatic test system, and import the soft component definitions involved in the PLC software program into the soft component list, where the execution steps in the written test cases will be logically associated with the soft components;

[0047] When starting the automatic execution, the software startup unit will first start the debugging module of the PLC program. After the debugging module of the PLC program is started, the software startup unit will select the screened test cases from the case library to form a test case list, and complete the execution of the test cases by traversing the list;

[0048] Each time a test case is traversed, the software startup unit sends the test case to the element query unit. Based on the xpath query logic of the element query unit, the soft component information associated with the test steps in the test case is assembled into an xpath, and the query logic of the element query unit is used to query whether the element of the execution step exists.

[0049] If the element exists, the element information is sent to the element control unit, and the element control unit performs related UI operations such as click, slide, and input. After the element operation is completed, the time a is recorded and sent to the PLC result collection unit for record and storage. If the element does not exist at this time, the view of the entire PLC program debugging module is slid until the element is found. If the view is still not found after sliding, the use case execution failure is recorded, the soft element information is marked, and it is sent to the PLC result collection unit for record and storage;

[0050] When starting the automatic execution, the execution result collection unit will also establish communication with the PLC logic controller based on MODBUS communication. When each test case is executed, it monitors the protocol points exposed by the PLC software layer, obtains the point status and records the time b, so as to monitor the test case execution results and the hardware execution results, and capture the interactive network data packets to produce pcap files;

[0051] After all use cases are executed, the pcap file is parsed to obtain all interactive modbus communication data packets. Finally, the report generation unit combines the execution status of each use case and the execution time of the soft components to generate a report on the stability, protocol consistency and performance of the PLC.

[0052] like Figure 2 As shown, the automatic testing system for PLC program and PLC lower hardware is characterized in that it includes a PLC main testing module 1 for automatically testing the PLC program, the PLC main testing module 1 communicates with a PLC programming controller 2 for programming the PLC program through the MODBUS protocol, and the PLC programming controller 2 is communicatively connected with the PLC lower hardware 3 through a power line.

[0053] The PLC main test module 1 includes a use case library, a soft element list, a software startup unit, an element control unit, an element query unit, an execution result collection unit and a report production unit;

[0054] The test case library is used to store the written PLC test cases;

[0055] The soft component list is used to store the software component definitions designed in the PLC program;

[0056] The software startup unit is used to start the debugging module of the PLC program and select the screened test cases from the test case library to form a test case list;

[0057] The element control unit is used for click, slide, and input related UI operations;

[0058] The element query unit queries whether the element of the execution step exists through query logic;

[0059] The execution result collection unit is used to monitor the execution results of test cases and hardware;

[0060] The report production unit generates PLC report results based on the execution status of each use case and the execution time of the soft element.

[0061] During use, the present invention realizes the testing of PLC functions, performance and protocol consistency in an automated manner. Testers only need to maintain test cases, which effectively reduces the time investment of personnel during long-term stable operation and greatly improves the efficiency of PLC testing.

[0062] It can realize unattended operation, and judge whether the action execution of hardware equipment meets expectations by automatically obtaining execution results, and automatically obtain protocols in the process to judge whether there are inconsistencies in the protocols. In addition, during the execution process, the execution time of hardware actions will be collected based on the protocol layer to realize performance statistics. After the test is completed, the corresponding test report will be automatically output according to the execution results of each use case. Testers only need to be responsible for the development and maintenance of test cases. Through this system, the time cost of PLC testing can be effectively reduced in terms of functional effectiveness, protocol consistency, and performance testing of PLC, as well as the testing efficiency can be improved.

[0063] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. The automatic testing method of PLC program and PLC lower hardware is characterized in that: The following steps are involved: Import the written PLC test cases into the case library of the PLC automatic test system, and import the soft component definitions involved in the PLC software program into the soft component list; Start the debugging module of the PLC program. The software startup unit will select the screened PLC test cases from the test case library to form a test case list, and complete the execution of the test cases by traversing the list; Start the automatic execution. When each test case is executed, the execution result collection unit monitors the protocol points exposed by the PLC software layer, obtains the point status and records the time b, so as to monitor the test case execution results and the hardware execution results, and capture the interactive network data packets to produce pcap files; After all use cases are executed, the pcap file is parsed to obtain all interactive modbus communication data packets; Finally, the report generation unit combines the execution status of each use case and the execution time of the soft component to generate a report on the stability, protocol consistency and performance of the PLC.

2. The automatic testing method for PLC program and PLC lower hardware according to claim 1, characterized in that: The written PLC test cases will be logically associated with the soft elements in the PLC software program.

3. The automatic testing method for PLC program and PLC lower hardware according to claim 1, characterized in that: When the test cases are executed by traversing the list, each time a test case is traversed, the software startup unit sends the test case to the element query unit, and queries whether the element of the execution step exists through the query logic of the element query unit.

4. The automatic testing method for PLC program and PLC lower hardware according to claim 3, characterized in that: When querying whether the element of the execution step exists through the query logic of the element query unit: If the element exists, the element information is sent to the element control unit, which performs relevant UI operations such as clicking, sliding, and inputting. After the element operation is completed, the time a is recorded and sent to the PLC result collection unit for record and storage; If the element does not exist, slide the view of the entire PLC program debugging module until the element is found; If the object is still not found after the view slides, the failure of the use case execution is recorded, and the soft component information is marked and sent to the PLC result collection unit for record and storage.

5. The automatic testing method for PLC program and PLC lower hardware according to claim 3, characterized in that: When the software startup unit sends the test case to the element query unit, the soft component information associated with the test steps in the test case is assembled into an xpath based on the xpath query logic of the element query unit.

6. The automatic testing method for PLC program and PLC lower hardware according to claim 1, characterized in that: The execution result collection unit establishes a communication connection with the PLC logic controller based on the MODBUS communication protocol.

7. Automatic testing system for PLC program and PLC lower hardware, characterized by: The invention comprises a PLC main test module (1) for automatically testing a PLC program. The PLC main test module (1) communicates with a PLC programming controller (2) for programming the PLC program via a MODBUS protocol. The PLC programming controller (2) is connected to communicate with PLC lower hardware (3) via a power line.

8. The automatic testing system for PLC program and PLC lower hardware according to claim 7, characterized in that: The PLC main test module (1) includes a use case library, a soft element list, a software startup unit, an element control unit, an element query unit, an execution result collection unit and a report production unit; The test case library is used to store the prepared PLC test cases; The soft component list is used to store the software component definitions designed in the PLC program; The software startup unit is used to start the debugging module of the PLC program and select the screened test cases from the test case library to form a test case list; The element control unit is used for clicking, sliding, and inputting related UI operations; The element query unit queries whether the element of the execution step exists through query logic; The execution result collection unit is used to monitor the execution results of the test cases and the execution results of the hardware; The report production unit generates a PLC report result based on the execution status of each use case and the execution time of the soft element.

9. A computer device comprising a memory and a processor, characterized in that: The memory stores computer-readable instructions, which, when executed by the processor, implement the method as described in any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.