Update method and device for variable attributes, vehicle, and storage medium
By automatically updating the type package attributes of the control variables based on the variable library in the automotive electronic control system, the inefficiency problem caused by the need to recreate each control variable in the existing technology is solved, and efficient update of batch variable attributes is achieved.
Patent Information
- Application Number
- CN202210603437.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-30
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-05-30
AI Technical Summary
In the prior art, when complex automotive electronic control systems update the variable attributes of the control variable, they need to recreate each control variable, resulting in low working efficiency.
By extracting the variable information of the target control variable based on the first variable library, determining the target attribute value of its type package attribute, and automatically updating the attribute value, batch changing of the type package attribute of the control variable is achieved.
Reduce the process of manually repetitively creating control variables, improve work efficiency, and realize automated variable attribute updates.
Smart Images

Figure CN114911504B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular, to a method and apparatus for updating variable attributes, a vehicle, and a storage medium. Background Art
[0002] In a vehicle electronic control system, when building application layer software, a simulation model needs to be built. As the control system becomes increasingly complex, the number of control variables in the simulation model (for example, Simulink) is also increasing. However, most simulation models only support creating control variables under a limited number of types of packages. For example, the Simulink model only supports creating control variables under 7 types of packages, and these 7 types of package types are Simulink, SimulinkBuiltin (a type package of a data format), mpt (a type package of a data format), AUTOSAR (Automotive Open System Architecture, that is, a type package of an automotive open system architecture type), AUTOSAR4 (another type package of an automotive open system architecture type), ECodeDemos (a type package of a data format), and canlib (a type package of a data format).
[0003] In the related art, for a complex electronic control system, the control variable library contains a large number of control variables. When only wanting to change the package type of variables such as Signal (signal line information) and Parameter (parameter information) without changing other attributes of the variables (for example, storage type, etc.), since most simulation models do not support direct modification, it is necessary to record the attributes of each variable and recreate each variable. During the creation process, it is necessary to input the variable attributes and reselect the package type, which greatly increases the operation difficulty.
[0004] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention
[0005] Embodiments of the present invention provide a method and apparatus for updating variable attributes, a vehicle, and a storage medium, so as to at least solve the technical problem in the related art that when updating the variable attributes of control variables, it is necessary to recreate each control variable, resulting in low work efficiency.
[0006] According to one aspect of an embodiment of the present invention, there is provided a method for updating variable attributes, including: extracting variable information of a target control variable whose variable type is a preset variable type based on a first variable library, where the first variable library includes a plurality of control variables and variable attributes of each control variable, and the variable information at least includes: variable identifier, variable attribute, and the variable attribute includes: type package attribute and other variable attributes; determining a target attribute value of the type package attribute of the target control variable according to the variable identifier; updating the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable.
[0007] Optionally, the other variable attributes include at least one of the following: initial value attribute, variable type attribute, dimension attribute, complex type attribute, maximum value attribute, minimum value attribute, unit attribute, storage type attribute.
[0008] Optionally, before extracting variable information of a target control variable whose variable type is a preset variable type based on the first variable library, it further includes: determining a variable type of the variable attributes of the plurality of control variables that involves the type package attribute; using the variable type as the preset variable type, where the preset variable type at least includes: signal line type, parameter type.
[0009] Optionally, the step of extracting variable information of a target control variable whose variable type is a preset variable type based on the first variable library includes: obtaining all control variables based on the first variable library and adding all control variables to a preset working area; extracting the target control variable whose variable type is the preset variable type from the preset working area; obtaining the variable identifier of the target control variable based on a preset policy; obtaining the variable attribute of the target control variable based on the variable identifier; and obtaining the variable information of the target control variable based on the variable identifier and the variable attribute.
[0010] Optionally, before determining the target attribute value of the type package attribute of the target control variable according to the variable identifier, it further includes: obtaining requirement information of the target control variable, where the requirement information includes at least one of the following: storage area information, header file information, declaration information; creating a preset type package attribute based on the requirement information; storing the attribute information of the preset type package attribute in a preset folder, where the attribute information at least includes: target attribute value; and storing the preset folder in a preset simulation project folder.
[0011] Optionally, after updating the attribute value of the type package attribute of the target control variable to the target attribute value, the method further includes: based on a preset inheritance policy, adding the attribute values of the other variable attributes to the other variable attributes of the target control variable whose type package attribute has been updated.
[0012] Optionally, after adding the attribute values of the other variable attributes to the other variable attributes of the target control variable whose type package attribute has been updated, the method further includes: storing all current control variables in a preset workspace into a second variable library; based on the second variable library, obtaining variable identifiers of all the current control variables to obtain a variable identifier set; based on the variable identifier set, determining target control variables corresponding to each variable identifier in the variable identifier set in the first variable library to obtain a target control variable set; replacing the attribute values of the type package attributes of each target control variable in the target control variable set with the attribute values of the type package attributes of the control variables in the second variable library corresponding to the target control variables.
[0013] According to another aspect of the embodiments of the present invention, there is also provided an apparatus for updating variable attributes, including: an extraction unit, configured to extract variable information of a target control variable whose variable type is a preset variable type based on a first variable library, where the first variable library includes a plurality of control variables and variable attributes of each control variable, and the variable information at least includes: a variable identifier, variable attributes, and the variable attributes include: a type package attribute and other variable attributes; a determination unit, configured to determine a target attribute value of the type package attribute of the target control variable according to the variable identifier; and an update unit, configured to update the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable.
[0014] Optionally, the other variable attributes include at least one of the following: an initial value attribute, a variable type attribute, a dimension attribute, a complex type attribute, a maximum value attribute, a minimum value attribute, a unit attribute, and a storage type attribute.
[0015] Optionally, the update apparatus further includes: a first determination module, configured to determine a variable type of the variable attributes of the plurality of control variables that involves the type package attribute before extracting the variable information of the target control variable whose variable type is a preset variable type based on the first variable library; and a first characterization module, configured to use the variable type as the preset variable type, where the preset variable type at least includes: a signal line type and a parameter type.
[0016] Optionally, the extraction unit includes: a first acquisition module, configured to acquire all control variables based on the first variable library and add all the control variables to a preset work area; a first extraction module, configured to extract target control variables of which the variable type is the preset variable type from the preset work area; a second acquisition module, configured to acquire the variable identifier of the target control variable based on a preset policy; a third acquisition module, configured to acquire the variable attribute of the target control variable based on the variable identifier; and a fourth acquisition module, configured to obtain the variable information of the target control variable based on the variable identifier and the variable attribute.
[0017] Optionally, the updating device further includes: a fifth acquisition module, configured to acquire requirement information of the target control variable before determining a target attribute value of a type package attribute of the target control variable according to the variable identifier, where the requirement information includes at least one of the following: storage area information, header file information, and declaration information; a first creation module, configured to create a preset type package attribute based on the requirement information; a first storage module, configured to store attribute information of the preset type package attribute to a preset folder, where the attribute information includes at least: the target attribute value; and a second storage module, configured to store the preset folder to a preset simulation project folder.
[0018] Optionally, the updating device further includes: a first addition module, configured to, after updating an attribute value of the type package attribute of the target control variable to the target attribute value, add the attribute values of the other variable attributes to the other variable attributes of the target control variable with the type package attribute that has been updated and completed based on a preset inheritance policy.
[0019] Optionally, the updating device further includes: a third storage module, configured to, after adding the attribute values of the other variable attributes to the other variable attributes of the target control variable with the type package attribute that has been updated and completed, store all current control variables in the preset work area to a second variable library; a sixth acquisition module, configured to acquire variable identifiers of all the current control variables based on the second variable library to obtain a variable identifier set; a second determination module, configured to determine target control variables corresponding to each variable identifier in the variable identifier set in the first variable library based on the variable identifier set to obtain a target control variable set; and a first replacement module, configured to replace the attribute value of the type package attribute of each target control variable in the target control variable set with the attribute value of the type package attribute of the control variable in the second variable library corresponding to the target control variable.
[0020] According to another aspect of the embodiments of the present invention, a vehicle is further provided, and an in-vehicle electronic control system in the vehicle executes the method for updating the variable attribute described above.
[0021] According to another aspect of the embodiments of the present invention, a vehicle-mounted storage medium is further provided. The vehicle-mounted storage medium includes a stored computer program, wherein when the computer program runs, it controls the device where the vehicle-mounted storage medium is located to execute the above-mentioned variable attribute update method.
[0022] In the present disclosure, based on the first variable library, variable information of a target control variable whose variable type is a preset variable type is extracted. According to the variable identifier, a target attribute value of the type package attribute of the target control variable is determined, and the attribute value of the type package attribute of the target control variable is updated to the target attribute value to complete the update of the variable attribute of the target control variable. In the present application, the variable information of the target control variable can be automatically extracted. By determining the target attribute value of the type package attribute of the target control variable and updating the attribute value of the type package attribute of the target control variable to the corresponding target attribute value, the function of batch-changing the type package attributes of control variables can be realized, the process of manually and repeatedly creating control variables is reduced, the work efficiency is improved, and thus the technical problem in the related art that when updating the variable attributes of control variables, each control variable needs to be re-created, resulting in low work efficiency, is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The illustrative embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0024] Figure 1 is a flowchart of an optional variable attribute update method according to an embodiment of the present invention;
[0025] Figure 2 is a flowchart of an optional method for batch-changing the control variable package type according to an embodiment of the present invention;
[0026] Figure 3 is a schematic diagram of an optional variable attribute update device according to an embodiment of the present invention;
[0027] Figure 4 is a hardware structure block diagram of an electronic device (or mobile device) for a variable attribute update method according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0028] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0030] To facilitate the understanding of the present invention by those skilled in the art, the following explains some terms or nouns involved in each embodiment of the present invention:
[0031] Simulink model: It is a visual simulation tool and also a module diagram environment for multi-domain simulation and model-based design. It can support system design, simulation, automatic code generation, and continuous testing and verification of embedded systems. It can also provide a graphical editor, a customizable module library, and a solver, and can perform dynamic system modeling and simulation.
[0032] The following embodiments of the present invention can be applied to various systems / applications / devices for updating variable attributes. The present invention can implement the process of automatically extracting variable information of control variables such as Signal and Parameter in the control variable library, and can store the extracted variable information in a preset file (such as a preset excel table) for information adjustment and management. Then, based on the adjusted variable information, the function of batch-changing the package type of control variables is realized, which reduces the process of manually and repeatedly creating control variables and saves time.
[0033] The present invention will be described in detail below in conjunction with each embodiment.
[0034] Embodiment 1
[0035] According to an embodiment of the present invention, there is provided an embodiment of a method for updating variable attributes. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0036] Figure 1 FIG. is a flowchart of an optional method for updating variable attributes according to an embodiment of the present invention. As Figure 1 shown, the method includes the following steps:
[0037] Step S102, based on the first variable library, extract the variable information of the target control variable whose variable type is the preset variable type. Among them, the first variable library includes multiple control variables and the variable attributes of each control variable. The variable information at least includes: variable identifier, variable attribute, and the variable attribute includes: type package attribute and other variable attributes.
[0038] Step S104, according to the variable identifier, determine the target attribute value of the type package attribute of the target control variable. [[ID=1...]]
[0039] Step S106, update the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable.
[0040] Through the above steps, based on the first variable library, the variable information of the target control variable whose variable type is the preset variable type can be extracted. According to the variable identifier, the target attribute value of the type package attribute of the target control variable can be determined, and the attribute value of the type package attribute of the target control variable can be updated to the target attribute value to complete the update of the variable attributes of the target control variable. In the embodiment of the present invention, the variable information of the target control variable can be automatically extracted. By determining the target attribute value of the type package attribute of the target control variable and updating the attribute value of the type package attribute of the target control variable to the corresponding target attribute value, the function of batch-changing the type package attributes of the control variables can be realized, reducing the process of manually and repeatedly creating control variables, improving work efficiency, and thus solving the technical problem in the related art that when updating the variable attributes of the control variables, each control variable needs to be re-created, resulting in low work efficiency.
[0041] The embodiments of the present invention will be described in detail below in combination with the above steps.
[0042] In an embodiment of the present invention, optionally, before extracting variable information of a target control variable whose variable type is a preset variable type based on a first variable library, it further includes: determining a variable type of a plurality of control variables whose variable attributes involve a type package attribute; and using the variable type as the preset variable type, where the preset variable type at least includes: a signal line type and a parameter type.
[0043] In an embodiment of the present invention, it is possible to first determine a variable type of a control variable whose variable attribute involves a package attribute (i.e., a type package attribute), and set the variable type as the preset variable type (the preset variable type includes: a signal line type (Signal), a parameter type (Parameter), etc.), that is, first determine a target control variable involving a package type selection.
[0044] Step S102, based on the first variable library, extract variable information of a target control variable whose variable type is a preset variable type, where the first variable library includes a plurality of control variables and variable attributes of each control variable, and the variable information at least includes: a variable identifier and a variable attribute, and the variable attribute includes: a type package attribute and other variable attributes. Optionally, the other variable attributes include at least one of the following: an initial value attribute, a variable type attribute, a dimension attribute, a complex type attribute, a maximum value attribute, a minimum value attribute, a unit attribute, and a storage type attribute.
[0045] In an embodiment of the present invention, the first variable library includes a plurality of control variables and variable attributes of each control variable, which is an existing control variable library. By loading the first variable library (i.e., adding all control variables (all control variables in the first variable library) corresponding to the control system application software to the simulation software into the work area), extract variable information of a target control variable whose variable type is a preset variable type in the work area (the variable information includes: a variable identifier (i.e., a variable name), a variable attribute, etc.), and the variable attribute includes: a type package attribute and other variable attributes. In this embodiment, the other variable attributes include but are not limited to: an initial value attribute, a variable type attribute, a dimension attribute, a complex type attribute, a maximum value attribute, a minimum value attribute, a unit attribute, a storage type attribute, etc.
[0046] Optionally, the step of extracting variable information of a target control variable whose variable type is a preset variable type based on the first variable library includes: based on the first variable library, obtain all control variables, and add all control variables to a preset work area; extract a target control variable whose variable type is a preset variable type from the preset work area; based on a preset policy, obtain a variable identifier of the target control variable; based on the variable identifier, obtain a variable attribute of the target control variable; and based on the variable identifier and the variable attribute, obtain variable information of the target control variable.
[0047] In an embodiment of the present invention, all control variables in the first variable library can be obtained first, and all control variables are added to a preset work area. Then, target control variables with a preset variable type are extracted from the preset work area (that is, the control variables related to the package type selection can be extracted from the preset work area through a preset algorithm). Through a preset strategy, the variable identifier of the target control variable is obtained (for example, the variable name of the target control variable can be obtained through the code objName = var(n).name). After the variable identifier extraction is completed, through programming techniques, the variable attributes corresponding to all target control variables in the preset work area can be obtained (including: initial value, variable type, dimension, complex type, maximum value, minimum value, unit, storage type, etc.). For example, in this embodiment, the following code can be used to obtain variable attributes:
[0048] The code for extracting the initial value attribute is:
[0049] objNameInitialValue = eval([[var(n).name],'.InitialValue']);
[0050] The code for extracting the variable type attribute is:
[0051] objNameDataType = eval([[var(n).name],'.DataType']);
[0052] The code for extracting the dimension attribute is:
[0053] objNameDimensions = eval([[var(n).name],'.Dimensions']);
[0054] The code for extracting the complex type attribute is:
[0055] objNameComplexity = eval([[var(n).name],'.Complexity']);
[0056] The code for extracting the maximum value attribute is:
[0057] objNameMax = eval([[var(n).name],'.Max']);
[0058] The code for extracting the minimum value attribute is:
[0059] objNameMin = eval([[var(n).name],'.Min']);
[0060] The code for extracting the unit attribute is: objNameUnit = eval([[var(n).name],'.Unit']);
[0061] The code for extracting the storage type attribute is:
[0062] objNameStorageClass = eval([[var(n).name],'.StorageClass']).
[0063] Then, based on the variable identifier and variable attributes, the variable information of the target control variable can be obtained.
[0064] Optionally, before determining the target attribute value of the type package attribute of the target control variable based on the variable identifier, it further includes: obtaining the requirement information of the target control variable, where the requirement information includes at least one of the following: storage area information, header file information, declaration information; creating a preset type package attribute based on the requirement information; storing the attribute information of the preset type package attribute in a preset folder, where the attribute information includes at least: the target attribute value; storing the preset folder in a preset simulation project folder.
[0065] In the embodiment of the present invention, a custom package type (which can be denoted as mypackage (i.e., the preset type package)) can be created according to the actual requirements for the storage area, header file, declaration, etc. of the control variable (that is, a preset type package attribute can be created based on the obtained requirement information of the target control variable, and the requirement information includes: storage area information, header file information, declaration information, etc.). After that, the detailed information (i.e., the attribute information) of the preset type package attribute can be placed in a preset folder (for example, it can be placed in a folder named "mypackage"), and the preset folder can be placed in a preset simulation project folder (such as, the Simulink project folder).
[0066] Step S104, determine the target attribute value of the type package attribute of the target control variable according to the variable identifier.
[0067] In the embodiment of the present invention, the target attribute value of the type package attribute of the control variable can be determined according to the variable identifier of the control variable, that is, the corresponding preset type package attribute can be queried under the preset folder in the preset simulation project folder through the variable identifier to determine its target attribute value.
[0068] Another option is to store the variable identifier of the extracted target control variable and its corresponding variable attributes in a preset workspace, and add the variable identifier and variable attributes to a preset file (such as an excel table) to further update and maintain the variable information of the target control variable using the preset file.
[0069] Step S106: Update the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attribute of the target control variable.
[0070] In the embodiment of the present invention, after determining the target attribute value of the preset type package attribute of each target control variable, the attribute value of the type package attribute of the target control variable can be updated to the corresponding target attribute value to complete the update of the variable attribute of the target control variable. Moreover, in this embodiment, the attribute values of other attributes of the target control variable remain unchanged.
[0071] Alternatively, the step of updating the attribute value of the type package attribute of the target control variable to the target attribute value includes: importing the variable identifier in the preset file into the preset work area; when the variable type of the target control variable indicated by the variable identifier is the signal line type, adopting a first update strategy to update the attribute value of the type package attribute of the target control variable indicated by the variable identifier in the preset work area to the target attribute value of the preset type package attribute corresponding to the target control variable; when the variable type of the target control variable indicated by the variable identifier is the parameter type, adopting a second update strategy to update the attribute value of the type package attribute of the target control variable indicated by the variable identifier in the preset work area to the target attribute value of the preset type package attribute corresponding to the target control variable.
[0072] In an embodiment of the present invention, after managing control variables of types such as Signal (i.e., signal line type) and Parameter (i.e., parameter type) in a preset file, the control variables can be added to a preset workspace, the package type can be changed, and the variable attributes in the preset file can be inherited. Specifically, the following steps are included: (1) Import the variable names of Signal and Parameter types in the preset file; (2) Through a preset programming technique, define the package type of each variable name as "mypackage". When it is of Signal type, adopt a first update strategy (e.g., use the code: objName = mypackage.Signal) to update the attribute value of the type package attribute of this control variable to the corresponding target attribute value; when it is of Parameter type, adopt a second update strategy (e.g., use the code: objName = mypackage.Parameter) to update the attribute value of the type package attribute of this control variable to the corresponding target attribute value; (3) Through a preset programming technique, add other attributes of each control variable of Signal and Parameter types, including initial value, variable type, dimension, complex type, maximum value, minimum value, unit, storage type, etc. In this way, the package types of control variables of types such as Signal and Parameter in the preset workspace have been changed to "mypackage", and other attribute values remain unchanged.
[0073] Optionally, after updating the attribute value of the type package attribute of the target control variable to the target attribute value, it further includes: Based on a preset inheritance strategy, add the attribute values of other variable attributes to the other variable attributes of the target control variable whose type package attribute has been updated.
[0074] In an embodiment of the present invention, a preset inheritance strategy can be adopted to add the attribute values of other variable attributes to the other variable attributes of the target control variable whose type package attribute has been updated, so that only the type package attribute of the target control variable can be updated while keeping other attribute values unchanged.
[0075] Optionally, after adding the attribute values of other variable attributes to the other variable attributes of the target control variable whose type package attribute has been updated, it further includes: Store all current control variables in the preset workspace in a second variable library; Based on the second variable library, obtain the variable identifiers of all current control variables to obtain a variable identifier set; Based on the variable identifier set, determine the target control variables corresponding to each variable identifier in the first variable library to obtain a target control variable set; Replace the attribute value of the type package attribute of each target control variable in the target control variable set with the attribute value of the type package attribute of the control variable in the second variable library corresponding to the target control variable.
[0076] In an embodiment of the present invention, all current control variables in a preset work area can be stored in a second variable library, and the package types of the control variables (i.e., the target control variable set) under types such as Signal and Parameter in the original first variable library are replaced. Specifically: Based on the second variable library, the variable identifiers of all current control variables can be obtained to get a variable identifier set. Then, according to the variable identifier set, the target control variables corresponding to each variable identifier in the variable identifier set in the first variable library are determined to obtain a target control variable set. Then, the attribute value of the type package attribute of each target control variable in the target control variable set is replaced with the attribute value of the type package attribute of the control variable in the second variable library corresponding to the target control variable, so as to complete the function of batch-changing the package types of control variables.
[0077] The following is a detailed description in combination with another optional specific implementation manner.
[0078] Figure 2 It is a flowchart of an optional method for batch-changing the package type of a control variable according to an embodiment of the present invention. This embodiment is described by taking a Simulink model as an example. As Figure 2 shown, it includes the following steps:
[0079] Step S201: Create a custom package type (which can be denoted as mypackage) according to the actual requirements for the storage area, header file, declaration, etc. of the control variable (i.e., establish a custom package type according to the requirements of the control variable), and place the detailed information under this type in a folder named "mypackage", and place the "mypackage" folder in the Simulink project folder.
[0080] Step S202: Load the existing first variable library, that is, add all control variables in the control system application software corresponding to the simulation software to the work area.
[0081] Step S203: In the control system, the control variables involved in package type selection include types such as Signal (signal line information) and Parameter (parameter information). Through programming techniques, obtain the variable names of types such as Signal and Parameter, specifically including the following two steps:
[0082] (1) Find the variables under types such as Signal and Parameter in the work area;
[0083] (2) Extract their names, and the name extraction code is: objName = var(n).name.
[0084] Step S204: After completing the extraction of variable names, use programming techniques to obtain the variable attributes corresponding to all variables of types such as Signal and Parameter in the workspace, including: initial value, variable type, dimension, complex type, maximum value, minimum value, unit, storage type, etc.
[0085] Step S205: After extracting the variable names and their corresponding variable attributes of variables of types such as Signal and Parameter and storing them in the workspace, add the variable names and variable attributes to the excel to complete the update and maintenance of the control variable information.
[0086] Step S206: After completing the management of variables of types such as Signal and Parameter in the excel, add the variables to the workspace, change the package type, and inherit the variable attributes in the excel sheet. The specific steps are as follows:
[0087] (1) Import the variable names of types such as Signal and Parameter in the excel;
[0088] (2) Use programming techniques to define the package type under each variable name as "mypackage". When it is of type Parameter, the code is: objName = mypackage.Parameter; when it is of type Signal, the code is: objName = mypackage.Signal;
[0089] (3) Use programming techniques to add the attributes of each control variable of types such as Signal and Parameter, including initial value, variable type, dimension, complex type, maximum value, minimum value, unit, storage type, etc.
[0090] Step S207: After the package type of the control variables of types such as Signal and Parameter in the workspace has been changed to "mypackage" and other attribute values remain unchanged, store all the variables in the workspace at this time as the second variable library.
[0091] Step S208: Load the first variable library and the second variable library. After that, replace the package type of the control variables of types such as Signal and Parameter in the first variable library with the mypackage type of the control variables of types such as Signal and Parameter in the second variable to complete the function of batch-changing the package type of the control variables.
[0092] In the embodiments of the present invention, the process of automatically extracting the variable name and variable attributes of control variables can be realized, and the variable information of the extracted control variables is stored in a preset file for information adjustment and management. On the basis of inheriting the original variable attributes, the package type of the control variables is batch modified to a custom type, so as to reduce the process of manually and repeatedly creating control variables, save time and improve work efficiency.
[0093] Embodiment 2
[0094] A variable attribute update device provided in this embodiment includes multiple implementation units, and each implementation unit corresponds to each implementation step in the first embodiment above.
[0095] Figure 3 It is a schematic diagram of an optional variable attribute update device according to an embodiment of the present invention, as Figure 3 shown. The update device may include: an extraction unit 30, a determination unit 31, and an update unit 32, where
[0096] The extraction unit 30 is used to extract the variable information of the target control variable whose variable type is a preset variable type based on the first variable library. The first variable library includes multiple control variables and the variable attributes of each control variable. The variable information includes at least: variable identification, variable attributes, and the variable attributes include: type package attributes and other variable attributes;
[0097] The determination unit 31 is used to determine the target attribute value of the type package attribute of the target control variable according to the variable identification;
[0098] The update unit 32 is used to update the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable.
[0099] For the above update device, the extraction unit 30 can extract the variable information of the target control variable whose variable type is a preset variable type based on the first variable library, the determination unit 31 can determine the target attribute value of the type package attribute of the target control variable according to the variable identification, and the update unit 32 can update the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable. In the embodiments of the present invention, the variable information of the target control variable can be automatically extracted, and by determining the target attribute value of the type package attribute of the target control variable and updating the attribute value of the type package attribute of the target control variable to the corresponding target attribute value, the function of batch changing the type package attributes of control variables can be realized, reducing the process of manually and repeatedly creating control variables, improving work efficiency, and thus solving the technical problem in the related art that when updating the variable attributes of control variables, each control variable needs to be recreated, resulting in low work efficiency.
[0100] Optionally, other variable attributes include at least one of the following: initial value attribute, variable type attribute, dimension attribute, complex type attribute, maximum value attribute, minimum value attribute, unit attribute, storage type attribute.
[0101] Optionally, the updating device further includes: a first determining module, configured to determine the variable types of multiple control variables whose variable attributes involve the type package attribute before extracting the variable information of the target control variable whose variable type is a preset variable type based on the first variable library; a first characterizing module, configured to use the variable type as the preset variable type, where the preset variable type includes at least: signal line type, parameter type.
[0102] Optionally, the extracting unit includes: a first obtaining module, configured to obtain all control variables based on the first variable library and add all control variables to a preset working area; a first extracting module, configured to extract the target control variable whose variable type is the preset variable type from the preset working area; a second obtaining module, configured to obtain the variable identifier of the target control variable based on a preset policy; a third obtaining module, configured to obtain the variable attribute of the target control variable based on the variable identifier; a fourth obtaining module, configured to obtain the variable information of the target control variable based on the variable identifier and the variable attribute.
[0103] Optionally, the updating device further includes: a fifth obtaining module, configured to obtain the requirement information of the target control variable before determining the target attribute value of the type package attribute of the target control variable according to the variable identifier, where the requirement information includes at least one of the following: storage area information, header file information, declaration information; a first creating module, configured to create a preset type package attribute based on the requirement information; a first storing module, configured to store the attribute information of the preset type package attribute under a preset folder, where the attribute information includes at least: the target attribute value; a second storing module, configured to store the preset folder under a preset simulation project folder.
[0104] Optionally, the updating device further includes: a first adding module, configured to add the attribute values of other variable attributes to the other variable attributes of the target control variable with the type package attribute that has been updated after updating the attribute value of the type package attribute of the target control variable to the target attribute value based on a preset inheritance policy.
[0105] Optionally, the updating device further includes: a third storage module, configured to store all current control variables in the preset workspace into the second variable library after adding the attribute values of other variable attributes to the other variable attributes of the target control variable with the type package attribute of the updated completed type package; a sixth obtaining module, configured to obtain the variable identifiers of all current control variables based on the second variable library to obtain a variable identifier set; a second determining module, configured to determine, based on the variable identifier set, the target control variables corresponding to each variable identifier in the variable identifier set in the first variable library to obtain a target control variable set; a first replacement module, configured to replace the attribute values of the type package attributes of each target control variable in the target control variable set with the attribute values of the type package attributes of the control variables in the second variable library corresponding to the target control variables.
[0106] The above-mentioned updating device may further include a processor and a memory. The above-mentioned extraction unit 30, determination unit 31, updating unit 32, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to implement corresponding functions.
[0107] The above-mentioned processor includes a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels may be set, and by adjusting the kernel parameters, the attribute value of the type package attribute of the target control variable is updated to the target attribute value to complete the update of the variable attributes of the target control variable.
[0108] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.
[0109] The present application also provides a computer program product, which is suitable for executing a program initialized with the following method steps when executed on a data processing device: extracting the variable information of the target control variable with the variable type of the preset variable type based on the first variable library, determining the target attribute value of the type package attribute of the target control variable according to the variable identifier, and updating the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable.
[0110] According to another aspect of the embodiments of the present invention, a vehicle is further provided, and the vehicle's on-vehicle electronic control system executes the above-mentioned method for updating variable attributes.
[0111] According to another aspect of the embodiments of the present invention, an in-vehicle storage medium is further provided, and the in-vehicle storage medium includes a stored computer program, wherein when the computer program runs, it controls the device where the in-vehicle storage medium is located to execute the above-mentioned method for updating variable attributes.
[0112] According to another aspect of the embodiments of the present invention, an electronic device is further provided, including one or more processors and a memory. The memory is used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned method for updating variable attributes.
[0113] Figure 4 is a hardware structure block diagram of an electronic device (or mobile device) for a method of updating variable attributes according to an embodiment of the present invention. As Figure 4 shown, the electronic device may include one or more processors 102 (shown as 102a, 102b,..., 102n in the figure) (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 4 the structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the electronic device may further include more or fewer components than Figure 4 shown, or have a different configuration from Figure 4 shown.
[0114] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0115] In the above embodiments of the present invention, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0116] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the units or modules can be in electrical or other forms.
[0117] The unit described as a separating component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or may be distributed over multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0118] In addition, each functional unit in various embodiments of the present invention may be integrated into a processing unit, may also be physically present separately for each unit, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0119] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.
[0120] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can still be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A method for updating variable attributes, characterized in that, Including: Based on a first variable library, extracting variable information of a target control variable whose variable type is a preset variable type, where the first variable library includes multiple control variables and variable attributes of each control variable, and the variable information at least includes: a variable identifier, variable attributes, and the variable attributes include: a type package attribute and other variable attributes; According to the variable identifier, determining a target attribute value of the type package attribute of the target control variable. Before determining the target attribute value of the type package attribute of the target control variable according to the variable identifier, obtaining requirement information of the target control variable, where the requirement information includes at least one of the following: storage area information, header file information, declaration information; creating a preset type package attribute based on the requirement information; storing attribute information of the preset type package attribute in a preset folder, where the attribute information at least includes: the target attribute value; storing the preset folder in a preset simulation project folder; Updating the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable.
2. The update method according to claim 1, wherein The other variable attributes include at least one of the following: an initial value attribute, a variable type attribute, a dimension attribute, a complex type attribute, a maximum value attribute, a minimum value attribute, a unit attribute, a storage type attribute.
3. The update method according to claim 1, wherein Before extracting variable information of a target control variable whose variable type is a preset variable type based on a first variable library, it further includes: Determining a variable type of the type package attribute involved in the variable attributes of the multiple control variables; Taking the variable type as the preset variable type, where the preset variable type at least includes: a signal line type, a parameter type.
4. The update method according to claim 3, characterized in that The step of extracting variable information of a target control variable whose variable type is a preset variable type based on a first variable library includes: Based on the first variable library, obtaining all control variables and adding all control variables to a preset workspace; Extracting from the preset workspace a target control variable whose variable type is the preset variable type; Based on a preset policy, obtaining the variable identifier of the target control variable; Based on the variable identifier, obtaining the variable attributes of the target control variable; Based on the variable identifier and the variable attributes, obtaining the variable information of the target control variable.
5. The update method according to claim 1, wherein After updating the attribute value of the type package attribute of the target control variable to the target attribute value, it further includes: Based on a preset inheritance policy, adding the attribute values of the other variable attributes to the other variable attributes of the target control variable with the type package attribute that has been updated and completed.
6. The update method according to claim 5, characterized in that After adding the attribute values of the other variable attributes to the other variable attributes of the target control variable with the type package attribute that has been updated and completed, it further includes: Storing all current control variables in the preset workspace in a second variable library; Based on the second variable library, obtaining variable identifiers of all current control variables to obtain a variable identifier set; Based on the set of variable identifiers, determine the target control variables in the first variable library corresponding to each variable identifier in the set of variable identifiers, and obtain a set of target control variables; Replace the attribute value of the type package attribute of each target control variable in the set of target control variables with the attribute value of the type package attribute of the control variable in the second variable library corresponding to the target control variable.
7. An update device for variable attributes, characterized in that, Including: An extraction unit, configured to extract variable information of target control variables whose variable type is a preset variable type based on a first variable library, where the first variable library includes a plurality of control variables and variable attributes of each control variable, and the variable information at least includes: variable identifier, variable attribute, and the variable attribute includes: type package attribute and other variable attributes; A determination unit, configured to determine a target attribute value of the type package attribute of the target control variable according to the variable identifier; An update unit, configured to update the attribute value of the type package attribute of the target control variable to the target attribute value to complete the update of the variable attributes of the target control variable; The update device further includes: a fifth acquisition module, configured to acquire requirement information of the target control variable before determining the target attribute value of the type package attribute of the target control variable according to the variable identifier, where the requirement information includes at least one of the following: storage area information, header file information, declaration information; a first creation module, configured to create a preset type package attribute based on the requirement information; a first storage module, configured to store the attribute information of the preset type package attribute in a preset folder, where the attribute information at least includes: target attribute value; a second storage module, configured to store the preset folder in a preset simulation project folder.
8. A vehicle, characterized in that, The vehicle's in-vehicle electronic control system executes the variable attribute update method according to any one of claims 1 to 6.
9. A vehicle-mounted storage medium, characterized in that, The in-vehicle storage medium includes a stored computer program, where when the computer program runs, it controls the device where the in-vehicle storage medium is located to execute the variable attribute update method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Simulink model variable distribution processing method, device and equipment
CN110333870A
Data dictionary creation method, terminal equipment and medium
CN113886647A