技术领域Technical Field
本发明涉及自动化控制技术领域,特别是涉及了工业自动化领域中的控制系统设计与实现。具体指一种基于SAMA图自动生成组态程序的方法,用于自动化控制系统的设计和实施。The present invention relates to the field of automation control technology, and in particular to the design and implementation of control systems in the field of industrial automation, and specifically to a method for automatically generating a configuration program based on a SAMA diagram, which is used for the design and implementation of an automation control system.
背景技术Background Art
在工业自动化领域,控制系统设计与实施是至关重要的。传统上,工程师们通常依赖于手动编程来实现控制系统的功能。其中,SAMA(Sequential Function Chart andFunction Block Diagram)图是一种常用的工具,用于描述控制逻辑和功能。然而,手动编程存在一些缺点,例如耗时、容易出错以及难以维护等。In the field of industrial automation, control system design and implementation are crucial. Traditionally, engineers usually rely on manual programming to implement the functions of the control system. Among them, SAMA (Sequential Function Chart and Function Block Diagram) diagram is a commonly used tool to describe control logic and functions. However, manual programming has some disadvantages, such as time-consuming, error-prone, and difficult to maintain.
随着计算机科技的发展,自动化工具的使用日益普及。自动化工具可以大大提高控制系统设计的效率和精度。目前市面上已经存在一些自动化工具,可以将图形化的描述转换为相应的组态程序。然而,这些现有工具通常需要用户手动干预,不能完全自动化转换,并且对于复杂的逻辑关系处理能力有限。此外,SAMA图作为一种常用的图形化描述方法,在不同的仪表公司中缺乏统一的标准,这也给自动化工具的开发和应用带来了一定的难度。另外,在画图的过程中,可能会出现多线并线的问题,这会导致自动化工具在解析图形化描述时出现困难,进而影响到组态程序的生成。因此,尽管自动化工具在提高控制系统设计效率方面有一定优势,但在处理复杂逻辑和规范标准方面仍需要进一步改进。With the development of computer technology, the use of automation tools is becoming increasingly popular. Automation tools can greatly improve the efficiency and accuracy of control system design. At present, there are some automation tools on the market that can convert graphical descriptions into corresponding configuration programs. However, these existing tools usually require manual intervention from users, cannot be fully automated, and have limited processing capabilities for complex logical relationships. In addition, SAMA diagrams, as a commonly used graphical description method, lack unified standards among different instrument companies, which also brings certain difficulties to the development and application of automation tools. In addition, in the process of drawing, there may be problems with multiple lines being paralleled, which will cause difficulties for automation tools in parsing graphical descriptions, thereby affecting the generation of configuration programs. Therefore, although automation tools have certain advantages in improving the efficiency of control system design, they still need further improvement in handling complex logic and standard specifications.
因此,需要一种新的方法来解决这些问题,提高控制系统设计的效率和精度。本发明就是针对这一需求提出的,旨在提供一种基于SAMA图的自动化转换方法,使得用户能够更快速、准确地将SAMA图转换为相应的组态程序,从而降低了工程师的工作负担,提高了控制系统的设计和实施效率。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 demand and aims to provide an automatic conversion method based on SAMA diagram, so that users can convert SAMA diagram into corresponding configuration programs more quickly and accurately, thereby reducing the workload of engineers and improving the design and implementation efficiency of control systems.
发明内容Summary of the invention
本发明针对现有技术的不足,提出一种基于SAMA图自动生成组态程序的方法,用户可以更快速、更准确地将SAMA图转换为相应的组态程序,从而降低工程师的工作负担,提高了控制系统的设计和实施效率。In view of the deficiencies in the prior art, the present invention proposes a method for automatically generating a configuration program based on a SAMA diagram, so that users can convert the 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 the control system.
为了解决上述技术问题,本发明的技术方案为:In order to solve the above technical problems, the technical solution of the present invention is:
一种基于SAMA图自动生成组态程序的方法,包括如下步骤:A method for automatically generating a configuration program based on a SAMA diagram comprises the following steps:
步骤1、预处理过程:识别并解析不同源的SAMA图图例文件以及预定义的图例代码段文件,将图例和代码段进行匹配,并存为组件;Step 1, preprocessing process: 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;
步骤2、工程文件解析及信息提取:读取真实SAMA图,并解析该SAMA图的工程文件,获取图例和线段信息;Step 2: Engineering file analysis and information extraction: read the real SAMA diagram, analyze the engineering file of the SAMA diagram, and obtain the legend and line segment information;
步骤3、错误检查和修正:分析SAMA图中的布局和结构,并提供修正提示以改正错误;Step 3, Error checking and correction: Analyze the layout and structure in the SAMA diagram and provide correction hints to correct the errors;
步骤4、连接关系的建立和保存:识别SAMA图中各个图例之间的连接关系,将其保存为图状结构,包括节点和连接线;Step 4: Establish and save the connection relationship: Identify the connection relationship between each legend in the SAMA diagram and save it as a graph structure, including nodes and connection lines;
步骤5、转换成XML存储:遍历图状结构,将图状结构的数据转换为XML格式,并进行存储。Step 5: Convert to XML for storage: traverse the graph structure, convert the data of the graph structure into XML format, and store it.
作为优选,所述步骤1中将图例与代码段进行匹配时,通过改进的DT-DETR模型对图例进行识别,得到不同类型的图例,并按类型分类将图例以及对应的代码段存储到组件库中。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 the corresponding code segments are stored in the component library by type classification.
作为优选,改进的DT-DETR模型主要包括以下几个方面的优化:设计了RepGhostELAN模块替换原来的basicblock模块,RepGhostELAN模块的引入通过设计轻量化网络来降低网络的参数量和计算量,使得模型在保证识别精度的同时,大幅提升了运算效率;引入BiForme注意力机制,在不同尺度上更多地关注与SAMA图图例相关的特征信息,BiForme注意力机制通过在多尺度上捕捉图例的关键特征,同时保持了轻量级,不会给模型带来显著的计算负担,确保了模型的高效性和准确性;使用MPDIou替换原来的GIoU,MPDIou的引入提高了检测模型对SAMA图图例识别的鲁棒性,使得模型在复杂背景下仍能准确识别各类图例。通过上述改进,DT-DETR模型在识别SAMA图中的图例时,不仅提高了精度和鲁棒性,还显著降低了计算资源的消耗,提升了整体识别效率。As the preferred method, 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 ensure recognition accuracy while greatly improving the computational efficiency; 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, and does not bring significant computational burden to the model, thus 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 types of legends under complex backgrounds. Through the above improvements, the DT-DETR model not only improves the accuracy and robustness when identifying the legends in the SAMA diagram, but also significantly reduces the consumption of computing resources and improves the overall recognition efficiency.
作为优选,所述步骤2中,解析SAMA图的工程文件的方法为:Preferably, in step 2, the method for parsing the engineering file of the SAMA diagram is:
首先遍历SAMA图中所有的实体信息;First, traverse all entity information in the SAMA graph;
然后,根据实体信息的特定标识或属性,识别图例。具体步骤如下:Then, the legend is identified based on the specific identification or attributes of the entity information. The specific steps are as follows:
a.对每个实体信息进行分析,提取其类型、标识符及其他相关属性;a. Analyze each entity information and extract its type, identifier and other relevant attributes;
b.将提取的信息与预定义的组件库进行匹配,以确定实体信息是否属于某个特定的组件;b. Match the extracted information with the predefined component library to determine whether the entity information belongs to a specific component;
其次,提取所识别图例的相关属性和功能描述,包括但不限于名称、类型、连接关系等;Secondly, extract the relevant attributes and functional descriptions of the identified legends, including but not limited to name, type, connection relationship, etc.;
最后,基于识别出的图例,生成图例和线段信息。具体步骤如下:Finally, based on the identified legend, the legend and line segment information are generated. The specific steps are as follows:
a.根据图例的位置和连接关系,绘制相应的图例;a. Draw the corresponding legend according to the position and connection relationship of the legend;
b.提取并绘制图例之间的连接线段,以完成整个SAMA图的解析。b. Extract and draw the connecting line segments between the legends to complete the analysis of the entire SAMA diagram.
作为优选,所述实体信息包括图形元素、文本描述、块类型。Preferably, the entity information includes graphic elements, text descriptions, and block types.
作为优选,所述步骤2中,在解析SAMA图的工程文件的过程中,对于非图例的基本图形,根据图形组合算法将其进行组合,将组合后得到的图例与组件库进行比对,如果匹配,则将组合保存。Preferably, in step 2, in the process of parsing the engineering file of the SAMA diagram, basic graphics other than legends are combined according to a graphics combination algorithm, and the legend obtained after the combination is compared with the component library. If they match, the combination is saved.
作为优选,所述步骤3中,SAMA图中的布局和结构的分析方法为:Preferably, in step 3, the analysis method of the layout and structure in the SAMA diagram is:
使用各种编程语言中的数据结构和算法来检查每个识别的图例是否已经在组件库中存在,以确定该图例在系统中的识别状态。具体来说,可以利用哈希表(Hash Table)或者集合(Set)等数据结构,将组件库中已有的图例存储起来,并在识别过程中对每个识别的图例进行检查,看其是否存在于组件库中;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, data structures such as hash tables or sets can be used to store the existing legends in the component library, and during the recognition process, each recognized legend is checked to see whether it exists in the component library;
利用图论中的算法来进行检查两个图例之间可能存在多条线段,确保连接关系的清晰和准确。具体来说,可以使用深度优先搜索(DFS)或广度优先搜索(BFS)等算法,从一个图例出发,逐步遍历其连接的线段,以确定是否存在多头线段;Use graph theory algorithms to check if there are multiple line segments between two legends to ensure that the connection relationship is clear and accurate. Specifically, you can use algorithms such as depth-first search (DFS) or breadth-first search (BFS) to start from one legend and gradually traverse the connected line segments to determine whether there are multiple line segments.
使用几何计算中的点到线段的距离公式分析线段位置,确定线段是否在对应的图例上。具体来说,对于给定的线段和图例,首先计算线段上每个点到图例的最短距离,然后将这些距离与预设的阈值进行比较。如果最短距离在阈值范围内,则可以将该线段视为在图例上,否则将其标记为错误。The distance formula from a point to a line segment in geometric calculation 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 the 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.
作为优选,所述步骤4的具体方法如下:Preferably, the specific method of step 4 is as follows:
步骤4.1、对于识别出的连接关系,明确标识每个图例的输入和输出,以便后续的逻辑处理和程序生成;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;
步骤4.2、保存每个连接的属性信息,以便在后续处理中进行更详细的分析和优化;Step 4.2: Save the attribute information of each connection for more detailed analysis and optimization in subsequent processing;
步骤4.3、连接关系可视化;Step 4.3: Visualize the connection relationship;
步骤4.4、对于每个图例的输入和输出,进行匹配检查,确保输入端口和输出端口的数据类型和格式匹配,避免出现不兼容或错误的连接。Step 4.4: For each legend input and output, perform a matching check to ensure that the data types and formats of the input ports and output ports match to avoid incompatible or incorrect connections.
作为优选,所述属性信息包括连接类型、连接方式和连接通道。其中连接类型包括逻辑连接和数据流连接;连接方式包括串行和并行。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.
作为优选,步骤3中,修正步骤包括基于学习的知识库和规则进行错误修正和提示。Preferably, in step 3, the correction step includes error correction and prompting based on the learned knowledge base and rules.
作为优选,错误检查和修正步骤进一步包括对识别的图形进行自动排列和优化,以提高组态程序的效率和性能。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.
作为优选,连接关系的建立和保存步骤进一步包括对识别的连接关系进行验证和优化,以确保转换后的组态程序的正确性和稳定性。Preferably, the step of establishing and saving the connection relationship further includes verifying and optimizing the identified connection relationship to ensure the correctness and stability of the converted configuration program.
作为优选,转换成XML存储步骤进一步包括对生成的XML文件进行压缩和加密处理,以保护知识产权和程序的安全性。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.
本发明具有以下的特点和有益效果:The present invention has the following characteristics and beneficial effects:
采用上述技术方案,利用预处理过程中对SAMA图进行的精准识别和解析,以及对SAMA图工程文件的深度解析和信息提取,系统能够准确地获取SAMA图中的图例和线段信息。通过对图例的清晰识别和线段的位置分析,系统能够确定图例与线段之间的连接关系,包括多条线段的情况。这样,用户可以在转换为组态程序的过程中,更快速、更准确地将SAMA图转换为相应的组态程序。这一过程大大降低了工程师的工作负担,提高了控制系统的设计和实施效率。By adopting the above technical solution, the system can accurately obtain the legend and line segment information in the SAMA diagram by using the precise identification and analysis of the SAMA diagram in the preprocessing process, as well as the deep analysis and information extraction of the SAMA diagram engineering file. Through the clear identification of the legend and the position analysis of the line segment, the system can determine the connection relationship between the legend and the line segment, including the case of multiple line segments. In this way, the user can convert the SAMA diagram into the corresponding configuration program more quickly and accurately during the conversion to the configuration program. This process greatly reduces the workload of engineers and improves the design and implementation efficiency of the control system.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 creative labor.
图1为本申请一实施例提供的SAMA图自动生成组态程序方法流程框图;FIG1 is a flowchart of a method for automatically generating a configuration program for a SAMA diagram provided by an embodiment of the present application;
图2为本申请一实施例提供的工程文件解析及信息提取过程的流程框图;FIG2 is a flowchart of a process of engineering file parsing and information extraction provided by an embodiment of the present application;
图3为本申请一实施例提供的图形组合和修正的流程框图;FIG3 is a flowchart of a process of combining and modifying graphics provided by an embodiment of the present application;
图4为本申请一实施例提供的连接关系的建立和保存的流程框图;FIG4 is a flowchart of establishing and saving a connection relationship according to an embodiment of the present application;
图5为本申请一实施例提供的SAMA图图例文件;FIG5 is a SAMA diagram legend file provided in an embodiment of the present application;
图6为本申请一实施例提供的SAMA图典型案例。FIG6 is a typical example of a SAMA diagram provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
需要说明的是,在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。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.
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图对本发明进行进一步详细说明。In order to make the purpose, 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.
相反,本发明涵盖任何由权利要求定义的在本发明的精髓和范围上做的替代、修改、等效方法以及方案。进一步,为了使公众对本发明有更好的了解,在下文对本发明的细节描述中,详尽描述了一些特定的细节部分。对本领域技术人员来说没有这些细节部分的描述也可以完全理解本发明。On the contrary, the present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention as defined by the claims. Further, in order to make the public have a better understanding of the present invention, some specific details are described in detail in the detailed description of the present invention below. Those skilled in the art can fully understand the present invention without the description of these details.
针对现有技术在将SAMA图转换为组态程序时的局限性和不足,本发明提出了一种创新的解决方案。以下是具体的实施例:参见图1,所示为本申请一种SAMA图自动生成组态程序的方法的流程框图,该方法至少包含以下步骤:In view of the limitations and shortcomings of the prior art in converting SAMA diagrams into configuration programs, the present invention proposes an innovative solution. The following is a specific embodiment: Referring to FIG1 , a flowchart of a method for automatically generating a configuration program from a SAMA diagram of the present application is shown, and the method at least comprises the following steps:
S1:预处理过程S1: Preprocessing
对输入的SAMA图图例文件进行逐一扫描和分析,以准确识别不同类型的图例,将图例和代码段进行匹配,并按类型分类将它们存储到组件库中。同时读取预定义的图例代码段文件,确保与组件库相对应。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 classification. At the same time, the predefined legend code snippet files are read to ensure that they correspond to the component library.
进一步的,图例与代码段进行匹配时,通过改进的DT-DETR模型对图例进行识别,得到不同类型的图例,并按类型分类将图例以及对应的代码段存储到组件库中。具体的,改进的DT-DETR模型主要包括以下几个方面的优化:设计了RepGhostELAN模块替换原来的basicblock模块,RepGhostELAN模块的引入通过设计轻量化网络来降低网络的参数量和计算量,使得模型在保证识别精度的同时,大幅提升了运算效率;引入BiForme注意力机制,在不同尺度上更多地关注与SAMA图图例相关的特征信息,BiForme注意力机制通过在多尺度上捕捉图例的关键特征,同时保持了轻量级,不会给模型带来显著的计算负担,确保了模型的高效性和准确性;使用MPDIou替换原来的GIoU,MPDIou的引入提高了检测模型对SAMA图图例识别的鲁棒性,使得模型在复杂背景下仍能准确识别各类图例。通过上述改进,DT-DETR模型在识别SAMA图中的图例时,不仅提高了精度和鲁棒性,还显著降低了计算资源的消耗,提升了整体识别效率。Furthermore, when matching the legend with the code segment, the legend is identified through the improved DT-DETR model to obtain different types of legends, and the legends and corresponding code segments are stored 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 the amount of calculation by designing a lightweight network, so that the model can ensure the recognition accuracy while greatly improving the operation efficiency; 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 will 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 types of legends under 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.
S2:工程文件解析及信息提取S2: Engineering file analysis and information extraction
深入解析SAMA图工程文件,精准地提取各式图例和线段信息,为系统后续的处理和分析提供丰富而可靠的数据支持,确保准确性和完整性。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 processing and analysis of the system, ensuring accuracy and completeness.
具体的,如图2所示,所述步骤S2包括如下的子步骤:Specifically, as shown in FIG2 , step S2 includes the following sub-steps:
S201:遍历实体信息S201: Traversing entity information
逐一遍历SAMA图中的所有实体信息,这些信息可能包括图形元素、文本描述、块类型等。通过遍历实体信息,系统可以全面了解SAMA图的结构和内容;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;
S202:识别图例S202: Identify the legend
首先会识别出图例,这些图例通常具有特定的外观和功能,用于表示控制系统中的各种功能块或功能模块。在识别过程中,系统将提取相关的属性和功能描述,以便后续处理和识别;First, legends are identified. These legends usually have a specific appearance and function, and are used to represent various functional blocks or modules in the control system. During the identification process, the system will extract relevant attributes and functional descriptions for subsequent processing and identification;
S203:处理基本图形S203: Processing basic graphics
处理非图例的基本图形。这些基本图形可能包括各种形状、线条或其他几何元素,它们可能不属于预定义的图例。系统将对这些基本图形进行组合,并与图例库进行比对。如果找到匹配的图例,则系统将保存这些组合,以便后续使用。这个过程有助于识别和处理SAMA图中的各种图形元素,从而更准确地转换为组态程序的组件和功能模块。Processing of non-legend basic graphics. These basic graphics may include various shapes, lines or other geometric elements, which may not belong to the predefined legend. The system will combine these basic graphics and compare them with the legend library. If a matching legend is found, the system will save these combinations for subsequent use. This process helps to identify and process various graphic elements in the SAMA diagram, so as to more accurately convert them into components and functional modules of the configuration program.
S3:错误检查和修正S3: Error checking and correction
对SAMA图中的布局和结构进行详细分析,以确保图形组合的准确性和合理性。随后,针对可能存在的错误或不规范的部分,提供修正提示以指导用户进行必要的修正操作,确保最终的转换结果准确无误。修正提示可能涵盖诸如图形位置调整、符号替换、逻辑关系优化等方面,以最大程度地改善SAMA图的质量和可读性。The layout and structure of the SAMA diagram are analyzed in detail to ensure the accuracy and rationality of the graphic combination. Subsequently, correction tips are provided for possible errors or irregularities to guide the user to make necessary corrections to ensure that the final conversion result is accurate. Correction tips may cover aspects such as graphic position adjustment, symbol replacement, and logical relationship optimization to maximize the quality and readability of the SAMA diagram.
进一步的,如图3所示,所述步骤S3包括如下的子步骤:Further, as shown in FIG3 , step S3 includes the following sub-steps:
S301:组件库状态检查S301: component library status check
逐一检查每个图例,验证其是否已经记录在组件库中。这一步骤确保了系统在处理过程中能够正确识别和处理每个块,避免了重复添加或处理已存在的块。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.
具体的,使用各种编程语言中的数据结构和算法来检查每个识别的图例是否已经在组件库中存在,以确定该图例在系统中的识别状态。具体来说,可以利用哈希表(HashTable)或者集合(Set)等数据结构,将组件库中已有的图例存储起来,并在识别过程中对每个识别的图例进行检查,看其是否存在于组件库中Specifically, data structures and algorithms in various programming languages are used to check whether each recognized legend already exists in the component library 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 during the recognition process, each recognized legend is checked to see whether it exists in the component library.
S302:连接关系分析S302: Connection relationship analysis
详细分析SAMA图中两个图例之间的连接关系,包括可能存在的多条线段。这一步骤的目标是确保连接关系清晰准确,以防止信息传递中的混淆或错误。Analyze the connection between the two legends in the SAMA diagram in detail, including the possible existence of multiple line segments. The goal of this step is to ensure that the connection is clear and accurate to prevent confusion or errors in the transfer of information.
具体的,利用图论中的算法来进行检查两个图例之间可能存在多条线段,确保连接关系的清晰和准确。具体来说,可以使用深度优先搜索(DFS)或广度优先搜索(BFS)等算法,从一个图例出发,逐步遍历其连接的线段,以确定是否存在多头线段。Specifically, algorithms in graph theory are used to check whether there may be multiple line segments between two legends to ensure the clarity and accuracy of the connection relationship. Specifically, algorithms such as depth-first search (DFS) or breadth-first search (BFS) can be used to start from one legend and gradually traverse the connected line segments to determine whether there are multiple-headed line segments.
S303:线段位置验证S303: Line segment position verification
使用几何计算中的点到线段的距离公式分析线段位置,确定线段是否在对应的图例上。针对每一条线段,验证其位置是否与相应的块相匹配。通过检查线段上每个点到图例的最短距离,然后将这些距离与预设的阈值进行比较,确定其准确性,标记出任何与块不匹配的线段,以识别和纠正可能的错误。The point-to-line segment distance formula in geometric calculation is used to analyze the line segment position and determine whether the line segment is on the corresponding legend. For each line segment, verify whether its position matches the corresponding block. By checking the shortest distance from each point on the line segment to the legend, and then comparing these distances with the preset threshold, determine its accuracy, mark any line segment that does not match the block to identify and correct possible errors.
具体的,对于给定的线段和图例,首先计算线段上每个点到图例的最短距离,然后将这些距离与预设的阈值进行比较。如果最短距离在阈值范围内,则可以将该线段视为在图例上,否则将其标记为错误。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.
S304:错误修正建议S304: Error correction suggestions
在发现错误后,提供相应的修正建议。这些建议可能包括将未识别的块添加到组件库中,或者调整线段位置等操作。这样的修正措施有助于确保图形的准确性和一致性,提高系统处理的质量和效率。After an error is found, corresponding correction suggestions are provided. These suggestions may include adding unrecognized blocks to the component library or adjusting the position of line segments. Such correction measures help ensure the accuracy and consistency of graphics and improve the quality and efficiency of system processing.
S4:连接关系的建立和保存S4: Establishing and preserving connection relationships
系统将对SAMA图中的各个组件之间的连接关系进行识别和建立。这一过程涉及识别图中的各个组件,并确定它们之间的逻辑或数据流连接。系统将识别出的连接关系以图状结构的形式保存,其中包括节点和连接线。节点代表图中的各个功能块,连接线则表示功能块之间的连接关系。通过保存这些连接关系的图状结构,系统能够更好地理解和描述SAMA图的控制逻辑,并为后续的转换和处理提供必要的数据基础。The system will identify and establish the connection relationships between the 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 saves the identified connection relationships in the form of a graph structure, which includes nodes and connecting lines. The nodes represent the functional blocks in the diagram, and the connecting lines represent the connection relationships between the functional blocks. By saving the graph structure of these connection 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.
进一步的,如图4所示,所述步骤S4包括如下的子步骤:Further, as shown in FIG4 , the step S4 includes the following sub-steps:
S401:输入输出标识S401: Input and output identification
对识别出的连接关系进行处理,明确标识每个组件的输入和输出。通过对每个连接进行标识,系统能够更清晰地了解各个组件之间的数据流向,为后续的逻辑处理和程序生成提供必要的信息;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 and provide necessary information for subsequent logic processing and program generation;
S402:连接属性记录S402: Connection attribute record
将保存每个连接的属性信息。这些属性信息包括连接的类型(如逻辑连接、数据流连接)、连接的方式(串行、并行)、连接的通道等。通过记录这些属性信息,系统可以进行更详细的分析和优化,在后续的处理过程中提供更多的参考依据;The attribute information of each connection will be saved. This attribute information includes the type of connection (such as logical connection, data flow connection), the mode of connection (serial, parallel), the channel of connection, etc. By recording this attribute information, the system can perform more detailed analysis and optimization, and provide more reference basis in the subsequent processing process;
S403:连接关系可视化S403: Visualization of connection relationships
将连接关系进行可视化展示。除了展示功能块之间的连接关系外,系统还会显示每个连接的输入和输出端口。这样的可视化展示能够直观呈现系统的数据流向和逻辑关系,帮助用户更好地理解整个控制系统的结构和运行方式;Visualize the connection relationship. In addition to displaying the connection relationship between function blocks, the system also displays the input and output ports of each connection. Such a visual display can directly present the data flow and logical relationship of the system, helping users better understand the structure and operation of the entire control system;
S404:输入输出匹配检查S404: Input and output matching check
将对每个组件的输入和输出进行匹配检查。通过检查输入端口和输出端口的数据类型和格式,系统可以确保它们之间的匹配,避免出现不兼容或错误的连接。这样的匹配检查可以提高系统的稳定性和可靠性。The input and output of each component will be checked for matching. By checking the data type and format of the input port and output port, the system can ensure that they match and avoid incompatible or incorrect connections. Such matching checks can improve the stability and reliability of the system.
S5:转换成XML存储S5: Convert to XML for storage
系统将根据预先定义的转换规则,将已识别的SAMA图和建立的连接关系转换为XML格式,并将其进行存储。这一过程涉及将SAMA图的各个功能块以及它们之间的连接关系转换为XML文档的结构化形式。通过XML格式的存储,系统可以更方便地进行后续的处理、分析和共享。XML文档中包含了SAMA图的所有关键信息,包括功能块属性、连接关系、布局等,这为组态程序的生成和调试提供了重要的数据基础。The system will convert the identified SAMA diagram and the established connection relationship into XML format according to the pre-defined conversion rules and store them. This process involves converting the various functional blocks of the SAMA diagram and the connection relationship between them into the structured form of an XML document. By storing in XML format, the system can more conveniently perform subsequent processing, analysis and sharing. The XML document contains all the key information of the SAMA diagram, including functional block attributes, connection relationships, layout, etc., which provides an important data basis for the generation and debugging of configuration programs.
如图5所示为SAMA图图例文件,里面包含工程文件所用到的所有图例。As shown in Figure 5, this is the SAMA diagram legend file, which contains all the legends used in the project file.
如图6所示为SAMA图工程文件中的一个简单的典型案例,具体内容是输入两个数经过乘法器求得乘积,输出的结果经过高值信号监视器,如果超过预定义的阈值,则报警并输出5s脉冲。As shown in Figure 6, this is a simple typical case in the SAMA diagram engineering file. The specific content is that two numbers are input and the product is obtained through the multiplier. The output result passes through the high-value signal monitor. If it exceeds the predefined threshold, an alarm is issued and a 5s pulse is output.
以上结合附图对本发明的实施方式作了详细说明,但本发明不限于所描述的实施方式。对于本领域的技术人员而言,在不脱离本发明原理和精神的情况下,对这些实施方式包括部件进行多种变化、修改、替换和变型,仍落入本发明的保护范围内。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. For those skilled in the art, various changes, modifications, substitutions and variations of these embodiments including components are made without departing from the principles and spirit of the present invention, and still fall within the scope of protection of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410659099.XACN118626072B (en) | 2024-05-27 | 2024-05-27 | Method for automatically generating configuration program by SAMA (sample presentation area) graph |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410659099.XACN118626072B (en) | 2024-05-27 | 2024-05-27 | Method for automatically generating configuration program by SAMA (sample presentation area) graph |
| Publication Number | Publication Date |
|---|---|
| CN118626072Atrue CN118626072A (en) | 2024-09-10 |
| CN118626072B CN118626072B (en) | 2025-09-09 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202410659099.XAActiveCN118626072B (en) | 2024-05-27 | 2024-05-27 | Method for automatically generating configuration program by SAMA (sample presentation area) graph |
| Country | Link |
|---|---|
| CN (1) | CN118626072B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110376959A (en)* | 2019-07-25 | 2019-10-25 | 大连理工大学 | A kind of Soft- PLC configuration software generation system based on FPGA platform |
| CN112462713A (en)* | 2020-11-25 | 2021-03-09 | 华能国际电力股份有限公司日照电厂 | Graphical logic control system, method, equipment and readable storage medium |
| CN113703405A (en)* | 2021-08-27 | 2021-11-26 | 中国核动力研究设计院 | Nuclear power DCS algorithm configuration logic diagram drawing system |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110376959A (en)* | 2019-07-25 | 2019-10-25 | 大连理工大学 | A kind of Soft- PLC configuration software generation system based on FPGA platform |
| CN112462713A (en)* | 2020-11-25 | 2021-03-09 | 华能国际电力股份有限公司日照电厂 | Graphical logic control system, method, equipment and readable storage medium |
| CN113703405A (en)* | 2021-08-27 | 2021-11-26 | 中国核动力研究设计院 | Nuclear power DCS algorithm configuration logic diagram drawing system |
| Publication number | Publication date |
|---|---|
| CN118626072B (en) | 2025-09-09 |
| Publication | Publication Date | Title |
|---|---|---|
| WO2022001132A1 (en) | Routing inspection method and apparatus for printed circuit board, and computer-readable storage medium | |
| Shi et al. | IFCdiff: A content-based automatic comparison approach for IFC files | |
| CN117056867A (en) | Multi-source heterogeneous data fusion method and system for digital twin | |
| CN111459982A (en) | Data query method and device, terminal device and storage medium | |
| CN111782117B (en) | Interface display method and device, storage medium and electronic device | |
| CN102567565B (en) | Method and system for processing cable parameters | |
| CN117931955A (en) | Knowledge graph-based power data processing method and system | |
| CN113935289A (en) | Document online processing method and device | |
| CN117635846A (en) | Digital twin method, system and storage medium of engineering object | |
| CN120012757A (en) | Method, device, computer equipment and storage medium for reviewing bidding documents | |
| CN118626072A (en) | A method for automatically generating configuration programs from SAMA diagrams | |
| CN118193376A (en) | A test method, system, electronic device, storage medium and test terminal | |
| CN110908962A (en) | A fast data processing method for SCD model of smart substation | |
| CN117931893A (en) | Data retrieval method and system based on distributed search engine | |
| CN116881512A (en) | Cross-system metadata blood-edge automatic analysis method | |
| CN101145216A (en) | System and method for inspecting and maintaining electronic components | |
| CN119829416B (en) | Test tool result fusion method based on text embedding | |
| CN118295864B (en) | Linux operating system hardware error identification method and system | |
| CN119203973B (en) | Data report intelligent generation method based on multidimensional feature mining and related equipment | |
| CN118312480A (en) | System and method for complex Excel unordered comparison | |
| CN120510247A (en) | A secondary system drawing system based on full-circuit diagram positioning based on diagram code | |
| CN119201913A (en) | A method and device for detecting quality of geographic information data and an electronic device | |
| CN118377808A (en) | Automatic extraction and identification method and system for design data | |
| CN119046151A (en) | Method for detecting data modeling quality | |
| CN119831524A (en) | Nuclear power asset evaluation record examination method |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |