Vehicle end software process template generation method, system and device and storage medium
By automatically generating vehicle-side software process templates, the problem of repetitive workload in building process module frameworks and developing common functions in new energy vehicles has been solved, improving software development efficiency and quality and adapting to rapid iteration.
Patent Information
- Application Number
- CN202511394093.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2026-01-13
AI Technical Summary
The software of new energy vehicles is massive, with a large number of processes running on each SOC. The framework construction of process modules and the development of common functions result in a large amount of repetitive work, and the uneven skill levels of developers may introduce quality issues.
The algorithm automatically generates the project directory structure by using process template configuration files, common code files, and preset directories. It then uses the root directory, process template configuration files, and project compilation scripts to generate common basic code and automatically generate the vehicle-side software process template.
It reduces the amount of repetitive work in developing common functions, improves software development efficiency and quality, adapts to the requirements of rapid software iteration, and reduces the dependence on developers to understand common interfaces.
Smart Images

Figure CN121326388A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer software technology, specifically to a method, system, device, and storage medium for generating vehicle-side software process templates. Background Technology
[0002] With the development of the four new trends in new energy vehicles, their functions are becoming increasingly diverse. Consequently, the software running on the system-on-chip (SoC) is also growing larger, with dozens or even hundreds of processes running on each SoC. The framework construction of these process modules and the development of common functions result in a huge amount of repetitive work, thereby reducing software development efficiency. Summary of the Invention
[0003] This invention provides a method, system, device, and storage medium for generating vehicle-side software process templates, aiming to improve the efficiency of vehicle-side software development.
[0004] Firstly, a method for generating a vehicle-side software process template is provided, including:
[0005] Obtain the common code files and process template configuration files;
[0006] The project directory structure is determined based on the process template configuration file, common code files, and preset directory structure algorithm; the project directory structure includes the root directory and the project compilation script.
[0007] The common base code is determined based on the root directory, process template configuration file, project compilation script, and preset code generation algorithm.
[0008] The process template is determined based on the project directory structure and common base code.
[0009] In some embodiments, the project directory structure is determined based on the process template configuration file, common code files, and a preset building algorithm, including:
[0010] Parse the contents of the process template configuration file to obtain configuration information; the configuration information includes the process name in the process template configuration file;
[0011] Creates a root directory named after the process based on the preset root directory creation command;
[0012] The project compilation script is determined based on the public code files, root directory, and configuration information.
[0013] In some embodiments, the project build script includes a common build script and a differentiated build script;
[0014] The project compilation script is determined based on the public code files, root directory, and configuration information, including:
[0015] The common compilation scripts are determined based on the common code files and the root directory;
[0016] The differentiated build scripts are determined based on the common code files and configuration information.
[0017] In some embodiments, determining the common compilation script based on the common code file and the root directory includes:
[0018] Copy the common code files to the first target directory to generate a common compilation script; the first target directory comes from a subdirectory of the root directory or a subdirectory of each level under the subdirectory.
[0019] In some embodiments, the public code file contains interfaces and variables for reserved differentiated functions; the configuration information also includes the compilation platform and compilation options;
[0020] The differentiated build scripts are determined based on the public code files and configuration information, including:
[0021] Modify the interfaces and variables of the reserved differentiated functions according to the configuration information to generate the first differentiated compilation script;
[0022] Alternatively, the key content in the configuration information can be replaced by the first preset keyword, and the replaced content can be placed in the second target directory to generate the second differentiated compilation script;
[0023] Alternatively, depending on the compilation platform and the compilation options, the preset compilation file is copied to the third target directory, and the second preset keyword of the preset compilation file is modified to generate a third differentiated compilation script; wherein the second target directory and the third target directory are both derived from the subdirectories corresponding to the root directory or the subdirectories at various levels under the subdirectories.
[0024] In some embodiments, the project directory structure also includes a standard test directory and a business service code directory;
[0025] The methods for determining the standard test catalog include:
[0026] Create a test directory and add test code to the project build script to generate a standard test directory;
[0027] Methods for determining the business service code directory include:
[0028] Create subdirectories corresponding to the root directory based on the directory structure in the configuration information;
[0029] Create a business service code directory based on the process template configuration file and subdirectories.
[0030] In some embodiments, common base code is determined based on the root directory, process template configuration file, project compilation script, and preset code generation algorithm, including:
[0031] Establish the main loop function and the process initialization function;
[0032] When generating a process template, the code related to the preset process lock is copied to the fourth target directory, and the switch status in the process template configuration file determines whether to add the preset process lock calling code to the process initialization function in order to generate the process lock;
[0033] During compilation, the dependency libraries and header files corresponding to the logs are added to the project compilation script, and when generating the log code, the preset log initialization code is added to the process initialization function to generate the logs;
[0034] During compilation, the dependency libraries and header files corresponding to the communication middleware are added to the project compilation script. In the case of generating communication middleware code, the initialization code of the preset communication middleware is added to the process initialization function according to the process template configuration file to generate communication management.
[0035] When generating a process template, copy the pre-defined service management related code to the fifth target directory and add the pre-defined service management initialization code to the process initialization function to generate service management;
[0036] In the case of compilation, the corresponding dependency libraries and header files for storage are added to the project compilation script, and when generating storage management code, the initialization code for the preset storage is added to the process initialization function to generate storage management;
[0037] In the case of compilation, the corresponding dependency libraries and header files for debugging are added to the project compilation script. When generating process debugging code, the debugging function name and debugging interface registration code are added to the process initialization function according to the process template configuration file to generate process debugging.
[0038] When generating a process template, copy the preset process monitoring code to the sixth target directory, and determine whether to add the preset process monitoring code to the main loop function according to the switch status in the process template configuration file in order to generate process monitoring;
[0039] When generating reserved interface code, insert a standard interface into the reserved interface code to generate the reserved interface.
[0040] Secondly, a system for generating vehicle-side software process templates is also provided, including:
[0041] The acquisition module is used to retrieve public code files and process template configuration files;
[0042] The first determination module is used to determine the project directory structure based on the process template configuration file, common code file and preset directory building algorithm; the project directory structure includes the root directory and project compilation script;
[0043] The second determination module is used to determine the common basic code based on the root directory, process template configuration file, project compilation script and preset code generation algorithm;
[0044] The third module is used to determine the process template based on the project directory structure and common base code.
[0045] Thirdly, an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, it implements the steps in any of the above-described design methods.
[0046] Fourthly, a computer-readable storage medium is also provided, on which a computer program is stored, which is loaded by a processor to perform the steps in any of the above-described methods or design schemes.
[0047] Beneficial Effects: This application provides a method, system, device, and storage medium for generating vehicle-side software process templates. The method includes: obtaining a common code file and a process template configuration file; determining a project directory structure based on the process template configuration file, the common code file, and a preset directory structure algorithm; the project directory structure includes a root directory and a project compilation script; determining common basic code based on the root directory, the process template configuration file, the project compilation script, and the preset code generation algorithm; and determining a process template based on the project directory structure and the common basic code. The method provided in this application automatically generates a project directory structure using the process template configuration file, the common code file, and the preset directory structure algorithm, and generates common basic code using the root directory, the process template configuration file, the project compilation script, and the preset code generation algorithm. This automatically generates the process template for the vehicle-side software, reducing repetitive work caused by developing common functions and improving software development efficiency. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1This is a flowchart of a method for generating a vehicle-side software process template provided in an embodiment of this application;
[0050] Figure 2 This is a schematic diagram of a vehicle-side software process template provided in an embodiment of this application;
[0051] Figure 3 This is a block diagram illustrating the operational principle of a business code directory provided in this application embodiment;
[0052] Figure 4 This is a schematic diagram of the principle structure of a vehicle-side software process template generation system provided in the embodiments of this application. Detailed Implementation
[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0054] In the description of this application, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0055] "A and / or B" includes the following three combinations: A only, B only, and a combination of A and B.
[0056] The use of "applies to" or "configured to" in this application implies open and inclusive language, which does not exclude the applicability to or configuration to devices performing additional tasks or steps. Additionally, the use of "based on" implies openness and inclusivity, because processes, steps, calculations, or other actions "based on" one or more of the stated conditions or values may in practice be based on additional conditions or values beyond those stated.
[0057] In this application, the term "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use this application. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that this application can be made without using these specific details. In other instances, well-known structures and processes are not described in detail to avoid obscuring the description of this application with unnecessary detail. Therefore, this application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0058] The applicant's research revealed that with the development of the four new trends in new energy vehicles (electrification, connectivity, intelligence, and sharing), the functions on new energy vehicles are increasing, and the scale of the software running on the System-on-Chips (SoC) is also growing larger, with dozens or even hundreds of processes running on each SoC. The framework construction of these process modules and the development of common functions have resulted in a huge amount of repetitive work. At the same time, due to the varying skill levels of developers, the development of these common functions may differ, and may even introduce quality problems.
[0059] New energy vehicles are increasingly equipped with more and more software functions and running more and more software processes. Each process module requires the construction of a code framework, and may also involve the development of common functions such as communication and logging. This repetitive development work not only wastes time and manpower, but may also introduce quality problems due to the skill level of the developers.
[0060] The relevant technology adopts the following approach: encapsulate some common functions into basic libraries, such as infrastructure libraries and communication libraries, for upper-layer software to call.
[0061] However, while encapsulating common software into libraries can address some issues caused by divergent changes and improve quality and development efficiency to a certain extent, it still has many shortcomings for the overall system. For example, encapsulating common libraries does not improve the code framework; code directory structure, project compilation, etc., still require developers to write manually. Any difference in compilation parameters or directory structure can affect continuous integration (CI) compilation (a software development practice that aims to detect integration errors early by frequently integrating code changes into a shared repository and automating builds and tests), failing to meet the requirements of rapid software iteration. Furthermore, although common code has been extracted, using and integrating library files into processes requires a certain amount of work. Also, developers need to understand the use of these interfaces, and the use of common interfaces still depends on each developer's software skill level; improper use can introduce serious problems. Finally, if each module relies on the development of other modules to integrate this common code, if external common libraries or CI processes change, all processes may need to modify their code to adapt.
[0062] In view of this, embodiments of this application provide a method, system, device, and storage medium for generating vehicle-side software process templates. This application automatically generates the project directory structure through a process template configuration file, common code files, and a preset directory building algorithm, and generates common basic code through the root directory, process template configuration file, project compilation script, and preset code generation algorithm, thereby automatically generating process templates for vehicle-side software, reducing repetitive workload caused by the development of common functions, and improving software development efficiency.
[0063] Figure 1 This is a flowchart illustrating a method for generating a vehicle-side software process template, as provided in an embodiment of this application. This method is applicable to improving the efficiency of vehicle-side software development in vehicle control systems. The method can be executed by a vehicle-side software process template generation system, which can be implemented in software and / or hardware. This system can be configured in the tool script, processor, or controller of the vehicle control system. The tool script (hereinafter referred to as "tool") is a collection of software; the entry point can be a Python script, a shell script, or other (e.g., a Windows executable file). By executing the tool entry script, the tool automatically generates the vehicle-side software process template. Please refer to [link to relevant documentation]. Figure 1 The method includes the following steps:
[0064] Step 110: Obtain the common code file and process template configuration file.
[0065] The process template configuration file is the process template definition file, used by the process template generation tool to generate process templates. Its format can be XML, JSON, or YAML, and it contains basic project configuration information. This basic configuration information includes, but is not limited to, the following: module name (i.e., the process name associated with the process template), related library files that the process depends on, standardized project directory structure, on / off switches for required functions and their corresponding module dependencies and other differentiated configurations, supported compilation platforms and related compilation options (or parameters), and the service names, dependent libraries, threads, and processed messages that the services need to be implemented.
[0066] The process name associated with the process template is used to generate the project directory based on the process name in the script. The related compilation script also needs to add the process name to generate a binary program with the same name as the process.
[0067] Among them, the relevant library files that the process depends on are used to automatically add the relevant library files and their corresponding header file paths to the project compilation script when the process template is generated. During compilation, the corresponding release program is automatically downloaded from the artifact repository for compilation and linking.
[0068] This includes the compilation platforms that need to be supported, as well as compilation options (or parameters) related to those platforms, such as toolchain paths, versions, special function macros, and dependency libraries, which will be automatically added to the project compilation script when the process template is generated.
[0069] The common code files are embedded in the tool scripts. These files contain common compilation implementations that provide common functionalities shared by all modules. Examples include CMake for linking common libraries and a shell interface for uploading and downloading dependency libraries.
[0070] Step 120: Determine the project directory structure based on the process template configuration file, common code files, and preset directory building algorithm.
[0071] The project directory structure includes the root directory and the project compilation scripts.
[0072] The construction of the project directory structure includes building a standard code repository directory, building project compilation scripts related to project compilation, building a standardized test directory (or test platform), and building a directory reserved for business code.
[0073] The process of setting up the code repository directory is as follows: First, create a complete directory named after the module as the root directory. Then, create the root directory according to the configuration file. For example, src is used to put the code, inc is used to put the header files, script is used to put the scripts, etc.
[0074] In some embodiments, determining the project directory structure based on the process template configuration file, common code file, and preset building algorithm includes: parsing the contents of the process template configuration file to obtain configuration information; the configuration information includes the process name in the process template configuration file; creating a root directory named after the process name according to a preset root directory creation command; and determining the project compilation script based on the common code file, the root directory, and the configuration information.
[0075] The configuration information includes the configuration path, header file, compilation platform, compilation options, and process name in the process template configuration file.
[0076] The default command for creating the root directory is, for example, the Python command `mkdir`. `mkdir` is an interface in the Python `os` library used to create directories. For example, executing `os.mkdir(r"E:\example")` will create a directory named `example` under drive E.
[0077] Specifically, the tool parses the contents of the process template configuration file to obtain configuration information. It then creates a root directory named after the process name in the configuration information using a preset root directory creation command. Finally, the tool builds the project compilation script based on the built-in common code files, the root directory, and the configuration information. There is only one root directory, which can contain multiple subdirectories, and each subdirectory can contain subdirectories at various levels. The specific number of subdirectories and the data within each subdirectory can be set according to actual needs; no specific limitations are set here.
[0078] Figure 2 This is a schematic diagram of a vehicle-side software process template provided in an embodiment of this application. For example, the locations of the root directory and project compilation scripts in the process template can be found in the provided diagram. Figure 2 The corresponding code repository directory and project compilation scripts are set up in the project directory structure.
[0079] In some embodiments, the project compilation script includes a common compilation script and a differentiated compilation script; determining the project compilation script based on the common code file, the root directory, and configuration information includes: determining the common compilation script based on the common code file and the root directory; and determining the differentiated compilation script based on the common code file and configuration information.
[0080] Specifically, the engineering compilation scripts provided in this application embodiment can provide both compilation scripts for common functions and compilation scripts for differences, thereby expanding the application scenarios and scope of the vehicle-side software process template, meeting various needs, and improving the flexibility and applicability of software development.
[0081] In some embodiments, determining a common compilation script based on a common code file and a root directory includes: copying the common code file to a first target directory to generate a common compilation script; wherein the first target directory comes from a subdirectory corresponding to the root directory or subdirectories at various levels under the subdirectory.
[0082] The first target directory is a subdirectory or a subdirectory of the specified root directory. The specific settings can be configured according to the actual situation, and no specific restrictions are made here.
[0083] Specifically, simply copying the common code files to the corresponding subdirectory or subdirectories under the specified root directory will generate a common compilation script, enabling common functions that are universal across all modules. This reduces the development effort required by business developers for common functions, decreases workload, and improves the efficiency of vehicle-side software development.
[0084] In some embodiments, the public code file contains reserved interfaces and variables for differentiated functions; the configuration information also includes the compilation platform and compilation options; determining the differentiated compilation script based on the public code file and configuration information includes: modifying the reserved interfaces and variables for differentiated functions according to the configuration information to generate a first differentiated compilation script; or, replacing key content in the configuration information with a first preset keyword and placing the replaced content in a second target directory to generate a second differentiated compilation script; or, copying a preset compilation file to a third target directory according to the compilation platform and compilation options, and modifying the second preset keyword of the preset compilation file to generate a third differentiated compilation script; wherein the second target directory and the third target directory both come from subdirectories corresponding to the root directory or subdirectories at various levels under the subdirectory.
[0085] The second and third target directories are both subdirectories or subdirectories at various levels under a specific root directory. The specific settings can be made according to the actual situation, and no specific restrictions are made here.
[0086] The first preset keywords include the process name, the path configured in the configuration file, and header files, etc. These can be set according to actual needs and are not specifically limited here. Key content in the configuration information includes, for example, the name of the compilation target, dependent libraries, and header file paths, etc., which can also be set according to actual needs and are not specifically limited here.
[0087] The second preset keyword is a keyword such as compilation option, which can be set according to the actual situation, and no specific limitation is made here.
[0088] The default compilation file is a standard compiler-related file that is built into the tool script based on the compilation platform, compilation options, and other information.
[0089] Specifically, the tool has built-in common compilation implementation code, which implements common functions that are common to all modules, such as CMake for linking common libraries and shell interfaces for uploading and downloading dependency libraries. These common code files can be directly copied to the specified directory.
[0090] There are multiple ways to implement differentiated functions, such as different dependencies of different processes on external library files, as detailed below:
[0091] The first implementation method is as follows: The common code file of the tool reserves the interface calling logic of standard differentiated functions. The interface can be a specific command interface, function, environment variable, etc. When the tool generates the process template, it modifies the contents of these interfaces and variables in the common code file according to the configuration information. When the compilation script is executed, the compilation script will call these interfaces or variables, thereby realizing differentiated functions.
[0092] The second implementation method involves using templates to represent different functionalities. Keyword substitution is then used during the build process (when the Python script is executed, a directory is created, and a compilation script is generated within the script; the template is copied to the specified directory, and then keywords are replaced). This replaces key content in the configuration information. For example, the name of the compilation target is replaced with the process name, and the paths to dependency libraries and header files are replaced with those configured in the configuration file. The replaced content is then placed in a subdirectory or sub-directories within a specific root directory, thus achieving differentiated functionality.
[0093] The third implementation method is as follows: Based on the compilation platform, compilation options, etc., the tool copies the built-in compilation files related to the standard compiler to the corresponding directory, and then modifies the compilation options and other keywords. The compilation script can specify the corresponding compilation platform by including the relevant scripts, thereby achieving differentiated functions.
[0094] In some embodiments, the project directory structure further includes a standard test directory and a business service code directory; wherein, the method for determining the standard test directory includes: creating a test directory and adding test code to the project compilation script to generate the standard test directory; the method for determining the business service code directory includes: creating a subdirectory corresponding to the root directory according to the directory structure in the configuration information; and creating the business service code directory according to the process template configuration file and the subdirectory.
[0095] Subdirectories include, for example, the src directory (used to store source code) and the inc directory (used to store header files). The specific settings can be configured according to the actual situation, and no specific restrictions are made here.
[0096] Specifically, the tool automatically creates a test directory to store test code and adds relevant compilation commands to the project compilation script to link specific test library files (such as the gtest library), test case execution code, etc., to generate a standard test directory. The tool automatically creates a business service code directory in the root directory (e.g., the src directory) based on the process template configuration file, adds relevant compilation files, and inserts the compilation of the business service code directory into the project compilation script to generate the business service code directory. The locations of the standard test directory and the business service code directory in the process template are shown in [link to relevant documentation]. Figure 2 The corresponding test framework and business service code directories (reserved) are set up in the project directory.
[0097] Step 130: Determine the common basic code based on the root directory, process template configuration file, project compilation script, and preset code generation algorithm.
[0098] The common foundation code consists of the code for the required common basic functions and the configuration parameters related to these functions. Business modules can choose the basic functions they need. The common foundation code includes process locks, log settings, communication management, service frame management (i.e., service management), data persistence (i.e., storage management), process monitoring, process debugging, other reserved standardized interfaces, and other functions.
[0099] The process lock is implemented by adding process lock code to the entry function to prevent the process from starting repeatedly.
[0100] The logging setting is configured to generate log initialization code, which is called at startup to complete log-related initialization.
[0101] Communication management involves generating initialization code for the communication middleware, which is automatically invoked upon process startup to create the communication network. The communication middleware is a communication component that provides standardized communication interfaces to upper-layer business software code (i.e., business software code using the communication middleware), such as connection establishment, sending, receiving, connection termination, and connection status acquisition. It supports various communication methods, including Data Distribution Service (DDS), Transmission Control Protocol (TCP), User Datagram Protocol (UDP), shared memory, message passing (MP), persistent publish-subscribe (PPS), inter-core communication, and universal asynchronous receiver-transmitter (UART). Communication methods, links, link identifiers, and other strategies such as caching and reliability can be defined through configuration files. The code simply loads the specified configuration file and calls the initialization interface. During runtime, the business logic can find the corresponding connection and send / receive data based on the connection identifier. Alternatively, if services are configured, the communication middleware can automatically distribute messages to the corresponding service threads for processing based on message type. The communication middleware links are defined through configuration files, which include the communication links required by the process, the communication method of each link, the relevant communication strategies, the identifier of the communication link, and the data callback interface of the communication link.
[0102] The service framework features integrated service management via process templates. The services that business modules need to implement are specified in the process template configuration file. Each service includes its name, number of processing threads, message identifiers (IDs), and the interfaces it needs to process. If the process template starts service management, the service framework dynamically loads (using library file names and interface names, without link relationships) the standardized interfaces in the business service library program according to the configuration information to start the business service. Upon receiving a message, communication management can distribute it to the corresponding business service for processing based on its type, avoiding manual code intervention. Service threads can also periodically execute scheduled tasks. In other words, service threads can also be used as timers.
[0103] Data persistence is achieved through the process template automatically generating storage management-related code and completing the initialization process directly at startup. Business services can directly use the storage management-related interfaces.
[0104] The process monitoring feature includes: automatically generating standardized process monitoring programs from process templates, such as thread timeout monitoring, main thread keep-alive detection, and anomaly detection alarms. During program execution, relevant alarms are automatically detected and reported.
[0105] Among them, process debugging is: process templates generate standardized debugging function code, supporting unified management of debugging functions, such as printing process status and executing debugging commands.
[0106] Other reserved standardized interfaces include: for example, a custom Init interface, which allows the business to complete specific initialization behaviors. If the business has an implementation, the corresponding initialization interface will be automatically called when the process starts.
[0107] In addition, the common base code also includes other functions. For example, if there are other common base functions, they can be added directly to the process template, and then regenerated to be added to all processes in batches.
[0108] It should be noted that the order in which various public functions are called can be determined by the configuration of the business module to determine the order in which basic functions are implemented. The specific order can be set according to the actual situation, and no specific restrictions are made here.
[0109] In some embodiments, common basic code is determined based on the root directory, process template configuration file, project compilation script, and preset code generation algorithm, including: establishing the main loop function and process initialization function; when generating the process template, copying the preset process lock-related code to the fourth target directory, and determining whether to add the preset process lock call code to the process initialization function according to the switch status in the process template configuration file to generate the process lock; when generating the compilation, adding the dependency library and header file corresponding to the log to the project compilation script, and adding the preset log initialization code to the process initialization function when generating the log code to generate the log; when generating the compilation, adding the dependency library and header file corresponding to the communication middleware to the project compilation script, and adding the preset communication middleware initialization code to the process initialization function according to the process template configuration file when generating the communication middleware code to generate communication management; when generating the process template, adding the preset service management-related code... The code is copied to the fifth target directory, and the initialization code for the preset service management is added to the process initialization function to generate service management. During compilation, the corresponding storage dependency libraries and header files are added to the project compilation script, and the initialization code for the preset storage is added to the process initialization function when generating storage management code to generate storage management. During compilation, the corresponding debugging dependency libraries and header files are added to the project compilation script, and the debugging function name and debugging interface registration code are added to the process initialization function according to the process template configuration file when generating process debugging code to generate process debugging. When generating process template, the preset process monitoring related code is copied to the sixth target directory, and the switch status in the process template configuration file determines whether to add the preset process monitoring related code to the main loop function to generate process monitoring. When generating reserved interface code, the standard interface is inserted into the reserved interface code to generate reserved interface.
[0110] Among them, the fourth target directory, the fifth target directory, and the sixth target directory all come from the subdirectories corresponding to the root directory or the subdirectories at all levels under the subdirectories, which are the subdirectories corresponding to the specified or particular root directory or the subdirectories at all levels under the subdirectories.
[0111] The preset process lock related code is the implementation code related to process locks. The preset service management related code is the implementation code related to the service management framework. The preset process monitoring related code is the implementation code related to process monitoring.
[0112] Specifically, after creating the project directory structure and compilation scripts, the execution tool's entry script can perform the following functions: The tool parses the process template configuration file to determine whether a feature needs to be enabled, whether there are additional dependency libraries, and whether there are feature-specific configurations (such as log levels or configuration files required for communication middleware). Whether a feature needs to be enabled, whether there are additional dependency libraries, and whether there are feature-specific configurations are all defined in the process template configuration file. For example, enabling a feature has a dedicated toggle setting. There may be many dependency libraries, resulting in multiple configurations. Specific configurations are parsed according to the feature; for example, logging requires retrieving the level configuration from the configuration file. The tool has built-in initialization main function interface code, which the tool will add to the specified directory. It also establishes the main loop function and the process initialization function.
[0113] The tool includes built-in implementation code related to process locks. When generating a process template, it copies the preset process lock-related code to a specific root directory (i.e., the fourth target directory). Based on the on / off status in the process template configuration file, it determines whether to add the preset process lock calling code to the process initialization function to generate the process lock. Specifically, the implementation of adding the preset process lock calling code to the process initialization function based on the on / off status in the process template configuration file works as follows: for example, if the script parses the process lock configuration in the configuration file and the on / off status is "on," it will add code to the process initialization function. Because the process lock code is fixed, it can be directly concatenated and written into the function, or keyword replacement can be used. For the location of the process lock in the process template, please refer to [link to relevant documentation]. Figure 2 The process lock shown.
[0114] The log file is an externally integrated library. During the tool's compilation process, the corresponding dependency libraries and header files need to be added to the project's compilation script. Simultaneously, when generating the logging functionality initialization code (i.e., the process initialization and common function initialization code), the preset log initialization code is added to the process initialization function to generate the log. This preset log initialization code includes log levels, caching, and configuration files. For the location of the log in the process template, please refer to [link / reference needed]. Figure 2 The log settings are shown.
[0115] The communication middleware is an external dependency library. During the tool's compilation process, the corresponding dependency library and header files are added to the project's compilation script. Simultaneously, when generating the communication function initialization code (i.e., process initialization and common function initialization code), the preset communication middleware initialization code is added to the process initialization function based on the process template configuration file to generate communication management. The process template configuration file can specify the communication configuration file, callback interfaces, etc. For the location of communication management in the process template, please refer to [link to relevant documentation]. Figure 2 The communication management shown.
[0116] The tool includes built-in implementation code related to the service management framework. When generating the process template, it copies the preset service management code to a specific directory (i.e., the fifth target directory) and adds the preset service management initialization code to the process initialization function to generate the service management. For details on the location of the service management within the process template, please refer to [link to relevant documentation]. Figure 2 The service management shown.
[0117] Storage management is an externally integrated library. During the tool's compilation process, the corresponding dependency libraries and header files need to be added to the project's compilation script. Simultaneously, when generating the storage management function initialization code (i.e., the process initialization and common function initialization code), the preset storage initialization code is added to the process initialization function to generate storage management. This preset storage initialization code includes storage path configuration, etc. For the location of storage management in the process template, please refer to [link / reference]. Figure 2 The persistence shown.
[0118] Process debugging is an externally integrated library. During the tool's compilation process, the corresponding dependency libraries and header files need to be added to the project's compilation script. Simultaneously, when generating the debugging function initialization code (i.e., the process initialization and public function initialization code), the debugging function name and debug interface registration code are added to the process initialization function according to the process template configuration file to generate the process debugger. For the location of the process debugger in the process template, please refer to [link / reference needed]. Figure 2 The process debugging shown.
[0119] The tool includes built-in code for process monitoring. When generating a process template, it copies the preset process monitoring code to a specific directory (the sixth target directory). Based on the on / off status in the process template configuration file, it determines whether to add the preset process monitoring code to the main loop function to generate process monitoring. Specifically, the implementation of adding the preset process monitoring code to the main loop function based on the on / off status in the process template configuration file works as follows: for example, if the script parses the process lock configuration in the configuration file and the status is "on," it adds code to the process initialization function. This code can be directly concatenated and written into the function, or built-in code keywords can be replaced. For the location of process monitoring in the process template, please refer to [link to relevant documentation]. Figure 2 The process monitoring shown.
[0120] The tool inserts standard interfaces into the code, such as the `Init` initialization interface. Business code can choose to implement these interfaces or not. If implemented, the business interface is called; otherwise, an empty interface is called. For the location of reserved interfaces in the process template, please refer to [link / reference needed]. Figure 2 The reserved standardized interface is shown.
[0121] It should be noted that since the common function code is relatively fixed, its code generation method can also be as follows: First, a tool can read the process template configuration file, concatenate the code based on the configuration file, and then directly write the concatenated code string to a specific location in the code file. Second, the tool can use built-in code, where all code directly reads the process template configuration file and selects the function to call based on it; during code generation, the process template configuration file and the code are copied to a specific directory. Third, the code can be written as a template, and during code generation, keywords are directly replaced according to the process template configuration file and copied to a specific directory. It should also be noted that the order in which the code is entered can be specified by configuration, and thus the initialization order of the corresponding functions can be configured.
[0122] Step 140: Determine the process template based on the project directory structure and common basic code.
[0123] For example, the structure of a process template is as follows: Figure 2 As shown, a process template can be generated with a single click using a process template generation tool (i.e., a tool script) and a process template definition file. The process template includes project directory setup and generation of common basic code.
[0124] It is understandable that the method for generating vehicle-side software process templates provided in this application automatically generates the project directory structure through process template configuration files, common code files, and a preset directory building algorithm. It also generates common basic code through the root directory, process template configuration files, project compilation scripts, and a preset code generation algorithm. Thus, a process template is automatically generated with a single click using a tool script. The process template includes a root directory, a test directory, project compilation scripts, and some common basic function code. Business modules only need to write their own business code in specific directories to build the complete process code project, ensuring a high degree of consistency between the entire project directory and compilation, which well adapts to the requirements of rapid software iteration. Simultaneously, common code is automatically generated with a single click, allowing software developers to focus on their own business development. This reduces the investment of business developers in developing common basic functions, lowers the developer's understanding of common basic function interfaces, reduces repetitive workload caused by common function development, and improves software development efficiency. Furthermore, focusing on common basic function initialization also improves software quality. Additionally, the normalization of common code enhances the overall quality level of the software.
[0125] Figure 3 This is a block diagram illustrating the operational principle of a business code directory provided in this application embodiment. After the process template is generated, the specific implementation process of the actual business executing the business program according to the process template is as follows: the actual business adds the actual business service code to the specified directory, for example, adding the actual business service code to the business service code directory reserved in the process template. There can be multiple services, and different services have different directories. The actual business service code only needs to implement the standardized interface, initialization interface, etc., of the service defined in the configuration file, which will be automatically called during process execution. For example, the actual business executes the project compilation script created by the process template. The project compilation script will generate a process binary file named after the process from the code outside the business service code directory reserved in the process template, while the contents of the business service code directory reserved in the process template will generate the corresponding business service library file. Figure 3As shown, the process binary file, business service library file, along with dependent libraries and their required configuration files, constitute a complete process program. For example, the project compilation script performs a series of operations, and the code generated by the process template ultimately produces a process binary executable program with the process name. The actual business code added to the business service code directory reserved in the process template is compiled into a business service library plugin with the name specified in the configuration file. Together with the dependent libraries and related configuration files, these components form a complete process program that can run on the system. Once this content is deployed on the system, executing the process binary executable program with the process name will allow the program to run normally. The actual business services will be automatically invoked, and received messages will be automatically distributed to the corresponding services for processing according to the process template configuration file.
[0126] In addition, during code execution, the process template will automatically complete the initialization and invocation of common basic functions, such as log configuration and communication network creation, and load the standardized interfaces implemented by the business service library in a dynamic manner to initialize or run business services.
[0127] The process template automatically completes the initialization and invocation of common basic functions as follows: During the compilation and linking process, the process binary executable program named after the process has already integrated the code for initializing and invoking common basic functions (e.g., process locks, logging, communication management, service management, storage management, process debugging, process monitoring, etc.). When the compiled binary program is deployed to the environment for execution, the process binary will complete the corresponding initialization and invocation, such as initializing the log level, calling the process lock interface to prevent repeated process starts during initialization, calling the storage management module's initialization interface to perform initialization, and periodically calling the process monitoring interface to monitor the process during runtime.
[0128] The process template loads standardized interfaces implemented by the business service library in a dynamic manner. The specific implementation process of initializing or running the business service is as follows: the business service library plugin needs to implement the standardized interfaces provided by the service framework (i.e., service management), such as the Create interface to create a service. The service includes, but is not limited to, interfaces such as Initialize (Init) to perform initialization operations, Service (Svc) to perform periodic tasks, and Receive Command (RecvCmd) to receive messages.
[0129] The process template tool has a built-in service framework code. The service framework dynamically loads the specified service library plugins according to the configured name, dynamically calls its Create interface to create the service handle obtained by the service, registers the service to the service framework, and then calls standardized service interfaces, such as calling the service Init to complete the initialization operation, periodically calling the service Svc interface to execute periodic tasks, and calling RecvCmd to distribute the messages specified in the configuration to the corresponding services, etc.
[0130] The process binary uses dynamic load open (dlopen) / dynamic load symbol (dlsym) (Portable Operating System Interface (POSIX) system) or load library (LoadLibrary) / get process address (GetProcAddress) (Windows platform) plus library name / interface name to load the plugin dynamic library and the interface in the plugin service, instead of directly linking the service plugin to the business service library during compilation. As a result, there is no dependency between the process binary and the business service library plugin, thus achieving decoupling between the process template and the business library.
[0131] In summary, this application's embodiments generate process template code through automated tool scripts and process template configuration files. The process template includes a standardized directory structure, project editing scripts, and a reserved code directory for business logic. The project compilation script generated by the process template automatically links the relevant dependency libraries from the download link and generates binary files with specified names according to the process template configuration file. The process template automatically selects and generates a series of common basic function codes according to the process template configuration file, including but not limited to process locks, logging, communication management, service management, process monitoring, storage management, and process debugging. It also supports calling reserved standardized interfaces, such as initialization (after business logic implementation, personalized functions for business code can be supported). The main function of the process template is directly integrated into the generated binary executable file (process program) during compilation and placed in the specified directory. The business logic code is placed in the specified reserved code directory, and the process template's project compilation script automatically compiles the business logic code into a binary library. The binary executable program (process program) of the process template does not directly depend on the binary library generated by the business code. Instead, it loads the service library interface directly during runtime in a dynamic loading manner (loaded by the library name and the name of the standard abstract interface), thereby decoupling the process template and the business library.
[0132] Therefore, the method for generating vehicle-side software process templates provided in this application has the following advantages: First, by using process templates, the standardization of directories and compilation projects is achieved, adapting to the requirements of rapid compilation and iteration of the codebase. Second, common basic functions are uniformly integrated, and problems or updates can be uniformly modified, avoiding the problems introduced by divergent modifications. Third, since a portion of the code can be automated, the workload of project setup and software development is greatly reduced. Fourth, the barrier to entry for business developers to use common basic components is lowered, reducing their focus on common components and allowing them to concentrate on their own business development. Fifth, business services are integrated into the code in the form of plugins, decoupled from the framework itself; extending plugins only requires modifying the configuration, making the extension of business services more flexible.
[0133] Figure 4 This is a schematic diagram illustrating the principle structure of a vehicle-side software process template generation system provided in this application embodiment. This application embodiment also provides a vehicle-side software process template generation system; please refer to [link / reference]. Figure 4 The vehicle-side software process template generation system 100 includes: an acquisition module 101 for acquiring a common code file and a process template configuration file; a first determination module 102 for determining the project directory structure based on the process template configuration file, the common code file, and a preset directory construction algorithm; the project directory structure includes a root directory and a project compilation script; a second determination module 103 for determining common basic code based on the root directory, the process template configuration file, the project compilation script, and the preset code generation algorithm; and a third determination module 104 for determining the process template based on the project directory structure and the common basic code.
[0134] The technical solution of this application embodiment provides a system for generating vehicle-side software process templates. It automatically generates the project directory structure through process template configuration files, common code files, and a preset directory building algorithm. It also generates common basic code through the root directory, process template configuration files, project compilation scripts, and a preset code generation algorithm, thereby automatically generating process templates for vehicle-side software, reducing repetitive workload caused by the development of common functions, and improving software development efficiency.
[0135] In some embodiments, the first determining module 102 is further configured to: parse the contents of the process template configuration file to obtain configuration information; the configuration information includes the process name of the process template configuration file;
[0136] Creates a root directory named after the process based on the preset root directory creation command;
[0137] The project compilation script is determined based on the public code files, root directory, and configuration information.
[0138] In some embodiments, the project compilation script includes a common compilation script and a differentiated compilation script; the first determining module 102 is further configured to: determine the common compilation script based on the common code file and the root directory; and determine the differentiated compilation script based on the common code file and configuration information.
[0139] In some embodiments, the first determining module 102 is further configured to: copy the common code file to the first target directory to generate a common compilation script; wherein the first target directory comes from the subdirectory corresponding to the root directory or the subdirectories at all levels under the subdirectory.
[0140] In some embodiments, the public code file contains interfaces and variables for reserved differentiated functions; the configuration information also includes the compilation platform and compilation options;
[0141] The first determining module 102 is further configured to: modify the interfaces and variables of the reserved differentiated functions according to the configuration information to generate a first differentiated compilation script; or, replace the key content in the configuration information with a first preset keyword and place the replaced content in the second target directory to generate a second differentiated compilation script; or, copy the preset compilation file to the third target directory according to the compilation platform and the compilation options, and modify the second preset keyword of the preset compilation file to generate a third differentiated compilation script; wherein the second target directory and the third target directory both come from the subdirectories corresponding to the root directory or the subdirectories at all levels under the subdirectories.
[0142] In some embodiments, the project directory structure further includes a standard test directory and a business service code directory; the first determining module 102 is further configured to: create a test directory and add test code to the project compilation script to generate a standard test directory; create a subdirectory corresponding to the root directory according to the directory structure in the configuration information; and create a business service code directory according to the process template configuration file and the subdirectory.
[0143] In some embodiments, the second determining module 103 is further configured to:
[0144] Establish the main loop function and the process initialization function;
[0145] When generating a process template, the code related to the preset process lock is copied to the fourth target directory, and the switch status in the process template configuration file determines whether to add the preset process lock calling code to the process initialization function in order to generate the process lock;
[0146] During compilation, the dependency libraries and header files corresponding to the logs are added to the project compilation script, and when generating the log code, the preset log initialization code is added to the process initialization function to generate the logs;
[0147] During compilation, the dependency libraries and header files corresponding to the communication middleware are added to the project compilation script. When generating the communication middleware code, the initialization code of the preset communication middleware is added to the process initialization function according to the process template configuration file to generate communication management.
[0148] When generating the process template, copy the preset service management related code to the fifth target directory and add the preset service management initialization code to the process initialization function to generate service management;
[0149] During compilation, the corresponding dependency libraries and header files for storage are added to the project compilation script, and when generating storage management code, the initialization code for the preset storage is added to the process initialization function to generate storage management;
[0150] During compilation, the corresponding dependency libraries and header files for debugging are added to the project compilation script. When generating process debugging code, the debugging function name and debugging interface registration code are added to the process initialization function according to the process template configuration file to generate process debugging.
[0151] When generating the process template, the preset process monitoring related code is copied to the sixth target directory, and the switch status in the process template configuration file determines whether to add the preset process monitoring related code to the main loop function in order to generate process monitoring;
[0152] When generating the reserved interface code, a standard interface is inserted into the reserved interface code to generate the reserved interface.
[0153] This embodiment also provides an electronic device, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, it implements the method for generating the vehicle-side software process template of any of the above embodiments.
[0154] This embodiment also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to execute the arrangement in any of the methods described above.
[0155] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0156] The foregoing has provided a detailed description of a method, system, device, and storage medium for generating vehicle-side software process templates according to embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for generating a vehicle-side software process template, characterized in that, include: Obtain the common code files and process template configuration files; The project directory structure is determined based on the process template configuration file, the common code file, and the preset directory construction algorithm; the project directory structure includes a root directory and project compilation scripts. The common basic code is determined based on the root directory, the process template configuration file, the project compilation script, and the preset code generation algorithm; The process template is determined based on the project directory structure and the common base code.
2. The method for generating a vehicle-side software process template according to claim 1, characterized in that, The step of determining the project directory structure based on the process template configuration file, the common code file, and the preset building algorithm includes: The contents of the process template configuration file are parsed to obtain configuration information; the configuration information includes the process name in the process template configuration file. Create the root directory named after the process name according to the preset root directory creation command; The project compilation script is determined based on the public code file, the root directory, and the configuration information.
3. The method for generating a vehicle-side software process template according to claim 2, characterized in that, The project compilation scripts include common compilation scripts and differentiated compilation scripts; The step of determining the project compilation script based on the public code file, the root directory, and the configuration information includes: The common compilation script is determined based on the common code file and the root directory; The differentiated compilation script is determined based on the public code file and the configuration information.
4. The method for generating a vehicle-side software process template according to claim 3, characterized in that, The step of determining the common compilation script based on the common code file and the root directory includes: The common code file is copied to the first target directory to generate the common compilation script; wherein the first target directory comes from the subdirectory corresponding to the root directory or the subdirectories at all levels under the subdirectory.
5. The method for generating a vehicle-side software process template according to claim 3, characterized in that, The public code file contains interfaces and variables for reserved differentiated functions; the configuration information also includes the compilation platform and compilation options. The step of determining the differentiated compilation script based on the public code file and the configuration information includes: Modify the interfaces and variables of the reserved differentiated functions according to the configuration information to generate the first differentiated compilation script; Alternatively, the key content in the configuration information can be replaced with a first preset keyword, and the replaced content can be placed in a second target directory to generate a second differentiated compilation script; Alternatively, based on the compilation platform and the compilation options, a preset compilation file is copied to a third target directory, and the second preset keyword of the preset compilation file is modified to generate a third differentiated compilation script; wherein the second target directory and the third target directory both come from the subdirectory corresponding to the root directory or the subdirectories at various levels under the subdirectory.
6. The method for generating a vehicle-side software process template according to claim 2, characterized in that, The project directory structure also includes a standard test directory and a business service code directory; The method for determining the test catalog of the standard includes: Create the test directory and add test code to the project compilation script to generate a standard test directory; The method for determining the business service code directory includes: Create the subdirectory corresponding to the root directory according to the directory structure in the configuration information; The business service code directory is created based on the process template configuration file and the subdirectories.
7. The method for generating a vehicle-side software process template according to claim 1, characterized in that, The step of determining the common base code based on the root directory, the process template configuration file, the project compilation script, and the preset code generation algorithm includes: Establish the main loop function and the process initialization function; When generating the process template, the preset process lock related code is copied to the fourth target directory, and the switch status in the process template configuration file is used to determine whether to add the preset process lock calling code to the process initialization function in order to generate the process lock; During compilation, the dependency libraries and header files corresponding to the logs are added to the project compilation script, and when generating the log code, the preset log initialization code is added to the process initialization function to generate the logs; During compilation, the dependency libraries and header files corresponding to the communication middleware are added to the project compilation script. When generating communication middleware code, the initialization code of the preset communication middleware is added to the process initialization function according to the process template configuration file to generate communication management. When the process template is generated, the preset service management related code is copied to the fifth target directory, and the preset service management initialization code is added to the process initialization function to generate service management; In the case of compilation, the corresponding dependency libraries and header files for storage are added to the project compilation script, and when generating storage management code, the preset storage initialization code is added to the process initialization function to generate storage management; In the case of compilation, the corresponding dependency libraries and header files for debugging are added to the project compilation script. When generating process debugging code, the debugging function name and debugging interface registration code are added to the process initialization function according to the process template configuration file to generate process debugging. When the process template is generated, the preset process monitoring related code is copied to the sixth target directory, and the switch status in the process template configuration file is used to determine whether to add the preset process monitoring related code to the main loop function in order to generate process monitoring; When generating reserved interface code, a standard interface is inserted into the reserved interface code to generate the reserved interface.
8. A system for generating vehicle-side software process templates, characterized in that, include: The acquisition module is used to retrieve public code files and process template configuration files; The first determining module is used to determine the project directory structure based on the process template configuration file, the common code file, and the preset directory building algorithm; the project directory structure includes a root directory and project compilation scripts. The second determining module is used to determine common basic code based on the root directory, the process template configuration file, the project compilation script, and the preset code generation algorithm. The third determining module is used to determine the process template based on the project directory structure and the common basic code.
9. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, it implements the method for generating a vehicle-side software process template as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to perform the steps in the method for generating the vehicle-side software process template as described in any one of claims 1-7.