CN-117270453-B - Variable comparison method, device, equipment and medium of programmable logic controller
Abstract
The application discloses a variable comparison method of a programmable logic controller, which comprises the steps of obtaining current variable data of a current project of the programmable logic controller and comparison variable data of a comparison project when a variable comparison instruction is received, converting the current variable data into current table data and converting the comparison variable data into comparison table data, wherein the table structure of the current table data is consistent with the table structure of the comparison table data, comparing the current table data with the comparison table data, and determining the difference between the current table data and the comparison table data. The application solves the technical problem of weak applicability of the existing PLC variable comparison method.
Inventors
- WU XIANPEI
- ZHU HAIBO
- HE BIN
Assignees
- 深圳市汇川技术股份有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20231012
Claims (8)
- 1. A variable comparison method of a programmable logic controller, the variable comparison method of the programmable logic controller comprising: When a variable comparison instruction is received, current variable data of the current project of the programmable logic controller and comparison variable data of a comparison project are obtained; converting the current variable data into current table data and converting the comparison variable data into comparison table data, wherein the table structure of the current table data is consistent with the table structure of the comparison table data; Comparing the current table data with the comparison table data, determining a difference between the current table data and the comparison table data; the step of converting the current variable data into current table data and converting the comparison variable data into comparison table data, wherein the table structure of the current table data is consistent with the table structure of the comparison table data, comprises the following steps: Converting the current variable data into first tree structure data and converting the comparison variable data into second tree structure data, wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data; Converting the first tree structure data into the current table data and converting the second tree structure data into the comparison table data, wherein the table structure of the current table data is consistent with the table structure of the comparison table data; the step of converting the current variable data into first tree structure data and converting the comparison variable data into second tree structure data, wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data comprises the following steps: Converting the current variable data into first table data and converting the comparison variable data into second table data; Converting the first table data into third tree structure data, and converting the second table data into fourth tree structure data, wherein the table structure of the first table data corresponds to the tree structure of the third tree structure data, and the table structure of the second table data corresponds to the tree structure of the fourth tree structure data; And adjusting the tree structure of the fourth tree structure data to obtain the second tree structure data, wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data.
- 2. The method for comparing variables of a programmable logic controller according to claim 1, wherein the step of adjusting the tree structure of the third tree structure data to obtain the first tree structure data, and adjusting the tree structure of the fourth tree structure data to obtain the second tree structure data, wherein the tree structure of the first tree structure data is identical to the tree structure of the second tree structure data, comprises the steps of: Traversing tree nodes of the third tree structure data layer by layer, judging whether the tree nodes exist in the fourth tree structure data, inserting empty tree nodes at corresponding positions in the fourth tree structure data to obtain the second tree structure data if the tree nodes do not exist in the fourth tree structure data, and, Traversing tree nodes of the fourth tree structure data layer by layer, judging whether the tree nodes exist in the third tree structure data, and if the tree nodes do not exist in the third tree structure data, inserting empty tree nodes at corresponding positions in the third tree structure data to obtain the first tree structure data; wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data.
- 3. The method for comparing variables of a programmable logic controller according to claim 1, wherein the step of adjusting the tree structure of the third tree structure data to obtain the first tree structure data, and adjusting the tree structure of the fourth tree structure data to obtain the second tree structure data, wherein the tree structure of the first tree structure data is identical to the tree structure of the second tree structure data, comprises the steps of: Traversing tree nodes of the third tree structure data layer by layer, converting each layer of the tree nodes into a first text language, traversing tree nodes of the fourth tree structure data layer by layer, and converting each layer of the tree nodes into a second text language; Traversing the character string of the first text language, judging whether the character string exists in the second text language, if not, inserting an empty tree node in a corresponding position in the fourth tree structure data to obtain the second tree structure data, and Traversing the character strings of the second text language, judging whether the character strings exist in the first text language, and if the character strings do not exist in the first text language, inserting empty tree nodes at corresponding positions in the third tree structure data to obtain the first tree structure data; wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data.
- 4. The variable comparison method of a programmable logic controller according to claim 1, wherein the step of comparing the current table data with the comparison table data, determining a difference between the current table data and the comparison table data, comprises: Acquiring row attribute information of the same row of the current table data and the comparison table data, wherein the row attribute information comprises at least one of variable name, data type, initial value, power-down maintenance, network disclosure, annotation, soft element address and allocation address; Judging whether the row attribute information of the same row of the current table data is consistent with that of the comparison table data, and determining the difference between the current table data and the comparison table data.
- 5. The variable comparison method of a programmable logic controller according to claim 1, wherein the step of comparing the current table data with the comparison table data, and determining a difference between the current table data and the comparison table data further comprises: When a variable synchronization instruction is received, determining a difference row in the comparison table data, which is different from the current table data; judging whether the data of the difference line support synchronization or not; and when the data of the difference line supports synchronization, replacing the data of the same line as the difference line in the current table data with the data of the difference line.
- 6. A variable comparison device of a programmable logic controller, the variable comparison device of the programmable logic controller comprising: The acquisition module is used for acquiring current variable data of the current engineering of the programmable logic controller and comparison variable data of the comparison engineering when receiving a variable comparison instruction; The conversion module is used for converting the current variable data into current table data and converting the comparison variable data into comparison table data, wherein the table structure of the current table data is consistent with that of the comparison table data; converting the current variable data into first tree structure data and converting the comparison variable data into second tree structure data, wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data; the method comprises the steps of converting first tree structure data into current tree structure data, converting second tree structure data into comparison tree structure data, converting the current variable data into first tree structure data, converting the comparison variable data into second tree structure data, converting the first tree structure data into third tree structure data, and converting the second tree structure data into fourth tree structure data, wherein the first tree structure data corresponds to the third tree structure data, the second tree structure data corresponds to the fourth tree structure data, adjusting the third tree structure data to obtain the first tree structure data, and adjusting the fourth tree structure data to obtain the second tree structure data, wherein the first tree structure data corresponds to the second tree structure data; and the comparison module is used for comparing the current table data with the comparison table data and determining the difference between the current table data and the comparison table data.
- 7. A variable comparison device of a programmable logic controller, characterized in that the variable comparison device of a programmable logic controller comprises a memory, a processor and a variable comparison program of a programmable logic controller stored on the memory and executable on the processor, which variable comparison program of a programmable logic controller, when executed by the processor, implements the steps of the variable comparison method of a programmable logic controller according to any one of claims 1 to 5.
- 8. A computer-readable storage medium, on which a variable comparison program of a programmable logic controller is stored, which when executed by a processor implements the steps of the variable comparison method of a programmable logic controller according to any one of claims 1 to 5.
Description
Variable comparison method, device, equipment and medium of programmable logic controller Technical Field The present invention relates to the field of programmable logic controllers, and in particular, to a variable comparison method, apparatus, device and readable storage medium for a programmable logic controller. Background During the debugging of a PLC (Programmable Logic Controller ) several engineering versions may be generated, and for the debugger, it is necessary to check the difference between the two PLC engineering versions, and at this time, it is necessary to compare the two PLC engineering versions. The PLC engineering comparison is generally divided into three parts, namely variable comparison, program comparison and configuration comparison. The existing PLC variable comparison method converts a variable into a text language, and then compares the converted text language by a text comparison algorithm, such as LCS (The longest common subsequence, longest common subsequence) algorithm, to determine the difference of the variable between two PLC engineering versions. However, this variable comparison method requires that both the PLC and the upper computer support text language programming, but many PLCs currently do not support text language programming, resulting in poor applicability of the existing PLC variable comparison method. Disclosure of Invention The invention mainly aims to provide a variable comparison method, device, equipment and medium of a programmable logic controller, and aims to solve the technical problem that the existing PLC variable comparison method is weak in applicability. In order to achieve the above object, the present invention provides a variable comparison method of a programmable logic controller, the variable comparison method of the programmable logic controller comprising: When a variable comparison instruction is received, current variable data of the current project of the programmable logic controller and comparison variable data of a comparison project are obtained; converting the current variable data into current table data and converting the comparison variable data into comparison table data, wherein the table structure of the current table data is consistent with the table structure of the comparison table data; Comparing the current table data with the comparison table data, determining a difference between the current table data and the comparison table data. Optionally, the step of converting the current variable data into current table data and converting the comparison variable data into comparison table data, wherein a table structure of the current table data is consistent with a table structure of the comparison table data includes: Converting the current variable data into first tree structure data and converting the comparison variable data into second tree structure data, wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data; and converting the first tree structure data into the current table data and converting the second tree structure data into the comparison table data, wherein the table structure of the current table data is consistent with the table structure of the comparison table data. Optionally, the step of converting the current variable data into first tree structure data and converting the comparison variable data into second tree structure data, where a tree structure of the first tree structure data is consistent with a tree structure of the second tree structure data includes: Converting the current variable data into first table data and converting the comparison variable data into second table data; Converting the first table data into third tree structure data, and converting the second table data into fourth tree structure data, wherein the table structure of the first table data corresponds to the tree structure of the third tree structure data, and the table structure of the second table data corresponds to the tree structure of the fourth tree structure data; And adjusting the tree structure of the fourth tree structure data to obtain the second tree structure data, wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data. Optionally, the step of adjusting the tree structure of the third tree structure data to obtain the first tree structure data, and the step of adjusting the tree structure of the fourth tree structure data to obtain the second tree structure data, wherein the tree structure of the first tree structure data is consistent with the tree structure of the second tree structure data, comprises the steps of: Traversing tree nodes of the third tree structure data layer by layer, judging whether the tree nodes exist in the fourth tree structure data, inserting empty tree nodes at corresponding positions in the fourth tree structure data to obtain the s