Implementation method and device for converting graphical language into text editing language
By parsing the hierarchical structure and mapping attributes of graphical programming programs, combined with recursive branch parsing and branch merging rules, the comprehensiveness and scalability of the graphical language conversion method for compiled soft PLCs are solved, and efficient and accurate text editing language conversion is achieved.
Patent Information
- Application Number
- CN202510810747.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-11-14
AI Technical Summary
Existing graphical language conversion methods for compiled soft PLCs are insufficient in terms of comprehensiveness, scalability, maintainability, and modular design, resulting in the loss of functionality in the converted text programs, difficulty in adapting to changes in programming requirements, and difficulties in software upgrades.
By employing hierarchical structure parsing and attribute mapping of graphical programming programs, and through recursive branch parsing and branch merging rules, we ensure the comprehensive acquisition of graphical programming information and process branches according to the blocking information table, thereby realizing the conversion from graphical language to text editing language.
It improves the comprehensiveness, accuracy, and reliability of the conversion, adapts to complex graphical program structures, has good scalability and maintainability, and ensures the stability and accuracy of the conversion process.
Smart Images

Figure CN120950072A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer language conversion technology, specifically relating to a method and apparatus for converting graphical language into text editing language. Background Technology
[0002] Compiled soft PLCs (Programmable Logic Controllers) are an important industrial automation control solution. They can compile user-written control logic programs (including graphical programming languages, text-based programming languages, and other forms) into target code (such as machine code or intermediate code), which can then be directly executed on the target system to achieve automated control of various equipment. To meet users' flexible programming needs, compiled soft PLCs typically support file import functions and have the ability to convert between multiple languages.
[0003] In the existing compiled software PLC system, graphical programming languages are widely used to describe logic control functions due to their intuitiveness and ease of use. Text-based programming languages, similar to assembly languages, use instruction lists, allowing engineers to control PLC operations in a more granular manner.
[0004] However, different PLC manufacturers tailor their language protocols to their specific needs when developing compiled soft PLCs, and design corresponding language conversion methods based on these protocols. This leads to significant differences between these language conversion methods, primarily in terms of comprehensiveness, scalability, maintainability, and modularity. In terms of comprehensiveness, they cannot fully cover all graphical programming elements, resulting in functional deficiencies in the converted text programs. In terms of scalability, they struggle to adapt to evolving programming requirements. Furthermore, their maintenance and modular design are inadequate, increasing the difficulty of software upgrades and feature expansion. Therefore, a method for converting graphical languages to text editing languages with good comprehensiveness, scalability, maintainability, and modularity is needed. Summary of the Invention
[0005] In view of the above-mentioned shortcomings of the prior art, the present invention provides a method and apparatus for converting graphical language into text editing language to solve the above-mentioned technical problems.
[0006] In a first aspect, the present invention provides a method for converting a graphical language into a text editing language, comprising the following steps: S1. The graphical programming program is parsed according to the hierarchical structure of program-network segment-line-component grid, and an attribute mapping is established for each component grid. Through this hierarchical parsing and attribute mapping, various information in the graphical programming program can be fully obtained, providing a solid foundation for subsequent conversion work and ensuring the comprehensiveness of the conversion.
[0007] S2. Based on the attribute mapping, parse the network segment from left to right to obtain network segment information, branch summary table, blocking information summary table and error information table, and determine the 0th order branch according to the number of extension lines; this helps to initially sort out the structure of the graphical program and prepare for subsequent branch parsing. S3. Perform the steps of parsing the same-order branches for each 0th-order branch, wherein the steps of parsing the same-order branches include: Confirm the header elements of all branches in the current stage; If multiple right-leader forks are detected in the branch, the steps for parsing branches of the same order are recursively called to start parsing the next order branch; otherwise, jump to step S4. This recursive parsing method can adapt to complex graphical program structures, ensuring that all branches are processed correctly.
[0008] S4. The steps for parsing the same-order branch set are as follows: traverse the current-order branches, perform single-branch parsing for each branch, and perform one of the following operations based on the single-branch parsing results: If branches need to be merged, the branch merge rules are invoked to perform the processing and the branch master table is updated; If the branch is not unified, return to step S3 to perform the same-order branch parsing step and re-parse the branch of the current order; the branch not being unified means that the branch has a right lead fork; If the waiting mechanism is triggered, proceed to step S5; By employing multiple branch merging rules, the method can flexibly handle branch merging requirements under different circumstances, improving its adaptability and comprehensiveness. This cyclical processing mechanism ensures that all branches are correctly merged, avoiding omissions or errors. Through the handling of special composite components, the method can better adapt to complex graphical program logic, improving its comprehensiveness and accuracy.
[0009] S5. Based on the blockage information table, process branches of the same or different order.
[0010] By establishing clear branching rules, we can ensure that branches are handled correctly under different circumstances, thereby improving the reliability and stability of the method.
[0011] As a further limitation of the technical solution of the present invention, the program in the hierarchical structure includes multiple network segments, each network segment includes multiple rows of element arrangements, each row includes multiple element cells, and each element cell has an independent set of attributes.
[0012] The clearly defined hierarchical structure of the program includes multiple network segments, each network segment contains multiple rows of elements, each row contains multiple element cells, and each element cell has an independent set of attributes. This detailed structural definition makes the parsing of the graphical programming program more accurate and comprehensive. It helps to accurately identify and process the attributes of each element cell during the conversion process, ensuring that the converted text editing language can accurately reflect the logic and function of the original graphical program, thus improving the accuracy and comprehensiveness of the conversion.
[0013] As a further limitation of the technical solution of the present invention, in S3, after the step of confirming the head element of all branches of the current order in the same-order branch parsing step, the following is included: For each branch, a branch data structure is constructed. The data structure includes a list of text statements, real-time cursor position, forward association information, waiting point mapping, host branch identifier, list of completed waiting points, block identifier, composite element identifier, and end marker.
[0014] For each branch, a branch data structure is constructed that includes a list of text statements, real-time cursor position, forward association information, waiting point mapping, host branch identifier, list of completed waiting points, block identifier, composite element identifier, and end marker. This structure comprehensively records and manages various states and information of each branch. In subsequent branch parsing and processing, this information can be easily retrieved and updated, enabling precise control and tracking of branches and enhancing the method's scalability and maintainability.
[0015] As a further limitation of the technical solution of the present invention, the steps of parsing the same-order branch set also include: When a special composite element is detected during the parsing process, the threshold for traversing columns is limited to the final column of the current branch; When the set conditions are met simultaneously, it is determined that the current branch has not ended, and the reference parameter status is changed to true; the set conditions include: the current branch has not been unified, the current branch has not terminated, the current branch has no waiting points of the same level, or the current branch has no waiting points of different levels.
[0016] When detecting special composite elements during parsing, limiting the traversal column threshold to the current branch's final column avoids over-parsing of these elements, improving parsing efficiency. Simultaneously, when conditions such as the branch not being unified, the branch not terminating, the branch having no waiting points of the same or different order are simultaneously met, the branch is determined not to have ended, and the reference parameter status is changed to true. This precise determination mechanism better adapts to complex graphical program logic, ensuring the accuracy of branch parsing and avoiding erroneous branch termination judgments.
[0017] As a further limitation of the technical solution of the present invention, the branch merging rule includes one of the following processing methods: Union: Changes the preceding branch header text statement to a header statement, and processes the following branch text statement; Concatenation and merging: directly merge text statements or add ANDSTK block identifiers; MPS Merging: Merge text statements according to the MPS-MRD-MPP structure; Special composite element processing: Combine and replace branch text and delete redundant branches.
[0018] It offers various branch merging rules, including union-join, series-merge, MPS merging, and special composite element processing, allowing users to choose the appropriate merging method based on different branch situations and needs. Union-join can integrate the header statements of branches, making the text statements more concise; series-merge can directly merge text statements or add block identifiers to adapt to different logical structures; MPS merging merges text statements according to a specific structure to meet specific programming requirements; special composite element processing can combine and replace branch text and delete redundant branches, optimizing the text structure.
[0019] As a further limitation of the technical solution of the present invention, the single-branch parsing step includes: Traverse the components from the head column of the branch, updating row attributes and component status in real time, and performing corresponding processing based on the component type and status; specifically as follows: For valid components, update the text language and status information; For terminating components, process and return; For components with vertical lines, perform left / right lead checks; When the left lead check shows a valid left lead, it is determined that there is a blockage waiting; When multiple valid right leads are found during the right lead check, the steps for parsing the same-order branch in S3 are recursively called to start parsing the next-order branch.
[0020] In the single-branch parsing step, the processing elements are traversed from the head column of the branch, updating row attributes and element states in real time. Appropriate processing is performed based on the element type and state, accurately acquiring information for each element and generating corresponding text. For valid elements, the text and state information are updated to ensure conversion accuracy. Terminating elements are processed and returned to avoid unnecessary parsing. Elements with vertical lines undergo left / right lead checks to promptly identify branching situations, providing a basis for subsequent branch parsing. When multiple valid right leads are found during right lead checks, the same-level branch parsing step is recursively called to initiate the next-level branch parsing, adapting to complex branch structures and improving the comprehensiveness and accuracy of the conversion.
[0021] As a further limitation of the technical solution of the present invention, the trigger waiting processing mechanism includes: When location and parent branch information are detected in the overall blocking information table, one of the following processing methods shall be adopted: If the branches are of the same level, perform a union operation and merge them into the previous branch, then decrement the branch number by 1. If the branches are of different orders, check the number of waiting points in the parent branch. If the number is 1, report an error and backtrack directly; if the number is not 1, delete the corresponding data in the blockage information table. If it is not the first branch, then perform a union of branches of the same order; After processing is complete, return to step S4, which involves parsing the same-order branch set.
[0022] The trigger wait handling mechanism has detailed processing methods for different situations. For branches of the same level, it performs a merge and combines them into the previous branch, decrementing the branch number by 1, which can reasonably integrate branches. For branches of different levels, it checks the number of waiting points on the parent branch. If the number is 1, it directly reports an error and recurses; if the number is not 1, it deletes the corresponding data from the blocking information table, which can promptly handle blocking information and avoid program errors. For non-first branches, it performs a merge and combines them of the same level to ensure the continuity of branch processing. After processing, it returns to step S4 to continue execution, ensuring the smooth progress of the entire transformation process and improving the reliability and stability of the method.
[0023] As a further limitation of the technical solution of the present invention, the specific processing rules in S5 include: When the branches are of the same level, perform a union operation and merge the branches into the previous branch; When branches are of different orders, if the number of waiting points in the parent branch is 1, an error is reported and the data is returned; otherwise, the corresponding data in the blockage information table is deleted. If it is not the first numbered branch, then perform a union of branches of the same order; After processing is complete, return to step S4.
[0024] The branch processing rules clearly define how to handle branches under different circumstances. For branches of the same order, they are merged and combined into the previous branch to optimize the branch structure. For branches of different orders, different processing is applied based on the number of waiting points on the parent branch: if the number is 1, an error is reported and the process is reverted; if the number is not 1, the corresponding data in the blocking information table is deleted to prevent errors due to waiting points. For branches not starting with a specific number, they are merged and combined with branches of the same order to ensure the correctness of branch processing. After processing, the process returns to step S4, forming a closed loop that allows for continuous and stable operation, improving the maintainability and reliability of the method.
[0025] As a further limitation of the technical solution of the present invention, the criterion for determining the non-first numbered branch is as follows: The current branch index is greater than 0; The blockage information table contains forward-association records; The host branch identifier is inconsistent with the current branch.
[0026] The criteria for identifying non-first-numbered branches are clearly defined: the current branch index is greater than 0, a forward-related record exists in the blocking information table, and the host branch identifier is inconsistent with the current branch. This ensures accurate identification of non-first-numbered branches. During branch processing, non-first-numbered branches are subjected to same-order union and other similar processing to ensure the accuracy and completeness of branch processing, avoid omissions or errors in branch processing, and improve the quality and reliability of the conversion.
[0027] Secondly, the technical solution of the present invention also provides an implementation device for converting graphical language into text editing language, including a data structure parsing module, a network segment parsing module, a same-order branch parsing module, a same-order branch set parsing module, and a branch processing module; The data structure parsing module is used to parse the graphical programming program according to the hierarchical structure of program-network segment-line-component grid, and to establish attribute mapping for each component grid; The network segment parsing module is used to parse network segments from left to right based on the attribute mapping, obtain network segment information, branch summary table, blocking information summary table and error information table, and determine the 0th order branch according to the number of extension lines. The same-order branch resolution module is used to perform the same-order branch resolution steps for each 0th-order branch. The same-order branch resolution steps include: Confirm the header elements of all branches in the current stage; If multiple right-leader forks are detected in a branch, the same-order branch parsing module is recursively called to start parsing the next-order branch; otherwise, the same-order branch set parsing module is triggered. The same-order branch set parsing module is used to perform the steps of same-order branch set parsing, including: Traverse the current branch, perform single-branch analysis on each branch, and perform one of the following operations based on the result of the single-branch analysis: If branches need to be merged, the branch merge rules are invoked to perform the processing and the branch master table is updated; If the branch is not unified, return to the same-order branch parsing module to perform the same-order branch parsing steps and re-parse the current-order branch; the branch not unified means that the branch has a right lead fork; If the waiting mechanism is triggered, the branch processing module will be activated. The branch processing module is used to process branches of the same or different levels based on the blockage information table.
[0028] The device achieves a complete conversion from graphical language to text editing language through the collaborative work of a data structure parsing module, a network segment parsing module, a same-level branch parsing module, a same-level branch set parsing module, and a branch processing module. Each module has a clear division of labor: the data structure parsing module provides the foundation for subsequent parsing, the network segment parsing module organizes the program structure, the same-level branch parsing and same-level branch set parsing modules perform detailed processing of branches, and the branch processing module handles special cases appropriately. This modular design gives the device good scalability, maintainability, and reusability, enabling it to efficiently and accurately complete the conversion task from graphical language to text editing language.
[0029] As a further limitation of the technical solution of the present invention, the program in the hierarchical structure includes multiple network segments, each network segment includes multiple rows of element arrangements, each row includes multiple element cells, and each element cell has an independent set of attributes.
[0030] As a further limitation of the technical solution of the present invention, the same-level branch parsing module is also used to construct a branch data structure for each branch. The content of the data structure includes a list of text statements, real-time cursor position, forward association information, waiting point mapping, host branch identifier, list of completed waiting points, block identifier, composite element identifier, and end mark.
[0031] As a further limitation of the technical solution of the present invention, the same-order branch set parsing module is also used to limit the traversal column threshold to the current branch end column when a special composite element is detected during the parsing process; when the set conditions are met at the same time, it is determined that the branch has not ended and the reference parameter status is changed to true; the set conditions include: the branch of the current order has not been unified, the branch has not terminated, the branch has no same-order waiting points or the branch has no different-order waiting points.
[0032] As a further limitation of the technical solution of the present invention, the branch merging rule includes one of the following processing methods: Union: Changes the preceding branch header text statement to a header statement, and processes the following branch text statement; Concatenation and merging: directly merge text statements or add ANDSTK block identifiers; MPS Merging: Merge text statements according to the MPS-MRD-MPP structure; Special composite element processing: Combine and replace branch text and delete redundant branches.
[0033] As a further limitation of the technical solution of the present invention, the steps of the same-order branch set parsing module performing single-branch parsing include: Traverse the components from the head column of the branch, updating row attributes and component status in real time, and performing corresponding processing based on the component type and status; specifically as follows: For valid components, update the text language and status information; For terminating components, process and return; For components with vertical lines, perform left / right lead checks; When the left lead check shows a valid left lead, it is determined that there is a blockage waiting; When multiple valid right leads are found during the right lead check, the same-order branch parsing module is recursively called to remember the same-order branch parsing steps and to start the next-order branch parsing.
[0034] As a further limitation of the technical solution of the present invention, the trigger waiting processing mechanism includes: When location and parent branch information are detected in the overall blocking information table, one of the following processing methods shall be adopted: If the branches are of the same level, perform a union operation and merge them into the previous branch, then decrement the branch number by 1. If the branches are of different orders, check the number of waiting points in the parent branch. If the number is 1, report an error and backtrack directly; if the number is not 1, delete the corresponding data in the blockage information table. If it is not the first branch, then perform a union of branches of the same order; After processing is complete, return to the same-order branch set parsing module to execute the same-order branch set parsing steps.
[0035] As a further limitation of the technical solution of the present invention, the specific processing rules of the branch processing module include: When the branches are of the same level, perform a union operation and merge the branches into the previous branch; When branches are of different orders, if the number of waiting points in the parent branch is 1, an error is reported and the data is returned; otherwise, the corresponding data in the blockage information table is deleted. If it is not the first numbered branch, then perform a union of branches of the same order; After processing, return to the same-order branch set parsing module.
[0036] As a further limitation of the technical solution of the present invention, the criterion for determining the non-first numbered branch is as follows: The current branch index is greater than 0; The blockage information table contains forward-association records; The host branch identifier is inconsistent with the current branch.
[0037] The beneficial effects of this invention lie in its ability to comprehensively and meticulously acquire various types of information from the graphical program by parsing the graphical programming program according to a hierarchical structure of program-network segment-line-component grid and establishing attribute mapping for each component grid. This ensures that no key elements are missed during the conversion process, improving the comprehensiveness of the conversion. Parsing the network segment from left to right obtains various information tables and determines the 0th-order branch, providing a clear structural foundation for subsequent branch parsing. A series of steps, including parsing branches of the same order, parsing the set of branches of the same order, and processing branches according to the blocking information table, form a complete and systematic conversion process. This process can adapt to various complex graphical program structures, has good scalability, and is easy to maintain and modularize, effectively solving the shortcomings of existing conversion methods in terms of comprehensiveness, scalability, maintainability, and modularity. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a schematic flowchart illustrating a method according to an embodiment of the present invention.
[0040] Figure 2 This is a diagram of the graphical language mapping data structure of the present invention.
[0041] Figure 3 Mind map for graphical language protocols.
[0042] Figure 4 Mind map of text language protocols.
[0043] Figure 5 This is a logic diagram for converting text language in an embodiment of the present invention. Detailed Implementation
[0044] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings of the specific embodiments. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0045] like Figure 1 As shown, this embodiment of the invention provides a method for converting a graphical language into a text editing language, including the following steps: S1. The graphical programming program is parsed according to the hierarchical structure of program-network segment-line-component grid, and an attribute mapping is established for each component grid. Through this hierarchical parsing and attribute mapping, various information in the graphical programming program can be fully obtained, providing a solid foundation for subsequent conversion work and ensuring the comprehensiveness of the conversion.
[0046] S2. Based on the attribute mapping, parse the network segment from left to right to obtain network segment information, branch summary table, blocking information summary table and error information table, and determine the 0th order branch according to the number of extension lines; this helps to initially sort out the structure of the graphical program and prepare for subsequent branch parsing. S3. Perform the steps of parsing the same-order branches for each 0th-order branch, wherein the steps of parsing the same-order branches include: Confirm the header elements of all branches in the current stage; If multiple right-leader forks are detected in the branch, the steps for parsing branches of the same order are recursively called to start parsing the next order branch; otherwise, jump to step S4. This recursive parsing method can adapt to complex graphical program structures, ensuring that all branches are processed correctly.
[0047] S4. The steps for performing parsing of the same-order branch set include: Traverse the current branch, perform single-branch analysis on each branch, and perform one of the following operations based on the result of the single-branch analysis: If branches need to be merged, the branch merge rules are invoked to perform the processing and the branch master table is updated; If the branch is not unified, return to step S3 to perform the same-order branch parsing step and re-parse the branch of the current order; the branch not being unified means that the branch has a right lead fork; If the waiting mechanism is triggered, proceed to step S5; By employing multiple branch merging rules, the method can flexibly handle branch merging requirements under different circumstances, improving its adaptability and comprehensiveness. This cyclical processing mechanism ensures that all branches are correctly merged, avoiding omissions or errors. Through the handling of special composite components, the method can better adapt to complex graphical program logic, improving its comprehensiveness and accuracy.
[0048] S5. Based on the blockage information table, process branches of the same or different order.
[0049] In this embodiment of the invention, the program in the hierarchical structure contains multiple network segments, each network segment contains multiple rows of elements, each row contains multiple element cells, and each element cell has an independent set of attributes.
[0050] In some embodiments, in step S3, after confirming the head elements of all branches at the current level in the same-order branch parsing step, the following is included: For each branch, a branch data structure is constructed. The data structure includes a list of text statements, real-time cursor position, forward association information, waiting point mapping, host branch identifier, list of completed waiting points, block identifier, composite element identifier, and end marker.
[0051] The steps for parsing same-order branch sets also include: When a special composite element is detected during the parsing process, the threshold for traversing columns is limited to the final column of the current branch; When the set conditions are met simultaneously, it is determined that the current branch has not ended, and the reference parameter status is changed to true; the set conditions include: the current branch has not been unified, the current branch has not terminated, the current branch has no waiting points of the same level, or the current branch has no waiting points of different levels.
[0052] Here, the branch merging rules include one of the following processing methods: Union: Changes the preceding branch header text statement to a header statement, and processes the following branch text statement; Concatenation and merging: directly merge text statements or add ANDSTK block identifiers; MPS Merging: Merge text statements according to the MPS-MRD-MPP structure; Special composite element processing: Combine and replace branch text and delete redundant branches.
[0053] In some embodiments, the single-branch parsing step includes: Traverse the components from the head column of the branch, updating row attributes and component status in real time, and performing corresponding processing based on the component type and status; specifically as follows: For valid components, update the text language and status information; For terminating components, process and return; For components with vertical lines, perform left / right lead checks; When the left lead check shows a valid left lead, it is determined that there is a blockage waiting; When multiple valid right leads are found during the right lead check, the steps for parsing the same-order branch in S3 are recursively called to start parsing the next-order branch.
[0054] Accordingly, the trigger waiting processing mechanism includes: When location and parent branch information are detected in the overall blocking information table, one of the following processing methods shall be adopted: If the branches are of the same level, perform a union operation and merge them into the previous branch, then decrement the branch number by 1. If the branches are of different orders, check the number of waiting points in the parent branch. If the number is 1, report an error and backtrack directly; if the number is not 1, delete the corresponding data in the blockage information table. If it is not the first branch, then perform a union of branches of the same order; After processing is complete, return to step S4, which involves parsing the same-order branch set.
[0055] In addition, in this embodiment of the invention, the specific processing rules in S5 include: When the branches are of the same level, perform a union operation and merge the branches into the previous branch; When the branches are of different orders, if the number of waiting points in the parent branch is 1, an error is reported and the data is returned; otherwise, the corresponding data in the blockage information table is deleted. If it is not the first numbered branch, then perform a union of branches of the same order; After processing is complete, return to step S4.
[0056] The criteria for determining non-first-number branches are as follows: The current branch index is greater than 0; The blockage information table contains forward-association records; The host branch identifier is inconsistent with the current branch.
[0057] Specifically, the graphical language mapping data structure diagram is as follows: Figure 2 As shown, based on the data structure family of program-network segment-line-component grid (various attributes), each component grid is mapped during the graphical programming process to prepare for the logical processing of the converted text programming language; In this embodiment of the invention, the graphical programming language maps data structures to text-based programming language logic. The graphical language protocol mind map is shown below. Figure 3 As shown in the mind map, the text language protocol is as follows: Figure 4 As shown, this invention adopts a tree-like hierarchical structure and a callback-based normalization approach. For example... Figure 5 As shown, the specific method is as follows: (1) Start parsing the network segment (accompanying parameters include network segment information (graphics), branch summary table (text), blocking information summary table (the concept of blocking and waiting, position + parent branch), and error information table). From the left lead to the right, confirm the number of extension lines, which is the 0th order branch. Then enter the same order branch parsing function and return the data (including error information), which is the final data.
[0058] (2) The same-order branch parsing function includes confirming the head of each branch (i.e., the first valid element), then performing branch set parsing, and then returning the data. (The branch data structure includes a list of text statements, a real-time cursor (starting from the first valid element), forward association (order, branch number), waiting point Map<row, column>, host branch (different orders are temporarily suspended from merging and the corresponding host branch needs to be stored), a list of completed but different order waiting points, whether it is a block, whether there is a normal composite element, and an end flag (0 for non-normal, 1 for normal termination, 2 for special composite elements)).
[0059] (3) The parsing function of the same-order branch set first traverses each branch for processing. When it returns to normal, do not rush to process the next branch. It needs to perform condition checks (1. If a special composite element is found in the branch retrieval, the threshold of the traversal column needs to be changed to the current branch's final column; 2. If the conditions (the current branch is not unified, the current branch is not terminated, the current branch has no same-order waiting, the current branch has no different-order waiting) are met at the same time, the current branch has not ended. Change the reference bool parameter status to true (enter directly from the right lead line, and then release it to false) and enter the current branch again according to the current point of the branch traversal column). After the normal traversal of the branches is completed, a second parsing is required to parse the branch summary table (text). (First, check if there is a reverse flow error in the current order in the blocking information summary table. Then confirm whether the current order branch is unified into a branch: if it has been unified, check if there is a waiting point in the branch and merge it into the branch before the current branch in the blocking summary table, and then perform the serial merging with the branch before the current branch; if there are multiple branches that have not been unified, there are two cases: special composite element merging and multi-output merging + forward serial merging).
[0060] (4) Parallel / Parallel Block Merging: For ordinary parallel merging, the header text statement of the preceding branch needs to be changed to a header statement; when the text statement of the following branch is 1 statement, it should be changed to an OR statement, and when it is greater than 1, the header text statement should be changed to a header statement. After merging the text, an ORSTK block OR statement identifier should be added. Then update the data of the preceding branch and delete the following branch.
[0061] Serialization / Serial Block Merging: No header statement changes are required. Subsequent element units can be directly appended to the text statement. If the subsequent element is a block, an ANDSTK block must be added and identified. Then update all data in the previous branch and delete the subsequent branch.
[0062] MPS Multi-Output Merging: The key text statements MPS, MRD, and MPP are merged based on the following: MPS --- n * branch single text statements (optional) + branch multi-text statements (required) --- n * (MRD --- single branch text statements) --- MPP --- the final branch text statement. The MRD portion is unnecessary if there are insufficient branches. Other data does not need to be moved; it is retained in the first branch, and deleted from other branches.
[0063] Special composite element handling: If the process can be scheduled here, it means the parsing is normal. You only need to replace the text statement with the first branch text by combining the second branch text, the first branch text, and the special composite element text, and then delete the second branch.
[0064] (5) Single-branch parsing: Based on the column at the head of the branch, the elements are traversed and processed, and the row attributes are changed in real time. The following points are considered when traversing specific elements: 1. Valid elements: The text language, status and other information need to be updated, the processing and return of the terminated element are terminated, and the waiting check is triggered (check if the blocking information table exists at this position) (explained by (6)); 2. Then the element needs to check the vertical line. If there is a vertical line, the left and right leads are checked. If there is a valid left lead in the left lead check, there is definitely a blocking wait. It is necessary to return and continue processing the next branch until the waiting check is triggered and unified; If there is a single valid right lead in the right lead check, the position is directly updated and the subsequent steps are taken. If there are multiple valid right leads, the next level branch needs to be opened to perform the same level branch parsing function, and then the returned data is conditionally processed (1. Detect that there is a waiting point in this branch). 1. If the first branch is of the same level, return to the upper level to execute the next branch; 2. If the end flag of this branch is complete, return to the upper level to execute the next branch; 3. If this branch (I) has a completed but different level waiting point, it means that it is related to the previous level branch. Directly follow the previous branch and merge (because it has already been unified and connected forward). The branch count is decremented by 1. Then check if there is a waiting point in the current branch, indicating that there is still waiting. It needs to be returned to run the next branch. If there is no waiting point, return to the logic and enter this branch to continue; (II) If there is no completed but different level waiting point, it means that there is no relationship. Directly update the traversal position and set the state to true. Directly check the right lead to continue. Determine whether to continue or return to the upper level.
[0065] (6) Triggering the waiting mechanism: In the branch master table (text) data structure, the branch data structure defines forward related branches, a waiting point list (used when it is a parent branch (subordinate left-pointing branch), and a host branch (the parent branch of this branch). When parsing a specific element, the blocking information master table position + parent branch is triggered, indicating that this element belongs to the valid left-pointing branch of this parent branch. Then, the parent branch and this branch are processed in two cases: those of the same level and those of different levels. After processing, the process directly returns to the previous level. (I) Same order, perform a union and merge with the previous branch, branch number -1, determine if there is no waiting point in this branch, indicating that it has been unified and needs to be connected to the next branch (if there is a forward associated main branch, return directly to the previous level, if the 0th order branch directly updates the traversal position and sets the state to true, directly check the right lead to connect to the next branch), (II) Different order, check if the number of waiting points of the triggered parent branch is 1, directly report an error and return to the previous branch, because it is impossible for the two branches to be of different order; delete the corresponding data in the blocked branch table; then determine if the branch number is not the first branch, perform a union and merge with the previous branch of the same order, branch number -1) after processing, return directly to the previous level.
[0066] This invention also provides an apparatus for converting graphical language into text editing language, including a data structure parsing module, a network segment parsing module, a same-order branch parsing module, a same-order branch set parsing module, and a branch processing module; The data structure parsing module is used to parse the graphical programming program according to the hierarchical structure of program-network segment-line-component grid, and to establish attribute mapping for each component grid; The network segment parsing module is used to parse network segments from left to right based on the attribute mapping, obtain network segment information, branch summary table, blocking information summary table and error information table, and determine the 0th order branch according to the number of extension lines. The same-order branch resolution module is used to perform the same-order branch resolution steps for each 0th-order branch. The same-order branch resolution steps include: Confirm the header elements of all branches in the current stage; If multiple right-leader forks are detected in a branch, the same-order branch parsing module is recursively called to start parsing the next-order branch; otherwise, the same-order branch set parsing module is triggered. The same-order branch set parsing module is used to perform the steps of same-order branch set parsing, including: Traverse the current branch, perform single-branch analysis on each branch, and perform one of the following operations based on the result of the single-branch analysis: If branches need to be merged, the branch merge rules are invoked to perform the processing and the branch master table is updated; If the branch is not unified, return to the same-order branch parsing module to perform the same-order branch parsing steps and re-parse the current-order branch; the branch not unified means that the branch has a right lead fork; If the waiting mechanism is triggered, the branch processing module will be activated. The branch processing module is used to process branches of the same or different levels based on the blockage information table.
[0067] In this embodiment of the invention, the program in the hierarchical structure contains multiple network segments, each network segment contains multiple rows of elements, each row contains multiple element cells, and each element cell has an independent set of attributes.
[0068] In some embodiments, the same-level branch parsing module is also used to construct a branch data structure for each branch. The content of the data structure includes a list of text statements, real-time cursor position, forward association information, waiting point mapping, host branch identifier, list of completed waiting points, block identifier, composite element identifier, and end marker.
[0069] In some embodiments, the same-order branch set parsing module is also used to limit the traversal column threshold to the current branch's final column when a special composite element is detected during the parsing process; when the set conditions are met simultaneously, it is determined that the current branch has not ended, and the reference parameter status is changed to true; the set conditions include: the current branch has not been unified, the current branch has not terminated, the current branch has no same-order waiting points, or the current branch has no different-order waiting points.
[0070] In some embodiments, the branch merging rule includes one of the following processing methods: Union: Changes the preceding branch header text statement to a header statement, and processes the following branch text statement; Concatenation and merging: directly merge text statements or add ANDSTK block identifiers; MPS Merging: Merge text statements according to the MPS-MRD-MPP structure; Special composite element processing: Combine and replace branch text and delete redundant branches.
[0071] In some embodiments, the steps of the same-order branch set parsing module performing single-branch parsing include: Traverse the components from the head column of the branch, updating row attributes and component status in real time, and performing corresponding processing based on the component type and status; specifically as follows: For valid components, update the text language and status information; For terminating components, process and return; For components with vertical lines, perform left / right lead checks; When the left lead check shows a valid left lead, it is determined that there is a blockage waiting; When multiple valid right leads are found during the right lead check, the same-order branch parsing module is recursively called to remember the same-order branch parsing steps and to start the next-order branch parsing.
[0072] In some embodiments, the trigger wait processing mechanism includes: When location and parent branch information are detected in the overall blocking information table, one of the following processing methods shall be adopted: If the branches are of the same level, perform a union operation and merge them into the previous branch, then decrement the branch number by 1. If the branches are of different orders, check the number of waiting points in the parent branch. If the number is 1, report an error and backtrack directly; if the number is not 1, delete the corresponding data in the blockage information table. If it is not the first branch, then perform a union of branches of the same order; After processing is complete, return to the same-order branch set parsing module to execute the same-order branch set parsing steps.
[0073] In some embodiments, the specific processing rules of the branch processing module include: When the branches are of the same level, perform a union operation and merge the branches into the previous branch; When the branches are of different orders, if the number of waiting points in the parent branch is 1, an error is reported and the data is returned; otherwise, the corresponding data in the blockage information table is deleted. If it is not the first numbered branch, then perform a union of branches of the same order; After processing, return to the same-order branch set parsing module.
[0074] The criteria for determining non-first-number branches are as follows: The current branch index is greater than 0; The blockage information table contains forward-association records; The host branch identifier is inconsistent with the current branch.
[0075] Although the present invention has been described in detail with reference to the accompanying drawings and preferred embodiments, the present invention is not limited thereto. Various equivalent modifications or substitutions can be made to the embodiments of the present invention by those skilled in the art without departing from the spirit and essence of the invention, and such modifications or substitutions should all be within the scope of the present invention. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should also be covered within the protection scope of the present invention.
Claims
1. A method for converting a graphical language into a text editing language, characterized in that, Includes the following steps: S1. Parse the graphical programming program according to the hierarchical structure of program-network segment-line-component grid, and establish attribute mapping for each component grid; S2. Based on the attribute mapping, parse the network segment from the left lead to the right to obtain network segment information, branch summary table, blocking information summary table and error information table, and determine the 0th order branch according to the number of extension lines; S3. Perform the steps of parsing the same-order branches for each 0th-order branch, wherein the steps of parsing the same-order branches include: Confirm the header elements of all branches in the current stage; If multiple right-leader forks are detected in the branch, the steps for parsing branches of the same order are recursively called to start parsing the next order branch; otherwise, jump to step S4. S4. The steps for performing parsing of the same-order branch set include: Traverse the current branch, perform single-branch analysis on each branch, and perform one of the following operations based on the result of the single-branch analysis: If branches need to be merged, the branch merge rules are invoked to perform the processing and the branch master table is updated; If the branch is not unified, return to the step of resolving the branch of the same level and re-resolve the branch of the current level; the branch not being unified means that the branch has a right lead fork; If the waiting mechanism is triggered, proceed to step S5; S5. Based on the blockage information table, process branches of the same or different order.
2. The method for converting graphical language to text editing language according to claim 1, characterized in that, The program in the hierarchical structure contains multiple network segments, each network segment contains multiple rows of elements, each row contains multiple element cells, and each element cell has an independent set of attributes.
3. The method for converting graphical language into text editing language according to claim 1 or 2, characterized in that, In S3, the steps for resolving branches of the same order, after confirming the head elements of all branches of the current order, include: For each branch, a branch data structure is constructed. The data structure includes a list of text statements, real-time cursor position, forward association information, waiting point mapping, host branch identifier, list of completed waiting points, block identifier, composite element identifier, and end marker.
4. The method for converting graphical language to text editing language according to claim 3, characterized in that, The steps for parsing same-order branch sets also include: When a special composite element is detected during the parsing process, the threshold for traversing columns is limited to the final column of the current branch; When the set conditions are met simultaneously, it is determined that the current branch has not ended, and the reference parameter status is changed to true; the set conditions include: the current branch has not been unified, the current branch has not terminated, the current branch has no waiting points of the same level, or the current branch has no waiting points of different levels.
5. The method for converting graphical language to text editing language according to claim 1, characterized in that, The branch merging rules include one of the following processing methods: Union: Changes the preceding branch header text statement to a header statement, and processes the following branch text statement; Concatenation and merging: directly merge text statements or add ANDSTK block identifiers; MPS Merging: Merge text statements according to the MPS-MRD-MPP structure; Special composite element processing: Combine and replace branch text and delete redundant branches.
6. The method for converting graphical language to text editing language according to claim 3, characterized in that, The steps of the single-branch parsing include: Traverse the components from the head column of the branch, updating row attributes and component status in real time, and performing corresponding processing based on the component type and status; specifically as follows: For valid components, update the text language and status information; For terminating components, process and return; For components with vertical lines, perform left / right lead checks; When the left lead check shows a valid left lead, it is determined that there is a blockage waiting; When multiple valid right leads are found during the right lead check, the steps for parsing the same-order branch in S3 are recursively called to start parsing the next-order branch.
7. The method for converting graphical language to text editing language according to claim 1, characterized in that, The trigger waiting processing mechanism includes: When location and parent branch information are detected in the overall blocking information table, one of the following processing methods shall be adopted: If the branches are of the same level, perform a union operation and merge them into the previous branch, then decrement the branch number by 1. If the branches are of different orders, check the number of waiting points in the parent branch. If the number is 1, report an error and backtrack directly; if the number is not 1, delete the corresponding data in the blockage information table. If it is not the first branch, then perform a union of branches of the same order; After processing is complete, return to step S4, which involves parsing the same-order branch set.
8. The method for converting a graphical language into a text editing language according to claim 1, characterized in that, The specific processing rules in S5 include: When the branches are of the same level, perform a union operation and merge the branches into the previous branch; When the branches are of different orders, if the number of waiting points in the parent branch is 1, an error is reported and the data is returned; otherwise, the corresponding data in the blockage information table is deleted. If it is not the first numbered branch, then perform a union of branches of the same order; After processing is complete, return to step S4.
9. The method for converting a graphical language into a text editing language according to claim 8, characterized in that, The criteria for determining non-first-number branches are as follows: The current branch index is greater than 0; The blockage information table contains forward-association records; The host branch identifier is inconsistent with the current branch.
10. A device for converting graphical language into text editing language, characterized in that, It includes a data structure parsing module, a network segment parsing module, a same-order branch parsing module, a same-order branch set parsing module, and a branch processing module; The data structure parsing module is used to parse the graphical programming program according to the hierarchical structure of program-network segment-line-component grid, and to establish attribute mapping for each component grid; The network segment parsing module is used to parse network segments from left to right based on the attribute mapping, obtain network segment information, branch summary table, blocking information summary table and error information table, and determine the 0th order branch according to the number of extension lines. The same-order branch resolution module is used to perform the same-order branch resolution steps for each 0th-order branch. The same-order branch resolution steps include: Confirm the header elements of all branches in the current stage; If multiple right-leader forks are detected in a branch, the same-order branch parsing module is recursively called to start parsing the next-order branch; otherwise, the same-order branch set parsing module is triggered. The same-order branch set parsing module is used to perform the steps of same-order branch set parsing, including: Traverse the current branch, perform single-branch analysis on each branch, and perform one of the following operations based on the result of the single-branch analysis: If branches need to be merged, the branch merge rules are invoked to perform the processing and the branch master table is updated; If the branch is not unified, return to the same-order branch parsing module to perform the same-order branch parsing steps and re-parse the current-order branch; the branch not unified means that the branch has a right lead fork; If the waiting mechanism is triggered, the branch processing module will be activated. The branch processing module is used to process branches of the same or different levels based on the blockage information table.