Digital factory MES software code automatic generation method
Patent Information
- Application Number
- CN202610805907.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-05
- Publication Date
- 2026-09-01
AI Technical Summary
[0005]因此,本发明提供了一种数字工厂MES软件代码自动化生成方法,解决MES代码生成过程缺乏语义理解、自适应演化与仿真验证能力的问题
[0016] The beneficial effects of this invention are as follows: By extracting semantic features and performing structured modeling on historical and real-time operational data of digital factories, a manufacturing semantic model is established and trained with real-time data to form an evolutionary semantic parameter model. This enables the dynamic expression of manufacturing knowledge and production logic, and allows for adaptive optimization of code generation logic based on data changes. By using the semantic parameter model to parse user-proposed MES functional requirements, a code logic list is generated, and target code is obtained by combining it with a preset rule set. An interpretable rule mapping table is established during the generation process, realizing a one-to-one correspondence between target code and manufacturing semantics, making the code generation process transparent and traceable. The target code is virtually executed through digital twin simulation, and the generation process data is uploaded to the database, enabling simulation verification and continuous optimization of code functionality, thereby improving the automation and reliability of MES software development.
Smart Images

Figure CN122672770A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial software automation technology, and in particular to a method for automatically generating MES software code for digital factories. Background Technology
[0002] With the continuous development of industrial informatization and intelligent manufacturing, Manufacturing Execution Systems (MES) are playing an increasingly important role in digital factories. MES serves as the middleware layer connecting Enterprise Resource Planning (ERP) systems and production equipment control systems, with its core objective being to achieve real-time monitoring, scheduling optimization, quality traceability, and equipment status management of the production process. Traditional MES software typically relies on manual requirements analysis and coding to implement its functions, with the design and optimization of code logic primarily handled by software engineers based on business needs and system architecture experience.
[0003] In existing MES development technologies, system functional requirements are often input in the form of structured documents or formal statements, and the code generation module generates the corresponding program structure according to fixed rule templates. While this approach shortens the development cycle to some extent, it lacks real-time perception and self-learning capabilities for dynamic data from the manufacturing site, making it difficult to automatically adjust the generation logic according to changes in the production environment. Furthermore, manufacturing data typically exhibits characteristics of multi-source heterogeneity and semantic complexity. Existing methods are relatively static in terms of data semantic modeling and semantic association rule generation, resulting in weak logical interpretability of the generated code. Summary of the Invention
[0004] In view of the aforementioned existing problems, the present invention is proposed.
[0005] Therefore, this invention provides an automated method for generating MES software code in digital factories, which solves the problems of lack of semantic understanding, adaptive evolution and simulation verification capabilities in the MES code generation process.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for automatically generating software code for a digital factory (MES) system, comprising, Collect historical and real-time operational data of the digital factory, extract semantic features and perform structured modeling on the collected historical data to obtain a manufacturing semantic model, and use real-time operational data to train the manufacturing semantic model to obtain an evolvable semantic parameter model. The semantic parameter model is used to parse the MES functional requirements proposed by the user, generate a list of code logic to be implemented, and obtain the target code by combining the preset generation rule set. During the process of obtaining the target code, an interpretability rule mapping table is established to generate target code with semantic interpretation. The generated target code is simulated using digital twin simulation, and the data generated during the target code generation process is uploaded to the database.
[0007] As a preferred embodiment of the automated generation method for digital factory MES software code described in this invention, the following steps are taken: collecting historical data and real-time operation data of the digital factory, extracting semantic features and performing structured modeling on the collected historical data to obtain a manufacturing semantic model; collecting historical data and real-time operation data of the digital factory, putting the collected historical data and real-time operation data into the original dataset, normalizing the original dataset to obtain a standardized dataset, and performing semantic feature recognition on the standardized dataset to extract semantic features. All extracted semantic features are placed into a semantic feature set, which includes a set of historical data features and a set of real-time running data features. The set of historical data features in the semantic feature set is analyzed to identify the entity categories in the manufacturing process. The relationships between entities are identified based on the correlation between features. The frequency of occurrence and the strength of dependence of each relationship are obtained by analyzing historical data, and the weights between relationships are obtained. By assembling entities and relationships into a graph structure, with each entity as a node in the graph, each relationship as an edge, and the weights between relationships as the edge weights of each edge, a semantic model is created.
[0008] As a preferred embodiment of the automated generation method for digital factory MES software code described in this invention, the step of training the manufacturing semantic model with real-time running data to obtain an evolvable semantic parameter model refers to comparing the set of real-time running data feature items in the semantic feature set with the semantic model, calculating the similarity between the entity relationships in the manufacturing semantic model and the real-time running data, and adjusting the weights of the relationships in the model based on the calculated similarity values. By continuously optimizing the manufacturing semantic model based on real-time operational data, an evolutionary semantic parameter model is obtained.
[0009] As a preferred embodiment of the automated code generation method for digital factory MES software described in this invention, the step of using a semantic parameter model to parse the user-proposed MES functional requirements and generate a list of code logic to be implemented refers to extracting the semantic features of the user requirements, inputting the extracted semantic features into the trained semantic parameter model, parsing the semantic features of the user requirements into corresponding logical tasks based on entities and relationships, mapping the identified logical tasks into specific operation steps, matching corresponding code templates for the operation steps, and combining all code templates according to dependencies to generate a list of code logic to be implemented.
[0010] As a preferred embodiment of the automated code generation method for digital factory MES software described in this invention, the step of obtaining the target code by combining a preset set of generation rules refers to matching the code logic list to be implemented with the preset set of generation rules, determining the specific implementation method of each code segment in the code logic list, arranging all code segments in the order of the code logic list to be implemented, and obtaining the complete target code.
[0011] As a preferred embodiment of the automated generation method for digital factory MES software code described in this invention, the step of establishing an interpretability rule mapping table during the acquisition of target code and generating target code with semantic interpretation refers to defining an interpretability rule mapping table before the target code is generated, performing semantic interpretation mapping on each code segment according to the set of interpretability rules after obtaining the target code, and generating target code with semantic interpretation based on the mapping result.
[0012] As a preferred embodiment of the digital factory MES software code automated generation method described in this invention, the step of using digital twin simulation to virtually execute the generated target code refers to establishing a digital twin model based on the equipment and historical data of the digital factory, inputting the generated target code with semantic interpretation into the digital twin model, setting the simulation step size and cyclically simulating in the digital twin model, recording the output simulation data, and calculating the simulation indicators of the main performance based on the simulation data, including average production cycle time, equipment utilization rate and on-time delivery rate. Calculate the deviation values between the main performance simulation indicators and the required indicators; Set deviation threshold ,like If the generated target code is unqualified, it needs to be regenerated. This indicates that the generated target code is qualified.
[0013] As a preferred embodiment of the automated code generation method for digital factory MES software described in this invention, the step of uploading the data generated during the generation of target code to the database refers to saving semantic feature data, structured modeling data, semantic parameter model training data, rule matching data, and the generated target code data to the database.
[0014] In a second aspect, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, it implements any step of the digital factory MES software code automated generation method as described in the first aspect of the present invention.
[0015] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the automated generation method for digital factory MES software code as described in the first aspect of the present invention.
[0016] The beneficial effects of this invention are as follows: By extracting semantic features and performing structured modeling on historical and real-time operational data of digital factories, a manufacturing semantic model is established and trained with real-time data to form an evolutionary semantic parameter model. This enables the dynamic expression of manufacturing knowledge and production logic, and allows for adaptive optimization of code generation logic based on data changes. By using the semantic parameter model to parse user-proposed MES functional requirements, a code logic list is generated, and target code is obtained by combining it with a preset rule set. An interpretable rule mapping table is established during the generation process, realizing a one-to-one correspondence between target code and manufacturing semantics, making the code generation process transparent and traceable. The target code is virtually executed through digital twin simulation, and the generation process data is uploaded to the database, enabling simulation verification and continuous optimization of code functionality, thereby improving the automation and reliability of MES software development. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A flowchart for the automated generation method of MES software code in a digital factory.
[0019] Figure 2 To generate the target code flowchart. Detailed Implementation
[0020] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0021] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0022] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0023] Reference Figure 1 and Figure 2 This is one embodiment of the present invention, which provides a method for automatically generating software code for a digital factory MES, comprising the following steps: Historical and real-time operational data of the digital factory are collected. Semantic features are extracted and structured modeling is performed on the collected historical data to obtain a manufacturing semantic model. The manufacturing semantic model is trained using real-time operational data to obtain an evolutionary semantic parameter model.
[0024] Specifically, historical and real-time operational data from the digital factory are collected, and these data are then placed into a raw dataset. The raw dataset is normalized to obtain a standardized dataset. Semantic feature recognition is then performed on the standardized dataset to extract semantic features, using the following formula: ; in, For the first Class semantic features For the first The comprehensive value of semantic features of class, For the first One observed attribute, For the first The number of observed attributes of class semantic features, For the first In the semantic features of the class, the first Each observed attribute value, The first determined by experience The semantic importance weight of each observed attribute.
[0025] All extracted semantic features are placed into a semantic feature set, which includes a set of historical data features and a set of real-time running data features. The set of historical data features in the semantic feature set is analyzed to identify the entity categories in the manufacturing process. The relationships between entities are identified based on the correlation between features. The frequency of occurrence and the strength of dependence of each relationship are obtained by analyzing historical data, and the weights between relationships are obtained. By assembling entities and relationships into a graph structure, with each entity as a node in the graph, each relationship as an edge, and the weights between relationships as the edge weights of each edge, a semantic model is created.
[0026] By uniformly collecting and normalizing historical and real-time operational data from the digital factory, consistent representation of multi-source heterogeneous data was achieved. Through semantic feature recognition and feature set construction, implicit semantics in manufacturing data were extracted and classified. By analyzing the relationships between features and calculating relationship weights, the quantitative expression of the dependence strength between entities in manufacturing knowledge was achieved. By constructing entities and relationships into a graph structure model, semantic, structured, and computable representation of manufacturing knowledge was realized, improving the accuracy and adaptability of the digital factory in data understanding, knowledge modeling, and subsequent intelligent decision-making.
[0027] Furthermore, the set of real-time running data feature items in the semantic feature set is compared with the semantic model to calculate the similarity between the entity relationships in the semantic model and the real-time running data. The formula is as follows: ; in, To create relations in the semantic model, For a set of real-time running data features, To generate similarity between entity relationships in the semantic model and real-time running data, To determine the number of features in the set of real-time running data features, For the set of real-time running data features, the first Each feature term To create the semantic model The relevant weights of each feature term.
[0028] The weights of relationships in the model are adjusted based on the calculated similarity values, using the following formula: ; in, For the adjusted number The correlation weights of the relationships between each feature term The learning rate is set to control the update pace.
[0029] By continuously optimizing the manufacturing semantic model based on real-time operational data, an evolutionary semantic parameter model is obtained.
[0030] By comparing the set of real-time running data features with the manufacturing semantic model, dynamic association and matching between the manufacturing semantic model and the current production state are achieved. This enables the manufacturing semantic model to perceive changes in the actual manufacturing process and adjust the relational weights within the model accordingly. Through a similarity-based weight adjustment mechanism, the manufacturing semantic model can self-correct and evolve under continuous data input, gradually forming an evolvable semantic parameter model.
[0031] The semantic parameter model is used to parse the user's proposed MES functional requirements, generate a list of code logic to be implemented, and obtain the target code by combining it with a set of preset generation rules. During the process of obtaining the target code, an interpretability rule mapping table is established to generate target code with semantic explanation.
[0032] Specifically, semantic features of user needs are extracted and input into a trained semantic parameter model. The semantic parameter model parses the semantic features of user needs into corresponding logical tasks based on entities and relationships, maps the identified logical tasks into specific operation steps, matches corresponding code templates for operation steps, and combines all code templates according to dependencies to generate a list of code logic to be implemented.
[0033] By extracting the semantic features of user needs and inputting them into the trained semantic parameter model, a semantic correspondence between user needs and the manufacturing semantic model is achieved, enabling the semantic parameter model to automatically identify the business logic and functional goals implicit in the needs. Through the model's parsing of entities and relationships, user needs are transformed into logical tasks, realizing automatic mapping from natural language needs to logical structures and reducing reliance on manual analysis. By mapping the identified logical tasks to specific operation steps and matching them with corresponding code templates, the automatic generation of functional requirements into code implementation paths is achieved, ensuring that the code structure is consistent with the business logic.
[0034] Furthermore, the list of code logic to be implemented is matched with the preset set of generation rules to determine the specific implementation method of each code segment in the list of code logic. All code segments are arranged in the order of the list of code logic to be implemented to obtain the complete target code.
[0035] By matching the list of code logic to be implemented with the preset set of generation rules, the automatic correspondence between code logic and generation rules is achieved. The appropriate implementation method can be automatically selected according to functional requirements, ensuring the accuracy of the generated code in terms of structure and logic.
[0036] Furthermore, before generating the target code, an interpretability rule mapping table is defined. After obtaining the target code, each code segment is semantically interpreted and mapped according to the set of interpretability rules. Based on the mapping results, target code with semantic interpretation is generated.
[0037] By defining an interpretability rule mapping table before target code generation, a semantic interpretation mechanism is introduced into the code generation stage, enabling the code generation process to have traceable logical meaning and behavioral description. Semantic mapping of the target code based on the set of interpretability rules achieves a one-to-one correspondence between code logic and manufacturing semantics, so that the generated code not only has execution function, but also reflects its design intent and business meaning in a semantic way.
[0038] The generated target code is simulated using digital twin simulation, and the data generated during the target code generation process is uploaded to the database.
[0039] Specifically, based on the equipment and historical data of the digital factory, a digital twin model is established. The generated target code with semantic interpretation is input into the digital twin model. The simulation step size is set and the simulation is carried out in a loop in the digital twin model. The output simulation data is recorded. The simulation indicators of the main performance are calculated based on the simulation data, including average production cycle time, equipment utilization rate and on-time delivery rate. The deviation between the main performance simulation indicators and the required indicators is calculated using the following formula: ; in, The deviation values between the main performance simulation indicators and the required indicators. , , These are simulation metrics for average production cycle time, equipment utilization rate, and on-time delivery rate, respectively. , , These are the required indicators for average production cycle time, equipment utilization rate, and on-time delivery rate, respectively.
[0040] Set deviation threshold ,like If the generated target code is unqualified, it needs to be regenerated. This indicates that the generated target code is qualified.
[0041] By establishing a digital twin model based on equipment and historical data from a digital factory, a virtual mapping and dynamic simulation environment were constructed, enabling the verification of the execution effect of the target code without the need for actual operation. By inputting the target code with semantic interpretation into the digital twin model and setting the simulation step size for cyclic simulation, dynamic testing and performance evaluation of the code logic in a virtual production environment were achieved.
[0042] Furthermore, semantic feature data, structured modeling data, semantic parameter model training data, rule matching data, and generated target code data are saved to the database.
[0043] By uniformly storing semantic feature data, structured modeling data, semantic parameter model training data, rule matching data, and generated target code data in a database, centralized management and traceability of data throughout the entire generation process are achieved. This allows for tracking and reuse of different data stages in subsequent phases, ensuring the continuity of model training, code generation, and verification processes.
[0044] This embodiment also provides a computer device applicable to the automated generation method of digital factory MES software code, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the automated generation method of digital factory MES software code as proposed in the above embodiment.
[0045] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0046] This embodiment also provides a storage medium storing a computer program, which, when executed by a processor, implements the method for automatically generating software code for a digital factory MES as proposed in the above embodiments. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0047] In summary, this invention achieves dynamic expression of manufacturing knowledge and production logic by: extracting semantic features and performing structured modeling on historical and real-time operational data of a digital factory; establishing a manufacturing semantic model and training it with real-time data to form an evolutionary semantic parameter model; and adaptively optimizing code generation logic based on data changes. Furthermore, by using the semantic parameter model to parse user-submitted MES functional requirements, a code logic list is generated and target code is obtained by combining it with a preset rule set. An interpretable rule mapping table is established during the generation process, achieving a one-to-one correspondence between target code and manufacturing semantics, making the code generation process transparent and traceable. Finally, by virtually executing the target code through digital twin simulation and uploading the generation process data to a database, simulation verification and continuous optimization of code functionality are achieved, improving the automation and reliability of MES software development.
[0048] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for automatically generating software code for a digital factory (MES), characterized in that: include, Collect historical and real-time operational data of the digital factory, extract semantic features and perform structured modeling on the collected historical data to obtain a manufacturing semantic model, and use real-time operational data to train the manufacturing semantic model to obtain an evolvable semantic parameter model. The semantic parameter model is used to parse the MES functional requirements proposed by the user, generate a list of code logic to be implemented, and obtain the target code by combining the preset generation rule set. During the process of obtaining the target code, an interpretability rule mapping table is established to generate target code with semantic interpretation. The generated target code is simulated using digital twin simulation, and the data generated during the target code generation process is uploaded to the database.
2. The method for automatically generating software code for a digital factory MES as described in claim 1, characterized in that: The process involves collecting historical and real-time operational data from the digital factory, extracting semantic features and performing structured modeling on the collected historical data to obtain a manufacturing semantic model. This involves collecting historical and real-time operational data from the digital factory, placing the collected historical and real-time operational data into the original dataset, normalizing the original dataset to obtain a standardized dataset, and then performing semantic feature recognition on the standardized dataset to extract semantic features. All extracted semantic features are placed into a semantic feature set, which includes a set of historical data features and a set of real-time running data features. The set of historical data features in the semantic feature set is analyzed to identify the entity categories in the manufacturing process. The relationships between entities are identified based on the correlation between features. The frequency of occurrence and the strength of dependence of each relationship are obtained by analyzing historical data, and the weights between relationships are obtained. By assembling entities and relationships into a graph structure, with each entity as a node in the graph, each relationship as an edge, and the weights between relationships as the edge weights of each edge, a semantic model can be created.
3. The method for automatically generating software code for a digital factory MES as described in claim 2, characterized in that: The process of training the manufacturing semantic model using real-time running data to obtain an evolvable semantic parameter model involves comparing the set of real-time running data feature items in the semantic feature set with the semantic model, calculating the similarity between the entity relationships in the manufacturing semantic model and the real-time running data, and adjusting the weights of the relationships in the model based on the calculated similarity values. By continuously optimizing the manufacturing semantic model based on real-time operational data, an evolutionary semantic parameter model is obtained.
4. The method for automatically generating software code for a digital factory MES as described in claim 3, characterized in that: The process of using a semantic parameter model to parse the user's proposed MES functional requirements and generate a list of code logic to be implemented involves extracting the semantic features of the user's requirements, inputting the extracted semantic features into the trained semantic parameter model, parsing the semantic features of the user's requirements into corresponding logical tasks based on entities and relationships, mapping the identified logical tasks into specific operation steps, matching corresponding code templates for the operation steps, and combining all the code templates according to their dependencies to generate a list of code logic to be implemented.
5. The method for automatically generating software code for a digital factory MES as described in claim 4, characterized in that: The step of obtaining the target code by combining the preset generation rule set refers to matching the code logic list to be implemented with the preset generation rule set, determining the specific implementation method of each code segment in the code logic list, arranging all code segments in the order of the code logic list to be implemented, and obtaining the complete target code.
6. The method for automatically generating software code for a digital factory MES as described in claim 5, characterized in that: The step of establishing an interpretability rule mapping table during the acquisition of target code and generating target code with semantic explanation refers to defining an interpretability rule mapping table before the target code is generated, performing semantic explanation mapping on each code segment according to the set of interpretability rules after the target code is obtained, and generating target code with semantic explanation based on the mapping results.
7. The method for automatically generating software code for a digital factory MES as described in claim 6, characterized in that: The process of virtually executing the generated target code using digital twin simulation refers to establishing a digital twin model based on the equipment and historical data of the digital factory, inputting the generated target code with semantic interpretation into the digital twin model, setting the simulation step size, cyclically simulating in the digital twin model, recording the output simulation data, and calculating the simulation indicators of the main performance based on the simulation data, including average production cycle time, equipment utilization rate, and on-time delivery rate. Calculate the deviation values between the main performance simulation indicators and the required indicators; Set deviation threshold ,like If the generated target code is unqualified, it needs to be regenerated. This indicates that the generated target code is qualified.
8. The method for automatically generating software code for a digital factory MES as described in claim 7, characterized in that: Uploading the data generated during the process of generating target code to the database refers to saving semantic feature data, structured modeling data, semantic parameter model training data, rule matching data, and generated target code data to the database.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the digital factory MES software code automated generation method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the automated generation method for digital factory MES software code as described in any one of claims 1 to 8.