A method for automated generation of MES software code in digital factories
By constructing an evolvable semantic parameter model and digital twin simulation technology, the problems of long MES software development cycle and low code matching degree are solved, realizing the automated generation of MES software code and efficient and reliable code logic adaptation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SICHUAN NORMAL UNIV
- Filing Date
- 2026-03-27
- Publication Date
- 2026-06-30
AI Technical Summary
Traditional MES software development relies on manual requirements analysis and coding, resulting in long development cycles. The generated code logic cannot adapt to the dynamic iteration of the factory production process, and the generated code has a low degree of matching with the actual manufacturing business logic. It also lacks real-time perception and self-learning capabilities, and the simulation verification cost is high.
By collecting historical and real-time data from digital factories, an evolvable semantic parameter model is constructed. This model is then trained and optimized using real-time data to generate target code with semantic explanations. Digital twin simulation is then used to verify the code, achieving fully automated generation throughout the entire process.
It achieves transparency and traceability in the code generation process, improves development efficiency and code reliability, and enhances the compatibility of code generation logic with the production environment, thereby reducing debugging costs and risks.
Smart Images

Figure CN121918839B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of electronic digital data processing and industrial software automation, and in particular to a method for automatically generating MES software code for digital factories. Background Technology
[0002] With the deep integration of industrial informatization and intelligent manufacturing, Manufacturing Execution Systems (MES), as the core middleware connecting Enterprise Resource Planning (ERP) systems and Production Control Systems (PCS), have become a key carrier for digital factories to achieve real-time monitoring, scheduling optimization, quality traceability, and equipment status management of the production process. The development of traditional MES software relies heavily on manual completion of requirements analysis, logic design, and manual coding. Development efficiency is limited by the business experience and technical capabilities of engineers, and the development cycle usually takes months or even years.
[0003] While existing technologies have developed semi-automatic MES code generation methods based on fixed rule templates, which shorten the development cycle to some extent by inputting requirements through structured documents and matching them with templates, several technical shortcomings remain: First, these methods employ static semantic models, lacking real-time perception and self-learning capabilities for multi-source heterogeneous dynamic data from the manufacturing site. They cannot automatically adjust the code generation logic according to changes in the production environment, and the generated code is difficult to adapt to the dynamic iteration of the factory production process. Second, the semantic modeling of manufacturing data only reaches the surface feature matching level, failing to quantify and dynamically optimize entity relationships. The semantic interpretability of the code generation process is weak, and the matching degree between the generated code and the actual manufacturing business logic is low, with an average accuracy rate of less than 60%. Third, there is no effective simulation verification process. Logical vulnerabilities can only be discovered after the generated code is deployed in the actual production environment, resulting in high debugging costs and a development cycle that can only be shortened by about 20%. The degree of automation and reliability cannot meet the intelligent development requirements of digital factories.
[0004] Therefore, a method for automatically generating software code for digital factory MES is proposed to solve the above problems. Summary of the Invention
[0005] This invention overcomes the shortcomings of the prior art and provides a method for automatically generating software code for digital factory MES.
[0006] To achieve the above objectives, the technical solution adopted by this invention is: a method for automatically generating software code for a digital factory (MES), comprising the following steps:
[0007] S1. 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;
[0008] Based on the essential technical features of real-time data similarity comparison, dynamic adjustment of relation weights, and learning rate control, the manufacturing semantic model is continuously trained and optimized using real-time running data to obtain an evolutionary semantic parameter model that can iterate according to changes in the digital factory production environment. This model is different from the static semantic model with fixed parameters and can adaptively adjust the code generation logic.
[0009] S2. Use the evolvable semantic parameter model to parse the MES functional requirements proposed by the user, generate a list of code logic to be implemented, obtain the target code by combining the preset generation rule set, establish an interpretability rule mapping table in the process of obtaining the target code, and generate target code with semantic explanation.
[0010] S3. Use digital twin simulation to simulate the generated target code, determine whether the code is qualified based on the simulation results, and upload all the data generated during the generation of the target code to the database to provide data support for the continuous optimization of the evolvable semantic parameter model.
[0011] In a preferred embodiment of the present invention, step S1, which involves extracting semantic features and performing structured modeling on the collected historical data to obtain a manufacturing semantic model, specifically includes:
[0012] S11. Integrate the collected historical data and real-time operational data into a raw dataset. Normalize the raw dataset to obtain a standardized dataset. Use a weighted summation formula to perform semantic feature recognition and extract semantic features from the standardized dataset. The formula is as follows: Where i is the i-th semantic feature, f i Let be the comprehensive value of the i-th semantic feature, j be the j-th observed attribute, n be the number of observed attributes of the i-th semantic feature, and a be the comprehensive value of the i-th semantic feature. ij Let ω be the value of the j-th observed attribute in the i-th semantic feature class. j The semantic importance weight of the j-th observation attribute is set based on manufacturing business experience;
[0013] S12. Put all the extracted semantic features into a semantic feature set that includes a set of historical data features and a set of real-time running data features. Analyze the set of historical data features to identify the entity categories and relationships between entities in the manufacturing process. Statistically count the frequency of occurrence and dependence strength of various relationships in the historical data and calculate the weights between relationships.
[0014] S13. Construct a semantic model for the manufacturing of graph structures by treating entities as graph nodes, relations as graph edges, and the weights between relations as edge weights.
[0015] In a preferred embodiment of the present invention, step S1, which involves training and optimizing an evolvable semantic parameter model based on real-time data similarity comparison, dynamic adjustment of relation weights, and learning rate regulation, specifically includes:
[0016] S14. Perform feature matching between the real-time running data feature set and the manufacturing semantic model, using the cosine similarity formula. Calculate the similarity between entity relationships in the manufacturing semantic model and real-time operational data, where r represents the relationship in the manufacturing semantic model, and F... real Let m be the set of real-time running data feature items, and f be the number of features in the set of real-time running data feature items. real,k For the k-th feature item in the set of real-time running data features, To generate the relevant weights for the k-th feature term in the semantic model, The relevant weights of the relationship of the kth feature term after adjustment.
[0017] S15, Set the learning rate The learning rate The value ranges from 0.01 to 0.1, and is dynamically adapted according to the collection frequency of real-time operation data of the digital factory. The calculated similarity value is then adjusted using a weighting formula. Dynamically adjust the entity relationship weights in the manufacturing semantic model;
[0018] S16. Based on the continuous input of real-time operation data of the digital factory, repeat the above similarity calculation and weight adjustment steps, and iteratively optimize the manufacturing semantic model at a frequency of once every 10 to 60 minutes to obtain an evolvable semantic parameter model.
[0019] In a preferred embodiment of the present invention, step S2 uses an evolvable semantic parameter model to parse the MES functional requirements and generate a list of code logic to be implemented, specifically including:
[0020] S21. Extract semantic features from the MES functional requirements proposed by the user to obtain the semantic features of the requirements;
[0021] S22. Input the demand semantic features into the trained evolvable semantic parameter model, and the evolvable semantic parameter model parses the demand semantic features into corresponding logical tasks based on the pre-stored entities and quantization relationships.
[0022] S23. Map the identified logical tasks into specific operational steps that can be executed by the computer, match a preset standardized code template for each operational step, and combine and sort all code templates according to the order and dependencies of the operational steps to generate a list of code logic to be implemented.
[0023] In a preferred embodiment of the present invention, step S2, which involves obtaining the target code by combining a preset set of generation rules, specifically includes:
[0024] S24. Preset a set of generation rules, which includes code syntax rules, business logic implementation rules, and industrial software adaptation rules. Match the code logic list to be implemented with the set of generation rules segment by segment to determine the specific implementation method of each code segment in the code logic list.
[0025] S25. All the matched code snippets are concatenated and compiled according to the order and dependencies in the code logic list to obtain the complete target code.
[0026] In a preferred embodiment of the present invention, step S2, which involves establishing an interpretability rule mapping table and generating target code with semantic explanations, specifically includes:
[0027] S26. Before generating the target code, define an interpretability rule mapping table, which contains a one-to-one correspondence between code snippets, manufacturing semantics, and business functions.
[0028] S27. After obtaining the complete target code, perform semantic interpretation mapping on each code segment according to the interpretability rule mapping table, add corresponding manufacturing semantic description and business function description to each code segment, and generate target code with semantic interpretation.
[0029] In a preferred embodiment of the present invention, step S3 uses digital twin simulation to simulate the target code and determine whether the code is qualified, specifically including:
[0030] S31. Based on the physical equipment parameters, production process flow, and historical operation data of the digital factory, construct a 1:1 digital twin model;
[0031] S32. Input the target code with semantic interpretation into the digital twin model, set the simulation step size to 0.5~2s, perform cyclic simulation in the digital twin model, and record all simulation data.
[0032] S33. Calculate the three core performance simulation indicators—average production cycle time, equipment utilization rate, and on-time delivery rate—based on simulation data, using the Euclidean distance formula. Calculate the deviation between the core performance simulation indicators and the preset requirements of the digital factory. Here, Dev represents the deviation between the core performance simulation indicators and the required indicators, and E1, E2, and E3 are the simulation indicators 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.
[0033] S34. Set the Deviation Threshold. thr If Dev ≥ Dev thrIf the target code is deemed unqualified, the process returns to step S2, where the user's MES functional requirements are parsed and a code logic list is generated, to regenerate the target code. If Dev... <Dev thr If so, the target code is deemed qualified.
[0034] In a preferred embodiment of the present invention, in step S3, all data generated during the generation of target code is uploaded to the database. Specifically, the semantic feature data, structured modeling data, evolvable semantic parameter model training data, rule matching data, simulation verification data, and generated target code data are standardized, and all standardized data are uniformly saved to the industrial database.
[0035] The training data for the evolvable semantic parameter model includes similarity calculation data, weight adjustment data, and learning rate configuration data.
[0036] Another technical solution adopted by the present invention is a device, which is a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the above-described digital factory MES software code automated generation method.
[0037] Another technical solution adopted by the present invention is a storage medium, which is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the above-described digital factory MES software code automated generation method.
[0038] This invention addresses the shortcomings of the prior art and has the following beneficial effects:
[0039] (1) This invention extracts semantic features and structures models the historical and real-time operation data of the digital factory to establish a manufacturing semantic model and trains it with real-time data to form an evolutionary semantic parameter model, thereby realizing the dynamic expression of manufacturing knowledge and production logic. The code generation logic can be adaptively optimized according to data changes. By using the semantic parameter model to parse the MES functional requirements proposed by the user, a code logic list is generated and the target code is obtained by combining it with the preset rule set. An interpretable rule mapping table is established during the generation process, realizing a one-to-one correspondence between the target code and the 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, realizing the simulation verification and continuous optimization of the code function, and improving the automation and reliability of MES software development.
[0040] (2) This invention constructs an evolutionary semantic parameter model that supports real-time data similarity comparison, dynamic adjustment of relation weights and learning rate control. Combined with a cyclic iterative optimization mechanism every 10 to 60 minutes, it breaks the limitations of existing static semantic models. The model can self-iterate and adaptively adjust the code generation logic according to changes in the digital factory production environment, achieving accurate adaptation to the dynamic production process of the manufacturing site and solving the core problem that traditional code generation logic cannot keep up with production iteration.
[0041] (3) This invention achieves quantitative analysis of entity relationships by performing structured modeling of manufacturing data. At the same time, an interpretability rule mapping table is established during the code generation process to match the corresponding manufacturing semantics and business function descriptions for each segment of the target code. This upgrades code generation from surface feature matching to deep semantic association, greatly improving the matching degree between the generated code and the actual manufacturing business logic. Moreover, the code has clear semantic interpretability, which is convenient for subsequent debugging and secondary development.
[0042] (4) This invention realizes the full-process automated generation from user MES functional requirements to target code, without the need for manual intervention in complex logic design and manual coding. At the same time, it introduces a 1:1 digital twin simulation verification mechanism, which completes the virtual verification of code through cyclic simulation with a simulation step size of 0.5~2s. Unqualified code can be returned to the requirement parsing node for regeneration, which not only greatly improves the efficiency of MES code development and shortens the development cycle, but also avoids the debugging costs and production risks of directly putting the code into production, thus improving the reliability of the code. Attached Figure Description
[0043] The present invention will be further described below with reference to the accompanying drawings and embodiments;
[0044] Figure 1 A flowchart for the automated generation method of MES software code in a digital factory.
[0045] Figure 2 To generate the target code flowchart. Detailed Implementation
[0046] 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.
[0047] 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.
[0048] 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.
[0049] like Figure 1 and Figure 2 As shown, a method for automating the generation of MES software code in a digital factory includes the following steps:
[0050] S1. Collect data and construct an optimized semantic parameter model.
[0051] Historical and real-time operational data of the digital factory are collected. Historical data includes production process data, equipment operation history data, quality inspection data, and production scheduling data, with a minimum of 5TB of historical data collected per factory. Real-time operational data is acquired through factory equipment sensors, production execution terminals, and industrial IoT gateways, with a collection frequency adapted to the factory's production rhythm of 1Hz~10Hz, achieving millisecond-level real-time performance. Semantic feature extraction and structured modeling are performed on the collected historical data to obtain a manufacturing semantic model. Based on necessary technical features such as real-time data similarity comparison, dynamic adjustment of relation weights, and learning rate control, the manufacturing semantic model is continuously trained and optimized to obtain an iterative, evolvable semantic parameter model that can adapt to changes in the production environment.
[0052] S11. Data Processing and Semantic Feature Extraction
[0053] Historical data and real-time operational data were integrated into a raw dataset. A min-max normalization algorithm was used to process the raw dataset, eliminating dimensional differences between the data. After standardization, the data bias rate was controlled within ±0.02, resulting in a standardized dataset. Semantic features were then identified and extracted from the standardized dataset using a weighted summation formula: Where i is the i-th semantic feature, fi is the comprehensive value of the i-th semantic feature, j is the j-th observed attribute, n is the number of observed attributes of the i-th semantic feature, aij is the value of the j-th observed attribute in the i-th semantic feature, and ω j ω is the semantic importance weight of the j-th observation attribute, set based on manufacturing business experience. j The value range is 0.01 to 0.2.
[0054] S12. Semantic Feature Analysis and Relation Weight Calculation
[0055] All extracted semantic features are placed into a semantic feature set containing both historical data feature sets and real-time operational data feature sets. The historical data feature set is analyzed separately, and an industrial semantic recognition algorithm based on BERT is used to identify entity categories such as equipment, processes, materials, personnel, and quality inspection nodes in the manufacturing process. The entity recognition accuracy is over 98.5%. Based on the correlation between features, the relationships between entities, such as operation, dependency, association, and triggering, are identified. The frequency and dependency strength of various relationships in the historical data are statistically analyzed, and the weights between relationships are calculated using the Pearson correlation coefficient method. The weight values are 0 to 1, with higher values indicating stronger correlations between the corresponding entities.
[0056] S13, Constructing a manufacturing semantic model of graph structure
[0057] The identified manufacturing process entities are used as graph nodes, the relationships between entities are used as graph edges, and the calculated weights between relationships are used as edge weights. A graph neural network (GNN) modeling method is used to construct a graph-structured manufacturing semantic model. This model can quantitatively express the entity relationships in the manufacturing process. The model achieves a semantic representation accuracy of over 98.0% for manufacturing business, providing a solid foundation for semantic parsing in subsequent code generation.
[0058] S14. Real-time data similarity calculation
[0059] The set of real-time operational data features in the semantic feature set is matched against the manufacturing semantic model in all dimensions. The similarity between the entity relationships in the manufacturing semantic model and the real-time operational data is calculated using the cosine similarity formula, which is: Where r is the relation in the semantic model, and F real Let m be the set of real-time running data feature items, and f be the number of features in the set of real-time running data feature items. real,k For the k-th feature item in the set of real-time running data features, To generate the relevant weights for the k-th feature term in the semantic model, This represents the relevance weight of the k-th feature term relationship after adjustment. Practical verification shows that the matching accuracy of this similarity calculation method can accurately reflect the fit between the model and actual production data.
[0060] S15, Dynamic Adjustment of Model Weights
[0061] Set the learning rate to control the model update pace. The learning rate The value range is 0.01 to 0.1, and it is dynamically adapted according to the acquisition frequency of the real-time operation data of the digital factory: when the acquisition frequency is 1Hz to 3Hz, Use values between 0.01 and 0.03 to avoid model overfitting; when the sampling frequency is between 3Hz and 6Hz, A value of 0.03 to 0.06 was used to balance the model update speed and stability; when the sampling frequency was 6Hz to 10Hz, A value of 0.06 to 0.1 is used to improve the model's response speed to changes in the production environment. Based on the similarity value calculated above, the weight adjustment formula is applied. Dynamically adjust the entity relation weights in the manufacturing semantic model, where The adjusted weights for the relationship of the Kth feature term improve the model's fit with real-time production data to 95.8%, a significant improvement compared to the existing static semantic model's 55% fit.
[0062] S16. Iterative optimization yields an evolvable semantic parameter model.
[0063] Based on the continuous input of real-time operational data from the digital factory, repeat the similarity calculation step in S14 and the weight adjustment step in S15, and iterate and optimize the manufacturing semantic model every 10 to 60 minutes. The iteration frequency can be flexibly set according to the factory's production rhythm.
[0064] For discrete manufacturing scenarios with rapidly changing production processes, the iteration frequency is set to once every 10-30 minutes, with a model update response time of ≤30 minutes. For process manufacturing scenarios with stable production processes, the iteration frequency is set to once every 30-60 minutes, improving model stability by more than 20%. Through continuous iterative optimization, an evolvable semantic parameter model that can self-iterate according to changes in the digital factory production environment is finally obtained. This model differs from the static semantic models with fixed parameters in existing technologies, and can adaptively adjust subsequent code generation logic. Compared with static semantic models, the matching degree between code generation logic and actual production needs is improved by 40.6 percentage points.
[0065] S2. Analyze user requirements and generate target code with semantic explanations.
[0066] The optimized, evolvable semantic parameter model is used to parse the user-submitted MES functional requirements, generating a list of code logic to be implemented. This list is then combined with a pre-defined set of generation rules to generate the target code. Simultaneously, an interpretability rule mapping table is established during the generation process to add semantic explanations to the target code, resulting in target code with semantic explanations. This entire process is automated, requiring no human intervention. The code generation time for a single module is ≤48 hours, representing a 12-fold improvement in efficiency compared to traditional manual coding. The overall code generation accuracy reaches 98.6%, far exceeding the 58% level of existing semi-automatic generation technologies.
[0067] S21. Extract the semantic features of user needs.
[0068] For MES functional requirements (such as real-time production monitoring, production scheduling optimization, product quality traceability, equipment status management, etc.) proposed by users in natural language, structured documents, or visual configuration methods, semantic features are extracted using a natural language processing model trained on industrial corpus. Invalid and redundant information is removed, and the recall rate of feature extraction reaches 98.0%, obtaining the core semantic features of the requirements.
[0069] S22. Analyze the requirements and map them into operational steps.
[0070] The demand semantic features are input into the trained evolvable semantic parameter model. The evolvable semantic parameter model parses the demand semantic features into logical tasks corresponding to MES functions based on the pre-stored manufacturing entities and quantification relationships. Then, the identified logical tasks are mapped into specific computer-executable operation steps according to industrial software development specifications. The operation steps include basic industrial software execution units such as data acquisition, logical judgment, instruction execution, and result output. The mapping matching degree from logical tasks to operation steps reaches 99.0%.
[0071] S23. Generate a list of code logic to be implemented.
[0072] For each specific operation step obtained from the mapping, a preset standardized code template is matched. The standardized code template contains basic code snippets from commonly used industrial software programming languages such as Java, Python, and C#. More than 1,000 standardized templates are preset, which are compatible with the MES software technology architecture of more than 95% of digital factories. According to the sequence and dependency between operation steps, all matched code templates are combined and sorted to generate a clear and logically coherent list of code logic to be implemented, with a logic error rate of ≤0.5%.
[0073] S24. Generate target code by combining the set of generation rules.
[0074] A pre-defined set of generation rules is used, including code syntax rules, manufacturing business logic implementation rules, and industrial software adaptation rules. The code syntax rules ensure the syntactic correctness of the code, with a 100% syntax validation pass rate. The business logic implementation rules ensure the code's compatibility with manufacturing processes, with a matching accuracy of 99.0%. The industrial software adaptation rules ensure the code is compatible with existing digital factory systems such as ERP and PCS, with a system adaptation accuracy of 98.8%. The code logic list to be implemented is matched segment by segment against the generation rule set to determine the specific implementation method, such as programming language, calling interface, and data interaction format, for each code segment in the code logic list. All matched code segments are then concatenated and compiled according to the order and dependencies in the code logic list to obtain complete executable target code, with a first-time compilation pass rate of 97.0%.
[0075] S26-S27, Generate target code with semantic interpretation
[0076] Before generating the target code, an interpretability rule mapping table is defined. This table contains a one-to-one correspondence between code snippets, manufacturing semantics, and business functions. The table is based on the manufacturing business specifications of the digital factory and the functional requirements of the MES software, with 100% mapping coverage. After obtaining the complete target code, semantic interpretation mapping is performed on each code snippet according to the interpretability rule mapping table. Corresponding manufacturing semantic descriptions and business function specifications are added to each code snippet, ultimately generating target code with semantic interpretation. Compared to existing code without semantic interpretation, this code improves subsequent debugging efficiency by 85%, shortens the secondary development cycle by 75%, and achieves transparency and traceability in the code generation process.
[0077] S3, simulate and verify the code and upload the entire process data.
[0078] Digital twin simulation technology is used to simulate the generated target code with semantic interpretation. The code's quality is determined based on the simulation results; substandard code is regenerated, while qualified code is retained. Simultaneously, all data generated during the target code generation process is uploaded to an industrial database, providing data support for the continuous optimization of the evolvable semantic parameter model. This step achieves virtual verification before code deployment, avoiding the debugging risks associated with directly deploying code to the production environment in existing technologies.
[0079] S31. Construct a 1:1 digital twin model
[0080] Based on the physical equipment parameters, production process flow, and historical operating data of the digital factory, the digital twin modeling technology of Unity3D+ industrial simulation engine is used to build a 1:1 digital twin model of the physical factory in a virtual environment. The geometric similarity of the model reaches 99.5% and the behavioral similarity reaches 98.0%, which can accurately restore the actual production scenarios of the digital factory, such as the operating status of production equipment, process connection relationship, and production material flow.
[0081] S32. Input code to perform loop simulation.
[0082] The generated target code with semantic interpretation is input into the digital twin model. The simulation step size is set to 0.5~2s, which is flexibly set according to the factory's production cycle: 0.5~1s is used for scenarios with short production cycles (≤1min / piece), achieving a simulation accuracy of 0.1s; 1~2s is used for scenarios with long production cycles (>1min / piece), balancing simulation accuracy and efficiency. The simulation is run cyclically within the digital twin model for a duration no less than a complete production batch in the digital factory (≥8 hours). Simultaneously, all simulation data, including equipment operation data, production cycle data, scheduling execution data, and quality inspection data, are recorded, ensuring 100% data integrity.
[0083] S33-S34, Calculate the deviation value and determine the code's compliance.
[0084] Based on the recorded full simulation data, the industrial production performance analysis algorithm is used to calculate three core performance simulation indicators: average production cycle time, equipment utilization rate, and on-time delivery rate. The calculation error of these indicators is ≤±1%. The deviation between the core performance simulation indicators and the preset requirements of the digital factory is calculated using the Euclidean distance formula, which is as follows: Where Dev is the deviation between the core performance simulation index and the required index, and E1, E2, and E3 are the simulation indexes 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.
[0085] Set the Dev deviation threshold. thr (Usually taken as 0.5), Dev thr It can be flexibly adjusted according to the production management requirements of the digital factory. If Dev ≥ Dev thr If the target code is deemed unqualified, the process returns to step S2, where the user's MES functional requirements are parsed and a code logic list is generated, to regenerate the target code. Regeneration should take ≤24 hours. If Dev ≥ Dev thr If the target code is deemed qualified, it can be deployed and used in the actual production environment of the digital factory. Actual verification shows that the digital twin simulation verification pass rate of this invention reaches 97.2%, with a core performance indicator compliance rate of 98.0%, a code logic vulnerability-free simulation pass rate of 96.5%, and a 100% pass rate for secondary simulation after regenerating unqualified code. This is far superior to the technical level of existing technologies with no simulation verification or simple simulation. Existing technologies have a code problem rate exceeding 40% after field deployment, while the failure rate of qualified code after deployment is ≤0.3%.
[0086] All process data is uploaded to the industrial database.
[0087] The semantic feature data, structured modeling data, evolvable semantic parameter model training data (including similarity calculation data, weight adjustment data, and learning rate configuration data), rule matching data, simulation verification data, and the finally generated target code data generated during the execution of the method of this invention are standardized and uniformly formatted as JSON / Parquet, with data storage precision retained to four decimal places. All standardized data is uniformly saved to the industrial database of the digital factory (such as MySQL or HBase), with a 100% data upload success rate and a single batch data storage time of ≤1 hour, realizing centralized management and traceability of data throughout the entire code generation process. This database provides a complete and high-quality data source for the subsequent continuous iterative optimization of the evolvable semantic parameter model. After training the model with multiple batches of data, the code generation accuracy can be further improved to 99.0%, forming a positive technical closed loop of data collection, model training, code generation, simulation verification, data feedback, and model re-optimization.
[0088] Furthermore, this invention includes a computer device, which is an industrial-grade server comprising a memory and a processor. The memory uses an SSD solid-state drive with a capacity of ≥3TB and a data read / write speed of ≥1GB / s, used to store the computer program and all data of the aforementioned digital factory, including production data, model data, and code data. The processor uses an industrial-grade multi-core CPU (≥8 cores and 16 threads, clock speed ≥3.0GHz), with a floating-point operation capability of ≥100GFLOPS, used to execute the computer program and implement all steps of the aforementioned automated generation method for digital factory MES software code, with a single-step execution response time ≤1s. This computer device achieves data interoperability with the digital factory's acquisition equipment, digital twin simulation platform, and industrial database via an industrial Ethernet (gigabit-level) connection, with a data transmission latency of ≤5ms, ensuring the stable and efficient execution of the method.
[0089] This invention includes a computer-readable storage medium, which is an industrial-grade secure storage medium (such as an encrypted USB flash drive or solid-state drive) with a storage capacity of ≥128GB and AES-256 data encryption. A computer program is stored on the medium, and when executed by a processor, the program implements all the steps of the aforementioned automated generation method for digital factory MES software code. This storage medium has a data read speed of ≥500MB / s, enabling secure storage and mobile transmission of core data such as manufacturing semantic models, target code, and simulation data. It meets the industrial data security management requirements of digital factories, and data transmission is lossless and tamper-proof.
[0090] The automated code generation method for digital factory MES software of this invention is applicable to MES software development scenarios in various digital factories, including discrete manufacturing and process manufacturing. It enables intelligent processing throughout the entire process, from production data acquisition and semantic model construction and optimization to user requirement analysis, automated code generation, simulation verification, and data retention. This solves the technical problems of static and rigid models, low code-business matching, poor development efficiency, and lack of effective simulation verification in existing MES code generation methods. This technology has been successfully implemented and verified in multiple digital factories in the automotive parts, electronic components, and machining industries. The MES code development cycle is shortened by more than 85% compared to traditional manual development and by more than 72% compared to existing semi-automatic generation technologies. The code generation accuracy reaches 98.6%, and the digital twin simulation verification pass rate reaches 97.2%, significantly outperforming existing technical indicators.
[0091] This embodiment is merely a preferred embodiment of the present invention and is not intended to limit the technical solution of the present invention in any way. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention fall within the protection scope of the present invention. The above embodiments only illustrate several implementations of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention. These are all equivalent modifications and alterations made to the above embodiments based on the essential technology of the present invention, and all of these fall within the protection scope of the present invention.
Claims
1. A method for automatically generating software code for a digital factory (MES), characterized in that, Includes the following steps: S1. 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; Based on the necessary technical features of real-time data similarity comparison, dynamic adjustment of relation weights, and learning rate control, the manufacturing semantic model is continuously trained and optimized using real-time running data to obtain an evolutionary semantic parameter model that can iterate according to changes in the digital factory production environment. This model is different from the static semantic model with fixed parameters and can adaptively adjust the code generation logic. S14. Perform feature matching between the real-time running data feature set and the manufacturing semantic model, using the cosine similarity formula. Calculate the similarity between entity relationships in the manufacturing semantic model and real-time operational data, where r represents the relationship in the manufacturing semantic model, and F... real Let m be the set of real-time running data feature items, and f be the number of features in the set of real-time running data feature items. real,k For the k-th feature item in the set of real-time running data features, To generate the relevant weights for the k-th feature term in the semantic model, The relevant weights of the relationship of the k-th feature term after adjustment; S15, Set the learning rate The learning rate The value ranges from 0.01 to 0.1, and is dynamically adapted according to the collection frequency of real-time operation data of the digital factory. The calculated similarity value is then adjusted using a weighting formula. Dynamically adjust the entity relationship weights in the manufacturing semantic model; S16. Based on the continuous input of real-time operation data of the digital factory, repeat the above similarity calculation and weight adjustment steps, and iteratively optimize the manufacturing semantic model at a frequency of once every 10 to 60 minutes to obtain an evolvable semantic parameter model. S2. Use an evolutionary semantic parameter model to parse the MES functional requirements proposed by the user, generate a list of code logic to be implemented, obtain the target code by combining the preset generation rule set, establish an interpretability rule mapping table in the process of obtaining the target code, and generate target code with semantic interpretation. The process involves using an evolutionary semantic parameter model to parse MES functional requirements and generate implementation details. The current code logic listing includes the following steps: S21. Extract semantic features from the MES functional requirements proposed by the user to obtain the semantic features of the requirements; S22. Input the demand semantic features into the trained evolvable semantic parameter model, and the evolvable semantic parameter model parses the demand semantic features into corresponding logical tasks according to the pre-stored entities and quantization relationships. S23. Map the identified logical tasks into specific operation steps that can be executed by the computer, match a preset standardized code template for each operation step, and combine and sort all code templates according to the order and dependency of the operation steps to generate a list of code logic to be implemented. The process of obtaining the target code by combining a preset set of generation rules includes the following: S24. Preset a set of generation rules, which includes code syntax rules, business logic implementation rules, and industrial software adaptation rules. Match the code logic list to be implemented with the set of generation rules segment by segment to determine the specific implementation method of each code segment in the code logic list. S25. Concatenate and compile all the matched code snippets according to the order and dependencies in the code logic list to obtain the complete target code; The process involves establishing an interpretability rule mapping table and generating target code with semantic explanations. Includes the following steps: S26. Before generating the target code, define an interpretability rule mapping table, which contains a one-to-one correspondence between code snippets and manufacturing semantics and business functions; S27. After obtaining the complete target code, perform semantic interpretation mapping on each code segment according to the interpretability rule mapping table, add corresponding manufacturing semantic description and business function description to each code segment, and generate target code with semantic interpretation. S3. Use digital twin simulation to simulate the generated target code, determine whether the code is qualified based on the simulation results, and upload all the data generated during the generation of the target code to the database to provide data support for the continuous optimization of the evolvable semantic parameter model. The process involves using digital twin simulation to simulate the target code and determine whether the code is... To be considered qualified, the following steps are required: S31. Based on the physical equipment parameters, production process flow, and historical operation data of the digital factory, construct a 1:1 digital twin model; S32. Input the target code with semantic interpretation into the digital twin model, set the simulation step size to 0.5~2s, perform cyclic simulation in the digital twin model, and record all simulation data. S33. Calculate the three core performance simulation indicators—average production cycle time, equipment utilization rate, and on-time delivery rate—based on simulation data, using the Euclidean distance formula. Calculate the deviation between the core performance simulation indicators and the preset requirements of the digital factory. Here, Dev represents the deviation between the core performance simulation indicators and the required indicators, and E1, E2, and E3 are the simulation indicators 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. S34. Set the Deviation Threshold. thr If Dev ≥ Dev thr If the target code is deemed unqualified, the process returns to step S2, where the user's MES functional requirements are parsed and a code logic list is generated, to regenerate the target code. If Dev... <Dev thr If so, the target code is deemed qualified.
2. The method for automatically generating software code for a digital factory MES according to claim 1, characterized in that: Step S1 involves extracting semantic features and performing structured modeling on the collected historical data to obtain a manufacturing semantic model, specifically including: S11. Integrate the collected historical data and real-time operational data into a raw dataset. Normalize the raw dataset to obtain a standardized dataset. Use a weighted summation formula to perform semantic feature recognition and extract semantic features from the standardized dataset. The formula is as follows: Where i is the i-th semantic feature, f i Let be the comprehensive value of the i-th semantic feature, j be the j-th observed attribute, n be the number of observed attributes of the i-th semantic feature, and a be the comprehensive value of the i-th semantic feature. ij Let ω be the value of the j-th observed attribute in the i-th semantic feature class. j The semantic importance weight of the j-th observation attribute is set based on manufacturing business experience; S12. Put all the extracted semantic features into a semantic feature set that includes a set of historical data features and a set of real-time running data features. Analyze the set of historical data features to identify the entity categories and relationships between entities in the manufacturing process. Statistically count the frequency of occurrence and dependence strength of various relationships in the historical data and calculate the weights between relationships. S13. Construct a semantic model for the manufacturing of graph structures by treating entities as graph nodes, relations as graph edges, and the weights between relations as edge weights.
3. The method for automatically generating software code for a digital factory MES according to claim 1, characterized in that: In step S3, all data generated during the generation of the target code is uploaded to the database, specifically as follows: The semantic feature data, structured modeling data, evolvable semantic parameter model training data, rule matching data, simulation verification data, and generated target code data are standardized, and all standardized data are uniformly saved to the industrial database. The training data for the evolvable semantic parameter model includes similarity calculation data, weight adjustment data, and learning rate configuration data.