Code generation method and device, equipment, storage medium and vehicle

By generating dynamic code corresponding to user configuration, the problem of code redundancy in the prior art is solved, and the implementation efficiency and user experience of user configuration functions are improved.

CN119225789APending Publication Date: 2024-12-31BEIJING CO WHEELS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310778603.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-28
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The prior art relies on commercial software when generating dynamic code, resulting in code redundancy, which reduces the implementation efficiency and user experience of user configuration functions.

Method used

By obtaining multiple configuration data of the BswM module of the basic software mode manager, generating an index corresponding to each configuration data, creating an array of configuration data types, saving the configuration data into the array, and generating dynamic code corresponding to user configuration.

Benefits of technology

Ensure that the generated code only contains the functions required by the user, improves the implementation efficiency and user experience of user configuration functions, and reduces dependence on commercial software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119225789A_ABST
    Figure CN119225789A_ABST
Patent Text Reader

Abstract

The invention discloses a code generation method and device, equipment, a storage medium and a vehicle. The method comprises the steps that multiple pieces of configuration data corresponding to a basic software mode manager BswM module are obtained, each piece of configuration data corresponds to one configuration data type, and each configuration data type corresponds to at least one piece of configuration data; based on the position of each piece of configuration data in the multiple pieces of configuration data, generating an index corresponding to each piece of configuration data to obtain a first configuration file; creating arrays respectively corresponding to the plurality of configuration data types; storing the configuration data in an array corresponding to the configuration data to obtain a second configuration file; and determining codes in the first configuration file and codes in the second configuration file as dynamic codes corresponding to the BswM module. According to the code generation method provided by the embodiment of the invention, the codes which can be generated are codes corresponding to user configuration, so that the use experience of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular, relates to a code generation method, device, equipment, storage medium and vehicle. Background Art

[0002] The Basic Software Mode Manager (BswM) is a basic software module in the AUTomotive Open System Architecture (AUTOSAR) architecture. The BswM module provides an interface to the application software upward and is decoupled from the specific hardware downward. The overall function of the BswM module is to perform serialization operations on each basic software module based on the specific input of the basic software module or application under the condition of meeting certain rules. In order to realize the above functions of the BswM module, it is necessary to generate code corresponding to the function. Among them, the code usually includes static code (fixed) and dynamic code (user configuration).

[0003] In the prior art, code generation strongly relies on existing commercial software. However, in the process of generating dynamic code, commercial software usually directly generates full configuration code in order to meet its versatility, and may generate code that is irrelevant to user configuration, resulting in functional redundancy. As a result, the efficiency of implementing functions corresponding to user configuration is reduced. Summary of the invention

[0004] The embodiments of the present application provide a code generation method, apparatus, device, storage medium and vehicle, and the codes that can be generated are all codes corresponding to the user configuration, thereby improving the efficiency of implementing the functions corresponding to the user configuration and improving the user experience.

[0005] In a first aspect, an embodiment of the present application provides a code generation method, the method comprising:

[0006] Acquire multiple configuration data corresponding to the basic software mode manager BswM module, each of the configuration data corresponds to a configuration data type, and each of the configuration data types corresponds to at least one of the configuration data;

[0007] Based on the position of each configuration data in the plurality of configuration data, generate an index corresponding to each configuration data, and obtain a first configuration file;

[0008] Create arrays corresponding to a plurality of the configuration data types respectively;

[0009] Saving the configuration data into an array corresponding to the configuration data to obtain a second configuration file;

[0010] The code in the first configuration file and the code in the second configuration file are determined as dynamic codes corresponding to the BswM module.

[0011] In a possible implementation, the second configuration file includes a first configuration sub-file and a second configuration sub-file, and the step of saving the configuration data into an array corresponding to the configuration data to obtain the second configuration file includes:

[0012] When the data type of the configuration data is a first configuration data type, the configuration data is saved in a first array corresponding to the configuration data to obtain a first configuration subfile, wherein the first configuration data type includes any one of a mode request, an operation list, and a rule;

[0013] In a case where the data type of the configuration data is a second configuration data type, generating a code corresponding to the configuration data, wherein the second configuration data type includes any one of a logical expression and an operation;

[0014] The code corresponding to the configuration data is saved in a second array corresponding to the configuration data to obtain a second configuration sub-file.

[0015] In a possible implementation, the step of saving the configuration data into a first array corresponding to the configuration data to obtain a first configuration subfile includes:

[0016] Saving the configuration data into a first array corresponding to the configuration data to obtain a first initial configuration sub-file;

[0017] The first target configuration data is defined in the first initial configuration subfile to obtain a first configuration subfile, wherein the first target configuration data is the configuration data of the target basic software module corresponding to the dynamic code, and the target basic software module is the remaining basic software modules except the BswM module.

[0018] In a possible implementation, the step of saving the code corresponding to the configuration data into a second array corresponding to the configuration data to obtain a second configuration subfile includes:

[0019] Saving the code corresponding to the configuration data into a second array corresponding to the configuration data to obtain a second initial configuration sub-file;

[0020] A mode request function is defined in the second initial configuration subfile to obtain a second configuration subfile, wherein the mode request function is used to provide a calling mode to the remaining basic software modules except the BswM module.

[0021] In a possible implementation, before generating an index corresponding to each of the configuration data based on a position of each of the configuration data in the plurality of configuration data and obtaining the first configuration file, the method further includes:

[0022] Converting the configuration data into second target configuration data having a target type language and a target data type, wherein the target type language is an object-oriented, interpreted programming language, and the target data type is a data type including a key-value pair;

[0023] The second target configuration data is passed into a target template, where the target template is a code generation template constructed based on the target type language, and both the first configuration file and the second configuration file are generated based on the target template.

[0024] In a possible implementation manner, the transferring the second target configuration data into the target template includes:

[0025] Verifying the second target configuration data to obtain a verification result;

[0026] When the verification result is that the verification passes, the second target configuration data is transferred into the target template.

[0027] In a possible implementation, the array includes a rule array, an operation list array, and an operation array. After obtaining the dynamic code corresponding to the BswM module, the method further includes:

[0028] Traversing the rule array in the dynamic code;

[0029] For each rule data in the rule array, arbitrate the logical expression in the rule data to obtain an arbitration result corresponding to each rule data;

[0030] Accessing the operation list data corresponding to the arbitration result in the operation list array through the operation list index in the rule data;

[0031] The operation data in the operation array is accessed through the operation index in the operation list data to implement the function corresponding to the dynamic code.

[0032] In a second aspect, an embodiment of the present application provides a code generation device, the device comprising:

[0033] An acquisition module, used for acquiring a plurality of configuration data corresponding to the basic software mode manager BswM module, each of the configuration data corresponds to a configuration data type, and each of the configuration data types corresponds to at least one of the configuration data;

[0034] A generating module, configured to generate an index corresponding to each of the configuration data based on a position of each of the configuration data in the plurality of configuration data, to obtain a first configuration file;

[0035] A creation module, used to create arrays corresponding to a plurality of the configuration data types respectively;

[0036] A saving module, used for saving the configuration data into an array corresponding to the configuration data to obtain a second configuration file;

[0037] A determination module is used to determine the code in the first configuration file and the code in the second configuration file as dynamic codes corresponding to the BswM module.

[0038] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions;

[0039] When the processor executes the computer program instructions, the processor implements any possible implementation method of the first aspect described above.

[0040] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implements a method in any possible implementation method of the first aspect described above.

[0041] In a fifth aspect, an embodiment of the present application provides a vehicle, the vehicle comprising at least one of the following:

[0042] A code generating device as in any one of the embodiments of the second aspect;

[0043] An electronic device as in any one of the embodiments of the third aspect;

[0044] A computer-readable storage medium as in any embodiment of the fourth aspect.

[0045] The code generation method, device, equipment, storage medium and vehicle of the embodiment of the present application generate indexes corresponding to each configuration data based on the position of each configuration data in multiple configuration data to obtain a first configuration file, and create arrays corresponding to multiple configuration data types, save the configuration data to the array corresponding to the configuration data, and obtain a second configuration file, which can ensure that the first configuration file and the second configuration file only include codes corresponding to the user configuration. In this way, by determining the code in the first configuration file and the code in the second configuration file as dynamic codes corresponding to the BswM module, it can be ensured that the generated codes are all codes corresponding to the user configuration. Therefore, it can be ensured that all functions implemented based on dynamic codes are functions required by users, that is, it can improve the efficiency of implementing functions corresponding to user configurations and improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0047] Figure 1 is a schematic diagram of the overall function of a BswM module provided in an embodiment of the present application;

[0048] Figure 2 It is a schematic diagram of the execution logic of a BswM function provided in an embodiment of the present application;

[0049] Figure 3 It is a flowchart of a code generation method provided in an embodiment of the present application;

[0050] Figure 4 It is a flowchart of another code generation method provided in an embodiment of the present application;

[0051] Figure 5 It is a structural schematic diagram of a code generation device provided in an embodiment of the present application;

[0052] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0054] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.

[0055] It should be noted that, in this article, relational terms such as "first" and "second" 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 term "comprises" or any other variant thereof is 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 sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0056] In addition, in the embodiments of the present application, the definitions of abbreviations and key terms may be as follows.

[0057] Eclipse: Eclipse is an open source, Java-based extensible development platform. In itself, it is just a framework and a set of services for building a development environment through plug-in components.

[0058] Java: Java is a programming language that is specifically designed for the distributed environment of the Internet. Java has a "form and feel" similar to the C++ language, but it is easier to use than the C++ language and adopts a completely "object-oriented" approach to programming.

[0059] Python: Python is an object-oriented, interpreted programming language. Python syntax and dynamic typing, as well as the nature of an interpreted language, make it a programming language for writing scripts and rapidly developing applications on most platforms.

[0060] Jinja2: Jinja2 is a modern, designer-friendly Python template language modeled after Django templates. It is fast and widely used.

[0061] XML: Extensible Markup Language (XML), a subset of the standard generalized markup language, can be used to mark data and define data types. It is a source language that allows users to define their own markup languages.

[0062] ARXML: The full name is "AUTOSAR XML". This standard serializes AUTOSAR models into rules described by AUTOSAR XML, providing support for interoperability between AUTOSAR tools.

[0063] As described in the background technology section, the overall function of the BswM module is to perform serial operations on each basic software module under the condition that certain rules are met according to the specific input of the basic software module or application. Figure 1 Specifically, the BswM module has the following three significant features:

[0064] 1. Input is a mode request or mode indication from a basic software module or application;

[0065] 2. Certain rules need to be met when executing mode requests or mode instructions;

[0066] 3. Implement serialization operations on each module by calling the functions of the basic software module or user-defined functions.

[0067] The above three features all need to be implemented through configuration. Users can configure different mode requests, set different rules, and set a list of operations to be performed when the rules are met and / or not met. Different specific operations can also be configured in the operation list.

[0068] In order to realize the above functions of the BswM module, it is necessary to generate codes corresponding to the functions. At present, in the existing solutions provided by other companies in the industry, the function implementation mainly consists of two parts: static code (fixed) and dynamic code (user configuration). However, the generation of these two parts of the code is strongly dependent on the development software provided by other companies. The software is expensive and the core technology is monopolized by overseas companies. In addition, in the existing solutions provided by other companies in the industry, there are many invalid generated codes and the requirements of some functions cannot be perfectly realized. The code logic is complex and difficult to analyze, the functions are redundant, and the implementation consumes too many resources and does not meet the requirements of the vehicle operating system. Furthermore, in the existing solutions provided by other companies in the industry, the generation of dynamic code is based on the Eclipse framework. Because the Eclipse framework uses too many resources based on Java, the code generation process takes too long, affecting the user experience and the software development efficiency of the developer.

[0069] Specifically, the code generation logic provided by other solutions is to directly generate full configuration code without considering the user's current configuration, including all functions of the BswM module and other basic software modules or configuration information of other modules. Since in the current configuration, the BswM module may only interact with a few basic software modules, the information of other modules does not need to be generated. Therefore, most of the codes generated in the existing solutions are redundant codes.

[0070] In this way, in order to reduce the dependence on software from other companies in the industry, improve the user experience and the software development efficiency of developers, and reduce the development costs of developers, this application innovatively designs the structure of the BswM module configuration code on the premise of complying with the official AUTOSAR specifications, reduces redundant configuration code, and improves the readability, scalability and maintainability of the code. In addition, the code generation process of this application is based on Python and jinja2 template technology, with simple logic and low resource consumption, which optimizes the user experience and reduces the learning cost of developers.

[0071] Specifically, in order to realize the functions of the BswM module, corresponding to the structure of the BswM module configuration code, such as Figure 2 As shown, the execution logic of the BswM function provided in the embodiment of the present application can be implemented by multiple components. Among them, multiple components may include: a mode request array, a condition array, a logical expression data, a rule array, an operation list array, and an operation array. The mode request array can save the mode request values ​​of each basic software module or application software; the condition array can save different conditions, each condition can correspond to a mode request, and the condition can determine whether the mode request value is equal to / not equal to the preset value; the logical expression array can save different logical expressions, and each logical expression can include multiple conditions plus different logical operators; the operation array can save different operations, and the operation can be a function provided by other basic software modules or a user-defined function; the operation list array can save different operation lists, and the operation list can include different operations, thereby completing the definition of serialized operations; the rule array may include a logical expression and an operation list, each rule may correspond to a logical expression, and contain an operation list executed when the logical expression is correct and / or an operation list executed when it is wrong.

[0072] As an example, Figure 2 As shown, the implementation process of the BswM core function may include: if expression 1 satisfies rule 1, operation list 1 may be executed; if expression 1 does not satisfy rule 1, operation list 2 may be executed. Among them, operation list 1 may include operation 1, and operation list 2 may include operation 2 and operation i. In addition, expression 1 may include request 1 satisfying condition 1, and request 2 satisfying condition 2.

[0073] Based on this, in order to solve the problems of the prior art, the embodiments of the present application provide a code generation method, apparatus, device, storage medium and vehicle.

[0074] The following first introduces the code generation method provided in the embodiment of the present application.

[0075] Figure 3 FIG. 1 is a flow chart of a code generation method provided by an embodiment of the present application. Figure 3 As shown, the code generation method provided in the embodiment of the present application includes the following steps:

[0076] S310, acquiring multiple configuration data corresponding to the basic software mode manager BswM module, each configuration data corresponds to a configuration data type, and each configuration data type corresponds to at least one configuration data;

[0077] S320, based on the position of each configuration data in the multiple configuration data, generate an index corresponding to each configuration data, and obtain a first configuration file;

[0078] S330, creating arrays corresponding to multiple configuration data types respectively;

[0079] S340, saving the configuration data into an array corresponding to the configuration data to obtain a second configuration file;

[0080] S350: Determine the code in the first configuration file and the code in the second configuration file as dynamic codes corresponding to the BswM module.

[0081] The code generation method of the embodiment of the present application generates an index corresponding to each configuration data based on the position of each configuration data in multiple configuration data, obtains a first configuration file, and creates arrays corresponding to multiple configuration data types, saves the configuration data to the array corresponding to the configuration data, and obtains a second configuration file, which can ensure that the first configuration file and the second configuration file only include codes corresponding to the user configuration. In this way, by determining the code in the first configuration file and the code in the second configuration file as dynamic codes corresponding to the BswM module, it can be ensured that the generated codes are all codes corresponding to the user configuration. Therefore, it can be ensured that all functions implemented based on dynamic codes are functions required by users, that is, it can improve the implementation efficiency of functions corresponding to user configurations and improve the user experience.

[0082] The specific implementation methods of the above steps are introduced below.

[0083] In some embodiments, in S310, the configuration data may include mode request data, condition data, logical expression data, operation data, operation list data and rule data. Among them, the mode request data may include the request source and the initial value of the request mode. The condition data may include the path of the corresponding mode request, the preset value (the value of the target mode), and the operator (equal to / not equal to). The condition data may be, for example, request 1 to be equal to / not equal to the value of the target mode. The logical expression data may include the path of the conditions used and the conditional operator (including and, or). The operation data may include functions that may be called by each basic software module or user-defined functions. The operation list data may include the path of the operations used by the operation list. The rule data may include the path of the logical expression used, the path of the operation list executed when the logical expression is established, and the path of the operation list executed when the logical expression is not established. In addition, the configuration data type corresponding to the mode request data may be a mode request, the configuration data type corresponding to the condition data may be a condition, the configuration data type corresponding to the logical expression data may be a logical expression, the configuration data type corresponding to the operation data may be an operation, the configuration data type corresponding to the operation list data may be an operation list, and the configuration data type corresponding to the rule data may be a rule. Based on this, configuration data types can include mode requests, conditions, logical expressions, actions, action lists, and rules.

[0084] As an example, multiple configuration data may be stored in the target configuration file, each configuration data may correspond to a configuration data type, and each configuration data type may correspond to at least one configuration data. The number of configuration data corresponding to different configuration data types may be the same or different, and is not limited here. Among them, there may be m configuration data, and there may be n configuration data types, and m may not be less than n. Both m and n are positive integers.

[0085] In addition, the target configuration file can be an ARXML configuration file configured by the user.

[0086] As an example, obtaining multiple configuration data corresponding to the basic software mode manager BswM module may specifically be obtaining a target configuration file corresponding to the BswM module. Obtaining the target configuration file corresponding to the BswM module may specifically include:

[0087] Get the initial ARXML configuration file corresponding to the BswM module;

[0088] Receiving a first input from a user for modifying an initial ARXML configuration file;

[0089] In response to the first input, the initial ARXML configuration file is updated to obtain an ARXML configuration file, ie, a target configuration file.

[0090] Here, the module configuration tool can first read the initial ARXML configuration file corresponding to the BswM module. After reading the initial ARXML configuration file, the initial ARXML configuration file can be parsed to obtain configuration data, and the configuration data can be displayed in the interface of the module configuration tool so that the user can modify the configuration data according to needs. The first input used by the user to modify the initial ARXML configuration file can include any one of adding configuration data, deleting configuration data, and modifying configuration data. In the process of the user modifying the configuration data, the module configuration tool can synchronously save the user configuration and synchronously update the initial ARXML configuration file to obtain the target configuration file. That is, the target configuration file can be the final ARXML configuration file after the user configures, or it can be any ARXML configuration file in the user configuration process, which is not limited here.

[0091] In some embodiments, in S320, the first configuration file may be a BswM_Cfg.h file. The first configuration file may define indexes of mode request data, logical expression data, rule data, operation data, and operation list data. That is, the first configuration file may include a correspondence between configuration data and indexes. Based on the execution logic of the BswM function as described above, access to different components may be achieved by accessing arrays. Therefore, different indexes may be defined for members in different components (configuration data belonging to different configuration data types) to access different members in different components through index values. Since the condition is only an intermediate product between the mode request and the logical expression, it may not participate in the implementation of the overall logic of the BswM function, and therefore, the index of the condition data may not be defined.

[0092] In addition, the position of each configuration data in the plurality of configuration data may be the position of each configuration data in the target configuration file.

[0093] In some embodiments, in S330, based on the execution logic of the BswM function as described above, in order to access different components by accessing arrays, arrays corresponding to n configuration data types may be created to obtain n arrays. The n arrays may include a mode request array, a condition array, a logic expression array, an operation array, an operation list array, and a rule array.

[0094] Based on this, in some embodiments, in S340, after the array is created, the configuration data can be saved in the array corresponding to the configuration data to obtain the second configuration file. That is, the second configuration file may include n arrays storing configuration data. Since there is a one-to-one correspondence between the array and the configuration data type, and a one-to-many relationship between the configuration data type and the configuration data, multiple configuration data can be saved in each array. Among them, the configuration data can be a specific numerical value corresponding to the configuration data, or a code corresponding to the configuration data, which is not limited here. In addition, the second configuration file can be a single file, or a combination of multiple files, which is not limited here. If the second configuration file is a combination of multiple files, the second configuration file may include a first configuration sub-file and a second configuration sub-file.

[0095] Based on this, in order to realize the function corresponding to the dynamic code, in some embodiments, the above S340 may specifically include:

[0096] When the data type of the configuration data is a first configuration data type, the configuration data is saved in a first array corresponding to the configuration data to obtain a first configuration subfile, wherein the first configuration data type includes any one of a mode request, an operation list, and a rule;

[0097] In the case where the data type of the configuration data is a second configuration data type, generating code corresponding to the configuration data, the second configuration data type including any one of a logical expression and an operation;

[0098] The code corresponding to the configuration data is saved in a second array corresponding to the configuration data to obtain a second configuration sub-file.

[0099] Here, the first configuration subfile may be a BswM_PBcfg.c file. The first configuration subfile may define the specific configuration of the BswM module, such as the initial value of the mode request, the specific logical expressions and operation lists contained in the rules, the specific operations contained in different operation lists, and the configuration of other basic software modules required for different operations. That is, the first configuration subfile may include the configuration of the BswM module itself, as well as the configuration for interaction between the BswM module and other Bsw modules.

[0100] As an example, since the access mode request, operation list, and rule actually use indexes, if the data type of the configuration data is any one of the mode request, operation list, and rule, the configuration data can be directly saved in the first array corresponding to the configuration data. Based on this, the first array in the first configuration subfile can include, for example, a rule array: [Rule 1, Rule 2, ..., Rule 10]. Among them, Rule 1, Rule 2, and Rule 10 can be rule data. In C language, the index of Rule 1 can be 0, the index of Rule 2 can be 1, and the index of Rule 10 can be 9. Therefore, if you want to access the specific data of Rule 10, you can access the specific data with index 9 in the rule array. In addition, since the BswM_Cfg.h file has been generated, for example, the specific data in the rule data can include operation list data and logical expression data, and can also include indexes corresponding to the operation list data, and indexes corresponding to the logical expression data, which are not limited here. For another example, the operation list data can include operation data, and can also include indexes corresponding to the operation data, which are not limited here.

[0101] Based on this, in some embodiments, the above-mentioned saving the configuration data into the first array corresponding to the configuration data to obtain the first configuration sub-file may specifically include:

[0102] Saving the configuration data into a first array corresponding to the configuration data to obtain a first initial configuration sub-file;

[0103] The first target configuration data is defined in the first initial configuration subfile to obtain the first configuration subfile, wherein the first target configuration data is the configuration data of the target basic software module corresponding to the dynamic code, and the target basic software module is the remaining basic software modules except the BswM module.

[0104] Here, the BswM module can be a mode management module in the Basic Software Layer (Bsw). In addition, Bsw can also include other basic software modules such as Data Communication Module (DCM), Non-volatile Memory Module (NvM), Communication Manager Module (ComM). The target basic software module can include any one of DCM, NvM, and ComM. Based on this, the first initial configuration subfile can only include the configuration of the BswM module itself. After obtaining the first initial configuration subfile, the configuration for interactive use between the BswM module and other Bsw modules, that is, the first target configuration data, can be defined in the first initial configuration subfile to obtain a complete first configuration subfile. Among them, the first target configuration data can specifically be data used to complete the operation corresponding to the operation data. For example, if the first initial configuration subfile includes operation data related to communication, in order to complete the operation related to communication, the signal data and communication channel data of the communication module can be defined in the first initial configuration subfile.

[0105] In addition, the second configuration subfile may be a BswM_Cfg.c file. Since the logic expression, operation (function definition), and mode request function (function definition) all need to be implemented through specific codes, the second configuration subfile may include specific implementation codes of the logic expression and operation, as well as the definition of the mode request function.

[0106] As an example, when the data type of the configuration data is the second configuration data type, a code corresponding to the configuration data may be generated first, and then the code corresponding to the configuration data may be saved in a second array corresponding to the configuration data.

[0107] Based on this, in some embodiments, the above-mentioned saving of the code corresponding to the configuration data into the second array corresponding to the configuration data to obtain the second configuration sub-file may specifically include:

[0108] The code corresponding to the configuration data is saved in a second array corresponding to the configuration data to obtain a second initial configuration sub-file;

[0109] A mode request function is defined in the second initial configuration subfile to obtain a second configuration subfile, and the mode request function is used to provide a calling mode to the remaining basic software modules except the BswM module.

[0110] Here, the second initial configuration subfile may only include the specific implementation code of the logical expression and the operation. After obtaining the second initial configuration subfile, a mode request function may be defined in the second initial configuration subfile to obtain the second configuration subfile. The mode request may be implemented through the mode request function.

[0111] In this way, by defining the first target configuration data in the first configuration subfile and defining the mode request function in the second configuration subfile, the function corresponding to the dynamic code can be implemented.

[0112] In some embodiments, in S350, since the first configuration file may be a BswM_Cfg.h file, the second configuration file may include a first configuration sub-file and a second configuration sub-file, the first configuration sub-file may be a BswM_PBcfg.c file, and the second configuration sub-file may be a BswM_Cfg.c file, therefore, the dynamic code corresponding to the BswM module may include the code in the BswM_Cfg.h file, the BswM_PBcfg.c file, and the BswM_Cfg.c file.

[0113] After obtaining the three files BswM_Cfg.h, BswM_PBcfg.c and BswM_Cfg.c, the three files can be used together to implement the functions corresponding to the BswM module. Among them, BswM_PBcfg.c and BswM_Cfg.c can access the elements in their respective arrays according to the indexes of different array elements defined by BswM_Cfg.h. On the other hand, since BswM_Cfg.c contains specific definitions of various operations, in order to implement specific operations, BswM_Cfg.c can also access the configuration data of other basic software modules in BswM_PBcfg.c.

[0114] Based on this, in order to improve the efficiency of function implementation and enhance user experience, in some embodiments, after the above S350, the following steps may also be included:

[0115] Traverse the array of rules in the dynamic code;

[0116] For each rule data in the rule array, the logical expression in the rule data is arbitrated to obtain the arbitration result corresponding to each rule data;

[0117] Access the operation list data corresponding to the arbitration result in the operation list array through the operation list index in the rule data;

[0118] The operation data in the operation array is accessed through the operation index in the operation list data to implement the function corresponding to the dynamic code.

[0119] Here, the operation list index may be an index corresponding to the operation list data, and the operation index may be an index corresponding to the operation data. As described above, the rule data may include the operation list index, and the operation list data may include the operation index.

[0120] As an example, the BswM module can obtain all configuration data during the initialization process, that is, the configuration data in BswM_Cfg.h, BswM_PBcfg.c and BswM_Cfg.c. After obtaining the configuration data, the system can call the BswM_MainFunction function cyclically during operation to traverse the rule array. In the process of traversing the rule array, for each rule data in the rule array, the logical expression in the rule data can be arbitrated to obtain the arbitration result (established / not established) corresponding to each rule data. The operation list data that needs to be accessed can be determined from the arbitration result in the rule data. The specific value corresponding to the operation list data in the operation list array can be accessed through the operation list index. Through the operation index saved in the operation list data, the operation data in the operation array can be accessed to perform the corresponding operation, thereby realizing the function corresponding to the dynamic code.

[0121] In this way, data access between different components through the index of array elements can improve the efficiency of function implementation and enhance user experience.

[0122] In other configuration and code generation solutions at this stage, the Java-based Eclipse framework is used for implementation. When the tool loads the configuration and the user modifies the configuration, the tool will often freeze and take too long. When generating code, the Eclipse framework consumes a lot of resources, resulting in a long time to generate code. In this way, in order to reduce resource consumption, increase the speed of code generation, and further enhance the user experience, in some embodiments, before the above S320, it can also include:

[0123] Converting the configuration data into second target configuration data having a target type language and a target data type, the target type language being an object-oriented, interpreted programming language, and the target data type being a data type including a key-value pair;

[0124] The second target configuration data is passed into the target template, where the target template is a code generation template built based on the target type language, and both the first configuration file and the second configuration file are generated based on the target template.

[0125] Here, the second target configuration data may be a Python dictionary, and the target template may be a jinja2 template.

[0126] As an example, after passing the Python dictionary into the jinja2 template, the jinja2 template can be used to generate an index corresponding to each configuration data based on the position of the configuration data in the target configuration file to obtain a first configuration file; the jinja2 template can be used to create arrays corresponding to n configuration data types to obtain n arrays; and the jinja2 template can be used to save the configuration data to the array corresponding to the configuration data to obtain a second configuration file.

[0127] In addition, in order to ensure the normal progress of code generation, in some embodiments, the above-mentioned transferring the second target configuration data into the target template may specifically include:

[0128] Verifying the second target configuration data to obtain a verification result;

[0129] When the verification result is that the verification passes, the second target configuration data is transferred to the target template.

[0130] Here, the verification is passed when both the second target configuration data and the configuration data meet the preset rules. If the verification result is that the verification fails, it may be that any one of the second target configuration data and the configuration data does not meet the preset rules. In this way, by reporting an error, the user can be prompted that the configuration data is wrong and / or the second target configuration data is wrong, so that the configuration data error and / or the second target configuration data can be corrected, thereby ensuring the normal progress of code generation.

[0131] In this way, using Python+jinja2 for configuration verification and code generation can reduce resource consumption, increase code generation speed, and further enhance user experience.

[0132] Based on this, in order to better describe the entire solution, some specific examples are given based on the above embodiments.

[0133] For example, Figure 4 A code generation method provided in an embodiment of the present application may include the following steps:

[0134] S41, read the initial ARXML configuration file;

[0135] S42, configuration analysis;

[0136] S43, construct BswM configuration items;

[0137] S44, generating a target configuration file corresponding to the BswM configuration item;

[0138] S45, converting the target configuration file into a Python dictionary;

[0139] S46, configuration verification;

[0140] S47. Generate dynamic code.

[0141] Here, after the configuration is parsed, the configuration data obtained by the analysis can be displayed on the interface so that the user can modify the configuration data. According to the user's modification of the configuration data, the BswM configuration item can be constructed, and then the target configuration file corresponding to the BswM configuration item can be generated. Among them, each time the target configuration file is generated, the configuration data corresponding to the target configuration file can be parsed and displayed once. Each time the BswM configuration item is constructed, the target configuration file corresponding to the BswM configuration item can be generated once. In addition, each time the target configuration file is generated, the target configuration file can be converted into a Python dictionary and the configuration can be verified. In this way, if the verification passes, if the user clicks the "Generate Code" button, the dynamic code can be generated. After the dynamic code is generated, combined with the static code, the BswM configuration code can be obtained.

[0142] Therefore, since the configuration code generated by the embodiment of the present application is entirely from the user configuration, the generated code removes additional information that the user does not care about, thereby reducing redundant code and facilitating user use and subsequent iterative development by developers. In addition, the embodiment of the present application implements a new BswM module configuration method, which redesigns the structure of the module configuration file according to the module function. Developers and users can more easily understand the working principle of the module in combination with the BswM module source code, and can more accurately implement the desired functions by modifying the configuration file, thereby improving the user experience.

[0143] Based on the code generation method provided in the above embodiment, the present application also provides a specific implementation of a code generation device. Please refer to the following embodiment.

[0144] like Figure 5 As shown, the code generation device 500 provided in the embodiment of the present application includes the following modules:

[0145] The acquisition module 510 is used to acquire multiple configuration data corresponding to the basic software mode manager BswM module, each configuration data corresponds to a configuration data type, and each configuration data type corresponds to at least one configuration data;

[0146] A generating module 520, configured to generate an index corresponding to each configuration data based on a position of each configuration data in the plurality of configuration data, to obtain a first configuration file;

[0147] A creation module 530, used to create arrays corresponding to a plurality of configuration data types respectively;

[0148] A saving module 540 is used to save the configuration data into an array corresponding to the configuration data to obtain a second configuration file;

[0149] The determination module 550 is used to determine the code in the first configuration file and the code in the second configuration file as dynamic codes corresponding to the BswM module.

[0150] The code generation device 500 is described in detail below, as shown below:

[0151] In some embodiments, the second configuration file includes a first configuration sub-file and a second configuration sub-file. Based on this, the saving module 540 may specifically include:

[0152] A first saving submodule is used to save the configuration data into a first array corresponding to the configuration data to obtain a first configuration subfile when the data type of the configuration data is a first configuration data type, and the first configuration data type includes any one of a mode request, an operation list, and a rule;

[0153] A generating submodule, used for generating a code corresponding to the configuration data when the data type of the configuration data is a second configuration data type, and the second configuration data type includes any one of a logical expression and an operation;

[0154] The second saving submodule is used to save the code corresponding to the configuration data into a second array corresponding to the configuration data to obtain a second configuration subfile.

[0155] In some embodiments, the first preservation submodule may specifically include:

[0156] A first saving unit, used to save the configuration data into a first array corresponding to the configuration data to obtain a first initial configuration sub-file;

[0157] The first definition unit is used to define first target configuration data in a first initial configuration subfile to obtain a first configuration subfile, wherein the first target configuration data is configuration data of a target basic software module corresponding to the dynamic code, and the target basic software module is the remaining basic software modules except the BswM module.

[0158] In some embodiments, the second storage submodule may specifically include:

[0159] A second saving unit, used to save the code corresponding to the configuration data into a second array corresponding to the configuration data, to obtain a second initial configuration sub-file;

[0160] The second definition unit is used to define a mode request function in a second initial configuration subfile to obtain a second configuration subfile, wherein the mode request function is used to provide a calling mode to the remaining basic software modules except the BswM module.

[0161] In some embodiments, the code generating device 500 may further include:

[0162] a conversion module, used for converting the configuration data into second target configuration data having a target type language and a target data type before generating an index respectively corresponding to each configuration data, wherein the target type language is an object-oriented, interpreted programming language, and the target data type is a data type including a key-value pair;

[0163] The input module is used to input the second target configuration data into the target template. The target template is a code generation template built based on the target type language. The first configuration file and the second configuration file are both generated based on the target template.

[0164] In some embodiments, the incoming module may specifically include:

[0165] A verification submodule, used to verify the second target configuration data and obtain a verification result;

[0166] The input submodule is used to input the second target configuration data into the target template when the verification result is that the verification passes.

[0167] In some embodiments, the array includes a rule array, an operation list array, and an operation array. Based on this, the code generation device 500 may further include:

[0168] A traversal module, used for traversing the rule array in the dynamic code after obtaining the dynamic code corresponding to the BswM module;

[0169] An arbitration module, for arbitrating the logical expressions in the rule data for each rule data in the rule array, and obtaining arbitration results corresponding to each rule data;

[0170] A first access module, used to access the operation list data corresponding to the arbitration result in the operation list array through the operation list index in the rule data;

[0171] The second access module is used to access the operation data in the operation array through the operation index in the operation list data to implement the function corresponding to the dynamic code.

[0172] The code generation device of the embodiment of the present application generates an index corresponding to each configuration data based on the position of each configuration data in multiple configuration data, obtains a first configuration file, and creates arrays corresponding to multiple configuration data types, saves the configuration data to the array corresponding to the configuration data, and obtains a second configuration file, which can ensure that the first configuration file and the second configuration file only include codes corresponding to the user configuration. In this way, by determining the code in the first configuration file and the code in the second configuration file as dynamic codes corresponding to the BswM module, it can be ensured that the generated codes are all codes corresponding to the user configuration. Therefore, it can be ensured that all functions implemented based on dynamic codes are functions required by users, that is, it can improve the implementation efficiency of functions corresponding to user configurations and improve the user experience.

[0173] Based on the code generation method provided in the above embodiment, the embodiment of the present application also provides a specific implementation of the electronic device. Figure 6 A schematic diagram of an electronic device 600 provided in an embodiment of the present application is shown.

[0174] The electronic device 600 may include a processor 610 and a memory 620 storing computer program instructions.

[0175] Specifically, the processor 610 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.

[0176] The memory 620 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 620 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 620 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 620 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 620 is a non-volatile solid-state memory.

[0177] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, 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 according to the first aspect of the present application.

[0178] The processor 610 implements any one of the code generation methods in the above embodiments by reading and executing computer program instructions stored in the memory 620 .

[0179] In one example, the electronic device 600 may further include a communication interface 630 and a bus 640. Figure 6 As shown, the processor 610, the memory 620, and the communication interface 630 are connected via a bus 640 and communicate with each other.

[0180] The communication interface 630 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0181] Bus 640 includes hardware, software or both, and the parts of electronic 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 side 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 640 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.

[0182] Exemplarily, the electronic device 600 may be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA).

[0183] The electronic device can execute the code generation method in the embodiment of the present application, thereby realizing the combination Figures 1 to 5 The code generation method and device described.

[0184] In addition, in combination with the code generation method in the above embodiment, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the code generation methods in the above embodiment is implemented.

[0185] In addition, the embodiment of the present application further provides a vehicle, which may include at least one of the following:

[0186] A code generating device as in any one of the embodiments of the second aspect;

[0187] An electronic device as in any one of the embodiments of the third aspect;

[0188] The computer-readable storage medium in any one of the embodiments of the fourth aspect will not be described in detail here.

[0189] 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.

[0190] 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.

[0191] 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.

[0192] The above reference is according to the method of the embodiment of the present application, the flow chart of the device (system) and the computer program product and / or the block diagram described various aspects of the present application.It should be understood that each square box in the flow chart and / or the block diagram and the combination of each square box in the flow chart and / or the block diagram can be realized by computer program instructions.These computer program instructions can be provided to the 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 realization of the function / action specified in one or more square boxes of the flow chart and / or the 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 square box in the block diagram and / or the flow chart and the combination of the square boxes in the block diagram and / or the flow chart can also be realized by the dedicated hardware that performs the specified function or action, or can be realized by the combination of dedicated hardware and computer instructions.

[0193] 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 code generation method, characterized in that: include: Acquire multiple configuration data corresponding to the basic software mode manager BswM module, each of the configuration data corresponds to a configuration data type, and each of the configuration data types corresponds to at least one of the configuration data; Based on the position of each configuration data in the plurality of configuration data, generate an index corresponding to each configuration data, and obtain a first configuration file; Create arrays corresponding to a plurality of the configuration data types respectively; Saving the configuration data into an array corresponding to the configuration data to obtain a second configuration file; The code in the first configuration file and the code in the second configuration file are determined as dynamic codes corresponding to the BswM module.

2. The method according to claim 1, characterized in that The second configuration file includes a first configuration sub-file and a second configuration sub-file; The step of saving the configuration data into an array corresponding to the configuration data to obtain a second configuration file includes: When the data type of the configuration data is a first configuration data type, the configuration data is saved in a first array corresponding to the configuration data to obtain a first configuration subfile, wherein the first configuration data type includes any one of a mode request, an operation list, and a rule; In a case where the data type of the configuration data is a second configuration data type, generating a code corresponding to the configuration data, wherein the second configuration data type includes any one of a logical expression and an operation; The code corresponding to the configuration data is saved in a second array corresponding to the configuration data to obtain a second configuration sub-file.

3. The method according to claim 2, characterized in that The step of saving the configuration data into a first array corresponding to the configuration data to obtain a first configuration sub-file includes: Saving the configuration data into a first array corresponding to the configuration data to obtain a first initial configuration sub-file; The first target configuration data is defined in the first initial configuration subfile to obtain a first configuration subfile, wherein the first target configuration data is the configuration data of the target basic software module corresponding to the dynamic code, and the target basic software module is the remaining basic software modules except the BswM module.

4. The method according to claim 2, characterized in that: The step of saving the code corresponding to the configuration data into a second array corresponding to the configuration data to obtain a second configuration sub-file includes: Saving the code corresponding to the configuration data into a second array corresponding to the configuration data to obtain a second initial configuration sub-file; A mode request function is defined in the second initial configuration subfile to obtain a second configuration subfile, wherein the mode request function is used to provide a calling mode to the remaining basic software modules except the BswM module.

5. The method according to claim 1, characterized in that Before generating an index corresponding to each of the configuration data based on the position of each of the configuration data in the plurality of configuration data and obtaining the first configuration file, the method further includes: Converting the configuration data into second target configuration data having a target type language and a target data type, wherein the target type language is an object-oriented, interpreted programming language, and the target data type is a data type including a key-value pair; The second target configuration data is passed into a target template, where the target template is a code generation template constructed based on the target type language, and both the first configuration file and the second configuration file are generated based on the target template.

6. The method according to claim 5, characterized in that The step of transferring the second target configuration data into the target template includes: Verifying the second target configuration data to obtain a verification result; When the verification result is that the verification passes, the second target configuration data is transferred into the target template.

7. The method according to claim 1, characterized in that The array includes a rule array, an operation list array and an operation array. After obtaining the dynamic code corresponding to the BswM module, the method further includes: Traversing the rule array in the dynamic code; For each rule data in the rule array, arbitrate the logical expression in the rule data to obtain an arbitration result corresponding to each rule data; Accessing the operation list data corresponding to the arbitration result in the operation list array through the operation list index in the rule data; The operation data in the operation array is accessed through the operation index in the operation list data to implement the function corresponding to the dynamic code.

8. A code generating device, characterized in that: The device comprises: An acquisition module, used for acquiring a plurality of configuration data corresponding to the basic software mode manager BswM module, each of the configuration data corresponds to a configuration data type, and each of the configuration data types corresponds to at least one of the configuration data; A generating module, configured to generate an index corresponding to each of the configuration data based on a position of each of the configuration data in the plurality of configuration data, to obtain a first configuration file; A creation module, used to create arrays corresponding to a plurality of the configuration data types respectively; A saving module, used for saving the configuration data into an array corresponding to the configuration data to obtain a second configuration file; A determination module is used to determine the code in the first configuration file and the code in the second configuration file as dynamic codes corresponding to the BswM module.

9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the code generation method according to any one of claims 1 to 7 is implemented.

10. 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 code generation method according to any one of claims 1 to 7 is implemented.

11. A vehicle, characterized in that: Include at least one of the following: The code generating device as claimed in claim 8; The electronic device as claimed in claim 9; The computer readable storage medium of claim 10.