Code file generation method and device corresponding to vehicle signal, equipment, storage medium and product
By analyzing and generating signal definition classes and generating project codes based on code templates, the problem of cumbersome and repetitive signal processing development in the on-board Android operating system is solved, efficient and automated code generation is achieved, and development efficiency and quality is improved.
Patent Information
- Application Number
- CN202411833550.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-11
AI Technical Summary
In the on-board Android operating system, the customized development work required for signal processing is cumbersome and highly repetitive, causing developers to spend a lot of time on applications of similar business codes and are prone to human errors.
By responding to the user's editing operation of the signal definition document, the preset document processing library is used to parse the signal definition document, generate the signal definition class, and generate project code based on the preset code template, and generate the corresponding code file after compilation and verification.
This method simplifies user operations, automatically generates a large number of repetitive codes, reduces repetitive labor, reduces human errors, and improves overall development efficiency and quality.
Smart Images

Figure CN119806629A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment, storage medium and product for generating a code file corresponding to a vehicle signal. Background Art
[0002] In the in-vehicle Android operating system (Android Automotive OS, AAOS), the in-vehicle service (CarService) is responsible for vehicle status query and control of in-vehicle applications. It communicates through the hardware abstraction layer service to pass instructions to the various electronic control units of the car, thereby controlling the vehicle's actuators, realizing communication from system applications to vehicle actuators, which involves a lot of signal processing.
[0003] In actual development, a lot of customized development work is required for these signal processing. With the addition of new signals, it is necessary to go through the processes of definition, coding, testing and document writing, which are cumbersome and highly repetitive. When adding a large number of signals, this series of processes needs to be repeated, which is very cumbersome. Most of the time of developers is spent on applying these similar business codes, which is time-consuming and labor-intensive, and prone to human errors. Summary of the invention
[0004] The embodiments of the present application provide a method, device, equipment, storage medium and product for generating a code file corresponding to a vehicle signal, which can improve overall development efficiency and quality.
[0005] In a first aspect, the present application provides a method for generating a code file corresponding to a vehicle signal, the method comprising:
[0006] In response to a user editing operation on a signal definition document, determining an updated signal definition document, the signal definition document including attributes of a vehicle signal;
[0007] Parsing the signal definition document using a preset document processing library to obtain a corresponding signal definition class;
[0008] Generate corresponding project codes for each of the signal definition classes according to a preset code template;
[0009] Compile the project code;
[0010] If the compilation is successful, generate test code, and verify the project code through the test code;
[0011] When the project code is compiled and verified successfully, a code file corresponding to the updated signal definition document is generated.
[0012] In some possible implementations, before generating corresponding project codes for each of the signal definition classes according to a preset code template, the method further includes:
[0013] Determine the code structure corresponding to the preset project requirements based on the signal attributes, signal protocols and signal permissions corresponding to the preset project requirements;
[0014] A preset parameter placeholder is added to the code structure to obtain a preset code template.
[0015] In some possible implementations, the generating the test code and verifying the project code by using the test code includes:
[0016] Generate corresponding test codes for code files corresponding to vehicle signals generated by each of the project codes according to a preset code template;
[0017] Each of the test codes is run through the preset bus tool chain software to simulate the signal receiving and sending process and perform signal transmission verification.
[0018] In some possible implementations, the using a preset document processing library to parse the signal definition document to obtain a corresponding signal definition class includes:
[0019] Parsing the signal definition document using a preset document processing library to perform data format verification;
[0020] In case of data format verification failure, verification error information is generated;
[0021] When the data format verification is successful, a corresponding signal definition class is generated according to the signal definition document.
[0022] In some possible implementations, generating a corresponding project code for each of the signal definition classes according to a preset code template includes:
[0023] Traverse each of the signal definition classes and perform the following steps for each of the signal definition classes:
[0024] Based on the type of the signal definition class, a corresponding preset code template is obtained, where the preset code template is a code structure predefined according to actual needs;
[0025] Extracting target parameters in the signal definition class;
[0026] The target parameters are used to replace the corresponding parameters in the preset code template to obtain the project code.
[0027] In some possible implementations, when the project code is compiled and verified, after generating a code file corresponding to the updated signal definition document, the method further includes:
[0028] When the project code is compiled and verified, performing signal parsing on the signal definition class to obtain a parsing result;
[0029] Generate a description document of the project code based on the analysis result.
[0030] In a second aspect, the present application provides a device for generating a code file corresponding to a vehicle signal, the device comprising:
[0031] a response module, configured to determine an updated signal definition document in response to a user's editing operation on the signal definition document, wherein the signal definition document includes attributes of the vehicle signal;
[0032] A parsing module, used for parsing the signal definition document using a preset document processing library to obtain a corresponding signal definition class;
[0033] A generation module, used for generating corresponding project codes for each of the signal definition classes according to a preset code template;
[0034] A compiling module, used for compiling the project code;
[0035] The test module is used to generate test code when the compilation is successful, and verify the project code through the test code;
[0036] The generation module is also used to generate a code file corresponding to the updated signal definition document when the compilation and verification of the project code are passed.
[0037] In a third aspect, the present application provides a device for generating a code file corresponding to a vehicle signal, the device comprising: a processor, and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the method for generating a code file corresponding to a vehicle signal as described above.
[0038] In a fourth aspect, the present application provides a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, the method for generating a code file corresponding to the vehicle signal as described above is implemented.
[0039] In a fifth aspect, the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the method for generating a code file corresponding to the vehicle signal as described above.
[0040] The code file generation method, device, equipment, storage medium and product corresponding to the vehicle signal provided in the embodiment of the present application determine the updated signal definition document by responding to the user's editing operation on the signal definition document, the signal definition document includes the attributes of the vehicle signal, and then use the preset document processing library to parse the signal definition document to obtain the corresponding signal definition class, and then generate the corresponding project code for each signal definition class according to the preset code template, and then compile the project code. If the compilation passes, generate the test code, verify the project code through the test code, and if the compilation and verification of the project code pass, generate the code file corresponding to the updated signal definition document. In this way, the developer only needs to pay attention to the accuracy of the signal definition document and the implementation of the business logic, and edit and modify the signal definition document. There is no need to perform other operations, and there is no need to manually write a large amount of templated code, so that a large amount of repetitive code can be automatically generated, which simplifies the user's operation, can automatically generate a large amount of repetitive code, reduces repetitive work, and enables developers to devote more energy to the development of core business logic, reduce human errors, and improve overall development efficiency and quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The present application can be better understood from the following description of the specific embodiments of the present application in conjunction with the accompanying drawings, in which:
[0042] Other features, objects and advantages of the present application will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings, in which the same or similar reference numerals represent the same or similar features.
[0043] Figure 1 is a flowchart of a method for generating a code file corresponding to a vehicle signal provided by an embodiment of the present application;
[0044] Figure 2 is a flowchart of a method for generating a code file corresponding to a vehicle signal provided by another embodiment of the present application;
[0045] Figure 3 It is a flowchart of a method for generating a code file corresponding to a vehicle signal provided by another embodiment of the present application;
[0046] Figure 4 It is a structural schematic diagram of a device for generating a code file corresponding to a vehicle signal provided by an embodiment of the present application;
[0047] Figure 5 It is a schematic diagram of the hardware structure of a code file generating device corresponding to a vehicle signal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0049] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0050] In order to solve the problems of the prior art, the embodiments of the present application provide a method, device, equipment, storage medium and product for generating a code file corresponding to a vehicle signal. The method for generating a code file corresponding to a vehicle signal provided in the embodiments of the present application is first introduced below.
[0051] Figure 1 FIG. 1 is a flow chart showing a method for generating a code file corresponding to a vehicle signal provided by an embodiment of the present application. Figure 1 As shown, the method includes the following steps: S101 to S106.
[0052] S101: In response to a user's editing operation on a signal definition document, determining an updated signal definition document, wherein the signal definition document includes attributes of a vehicle signal.
[0053] In the specific implementation, the user edits the signal definition document, and the document content involves the signal attributes of the vehicle, such as the signal type, name, data type, unit, etc. After the user submits the edited document, these modifications are confirmed and the document content is correct in format and content. This involves verifying the structure and format of the document and ensuring that the signal attributes such as name, type, length, etc. are consistent with the system requirements.
[0054] As another implementation, a text editor or interface can be provided to allow the user to edit the vehicle signal definition. After the user saves the document, the system will perform a format check on the document to ensure the integrity and legality of the document.
[0055] S102: Use a preset document processing library to parse the signal definition document to obtain a corresponding signal definition class.
[0056] Parsing is the process of converting a signal definition document into a structure that can be manipulated by a computer. This process requires the use of a preset document processing library to convert the document content into a corresponding data structure.
[0057] In the specific implementation, a suitable document processing library is selected to parse the signal definition document. During the parsing process, each signal item in the signal document will be converted into the attribute of the signal definition class. The signal definition class may be a class object, which contains the various attributes of the signal. The parsed data will be converted into a signal definition class object, where each signal may have different attributes.
[0058] S103: Generate corresponding project codes for each of the above signal definition classes according to a preset code template.
[0059] The preset code template is usually a set of standardized code structures used to generate source code corresponding to the signal definition class. The template can be a code snippet based on a certain programming language, which contains the declaration, initialization, operation and other methods of the signal definition class.
[0060] In the specific implementation, by parsing the information of the signal definition class, the signal attributes are replaced into the template using the template to generate the corresponding project code. For each signal definition class, the code is generated according to the preset template. The various attributes of the signal definition class are filled into the corresponding positions in the template to generate the corresponding class files, constructors, data members, methods, etc. The generated code usually includes the implementation of the signal class and the necessary operation methods.
[0061] S104: Compile the above project code.
[0062] In the specific implementation, the generated project code needs to be compiled and converted into executable machine code or bytecode. The compilation process will check syntax errors, type errors, dependencies, etc., and convert the source code into a target file. The compilation step usually uses a preset compilation tool to compile the generated source code. The compilation process includes code checking, syntax analysis, generating target files, etc. If there is an error in the compilation process, the system will capture the error and return a log of the compilation failure for the developer to modify.
[0063] S105: If the compilation is successful, a test code is generated, and the project code is verified by the test code. The test code usually simulates different input signals to check whether the output result is correct. The test may include boundary testing, functional testing, performance testing, etc.
[0064] In the specific implementation, the compiled project code needs to be verified to ensure that it meets the expected functions, and the corresponding unit test code is generated according to the signal definition class. The purpose of the test code is to verify whether the generated project code can work according to the expected logic.
[0065] As another implementation method, test codes are first automatically generated, such as testing the initialization and assignment of signals, testing whether signal attributes are correct, testing whether methods of signal classes work as expected, etc. These test codes are run using a test framework to perform functional verification on project codes.
[0066] S106: When the compilation and verification of the project code are passed, a code file corresponding to the updated signal definition document is generated.
[0067] In the specific implementation, after the project code is compiled and tested, the final generated code file will be consistent with the updated signal definition document. This process is usually performed after verification, which means that all generated code has passed the test verification. After the code is compiled and tested, the final code file will be generated, and may include documented comments, log information, or configuration files to ensure that it is consistent with the signal definition document. The final code file will be stored in a specified location for subsequent integration or deployment.
[0068] The method for generating a code file corresponding to a vehicle signal provided in an embodiment of the present application determines an updated signal definition document by responding to a user's editing operation on a signal definition document, wherein the signal definition document includes attributes of a vehicle signal, and then uses a preset document processing library to parse the signal definition document to obtain a corresponding signal definition class, and then generates a corresponding project code for each of the signal definition classes according to a preset code template, and then compiles the project code. If the compilation passes, a test code is generated, and the project code is verified by the test code. If the compilation and verification of the project code pass, a code file corresponding to the updated signal definition document is generated. In this way, developers only need to pay attention to the accuracy of the signal definition document and the implementation of business logic, and edit and modify the signal definition document. No other operations need to be performed, and no large amount of templated code needs to be manually written. A large amount of repetitive code can be automatically generated, which simplifies user operations, can automatically generate a large amount of repetitive code, reduces repetitive work, and enables developers to devote more energy to the development of core business logic, reduce human errors, and improve overall development efficiency and quality.
[0069] In order to obtain an accurate preset code template, in some implementations, before the above S103, the above method may further include the following steps: S113 to S123.
[0070] S113: Determine a code structure corresponding to the preset project requirement according to the signal attributes, signal protocols and signal permissions corresponding to the preset project requirement.
[0071] In specific implementations, signal attributes usually include information such as the signal type, name, data length, and unit. Signal protocol refers to the communication specification of the signal. The protocol specification affects how the signal is transmitted in the network and how the signal data is packaged and unpacked. Therefore, the code structure needs to be designed according to the protocol requirements to correctly handle the sending and receiving of signal data. Signal permissions involve which modules or users can access or modify certain signals. Permissions usually determine whether the signal needs to be encrypted or access control needs to be set. For example, some signals may only be modified by specific hardware modules, while others can be read by all modules in the system.
[0072] As another implementation method, first scan the signal definition document and determine how to represent these signals in the code based on the signal type, length, unit and other attributes defined in the document. It may be necessary to define a data type, structure or class for each signal. According to the signal protocol required by the project, the requirements of each protocol will be analyzed and the signal processing logic will be designed. At the same time, different access rights, encryption methods, etc. will be set according to the permission control of the signal.
[0073] S123: Add a preset parameter placeholder to the above code structure to obtain a preset code template.
[0074] In the specific implementation, placeholders are occupied positions in the code template, which are used to dynamically replace the actual signal attributes, protocols, permissions, and other values. Placeholders are usually represented by specific symbols or formats. They represent places that will be replaced by actual data when the code is generated. For example, the name, data type, and unit of the signal can be used as placeholders in the code structure, and then replaced with the actual signal attributes when the specific code is generated. If the signal uses a specific communication protocol, there may be placeholders in the code to represent the signal's protocol type, message ID, signal length, etc. These placeholders will be replaced by specific parameters related to the protocol when the code is actually generated. The access rights of the signal may also use placeholders, which will be replaced by the actual permission control logic in the subsequent generated code, thereby obtaining a preset code template. A code template is usually a structured code file that contains placeholders and a preset code skeleton. In this step, the system inserts the placeholders of the signal into the appropriate positions of the template to ensure that the code template can correctly express the various attributes, protocols, and permissions of the signal.
[0075] The above-mentioned implementation method of the embodiment of the present application determines the code structure corresponding to the preset project requirements according to the signal attributes, signal protocols and signal permissions corresponding to the preset project requirements, and then adds preset parameter placeholders to the above-mentioned code structure to obtain a preset code template, thereby ensuring that the signal processing code can flexibly respond to various project requirements and obtain an accurate preset code template.
[0076] In order to improve the reliability of the code, in some implementations, the above S105 may include the following steps: S1051 to S1052.
[0077] S1051: Generate corresponding test codes for each of the above project codes according to a preset code template.
[0078] In the specific implementation, we first need to analyze the generated code structure and extract the key points of the test from the preset code template. For example, for signal generation, protocol parsing, permission processing, etc., the system will find these modules from the template and determine their test requirements. Based on the template, the test code framework will generate a preliminary skeleton covering the unit tests of each functional module. The goal of these test cases is to simulate the input signal and verify the output of the system. Finally, the corresponding test code is generated for each of the above project codes.
[0079] As another implementation, the test code verifies that each signal is generated as expected, and the test code ensures that the protocol processing module can correctly parse and package the signal. For example, the CAN protocol may involve the signal ID, data bits, message length, etc. The test code checks whether these meet the protocol standards. If the system requires permission control for access to the signal, the test code will verify whether the access rights of the signal meet expectations to prevent unauthorized access.
[0080] S1052: Run each of the above test codes through the preset bus tool chain software to simulate the signal receiving and sending process and perform signal transmission verification.
[0081] In the specific implementation, before executing the test, the bus tool chain software needs to be configured. It is used to simulate and verify signal transmission under the communication protocol. The configuration of the tool chain includes configuring the protocol used by the target signal and setting the parameters of the signal according to the project requirements, such as signal ID, data length, cycle, transmission rate, etc. Configure the hardware interface or virtual interface used for simulation, such as simulating vehicle networks, industrial control systems and other environments. After the test code is generated, the test code will be imported into the bus tool chain software. These test codes will simulate the generation, transmission and reception process of the signal, and the simulator will execute these test cases to ensure the correctness of the signal. The simulator will simulate the signal transmission process based on the signal generation information provided by the test code. The simulator will receive the signal transmitted from the sender and decode and verify it. The system will compare the received signal with the expected signal to ensure that its data content, format, cycle, etc. are consistent with the expected. The bus tool chain software will parse and process the signal according to the preset protocol. For signals involving permission control, the test code also needs to verify whether the permission is applied correctly. The tool chain will simulate various permission configuration scenarios to ensure that only authorized modules can modify or read specific signals. During the test, the bus tool chain will record the transmission results of all signals, including successful transmission, failure, transmission delay, etc. The test code will be executed repeatedly to simulate different signal inputs, network environments and protocol configurations to ensure that the code can work stably in various situations and perform signal transmission verification.
[0082] The above-mentioned implementation method of the embodiment of the present application generates corresponding test codes for each of the above-mentioned project codes according to a preset code template, and then runs each of the above-mentioned test codes through a preset bus tool chain software to simulate the signal receiving and sending process and perform signal transmission verification, thereby ensuring that the signal transmission, processing and authority control meet the design requirements, avoiding potential errors and loopholes, and ultimately improving the reliability of the code.
[0083] In order to correctly process the signal definition, in some implementations, the above S102 may include the following steps: S1021 to S1023.
[0084] S1021: Use a preset document processing library to parse the signal definition document and perform data format verification.
[0085] In the specific implementation, the signal definition document is usually stored in a specific format. Therefore, you need to select a suitable document parsing library first. Load the signal definition document into memory. The loading method depends on the source of the document, which can be read from a local file, network, database, etc. Perform format verification, document format correctness, and field integrity check to ensure that the signal definition document contains the necessary fields. Perform field type check to ensure that the field data type is correct.
[0086] S1022: When the data format verification fails, generate verification error information.
[0087] In the specific implementation, if the document format does not meet the requirements, an error log is recorded so that the developer can track and fix the problem. The error information can be recorded in a log file. The specific method is to call the log function and write the error information into the log file to obtain the verification error information. After that, the corresponding verification error information can be displayed in the vehicle operating system through this verification error information, and these verification error information can also be sent to the user terminal to prompt the user to verify the error.
[0088] S1023: When the data format verification is successful, a corresponding signal definition class is generated according to the above signal definition document.
[0089] In the specific implementation, when the data format verification is successful, the corresponding signal definition class instance is generated according to the content of the document. First, a class needs to be defined, which will be used to store the properties of each signal. According to each signal information in the signal definition document, an instance of the class is created and stored in a list for subsequent use. For example, if the document contains multiple signals, the system will traverse the document and create an instance for each signal, and generate the corresponding signal definition class according to the above signal definition document. Once the signal class instance is generated, the system can perform subsequent operations on these signals. For example, signals can be used for real-time data transmission, signal value calculation, signal parsing, etc.
[0090] The above-mentioned implementation method of the embodiment of the present application parses the above-mentioned signal definition document by using a preset document processing library to perform data format verification. When the data format verification fails, a verification error message is generated. When the data format verification succeeds, a corresponding signal definition class is generated according to the above-mentioned signal definition document. Each step of the signal definition document from format to instantiation can be completed smoothly, ensuring that the signal definition can be processed correctly.
[0091] In order to improve development efficiency and automation, in some implementations, the above S103 may include the following steps: S1031 to S1033.
[0092] Traverse each of the above signal definition classes and perform the following steps for each of the above signal definition classes:
[0093] S1031: Based on the type of the signal definition class, a corresponding preset code template is obtained. The preset code template is a code structure predefined according to actual requirements.
[0094] In the specific implementation, according to the type or attribute of the signal definition class, a suitable code template is selected from the preset templates. These templates have been predefined during the design and provide different structures for different signal types and requirements. The preset code templates are generally designed in the early stages of software development. They can be fixed code blocks or codes with replaceable parts. The design of the template needs to take into account different signal types, such as integer signals, floating-point signals, Boolean signals, etc. When traversing the signal definition class, the system needs to select a suitable template according to the type of signal and obtain the corresponding preset code template.
[0095] S1032: Extract target parameters in the above signal definition class.
[0096] In the specific implementation, the target parameters required for code generation are extracted from the signal definition class. Each signal class usually contains some important properties for generating a specific code structure. Each signal definition class may contain some useful parameters that can be replaced as variables in the code template.
[0097] S1033: Use the above target parameters to replace the corresponding parameters in the above preset code template to obtain the project code.
[0098] In the specific implementation, after obtaining the preset code template and target parameters, the target parameters are used to replace the placeholders in the template, and finally the code for the project is generated. The preset code template usually contains placeholders, which will be replaced by the target parameters later. The final generated code can be stored in a file or directly passed to the downstream system for further processing. For multiple signals, a corresponding code will be generated for each signal, and finally combined into a complete project code to obtain the project code.
[0099] The above-mentioned implementation method of the embodiment of the present application obtains the corresponding preset code template based on the type of signal definition class, extracts the target parameters in the above-mentioned signal definition class, and then uses the above-mentioned target parameters to replace the corresponding parameters in the above-mentioned preset code template to obtain the project code. It can automatically convert the signal definition into a specific project code, thereby improving development efficiency and automation level.
[0100] In order to improve the efficiency of development and use, in some embodiments, after the above S106, the above method may further include: S107 to S108.
[0101] S107: When the compilation and verification of the above project code are passed, the signal definition class is subjected to signal parsing to obtain a parsing result.
[0102] In the specific implementation, the signal definition class usually contains multiple attributes, which describe various aspects of the signal. Get basic information such as signal name, data type, length, unit, etc. Analyze the correlation between signals. For example, a signal may depend on the state or value of other signals, or there is a calculation relationship between the signal value and other parameters. Verify whether the data type of the signal meets the requirements and convert it as needed. Perform signal analysis on the above signal definition class to obtain the analysis result.
[0103] S108: Generate a description document of the project code according to the analysis result.
[0104] In the specific implementation, once the signal definition class is parsed and the parsing results are obtained, the next step is to generate the project code description document. The generated description document should include the signal list, signal description, signal mapping relationship and signal verification rules, etc., to generate the above project code description document.
[0105] The above-mentioned implementation method of the embodiment of the present application performs signal analysis on the above-mentioned signal definition class to obtain a analysis result when the compilation and verification of the above-mentioned project code are passed, and then generates a description document for the above-mentioned project code according to the above-mentioned analysis result. After compilation and verification, detailed signal analysis results and project description documents can be automatically generated to improve the efficiency of development, maintenance and use.
[0106] As another implementation method of this application, you can refer to Figure 2 The specific process may include the following steps: S201 to S208.
[0107] S201: Modify the signal definition document. The developer manually edits the signal definition document according to new requirements or changes to ensure that all necessary signal properties are correctly recorded and updated.
[0108] S202: Generate project code. Use the document parsing module and signal definition module of the tool to generate corresponding project code for each signal according to the preset code template. This process involves traversing the signal definition class and replacing the parameters in the template with the specific information in the document.
[0109] S203: Compile and generate a code base. Submit the generated code to the compiler, which will compile the code according to the language and framework requirements of the project. This step is to ensure that the code has no syntax errors and meets the technical specifications of the project.
[0110] S204: Determine whether the compilation is successful. Check the compiler output to confirm that there are no compilation errors. If the compilation fails, record the error information and prompt the developer to make corrections.
[0111] S205: Generate test code. Use the test generation module of the tool to generate test code for each signal according to the preset test code template. These test codes will be used to simulate the signal transmission and reception process to verify the validity and accuracy of the signal.
[0112] S206: Signal test. Run the test code and use the tool to simulate the signal receiving and sending process to check whether the signal can be processed correctly. This step is to ensure that the signal can work properly in actual applications.
[0113] S207: Determine whether the test is successful. Check the test results to confirm that all test cases have passed. If the test fails, record the failed test cases and analyze the reasons for correction.
[0114] S208: Generate a description document. Use the document generation module of the tool to generate a corresponding description document for each signal according to a preset description document template. These documents will describe the signal usage and precautions in detail.
[0115] The actual tool consists of a document parsing module 301, a signal definition module 302, a test generation module 303, and a document generation module 304. Figure 3 .
[0116] The core responsibility of the document parsing module is to parse the information definition document. It mainly converts the "signal definition document" into the corresponding internal signal definition class for use by other modules. This module mainly uses the Java open source library to parse the signal definition document, verify the validity of the document and the correctness of the data format, and convert the document data type into the corresponding signal definition class.
[0117] The signal definition document is the key input of the module, which lists in detail many properties of the vehicle signal, such as signal description, signal ID, data type, corresponding message, precision, offset, callback class, etc. In view of the complexity of the signal definition class and the immutability of the object, the design of this class adopts the builder pattern, which provides a more intuitive and easy-to-understand construction process, naturally supports the creation of immutable objects, and has good scalability. During the document parsing process, if a signal definition that cannot be parsed is encountered, the module will record the error and prompt the developer to make corrections to ensure that all signal definitions can be accurately parsed and used in subsequent development processes.
[0118] Signal definition module This module is mainly responsible for generating the required project code for each signal based on the preset Java code template. During the code generation process, the module will traverse the signal definition class previously generated by the document parsing module, generate the corresponding class code for each signal, and perform compilation verification. The preset code template is the core of the project development code, which predefines the code structure based on the actual needs of the project. The parameters in the template are configurable and will be replaced by the specific information in the signal definition class during code generation. Specific templates include templates for signal attributes, signal protocols, signal permissions, etc. During the code generation and compilation process, if you encounter exceptions such as compilation failure, the module will record the error and prompt the developer to make corrections to ensure the accuracy of the generated code.
[0119] The test generation module is mainly responsible for generating signal test code and performing tests. It generates test code for each signal based on the preset Java code template, and tests the signal path to verify the validity and accuracy of the signal. The implementation of the test template is similar to that of the signal definition module, but focuses on the testing aspects of the signal, such as signal uplink test, signal downlink test, etc. When testing the signal path, the module uses the bus tool chain software to simulate the signal transmission and reception process, promptly discovers possible problems in the signal transmission process, and ensures the validity of the signal path.
[0120] The document generation module is responsible for generating the signal usage documentation so that developers and interface users can understand and use these signals. It generates corresponding descriptions for each signal according to the preset description document template and outputs the description document.
[0121] The development tool proposed in this embodiment can automatically generate a large amount of repetitive code through the collaboration between multiple modules, reduce human errors, and improve development efficiency. Developers only need to focus on the accuracy of signal definition documents and business logic implementation, without having to manually write a large amount of templated code. The time-consuming difference between the coding process and manual development is shown in Table 1.
[0122] Table 1
[0123]
[0124] According to the calculation in Table 1, compared with the traditional manual development, when there is only one signal to develop, the efficiency of using the development tool is improved by 14 / 9-1=55.5%. When there are 100 signals to develop, the efficiency of using the development tool is improved by 1025 / 128-1=701%.
[0125] In actual projects, there are hundreds of semaphores involved. In addition, considering the occasional errors caused by long-term repeated development, the time consumption of individual development will be further increased. By using development tools, not only the work efficiency is greatly improved, but also the code standardization can be enhanced.
[0126] Based on the method for generating a code file corresponding to a vehicle signal provided in the above embodiment, the present application also provides a specific implementation of a device for generating a code file corresponding to a vehicle signal. Please refer to the following embodiment.
[0127] See first Figure 4 The device 400 for generating a code file corresponding to a vehicle signal provided in an embodiment of the present application includes the following modules:
[0128] The response module 401 is used to determine an updated signal definition document in response to a user's editing operation on the signal definition document, wherein the signal definition document includes attributes of the vehicle signal.
[0129] The parsing module 402 is used to parse the signal definition document using a preset document processing library to obtain a corresponding signal definition class.
[0130] The generating module 403 is used to generate corresponding project codes for each of the above signal definition classes according to a preset code template.
[0131] The compiling module 404 is used to compile the above project code.
[0132] The test module 405 is used to generate test code when the compilation is successful, and verify the project code through the test code.
[0133] The generating module 403 is further used to generate a code file corresponding to the updated signal definition document when the compilation and verification of the project code are passed.
[0134] As an implementation of the present application, the device 400 for generating a code file corresponding to a vehicle signal further includes:
[0135] The determination module is used to determine the code structure corresponding to the preset project requirements according to the signal attributes, signal protocols and signal permissions corresponding to the preset project requirements.
[0136] Add a module to add preset parameter placeholders to the above code structure to obtain a preset code template.
[0137] As an implementation of the present application, the test module 405 includes:
[0138] The generating unit is used to generate corresponding test codes for the code files corresponding to the vehicle signals for each of the above-mentioned project codes according to the preset code template.
[0139] The simulation unit is used to run each of the above test codes through the preset bus tool chain software, simulate the signal receiving and sending process, and perform signal transmission verification.
[0140] As an implementation of the present application, the above-mentioned parsing module 402 includes:
[0141] The verification unit is used to parse the signal definition document using a preset document processing library to perform data format verification.
[0142] The sending unit is used to generate verification error information when the data format verification fails.
[0143] The generating unit is used to generate a corresponding signal definition class according to the above signal definition document when the data format verification is successful.
[0144] As an implementation of the present application, the generation module 403 includes:
[0145] The acquisition unit is used to acquire the corresponding preset code template based on the type of the signal definition class, and the preset code template is a code structure predefined according to actual needs.
[0146] The extraction unit is used to extract the target parameters in the above signal definition class.
[0147] The replacement unit is used to replace the corresponding parameters in the above preset code template with the above target parameters to obtain the project code.
[0148] As an implementation of the present application, the device 400 for generating a code file corresponding to a vehicle signal further includes:
[0149] The parsing module is used to perform signal parsing on the above signal definition class to obtain a parsing result when the compilation and verification of the above project code are passed.
[0150] The generation module is used to generate a description document of the above project code according to the above analysis results.
[0151] The various modules in the device for generating a code file corresponding to a vehicle signal provided in the embodiment of the present application can implement the various steps in the method for generating a code file corresponding to a vehicle signal and achieve the corresponding effects, which will not be described in detail here for the sake of brevity.
[0152] Figure 5 A schematic diagram of the structure of the code file generation hardware corresponding to the vehicle signal provided in an embodiment of the present application is shown.
[0153] The device for generating a code file corresponding to a vehicle signal may include a processor 501 and a memory 502 storing computer program instructions.
[0154] Specifically, the processor 501 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0155] The memory 502 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 502 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 502 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 502 is a non-volatile solid-state memory.
[0156] The memory may include a read-only memory (ROM), a random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method for generating a code file corresponding to a vehicle signal according to any one embodiment of the present disclosure.
[0157] The processor 501 reads and executes the computer program instructions stored in the memory 502 to implement any one of the code file generation methods corresponding to the vehicle signal in the above embodiments.
[0158] In one example, the device for generating a code file corresponding to a vehicle signal may further include a communication interface 503 and a bus 510. Figure 5 As shown, the processor 501, the memory 502, and the communication interface 503 are connected via a bus 510 and communicate with each other.
[0159] The communication interface 503 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0160] Bus 510 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 510 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0161] In addition, in combination with the method for generating a code file corresponding to a vehicle signal in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, the method for generating a code file corresponding to any one of the vehicle signals in the above embodiment is implemented.
[0162] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed, implements a method for generating a code file corresponding to any one of the vehicle signals in the above embodiments.
[0163] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0164] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0165] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0166] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0167] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A method for generating a code file corresponding to a vehicle signal, characterized in that: The method comprises: In response to a user editing operation on a signal definition document, determining an updated signal definition document, the signal definition document including attributes of a vehicle signal; Parsing the signal definition document using a preset document processing library to obtain a corresponding signal definition class; Generate corresponding project codes for each of the signal definition classes according to a preset code template; Compile the project code; If the compilation is successful, generate test code, and verify the project code through the test code; When the project code is compiled and verified successfully, a code file corresponding to the updated signal definition document is generated.
2. The method for generating a code file corresponding to a vehicle signal according to claim 1, characterized in that: Before generating corresponding project codes for each of the signal definition classes according to the preset code template, the method further includes: Determine the code structure corresponding to the preset project requirements based on the signal attributes, signal protocols and signal permissions corresponding to the preset project requirements; A preset parameter placeholder is added to the code structure to obtain a preset code template.
3. The method for generating a code file corresponding to a vehicle signal according to claim 1, characterized in that: The generating of the test code and verifying the project code by the test code includes: Generate corresponding test codes for each of the project codes according to the preset code template; Each of the test codes is run through the preset bus tool chain software to simulate the signal receiving and sending process and perform signal transmission verification.
4. The method for generating a code file corresponding to a vehicle signal according to claim 1, characterized in that: The using a preset document processing library to parse the signal definition document to obtain a corresponding signal definition class includes: Parsing the signal definition document using a preset document processing library to perform data format verification; In case of data format verification failure, verification error information is generated; When the data format verification is successful, a corresponding signal definition class is generated according to the signal definition document.
5. The method for generating a code file corresponding to a vehicle signal according to claim 1, characterized in that: Generating a corresponding project code for each of the signal definition classes according to a preset code template includes: Traverse each of the signal definition classes and perform the following steps for each of the signal definition classes: Based on the type of the signal definition class, a corresponding preset code template is obtained, where the preset code template is a code structure predefined according to actual needs; Extracting target parameters in the signal definition class; The target parameters are used to replace the corresponding parameters in the preset code template to obtain the project code.
6. The method for generating a code file corresponding to a vehicle signal according to any one of claims 1 to 5, characterized in that: In the case where the project code is compiled and verified, after generating a code file corresponding to the updated signal definition document, the method further includes: When the project code is compiled and verified, performing signal parsing on the signal definition class to obtain a parsing result; Generate a description document of the project code based on the analysis result.
7. A device for generating a code file corresponding to a vehicle signal, characterized in that: The device comprises: a response module, configured to determine an updated signal definition document in response to a user's editing operation on the signal definition document, wherein the signal definition document includes attributes of the vehicle signal; A parsing module, used for parsing the signal definition document using a preset document processing library to obtain a corresponding signal definition class; A generation module, used for generating corresponding project codes for each of the signal definition classes according to a preset code template; A compiling module, used for compiling the project code; The test module is used to generate test code when the compilation is successful, and verify the project code through the test code; The generation module is also used to generate a code file corresponding to the updated signal definition document when the compilation and verification of the project code are passed.
8. A device for generating a code file corresponding to a vehicle signal, characterized in that: The device includes: a processor, and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the method for generating a code file corresponding to a vehicle signal according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method for generating a code file corresponding to a vehicle signal according to any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the method for generating a code file corresponding to a vehicle signal as described in any one of claims 1 to 6.
Citation Information
Cited By
Vehicle message processing method and related device
CN120980157A