A method for automatically generating configuration programs from SAMA diagrams

Through the improved DT-DETR model and graph theory algorithm, the legend and line segment information in the SAMA diagram are automatically processed, which solves the problem of manual intervention required during the conversion process of existing tools, realizes fast and accurate configuration program generation, and improves the design and implementation efficiency of control systems.

CN118626072BActive Publication Date: 2025-09-09HANGZHOU DIANZI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410659099.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2025-09-09
Estimated Expiration
2044-05-27

AI Technical Summary

Technical Problem

Existing automation tools require manual intervention when converting SAMA diagrams into configuration programs. They are difficult to handle complex logical relationships and lack unified standards, resulting in insufficient design efficiency and accuracy.

Method used

The improved DT-DETR model is used to identify legends in SAMA diagrams. Graph theory algorithms and geometric calculations are combined to automatically process legends and line segment information, provide error correction and connection relationship establishment, and finally convert them into XML format for storage.

Benefits of technology

It realizes the rapid and accurate conversion from SAMA diagram to configuration program, reduces the workload of engineers, and improves the design and implementation efficiency of control systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626072B_ABST
    Figure CN118626072B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for automatically generating a configuration program based on a SAMA diagram, comprising the following steps: Step 1, preprocessing process: identifying and parsing SAMA diagram legend files and predefined legend code segment files from different sources, matching the legends and code segments, and saving them as a component library; Step 2, engineering file parsing and information extraction: reading a real SAMA diagram, parsing the engineering file of the SAMA diagram, and obtaining legend and line segment information; Step 3, error checking and correction: analyzing the layout and structure in the SAMA diagram and providing correction prompts to correct errors; Step 4, identifying the connection relationship between each legend in the SAMA diagram and saving it as a graph-like structure; Step 5, traversing the graph-like structure, converting the converted graph-like structure into XML format, and storing it. This method can convert a SAMA diagram into a corresponding configuration program more quickly and accurately, thereby reducing the workload of engineers and improving the design and implementation efficiency of control systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automated control technology, and in particular to the design and implementation of control systems in the field of industrial automation. Specifically, it relates to a method for automatically generating a configuration program based on a SAMA diagram, which is used for the design and implementation of automated control systems. Background Art

[0002] Control system design and implementation are crucial in industrial automation. Traditionally, engineers have relied on manual programming to implement control system functionality. SAMA (Sequential Function Chart and Function Block Diagram) diagrams are a commonly used tool for describing control logic and functionality. However, manual programming has several drawbacks, such as being time-consuming, error-prone, and difficult to maintain.

[0003] With the advancement of computer technology, the use of automated tools is becoming increasingly prevalent. These tools can significantly improve the efficiency and accuracy of control system design. Currently, some automated tools are commercially available that can convert graphical descriptions into corresponding configuration programs. However, these existing tools typically require manual user intervention, cannot fully automate the conversion, and have limited capabilities for handling complex logical relationships. Furthermore, SAMA diagrams, a commonly used graphical description method, lack a unified standard across different instrumentation companies, which complicates the development and application of automated tools. Furthermore, the drawing process can involve multiple lines merging, which can make it difficult for automated tools to interpret graphical descriptions, thus hindering the generation of configuration programs. Therefore, while automated tools offer certain advantages in improving control system design efficiency, they still require further improvement in handling complex logic and standards.

[0004] Therefore, a new method is needed to solve these problems and improve the efficiency and accuracy of control system design. The present invention is proposed to address this need and aims to provide an automated conversion method based on SAMA diagrams, which enables users to convert SAMA diagrams into corresponding configuration programs more quickly and accurately, thereby reducing the workload of engineers and improving the efficiency of control system design and implementation. Summary of the Invention

[0005] In view of the shortcomings of the existing technology, the present invention proposes a method for automatically generating configuration programs based on SAMA diagrams. Users can convert SAMA diagrams into corresponding configuration programs more quickly and accurately, thereby reducing the workload of engineers and improving the design and implementation efficiency of control systems.

[0006] In order to solve the above technical problems, the technical solution of the present invention is:

[0007] A method for automatically generating a configuration program based on a SAMA diagram comprises the following steps:

[0008] Step 1: Preprocessing: Identify and parse SAMA diagram legend files and predefined legend code segment files from different sources, match the legends and code segments, and save them as components.

[0009] Step 2: Project file parsing and information extraction: Read the real SAMA diagram and parse the project file of the SAMA diagram to obtain the legend and line segment information;

[0010] Step 3, Error checking and correction: Analyze the layout and structure of the SAMA diagram and provide correction hints to correct errors;

[0011] Step 4: Establish and save connection relationships: Identify the connection relationships between the various legends in the SAMA diagram and save them as a graph structure, including nodes and connection lines;

[0012] Step 5: Convert to XML for storage: traverse the graph structure, convert the data of the graph structure into XML format, and store it.

[0013] Preferably, when matching the legend with the code segment in step 1, the legend is identified by the improved DT-DETR model to obtain different types of legends, and the legends and corresponding code segments are stored in the component library according to type classification.

[0014] As the preferred model, the improved DT-DETR model mainly includes the following optimizations: the RepGhostELAN module is designed to replace the original basicblock module. The introduction of the RepGhostELAN module reduces the number of network parameters and computational complexity by designing a lightweight network, so that the model can significantly improve the computational efficiency while ensuring recognition accuracy; the BiForme attention mechanism is introduced to pay more attention to the feature information related to the SAMA diagram legend at different scales. The BiForme attention mechanism captures the key features of the legend at multiple scales while maintaining its lightweight, which does not bring significant computational burden to the model, ensuring the efficiency and accuracy of the model; MPDIou is used to replace the original GIoU. The introduction of MPDIou improves the robustness of the detection model for SAMA diagram legend recognition, so that the model can still accurately recognize various legends in complex backgrounds. Through the above improvements, the DT-DETR model not only improves the accuracy and robustness when identifying legends in SAMA diagrams, but also significantly reduces the consumption of computing resources and improves the overall recognition efficiency.

[0015] Preferably, in step 2, the method for parsing the engineering file of the SAMA diagram is:

[0016] First, traverse all entity information in the SAMA graph;

[0017] Then, based on the specific identifiers or attributes of the entity information, identify the legend. The specific steps are as follows:

[0018] a. Analyze each entity information and extract its type, identifier and other relevant attributes;

[0019] b. Match the extracted information with a predefined component library to determine whether the entity information belongs to a specific component;

[0020] Secondly, extract the relevant attributes and functional descriptions of the identified legends, including but not limited to name, type, connection relationship, etc.;

[0021] Finally, based on the identified legend, generate the legend and line segment information. The specific steps are as follows:

[0022] a. Draw the corresponding legend according to its position and connection relationship;

[0023] b. Extract and draw the connecting line segments between the legends to complete the analysis of the entire SAMA diagram.

[0024] Preferably, the entity information includes graphic elements, text descriptions, and block types.

[0025] Preferably, in step 2, in the process of parsing the engineering file of the SAMA diagram, the basic graphics that are not legends are combined according to the graphics combination algorithm, and the legend obtained after the combination is compared with the component library. If they match, the combination is saved.

[0026] Preferably, in step 3, the analysis method of the layout and structure in the SAMA diagram is:

[0027] Use data structures and algorithms in various programming languages ​​to check whether each recognized legend already exists in the component library to determine the recognition status of the legend in the system. Specifically, you can use data structures such as hash tables or sets to store the existing legends in the component library, and check each recognized legend during the recognition process to see if it exists in the component library;

[0028] Use graph theory algorithms to check for possible multiple segments between two legends to ensure the connection is clear and accurate. Specifically, you can use algorithms such as depth-first search (DFS) or breadth-first search (BFS), starting from one legend and gradually traversing its connected segments to determine whether there are multiple segments.

[0029] The point-to-line-segment distance formula from geometric calculations is used to analyze the line segment position and determine whether the line segment is on the corresponding legend. Specifically, for a given line segment and legend, the shortest distance from each point on the line segment to the legend is first calculated, and then these distances are compared with a preset threshold. If the shortest distance is within the threshold range, the line segment can be considered to be on the legend; otherwise, it is marked as an error.

[0030] Preferably, the specific method of step 4 is as follows:

[0031] Step 4.1: For the identified connection relationships, clearly mark the input and output of each legend to facilitate subsequent logic processing and program generation;

[0032] Step 4.2: Save the attribute information of each connection for more detailed analysis and optimization in subsequent processing;

[0033] Step 4.3: Visualize the connection relationship;

[0034] Step 4.4: For each legend input and output, perform a matching check to ensure that the data types and formats of the input and output ports match to avoid incompatible or incorrect connections.

[0035] Preferably, the attribute information includes connection type, connection mode and connection channel, wherein the connection type includes logical connection and data stream connection, and the connection mode includes serial and parallel.

[0036] Preferably, in step 3, the correction step includes error correction and prompting based on the learned knowledge base and rules.

[0037] Preferably, the error checking and correction step further includes automatically arranging and optimizing the identified graphics to improve the efficiency and performance of the configuration program.

[0038] Preferably, the steps of establishing and saving the connection relationship further include verifying and optimizing the identified connection relationship to ensure the correctness and stability of the converted configuration program.

[0039] Preferably, the step of converting to XML storage further includes compressing and encrypting the generated XML file to protect intellectual property rights and program security.

[0040] The present invention has the following characteristics and beneficial effects:

[0041] Using this technical solution, the system leverages precise identification and analysis of SAMA diagrams during preprocessing, as well as in-depth analysis and information extraction of SAMA diagram engineering files, to accurately capture legend and line segment information within SAMA diagrams. By clearly identifying legends and analyzing the position of line segments, the system can determine the connections between legends and line segments, including those involving multiple segments. This allows users to more quickly and accurately convert SAMA diagrams into corresponding configuration programs. This process significantly reduces the workload for engineers and improves the efficiency of control system design and implementation. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0043] Figure 1 A flowchart of a method for automatically generating a configuration program from a SAMA diagram provided in one embodiment of the present application;

[0044] Figure 2 A flowchart of the engineering file parsing and information extraction process provided in one embodiment of the present application;

[0045] Figure 3 A flowchart of the graphic combination and correction provided in one embodiment of the present application;

[0046] Figure 4 A flowchart of establishing and saving a connection relationship according to an embodiment of the present application;

[0047] Figure 5 SAMA diagram legend file provided for an embodiment of the present application;

[0048] Figure 6 This is a typical example of a SAMA diagram provided in one embodiment of the present application. DETAILED DESCRIPTION

[0049] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0050] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings.

[0051] On the contrary, the present invention covers any alternatives, modifications, equivalents, and solutions that fall within the spirit and scope of the present invention as defined by the claims. Furthermore, to facilitate a better understanding of the present invention, certain specific details are described in detail below in the detailed description of the present invention. Those skilled in the art will be able to fully understand the present invention without these details.

[0052] In view of the limitations and deficiencies of the prior art in converting SAMA diagrams into configuration programs, the present invention proposes an innovative solution. The following are specific embodiments: Figure 1 , shown is a flowchart of a method for automatically generating a configuration program from a SAMA diagram of the present application, the method comprising at least the following steps:

[0053] S1: Preprocessing

[0054] The input SAMA diagram legend files are scanned and analyzed one by one to accurately identify different types of legends, match the legends and code snippets, and store them in the component library by type. At the same time, the predefined legend code snippet files are read to ensure that they correspond to the component library.

[0055] Furthermore, when matching legends with code snippets, the improved DT-DETR model is used to identify legends, obtain different types of legends, and store the legends and corresponding code snippets in the component library by type classification. Specifically, the improved DT-DETR model mainly includes the following optimizations: the RepGhostELAN module is designed to replace the original basicblock module. The introduction of the RepGhostELAN module reduces the number of network parameters and computational complexity by designing a lightweight network, so that the model significantly improves the computational efficiency while ensuring recognition accuracy; the BiForme attention mechanism is introduced to pay more attention to feature information related to SAMA graph legends at different scales. The BiForme attention mechanism captures the key features of the legend at multiple scales while maintaining its lightweight, which does not bring a significant computational burden to the model, ensuring the efficiency and accuracy of the model; MPDIou is used to replace the original GIoU. The introduction of MPDIou improves the robustness of the detection model for SAMA graph legend recognition, allowing the model to accurately recognize various types of legends even in complex backgrounds. Through the above improvements, the DT-DETR model not only improves the accuracy and robustness when identifying legends in SAMA diagrams, but also significantly reduces the consumption of computing resources and improves the overall recognition efficiency.

[0056] S2: Engineering file parsing and information extraction

[0057] In-depth analysis of SAMA diagram engineering files, accurate extraction of various legends and line segment information, providing rich and reliable data support for subsequent system processing and analysis, ensuring accuracy and completeness.

[0058] Specifically, such as Figure 2 As shown, step S2 includes the following sub-steps:

[0059] S201: Traversing entity information

[0060] Traverse all entity information in the SAMA diagram one by one, which may include graphic elements, text descriptions, block types, etc. By traversing the entity information, the system can fully understand the structure and content of the SAMA diagram;

[0061] S202: Identify the legend

[0062] First, legends are identified. These legends typically have a specific appearance and functionality, representing various functional blocks or modules in the control system. During the identification process, the system extracts relevant attributes and functional descriptions for subsequent processing and identification.

[0063] S203: Processing basic graphics

[0064] Processing of non-legendary basic graphics. These basic graphics may include various shapes, lines, or other geometric elements that may not belong to the predefined legends. The system combines these basic graphics and compares them with the legend library. If a matching legend is found, the system saves the combination for subsequent use. This process helps identify and process the various graphic elements in the SAMA diagram, allowing for more accurate conversion into components and functional modules in the configuration program.

[0065] S3: Error checking and correction

[0066] The SAMA diagram's layout and structure are carefully analyzed to ensure the accuracy and rationality of the graphic combination. Correction prompts are then provided to guide the user in making the necessary corrections for any potential errors or irregularities, ensuring the final conversion is accurate. These correction prompts may include adjusting graphic position, replacing symbols, and optimizing logical relationships to maximize the quality and readability of the SAMA diagram.

[0067] Further, such as Figure 3 As shown, step S3 includes the following sub-steps:

[0068] S301: Component library status check

[0069] Check each legend one by one to verify whether it has been recorded in the component library. This step ensures that the system can correctly identify and process each block during processing, avoiding duplicate additions or processing of existing blocks.

[0070] Specifically, data structures and algorithms in various programming languages ​​are used to check whether each recognized legend already exists in the component library, so as to determine the recognition status of the legend in the system. Specifically, data structures such as hash tables or sets can be used to store the existing legends in the component library, and each recognized legend is checked during the recognition process to see whether it exists in the component library.

[0071] S302: Connection relationship analysis

[0072] Analyze the connections between the two legends in the SAMA diagram in detail, including any possible multiple line segments. The goal of this step is to ensure that the connections are clear and accurate to prevent confusion or errors in the transmission of information.

[0073] Specifically, we use graph theory algorithms to check for possible multiple line segments between two legends, ensuring the clarity and accuracy of the connection relationship. Specifically, we can use algorithms such as depth-first search (DFS) or breadth-first search (BFS), starting from one legend and gradually traversing its connected segments to determine whether there are multiple-headed line segments.

[0074] S303: Line segment position verification

[0075] The point-to-line distance formula used in geometric calculations analyzes the line segment position to determine whether the line segment is on the corresponding legend. For each line segment, its position is verified to match the corresponding block. The accuracy is determined by checking the shortest distance from each point on the line segment to the legend and then comparing these distances to a preset threshold. Any line segment that does not match the block is marked to identify and correct possible errors.

[0076] Specifically, for a given line segment and legend, we first calculate the shortest distance from each point on the line segment to the legend, and then compare these distances with a preset threshold. If the shortest distance is within the threshold, the line segment can be considered to be on the legend, otherwise it is marked as an error.

[0077] S304: Error correction suggestions

[0078] When errors are discovered, the system provides corrective suggestions. These suggestions may include adding unrecognized blocks to the component library or adjusting the position of line segments. These corrective actions help ensure the accuracy and consistency of graphics, improving the quality and efficiency of system processing.

[0079] S4: Establishing and saving connection relationships

[0080] The system identifies and establishes the connectivity relationships between components in the SAMA diagram. This process involves identifying the components in the diagram and determining the logical or data flow connections between them. The system stores these identified connectivity relationships as a graphical structure consisting of nodes and connecting lines. Nodes represent the functional blocks in the diagram, while connecting lines represent the connections between functional blocks. By storing these graphical structures of connectivity relationships, the system can better understand and describe the control logic of the SAMA diagram and provide the necessary data foundation for subsequent conversion and processing.

[0081] Further, such as Figure 4 As shown, step S4 includes the following sub-steps:

[0082] S401: Input and output identification

[0083] Process the identified connection relationships and clearly identify the input and output of each component. By identifying each connection, the system can more clearly understand the data flow between components, providing the necessary information for subsequent logic processing and program generation;

[0084] S402: Connection attribute record

[0085] The attribute information of each connection will be saved. This attribute information includes the connection type (such as logical connection, data flow connection), connection mode (serial, parallel), connection channel, etc. By recording this attribute information, the system can perform more detailed analysis and optimization, providing more reference basis in the subsequent processing process;

[0086] S403: Connection relationship visualization

[0087] Visualize the connection relationship. In addition to showing the connection relationship between function blocks, the system also displays the input and output ports of each connection. This visual display can directly show the data flow and logical relationship of the system, helping users better understand the structure and operation of the entire control system.

[0088] S404: Input and output matching check

[0089] Each component's input and output are checked for compatibility. By checking the data types and formats of input and output ports, the system ensures that they match, avoiding incompatible or incorrect connections. This compatibility check improves system stability and reliability.

[0090] S5: Convert to XML for storage

[0091] Based on predefined conversion rules, the system converts the identified SAMA diagrams and established connections into XML format and stores them. This process involves converting the individual function blocks of the SAMA diagram and the connections between them into a structured XML document. Storing the data in XML format facilitates subsequent processing, analysis, and sharing. The XML document contains all the key information about the SAMA diagram, including function block attributes, connection relationships, and layout, providing a crucial data foundation for generating and debugging configuration programs.

[0092] like Figure 5 Shown is the SAMA diagram legend file, which contains all the legends used in the project file.

[0093] like Figure 6 The following is a typical example in a SAMA diagram project file. Specifically, two numbers are input and multiplied by a multiplier. The output result is passed through a high-value signal monitor. If it exceeds a predefined threshold, an alarm is generated and a 5-second pulse is output.

[0094] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. It will be apparent to those skilled in the art that various changes, modifications, substitutions, and variations of these embodiments, including components, without departing from the principles and spirit of the present invention are still within the scope of protection of the present invention.

Claims

1. A method for automatically generating a configuration program based on a SAMA diagram, characterized in that: The steps include: Step 1: Preprocessing: Identify and parse SAMA diagram legend files and predefined legend code segment files from different sources, match the legends and code segments, and save them as components. When matching legends with code snippets, the target detection model is used to identify the legends, obtain different types of legends, and store the legends and corresponding code snippets in the component library according to type. The target detection model adopts the DT-DETR model as the backbone network and replaces the basicblock module in the DT-DETR model with the RepGhostELAN module to reduce the number of network parameters and computational complexity through a lightweight network. The BiForme attention mechanism is introduced after the RepGhostELAN module to capture key features related to the SAMA map legend at different scales. MPDIou replaces the GIoU in the DT-DETR model. Step 2: Project file parsing and information extraction: Read the real SAMA diagram and parse the project file of the SAMA diagram to obtain the legend and line segment information; The method for parsing the engineering file of the SAMA diagram is: First, all entity information in the SAMA graph is traversed, including legends, line segments, graphic elements, text descriptions, and block types; Then, the legend is identified based on the specific identification or attributes of the entity information; Secondly, extract the relevant attributes and functional descriptions of the identified legends, including name, type, and connection relationship; Finally, based on the identified legends, the legend and line segment information are generated: the corresponding legends are drawn according to the position and connection relationship of the legends; the connecting line segments between the legends are extracted and drawn to complete the analysis of the entire SAMA diagram Step 3, Error checking and correction: Analyze the layout and structure of the SAMA diagram and provide correction hints to correct errors; Step 4: Establish and save connection relationships: Identify the connection relationships between the various legends in the SAMA diagram and save them as a graph structure, including nodes and connection lines; Step 5: Convert to XML for storage: traverse the graph structure, convert the data of the graph structure into XML format, and store it.

2. The method for automatically generating a configuration program based on a SAMA diagram according to claim 1, wherein: In step 2, the method for identifying the legend is: Analyze each entity information and extract its type, identifier and other relevant attributes; The extracted information is matched with a predefined component library to determine whether the entity information belongs to a specific component.

3. The method for automatically generating a configuration program based on a SAMA diagram according to claim 1, wherein: In step 2, in the process of parsing the engineering file of the SAMA diagram, the basic graphics that are not legends are combined according to the graphics combination algorithm, and the legend obtained after the combination is compared with the component library. If they match, the combination is saved.

4. The method for automatically generating a configuration program based on a SAMA diagram according to claim 1, wherein: In step 3, the analysis method of the layout and structure in the SAMA diagram is: Using data structures and algorithms in any programming language to check whether each recognized legend already exists in the component library to determine the recognition status of the legend in the system; Use graph theory algorithms to check if there may be multiple line segments between two legends to ensure the connection relationship is clear and accurate; Use the distance formula from a point to a line segment in geometric calculations to analyze the position of the line segment and determine whether the line segment is on the corresponding legend.

5. The method for automatically generating a configuration program based on a SAMA diagram according to claim 4, characterized in that: The specific method of step 4 is as follows: Step 4.1: For the identified connection relationships, clearly mark the input and output of each legend to facilitate subsequent logic processing and program generation; Step 4.2: Save the attribute information of each connection for more detailed analysis and optimization in subsequent processing; Step 4.3: Visualize the connection relationship; Step 4.4: For each legend input and output, perform a matching check to ensure that the data types and formats of the input and output ports match to avoid incompatible or incorrect connections.

6. The method for automatically generating a configuration program based on a SAMA diagram according to claim 5, characterized in that: The attribute information includes connection type, connection mode and connection channel.

Citation Information

Patent Citations

  • Graphical logic control system, method and device and readable storage medium

    CN112462713A

  • Nuclear power DCS algorithm configuration logic diagram drawing system

    CN113703405A