A method and system for comparing ladder program

Through ladder diagram loop recognition, coding processing and multiple comparison algorithms, the problems of low efficiency and poor accuracy in ladder diagram control program comparison are solved, and efficient and accurate ladder diagram control program iterative upgrade support is achieved.

CN117666459BActive Publication Date: 2025-10-10WUXI XINJIE ELECTRICAL
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311651476.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-05
Publication Date
2025-10-10
Estimated Expiration
2043-12-05

AI Technical Summary

Technical Problem

The existing ladder diagram control program comparison method has complex algorithms, low efficiency and poor accuracy. It is unable to quickly and accurately identify similarities and differences, affecting the efficiency and reliability of electrical engineers' iterative upgrades of automation equipment.

Method used

The method of ladder diagram circuit recognition, coding processing, multiple comparison algorithm and result proofreading is adopted. By constructing a tree data structure, a hybrid dynamic programming algorithm and a weighted algorithm, the nodes and circuits of the ladder diagram control program are gradually compared to generate the final comparison result.

Benefits of technology

Improves the accuracy and efficiency of ladder diagram control program comparison, provides clear and intuitive visualization results, and helps electrical engineers better perform iterative upgrades.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117666459B_ABST
    Figure CN117666459B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of software upgrading, and particularly relates to a comparison method and system for ladder diagram control programs, which comprises a ladder diagram loop identification module, a ladder diagram loop node coding module, a ladder diagram loop comparison module, a comparison algorithm module and a comparison result proofreading module, and the program similarities and differences are obtained through ladder diagram loop identification, coding processing, secondary coding processing, first comparison algorithm comparison, second comparison algorithm comparison, integrated comparison information acquisition, third comparison algorithm comparison, comparison result integration and comparison result proofreading. The present application can quickly and accurately compare different ladder diagram control programs with each other, confirm the similarities and differences, and help electrical engineers better handle the requirements for iterative upgrading of ladder diagram control programs.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of software upgrading, and in particular to a comparison method and system for ladder diagram control programs. BACKGROUND

[0002] With the development and upgrading of the national industry, manufacturers have increasingly high demand for industrial automation. At the same time, the manufacturers' own industrial upgrading requires iteration and upgrading of the original automation equipment and production lines. In the process of iteration and upgrading of the automation equipment and production lines, electrical engineers need to adjust, optimize and upgrade the control programs of the original automation equipment and production lines to meet the needs of the manufacturers' industrial upgrading. In the process of iteration and upgrading of the control programs, electrical engineers need to master and understand the modification points of the control programs in order to better ensure the reliability and stability of the control programs.

[0003] Ladder diagram, as a programming language for programmable controllers that is easy for electrical engineers to understand, is widely used in the fields of industrial control and automation. In the process of iteration and upgrading of the ladder diagram control programs by electrical engineers, it is necessary to understand the similarities and differences between the current iteration and update of the ladder diagram control programs and the original ladder diagram control programs in order to facilitate the iteration and upgrading of the ladder diagram control programs. By comparing different ladder diagram control programs, electrical engineers can intuitively understand the similarities and differences between different ladder diagram control programs.

[0004] However, the existing method for comparing the similarities and differences between the ladder diagram control programs and the original ladder diagram control programs is not only complex and inefficient, but also inaccurate, and cannot quickly and accurately find the similarities and differences.

[0005] Therefore, based on the above needs, a new technical solution is needed to compare different ladder diagram control programs, identify similarities and differences, and help electrical engineers better handle the needs of iteration and upgrading of the ladder diagram control programs. SUMMARY

[0006] The present application aims to overcome the problems of the prior art and provide a comparison method and system for ladder diagram control programs to solve the technical problem that the prior art cannot quickly and accurately find the similarities and differences between the ladder diagram control programs and the original ladder diagram control programs.

[0007] The above object is achieved by the following technical solution:

[0008] A comparison method for ladder diagram control programs, comprising:

[0009] S1 identifies the ladder diagram loop of the ladder diagram control program to obtain the ladder diagram loop of the ordinary node and the ladder diagram loop of the non-ordinary node;

[0010] S2 performs encoding processing on the ladder diagram loops of the common nodes and the ladder diagram loops of the non-common nodes to obtain a ladder diagram loop encoding table of the common nodes and a ladder diagram loop encoding table of the non-common nodes;

[0011] S3 performs secondary encoding processing on the ladder diagram loop coding table of the common node to obtain a secondary encoded coding table of the ladder diagram loop of the common node;

[0012] S4 performs a first comparison algorithm comparison on the coding table after the secondary coding of the ladder diagram loop of the common node to obtain a first comparison result of the ladder diagram loop of the common node;

[0013] S5 performs a second comparison algorithm on the first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the common node, and the ladder diagram loop of the common node to obtain a second comparison result of the ladder diagram loop of the common node;

[0014] S6 integrates the first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the non-common node, the ladder diagram loop of the non-common node, the ladder diagram loop of the common node, and the ladder diagram control program, and obtains comparison information to obtain the coding table required for the third comparison;

[0015] S7 performs a third comparison algorithm comparison on the coding table required for the third comparison to obtain a comparison result of the ladder diagram loop of the non-ordinary node;

[0016] S8 integrates the comparison results of the ladder diagram loops of the non-common nodes, the second comparison results of the ladder diagram loops of the common nodes, the first comparison results of the ladder diagram loops of the common nodes, the ladder diagram loops of the non-common nodes, the ladder diagram loops of the common nodes, and the ladder diagram control program to obtain a preliminary integrated comparison result of the ladder diagram control program;

[0017] S9 verifies the comparison result of the preliminarily integrated ladder diagram control program to obtain a final comparison result of the ladder diagram control program.

[0018] Furthermore, the step S1 of performing ladder diagram circuit identification on the ladder diagram control program is specifically as follows: the ladder diagram control program includes common nodes and non-common nodes;

[0019] For common nodes, a tree data structure list with AND or OR logical relationships is constructed based on the structural connection relationship between the ladder diagram nodes;

[0020] For non-ordinary nodes, they are only processed as an independent ladder diagram loop and are not included in the tree data structure list.

[0021] Furthermore, the non-ordinary nodes include label nodes and line comment nodes.

[0022] Furthermore, the information in the tree data structure list includes instruction identifiers, instruction operands, instruction node types, upper and lower connection line relationships of instruction nodes, instruction comments, and instruction operand comments.

[0023] Furthermore, the first comparison algorithm described in step S4, the second comparison algorithm described in step S5, and the third comparison algorithm described in step S7 are an algorithm that mixes two classic dynamic programming algorithms: the longest common subsequence algorithm and the shortest edit path algorithm, and balances the longest common subsequence algorithm and the shortest edit path algorithm through a weighted algorithm.

[0024] Furthermore, in step S6, the ladder diagram loops of common nodes are preferentially integrated and compared, and the ladder diagram loops of non-common nodes are processed later.

[0025] Furthermore, in step S8, ladder diagram loops of common nodes are preferentially compared and then integrated, while ladder diagram loops of non-common nodes are processed later.

[0026] A comparison system for ladder diagram control programs, comprising:

[0027] A ladder diagram circuit recognition module, wherein the ladder diagram circuit recognition module is used to perform ladder diagram circuit recognition on an input ladder diagram control program, and output ladder diagram circuits of common nodes and ladder diagram circuits of non-common nodes;

[0028] A ladder diagram loop node encoding module, the ladder diagram loop node encoding module is used to encode the input ladder diagram loops of the common nodes and the ladder diagram loops of the non-common nodes, and output a ladder diagram loop encoding table of the common nodes and a ladder diagram loop encoding table of the non-common nodes; and perform secondary encoding on the input ladder diagram loop encoding table of the common nodes, and output a secondary encoded encoding table of the ladder diagram loop of the common nodes;

[0029] A ladder diagram circuit comparison module, the ladder diagram circuit comparison module is used to perform a first comparison algorithm comparison on the coding table after the secondary coding of the input ladder diagram circuit of the common node, and output the first comparison result of the ladder diagram circuit of the common node;

[0030] Performing a second comparison algorithm comparison on the input first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the common node, and the ladder diagram loop of the common node, and outputting the second comparison result of the ladder diagram loop of the common node;

[0031] Integrate the first comparison result of the input ladder diagram loop of the common node, the ladder diagram loop coding table of the non-common node, the ladder diagram loop of the non-common node, the ladder diagram loop of the common node and the ladder diagram control program to obtain comparison information, and output the coding table required for the third comparison;

[0032] Performing a third comparison algorithm comparison on the input coding table required for the third comparison, and outputting a comparison result of the ladder diagram loop of the non-ordinary node;

[0033] and integrating the comparison results of the input ladder diagram loops of the non-ordinary nodes, the second comparison results of the ladder diagram loops of the ordinary nodes, the first comparison results of the ladder diagram loops of the ordinary nodes, the ladder diagram loops of the non-ordinary nodes, the ladder diagram loops of the ordinary nodes, and the ladder diagram control program, and outputting a preliminary integrated comparison result of the ladder diagram control program;

[0034] A comparison result checking module is used to check the comparison result of the input preliminary integrated ladder diagram control program and output a final comparison result of the ladder diagram control program.

[0035] Furthermore, the first comparison algorithm comparison, the second comparison algorithm comparison and the third comparison algorithm comparison are all completed by a comparison algorithm module.

[0036] Beneficial effects

[0037] The present invention provides a method and system for comparing ladder diagram control programs, which facilitates electrical engineers to compare different ladder diagram control programs, identify similarities and differences, and thus perform better iterative upgrades of the ladder diagram control programs. It also has the following advantages:

[0038] 1. Encode the ladder diagram node comparison information to effectively reduce the amount of information that the comparison algorithm needs to process and improve performance;

[0039] 2. By adding a weighted algorithm to the comparison algorithm, we can effectively balance the two dynamic programming algorithms, the longest common subsequence algorithm and the shortest edit path algorithm, improve the execution efficiency of the comparison algorithm, and obtain the optimal comparison result;

[0040] 3. By disassembling and integrating the ladder diagram control program according to the ladder diagram loop information and performing multiple comparisons, the accuracy and rationality of the ladder diagram control program comparison results are improved;

[0041] 4. By proofreading the comparison results, a visualization effect that is more in line with the graphical language used by electrical engineers is achieved, clearly, accurately and intuitively displaying the differences between different ladder diagrams, and improving the usability of the function. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 A flowchart of a method for comparing ladder diagram control programs according to the present invention;

[0043] Figure 2 A comparative system module diagram of a ladder diagram control program according to the present invention;

[0044] Figure 3 A schematic diagram of a first embodiment of the operation of a graphic loop identification module in a ladder diagram control program comparison method according to the present invention;

[0045] Figure 4 A schematic diagram of a second embodiment of the operation of a graphic loop identification module in a ladder diagram control program comparison method according to the present invention;

[0046] Figure 5 The present invention provides a schematic diagram of the comparison results of ladder diagram circuits in a ladder diagram control program comparison method. DETAILED DESCRIPTION

[0047] The present invention will be further described in detail below with reference to the accompanying drawings and examples. The described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort shall fall within the scope of protection of the present invention.

[0048] like Figure 1 As shown, this solution provides a ladder diagram control program comparison method, which facilitates electrical engineers to compare different ladder diagram control programs, obtain similarities and differences, and thus better iteratively upgrade the ladder diagram control program. The method includes the following steps:

[0049] Step S1 performs ladder diagram circuit identification on the ladder diagram control program to obtain ladder diagram circuits of common nodes and ladder diagram circuits of non-common nodes;

[0050] Step S2 performs encoding processing on the ladder diagram loops of the common nodes and the ladder diagram loops of the non-common nodes to obtain a ladder diagram loop encoding table of the common nodes and a ladder diagram loop encoding table of the non-common nodes;

[0051] Step S3 performs secondary encoding processing on the ladder diagram loop coding table of the common node to obtain a secondary encoded coding table of the ladder diagram loop of the common node;

[0052] Step S4 performs a first comparison algorithm comparison on the coding table after the secondary coding of the ladder diagram loop of the common node to obtain a first comparison result of the ladder diagram loop of the common node;

[0053] Step S5 performs a second comparison algorithm on the first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the common node, and the ladder diagram loop of the common node to obtain a second comparison result of the ladder diagram loop of the common node;

[0054] Step S6 integrates the first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the non-common node, the ladder diagram loop of the non-common node, the ladder diagram loop of the common node, and the ladder diagram control program, and obtains comparison information to obtain the coding table required for the third comparison;

[0055] Step S7: performing a third comparison algorithm comparison on the coding table required for the third comparison to obtain a comparison result of the ladder diagram loop of the non-ordinary node;

[0056] Step S8 integrates the comparison results of the ladder diagram loops of the non-common nodes, the second comparison results of the ladder diagram loops of the common nodes, the first comparison results of the ladder diagram loops of the common nodes, the ladder diagram loops of the non-common nodes, the ladder diagram loops of the common nodes, and the ladder diagram control program to obtain a preliminary integrated comparison result of the ladder diagram control program.

[0057] Step S9 verifies the comparison result of the preliminarily integrated ladder diagram control program to obtain a final comparison result of the ladder diagram control program.

[0058] It should be noted that the ladder diagram control program is identified as a ladder diagram loop in step S1 of this embodiment, specifically: the ladder diagram control program includes common nodes and non-common nodes;

[0059] For common nodes, a tree data structure list with AND or OR logical relationships is constructed based on the structural connection relationship between the ladder diagram nodes;

[0060] For non-ordinary nodes, they are only processed as an independent ladder diagram loop and are not included in the tree data structure list.

[0061] The non-ordinary nodes include label nodes, line comment nodes, etc.

[0062] The information in the tree data structure list includes instruction identifiers, instruction operands, instruction node types, upper and lower connection line relationships of instruction nodes, instruction comments, instruction operand comments, and the like.

[0063] In addition, the first comparison algorithm described in step S4, the second comparison algorithm described in step S5, and the third comparison algorithm described in step S7 are an algorithm that mixes two classic dynamic programming algorithms: the longest common subsequence algorithm and the shortest edit path algorithm, and balances the longest common subsequence algorithm and the shortest edit path algorithm through a weighted algorithm.

[0064] The weighted algorithm can ensure that the comparison results remain consistent when the comparison contents in the comparison source and the comparison object are exchanged.

[0065] By using the comparison algorithm, the similarities and differences between the comparison source and the comparison object can be obtained.

[0066] In step S6, the ladder diagram circuits of common nodes are prioritized for integration and comparison, and the ladder diagram circuits of non-common nodes are processed later. If the ladder diagram circuits of non-common nodes such as label node circuits and line comment circuits are integrated and processed together with the common node circuits, there will be subjective differences;

[0067] In step S8, the ladder diagram loops of common nodes are compared and integrated first, and the ladder diagram loops of non-common nodes are processed later. If the ladder diagram loops of common nodes are not processed first, there will be differences with the subjective logic.

[0068] like Figure 2 As shown, the present solution also provides a ladder diagram control program comparison system for implementing the above-mentioned ladder diagram control program comparison method. The system includes: a ladder diagram loop identification module, a ladder diagram loop node encoding module, a ladder diagram loop comparison module, a comparison algorithm module, and a comparison result verification module. The modules complement each other and collaborate efficiently to achieve a comprehensive comparison of the ladder diagram control program. Among them:

[0069] The ladder diagram loop recognition module is used to scan and analyze the ladder diagram control program of two-dimensional matrix independent nodes to obtain a plurality of tree data structures with AND or OR logical relationships, where one tree data structure corresponds to one ladder diagram loop;

[0070] Specifically, the ladder diagram loop recognition module scans and analyzes the ladder diagram control program of two-dimensional matrix independent nodes, which mainly include ladder diagram nodes such as common nodes, label nodes, and line comment nodes.

[0071] If a common node is scanned, a tree data structure consisting of AND or logical relationships is constructed based on the structural connection relationship between the ladder diagram nodes;

[0072] If ladder diagram nodes such as label nodes and line comment nodes are scanned, they are not processed into a tree data structure with logical relationships.

[0073] By scanning and parsing a ladder diagram control program with independent nodes in a two-dimensional matrix format, multiple tree-like data structures with AND or OR logical relationships are obtained. Each tree-like data structure corresponds to a ladder diagram loop. Using this tree-like data structure, the ladder diagram control program with independent nodes in a two-dimensional matrix format is disassembled, providing a basis for the logical execution of subsequent modules.

[0074] The ladder diagram loop node encoding module is used to encode the ladder diagram node comparison information in the ladder diagram control program of the two-dimensional matrix independent nodes, and provide the encoding information to the subsequent module call;

[0075] Specifically, the ladder diagram loop node encoding module is mainly responsible for encoding the ladder diagram node comparison information in the ladder diagram control program of the two-dimensional matrix independent node, and providing the encoding information to the subsequent modules to provide a basis for the logic execution of the subsequent modules.

[0076] By extracting ladder diagram node information, the information required for ladder diagram node comparison is integrated to form the basic information required for encoding.

[0077] By encoding basic information through a coding algorithm, the amount of information required for ladder diagram node comparison can be reduced. Without affecting the execution results of the comparison algorithm, the amount of information that the comparison algorithm needs to process can be reduced, the logical processing speed of the comparison algorithm can be accelerated, and the overall performance can be improved.

[0078] The ladder diagram loop comparison module is used to compare and process the ladder diagram control program of the two-dimensional matrix independent nodes according to the ladder diagram loop information, and perform multiple comparisons on the ladder diagram control program according to a certain execution logic, so as to obtain a ladder diagram comparison result that is reasonable and accurate;

[0079] Specifically, the ladder diagram loop comparison module will compare and process the ladder diagram control programs of two-dimensional matrix independent nodes based on the ladder diagram loop information, and perform multiple comparisons on the ladder diagram control programs according to a certain execution logic, so as to obtain a more reasonable and accurate ladder diagram comparison result.

[0080] The comparison algorithm module is used to compare the encoded ladder diagram loop nodes;

[0081] Specifically, the comparison algorithm in the comparison algorithm module is an algorithm that mixes two classic dynamic programming algorithms: the longest common subsequence algorithm and the shortest edit path algorithm, and balances the longest common subsequence algorithm and the shortest edit path algorithm through a weighted algorithm.

[0082] The weighted algorithm can ensure that the comparison results remain consistent when the comparison contents in the comparison source and the comparison object are exchanged.

[0083] The similarities and differences between the comparison source and the comparison object are obtained through the comparison algorithm.

[0084] The comparison result proofreading module is used to proofread the comparison result;

[0085] Specifically, as a graphical language, the ladder diagram has a structural connection relationship between the ladder diagram nodes, and there are ladder diagram nodes of the empty node type.

[0086] When the comparison algorithm is operating, the data is based on the codes of the ladder diagram nodes. If there is a difference between the two codes, they will be marked as 'modification points'.

[0087] However, for a graphical language like ladder diagrams, it's more intuitive for electrical engineers to mark differences in the structural connections between ladder nodes or in the coding of empty ladder nodes as "modification points" rather than "comparing only source existence" or "comparing only object existence." Therefore, comparison results need to be proofread to facilitate understanding by electrical engineers.

[0088] The comparison result verification module also addresses some extended functionality requirements from electrical engineers, such as ignoring labels, ignoring blank lines, and ignoring comments. These extended requirements are handled in the comparison result verification module to ensure that the comparison results of the ladder control program are not adversely affected before or after the logic execution of these extended requirements.

[0089] The comparison method of combining this system with the ladder diagram control program provided by this solution is as follows:

[0090] The ladder diagram circuit recognition module is used to perform ladder diagram circuit recognition on the input ladder diagram control program, and output the ladder diagram circuits of common nodes and the ladder diagram circuits of non-common nodes;

[0091] The ladder diagram loop node encoding module is used to encode the input ladder diagram loops of the common nodes and the ladder diagram loops of the non-common nodes, and output a ladder diagram loop encoding table of the common nodes and a ladder diagram loop encoding table of the non-common nodes; and perform secondary encoding on the input ladder diagram loop encoding table of the common nodes, and output a secondary encoded encoding table of the ladder diagram loop of the common nodes;

[0092] The ladder diagram circuit comparison module is used to perform a first comparison algorithm comparison on the coding table after the secondary coding of the ladder diagram circuit of the input common node, and output the first comparison result of the ladder diagram circuit of the common node;

[0093] Performing a second comparison algorithm comparison on the input first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the common node, and the ladder diagram loop of the common node, and outputting the second comparison result of the ladder diagram loop of the common node;

[0094] Integrate the first comparison result of the input ladder diagram loop of the common node, the ladder diagram loop coding table of the non-common node, the ladder diagram loop of the non-common node, the ladder diagram loop of the common node and the ladder diagram control program to obtain comparison information, and output the coding table required for the third comparison;

[0095] Performing a third comparison algorithm comparison on the input coding table required for the third comparison, and outputting a comparison result of the ladder diagram loop of the non-ordinary node;

[0096] and integrating the comparison results of the input ladder diagram loops of the non-ordinary nodes, the second comparison results of the ladder diagram loops of the ordinary nodes, the first comparison results of the ladder diagram loops of the ordinary nodes, the ladder diagram loops of the non-ordinary nodes, the ladder diagram loops of the ordinary nodes, and the ladder diagram control program, and outputting a preliminary integrated comparison result of the ladder diagram control program;

[0097] The comparison result checking module is used to check the comparison result of the input preliminary integrated ladder diagram control program and output the final comparison result of the ladder diagram control program.

[0098] The first comparison algorithm comparison, the second comparison algorithm comparison and the third comparison algorithm comparison are all completed by a comparison algorithm module.

[0099] Specifically, in this embodiment:

[0100] The ladder diagram circuit identification step is achieved through the "ladder diagram circuit identification module";

[0101] The coding process is achieved through the "ladder diagram loop node coding module";

[0102] The first comparison algorithm comparison step, the second comparison algorithm comparison step, the third comparison algorithm comparison step, the step of integrating and obtaining comparison information, and the step of integrating comparison results are implemented through the "ladder diagram circuit comparison module";

[0103] The three comparison algorithm comparison steps are all implemented through the "comparison algorithm module";

[0104] The comparison result proofreading step is implemented through the "comparison result proofreading module".

[0105] The ladder diagram loop identification module scans and analyzes the two-dimensional matrix independent node ladder diagram control program, mainly including ordinary nodes, label nodes, line comment nodes and other ladder diagram nodes.

[0106] If a common node is scanned, a tree-shaped data structure with an and or logical relationship is constructed according to the structural connection relationship between the ladder diagram nodes;

[0107] If a label node, a line comment node or other ladder diagram nodes are scanned, they are not processed into a tree-shaped data structure with a logical relationship, but are processed as an independent ladder diagram loop and are not included in the tree-shaped data structure list, so as to avoid affecting the logical processing of the ladder diagram loop comparison module.

[0108] Through the ladder diagram loop identification module, the two-dimensional matrix independent node ladder diagram control program of the comparison source and the comparison object is scanned and analyzed, a plurality of tree-shaped data structures with an and or logical relationship are obtained, a tree-shaped data structure list is constructed, and one tree-shaped data structure corresponds to one ladder diagram loop.

[0109] The tree-shaped data structure list will be used as the data basis required by the logical processing of the ladder diagram loop comparison module.

[0110] The information required for the comparison of the ladder diagram nodes mainly includes an instruction identifier, an instruction operand, an instruction node type, an instruction node upper and lower connection line relationship, an instruction comment, an instruction operand comment and the like.

[0111] The ladder diagram loop node coding module scans and analyzes the two-dimensional matrix independent node ladder diagram control program, collects and integrates the ladder diagram node comparison information, encodes the same through a coding algorithm, constructs an encoding table of the two-dimensional matrix independent node, and constructs a ladder diagram loop encoding table of the ordinary nodes and a ladder diagram loop encoding table of the label nodes, line comments and other nodes according to the ladder diagram loop information obtained by the ladder diagram loop identification module.

[0112] The encoding table is used as one of the sources of the data required for the logical processing when the ladder diagram loop comparison module and the comparison algorithm module perform logical processing.

[0113] The comparison algorithm module is a key module of a ladder diagram comparison method based on the longest common subsequence and the shortest edit path algorithm. It should be noted that the comparison algorithm used in the module is a hybrid of two classic dynamic programming algorithms: the longest common subsequence algorithm and the shortest edit path algorithm, and the longest common subsequence algorithm and the shortest edit path algorithm are balanced through a weighting algorithm.

[0114] The comparison algorithm is essentially a dual problem with the maximum same item and the minimum different item, and the same item is given a weight of 0 and the different item is given a weight of 1, and the minimum total weight value is obtained.

[0115] The weighting algorithm can ensure that the comparison result remains consistent when the comparison contents in the comparison source and the comparison object are exchanged. Through the comparison algorithm, the similarities and differences between the comparison source and the comparison object are obtained.

[0116] The ladder diagram loop comparison module will first integrate all the ordinary node ladder diagram loops according to the logical execution result of the ladder diagram loop identification module before processing. The label node loop, line comment loop and other ladder diagram loops are processed later. If the label node loop and the line comment loop are integrated and processed together with the ordinary node loop, the comparison algorithm module will compare the label node loop with the ordinary node ladder diagram loop during logical processing, which actually has subjective differences. Therefore, the ordinary node ladder diagram loop needs to be integrated and processed first and compared, so as to reduce the comparison between the label node loop, the line comment loop and other ladder diagram loops and the ordinary node ladder diagram loop as much as possible, improve the accuracy of the logical operation of the comparison algorithm module, and increase its subjective rationality.

[0117] As a specific embodiment of the present scheme, as shown in the ladder diagram control program of Figure 3 , the ladder diagram loop 1 and the ladder diagram loop 2 are both ordinary node ladder diagram loops;

[0118] As shown in the ladder diagram control program of Figure 4 , the ladder diagram loop 1 and the ladder diagram loop 3 are both ordinary node ladder diagram loops, and the ladder diagram loop 2 is a label node loop.

[0119] The ladder diagram loop comparison module will preferentially process the ladder diagram loop 1 and the ladder diagram loop 2 in the ladder diagram control program of Figure 3 , and the ladder diagram loop 1 and the ladder diagram loop 3 in the ladder diagram control program of Figure 4 .

[0120] After the processing is completed, the ladder diagram loop 2 in the ladder diagram control program of Figure 4 is processed.

[0121] If the ordinary node ladder diagram loop is not processed first, the ladder diagram loop 2 in the ladder diagram control program of Figure 3 will be compared with the ladder diagram loop 2 in the ladder diagram control program of Figure 4 , which has differences with the subjective logic.

[0122] It should be noted that before integrating and comparing the ordinary node ladder diagram loop, the ordinary node ladder diagram loop needs to be processed again in order to ensure the independence and integrity of the ladder diagram loop comparison. If the processing is not performed, the problem of cross comparison between one ladder diagram loop and two ladder diagram loops will occur, which continues with Figure 3 and Figure 4 For example:

[0123] like Figure 3 As shown, the ladder diagram loop 1 in the ladder diagram control program occupies two lines;

[0124] like Figure 4 As shown in the figure, in the ladder diagram control program, ladder diagram loop 1 occupies only one line, and ladder diagram loop 3 occupies two lines.

[0125] At this time, if the ladder diagram circuit of the common node is directly compared, it will result in Figure 3 The ladder diagram circuit 1 in the ladder diagram control program shown is connected to Figure 4 The ladder control program shown in the figure is compared with the ladder circuit 1 and the ladder circuit 3, rather than just with Figure 4 Compare the ladder diagram circuit 1 in the ladder diagram control program shown in the figure, that is, Figure 3 The comparison of ladder diagram loop 1 in the ladder diagram control program shown is not complete, and a cross comparison of ladder diagram loops occurs.

[0126] To address this issue, before integrating the ladder diagram circuits of common nodes, the ladder diagram circuit code table for common nodes is divided and encoded based on the ladder diagram circuit information of the common nodes. By performing a secondary encoding, the ladder diagram circuit code information of the common nodes is integrated into a single code, ensuring the independence and integrity of the ladder diagram circuit comparisons and preventing cross-comparisons of common node ladder diagram circuits. The first comparison algorithm is then completed, producing the comparison results of the common node ladder diagram circuits (the first comparison result).

[0127] However, when comparing the ladder diagram circuits of common nodes for the first time, in order to ensure the independence and integrity of the ladder diagram circuits, the coding table of the ladder diagram circuits is encoded, resulting in the comparison result of the ladder diagram circuits of common nodes being the ladder diagram circuit level one, and not the ladder diagram node level one. Therefore, it is necessary to compare the ladder diagram circuits of common nodes again according to the ladder diagram nodes. The ladder diagram circuit information of common nodes obtained by the ladder diagram circuit recognition module, the coding table of the ladder diagram circuit of common nodes, and the ladder diagram circuit comparison result of common nodes (the first comparison result) are integrated, and the ladder diagram circuits of common nodes are compared for the second time. The second comparison algorithm is completed, and the ladder diagram circuit comparison result of common nodes (the second comparison result) is output.

[0128] After comparing the ladder diagram circuits for common nodes, the remaining parts of the ladder control program, namely the label node circuits, line comment circuits, and other ladder diagram circuits, need to be processed. When processing these ladder diagram circuits, no secondary encoding is required. This is because these ladder diagram circuits do not span multiple lines.

[0129] Considering the integrity of the ladder diagram control program and the relative positional relationship between ladder diagram circuits such as label node circuits and row comment circuits and ladder diagram circuits of ordinary nodes, when comparing ladder diagram circuits such as label node circuits and row comment circuits, it is necessary to integrate the ladder diagram circuit information of ordinary nodes.

[0130] By integrating the ladder diagram control program information, the ladder diagram circuit information of the common nodes and the ladder diagram circuit comparison results of the common nodes (the first comparison results), the information required for the ladder diagram circuit comparison such as the label node circuit and the row comment circuit is constructed, and the third comparison algorithm is performed to output the comparison results of the ladder diagram circuits such as the label node circuit and the row comment circuit.

[0131] In the third comparison, the comparison information provided by the ladder diagram circuit of a common node is the relative offset position of the ladder diagram circuit of the common node within the comparison result (the first comparison result) of the ladder diagram circuit of the common node. By using the offset position as the comparison information for the ladder diagram circuit of the common node, the relative position of the ladder diagram circuit of the common node can be ensured to remain consistent in the comparison algorithm, reducing the impact of ladder diagram circuits such as label node circuits and line comment circuits on the comparison result of the ladder diagram circuit of the common node.

[0132] The comparison results of the first comparison algorithm (the comparison results of the ladder diagram circuits of ordinary nodes (the first comparison results)), the comparison results of the second comparison algorithm (the comparison results of the ladder diagram circuits of ordinary nodes (the second comparison results)), and the comparison results of the third comparison algorithm (the comparison results of ladder diagram circuits such as label node circuits and line comment circuits) are integrated according to the ladder diagram circuit information and ladder diagram control program information produced by the ladder diagram circuit recognition module to form the comparison results of the ladder diagram control program, and the comparison results are transmitted to the comparison result proofreading module for processing.

[0133] The comparison result obtained after the ladder diagram loop comparison module logic runs needs to be processed by the comparison result proofreading module. As a graphical language, there is a structural connection relationship between the nodes of the ladder diagram, and there is a null node type in the nodes of the ladder diagram. When the comparison algorithm performs logical operation, if there is a difference in the coding of the nodes of the ladder diagram, it will be identified as a'modification point', and will not be identified as 'only compare source exists' or 'only compare object exists', but all are'modification points'. However, for this graphical language of the ladder diagram, if the coding of the structural connection relationship between some nodes of the ladder diagram and the null node type of the nodes of the ladder diagram is different, it is better to be identified as 'only compare source exists' and 'only compare object exists' than'modification point', which is more intuitive to electrical engineers. Therefore, the comparison result needs to be proofread.

[0134] At the same time, the comparison result proofreading module undertakes some extended functions, such as ignoring comments, ignoring blank lines, ignoring labels, etc. during comparison. The logical processing of the extended functions in the comparison result proofreading module can avoid the situation that the comparison results are inconsistent before and after the logical processing of the extended functions, which causes the deviation of the understanding of electrical engineers.

[0135] As shown in Figure 5 , the comparison result of the comparison algorithm has five kinds:

[0136] No difference (no difference between the two), only left side exists (only the content of the left comparison source exists), only right side exists (only the content of the right comparison object exists), modification point (the same position comparison source and comparison object are inconsistent), virtual (used for the right / left side of the left / right side existing only, so that the comparison result can be aligned with the information).

[0137] Referring to Figure 4 , the comparison result is displayed by different display lines, such as no color, thick line, dotted line, dashed line and gray, which is clear and intuitive.

[0138] Through the technical scheme provided in the embodiment, different ladder diagram control programs can be quickly compared, and the comparison result can be clearly and intuitively presented to electrical engineers, which helps electrical engineers to perform iterative upgrading operation on the ladder diagram control program.

[0139] The above is only a preferred specific embodiment of the present application, but the protection scope of the present application is not limited thereto, any changes or replacements within the technical range disclosed by the present application can be thought of by those skilled in the art, which are all covered in the protection scope of the present application. Therefore, the protection scope of the present application should be limited by the protection scope of the claims.

Claims

1. A method for comparing ladder diagram control programs, characterized in that: include: S1 performs ladder diagram circuit recognition on the ladder diagram control program to obtain ladder diagram circuits of common nodes and ladder diagram circuits of non-common nodes; S2: performing encoding processing on the ladder diagram loops of the common nodes and the ladder diagram loops of the non-common nodes to obtain a ladder diagram loop encoding table of the common nodes and a ladder diagram loop encoding table of the non-common nodes; S3: performing secondary encoding processing on the ladder diagram loop coding table of the common node to obtain a secondary encoded coding table of the ladder diagram loop of the common node; S4: performing a first comparison algorithm comparison on the coding table after the secondary coding of the ladder diagram loop of the common node, to obtain a first comparison result of the ladder diagram loop of the common node; S5: performing a second comparison algorithm on the first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the common node, and the ladder diagram loop of the common node to obtain a second comparison result of the ladder diagram loop of the common node; S6: Integrate the first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the non-common node, the ladder diagram loop of the non-common node, the ladder diagram loop of the common node, and the ladder diagram control program, and obtain comparison information to obtain the coding table required for the third comparison; S7: performing a third comparison algorithm comparison on the coding table required for the third comparison to obtain a comparison result of the ladder diagram loop of the non-ordinary node; S8: Integrating the comparison results of the ladder diagram loops of the non-common nodes, the second comparison results of the ladder diagram loops of the common nodes, the first comparison results of the ladder diagram loops of the common nodes, the ladder diagram loops of the non-common nodes, the ladder diagram loops of the common nodes, and the ladder diagram control program to obtain a preliminary integrated comparison result of the ladder diagram control program; S9: performing comparison result verification on the comparison result of the preliminarily integrated ladder diagram control program to obtain a final comparison result of the ladder diagram control program; The step S1 of identifying a ladder diagram circuit of the ladder diagram control program includes the following steps: the ladder diagram control program includes common nodes and non-common nodes; for common nodes, a tree data structure list having an AND or OR logical relationship is constructed based on the structural connection relationship between the ladder diagram nodes; and for non-common nodes, they are processed as independent ladder diagram circuits and are not included in the tree data structure list; The non-ordinary nodes include label nodes and line comment nodes.

2. The method for comparing ladder diagram control programs according to claim 1, wherein: The information in the tree data structure list includes instruction identifiers, instruction operands, instruction node types, upper and lower connection line relationships of instruction nodes, instruction comments, and instruction operand comments.

3. The method for comparing ladder diagram control programs according to claim 1, wherein: The first comparison algorithm described in step S4, the second comparison algorithm described in step S5, and the third comparison algorithm described in step S7 are an algorithm that mixes two classic dynamic programming algorithms: the longest common subsequence algorithm and the shortest edit path algorithm, and balances the longest common subsequence algorithm and the shortest edit path algorithm through a weighted algorithm.

4. The method for comparing ladder diagram control programs according to claim 1, wherein: In step S6, the ladder diagram loops of common nodes are preferentially integrated and compared, and the ladder diagram loops of non-common nodes are processed later.

5. The method for comparing ladder diagram control programs according to claim 1, wherein: In step S8, ladder diagram loops of common nodes are compared and integrated first, while ladder diagram loops of non-common nodes are processed later.

6. A comparison system for ladder diagram control programs, characterized in that: include: A ladder diagram circuit recognition module, wherein the ladder diagram circuit recognition module is used to perform ladder diagram circuit recognition on an input ladder diagram control program, and output ladder diagram circuits of common nodes and ladder diagram circuits of non-common nodes; A ladder diagram loop node encoding module, the ladder diagram loop node encoding module is used to encode the input ladder diagram loops of the common nodes and the ladder diagram loops of the non-common nodes, and output a ladder diagram loop encoding table of the common nodes and a ladder diagram loop encoding table of the non-common nodes; and perform secondary encoding on the input ladder diagram loop encoding table of the common nodes, and output a secondary encoded encoding table of the ladder diagram loop of the common nodes; A ladder diagram circuit comparison module, the ladder diagram circuit comparison module is used to perform a first comparison algorithm comparison on the coding table after the secondary coding of the input ladder diagram circuit of the common node, and output the first comparison result of the ladder diagram circuit of the common node; Performing a second comparison algorithm comparison on the input first comparison result of the ladder diagram loop of the common node, the ladder diagram loop coding table of the common node, and the ladder diagram loop of the common node, and outputting the second comparison result of the ladder diagram loop of the common node; Integrate the first comparison result of the input ladder diagram loop of the common node, the ladder diagram loop coding table of the non-common node, the ladder diagram loop of the non-common node, the ladder diagram loop of the common node and the ladder diagram control program to obtain comparison information, and output the coding table required for the third comparison; Performing a third comparison algorithm comparison on the input coding table required for the third comparison, and outputting a comparison result of the ladder diagram loop of the non-ordinary node; and integrating the comparison results of the input ladder diagram loops of the non-ordinary nodes, the second comparison results of the ladder diagram loops of the ordinary nodes, the first comparison results of the ladder diagram loops of the ordinary nodes, the ladder diagram loops of the non-ordinary nodes, the ladder diagram loops of the ordinary nodes, and the ladder diagram control program, and outputting a preliminary integrated comparison result of the ladder diagram control program; A comparison result checking module, wherein the comparison result checking module is used to check the comparison result of the input preliminary integrated ladder diagram control program and output a final comparison result of the ladder diagram control program; The ladder diagram control program includes common nodes and non-common nodes; For common nodes, a tree data structure list with AND or logical relationships is constructed based on the structural connection relationship between the ladder diagram nodes; for non-common nodes, they are only processed as an independent ladder diagram loop and are not included in the tree data structure list; The non-ordinary nodes include label nodes and line comment nodes.

7. A ladder diagram control program comparison system according to claim 6, characterized in that: The first comparison algorithm comparison, the second comparison algorithm comparison and the third comparison algorithm comparison are all completed by a comparison algorithm module.

Citation Information

Patent Citations

  • Ladder diagram data structural description and scanning analytic method

    CN103559727A

  • Label depth matching-based ladder diagram intelligent identification management method

    CN114527708A