Flight simulator interface code automatic generation method, system and equipment based on large language model and storage medium
By using a large language model-based approach, the generation of interface code for flight simulators is automated, solving the problems of low generation efficiency and poor accuracy in existing technologies. This achieves efficient and reliable automatic generation of interface code, improving the system's adaptability and code quality.
Patent Information
- Application Number
- CN202511395860.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-09-28
AI Technical Summary
Existing technologies in flight simulation training systems suffer from low efficiency and poor accuracy in interface code generation, as well as insufficient system adaptability, making it difficult to meet the requirements for high real-time performance and high reliability.
By adopting a large language model-based approach, interface data from external devices is acquired, noise is filtered and standardized, and then interface code templates are generated using deep learning and semantic understanding algorithms. These templates are then verified and optimized using example data and test cases, forming a closed-loop automated generation process.
It enables unified management and efficient automated processing of interface data from multi-source heterogeneous devices, generating code with reasonable structure and accurate logic, ensuring the functional correctness and operational stability of the code, and improving the intelligence and quality of code generation.
Smart Images

Figure CN120872322A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large language model technology, and in particular to a method, system, device and storage medium for automatically generating interface code for flight simulators based on large language models. Background Technology
[0002] In flight simulation training systems, interface code plays a crucial role in data interaction between the simulator and various external simulation or real equipment. Due to differences in communication protocols and data formats used by different equipment manufacturers, interface development needs to continuously adapt to multiple heterogeneous protocols and requires the generated code to have high real-time performance, high reliability, and good maintainability to meet the stringent requirements of flight simulation systems for the accuracy and timeliness of data exchange.
[0003] One existing solution employs template-based code generation technology. This technology uses pre-set code templates for various common communication protocols, selects the appropriate template based on the target device's protocol description file, and automatically fills in some data fields through rule mapping to ultimately generate basic interface code. This solution reduces the workload of entirely manual coding to some extent.
[0004] However, this approach still has significant limitations in practical applications. Its code template library covers a limited number of protocol types, exhibiting poor adaptability to novel or proprietary protocols that are not predefined. The rule-based mapping method relies on manually predefined mapping tables, which are insufficient in expressing complex interaction logic and state transition relationships within protocols, leading to logical deviations in the generated code when handling scenarios such as multi-threaded synchronization and exception recovery. Furthermore, the template-generated code structure tends to be fixed, leaving room for improvement in code efficiency and maintainability, making it difficult to fully meet the high reliability and real-time code requirements of flight simulation systems. Summary of the Invention
[0005] This application provides a method, system, device, and storage medium for automatically generating interface codes for flight simulators based on a large language model, in order to solve the problems of low generation efficiency, poor accuracy, and poor system adaptability of flight target interface codes in the prior art.
[0006] To address the aforementioned technical problems, in a first aspect, this application provides a method for automatically generating interface code for flight simulators based on a large language model, comprising: Acquire interface data provided by multiple external devices in the flight target, the interface data including communication protocols, data formats and sample data; The interface data is subjected to noise filtering, and key information of the communication protocol and key information of the data format are extracted from the processed interface data. The key information of the communication protocol and key information of the data format are then converted according to a preset standardized data format to form structured input data. The structured input data is input into a pre-trained large language model. The structured input data is deeply parsed using the deep learning algorithm in the large language model. Key semantic information is extracted from the parsing results using the semantic understanding algorithm in the large language model. An interface code template is generated based on the key semantic information. Based on the example data and data interaction rules, the variables, functions and communication interfaces in the interface code template are instantiated to generate the target interface code. Based on the target interface code and the example data, test cases in multiple scenarios are generated using a test case generation algorithm. By executing the test cases, the correctness, stability, and performance of the interface are verified, and test verification results are obtained. The target interface code is subjected to structural complexity analysis and runtime efficiency evaluation to obtain performance analysis results. Based on the test verification results and the performance analysis results, the parameters and training data of the large language model are dynamically adjusted to achieve a closed-loop automated interface code generation process.
[0007] Optionally, the step of inputting the structured input data into a pre-trained large language model, performing deep parsing of the structured input data using a deep learning algorithm within the large language model, extracting key semantic information from the parsing results using a semantic understanding algorithm within the large language model, and generating an interface code template based on the key semantic information includes: The structured input data is input into a large language model. The encoding module of the large language model performs joint encoding on the protocol definition content and data format description content in the structured input data to form a model input sequence. Using the deep learning algorithm provided by the large language model, multi-level semantic parsing is performed on the input sequence of the model to obtain deep parsing results; Using the semantic understanding algorithm provided by the large language model, semantic relationship reasoning is performed on the deep parsing results to obtain key semantic information, which includes protocol interaction logic and data mapping relationship. Based on the protocol interaction logic and the data mapping relationship, an interface code template is generated.
[0008] Optionally, the semantic understanding algorithm provided by the large language model is used to perform semantic relation reasoning on the deep parsing results to obtain key semantic information, including: Dependency analysis is performed on the protocol syntax units in the deep parsing results to identify the triggering conditions and timing constraints between protocol commands and responses; Semantic role labeling is performed on the data structure definitions in the deep parsing results to parse the functional attributes, value ranges, and encoding methods of the data fields; Based on the triggering conditions and the timing constraints, a state transition model for the message sequence is established, and the complete workflow of protocol interaction is derived based on the state transition model. Based on the functional attributes, the value range, and the encoding method, a mapping rule and conversion relationship between data fields are constructed, and a standard template for data parsing and encapsulation is formed based on the mapping rule and the conversion relationship. Based on the complete workflow and the standard template, key semantic information is generated.
[0009] Optionally, the generation of key semantic information based on the complete workflow and the standard template includes: The complete workflow is converted into a set of state transition rules that include state transition conditions and message processing order. The standard template is converted into a set of data manipulation rules that include field mapping relationships and data transformation methods; Based on the set of state transition rules and the set of data operation rules, a semantic description file is constructed, which defines the protocol interaction logic and data mapping relationship; The semantic description file is structured and encapsulated to generate key semantic information.
[0010] Optionally, the step of instantiating the variables, functions, and communication interfaces in the interface code template based on the example data and data interaction rules to generate the target interface code includes: Extract data samples with actual numerical values and their corresponding data type descriptions from the example data; Based on the data transmission order and verification requirements of the data interaction rules, determine the specific implementation methods of variables and functions in the interface code template; Match and bind the data sample and the data type description with the corresponding data structure and communication interface in the interface code template; Based on the specific implementation method described above, and in conjunction with the message organization format and interaction sequence flow specified in the communication protocol, the bound interface code template is filled in to generate the target interface code.
[0011] Optionally, based on the target interface code and the example data, a test case generation algorithm is used to generate test cases for multiple scenarios. By executing the test cases, the correctness, stability, and performance of the interface are verified to obtain test verification results, including: Based on the interface functions implemented by the target interface code, and according to the test requirements corresponding to the interface functions, generate normal data flow test scenarios and abnormal data flow test scenarios. Based on the example data, a test case generation algorithm is used to generate input test data sets corresponding to normal data processing scenarios and abnormal data processing scenarios, respectively. The input test data set is combined with the corresponding test scenario configuration information to form test cases for multiple scenarios; According to the message organization format and interaction sequence flow specified in the communication protocol, execute the test case in the corresponding scenario to obtain the interface output results; The interface output is compared with the preset expected behavior to verify the correctness of the interface under different load conditions, as well as to verify its stability and performance, and to obtain the test verification results.
[0012] Optionally, the step of performing structural complexity analysis and runtime efficiency evaluation on the target interface code to obtain performance analysis results, and then dynamically adjusting the parameters and training data of the large language model based on the test verification results and the performance analysis results, includes: Perform structural complexity analysis on the target interface code to generate quantitative indicators corresponding to the code logic complexity and module dependency relationship, respectively. In a pre-defined simulated data interaction environment, the runtime efficiency of the target interface code is evaluated to obtain resource utilization and data processing throughput. Based on the quantitative indicators, the resource utilization rate, and the data processing throughput, performance analysis results are generated. Based on the test verification results and performance analysis results, the types of code defects and performance bottlenecks are determined; Based on the code defects and the types of performance bottlenecks, the parameters and training data of the large language model are dynamically adjusted.
[0013] Secondly, this application provides an automatic generation system for flight simulator interface code based on a large language model, comprising: The acquisition module is used to acquire interface data provided by multiple external devices in the flight target. The interface data includes communication protocols, data formats, and sample data. The filtering module is used to perform noise filtering on the interface data, extract key information of the communication protocol and key information of the data format from the processed interface data, and convert the key information of the communication protocol and key information of the data format according to the preset standardized data format to form structured input data. The input module is used to input the structured input data into a pre-trained large language model, perform deep parsing on the structured input data through the deep learning algorithm in the large language model, extract key semantic information from the parsing results using the semantic understanding algorithm in the large language model, and generate an interface code template based on the key semantic information. The generation module is used to instantiate the variables, functions and communication interfaces in the interface code template based on the example data and data interaction rules, and generate the target interface code. The verification module is used to generate test cases for multiple scenarios based on the target interface code and the example data using a test case generation algorithm. By executing the test cases, the correctness, stability and performance of the interface are verified, and test verification results are obtained. The evaluation module is used to perform structural complexity analysis and runtime efficiency evaluation on the target interface code to obtain performance analysis results. Combining the test verification results and the performance analysis results, the parameters and training data of the large language model are dynamically adjusted to achieve a closed-loop automated interface code generation process.
[0014] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor, configured to implement the steps of the automatic generation method for flight simulator interface code based on a large language model as described in the first aspect above when executing the computer program.
[0015] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps of the automatic generation method for flight simulator interface code based on a large language model as described in the first aspect above.
[0016] The technical solution provided in this application has the following beneficial effects: This application achieves unified collection and centralized management of interface data from multi-source heterogeneous devices, providing a complete data foundation for subsequent automated processing. It improves data quality and consistency, ensuring the standardization and usability of input data, laying the foundation for efficient model parsing and understanding. Leveraging the powerful learning and reasoning capabilities of large language models, it automatically understands the deep semantics of protocols and data formats, generating a logically sound and structurally accurate code framework, reducing the difficulty and workload of coding. It transforms abstract code templates into concrete executable code, ensuring that the generated code accurately reflects actual data interaction needs, improving the code's practicality and accuracy. It automatically generates comprehensive test cases and performs verification, ensuring the functional correctness, operational stability, and performance of the generated code, improving code reliability. It quantitatively evaluates and continuously optimizes code quality, forming a self-improving closed-loop system that continuously improves the overall quality and generation efficiency of output code.
[0017] Furthermore, this application will perform multi-level semantic parsing on the structured input data after joint encoding through deep learning algorithms provided by a large language model, and use semantic understanding algorithms to perform semantic relationship reasoning on the parsing results, thereby extracting key semantic information containing protocol interaction logic and data mapping relationships, and finally generating interface code templates based on this information.
[0018] Furthermore, by leveraging the deep semantic understanding and reasoning capabilities of large language models, key interaction logic and mapping relationships are automatically extracted from protocols and data formats, and interface code templates with clear structure and accurate logic are generated accordingly. This greatly improves the automation and intelligence of code generation and ensures a high degree of consistency between code templates and protocol specifications.
[0019] These or other aspects of this application will become more apparent in the following description of the embodiments. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A flowchart illustrating an automatic generation method for flight simulator interface code based on a large language model, provided in this application embodiment; Figure 2 A data acquisition module data interaction flowchart for an automatic generation method of flight simulator interface code based on a large language model, provided in an embodiment of this application; Figure 3A flowchart of DeepSeek large model data processing and code generation for an automatic generation method of flight simulator interface code based on a large language model provided in this application embodiment; Figure 4 A flowchart illustrating the test case generation and verification process for an automatic generation method of flight simulator interface code based on a large language model, provided in this application embodiment; Figure 5 This application provides a code analysis tool and performance analysis tool for an automatic generation method of interface code for flight simulators based on a large language model, along with the connection method of the interface code and the flow of analysis data. Figure 6 This application provides a system optimization and iteration of an automatic generation method for flight simulator interface code based on a large language model, as exemplified in this application. Figure 7 This is a schematic diagram of the structure of an automatic generation system for flight simulator interface code based on a large language model, provided in an embodiment of this application. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0023] The core of this application is to provide a method for automatically generating interface code for flight simulators based on a large language model. A flowchart of one specific implementation is shown below. Figure 1 As shown, the method includes: Step 101: Obtain interface data provided by multiple external devices in the flight target. The interface data includes communication protocols, data formats, and sample data.
[0024] In step 101, the flight target refers to the entire aircraft system that requires simulation training. External equipment refers to simulated or real components that interact with the flight simulator, such as avionics systems, power systems, and control load systems. Interface data is a collection of all relevant information used to achieve communication and data exchange between the flight simulator and external equipment. The communication protocol, a part of the interface data, defines the set of rules for data transmission and exchange in the network, including packet structure, start and end markers, verification methods, and the correspondence between commands and responses. The data format, also part of the interface data, defines the specific organization and meaning of the data content, such as whether a data field is an integer or floating-point number, the data length in bytes, the unit of data, and the physical meaning of the data. Sample data, a part of the interface data, is a set of actually recorded instances of raw data streams or packets that conform to the communication protocol and data format requirements, used to concretely demonstrate the real appearance of data interaction.
[0025] In this embodiment, a data acquisition tool or program establishes communication connections with various external devices, actively reading or passively receiving data from these devices according to their interface documentation. This data includes text or configuration files detailing communication rules (communication protocols), documents defining data organization methods (data formats), and log files recording the actual data interaction process (example data). All these collected raw materials collectively form the input basis for subsequent automated processing.
[0026] For example, developers obtain a User Datagram Protocol (UDP) document, a format document defining 20 data structures, and a data log file recording 100 sets of actual transmitted and received data from the equipment manuals and communication logs of the navigation display unit (external device A) and engine control unit (external device B) of the flight target. These documents and files together constitute the interface data obtained in step 101.
[0027] Step 102: Perform noise filtering on the interface data, extract key information of the communication protocol and key information of the data format from the processed interface data, and convert the key information of the communication protocol and key information of the data format according to the preset standardized data format to form structured input data.
[0028] In step 102, noise filtering refers to the process of identifying and removing erroneous, redundant, or incomplete information from the raw interface data, with the aim of improving data quality. Key information about the communication protocol represents the protocol type, data transmission format, and data interaction rules. Key information about the data format represents the data structure and data type. A standardized data format is a predefined, unified data organization specification used to ensure that information from diverse sources can be processed by subsequent large language models in the same style. Structured input data is a collection of information that has been cleaned, extracted, and transformed, resulting in a clear and standardized structure that is easily read and understood efficiently and accurately by computer programs, especially large language models.
[0029] In this embodiment, firstly, noise filtering is performed on the raw interface data obtained in step 101, such as removing garbled lines from logs and correcting spelling errors in documents. Next, key information from the communication protocol, such as protocol type and important interaction rules, is extracted from the cleaned data. Key information from the data format, such as core data structures and data types, is also extracted. Then, this extracted key information is transformed and reorganized according to a pre-defined standardized data format. Finally, a well-structured input data set that can be directly used by a large language model is output.
[0030] For example, the interface data obtained from devices A and B was cleaned, removing three malformed data records from the data log. Subsequently, the interaction rule "command 0xA1 must receive a response within 5 milliseconds" was extracted from the communication protocol, and the data type "tilt angle data is a 4-byte unsigned integer" was extracted from the data format. This extracted key information was then converted into structured input data in JavaScript Object Notation (JSON), a JSON file that clearly contains the protocol rules and data format definitions.
[0031] Step 103: Input the structured input data into a pre-trained large language model, perform deep parsing on the structured input data using the deep learning algorithm in the large language model, extract key semantic information from the parsing results using the semantic understanding algorithm in the large language model, and generate an interface code template based on the key semantic information.
[0032] In step 103, the large language model is an artificial intelligence model pre-trained on massive amounts of data, possessing powerful text understanding and generation capabilities. Deep learning algorithms are machine learning techniques employed within the large language model that automatically learn and extract complex patterns and features from data. Deep parsing refers to the process by which the large language model utilizes its deep learning capabilities to deeply analyze and understand the structured input data. Semantic understanding algorithms are techniques employed within the large language model to understand the true meaning and relationships behind text and data. Key semantic information is the core knowledge about how protocols operate and how data is mapped, extracted after deep parsing and semantic understanding. The interface code template is a code draft generated based on key semantic information, containing the main framework and logic of the code but without specific numerical values yet filled in.
[0033] In this embodiment, the structured input data generated in step 102 is fed into a pre-trained large language model. The model first uses its internal deep learning algorithm to perform a comprehensive and in-depth analysis of the data, understanding its internal structure. Then, it uses its semantic understanding algorithm to reason about the analysis results, extracting key semantic information such as protocol interaction logic and data mapping relationships. Finally, based on this key semantic information, the model generates a structured interface code template, which defines the overall framework and main functions of the code.
[0034] For example, the structured input data in JSON format described above is fed into a large language model. The model analyzes the data and extracts key semantic information, including "the protocol interaction logic is that the main system sends a 0xA1 command and then waits to receive data packets" and "the data mapping relationship is that the data in bytes 12 to 15 of the received data packet needs to be processed and converted into actual angle values." Based on this, the model generates an interface code template, which includes a function framework for sending commands and a function framework for parsing data packets.
[0035] Step 104: Based on the example data and data interaction rules, instantiate the variables, functions and communication interfaces in the interface code template to generate the target interface code.
[0036] In step 104, the data interaction rules are the content of "key information of the communication protocol". Instantiation refers to the process of filling the abstract framework and variables in the interface code template with concrete, executable code content. The target interface code refers to the complete, directly compileable and runnable program code obtained after instantiation.
[0037] In this embodiment, based on the example data obtained in step 101, the specific data types and value examples for the variables in the code template are determined. Simultaneously, according to the data interaction rules derived from the protocol, the specific implementation logic of the functions in the template is determined. Then, the example data is bound to the preset data structure in the template, and the message assembly and parsing logic is filled in according to the data interaction rules. Finally, a complete and usable target interface code is generated.
[0038] For example, a set of real data is extracted from the initial 100 sets of sample data, where the original pitch angle value is 1234567. According to the verification rules specified in the protocol, the calculation logic for Cyclic Redundancy Check (CRC) is implemented in the verification function framework of the interface code template. The real data is bound to the data structure in the template, and the message processing function is fully populated, ultimately generating a target interface code that can correctly send the 0xA1 command and parse the reply data packet.
[0039] Step 105: Based on the target interface code and the example data, use a test case generation algorithm to generate test cases for multiple scenarios. By executing the test cases, verify the correctness, stability and performance of the interface, and obtain the test verification results.
[0040] In step 105, the test case generation algorithm is a computer program or method capable of automatically creating test scenarios and test data based on code functionality and input data. A test case is a specific test plan generated by the test case generation algorithm, containing test input data and expected output results. The test verification result is a comprehensive evaluation report on the correctness, stability, and performance of the target interface code after executing all test cases.
[0041] In this embodiment, based on the functionality implemented by the target interface code generated in step 104 and the example data in step 101, a test case generation algorithm automatically designs test cases for various scenarios, including normal and abnormal situations. These test cases are then automatically run, and the actual output of the code is recorded. The correctness of the code is verified by comparing the actual output with the expected results. Stability is tested through long-term execution. Performance is evaluated by monitoring processing speed. Finally, the test verification results are summarized.
[0042] For example, using a test case generation algorithm, 85 normal scenario test cases and 15 abnormal scenario test cases were created based on 100 sets of sample data. After executing all test cases, it was found that the generated code would encounter an error when handling a specific abnormal data packet, and that memory usage would slowly increase after running continuously for 1 hour. These findings were recorded in the test verification results.
[0043] Step 106: Perform structural complexity analysis and runtime efficiency evaluation on the target interface code to obtain performance analysis results. Combine the test verification results with the performance analysis results to dynamically adjust the parameters and training data of the large language model to achieve a closed-loop automated interface code generation process.
[0044] In step 106, structural complexity analysis refers to using tools to analyze the structure of the code and assess its complexity, typically focusing on metrics such as cyclomatic complexity. Runtime efficiency evaluation involves running the code in a simulated real-world environment and measuring performance metrics such as resource utilization and processing speed. The performance analysis results are a quantitative report on code quality and technical performance, derived from the structural complexity and runtime efficiency assessments. Closed-loop automation refers to feeding back the final output of the entire process (test verification results and performance analysis results) to the large language model in the initial stage to guide its self-optimization, thus forming an automatically looping and continuously improving system.
[0045] In this embodiment, code analysis tools are used to perform structural complexity analysis on the target interface code generated in step 104, calculating its cyclomatic complexity and other metrics. Simultaneously, the code is run in a simulation environment to evaluate its Central Processing Unit Usage (CPU) and data processing throughput. Combining the test verification results from step 105 with the performance analysis results from this step, defects and performance bottlenecks in the code are identified. Based on these findings, the parameters and training data composition of the large language model are dynamically adjusted to optimize its code generation strategy, thereby achieving closed-loop automation and resulting in higher quality code generated in subsequent iterations.
[0046] For example, analyzing the target interface code revealed a cyclomatic complexity of 15. Under a simulated load of processing 1000 packets per second, CPU utilization was observed at 12%, and throughput was 950 packets per second. Combining this with the defects found in the test results, the analysis determined that the problem stemmed from the overly complex logic of a function in the code. Therefore, the error information and performance data were fed back to the large language model, adjusting its training data, increasing the weight of similar correct code samples, and optimizing the model. When generating code for a similar protocol in the future, the model can generate code with a simpler structure and more correct logic.
[0047] This application achieves intelligent generation and continuous optimization of flight simulator interface code through a series of automated steps. This method can automatically process multi-source heterogeneous interface data, utilize large language models to deeply understand protocol semantics and generate high-quality code templates, combine instantiation and comprehensive testing to ensure code reliability, and finally, through a closed-loop feedback mechanism, continuously improve code generation quality and system adaptability, effectively enhancing development efficiency, code accuracy, and overall system performance.
[0048] To address the challenge of enabling large language models to accurately understand communication protocols and generate high-quality interface code templates, in some embodiments, step 103 involves: inputting the structured input data into a pre-trained large language model, performing deep analysis on the structured input data using deep learning algorithms within the large language model, extracting key semantic information from the analysis results using semantic understanding algorithms within the large language model, and generating an interface code template based on the key semantic information. This includes: Step 201: Input the structured input data into the large language model, and use the encoding module of the large language model to jointly encode the protocol definition content and data format description content in the structured input data to form a model input sequence.
[0049] In step 201, the encoding module is an internal component of the large language model responsible for converting different forms of input data into a series of numerical identifiers that the model can understand. The protocol definitions and data format descriptions in the structured input data are derived from information extracted and transformed after noise filtering and standardization of the original interface data. The protocol definitions include structured descriptions such as protocol types, data transmission formats, and data interaction rules extracted from communication protocols. The data format descriptions include standardized representations such as data structures, data types, and data constraints extracted from data formats. Joint encoding refers to the process of treating the protocol definitions and data format descriptions as a whole and performing a unified transformation. The model input sequence is an ordered numerical sequence containing all semantic information of the protocol and data format after joint encoding; this sequence serves as the direct input to the large language model.
[0050] In this embodiment, the large language model first receives structured input data, and then its internal encoding module starts working to read and analyze the protocol definition content and data format description content contained in the data as a whole. Through specific conversion rules, all these text and structural information are mapped into a continuous numerical sequence rich in semantic relationships, and finally a complete model input sequence is formed for subsequent analysis.
[0051] Step 202: Using the deep learning algorithm provided by the large language model, perform multi-level semantic parsing on the input sequence of the model to obtain the deep parsing results.
[0052] In step 202, multi-level semantic parsing refers to the process by which the model analyzes and understands the input sequence layer by layer, from shallow to deep, from surface to connotation. The result of deep parsing is the internal deep representation of the input sequence formed by the model after multi-level semantic parsing, which contains the complex structural and semantic information in the input data.
[0053] In this embodiment, the large language model utilizes its provided deep learning algorithm to perform in-depth processing on the model input sequence generated in step 201. This processing involves multiple layers. The model first parses the basic grammatical structure of the sequence, then understands the interaction rules it expresses, and finally deciphers its deep semantic relationships. Through this series of progressively layered analyses, a deep parsing result that comprehensively reflects the essence of the protocol and data format is ultimately obtained.
[0054] Step 203: Using the semantic understanding algorithm provided by the large language model, perform semantic relationship reasoning on the deep parsing results to obtain key semantic information, which includes protocol interaction logic and data mapping relationship.
[0055] In step 203, semantic relation reasoning refers to the process of inferring implicit, unexpressed semantic relationships based on existing information using logic and knowledge. Protocol interaction logic is a component of key semantic information; it describes the message exchange order and conditional judgment rules that the communicating parties must follow to complete specific functions. Data mapping relationships are another component of key semantic information; they define the correspondence between fields in different data formats and the necessary conversion rules.
[0056] In this embodiment, the large language model utilizes its semantic understanding algorithm to perform in-depth semantic relationship reasoning on the deep parsing results obtained in step 202. By analyzing the relationships between various elements in the parsing results, the model infers the complete interaction logic between the communicating parties, and accurately derives how data fields correspond and transform, ultimately extracting key semantic information containing protocol interaction logic and data mapping relationships.
[0057] Step 204: Generate an interface code template based on the protocol interaction logic and the data mapping relationship.
[0058] In this embodiment, the model begins to construct the code framework based on the two key semantic information components—the protocol interaction logic and the data mapping relationship—obtained in step 203. The protocol interaction logic is used to generate the control flow code structure, such as function call order and conditional branches. The data mapping relationship is used to generate data structure definitions and data conversion function prototypes. Finally, these elements are combined into a well-structured and logically complete interface code template.
[0059] Here is a specific example: Following the aforementioned embodiment, JSON-formatted structured input data, containing the rule "Instruction 0xA1 must receive a response within 5 milliseconds" and the type definition "Pitch angle data is a 4-byte unsigned integer," is input into the large language model. The model first uses its encoding module to jointly encode the protocol definition and data format description, converting the textual rules and structure into a model input sequence containing 512 numeric identifiers. The length of this sequence is determined by the model's preset input dimension. Subsequently, the deep learning algorithm provided by the large language model performs multi-level semantic parsing on the input sequence. The model sequentially identifies the parts representing instruction types, time constraints, and data structures, and understands the dependencies between them, ultimately obtaining a deep parsing result containing complete semantics. Next, the semantic understanding algorithm provided by the large language model is used to perform semantic relationship reasoning on the deep parsing result. The model infers that a data packet must be replied to within 5 milliseconds after receiving the instruction 0xA1. Further parsing reveals that the four bytes starting from the 12th byte of this data packet collectively represent an unsigned integer. This integer needs to be converted to have physical meaning, thus extracting key semantic information containing the protocol interaction logic and data mapping relationship. Finally, an interface code template is generated based on this key semantic information. This template includes a sending function framework for sending the 0xA1 instruction, a receiving processing function framework for waiting and receiving data packets within 5 milliseconds, and a data parsing function framework for extracting the data from bytes 12 to 15 of the received data packet and converting it into actual angle values.
[0060] In this embodiment, the above complete steps improve the accuracy and reliability of code generation by enabling a large language model to deeply understand the semantics of the protocol and data, and automatically generate a well-structured code framework accordingly. This effectively reduces the complexity of subsequent development and the need for manual intervention, laying a solid foundation for quickly building high-quality interface code.
[0061] To address the challenge of accurately extracting machine-understandable key semantic information from deep parsing results, in some embodiments, step 203 involves using a semantic understanding algorithm provided by a large language model to perform semantic relationship reasoning on the deep parsing results to obtain key semantic information, including: Step 301: Perform dependency analysis on the protocol syntax units in the deep parsing results to identify the triggering conditions and timing constraints between protocol commands and responses.
[0062] In step 301, the protocol grammar units in the deep parsing results originate from the intermediate parsing data generated after the large language model performs distributed representation learning on the structured input data. These units refer to the smallest units with independent grammatical functions identified in the communication protocol, such as protocol commands, response codes, and parameter identifiers. Dependency analysis is a method for analyzing the relationships of subordination, modification, or triggering among these units. A triggering condition refers to the prerequisite or rule that must be met for a protocol command to elicit a specific response. Temporal constraints specify the temporal order and delay requirements between commands and responses.
[0063] In the embodiments of this application, the semantic understanding algorithm first performs dependency analysis on the protocol syntax units in the deep parsing results, identifies the dependencies between each command and response, and then accurately extracts the specific conditions that the command must meet to trigger the response, as well as the time order and delay constraints that they must follow.
[0064] Step 302: Perform semantic role labeling on the data structure definition in the deep parsing result, and parse the functional attributes, value range and encoding method of the data fields.
[0065] In step 302, the data structure definition in the deep parsing result originates from the intermediate parsed data generated after the large language model performs distributed representation learning on the structured input data. It refers to the formal specifications of data organization parsed from the data format description, including information such as field composition, type system, and memory layout. A data field is the smallest unit of data that constitutes the data structure; each field has a specific data type, length, and semantic meaning. Semantic role labeling is the process of assigning specific functional labels to each field in the data structure. Functional attributes describe the role or physical meaning represented by a data field. Value range defines the upper and lower limits of the numerical values that a data field can represent. Encoding method specifies the specific representation of a data field in binary or character streams.
[0066] In this embodiment, the semantic understanding algorithm then performs semantic role labeling on the data structure definition in the deep parsing result, parsing out the specific function of each data field, its effective numerical range, and the encoding format used for storage and transmission.
[0067] Step 303: Based on the triggering conditions and the timing constraints, establish a state transition model for the message sequence, and derive the complete workflow of protocol interaction based on the state transition model.
[0068] In step 303, a message sequence refers to a set of messages with specific temporal relationships arranged according to the protocol specifications. It originates from a message exchange order model established based on the triggering conditions and temporal constraints between protocol syntax units. A state transition model is an abstract representation used to describe how a system transitions from one state to another under different message stimuli. The complete workflow of protocol interaction is a sequence diagram derived from the state transition model, clearly describing all possible paths from the start to the end of the interaction.
[0069] In this embodiment of the application, based on the triggering conditions and timing constraints identified in step 301, the semantic understanding algorithm begins to construct a state transition model of the message sequence. This model clearly shows the state transition path of the system under various messages. Based on this model, the algorithm can deduce the complete workflow of the entire protocol interaction.
[0070] Step 304: Based on the functional attributes, the value range, and the encoding method, construct mapping rules and conversion relationships between data fields, and form a standard template for data parsing and encapsulation based on the mapping rules and the conversion relationships.
[0071] In step 304, mapping rules define how different data fields correspond and relate to each other. Transformation relationships describe the computations or processing operations required to transform data from one field to another. The standard template for data parsing and encapsulation is a standardized specification based on mapping rules and transformation relationships, guiding how to extract data from the raw data stream and how to package the data into a transmission format.
[0072] In this embodiment of the application, based on the functional attributes, value range and encoding method of the data fields parsed in step 302, the semantic understanding algorithm constructs the mapping rules and transformation relationships between these fields, clarifies how the fields correspond and how the data is transformed, and forms a standard template for data parsing and encapsulation based on these rules and relationships.
[0073] Step 305: Generate key semantic information based on the complete workflow and the standard template.
[0074] In this embodiment of the application, based on the complete protocol interaction workflow derived in step 303 and the data parsing and encapsulation standard template formed in step 304, the semantic understanding algorithm integrates them to generate the final key semantic information, which fully defines the protocol's interaction logic and the data mapping relationship.
[0075] Here is a specific example: Based on the obtained deep parsing results, the semantic understanding algorithm first performs dependency analysis on the protocol syntax units in the deep parsing results. It identifies the triggering condition between the protocol command instruction 0xA1 and the response data packet 0x55AA as follows: instruction 0xA1 is the only command requesting data, and the timing constraint is that the response must be completed within 5 milliseconds. Next, it performs semantic role labeling on the data structure definitions in the deep parsing results, parsing out that the data field corresponding to the 4 bytes starting from the 12th byte in the data packet has the function attribute of pitch angle, with a value range of 0 to 4294967295, encoded as a 32-bit unsigned integer. Then, based on the identified triggering conditions and timing constraints, a state transition model for the message sequence is established. This model contains three states: State 1 is the waiting state for instructions; State 2 is the waiting state for a response after receiving instruction 0xA1; and State 3 is the data processing state after receiving data packet 0x55AA. The model stipulates that the condition for transitioning from State 1 to State 2 is receiving instruction 0xA1, and the condition for transitioning from State 2 to State 3 is receiving data packet 0x55AA within 5 milliseconds. If the timeout occurs, it returns to State 1. Based on this state transition model, the complete workflow of protocol interaction is derived as follows: after sending instruction 0xA1, a 5-millisecond timer is started. If data packet 0x55AA is received before the timer expires, data processing is performed; otherwise, it is considered a timeout failure. Next, based on the pitch angle functional attribute of the data field (range 0 to 4294967295) and the encoding method (32-bit unsigned integer), a mapping rule between data fields is constructed. This rule specifies that bytes 12 to 15 of the data packet are mapped to the pitch angle variable, and a conversion relationship is established: the actual pitch angle value equals the original value divided by a conversion factor of 1000. Here, the actual pitch angle value represents the final physical quantity in degrees, the original value represents the 4-byte unsigned integer extracted from the data packet, and the conversion factor 1000 is a dimensionless scaling factor. Based on this mapping rule and conversion relationship, a standard template for data parsing and encapsulation is formed. This template specifies how to extract specified bytes from the data packet and complete the numerical conversion. Finally, based on the derived complete workflow and the formed standard template, key semantic information is generated. This information fully contains the protocol interaction logic and data mapping relationship.
[0076] In the embodiments of this application, the above complete steps transform complex protocol and data format descriptions into clear, structured, and machine-understandable core semantic information through layer-by-layer in-depth semantic reasoning. This provides a solid and reliable logical basis for the subsequent accurate generation of interface code, and improves the accuracy and depth of capturing protocol intent and data meaning.
[0077] To transform the protocol workflow and data operation specifications into machine-readable standardized semantic information, in some embodiments, step 305: generating key semantic information based on the complete workflow and the standard template includes: Step 401: Convert the complete workflow into a set of state transition rules that include state transition conditions and message processing order.
[0078] In step 401, the state transition condition refers to the event or judgment condition that must be met for the system to switch from one state to another. The message processing order specifies the sequence in which different messages are processed and responded to. The state transition rule set is a collection of multiple independent rules obtained by breaking down the complete workflow. Each rule clearly describes under what conditions the system will undergo what state change and how messages need to be processed.
[0079] In this embodiment of the application, each state change step and message processing step described in the complete workflow is broken down and refined, and an independent rule is created for each step. The rule clearly states the specific conditions that the state transition must meet and the order of message processing in this process. The sum of all these rules constitutes the state transition rule set.
[0080] Step 402: Convert the standard template into a set of data operation rules that include field mapping relationships and data transformation methods.
[0081] In step 402, the field mapping relationship specifies the correspondence between fields in the source data and the target data. The data transformation method defines the specific calculation or processing steps required to transform the source data into the target data. The data manipulation rule set is a collection of multiple independent rules obtained by decomposing all data manipulation details contained in the standard template. Each rule clearly describes how a set of fields are mapped and how the data is transformed.
[0082] In this embodiment of the application, each set of field mapping relationships and each data transformation method defined in the standard template are extracted and formatted, and an independent rule is created for each set of mappings and each transformation. The rule clearly specifies how the fields correspond to each other and how the data is transformed. The sum of all these rules constitutes the data operation rule set.
[0083] Step 403: Construct a semantic description file based on the state transition rule set and the data operation rule set. The semantic description file defines the protocol interaction logic and data mapping relationship.
[0084] In step 403, the semantic description file is a machine-readable file written in a specific format that integrates all the core information of protocol interaction and data operation.
[0085] In this embodiment of the application, the set of state transition rules obtained in step 401 and the set of data operation rules obtained in step 402 are taken as inputs. The contents of these two sets of rules are systematically organized into a file according to a predefined file format. This file ultimately constitutes a semantic description file, which fully defines the protocol interaction logic and data mapping relationship.
[0086] Step 404: Perform structured encapsulation on the semantic description file to generate key semantic information.
[0087] In step 404, structured encapsulation refers to the process of adding necessary metadata information to the semantic description file and packaging it into a standard format.
[0088] In this embodiment of the application, the semantic description file generated in step 403 is processed by adding management information such as version number and creation time, and then converted into a compact and easy-to-parse standard data exchange format. The final result obtained after this processing is the key semantic information.
[0089] Here is a specific example: Following the derived complete workflow and the established standard template, the complete workflow is first converted into a set of state transition rules. This set contains three rules: Rule 1 stipulates that the state transition condition from the waiting instruction state to the waiting response state is the receipt of instruction 0xA1, and the message processing order is to immediately send instruction 0xA1; Rule 2 stipulates that the state transition condition from the waiting response state to the data processing state is the receipt of data packet 0x55AA within 5 milliseconds, and the message processing order is to start a 5-millisecond timer and process the data after receiving the data packet; Rule 3 stipulates that the state transition condition from the waiting response state to the waiting instruction state is a 5-millisecond timeout, and the message processing order is to terminate the current session. Next, the standard template is converted into a set of data manipulation rules. This set contains one rule specifying that the field mapping relationship is that bytes 12 to 15 of the data packet are mapped to the pitch angle variable. The data conversion method is that the actual pitch angle value equals the original value divided by the conversion factor 1000. Here, the actual pitch angle value represents the final physical quantity in degrees, the original value represents the 4-byte unsigned integer extracted from the data packet, and the conversion factor 1000 is a dimensionless scaling factor. For example, when the original value is 1234567, substituting it into the formula, the actual pitch angle value equals 1234567 divided by 1000, which equals 1234.567, resulting in an actual pitch angle value of 1234.567 degrees. Then, based on the state transition rule set containing three rules and the data manipulation rule set containing one rule, a semantic description file is constructed. This file is written in JSON format. The state transition section fully describes the three state transition rules, and the data manipulation section explicitly defines the field mapping relationship and the data conversion method. This file fully defines the protocol interaction logic and data mapping relationship. Finally, the semantic description file is structurally encapsulated, and metadata information such as the file version number 1.0 and the checksum 0x76D8FDC3 calculated using the CRC32 algorithm is added to generate the final key semantic information. The checksum is calculated by performing cyclic redundancy check on the file content to ensure the integrity of the information during transmission.
[0090] In the embodiments of this application, the above-described complete step scheme transforms the process and template into a set of rules and encapsulates them into a standard information package, enabling key protocols and data semantics to be clearly and unambiguously defined and transmitted. This provides accurate and reliable input for subsequent automated code generation, improving the system's information processing efficiency and overall reliability.
[0091] To transform the abstract interface code template into concrete executable target code, in some embodiments, step 104: instantiating the variables, functions, and communication interfaces in the interface code template based on the example data and data interaction rules to generate target interface code includes: Step 501: Extract data samples with actual numerical values and corresponding data type descriptions from the example data.
[0092] In step 501, a data sample refers to a real data instance extracted from the example data that contains specific values. The data type description corresponds to the data sample and describes the type and format of the values in that data sample.
[0093] In this embodiment of the application, representative data records are selected from the provided sample data, data fragments containing actual values are extracted from them, and the data type descriptions corresponding to these data fragments are recorded at the same time.
[0094] Step 502: Determine the specific implementation methods of variables and functions in the interface code template according to the data transmission order and verification requirements of the data interaction rules.
[0095] In step 502, the data transmission order and verification requirements in the data interaction rules are derived from key semantic information extracted after in-depth analysis of the communication protocol. These refer to the rules governing the order in which various fields in the data packet are sent, and verification mechanisms used to ensure data integrity and accuracy, such as CRC checksum and parity check. Specifically, the implementation involves determining the specific code syntax for variables and function logic not yet explicitly defined in the interface code template, based on the requirements of the data interaction rules.
[0096] In this embodiment, based on the data transmission order specified in the data interaction rules and the data verification regulations that must be followed, the specific implementation scheme is determined by how each variable in the interface code template should be defined and how each function should have its internal logic written.
[0097] Step 503: Match and bind the data sample, the data type description, and the corresponding data structure and communication interface in the interface code template.
[0098] In step 503, matching and binding refers to the process of establishing a one-to-one correspondence between data samples and their type descriptions and the abstract data structures and communication interfaces reserved in the interface code template.
[0099] In this embodiment of the application, the data sample and data type description extracted in step 501 are associated with the data structure and communication interface that have been defined in the interface code template to ensure that the real data can be connected to the correct abstract position in the code.
[0100] Step 504: Based on the specific implementation method and in conjunction with the message organization format and interaction sequence flow specified in the communication protocol, fill in the bound interface code template to generate the target interface code.
[0101] In step 504, the message organization format and interaction sequence flow specified in the communication protocol are derived from the specification description obtained by parsing the protocol definition content. Their meanings refer to the binary or character-level organization structure of the message (such as the layout of the frame header, data field, and frame trailer), as well as the time order and response relationship that must be followed during message exchange. The data interaction rules focus on the order and verification at the data level, while the communication protocol specifies the message structure and interaction sequence at a higher level. The two are related as specific implementation and overall framework. The data interaction rules must follow the overall specification of the communication protocol.
[0102] In this embodiment of the application, based on the specific implementation of variables and functions determined in step 502, and strictly adhering to the specific message organization style and interaction time sequence specified in the communication protocol, the interface code template that has completed data binding is filled in with details, and finally the complete target interface code is generated.
[0103] Here is a specific example: Building upon the generated interface code template and existing sample data, a set of data samples with actual numerical values is first extracted from the 100 sets of sample data. This sample includes the raw pitch angle values 1234567, and their corresponding data type description is recorded as a 32-bit unsigned integer. Next, based on the explicit data transmission order requirements in the data interaction rules—that commands must be sent before data is received—and the requirement to use the CRC32 algorithm for data integrity verification, the specific implementation methods of variables and functions in the interface code template are determined. Specifically, a variable named `pitch` is defined to store the pitch angle data, and a function is implemented to calculate the CRC checksum using the standard CRC32 polynomial algorithm. Then, the raw pitch angle values 1234567 and their 32-bit unsigned integer data type description in the data sample are matched and bound to the predefined attitude data structure and serial communication interface in the interface code template to ensure correct data storage and transmission. Finally, based on the determined implementation method, and considering the message organization format requirements stipulated in the communication protocol—that each data packet must begin with 0x55AA and end with a 2-byte CRC checksum—and the interaction timing requirement that the request-response loop must be completed within 5 milliseconds, the bound interface code template was fully populated. Specifically, the message assembly function is responsible for constructing data packets starting with 0x55AA, the data sending function is responsible for sending the command 0xA1 via the serial port, the data receiving function is responsible for waiting for and receiving data packets within 5 milliseconds, and the data parsing function is responsible for extracting data from bytes 12 to 15 of the data packet and converting it into actual angle values. The conversion formula is: the actual pitch angle value equals the original value divided by the conversion factor 1000. In this formula, the actual pitch angle value represents the final physical quantity in degrees, the original value represents the 4-byte unsigned integer extracted from the data packet, and the conversion factor 1000 is a dimensionless scaling factor. For example, when the original value is 1234567, substituting it into the formula, 1234567 divided by 1000 equals 1234.567, resulting in an actual pitch angle value of 1234.567 degrees. At the same time, the CRC check function is responsible for verifying the received data packet, and finally generating a complete and usable target interface code.
[0104] In the embodiments of this application, the above complete steps combine real data with abstract templates and fill in details according to rules, successfully transforming a general code framework into runnable special interface code, ensuring that the generated code can accurately reflect the protocol specifications and process real data, greatly improving development efficiency and code reliability.
[0105] To comprehensively verify the quality and reliability of the generated interface code, in some embodiments, step 105 involves generating multi-scenario test cases based on the target interface code and the example data using a test case generation algorithm. By executing these test cases, the correctness, stability, and performance of the interface are verified, and test verification results are obtained, including: Step 601: Based on the interface functions implemented by the target interface code, generate normal data flow test scenarios and abnormal data flow test scenarios according to the test requirements corresponding to the interface functions.
[0106] In step 601, the interface function refers to the specific capabilities implemented by the target interface code, such as data transmission, protocol parsing, and message processing. These capabilities are derived from the actual functions identified after analyzing the generated interface code. The corresponding test requirements for the interface function refer to the test requirements for verifying whether each function of the interface works properly, including data transmission and reception correctness, protocol compliance, and exception handling capabilities. These requirements are derived from the analysis of the interface function and the requirements of the communication protocol specifications. The normal data flow test scenario refers to a test environment that simulates data interaction by the device under standard operating conditions. The abnormal data flow test scenario refers to a test environment that simulates data interaction by the device under non-standard or erroneous conditions.
[0107] In this embodiment of the application, the target interface code is first analyzed to determine which interface functions are implemented. Then, for each interface function, the test requirements that it needs to meet are determined. Based on these test requirements, test scenarios simulating normal working conditions and test scenarios simulating various abnormal conditions are designed respectively.
[0108] Step 602: Based on the example data, use the test case generation algorithm to generate input test data sets corresponding to normal data processing scenarios and abnormal data processing scenarios, respectively.
[0109] In step 602, the input test data set refers to a set of test input data generated for a certain test scenario.
[0110] In this embodiment of the application, based on existing example data, a test case generation algorithm is used to generate a set of test data that conforms to normal data specifications for the normal data processing scenario determined in step 601, and at the same time, a set of test data containing various error situations is generated for the abnormal data processing scenario.
[0111] Step 603: Combine the input test data set with the corresponding test scenario configuration information to form test cases for multiple scenarios.
[0112] In step 603, the test scenario configuration information refers to the setting information that defines the test environment, test parameters, expected results and other test execution conditions, which comes from the configuration rules predefined for each scenario according to the test requirements.
[0113] In this embodiment of the application, the input test data set generated in step 602 is combined with the corresponding test scenario configuration information to form a complete test case containing specific test data and test conditions for each test scenario.
[0114] Step 604: Execute the test case in the corresponding scenario according to the message organization format and interaction sequence flow specified in the communication protocol to obtain the interface output results.
[0115] In step 604, the interface output result refers to the actual response and data output generated by the target interface code after receiving the input data of the test case.
[0116] In this embodiment of the application, the test cases formed in step 603 are executed in the corresponding test scenario in strict accordance with the message organization format and interaction sequence flow specified in the communication protocol, and all output results generated by the target interface code are recorded.
[0117] Step 605: Compare the interface output with the preset expected behavior to verify the correctness of the interface under different load conditions, and verify its stability and performance to obtain the test verification results.
[0118] In step 605, the preset expected behavior refers to the correct output that the interface should produce under specific inputs, predefined according to the interface function and protocol specifications. Different load conditions refer to various data traffic intensities and processing pressures simulated during testing, including data interaction states such as low load, normal load, peak load, and abnormal load.
[0119] In this embodiment of the application, the interface output result obtained in step 604 is compared in detail with the preset expected behavior to check whether the interface response is correct under various load conditions. At the same time, the stability of the interface is verified by long-term running test, and the performance of the interface is evaluated by measuring indicators such as response time, and finally a complete test verification result is obtained.
[0120] Here is a specific example: Utilizing the generated target interface code and 100 sets of existing sample data, the test case generation process first simulates the correct command interaction process based on the command sending and data parsing functions implemented by the target interface code, according to the corresponding test requirements. It then generates abnormal data flow test scenarios to simulate timeout responses and data format errors. Based on the 100 sets of sample data, a test case generation algorithm generates 85 sets of input test data corresponding to normal data processing scenarios, all conforming to the protocol specifications. Simultaneously, it generates 15 sets of input test data corresponding to abnormal data processing scenarios, containing error check codes or timeout trigger conditions. The 85 sets of normal test data are combined with normal scenario configuration information, and the 15 sets of abnormal test data are combined with abnormal scenario configuration information to form 100 multi-scenario test cases. Following the communication protocol's requirement that messages must begin with 0x55AA and end with a 2-byte CRC checksum, and that request-response interaction must be completed within 5 milliseconds, all 100 test cases are executed in their respective scenarios to obtain the interface output results. The interface output was compared with the preset expected behavior, which was derived from the protocol specification. This included correctly parsing pitch angle data in normal scenarios and returning an error code in abnormal scenarios. The comparison revealed that the target interface code's output did not match the expectations when handling the 73rd abnormal test case. This case simulated a checksum error, and the code failed to return the correct error code but instead parsed the data incorrectly. In addition, during the stability test after running continuously for 1 hour, memory usage was observed to increase from the initial 45MB to 68MB. In the performance test, under the load condition of processing 1000 data packets per second, the average response time was measured to be 1.05 milliseconds. These verification results were recorded in the test verification results. The memory usage increase value was 68 minus 45 equals 23MB, and the average response time was calculated by dividing the total response time by the number of test cases.
[0121] In this embodiment, the above complete steps automatically generate multi-scenario test cases and perform comprehensive verification, ensuring multi-dimensional quality assessment of the interface code's functionality, stability, and performance. This provides an accurate and reliable basis for subsequent code optimization and improves testing efficiency and verification completeness.
[0122] To achieve self-optimization and continuous improvement of the code generation system, in some embodiments, step 106: performing structural complexity analysis and runtime efficiency evaluation on the target interface code to obtain performance analysis results, and dynamically adjusting the parameters and training data of the large language model based on the test verification results and the performance analysis results, includes: Step 701: Perform structural complexity analysis on the target interface code to generate quantitative indicators corresponding to the code logic complexity and module dependency relationship.
[0123] In step 701, code logic complexity is a quantitative metric that measures the complexity of conditional statements and loop structures in the code. Module dependency refers to the relationships of mutual calls and references between different functional modules in the code. Quantitative metrics are the results of the analysis presented in numerical form.
[0124] In this embodiment of the application, a specialized code analysis tool is used to perform structural complexity analysis on the target interface code. Numerical indicators representing the complexity of the code logic are generated by calculating the number of conditional branches and the depth of nested loops in the code. At the same time, quantitative indicators describing the dependencies between modules are generated by analyzing the function call relationship graph.
[0125] Step 702: In a preset simulated data interaction environment, evaluate the running efficiency of the target interface code to obtain the resource utilization rate and data processing throughput.
[0126] In step 702, the simulated data interaction environment refers to a software testing environment constructed to mimic real device communication. Resource utilization rate refers to the proportion of computing resources used during code execution. Data processing throughput refers to the amount of data that the code can process per unit of time.
[0127] In this embodiment of the application, the target interface code is run in a preset simulated data interaction environment. The processor and memory usage during the code execution is collected in real time by a monitoring tool to obtain the resource utilization rate. At the same time, the number of data packets successfully processed by the code within a specific time period is counted to obtain the data processing throughput.
[0128] Step 703: Generate performance analysis results based on the quantitative indicators, the resource utilization rate, and the data processing throughput.
[0129] In this embodiment of the application, the code logic complexity and module dependency quantitative indicators generated in step 701 are comprehensively analyzed with the resource utilization and data processing throughput data obtained in step 702 to generate a performance analysis result that fully reflects the code quality and performance.
[0130] Step 704: Based on the test verification results and performance analysis results, determine the types of code defects and performance bottlenecks.
[0131] In step 704, code defects refer to functional or logical errors in the code. Performance bottlenecks refer to critical parts or modules that limit the efficiency of code execution.
[0132] In this embodiment, based on the functional errors and anomalies recorded in the test verification results, and combined with the resource utilization efficiency and data processing capability indicators shown in the performance analysis results, the specific defect types and performance bottleneck types in the code are comprehensively analyzed and determined. The specific implementation process is as follows: Error reports in the test verification results and anomaly indicators in the performance analysis results are analyzed. Functional errors and runtime crashes occurring during testing are correlated and compared with anomaly indicators such as high complexity and low throughput identified in the performance analysis, thereby determining the specific code defect types and performance bottleneck types. For example, if the test verification results show a data parsing error, and the performance analysis results show that the parsing function has a cyclomatic complexity as high as 20 and a processing throughput lower than the standard value, then the code defect is determined to be a logical error, and the performance bottleneck is an overly complex function structure.
[0133] Step 705: Dynamically adjust the parameters and training data of the large language model based on the code defects and the performance bottleneck types.
[0134] In step 705, dynamic adjustment refers to the process of modifying the model configuration and training content in real time based on feedback results.
[0135] In this embodiment of the application, based on the code defect type and performance bottleneck type determined in step 704, the internal parameter settings of the large language model are adjusted in a targeted manner, while the training data content of the model is updated to increase the proportion of correct code samples and reduce code patterns that lead to defects.
[0136] Here is a specific example: Based on the generated target interface code and existing test results, the structural complexity of the target interface code is first analyzed. Using code analysis tools, a cyclomatic complexity of 15 is calculated as a quantitative indicator of code logic complexity. This value is derived by counting the number of conditional decision nodes and edges in the code. The specific formula is: cyclomatic complexity equals the number of edges minus the number of nodes plus 2, where the number of edges represents the number of edges in the program control flow graph, and the number of nodes represents the number of nodes in the control flow graph. Simultaneously, a module dependency relationship quantitative indicator of 0.3 is generated, calculated by analyzing the ratio of dependency connections between modules to the total number of possible connections in the function call graph. Next, the runtime efficiency of the target interface code is evaluated in a preset simulated data interaction environment, simulating a load condition of processing 1000 data packets per second. Performance monitoring tools show a CPU utilization of 12%, a memory utilization of 45MB, and a data processing throughput of 950 data packets per second. The throughput value is calculated by dividing the total number of successfully processed data packets (57,000) by 60 seconds (i.e., 57,000 divided by 60 equals 950). Then, based on quantitative indicators such as cyclomatic complexity of 15, module dependency of 0.3, CPU utilization of 12%, memory utilization of 45MB, and data processing throughput of 950 data packets per second, performance analysis results were generated. Based on the recorded errors in handling specific abnormal data packets and the issue of memory usage slowly increasing from 45MB to 68MB in the test verification results, combined with the high cyclomatic complexity and relatively low data processing throughput in the performance analysis results, the code defect was determined to be an error in the exception handling logic, and the performance bottleneck was low memory usage efficiency caused by excessive code structure complexity. Finally, based on the determined code defect type and performance bottleneck type, the parameter configuration of the large language model was dynamically adjusted, reducing the generation weight of complex conditional structures, while increasing code samples with efficient memory usage in the training data to optimize the model and improve the accuracy and efficiency of subsequent code generation.
[0137] In the embodiments of this application, the above complete steps accurately identify the quality problems and efficiency bottlenecks of the generated code through systematic code analysis and performance evaluation, and accordingly achieve targeted optimization of the large language model, effectively improving the accuracy and efficiency of subsequent code generation and forming a good self-improvement cycle.
[0138] The following are specific examples: 1. Data collection and preprocessing The data acquisition module collects communication protocols, data formats, and sample data (such as) of simulation / real parts provided by different manufacturers. Figure 2As shown, the data acquisition module communicates with external simulation / real components to acquire relevant data. The collected data is preprocessed, using data cleaning algorithms to remove noise and data extraction algorithms to extract key information from the communication protocol, such as protocol type, data transmission format, and data interaction rules, as well as key information from the data format, such as data structure and data type. Data cleaning can be expressed by the following formula: ,in, This represents the cleaned data set. Represents the original data set. This represents a set of noisy data. When extracting data, it is assumed that the communication protocol information set is... The data format information set is The sets after extracting key information are as follows: and Its extraction process can be represented as and ,in and These are functions for extracting key information about the communication protocol and key information about the data format. This key information is then converted according to a pre-defined standardized data format to create a data file that is easy for DeepSeek's large models to process.
[0139] 2. DeepSeek Large Model Module A pre-trained DeepSeek model with powerful learning and inference capabilities is introduced. Preprocessed, standardized data is input into the DeepSeek model, which uses deep learning algorithms to perform deep analysis of communication protocols and data formats, and employs semantic understanding algorithms to extract key semantic information. Assuming the input data is X, the code template output by the DeepSeek model is T, the specific implementation details are D, and the final generated interface code is C, the process can be represented as follows: in, This represents the DeepSeek large model, where G represents the function that generates specific implementation details based on input information I (such as example data and data interaction rules). Based on the extracted key semantic information, the DeepSeek large model generates corresponding code templates, and then, based on the example data and data interaction rules, fills in the specific implementation details, ultimately forming the complete interface code (in...). Figure 3 The document demonstrates the connection between the DeepSeek large model and the data processing and code generation modules, as well as the data flow and code generation process.
[0140] 3. Automatic generation and verification of test cases Design a test case generation module that receives the generated interface code and sample data. Based on the functional requirements of the interface code and the characteristics of the sample data, the test case generation module automatically generates test cases using a test case generation algorithm. Assume the set of functional requirements for the interface code is as follows: The example data is S, and the generated test case set is TC. The generation process can be represented as follows: Here, `Gen` is the test case generation function. The generated test cases are input into the test execution module, and the test cases are executed. The correctness of the interface code is verified by comparing its output with the expected results of the example data; the stability of the interface code is verified by running it for an extended period and monitoring its execution status; and the performance of the interface code is verified by measuring metrics such as the time it takes to process data. Figure 4 It demonstrates the connection relationship and data interaction process between the test case generation module, the test execution module, and the interface code.
[0141] 4. Code Complexity and Execution Efficiency Analysis Code analysis tools are introduced to perform complexity analysis on the generated interface code, evaluating its readability and maintainability based on factors such as cyclomatic complexity, lines of code, and function call depth. Simultaneously, performance analysis tools are used to evaluate the runtime efficiency of the interface code by simulating real-world data interaction scenarios, monitoring metrics such as response time and throughput to ensure the interface code meets real-time requirements. Figure 5 This demonstrates how code analysis tools and performance analysis tools connect to the interface code and the flow of analysis data. Cyclomatic complexity can be calculated using the McCabe method. Assuming the number of decision nodes in the code is n, the number of connecting edges is e, and the number of regions is r, the cyclomatic complexity V(G) is calculated using the following formula: .
[0142] 5. System Optimization and Iteration Based on the test and performance analysis results, the DeepSeek large model is optimized. If tests reveal errors in the interface code, the error information and relevant data are fed back to the DeepSeek large model. By adjusting the model's parameters and training data, the accuracy of code generation is improved. If performance analysis shows that the interface code's execution efficiency is substandard, the code performance bottlenecks are analyzed, and the DeepSeek large model's code generation strategy is optimized to improve code generation efficiency, thus achieving system optimization and iteration. The flowchart is attached. Figure 6 As shown.
[0143] Figure 7 This application provides a schematic diagram of the structure of an automatic generation system for flight simulator interface code based on a large language model, and the specific implementation details are as follows: The acquisition module 71 is used to acquire interface data provided by multiple external devices in the flight target. The interface data includes communication protocols, data formats, and sample data.
[0144] The filtering module 72 is used to perform noise filtering on the interface data, extract key information of the communication protocol and key information of the data format from the processed interface data, and convert the key information of the communication protocol and key information of the data format according to the preset standardized data format to form structured input data.
[0145] The input module 73 is used to input the structured input data into a pre-trained large language model, perform deep parsing on the structured input data through the deep learning algorithm in the large language model, extract key semantic information from the parsing results using the semantic understanding algorithm in the large language model, and generate an interface code template based on the key semantic information.
[0146] The generation module 74 is used to instantiate the variables, functions and communication interfaces in the interface code template based on the example data and data interaction rules, and generate the target interface code.
[0147] The verification module 75 is used to generate test cases for multiple scenarios based on the target interface code and the example data using a test case generation algorithm. By executing the test cases, the correctness, stability and performance of the interface are verified, and test verification results are obtained.
[0148] Evaluation module 76 is used to perform structural complexity analysis and runtime efficiency evaluation on the target interface code to obtain performance analysis results. Combining the test verification results and the performance analysis results, the parameters and training data of the large language model are dynamically adjusted to realize a closed-loop automated interface code generation process.
[0149] The automatic generation system for flight simulator interface code based on a large language model in this application is used to implement the aforementioned automatic generation method for flight simulator interface code based on a large language model. Therefore, the specific implementation of the automatic generation system for flight simulator interface code based on a large language model can be found in the embodiment section of the automatic generation method for flight simulator interface code based on a large language model above. The specific implementation can be referred to the description of the corresponding embodiments, which will not be repeated here.
[0150] This application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described methods for automatically generating interface code for flight simulators based on large language models.
[0151] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the above-described methods for automatically generating interface code for flight simulators based on large language models.
[0152] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory, random access memory, portable hard drives, magnetic disks, or optical disks.
[0153] The embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the embodiments of the automatic generation method for flight simulator interface code based on a large language model.
[0154] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0155] The foregoing has provided a detailed description of the method, system, device, and storage medium for automatically generating interface code for a flight simulator based on a large language model, as provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.
Claims
1. A method for automatically generating interface code for flight simulators based on a large language model, characterized in that, include: Acquire interface data provided by multiple external devices in the flight target, the interface data including communication protocols, data formats and sample data; The interface data is subjected to noise filtering, and key information of the communication protocol and key information of the data format are extracted from the processed interface data. The key information of the communication protocol and key information of the data format are then converted according to a preset standardized data format to form structured input data. The structured input data is input into a pre-trained large language model. The structured input data is deeply parsed using the deep learning algorithm in the large language model. Key semantic information is extracted from the parsing results using the semantic understanding algorithm in the large language model. An interface code template is generated based on the key semantic information. Based on the example data and data interaction rules, the variables, functions and communication interfaces in the interface code template are instantiated to generate the target interface code. Based on the target interface code and the example data, test cases in multiple scenarios are generated using a test case generation algorithm. By executing the test cases, the correctness, stability, and performance of the interface are verified, and test verification results are obtained. The target interface code is subjected to structural complexity analysis and runtime efficiency evaluation to obtain performance analysis results. Based on the test verification results and the performance analysis results, the parameters and training data of the large language model are dynamically adjusted to achieve a closed-loop automated interface code generation process.
2. The method for automatically generating interface code for flight simulators based on a large language model according to claim 1, characterized in that, The process involves inputting the structured input data into a pre-trained large language model, performing deep analysis on the structured input data using deep learning algorithms within the large language model, extracting key semantic information from the analysis results using semantic understanding algorithms within the large language model, and generating an interface code template based on the key semantic information. This includes: The structured input data is input into a large language model. The encoding module of the large language model performs joint encoding on the protocol definition content and data format description content in the structured input data to form a model input sequence. Using the deep learning algorithm provided by the large language model, multi-level semantic parsing is performed on the input sequence of the model to obtain deep parsing results; Using the semantic understanding algorithm provided by the large language model, semantic relationship reasoning is performed on the deep parsing results to obtain key semantic information, which includes protocol interaction logic and data mapping relationship. Based on the protocol interaction logic and the data mapping relationship, an interface code template is generated.
3. The method for automatically generating interface code for flight simulators based on a large language model according to claim 2, characterized in that, The semantic understanding algorithm provided by the large language model is used to perform semantic relationship reasoning on the deep parsing results to obtain key semantic information, including: Dependency analysis is performed on the protocol syntax units in the deep parsing results to identify the triggering conditions and timing constraints between protocol commands and responses; Semantic role labeling is performed on the data structure definitions in the deep parsing results to parse the functional attributes, value ranges, and encoding methods of the data fields; Based on the triggering conditions and the timing constraints, a state transition model for the message sequence is established, and the complete workflow of protocol interaction is derived based on the state transition model. Based on the functional attributes, the value range, and the encoding method, a mapping rule and conversion relationship between data fields are constructed, and a standard template for data parsing and encapsulation is formed based on the mapping rule and the conversion relationship. Based on the complete workflow and the standard template, key semantic information is generated.
4. The method for automatically generating interface code for flight simulators based on a large language model according to claim 3, characterized in that, Based on the complete workflow and the standard template, key semantic information is generated, including: The complete workflow is converted into a set of state transition rules that include state transition conditions and message processing order. The standard template is converted into a set of data manipulation rules that include field mapping relationships and data transformation methods; Based on the set of state transition rules and the set of data operation rules, a semantic description file is constructed, which defines the protocol interaction logic and data mapping relationship; The semantic description file is structured and encapsulated to generate key semantic information.
5. The method for automatically generating interface code for flight simulators based on a large language model according to claim 1, characterized in that, The step of instantiating the variables, functions, and communication interfaces in the interface code template based on the example data and data interaction rules to generate the target interface code includes: Extract data samples with actual numerical values and their corresponding data type descriptions from the example data; Based on the data transmission order and verification requirements of the data interaction rules, determine the specific implementation methods of variables and functions in the interface code template; Match and bind the data sample and the data type description with the corresponding data structure and communication interface in the interface code template; Based on the specific implementation method described above, and in conjunction with the message organization format and interaction sequence flow specified in the communication protocol, the bound interface code template is filled in to generate the target interface code.
6. The method for automatically generating interface code for flight simulators based on a large language model according to claim 1, characterized in that, Based on the target interface code and the example data, a test case generation algorithm is used to generate test cases for multiple scenarios. By executing the test cases, the correctness, stability, and performance of the interface are verified, and test verification results are obtained, including: Based on the interface functions implemented by the target interface code, and according to the test requirements corresponding to the interface functions, generate normal data flow test scenarios and abnormal data flow test scenarios. Based on the example data, a test case generation algorithm is used to generate input test data sets corresponding to normal data processing scenarios and abnormal data processing scenarios, respectively. The input test data set is combined with the corresponding test scenario configuration information to form test cases for multiple scenarios; According to the message organization format and interaction sequence flow specified in the communication protocol, execute the test case in the corresponding scenario to obtain the interface output results; The interface output is compared with the preset expected behavior to verify the correctness of the interface under different load conditions, as well as to verify its stability and performance, and to obtain the test verification results.
7. The method for automatically generating interface code for flight simulators based on a large language model according to claim 1, characterized in that, The process of performing structural complexity analysis and runtime efficiency evaluation on the target interface code to obtain performance analysis results, and then dynamically adjusting the parameters and training data of the large language model based on the test verification results and the performance analysis results, includes: Perform structural complexity analysis on the target interface code to generate quantitative indicators corresponding to the code logic complexity and module dependency relationship, respectively. In a pre-defined simulated data interaction environment, the runtime efficiency of the target interface code is evaluated to obtain resource utilization and data processing throughput. Based on the quantitative indicators, the resource utilization rate, and the data processing throughput, performance analysis results are generated. Based on the test verification results and performance analysis results, the types of code defects and performance bottlenecks are determined; Based on the code defects and the types of performance bottlenecks, the parameters and training data of the large language model are dynamically adjusted.
8. A flight simulator interface code automatic generation system based on a large language model, characterized in that, include: The acquisition module is used to acquire interface data provided by multiple external devices in the flight target. The interface data includes communication protocols, data formats, and sample data. The filtering module is used to perform noise filtering on the interface data, extract key information of the communication protocol and key information of the data format from the processed interface data, and convert the key information of the communication protocol and key information of the data format according to the preset standardized data format to form structured input data. The input module is used to input the structured input data into a pre-trained large language model, perform deep parsing on the structured input data through the deep learning algorithm in the large language model, extract key semantic information from the parsing results using the semantic understanding algorithm in the large language model, and generate an interface code template based on the key semantic information. The generation module is used to instantiate the variables, functions and communication interfaces in the interface code template based on the example data and data interaction rules, and generate the target interface code. The verification module is used to generate test cases for multiple scenarios based on the target interface code and the example data using a test case generation algorithm. By executing the test cases, the correctness, stability and performance of the interface are verified, and test verification results are obtained. The evaluation module is used to perform structural complexity analysis and runtime efficiency evaluation on the target interface code to obtain performance analysis results. Combining the test verification results and the performance analysis results, the parameters and training data of the large language model are dynamically adjusted to achieve a closed-loop automated interface code generation process.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the automatic generation method for flight simulator interface code based on a large language model as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, enables the automatic generation method for flight simulator interface code based on a large language model as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Business data interface generation method and device, equipment and medium
CN118981304A
Visual intelligent programming method based on large language model
CN119045806A
Internet of Things equipment access protocol component development method, equipment and storage medium
CN119396365A
Automatic generation of test scenarios from specification files
US20240338306A1
Cited By
Tool generation method and device, computer equipment and storage medium
CN121478667A
Heterogeneous service system integration method and device based on large model, terminal and medium
CN121858607A
