A method for comparing continuous functional graphs based on dynamic programming algorithm
The continuous functional chart graphic comparison method of the dynamic programming algorithm solves the problems of low efficiency and difficulty in graphic display of logic engineering files in the existing technology, and achieves rapid and targeted difference identification and multi-dimensional perspective display, significantly improving To compare efficiency.
Patent Information
- Application Number
- CN202111501252.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-09
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-09
AI Technical Summary
When comparing large logic engineering files, the existing technology is inefficient and difficult to display graphically, making it impossible to identify difference information quickly and in a targeted manner.
A continuous function chart graphic comparison method based on dynamic programming algorithm is adopted. Through hierarchical screening of logical pages, component groups and component attributes, the dynamic programming algorithm is used to obtain the longest ordered subsequence, and the difference information is gradually obtained and displayed graphically. Compare the results.
It improves the efficiency of logical engineering file comparison, can quickly and targetedly identify difference information, and graphically display it from an overall to a local multi-dimensional perspective, significantly improving comparison efficiency and visualization effects.
Smart Images

Figure CN114416077B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of PLC application development, and more specifically, provides a continuous function diagram graphical comparison method based on a dynamic programming algorithm in a continuous function diagram. Background Art
[0002] PLC (Programmable Logic Controller) is an electronic device that replaces relays to perform logic operations and other sequential control functions to control various types of machinery or production processes. It has the characteristics of high reliability, simple programming, easy use, complete functions, and good versatility.
[0003] Continuous Function Chart is one of the PLC graphical programming languages. Due to its advantages of flexibility, convenience and intuition, it is currently widely used in industrial automation, especially in the development of large-scale systems such as DCS (Distributed Control System), and has become a very important configuration language. In more and more field projects, it is necessary to quickly and clearly grasp the differences between project files in order to determine the current status of the project, set subsequent project goals, and respond to project problem analysis. Therefore, it is very important to compare logic projects from different sites, different times, and different personnel.
[0004] Prior art document 1 (CN104714468B) discloses a method for comparing continuous function diagram files, including: extracting all program pages, function blocks, signals, comment blocks, and connection information in a first continuous function diagram file, and organizing them into a sorted internal data table that is easy to search quickly; extracting all program pages, function blocks, signals, comment blocks, and connection information in a second continuous function diagram file, and organizing them into a sorted internal data table that is easy to search quickly; traversing the internal data tables of the first and second continuous function diagram files, searching for differences between the internal data tables of the first and second continuous function diagram files; and outputting a difference information table. The shortcomings of the prior art represented by this comparative document are that the comparison efficiency is not high enough, the pertinence is general, and it is not easy to display graphically. Summary of the invention
[0005] The purpose of the present invention is to propose a continuous function diagram graphic comparison method based on a dynamic programming algorithm, so that in the comparison process of two logic engineering files with thousands of components, the comparison efficiency can be improved, the difference information can be quickly and specifically compared, and graphical display can be performed from the overall and local multi-dimensional perspectives.
[0006] The present invention specifically adopts the following technical solutions:
[0007] A continuous functional diagram graphic comparison method based on a dynamic programming algorithm adopts a divide-and-conquer strategy, and hierarchically screens and compares logic pages, component groups within logic pages, components, and component attributes. Based on similar component groups, the longest ordered subsequence is obtained based on a dynamic programming algorithm, and component difference information is gradually obtained. The comparison results are displayed in a graphical way.
[0008] Specifically, a continuous function diagram graphic comparison method based on a dynamic programming algorithm comprises the following steps:
[0009] Step 1: parse two continuous function diagram files to be compared, extract logic data, and generate a first logic page list and a second logic list;
[0010] Step 2: Taking the logical page as the unit, select the logical page with the same name from the first logical page list and the second logical page list, and compare the check codes of the logical data. If the check codes are the same, the comparison of the two logical pages is terminated and the comparison result is the same; if the check codes are different, enter the next level of comparison and continue to step 3;
[0011] Step 3: logical pages with the same name but different check codes are grouped according to topological logic to generate a first component group list and a second component group list;
[0012] Step 4: Compare the functional block logic in component groups, obtain similar component groups, and generate a similar component group list. If the component groups are not similar, the comparison is terminated, and the primitive comparison results in the component groups are different. If the component group lists are similar, enter the next level of comparison and continue to step 5.
[0013] Step 5: Using the dynamic programming algorithm, compare similar component groups based on components to generate the longest ordered subsequence. Components not in the subsequence are compared as different; components in the subsequence enter the next level of comparison and continue to step 6.
[0014] Step 6: Compare the specific component attributes of the longest ordered subsequence in units of component attributes. If the component attributes are the same, the comparison results of the components are the same; if the component attributes are different, the comparison results of the components are different.
[0015] Step 7: After several comparisons, the comparison results are obtained as the same / different components, and the final comparison results are displayed in a graphical manner.
[0016] Preferably, in step 1, each logic page is unique in the entire project, and the logic page list is sorted by name.
[0017] Preferably, in step 2, a logical page that exists in only one logical group list no longer participates in subsequent comparisons, and the comparison results of the components thereunder are different.
[0018] Preferably, in step 3, grouping is performed based on topological logic, and factors affecting the topological logic include: component type, execution sequence number, and connection line.
[0019] Preferably, in step 4, when determining whether they are similar component groups, the criterion for measuring the degree of matching between the two component groups is, according to Nash equilibrium, when the ratio of the longest subsequence length of the executable components in the two component groups to the number of components in the current component group is greater than or equal to 63%, it is considered that the two component groups match each other, and further component attribute comparison can be performed.
[0020] Preferably, in step 5, the similar element group is an ordered sequence, and the algorithm aims to compare the ordered sequence. After each layer of matching is completed, the next layer of loop is entered without starting the comparison from the beginning, but starting the comparison from the position where the previous layer successfully matched.
[0021] Preferably, in step 6, the component properties of the two execution components should be compared first, including: component type, component name, component instance name, and then the connection relationship of the connection lines of the two components should be compared; including: the number of input pins, input pin names, and the connection relationship of input pins. If both input pins are in a connected state, further recursive operation is performed.
[0022] Preferably, in step 7, the final comparison result is displayed in a graphical manner. On the one hand, the "program unit-logic page" hierarchical tree is displayed to clearly show the overall comparison result. On the other hand, different comparison results are distinguished by different colors in the logic area, and the logic blocks are folded / expanded in a targeted manner to view further comparison results.
[0023] Preferably, in step 7, the final comparison result is displayed in a graphical manner, and when the scroll bars on the left and right sides are dragged, the logic area graphics change synchronously for operation and viewing.
[0024] The present invention has the following beneficial technical effects:
[0025] The above-mentioned continuous function diagram graphic comparison method compares logic projects from different sites, different times, and different personnel. By comparing layer by layer, the dynamic programming algorithm is fully utilized in the comparison process to provide comparison efficiency, and the comparison results can be obtained in a targeted and rapid manner. The comparison results are further displayed in a graphical manner from different perspectives from the overall to the local. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 The present invention is a flow chart of a method for comparing continuous function graphs based on a dynamic programming algorithm;
[0027] Figure 2A schematic diagram of the process of calculating the longest subsequence by the optimized dynamic programming algorithm of the present invention;
[0028] Figure 3 The figure is a schematic diagram of a screen showing a comparison result graphically according to the present invention. DETAILED DESCRIPTION
[0029] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings.
[0030] like Figure 1 As shown, embodiment 1 of the present invention provides a continuous function diagram graphic comparison method based on a dynamic programming algorithm, comprising the following steps:
[0031] Step 1, parse two continuous function diagram files to be compared, extract logic data, and generate logic page lists LogicPageList1 and LogicPageList2 respectively. Each logic page is unique in the entire project, and the logic page lists are sorted by name.
[0032] Step 2, taking the logical page as the unit, select the logical pages with the same name from LogicPageList1 and LogicPageList2 respectively, and compare the CRC (Cyclic Redundancy Check) codes of the logical data. If the CRC codes are the same, the two logical pages are terminated for comparison, and the comparison results of the components under them are the same; if the CRC codes are different, enter the next level of comparison and execute step 3; for the logical pages that only exist in LogicPageList1 or LogicPageList2, they will no longer participate in the subsequent comparison, and the comparison results of the components under them are different.
[0033] Step 3, two logic pages with the same name but different CRC codes are grouped according to topological logic to generate two component group lists LogicItemList1 and LogicItemList2. Factors affecting topological logic include but are not limited to component type, execution sequence number, and connection line.
[0034] Step 4, taking component groups as units, compare the topological logic to obtain similar component groups.
[0035] In a preferred embodiment of the present invention, the criterion for judging the degree of match between two component groups is calculated according to the Nash Equilibrium Theory. In the statistical practice of big data, "63%" is a relatively reasonable Nash equilibrium point. The comparison process adopts "63%" by default, and it can be adjusted appropriately according to the actual situation in the specific comparison process. When the ratio of the longest subsequence length of the executable elements in the two component groups to the number of elements in the current component group is greater than or equal to 63%, it is considered that the two component groups match each other, and a list of similar component groups is generated. The comparison of dissimilar component groups is terminated, and the comparison results of the components in the component group are different; for similar component group lists, the next level of comparison is entered, and step 5 is executed to perform further component attribute comparison.
[0036] Step 5: Taking components as units, a dynamic programming algorithm (DP) is used to compare similar component groups and generate a longest ordered subsequence (S-LCS). Components not in the subsequence are compared as different; components in the subsequence enter the next level of comparison;
[0037] In the preferred embodiment of the present invention, the algorithm compares ordered sequences, so not every comparison is necessary. That is, after completing each layer of matching, it enters the next layer loop without starting the comparison from the beginning, but starting the comparison from the position where the previous layer successfully matched. The comparison process based on the dynamic programming algorithm is as follows Figure 2 As shown,
[0038] The ordered sequence of similar component group 1 is,itemb,itemd,itemc,itema,itemb,itema;
[0039] The ordered sequence of similar component group 2 is,itema,itemb,itemc,itemb,itemd,itema,itemb;
[0040] The longest ordered subsequence finally obtained is,itemb,itemc,itemb,itema;
[0041] The comparison result of the components not in the subsequence is different, and the components in the subsequence enter the next level of comparison and execute step 6.
[0042] Step 6: Compare the specific element attributes of the longest ordered subsequence in units of element attributes. If the element attributes are the same, the comparison result of the element is the same; if the element attributes are different, the comparison result of the element is different.
[0043] In a preferred embodiment of the present invention, the element properties of two execution elements should first be compared, including but not limited to element type, element name, element instance name (operation block element), and then the connection relationship of the wires of the two elements should be compared, including but not limited to the number of input pins, input pin names, and the connection relationship of input pins. If both input pins are in a connected state, further recursive operation is performed.
[0044] If the component attributes are the same, the comparison result of the components is the same; if the component attributes are different, the comparison result of the components is different.
[0045] Step 7: After several comparisons, the comparison results are obtained as the same / different components, and the final comparison results are displayed in a graphical manner.
[0046] In a preferred embodiment of the present invention, the final comparison result is displayed in a graphical manner, such as Figure 3 As shown, on the one hand, the "Program Unit-Logic Page" hierarchy tree is displayed to clearly show the overall comparison results. On the other hand, different comparison results are distinguished by different colors in the logic area, and logic blocks are folded / expanded in a targeted manner, making it easier to view further comparison results.
[0047] Further preferably, the final comparison result is displayed in a graphical manner, and when the scroll bars on the left and right sides are dragged, the logic area graphics change synchronously, which is easy to operate and view.
[0048] The above is only one embodiment of the present invention. It should be pointed out that for those skilled in the art, several improvements and adjustments can be made without departing from the principle of the present invention. These improvements and adjustments should be regarded as within the scope of protection of the present invention.
Claims
1. A method for comparing continuous function graphs based on a dynamic programming algorithm, characterized in that: The graphic comparison method comprises the following steps: Step 1: parse two continuous function diagram files to be compared, extract logic data, and generate a first logic page list and a second logic list; Step 2: Taking the logical page as the unit, select the logical page with the same name from the first logical page list and the second logical page list, and compare the check codes of the logical data. If the check codes are the same, the comparison of the two logical pages is terminated and the comparison result is the same; if the check codes are different, enter the next level of comparison and continue to step 3; Step 3: logical pages with the same name but different check codes are grouped according to topological logic to generate a first component group list and a second component group list; Step 4: Compare the functional block logic in component groups, obtain similar component groups, and generate a similar component group list. If the component groups are not similar, the comparison is terminated, and the primitive comparison results in the component groups are different. If the component group lists are similar, enter the next level of comparison and continue to step 5. Step 5: Using the dynamic programming algorithm, compare similar component groups based on components to generate the longest ordered subsequence. Components not in the subsequence are compared as different; components in the subsequence enter the next level of comparison and continue to step 6. Step 6: Compare the specific component attributes of the longest ordered subsequence in units of component attributes. If the component attributes are the same, the comparison results of the components are the same; if the component attributes are different, the comparison results of the components are different. Step 7: After several comparisons, the comparison results are obtained as the same / different components, and the final comparison results are displayed in a graphical manner.
2. The continuous function diagram comparison method based on dynamic programming algorithm as claimed in claim 1, characterized in that: In step 1, each logical page is unique in the entire project, and the logical page list is sorted by name.
3. The continuous function diagram comparison method based on dynamic programming algorithm according to claim 1, characterized in that: In step 2, for a logic page that exists only in one logic group list, it no longer participates in the subsequent comparison, and the comparison results of the components under it are different.
4. The continuous function diagram comparison method based on dynamic programming algorithm as claimed in claim 1, characterized in that: In step 3, grouping is performed based on topological logic. Factors affecting the topological logic include: component type, execution sequence number, and connection line.
5. The continuous function diagram comparison method based on dynamic programming algorithm as claimed in claim 1, characterized in that: In step 4, when determining whether they are similar component groups, the matching degree between the two component groups is measured according to the Nash equilibrium. When the ratio of the longest subsequence length of the executable components in the two component groups to the number of components in the current component group is greater than or equal to 63%, the two component groups are considered to match each other and further component attribute comparison can be performed.
6. The continuous function diagram comparison method based on dynamic programming algorithm according to claim 1, characterized in that: In step 5, the similar component group is an ordered sequence, and the algorithm aims to compare the ordered sequence. After completing each layer of matching, it enters the next layer of loop. There is no need to start the comparison from the beginning, but to start the comparison from the position where the previous layer successfully matches.
7. The continuous function diagram comparison method based on dynamic programming algorithm according to claim 1, characterized in that: In step 6, the component properties of the two execution components should first be compared, including: component type, component name, component instance name, and then the connection relationship of the wires of the two components should be compared; including: the number of input pins, input pin names, and the connection relationship of input pins. If both input pins are in a connected state, further recursive operation is performed.
8. The continuous function diagram comparison method based on dynamic programming algorithm according to claim 1, characterized in that: In step 7, the final comparison results are displayed graphically. On the one hand, the "Program Unit-Logic Page" hierarchy tree is displayed to clearly show the overall comparison results. On the other hand, different comparison results are distinguished by different colors in the logic area, and the logic blocks are folded / expanded in a targeted manner to view further comparison results.
9. The continuous function diagram comparison method based on dynamic programming algorithm according to claim 1, characterized in that: In step 7, the final comparison result is displayed graphically. When the scroll bars on the left and right sides are dragged, the logic area graphics change synchronously for operation and viewing.
