A method and apparatus for generating industrial control codes based on industrial knowledge graphs

By combining industrial knowledge graphs and large language models, industrial systems are broken down into functional subsystems, generating control codes that conform to industrial standards. This solves the problem of code generation not conforming to actual industrial scenarios in existing technologies, and achieves highly reliable and low-ambiguity automatic code generation.

CN122086374APending Publication Date: 2026-05-26BEIJING RES INST OF AUTOMATION FOR MACHINERY IND
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING RES INST OF AUTOMATION FOR MACHINERY IND
Filing Date
2026-04-27
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing intelligent generation technologies for industrial control codes lack knowledge graphs from actual industrial scenarios, resulting in generated codes that cannot guarantee compliance with industrial scenario requirements and safety standards. Furthermore, the lack of user participation in the decision-making process affects the generation quality and practical application effectiveness.

Method used

By breaking down the industrial system into multiple functional subsystems, an industrial knowledge graph is constructed. A list of node types is generated by combining a large language model and real-time industrial control requirements. Candidate entity sets are matched, and context enrichment operations are performed in the industrial knowledge graph to finally generate control code that conforms to industrial standards.

Benefits of technology

It achieves highly reliable and unambiguous automatic conversion from natural language requirements to target code, ensuring that the generated code conforms to industrial control logic, system topology logic and industry standards, and improving the accuracy, scenario adaptability and efficiency of code generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086374A_ABST
    Figure CN122086374A_ABST
Patent Text Reader

Abstract

This application provides a method and apparatus for generating industrial control code based on an industrial knowledge graph, belonging to the field of code generation technology. The method provided in this application involves: splitting an industrial system into multiple functional subsystems; determining the topological relationships of each component based on each functional subsystem; constructing an industrial knowledge graph based on the topological relationships and the logical relationships of each functional subsystem; generating a list of node types based on real-time industrial control requirements; matching candidate entity sets in the industrial knowledge graph based on the node type list to generate a candidate knowledge list; using a large language model as a decision-maker to evaluate the candidate knowledge list and output decision instructions; and using the industrial knowledge graph as a constraint, combining the decision instructions to generate industrial control code. The industrial control code generation method and apparatus based on an industrial knowledge graph provided in this application achieve highly reliable and low-ambiguity conversion from natural language requirements to target code that conforms to industrial standards and control logic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of code generation technology, and in particular to a method and apparatus for generating industrial control codes based on an industrial knowledge graph. Background Technology

[0002] In the field of industrial automation, programmable logic controllers (PLCs) are the core execution devices for industrial control. The quality and efficiency of the development of their supporting control codes directly determine the operational stability, intelligence level, and implementation cycle of industrial production lines. With the advancement of industry, complex industrial scenarios have placed higher demands on the standardization, security, and scenario adaptability of control codes. The traditional manual control code writing model is no longer able to meet the development needs of efficient and intelligent industrial production. Intelligent generation technology of industrial control codes based on artificial intelligence has become an important research direction for industry upgrading.

[0003] In the prior art, CN202511005733.9 discloses an ST code generation method based on graph-aligned coding large model and multi-agent collaboration, and CN202511254265.9 discloses a structured text code generation and review method. However, the existing intelligent generation technology of industrial control code still has obvious defects. (1) It lacks a knowledge graph formed by knowledge from actual industrial scenarios, which means that the generated code can only guarantee the correctness of the syntax and the basic logic, but cannot guarantee that the code meets the requirements and safety standards of industrial scenarios. (2) It lacks the process of user participation in decision-making. Relying solely on LLM and knowledge base cannot guarantee that the generated code meets the actual needs that users have not correctly expressed, which ultimately affects the generation quality of control code and the actual application effect. Summary of the Invention

[0004] In view of this, this application provides an industrial control code generation method and apparatus based on industrial knowledge graphs, which can achieve highly reliable and low-ambiguity conversion from natural language requirements to target codes that conform to industrial standards and control logic.

[0005] Specifically, this application is implemented through the following technical solution:

[0006] The first aspect of this application provides a method for generating industrial control codes based on industrial knowledge graphs, the method comprising:

[0007] The industrial system is divided into multiple functional subsystems, each of which independently completes the tasks of the industrial system, and each functional subsystem is communicatively connected to the control center;

[0008] The topological relationship of each component within a functional subsystem is determined based on the control signal flow relationship within each functional subsystem;

[0009] An industrial knowledge graph is constructed based on the topological relationships and the logical relationships of the various functional subsystems.

[0010] Generate a list of node types based on real-time industrial control requirements;

[0011] Match candidate entity sets in the industrial knowledge graph based on the node type list;

[0012] The candidate entity set is subjected to context enrichment operation in the industrial knowledge graph to generate a candidate knowledge list;

[0013] The large language model is used as a decision-maker to evaluate the candidate knowledge list and output decision instructions;

[0014] The industrial knowledge graph is used as a constraint, and combined with the decision instructions, industrial control code is generated.

[0015] A second aspect of this application provides an industrial control code generation device based on an industrial knowledge graph, the device comprising a splitting module, a building module, and a generation module;

[0016] The splitting module is used to split the industrial system into multiple functional subsystems. Each functional subsystem independently completes the tasks of the industrial system, and each functional subsystem is communicatively connected to the control center.

[0017] The construction module is used to determine the topological relationship of each component in each functional subsystem based on the control signal flow relationship within each functional subsystem;

[0018] The construction module is also used to construct an industrial knowledge graph based on the topological relationship and the logical relationship of each functional subsystem;

[0019] The generation module is used to generate a list of node types based on real-time industrial control requirements;

[0020] The generation module is also used to match a set of candidate entities in the industrial knowledge graph according to the list of node types;

[0021] The generation module is further configured to perform context enrichment operations on the candidate entity set in the industrial knowledge graph to generate a candidate knowledge list;

[0022] The generation module is also used to use the large language model as a decision-maker to evaluate the candidate knowledge list and output decision instructions;

[0023] The generation module is further configured to use the industrial knowledge graph as a constraint and combine it with the decision instructions to generate industrial control code.

[0024] The industrial control code generation method and apparatus based on industrial knowledge graph provided in this application enrich the knowledge from the perspective of professional knowledge by constructing a knowledge graph during code generation, ensuring a rich source of information for code generation. At the same time, decision instructions generated based on rich knowledge and industrial knowledge graph are used as constraints during code generation. This not only ensures a rich source of information, but also enables the generation of industrial control code to learn standardized and rich code generation information based on decision instructions, and can constrain code logic under the same logical architecture. Specifically, addressing the technical problems of existing intelligent industrial control code generation technologies, such as the lack of a structured knowledge system that fits actual industrial scenarios, the tendency to misunderstand industrial control requirements, and the lack of targeted industrial constraints in decision-making leading to poor code generation quality, this paper focuses on constructing an industrial knowledge graph that integrates the actual architecture and standards of industrial systems. This is achieved by breaking down the industrial system into independent functional subsystems that communicate with the control center, determining the topological relationships of components based on the flow of control signals within the subsystems, and constructing an industrial knowledge graph by combining these topological relationships with the logical relationships of the subsystems. This embeds structured knowledge constraints that fit actual industrial scenarios into code generation. Furthermore, it involves transforming real-time industrial control requirements into a list of node types, accurately matching candidate entity sets in the industrial knowledge graph and enriching their industrial semantic context to form a candidate knowledge list, using a large language model as a decision-maker to evaluate the list and output decision instructions, and finally using the industrial knowledge graph as a constraint to generate industrial control code based on the decision instructions—a fully integrated approach that ensures that the industrial scenario semantics, topological logic, and industry standards of the industrial knowledge graph permeate the entire code generation process. In the process of automatically generating code, compared with existing technologies, the generation stage is input with structured information that fits the actual industrial scenario, such as the topological relationship of industrial system components, the logical association between functional subsystems, and industrial control professional specifications. At the same time, the automatic generation process is subject to multi-level intervention through the strong constraints of industrial knowledge graph, including requirement parsing and mapping, entity matching scope, decision-making basis, and code generation logic. This avoids the problem of pure algorithm generation being out of touch with the industrial scenario, ensuring that the automatic generation process from natural language requirements to control code always follows the actual control logic of the industrial system and industry standards. Ultimately, the industrial control code generation logic is highly consistent with the actual industrial scenario, and the generated code conforms to the basic logic of industrial control, system topology logic, and industry specifications. At the same time, it achieves highly reliable and unambiguous automatic conversion from natural language requirements to target code, which greatly improves the accuracy, scenario adaptability, and generation efficiency of code generation. Attached Figure Description

[0025] Figure 1 A flowchart of an embodiment of the industrial control code generation method based on industrial knowledge graph provided in this application;

[0026] Figure 2 This is a schematic diagram of the structure of Embodiment 2 of the industrial control code generation device based on industrial knowledge graph provided in this application. Detailed Implementation

[0027] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.

[0028] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used herein are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

[0029] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."

[0030] The following specific embodiments are given to illustrate the technical solution of this application in detail.

[0031] Figure 1 This is a flowchart of an embodiment of the industrial control code generation method based on industrial knowledge graphs provided in this application. Please refer to... Figure 1 The method provided in this embodiment may include:

[0032] S101. The industrial system is divided into multiple functional subsystems. Each functional subsystem independently completes the tasks of the industrial system, and each functional subsystem is communicatively connected to the control center.

[0033] Specifically, the overall task of the industrial system is broken down into multiple functional subsystems that can independently complete corresponding industrial sub-tasks. Then, communication connections are established between each functional subsystem and the control center. A functional subsystem refers to a modular unit formed by decomposing the overall production control and operation management tasks of the industrial system according to functional independence and task correlation. Each functional subsystem is equipped with dedicated execution, detection, and control components and can autonomously realize the complete control flow of its sub-task. It also establishes a separate two-way communication connection with the control center, receiving instructions from the control center and providing feedback on its own operating status. The functional subsystem is the core functional decomposition unit of the industrial system. Different functional subsystems cooperate to complete the overall task of the industrial system. There are clear logical collaboration and signal interaction relationships between the various functional subsystems, and the components within each functional subsystem form a unique topology based on the flow of control signals. Even if different functional subsystems have components of the same type or specification, each component only functions within its own functional subsystem, possessing independent topology positioning and control functions, and does not interfere with each other.

[0034] Furthermore, an industrial system refers to an organic whole composed of various industrial production, control, and detection hardware components, as well as supporting control logic and communication links, capable of completing specific industrial production, processing, operation management, and other overall tasks. It is a complete system for realizing industrial automation operations, encompassing various components such as execution units, detection units, control units, and communication units. A functional subsystem is a modular unit formed by decomposing the overall task of an industrial system according to functional independence and task correlation. Each functional subsystem can independently complete its corresponding industrial sub-task, equipped with dedicated execution, detection, and control components, and can autonomously realize the complete control process of its sub-task, and only complete signal transmission and logic execution within its own system boundary. The decomposition of industrial systems follows the principles of functional independence, task correlation, and topological closed loop. First, the overall production control or operation management tasks that the industrial system needs to complete are identified and broken down into several industrial sub-tasks that can be executed independently without task overlap. Then, each sub-task is configured with dedicated hardware components and execution units to build an independent signal transmission and control logic closed loop, forming a functional subsystem that can autonomously complete the corresponding sub-task. At the same time, each functional subsystem is configured with a communication module to establish a two-way communication link with the control center, enabling the control center to issue commands and the functional subsystems to provide feedback on their operating status. Each functional subsystem cooperates with each other while remaining independent, working together to complete the overall task of the industrial system.

[0035] Furthermore, the entire production control or operation management task that the industrial system needs to complete is analyzed. Based on the principles of functional independence and task relevance, the overall task is broken down into several independently executable sub-tasks. Each sub-task is configured with corresponding hardware components and execution units to form an independent functional subsystem. Each functional subsystem can autonomously complete its assigned industrial sub-task. Communication modules are configured for each functional subsystem to establish a two-way communication link between each functional subsystem and the control center. This enables the control center to issue control commands to each functional subsystem, and each functional subsystem to provide feedback on its operating status information to the control center.

[0036] Furthermore, by clearly defining all control functions that need to be implemented in real-time industrial control, and sorting out all related hardware components and logic execution units involved in the implementation process of each control function, and then based on the working principle, signal interaction method and function implementation mechanism of each related component, components with synergistic effect and matching mechanism are collected and integrated, and initially divided into several basic subsystems.

[0037] Furthermore, after the initial subsystem division, a secondary assessment and adjustment can be made based on the degree of correlation between the subsystems and the target control functions, as well as the functional collaboration relationships between each subsystem. Optionally, in one embodiment, if the functional boundaries of each subsystem in the initially divided basic subsystem are clear, there is no functional coupling or collaboration requirement, and each independently supports different control function modules, and the functional requirements of code generation are independently compatible, then the subsystem division work is terminated, and the initial division result is the final functional subsystem.

[0038] Optionally, in another embodiment, if the initially divided multiple basic subsystems belong to the same functional module, then based on the actual needs of code generation, if multiple basic subsystems are essential modules for the logical implementation and functional execution of the control code, and none can be omitted, then the independence of each basic subsystem is preserved, and it is set up as an independent functional subsystem; if one of the basic subsystems is only an auxiliary module and has no key impact on the core logic generation of the control code, while another is an essential module, then the modules will be integrated according to the functional progression relationship and merged into a functional subsystem. The essential module will lead the overall functional implementation of the merged functional subsystem, and the auxiliary module will participate in the control process as a supporting unit within the merged functional subsystem.

[0039] S102. Determine the topological relationship of each component in each functional subsystem based on the control signal flow relationship within each functional subsystem.

[0040] Specifically, the input and output relationships of control signals of each component within each functional subsystem are analyzed. Based on the transmission flow of control signals, the sequential relationships and logical connections between components are clarified, thereby determining the topological relationship of each component within the functional subsystem.

[0041] Furthermore, for each functional subsystem, the various execution components, detection components, and control components contained within are identified one by one. The sources of control signals received by each component and the destinations of control signals sent out are sorted out. According to the transmission flow of control signals from sending to receiving and from triggering to execution, the upstream and downstream relationships between each component are sorted out. At the same time, the logical connection forms such as series and parallel between components are clarified. These relationships and connection forms are structured and sorted out to form a topological relationship that can reflect the signal transmission and logical connection of components within the functional subsystem.

[0042] Furthermore, components of the same type or even the same specifications can be set in different functional subsystems. The same components in each functional subsystem only participate in the transmission and interaction of control signals within their respective systems. Based on the control signal flow relationship of their respective functional subsystems, they form independent topological relationships and do not affect the topological relationships and signal transmission logic of the same components in other functional subsystems. Even if they are the same components, they will have different topological positioning and control functions depending on the functional subsystem they belong to.

[0043] Furthermore, the connection relationships and signal flow between each component in each functional subsystem are determined, the execution links are determined based on the control functions of the generated code, and the execution links in the original system are supplemented and corrected.

[0044] Specifically, in determining the topological relationships of components within each functional subsystem, starting from the core functions of the functional subsystem itself, the flow of control signals generated by each component in order to achieve its own function is sorted out, thereby clarifying the original upstream and downstream connections and logical connections between each component; the control functions that need to be implemented for code generation are determined, and the signal transmission and action execution links required for the implementation of the control functions are sorted out, the signal relationships to be supplemented are determined, and after verifying the signal relationships to be supplemented, the component association nodes and signal flow relationships that are strongly related to code implementation and may have been missed due to the sorting out of the original functions of the system are supplemented, ensuring that the results of the two sorting outs corroborate each other and that no topological association information related to code generation is missing. The final component topological relationship not only fits the actual operating logic of the functional subsystem, but also fully matches the functional implementation requirements of industrial control code generation.

[0045] S103. Construct an industrial knowledge graph based on the topological relationships and the logical relationships of each functional subsystem.

[0046] Specifically, sub-graphies based on component topology relationships are constructed within each functional subsystem. By combining the collaboration logic and signal interaction logic between each functional subsystem, the sub-graphies are merged and associated to form a complete industrial knowledge graph.

[0047] Furthermore, taking each functional subsystem as a unit, each component within the system is treated as a graph node, and the topological relationships between components are used as the connecting edges between nodes to construct a local industrial knowledge subgraph corresponding to each functional subsystem. The execution logic, coordination logic, signal interaction, and instruction transmission relationships of each functional subsystem in completing the overall task of the industrial system are sorted out, and these logical relationships are used as connecting edges to connect and merge the independent functional subsystem subgraphs. At the same time, knowledge information such as programming specifications and safety standards in the field of industrial control is incorporated to form a complete industrial knowledge graph covering component topology, subsystem logic, and industrial specifications.

[0048] Furthermore, each component in the functional subsystem is sorted according to its function, and the first component of each functional subsystem is determined. The first component is then used as the first-level node of the knowledge graph. The hierarchical relationship of each sub-component in each first component is determined, and the hierarchical node of each sub-component is determined according to the hierarchical relationship of each sub-component, thus completing the construction of the knowledge graph.

[0049] Furthermore, each first-level node is independent of the others. The hierarchical nodes of each sub-component under each first-level node may or may not be independent. The hierarchical nodes of each sub-component are determined based on the connection relationships between them. When receiving a code generation instruction, the target first-level component is obtained from the instruction, and the target first-level nodes of the target first-level component are traversed.

[0050] Specifically, in the process of constructing an industrial knowledge graph based on topological relationships and logical relationships of functional subsystems, the first component in each functional subsystem is set as the first-level node of the graph. Each first-level node corresponds to an independent functional branch in the functional subsystem. In subsequent graph retrieval and matching, only the first-level node of one functional branch will be selected for traversal based on specific control requirements. When the first-level node extends downwards, the sub-components of the corresponding functional branches are sequentially designated as second-level, third-level, and so on, nodes. The node hierarchy follows the direction of control signal transmission and the execution logic of component actions, forming a chain-like topology within a single branch. The first-level nodes within each functional subsystem are independent of each other, avoiding cross-interference of signals and logic between components of different functional branches and ensuring the independence of the functional implementation of each branch. The secondary-level nodes extending from the same first-level node form an orderly upstream and downstream connection relationship based on the direction of control signal flow within the functional subsystem. At the same time, according to the series and parallel logical connection forms in industrial control logic, some nodes will also form a feedback connection relationship according to actual control requirements, ensuring that the connection relationship of the later-level nodes completely reproduces the actual component collaboration and signal interaction logic of the corresponding functional branches.

[0051] S104. Generate a list of node types based on real-time industrial control requirements.

[0052] Specifically, the received real-time industrial control requests are semantically parsed and intents are extracted. The extracted control intents are then mapped to the pre-defined knowledge entity types in the industrial knowledge graph, ultimately generating a list of corresponding node types.

[0053] Furthermore, the system receives industrial control requirements in natural language form from user input via a pre-defined interface. It then performs deep semantic analysis on these requirements, eliminating invalid information and extracting core control intentions such as control objectives, control objects, and control actions. These extracted core control intentions are then matched and mapped with predefined knowledge entity types in the industrial knowledge graph, such as systems, equipment, and functions. The matched knowledge entity types are then organized and summarized to form a structured list of node types, providing a clear retrieval basis for subsequent graph searches.

[0054] Furthermore, the specific implementation steps include:

[0055] (1) Configure the large language model as a query planner by using preset prompt words to extract the demand text of the real-time industrial control requirements;

[0056] Specifically, pre-defined prompts adapted to semantic parsing in the industrial control field are used. These prompts include rules for extracting industrial control requirements, requirements for filtering invalid information, and standards for standardizing requirement text. The pre-defined prompts are input into a large language model, which is then configured as a query planner with the ability to parse industrial control requirements. The received real-time industrial control requirements are imported into this query planner, which extracts the core and standardized requirement text from the original real-time industrial control requirements according to the prompts, and removes redundant and invalid expressions.

[0057] (2) Use the query planner to perform semantic analysis on the demand text and output the industrial control requirements of the demand text;

[0058] Specifically, using the configured query planner, deep semantic analysis specific to the industrial field is carried out on the extracted requirement text. Combined with the professional logic of industrial control, the core elements contained in the requirement text, such as control objects, control actions, control objectives, and process constraints, are identified. These core elements are integrated and sorted to form clear, explicit industrial control requirements that conform to the professional expression of industrial control, thus completing the transformation from natural language text to professional control requirements.

[0059] (3) Map the industrial control requirements to the preset knowledge entity types of the industrial knowledge graph, and generate a list of node types based on the mapping results.

[0060] Specifically, the identified industrial control requirements are matched and mapped one by one with various knowledge entity types such as systems, equipment function bits, logic blocks, and control actions predefined in the industrial knowledge graph to determine the knowledge entity type corresponding to each industrial control requirement. Then, all the matched and mapped knowledge entity types are systematically organized and collected to form a structured and standardized list of node types. This list provides clear and specific retrieval basis for accurately matching candidate entity sets in the industrial knowledge graph.

[0061] By configuring the large language model as a dedicated query planner through preset prompts, and generating a node type list through demand text extraction, industrial domain semantic analysis, and mapping of knowledge entity types from the industrial knowledge graph, this approach leverages the semantic understanding capabilities of the large language model combined with industry-specific parsing rules to accurately filter redundant and invalid information in real-time industrial control requirements. It deeply mines and extracts core requirements that conform to the professional logic of industrial control, while simultaneously achieving precise matching between industrial control requirements and preset entity types in the industrial knowledge graph. This generates a structured and standardized node type list, effectively avoiding the ambiguity and vagueness of natural language requirements. This lays a precise and standardized retrieval foundation for subsequent accurate matching of candidate entity sets in the industrial knowledge graph, ensuring the industrial scenario adaptability and logical accuracy of subsequent knowledge retrieval and code generation processes.

[0062] Furthermore, based on industrial control requirements, the controlled objects, actions, and constraints are determined. Key-value pair representation styles are generated based on the controlled objects, actions, and constraints, and these key-value pair representation styles are mapped to the industrial knowledge graph to generate a list of node types.

[0063] Specifically, in the process of mapping industrial control requirements to the pre-defined knowledge entity types of the industrial knowledge graph and generating a list of node types, the industrial control requirements are organized into a standardized key-value pair expression style of object-action-constraint. Here, the object refers to the industrial equipment / component / subsystem corresponding to the control target, the action refers to the control operation to be performed, and the constraint refers to the process, parameters, timing and other requirements in the control process. This makes the industrial control requirements form a structured and unambiguous expression.

[0064] Furthermore, entity mapping addresses the problem of the inability to directly match control requirements derived from natural language parsing with the structured node system of industrial knowledge graphs. Mapping key-value pair representations to the industrial knowledge graph transforms abstract control requirements into entity type language recognizable by the graph, laying the foundation for accurate entity retrieval and avoiding retrieval biases caused by inconsistent representations. During mapping, feature elements corresponding to objects, actions, and constraints in standardized key-value pairs are extracted. These feature elements are then matched one-to-one with knowledge entity types in the industrial knowledge graph, such as equipment, actions, specifications, and parameters. The type of knowledge entity matched for each feature is determined and categorized. All matched knowledge entity types are organized according to the logical hierarchy of control object-control action-control constraint, generating a structured and standardized list of node types. This list serves as the direct basis for retrieving candidate entities in the industrial knowledge graph, clarifying the scope and logical relationships of the retrieved entity types.

[0065] Furthermore, entity type combinations are determined based on the node type list, functional subsystems and retrieval boundaries are determined based on the control objectives, control objects, and control actions of the control requirements, target entity types are filtered in the industrial knowledge graph based on the entity type combinations, and entities of the target entity types are matched based on the retrieval boundaries.

[0066] Furthermore, during the matching of candidate entity sets in the industrial knowledge graph, the retrieval operation is always guided by real-time industrial control needs, while strictly adhering to the entity type requirements clearly defined in the node type list. This dual-dimensional approach locks in the retrieval scope and targets. Based on the node type list, the entity type combinations corresponding to various knowledge required for code generation are identified, clarifying the retrieval type requirements. Combining the control objectives, control objects, and control actions of real-time industrial control needs, the functional subsystems strongly related to control needs and the graph retrieval boundaries are defined. During the retrieval, all target entity types in the industrial knowledge graph that belong to the required type are first screened out. Based on the defined retrieval boundaries, entities that simultaneously carry the logic of real-time industrial control needs and belong to the required type are matched. This ensures that each matched entity not only conforms to the functional implementation of actual control needs but also meets the knowledge entity type specifications required for code generation. This dual-dimensional approach of needs and types guarantees the accuracy and effectiveness of candidate entity set matching, avoiding the mixing of irrelevant entities and entities of incompatible types.

[0067] S105. Match candidate entity sets in the industrial knowledge graph according to the node type list.

[0068] Specifically, based on the node structure constructed from the topological relationships of functional subsystems and components in the industrial knowledge graph, the node types in the node type list are matched to the top-level nodes of the corresponding functional subsystems. Taking the matched top-level nodes as the starting point for retrieval, the system traverses layer by layer according to the topological relationships of components, and matches and aggregates them to form a candidate entity set.

[0069] Furthermore, referring to the node hierarchy structure of each functional subsystem and the topological relationship between components in the industrial knowledge graph, each node type in the node type list is matched with the top-level node of each functional subsystem in the graph to determine the functional subsystem range to which each node type belongs. Taking the top-level node of the determined functional subsystem as the starting point for retrieval, the graph is traversed layer by layer from top to bottom according to the topological relationship of the components within the functional subsystem to find entity nodes that match the node type list. All matched entity nodes in all functional subsystems are collected, filtered, and aggregated to form the corresponding candidate entity set.

[0070] Furthermore, the specific implementation steps include:

[0071] (1) Based on the node structure of the industrial knowledge graph, match each node type in the node type list with the top-level node of the corresponding functional subsystem in the industrial knowledge graph to determine the range of the top-level node of the functional subsystem for each node type;

[0072] Specifically, the overall node structure of the industrial knowledge graph, which is constructed by the topological relationships of various functional subsystems and internal components, is sorted out. Each node type in the node type list is matched with the top-level node of each functional subsystem in the graph. Based on the matching results, the range of the top-level node of the functional subsystem to which each node type belongs is determined.

[0073] Furthermore, the node structure of the industrial knowledge graph is comprehensively reviewed to clarify the type definition, attribute characteristics, and corresponding functional subsystem boundaries of the top-level nodes of each functional subsystem in the graph, and to establish the correspondence between the top-level nodes and functional subsystems. Node types are extracted one by one from the node type list, and based on the professional logic of the industrial control field and the node definition rules of the graph, they are accurately compared and matched with the top-level nodes of all functional subsystems in the graph. Based on the matching results, it is determined which functional subsystem(s) top-level nodes each node type belongs to, and the retrieval scope corresponding to each node type is defined to avoid boundless global retrieval.

[0074] (2) Taking the top-level node of each functional subsystem as the starting point for retrieval, the nodes are traversed layer by layer downwards according to the topological relationship of the components within the node structure;

[0075] Specifically, the top-level node of each functional subsystem is used as the exclusive retrieval starting point. Based on the pre-determined component topology relationship within the corresponding functional subsystem, a top-down layer-by-layer traversal operation is carried out within the node structure of the functional subsystem.

[0076] Furthermore, the search begins with the top-level node of each defined functional subsystem as the starting point, locking the search entry point corresponding to each node type to ensure that the search operation is carried out only within the defined functional subsystem. According to the topological relationship of the internal components of the functional subsystem, that is, the upstream and downstream associations and logical connections formed by the flow of control signals, the search proceeds from the top-level node downwards, sequentially traversing the second-level nodes, third-level nodes, and so on. During the traversal, the node hierarchy structure of the functional subsystem is strictly followed, and traversal is not performed across functional subsystems, ensuring that the search process is consistent with the actual functional architecture of the industrial system.

[0077] (3) During the traversal, match entities that match the node types in the node type list, and collect and integrate all matched entities to form a candidate entity set.

[0078] Specifically, during the layer-by-layer traversal, the type of each node encountered is determined, and entities that match the node types in the node type list are matched. The matching entities matched in all functional subsystems are collected and filtered, and the filtered entities are uniformly collected and integrated to form a candidate entity set.

[0079] Furthermore, during the layer-by-layer traversal of the node structure of each functional subsystem, the entity type of the nodes encountered is identified in real time, and compared with the corresponding node type in the node type list to determine the entity node whose type is a perfect match. All matching entities within the defined search range are comprehensively collected, and duplicate matching entities and redundant entities unrelated to industrial control requirements are eliminated. The selected effective entities are systematically organized according to their functional subsystem affiliation or entity type, and uniformly collected and integrated into a complete candidate entity set, providing accurate entity objects for subsequent context enrichment operations.

[0080] First, by matching the top-level nodes of the functional subsystems to which the node types belong in the industrial knowledge graph node structure to accurately define the search scope, then, starting from the top-level node, traversing layer by layer according to the component topology, and finally matching and integrating matching entities to form a candidate entity set, the search scope within the industrial knowledge graph is accurately anchored. This avoids problems such as confusion of entities with the same name and matching of irrelevant entities caused by global search, ensuring that the entity search process strictly conforms to the functional architecture and component association logic of the industrial system. This significantly improves the accuracy, uniqueness, and effectiveness of candidate entity set matching, eliminates redundant and invalid entities, and lays a high-quality entity foundation that conforms to the actual industrial scenario for subsequent context enrichment operations of candidate entities. From the source of the search, it ensures the scenario adaptability and logical accuracy of subsequent industrial control code generation.

[0081] Furthermore, after completing the initial matching and aggregation of candidate entities in the industrial knowledge graph, a second precise screening is performed based on the complete semantics of real-time industrial control requirements. Entities that are irrelevant to the semantics of the requirements, only match in type but do not fit the function and control objectives, or whose topological associations cannot support the implementation of control actions and constraints in the requirements are all eliminated. At the same time, based on the core elements in the semantics of the requirements, such as control logic, execution sequence, and parameter thresholds, the remaining entities are verified for relevance. This ensures that the remaining candidate entities not only meet the requirements of the node type list in terms of type, but also that their own attributes, topological branches, and signal interaction capabilities match the semantic connotation of the industrial control requirements. The final set of candidate entities is a precise set of entities that highly matches the semantics of the requirements and can directly support the generation of subsequent control code, laying a solid foundation for subsequent context enrichment operations that aligns with actual control needs.

[0082] S106. Perform context enrichment operation on the candidate entity set in the industrial knowledge graph to generate a candidate knowledge list.

[0083] Specifically, for each entity in the candidate entity set, the corresponding functional subsystem is matched and the topological association information within the same system is obtained. The logical association information of the entity across functional subsystems is obtained. Then, the full information of the entity is integrated to form a complete semantic context. Finally, the semantic context of all entities is summarized to generate a candidate knowledge list.

[0084] Furthermore, for each entity in the candidate entity set, its functional subsystem is located in the industrial knowledge graph. Based on the established component topology relationships within its functional subsystem, topological association information such as control signal flow and logical connections between the entity and other components within the same system is retrieved. Combining the communication relationships between each functional subsystem and the control center, and the logical collaboration relationships between functional subsystems in the industrial knowledge graph, the association information between the entity and related entities in other functional subsystems is retrieved. The entity's own attribute information, topological association information within the same functional subsystem, and logical association information across functional subsystems are integrated to form a complete industrial semantic context for each candidate entity. The complete industrial semantic contexts of all candidate entities are systematically organized and summarized to generate a candidate knowledge list with complete industrial semantics.

[0085] Furthermore, the specific implementation steps include:

[0086] (1) For each candidate entity in the candidate entity set, match its functional subsystem, and obtain the control signal flow association information between the candidate entity and other components in the corresponding functional subsystem according to the topological relationship within the functional subsystem;

[0087] Specifically, each candidate entity in the candidate entity set is identified individually, and each candidate entity is matched with the functional subsystem to which it belongs in the industrial knowledge graph. Based on the pre-determined component topology relationship within the functional subsystem, the control signal flow association information between each candidate entity and other components within the same functional subsystem is accurately obtained.

[0088] Furthermore, candidate entities in the candidate entity set are extracted one by one. Based on the node structure and affiliation of the industrial knowledge graph, the functional subsystem corresponding to each candidate entity is located, and the system affiliation boundary of the entity is clarified. The component topology relationship already constructed within the functional subsystem is retrieved, and the other components corresponding to the candidate entity as the source and receiver of control signals are sorted out, as well as the transmission direction and interaction mode of the signal between the entity and these components. The control signal flow association information between the candidate entity and other components in the same system is fully obtained, and the topological association logic of the entity within its system is clarified.

[0089] (2) Based on the communication connection relationship between each functional subsystem and the control center, and the logical relationship between each functional subsystem, obtain the association relationship between the candidate entity and the candidate entities in other functional subsystems;

[0090] Specifically, the system retrieves the pre-defined bidirectional communication connections between each functional subsystem and the control center in the industrial knowledge graph, as well as the logical relationships such as collaboration, timing, and signal interaction between each functional subsystem. Based on these relationships, it then systematically analyzes the association forms and content between each candidate entity and candidate entities in other functional subsystems to obtain the corresponding cross-system association relationships.

[0091] Furthermore, the communication rules for each functional subsystem to feed back status to the control center and receive instructions from the control center are extracted from the industrial knowledge graph. The execution logic, coordination requirements, and signal transmission relationships of each functional subsystem in completing the overall industrial task are also extracted. Combined with the system affiliation and functional positioning of each candidate entity, the associations between the entity and other candidate entities in the functional subsystems due to the communication and collaboration needs of its subsystem are sorted out, including the associated entity objects, the triggering conditions of the association, and the interaction forms of the association. The cross-functional subsystem associations of the candidate entities are fully obtained, and the collaboration logic of the entities in the overall industrial system is clarified.

[0092] (3) Integrate the attribute information of each candidate entity, the topological association information within the same functional subsystem, and the logical association information across functional subsystems to form a complete industrial semantic context for each candidate entity. Organize and summarize the complete industrial semantic contexts of all candidate entities to generate a candidate knowledge list with complete industrial semantics.

[0093] Specifically, for each candidate entity, its basic attribute information, topological association information within the same functional subsystem, and logical association information across functional subsystems are integrated to form a complete industrial semantic context for each candidate entity. The complete industrial semantic contexts of all candidate entities are systematically organized, classified, and summarized to generate a candidate knowledge list with complete industrial semantics.

[0094] Furthermore, for each candidate entity, its basic attribute information such as specifications, functions, and models is integrated with the control signal flow association information within the same functional subsystem and the logical association information across functional subsystems to form a complete industrial semantic context that includes the entity's own attributes, the topological association within the system, and the cross-system collaboration association, giving the entity information a comprehensive industrial scenario connotation. Subsequently, the complete industrial semantic contexts of all candidate entities are organized and sorted according to dimensions such as entity type and functional subsystem affiliation, eliminating duplicate information, supplementing missing associations, and uniformly summarizing and arranging them to finally form a candidate knowledge list with a clear structure, complete information, and complete industrial semantics.

[0095] Furthermore, a "same-function subsystem" refers to the functional subsystem to which a candidate entity belongs, that is, the same functional subsystem that shares the same system affiliation as the candidate entity. All components and other candidate entities within this scope belong to the same independent functional subsystem as the target candidate entity, and they form a direct topological connection with each other through the flow of control signals to jointly complete the specific industrial sub-task of this subsystem. A "cross-functional subsystem" refers to all other functional subsystems in the industrial system other than the functional subsystem to which a candidate entity belongs, that is, functional subsystems that belong to different system boundaries from the target candidate entity. These subsystems have a clear logical cooperation and signal interaction relationship with the system to which the candidate entity belongs. The candidate entity and other candidate entities in these dissimilar functional subsystems will form an indirect cross-system connection based on the logical relationship between the subsystems.

[0096] By matching the functional subsystems to which candidate entities belong and obtaining the control signal flow association information within the same system, and combining the communication relationship between the functional subsystem and the control center, as well as the logical relationship between subsystems, to obtain cross-system association information, and finally integrating all entity information to form a complete industrial semantic context and generating a candidate knowledge list, each candidate entity is accompanied by complete semantic information that fits the actual industrial scenario. This clarifies the topological location and signal interaction logic of the entity within its functional subsystem, and also clarifies the collaborative relationship between entities across subsystems. This effectively compensates for the one-sidedness of single entity information. The generated candidate knowledge list has complete industrial scenario semantics and logical associations, providing comprehensive and accurate knowledge basis for the subsequent decision-making of the decision-maker. From an information perspective, this ensures the scenario adaptability and logical rationality of the subsequent industrial control code generation.

[0097] S107. Use the large language model as a decision-maker to evaluate the candidate knowledge list and output decision instructions.

[0098] Specifically, in the process of using the large language model as a decision-maker to evaluate the candidate knowledge list, the evaluation focuses on whether the information in the list is sufficient. This involves checking whether the full amount of information contained in the candidate knowledge list, such as entity attributes, topological relationships, and cross-system logical relationships, can fully support the complete generation of industrial control code and whether it meets the information completeness requirements for code generation. During the evaluation process, the industrial control-related specifications and constraints preset by the industrial knowledge graph are used as a benchmark to verify the coverage and detail of each information dimension one by one. This confirms whether various types of information can fully match the semantic connotation and functional implementation requirements of real-time industrial control needs. There is no need to make qualitative judgments on whether the information is normal or abnormal. Instead, the evaluation focuses on whether the information in the existing candidate knowledge list meets the sufficiency standard based on the actual information needs of code generation. Based on the evaluation results, the corresponding decision instructions are output to provide accurate information usage basis for the subsequent code generation stage. Decision instructions are generated based on the sufficiency assessment results of the candidate knowledge list. They are used to clearly inform the execution direction of subsequent processes, as well as the information usage guidelines / supplementation requirements under the corresponding direction. Decision instructions include information sufficiency decision instructions and information supplementation requirement decision instructions. The content of information sufficiency decision instructions must clearly determine that the information dimension coverage and detail of the candidate knowledge list meet the completeness requirements for the full generation of industrial control codes, and that the full amount of information can completely match the semantic connotation and functional implementation requirements of real-time industrial control needs. At the same time, the instructions must clearly state that the candidate knowledge list can be directly used as the information basis for subsequent industrial control code generation without the need to supplement or correct the information in the list. The content of information supplementation requirement decision instructions must clearly determine that the information in the candidate knowledge list does not meet the sufficiency standards required for code generation, and that there are problems such as missing information dimensions and insufficient detail. The decision instructions must clearly point to the information verification dimensions that do not meet the requirements, and inform that relevant information needs to be supplemented for these dimensions before the generation and assessment of the candidate knowledge list are carried out again.

[0099] Furthermore, it is determined whether the candidate knowledge list needs supplementary information. If supplementary information is needed, supplementary questions are generated based on the information to be supplemented, and supplementary suggestions are generated based on the industrial knowledge graph. If no supplementary information is needed, the candidate knowledge list is verified.

[0100] Furthermore, the system independently determines whether the candidate knowledge list needs supplementary information. It performs a normality logic check on all information content and conducts an independent information sufficiency check on the candidate knowledge list, focusing only on whether the entity attributes, topological relationships, and cross-system logical relationships within the list cover all dimensions required for code generation. If information is found to be missing, the system accurately locates the missing item and generates specific supplementary questions based on the corresponding graph node attributes and relationships. Simultaneously, relying on the standardized industrial knowledge pre-set in the industrial knowledge graph, it matches corresponding information supplementation suggestions for each supplementary question, clarifying the type of information to be supplemented, its value range, and the basis for association. If information is found to be sufficient, the system proceeds to a subsequent independent information logic compliance check. Using industrial control standards, topological relationships, and subsystem logic in the industrial knowledge graph as benchmarks, it performs logical consistency and compliance checks on all information within the list, determining whether the information is normal and without contradictions. Combining the results of the information sufficiency check and the information logic compliance check, the system outputs a decision instruction containing information supplementation requirements (if any) or logical verification conclusions, achieving layered and precise control of the assessment process.

[0101] Optionally, in one embodiment, industrial control-related specifications and constraints in the industrial knowledge graph can be retrieved as the judgment benchmark to conduct a comprehensive review and judgment of the candidate knowledge list. Based on the judgment results, the situation is determined to be normal or abnormal, and corresponding decision instructions are output for different situations. Furthermore, the large language model is configured as a decision-maker. The decision-maker retrieves pre-defined industrial programming specifications, functional safety standards, component topology constraints, and subsystem logical constraints from the industrial knowledge graph as the benchmark for evaluating the candidate knowledge list. It comprehensively checks and evaluates the attribute information, topological association information, and logical association information of each entity in the candidate knowledge list, verifying the completeness, consistency, and compliance of the information one by one. If the evaluation determines that the list information is complete, without contradictions, and conforms to relevant industrial control constraints, it is judged as a normal situation, and a selected decision instruction is output, clarifying the candidate knowledge content that can be used for code generation. If the evaluation finds that the list has missing information, contradictory information, or does not meet constraint requirements, it is judged as an abnormal situation, and a supplementary decision instruction is output, clarifying the information to be supplemented or corrected. The decision instructions generated after the evaluation are standardized and output to provide a decision basis for subsequent code generation.

[0102] Furthermore, the specific steps for evaluating the candidate knowledge list include:

[0103] (1) Retrieve the preset industrial control-related norms and constraints in the industrial knowledge graph as the judgment benchmark, and verify the attribute information, topological association information and logical association information of each entity in the candidate knowledge list to confirm that there is no contradiction between each piece of information and that it conforms to the basic logic of industrial control.

[0104] Specifically, various industrial control-related standards and constraints are retrieved from the industrial knowledge graph and used as the core judgment benchmark. Then, a comprehensive verification of all information of each entity in the candidate knowledge list is carried out to confirm that there are no contradictions among the various types of information and that they all conform to the basic logic of industrial control.

[0105] Furthermore, all pre-embedded PLC programming specifications, functional safety standards, industrial equipment operation guidelines, component topology constraints, and other relevant industrial control specifications and constraints are extracted from the industrial knowledge graph. This content is integrated into a unified and standardized evaluation benchmark to provide a basis for subsequent information verification. Then, for each entity in the candidate knowledge list, its own attribute information, topological association information within the same functional subsystem, and logical association information across functional subsystems are extracted one by one. Each piece of information is compared and verified with the evaluation benchmark, and at the same time, it is checked whether there are logical conflicts or contradictions between the various types of information of the entity. After completing the full information verification, it is confirmed that all information of each entity in the candidate knowledge list conforms to the basic logic of industrial control, and there are no contradictions or conflicts between the information.

[0106] (2) Determine that the information completeness in the candidate knowledge list meets the requirements for industrial control code generation, and no supplementation or correction of relevant information is required;

[0107] Specifically, based on the actual needs of industrial control code generation, a standard for judging information completeness is formulated. Then, the overall information of the candidate knowledge list is comprehensively evaluated against this standard. If the completeness of the information in the list meets the code generation requirements, no supplementation or correction of the information is necessary.

[0108] Furthermore, based on the actual process requirements and control logic design needs for industrial control code generation, the completeness criteria for various information such as entity attributes, topological associations, and logical collaborations required for code generation are clarified, and the essential items and specifications of various key information are defined. Then, according to these criteria, the overall information of the candidate knowledge list is checked and evaluated item by item to confirm whether the list contains all the key information required for generating industrial control codes, and whether the level of detail and accuracy of various information meets the requirements for code generation. After evaluation, it is determined that the information in the candidate knowledge list meets the actual needs for industrial control code generation in terms of completeness and accuracy, and no supplementation, modification, or correction is required for any information in the list.

[0109] (3) Output the selected class decision instruction based on the verification result, and determine the candidate knowledge content for generating the control logic scheme according to the selected class decision instruction.

[0110] Specifically, based on the results of prior information verification and completeness determination, standardized selection class decision instructions are generated, and candidate knowledge content that can be directly used to generate control logic schemes is selected from the candidate knowledge list according to the selection class decision instructions.

[0111] Furthermore, by integrating the information verification results and the completeness judgment results, and according to the system's preset instruction specifications, corresponding selection-type decision instructions are generated. These selection-type decision instructions clearly indicate that the candidate knowledge list information is compliant and complete, and can proceed to the subsequent control logic scheme generation stage. Based on the selection-type decision instructions, the content in the candidate knowledge list is systematically sorted out, and all candidate knowledge content that can be directly used for control logic scheme design is selected. Redundant annotation information in the list is removed, and the selected knowledge content is organized according to the functional subsystem affiliation and entity association logic to determine the final candidate knowledge content used to generate the control logic scheme, providing direct and effective knowledge support for the subsequent code generation stage.

[0112] By first verifying the consistency and compliance of the candidate knowledge list based on industrial control standards and constraints in the industrial knowledge graph, then determining whether the completeness of the list information meets the code generation requirements, and finally outputting the selected class decision instructions and determining the candidate knowledge content for the control logic scheme based on the verification results, the large language model, as the decision-maker, always relies on the professional standards and actual needs of the industrial field in the judgment process. This ensures the professionalism and rationality of the judgment results, effectively filters out compliant, complete, and usable candidate knowledge content, and provides accurate and reliable knowledge basis for the subsequent design of control logic schemes and the generation of industrial control codes. This ensures the industrial scenario adaptability and logical accuracy of the generated code from the decision-making stage.

[0113] Furthermore, the specific steps for evaluating the candidate knowledge list also include:

[0114] (1) Based on the industrial control specifications, logical relationships and topological relationships of each functional subsystem preset in the industrial knowledge graph, the attribute information and association information of each entity in the candidate knowledge list are checked.

[0115] Specifically, the industrial control standards, logical relationships between functional subsystems, and topological relationships of components within subsystems are integrated into the industrial knowledge graph to form standardized criteria for anomaly assessment. Then, a comprehensive review of the attribute information and association information of each entity in the candidate knowledge list is conducted.

[0116] Furthermore, pre-defined general industrial control specifications, collaborative logic and timing logic for each functional subsystem to complete the overall task, and topological relationships of control signal flow within each functional subsystem are extracted from the industrial knowledge graph. These three types of content are integrated into a complete and unified set of anomaly judgment criteria. Then, for each entity in the candidate knowledge list, its own attribute information, topological association information within the same functional subsystem, and logical association information across functional subsystems are extracted one by one. The compliance, completeness, and logical consistency of the information are checked against the judgment criteria to ensure that the verification process conforms to the actual architecture and control requirements of the industrial system.

[0117] (2) During the verification process, if the candidate knowledge list is found to have abnormal situations such as missing information, contradictory information, or information content that does not conform to the basic logic of industrial control, the supplementary content shall be sorted out according to the type of abnormal situation;

[0118] Specifically, during the information verification process, it is necessary to identify and determine whether there are any abnormal situations in the candidate knowledge list, such as missing information, contradictory information, or inconsistent with the basic logic of industrial control. For different types of abnormal situations, specific content items that need to be supplemented or corrected are identified.

[0119] Furthermore, during the verification process of the candidate knowledge list information, anomalies are determined in real time: if key attributes of an entity are missing or topological association information is incomplete, it is determined to be an information missing anomaly; if information of different dimensions of an entity conflicts with each other or cross-subsystem association logic is contradictory, it is determined to be an information contradiction anomaly; if the information content violates the basic principles of industrial control or the operating rules of equipment, it is determined to be a non-compliance with basic logic anomaly; for the specific anomalies identified, the information items to be supplemented are classified and sorted out, such as missing entity specification parameters, unclear signal flow direction, or content points to be corrected, such as contradictory subsystem collaboration logic, forming a clear and specific list of content to be supplemented.

[0120] (3) Based on the judgment result, output the guidance supplementary decision instruction, return to the node type list generation stage to supplement the content to be supplemented and then perform matching again.

[0121] Specifically, based on the abnormal situation determination results and the list of content to be supplemented, a standardized guidance supplementation decision instruction is generated. According to the instruction, the process is returned to the node type list generation stage, and the entity matching operation is restarted after the content to be supplemented is added.

[0122] Furthermore, based on the content to be supplemented, missing information items are identified. These missing information items are then matched with missing nodes in the industrial knowledge graph. Node information for the missing nodes is extracted, and the type of content to be supplemented is determined based on the node information. The missing information items and related logic are bound according to the semantic connotation of industrial control requirements to generate supplementary questions. Parameter information matching the missing nodes in the industrial knowledge graph is retrieved as supplementary suggestions. The type of content to be supplemented, the supplementary questions, and the supplementary suggestions are integrated and added to the supplementary decision-making instructions.

[0123] Specifically, the output of guidance and supplementary decision-making instructions relies on the structured node system and standardized industrial knowledge of the industrial knowledge graph to accurately generate supplementary information. Based on the missing information items identified during the information sufficiency check, the corresponding industrial knowledge graph nodes are linked, and node information such as preset attribute types, relational dimensions, and industrial standard value requirements are extracted. This clarifies the specific type, required dimensions, and standard requirements of the content to be supplemented. Combining the semantic connotations of real-time industrial control needs, the missing information items are bound to the relational logic of control function implementation, generating clearly targeted supplementary questions. Simultaneously, standardized industrial parameters, topological association rules, and subsystem collaboration logic matching the missing nodes are retrieved from the industrial knowledge graph as supplementary suggestions for the corresponding supplementary questions. The specific dimensions of the content to be supplemented, the supplementary questions, and the graph-adapted supplementary suggestions are integrated into structured information and incorporated into the guidance and supplementary decision-making instructions. This ensures that after returning to the node type list generation stage, the node type list can be specifically improved based on the explicit information within the instructions, accurately supplementing missing entity types and relational dimensions, avoiding aimless information supplementation, and improving the efficiency and accuracy of re-matching.

[0124] Furthermore, the anomaly detection results are integrated with the list of content to be supplemented, and supplementary decision instructions are generated according to a preset instruction format. These instructions clearly indicate the anomaly type, the content to be supplemented, and the return process node. Then, a process backtracking mechanism is triggered, returning the entire generation process to the node type list generation stage. In this stage, the parsing results of real-time industrial control requirements are improved based on the list of content to be supplemented, the corresponding node type information is supplemented, and a complete and accurate node type list is regenerated. Based on the supplemented node type list, entity matching operations within the industrial knowledge graph are performed again to ensure that the subsequently generated candidate entities and knowledge lists meet the requirements for industrial control code generation.

[0125] Furthermore, when returning to the node type list generation stage to supplement the content to be supplemented, the corresponding preset content is retrieved from the industrial knowledge graph for supplementation and improvement. Specifically, the complete attribute information of the top-level nodes and subordinate nodes of each functional subsystem, the standard topological relationships and control signal flow information of the internal components of each functional subsystem, the cooperation logic and signal interaction specifications between each functional subsystem, and the PLC programming specifications, functional safety standards and other general industrial control specifications embedded in the graph are used to extract standardized industrial knowledge that matches the content to be supplemented. This completes the information supplementation of the node type list, ensuring that the supplemented content is consistent with the actual industrial scenario and meets the unified industrial control specification requirements.

[0126] By verifying candidate knowledge list information based on industrial control specifications, functional subsystem logical relationships, and topological relationships in the industrial knowledge graph, then identifying abnormal situations and sorting out the content to be supplemented, and finally outputting guiding supplementary decision instructions and tracing back to the node type list generation stage for rematching, the decision-maker's anomaly judgment process is anchored to the core constraints and logic of the industrial scenario. It can accurately identify various abnormal issues in the knowledge list, correct source problems through process tracing and information supplementation, effectively avoid code generation errors caused by information defects, ensure the accuracy and compliance of subsequent industrial control code generation, and form a closed-loop anomaly correction mechanism, improving the robustness and adaptability of the entire code generation system.

[0127] Furthermore, after outputting the decision instruction, the method provided in this embodiment also includes:

[0128] (1) Send the decision instruction to the user terminal for user confirmation;

[0129] Specifically, the decision instructions output by the decision-maker are standardized and formatted, and then sent to the user terminal through a preset communication link for manual confirmation and review.

[0130] Furthermore, following a user-recognizable display format, the key elements of the decision-making instructions, such as their type, core judgment results, corresponding candidate knowledge content, or supplementary information requirements, are organized and streamlined to ensure that the instructions are clear, complete, and easy to understand. Relying on the two-way communication link between the user and control terminals established by the system, the organized decision-making instructions are sent in real-time to the operation terminals of relevant industrial control engineers. The corresponding candidate knowledge content or supplementary requirements are clearly submitted to the user, who then manually confirms and reviews them based on the actual production needs and process experience of the industrial site.

[0131] (2) If the user confirms, proceed with the code generation step;

[0132] Specifically, the system receives confirmation commands from the user terminal, verifies the validity of the user's confirmation information, and initiates the subsequent formal steps of industrial control code generation based on the confirmed decision command. It receives operation feedback from the user terminal in real time, verifies that the feedback information is a clear confirmation command, and that the confirmation information has not been tampered with or had any invalid commands added, ensuring the validity of the user's confirmation operation. Then, using the user's confirmed decision command as the core basis, it retrieves the corresponding candidate knowledge content, integrates the various constraints of the industrial knowledge graph with the confirmed knowledge content, and formally initiates the industrial control code generation process, entering the code writing and compliance verification stage.

[0133] (3) If the user does not confirm, return to the step of generating the candidate knowledge list.

[0134] Specifically, upon receiving a non-confirmation instruction from the user, the system extracts the core reasons for the user's non-confirmation and modification suggestions, then retraces the process back to the step of generating the candidate knowledge list and restarts the relevant operations. Upon receiving non-confirmation feedback from the user, the system simultaneously extracts the core reasons for the user's non-confirmation, specific modification suggestions for the candidate knowledge content, or new requirements noted in the feedback; then, it triggers the system's process backtracking mechanism, returning the entire industrial control code generation process to the step of generating the candidate knowledge list. Combining the reasons and suggestions raised by the user, the system re-enriches the context of the candidate entity set, supplements and corrects relevant related information, and regenerates a candidate knowledge list that meets the user's actual needs.

[0135] By submitting decision instructions to the user for confirmation, initiating code generation based on user confirmation, or regressing to the candidate knowledge list generation step based on non-confirmation, a human-machine collaborative verification process is embedded at key code generation nodes. This allows users' industrial field experience and professional judgment to be deeply integrated into the code generation process, effectively compensating for the shortcomings of pure algorithm judgment in adaptability to actual industrial scenarios. It ensures that decision instructions and corresponding candidate knowledge content are highly consistent with the real production needs of industrial sites, further guaranteeing the practicality, scenario adaptability, and engineering reliability of the subsequently generated industrial control code from the perspective of human-machine collaboration. At the same time, it forms a closed-loop correction mechanism for human-machine interaction, significantly improving the matching degree between code generation results and users' actual intentions.

[0136] S108. Using the industrial knowledge graph as a constraint, and combining it with the decision instructions, generate industrial control code.

[0137] Specifically, the industrial specifications, topological constraints, and logical constraints in the industrial knowledge graph are solidified as hard generation constraints. Then, the decision instructions are parsed to extract the core control requirements. Finally, the generation constraints and core control requirements are combined to generate industrial control code that meets the requirements.

[0138] Furthermore, the PLC programming specifications, functional safety standards, component topology constraints of various functional subsystems, and logical collaboration constraints between subsystems contained in the industrial knowledge graph are extracted and solidified as hard constraints for industrial control code generation, ensuring that the generated code meets the requirements of industrial application scenarios. The decision instructions output by the decision-maker are deeply analyzed to extract core control requirements such as the controlled object, control action, execution logic, and parameter requirements. The large language model is configured as a code generator, and the solidified industrial knowledge graph constraints and the core control requirements obtained from the analysis are simultaneously input into the code generator. Under dual constraints, the code generator generates industrial control code that conforms to industrial control standards and matches real-time control requirements, completing the conversion from control requirements to executable code.

[0139] Furthermore, the specific implementation steps include:

[0140] (1) Configure the large language model as a code generator based on preset prompt words;

[0141] Specifically, preset prompt words are formulated to adapt to industrial control code generation scenarios, and then these prompt words are input into the large language model to complete the configuration of the large language model into the industrial control dedicated code generator.

[0142] Furthermore, by combining coding standards in the industrial control field, syntax rules of industrial controllers such as PLCs, and code logic requirements for different industrial scenarios, preset prompt words are formulated, including code generation rules, semantic constraints, format specifications, and industrial scenario adaptation requirements. These preset prompt words are then input into the large language model to guide the model to adapt to the professional scenarios of industrial control code generation. This enables the model to recognize industrial semantic context, follow industrial control constraints, and generate standardized industrial control code, thus completing the dedicated configuration from the large language model to the code generator.

[0143] (2) Based on the system architecture layer topology, control logic layer control constraints and industrial standard specifications in the industrial knowledge graph as strong constraints, and combined with the control logic scheme of the decision instruction, the complete industrial semantic context of the industrial knowledge graph is integrated to generate industrial control code.

[0144] Specifically, the system architecture layer topology, control logic layer control constraints, and industrial standards and specifications are extracted from the industrial knowledge graph as strong constraints and solidified. The control logic scheme in the decision instructions is integrated with the complete industrial semantic context of the industrial knowledge graph, and industrial control code is generated based on the strong constraints and the integrated information.

[0145] Furthermore, the topology of each functional subsystem and component relationships in the system architecture layer, signal interaction constraints and action execution timing constraints in the control logic layer, as well as industrial standards and specifications such as safety standards and programming specifications in the industrial field are extracted from the industrial knowledge graph. These contents are used as strong constraints for code generation and are solidified to ensure that the generated code conforms to the physical architecture and operating logic of the industrial system. The control logic scheme in the decision instructions is parsed to extract the core control objectives, execution actions, parameter requirements, etc. At the same time, the complete industrial semantic context matching the scheme in the industrial knowledge graph is retrieved and the two are deeply integrated. Under the constraints of the strong constraints, the configured code generator generates industrial control code that is grammatically compliant, logically matched, and fits the actual industrial scenario based on the integrated control logic scheme and industrial semantic context.

[0146] By first configuring a large language model as a dedicated code generator for industrial control based on preset prompts, and then using the system architecture, control logic, and industrial standards of the industrial knowledge graph as strong constraints, combined with the control logic scheme of decision instructions and the complete industrial semantic context to generate code, the industrial control code generated by the large language model is always anchored to the actual architecture and core constraints of the industrial system. This effectively avoids the problems that easily occur when generating code using pure language models, such as being detached from the industrial scenario, violating control logic, and not conforming to industrial standards. It ensures that the generated code is not only syntactically correct, but also fits the physical topology and operating logic of the industrial system, greatly improving the scenario adaptability, logical accuracy, and engineering usability of industrial control code.

[0147] Furthermore, after generating the industrial control code, the method provided in this embodiment also includes:

[0148] (1) Automatically compare and verify the industrial control code and the industrial knowledge graph;

[0149] Specifically, a code verification rule system based on industrial knowledge graphs will be constructed to automatically compare and verify the generated industrial control code with the core content in the industrial knowledge graph, and comprehensively check the compliance and adaptability of the code.

[0150] Furthermore, based on the system architecture layer topology, control logic layer constraints, and industry standards and specifications in the industrial knowledge graph, an automated verification rule system is constructed, which includes code logic verification, topology matching verification, and specification compliance verification. Through a preset code parsing algorithm, the generated industrial control code is broken down into core modules such as control logic statements, equipment association instructions, and parameter configuration items. Each module is then automatically compared with the corresponding functional subsystem topology, control signal flow, and industrial programming specifications in the industrial knowledge graph to verify whether the code conforms to the industrial system physical architecture, control logic constraints, and industry standard requirements.

[0151] Furthermore, during the automatic comparison and verification process, the focus is on comparing three core aspects of the code—the component calling logic of the functional subsystems, the control signal transmission path, and the parameter configuration thresholds—with the industrial knowledge graph. The component calling logic must match the topological node associations of the functional subsystems in the graph, the control signal transmission path must conform to the preset signal flow rules in the graph, and the parameter configuration thresholds must comply with the industrial equipment safety operation standards embedded in the graph, ensuring that the verification dimensions comprehensively cover the core application scenarios of the industrial control code.

[0152] (2) If the verification fails, return to the step of generating industrial control code in combination with the decision instruction; if the verification passes, it is determined to be an industrial control code that meets the requirements.

[0153] Specifically, the code is determined to pass the verification based on the automatic comparison and verification results. If the verification fails, the process backtracking mechanism is triggered to return to the code generation step. If the verification passes, the code is identified as a qualified industrial control code.

[0154] Furthermore, the system automatically compares and verifies the results. If the code is found to have issues such as logical violations of topological relationships, instructions that do not conform to industrial standards, or parameter configurations that do not meet the requirements of the industrial knowledge graph, the verification fails. The system automatically triggers a process backtracking mechanism, returning the entire process to the step of generating industrial control code in conjunction with decision instructions. At the same time, the specific problems found during the verification are synchronized to the code generator to guide it in correcting the code generation logic. If all core modules of the code are found to match the constraints of the industrial knowledge graph and there are no violations or logical errors, the verification passes. The system marks the industrial control code as the final code that meets the requirements of industrial application scenarios, completing the full-process verification of code generation.

[0155] By automatically comparing and verifying the generated industrial control code with an industrial knowledge graph, and determining whether to backtrack the code generation steps or finalize the compliant code based on the verification results, a closed-loop verification mechanism is constructed after code generation. Using the industrial knowledge graph as a unified verification benchmark, it can automatically identify problems in the code that violate industrial system topology, control logic, and industry standards, correct code defects in a timely manner, and effectively avoid the application of code that does not conform to actual industrial scenarios. The verification process ensures the accuracy, compliance, and engineering reliability of the final output industrial control code, further improving the robustness of the entire code generation system.

[0156] This embodiment provides an industrial control code generation method based on an industrial knowledge graph. This method achieves highly reliable and low-ambiguity conversion from real-time industrial control requirements in natural language to industrial control code that conforms to industrial standards and control logic, significantly improving the efficiency and quality of industrial control code generation. By decomposing the industrial system into functional subsystems and constructing an industrial knowledge graph that integrates topological relationships, subsystem logic, and industrial specifications, a structured knowledge foundation aligned with industrial realities is laid for code generation. A query planner configured with a large language model completes requirement parsing and node type mapping, effectively avoiding the ambiguity of natural language and achieving precise requirement extraction. Through precise entity matching anchored to the knowledge graph node structure and the generation of candidate knowledge lists containing complete industrial semantics, knowledge retrieval and organization are aligned with the industrial system architecture and logic, providing a comprehensive and accurate basis for subsequent analysis. Using a large language model as a decision-maker to conduct normal and abnormal dual-mode analysis, combined with human-machine collaborative confirmation and a closed-loop abnormality correction mechanism, ensures the professionalism and scenario adaptability of decision instructions. Ultimately, by using an industrial knowledge graph as a strong constraint, a dedicated code generator generates code and completes automated verification. This effectively avoids the problems of purely algorithm-generated code being out of touch with industrial scenarios and violating control logic, ensuring that the generated code is grammatically compliant and logically matched. At the same time, it forms a closed-loop verification and correction system throughout the entire process, significantly improving the scenario adaptability, engineering usability, and operational reliability of the code, and adapting to the high requirements of standardized and secure control code in complex industrial scenarios.

[0157] Corresponding to the aforementioned embodiment of an industrial control code generation method based on an industrial knowledge graph, this application also provides an embodiment of an industrial control code generation device based on an industrial knowledge graph.

[0158] Figure 2 This is a schematic diagram of the structure of Embodiment 2 of the industrial control code generation device based on industrial knowledge graph provided in this application. Please refer to... Figure 2 The apparatus provided in this embodiment includes a splitting module 210, a building module 220, and a generating module 230;

[0159] The splitting module 210 is used to split the industrial system into multiple functional subsystems, each of which independently completes the tasks of the industrial system and is communicatively connected to the control center.

[0160] The construction module 220 is used to determine the topological relationship of each component in the functional subsystem based on the control signal flow relationship within each functional subsystem;

[0161] The construction module 220 is also used to construct an industrial knowledge graph based on the topological relationship and the logical relationship of each functional subsystem;

[0162] The generation module 230 is used to generate a list of node types according to real-time industrial control requirements.

[0163] The generation module 230 is further configured to match a set of candidate entities in the industrial knowledge graph according to the list of node types;

[0164] The generation module 230 is further configured to perform a context enrichment operation on the candidate entity set in the industrial knowledge graph to generate a candidate knowledge list;

[0165] The generation module 230 is also used to use the large language model as a decision-maker to evaluate the candidate knowledge list and output decision instructions;

[0166] The generation module 230 is further configured to use the industrial knowledge graph as a constraint and combine it with the decision instructions to generate industrial control code.

[0167] The apparatus of this embodiment can be used to perform... Figure 1 The steps of the method embodiment shown are similar in principle and process, and will not be repeated here.

[0168] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.

[0169] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0170] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A method for generating industrial control codes based on industrial knowledge graphs, characterized in that, The method includes: The industrial system is divided into multiple functional subsystems, each of which independently completes the tasks of the industrial system, and each functional subsystem is communicatively connected to the control center; The topological relationship of each component within a functional subsystem is determined based on the control signal flow relationship within each functional subsystem; An industrial knowledge graph is constructed based on the topological relationships and the logical relationships of the various functional subsystems. Generate a list of node types based on real-time industrial control requirements; Match candidate entity sets in the industrial knowledge graph based on the node type list; The candidate entity set is subjected to context enrichment operation in the industrial knowledge graph to generate a candidate knowledge list; The large language model is used as a decision-maker to evaluate the candidate knowledge list and output decision instructions; The industrial knowledge graph is used as a constraint, and combined with the decision instructions, industrial control code is generated.

2. The method according to claim 1, characterized in that, The node type list generated based on real-time industrial control requirements includes: The large language model is configured as a query planner by using preset prompt words to extract the demand text of the real-time industrial control requirements. The query planner is used to perform semantic analysis on the demand text, and the industrial control requirements of the demand text are output. The industrial control requirements are mapped to the preset knowledge entity types of the industrial knowledge graph, and a list of node types is generated based on the mapping results.

3. The method according to claim 1, characterized in that, The step of matching candidate entity sets in the industrial knowledge graph according to the node type list includes: Based on the node structure of the industrial knowledge graph, each node type in the node type list is matched with the top-level node of the corresponding functional subsystem in the industrial knowledge graph to determine the range of the top-level node of the functional subsystem for each node type. Starting from the top-level node of each functional subsystem, the search proceeds by traversing downwards layer by layer within the node structure according to the topological relationship of the components. During the traversal, entities that match the node types in the node type list are matched, and all matched entities are aggregated to form a candidate entity set.

4. The method according to claim 1, characterized in that, The step of performing context enrichment operations on the candidate entity set in the industrial knowledge graph to generate a candidate knowledge list includes: For each candidate entity in the candidate entity set, match its functional subsystem, and obtain the control signal flow association information between the candidate entity and other components in the corresponding functional subsystem based on the topological relationship within the functional subsystem. Based on the communication connection between each functional subsystem and the control center, as well as the logical relationship between each functional subsystem, the association relationship between the candidate entity and the candidate entities in other functional subsystems is obtained; By integrating the attribute information of each candidate entity, the topological association information within the same functional subsystem, and the logical association information across functional subsystems, a complete industrial semantic context for each candidate entity is formed. The complete industrial semantic contexts of all candidate entities are then compiled and summarized to generate a candidate knowledge list with complete industrial semantics.

5. The method according to claim 1, characterized in that, The step of using a large language model as a decision-maker to evaluate the candidate knowledge list and output decision instructions includes: The industrial control-related standards and constraints preset in the industrial knowledge graph are retrieved as the evaluation criteria. The attribute information, topological association information and logical association information of each entity in the candidate knowledge list are verified to confirm that there are no contradictions between each piece of information and that they conform to the basic logic of industrial control. The information in the candidate knowledge list is determined to be complete enough to meet the requirements for generating industrial control codes, and no supplementation or correction of relevant information is required. Based on the verification results, a selected class decision instruction is output, and candidate knowledge content for generating control logic schemes is determined according to the selected class decision instruction.

6. The method according to claim 5, characterized in that, The method further includes: Based on the industrial control specifications, logical relationships and topological relationships of each functional subsystem pre-set in the industrial knowledge graph, the attribute information and association information of each entity in the candidate knowledge list are checked. During the verification process, it was determined that the candidate knowledge list contained abnormal situations such as missing information, contradictory information, or information content that did not conform to the basic logic of industrial control. Based on the type of abnormal situation, the content to be supplemented was sorted out. Based on the judgment result, a supplementary decision instruction is output, and the process returns to the node type list generation stage to supplement the content to be supplemented before re-matching.

7. The method according to claim 1, characterized in that, The step of using the industrial knowledge graph as a constraint and combining it with the decision instructions to generate industrial control code includes: Configure the large language model as a code generator based on preset prompt words; Based on the system architecture layer topology, control logic layer control constraints, and industrial standards and specifications in the industrial knowledge graph, and combined with the control logic scheme of the decision instructions, industrial control code is generated by integrating the complete industrial semantic context of the industrial knowledge graph.

8. The method according to claim 1, characterized in that, After generating industrial control code, the method further includes: The industrial control code and the industrial knowledge graph are automatically compared and verified. If the verification fails, return to the step of generating industrial control code in conjunction with the decision instruction; if the verification passes, it is determined to be a qualified industrial control code.

9. The method according to claim 1, characterized in that, After outputting the decision instruction, the method further includes: The decision instruction is sent to the user terminal for user confirmation. If the user confirms, proceed with the code generation step; If the user does not confirm, return to the step of generating the candidate knowledge list.

10. An industrial control code generation device based on an industrial knowledge graph, characterized in that, The device includes a splitting module, a building module, and a generating module; The splitting module is used to split the industrial system into multiple functional subsystems. Each functional subsystem independently completes the tasks of the industrial system, and each functional subsystem is communicatively connected to the control center. The construction module is used to determine the topological relationship of each component in each functional subsystem based on the control signal flow relationship within each functional subsystem; The construction module is also used to construct an industrial knowledge graph based on the topological relationship and the logical relationship of each functional subsystem; The generation module is used to generate a list of node types based on real-time industrial control requirements; The generation module is also used to match a set of candidate entities in the industrial knowledge graph according to the list of node types; The generation module is further configured to perform context enrichment operations on the candidate entity set in the industrial knowledge graph to generate a candidate knowledge list; The generation module is also used to use the large language model as a decision-maker to evaluate the candidate knowledge list and output decision instructions; The generation module is further configured to use the industrial knowledge graph as a constraint and combine it with the decision instructions to generate industrial control code.

Citation Information

Patent Citations

  • Code generation method based on graph alignment coding large model and multi-agent collaboration

    CN120508285A

  • Structured text code generation and review method

    CN120743231A

  • Automatic control code generation and verification method and device, equipment and storage medium

    CN120406914A

  • Industrial control logic intelligent generation system and method

    CN121349424A

  • A method for controlling a sub-system of an industrial plant

    WO2025242746A1