Disclosure of Invention
In view of this, the present invention provides a method and an apparatus for generating a data dictionary, a storage medium, and an electronic device, and when a data dictionary of a data module is created, a programmer is not required to define contents in the data dictionary one by one, so that time spent by the programmer is reduced when the data dictionary is created, and work efficiency of the programmer is improved.
In order to achieve the purpose, the invention provides the following technical scheme:
the first aspect of the present application discloses a method for generating a data dictionary, which includes:
determining a data module needing to create a data dictionary;
scanning a bottom file of the data module to obtain all variables of the data module;
normalizing the attribute information of each variable to obtain each standard variable;
extracting the characteristic information of each standard variable, and creating a data object of each standard variable based on the characteristic information of each standard variable;
and obtaining a data dictionary of the data module based on the data object of each standard variable.
Optionally, in the method, the normalizing the attribute information of each variable to obtain each standard variable includes:
acquiring attribute information of each variable;
for each variable, judging whether the variable is a standard variable or not based on the attribute information of the variable;
if the variable is a standard variable, determining the variable as a standard variable;
and if the variable is not a standard variable, modifying the attribute information of the variable based on a preset modification rule, and determining the variable as a standard variable after obtaining the modified attribute information.
Optionally, the method for obtaining the data dictionary of the data module based on the data object of each standard variable includes:
determining whether a historical data dictionary exists for the data module;
if the data module has a historical data dictionary, updating the historical data dictionary based on each data object, and taking the updated data dictionary as the data dictionary of the data module;
and if the data module does not have a historical data dictionary, generating a data dictionary of the data module based on each data object, and associating the data dictionary with the data module.
Optionally, in the foregoing method, the updating the historical data dictionary based on each data object includes:
for each data object, determining whether a historical data object corresponding to the data object exists in the historical data dictionary;
if the historical data dictionary has the historical data object corresponding to the data object, updating the data of the historical data object corresponding to the data object in the historical data dictionary based on the characteristic information of the data object;
and if the historical data dictionary does not have the historical data object corresponding to the data object, adding the data object to the historical data dictionary.
The method described above, optionally, further includes:
determining a data model to which the data module belongs;
acquiring each data dictionary corresponding to the data model, and combining the data dictionaries corresponding to the data model to obtain an overall data dictionary corresponding to the data model;
and encrypting the overall data dictionary and the data model, and compiling the encrypted overall data dictionary and the data model to obtain a source code corresponding to the data model.
A second aspect of the present application discloses a device for generating a data dictionary, including:
the first determining unit is used for determining a data module needing to create a data dictionary;
the scanning unit is used for scanning the bottom file of the data module to acquire each variable of the data module;
the processing unit is used for carrying out standardized processing on the attribute information of each variable to obtain each standard variable;
the extracting unit is used for extracting the characteristic information of each standard variable and creating a data object of each standard variable based on the characteristic information of each standard variable;
and the obtaining unit is used for obtaining the data dictionary of the data module based on the data object of each standard variable.
The above apparatus, optionally, the processing unit includes:
an obtaining subunit, configured to obtain attribute information of each of the variables;
a judging subunit, configured to, for each of the variables, judge whether the variable is a normative variable based on attribute information of the variable;
the first determining subunit is used for determining the variable as a standard variable if the variable is a standard variable;
and the correcting subunit is used for correcting the attribute information of the variable based on a preset correction rule if the variable is not the standard variable, and determining the variable as the standard variable after obtaining the corrected attribute information.
The above apparatus, optionally, the obtaining unit includes:
the second determining subunit is used for determining whether the historical data dictionary exists in the data module;
the updating subunit is configured to update the historical data dictionary based on each data object if the data module has the historical data dictionary, and use the updated data dictionary as the data dictionary of the data module;
and the generation subunit is configured to generate a data dictionary of the data module based on each data object and associate the data dictionary with the data module if the data module does not have a historical data dictionary.
The above apparatus, optionally, the update subunit includes:
a determining module, configured to determine, for each data object, whether a history data object corresponding to the data object exists in the history data dictionary;
the updating module is used for updating the data of the historical data object corresponding to the data object in the historical data dictionary based on the characteristic information of the data object if the historical data object corresponding to the data object exists in the historical data dictionary;
and the adding module is used for adding the data object into the historical data dictionary if the historical data object corresponding to the data object does not exist in the historical data dictionary.
The above apparatus, optionally, further comprises:
the second determining unit is used for determining the data model to which the data module belongs;
the acquisition unit is used for acquiring each data dictionary corresponding to the data model and combining the data dictionaries corresponding to the data model to obtain an overall data dictionary corresponding to the data model;
and the encryption unit is used for encrypting the overall data dictionary and the data model and compiling the encrypted overall data dictionary and the data model to obtain a source code corresponding to the data model.
A third aspect of the present application discloses a storage medium, where the storage medium includes stored instructions, and when the instructions are executed, a device on which the storage medium is located is controlled to execute the method for generating a data dictionary.
A fourth aspect of the present application discloses an electronic device comprising a memory, and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by the one or more processors to perform the method for generating a data dictionary as described above.
Compared with the prior art, the invention has the following advantages:
the invention provides a method and a device for generating a data dictionary, a storage medium and electronic equipment, wherein the method comprises the following steps: determining a data module needing to create a data dictionary, and scanning a bottom file of the data module to obtain each variable of the data module; carrying out standardization processing on the attribute information of each variable to obtain each standard variable; extracting the characteristic information of each standard variable, and creating a data object of each standard variable based on the characteristic information of each standard variable; and obtaining a data dictionary of the data module based on the data objects of the standard variables. When the data dictionary of the data module is created, all variables of the data module can be obtained by scanning a bottom file of the data module, after attribute information of all the variables is subjected to standardization processing, all the standard variables are obtained, and after a data object is created for each standard variable, the data dictionary is obtained based on all the data objects, so that the process of generating the data dictionary is effectively shortened, the process of generating the data dictionary is simpler and more convenient, the consumed time is shorter, and the working efficiency of programmers is effectively improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
In this application, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
The invention is operational with numerous general purpose or special purpose computing device environments or configurations. For example: the invention also provides a method for generating the data dictionary, which comprises the steps of generating the corresponding data dictionary for an embedded software product based on the development of software by MBD tools such as Simulink/Stateflow and the like.
Referring to fig. 1, a flowchart of a method for generating a data dictionary according to an embodiment of the present invention is specifically described as follows:
s101, determining a data module needing to create a data dictionary.
In the method provided by the embodiment of the invention, when the data module of the data dictionary required to be created is determined, the data module of the data dictionary required to be created can be accurately positioned by using the interface, and the requirement indicates that the data module is a data model constructed by using Matlab or one of the data modules in Simulink.
S102, scanning the bottom files of the data module to obtain all the variables of the data module.
It should be noted that each data module has a corresponding bottom file, and the bottom files of the data blocks are scanned from left to right by using a lexical analysis technology, so that attribute information of each variable in the data module is identified, and each variable of the data module is obtained.
S103, carrying out standardization processing on the attribute information of each variable to obtain each standard variable.
In order to establish the normalization and fluency of the data dictionary subsequently, the attribute information of each variable needs to be normalized so as to obtain a standard variable, and it should be noted that the attribute information includes information such as variable name description, scope, data type, color, parameter configuration, location, hierarchy, and naming.
The method is characterized in that the standard and the specification of a standard variable are preset, and the scope, the function, the type and the like of the variable have corresponding standard definitions and names; different scopes, different functions, and different types of variables have different specifications in terms of usage, location, hierarchy, parameter configuration, and color.
Referring to fig. 2, a flowchart of a method for performing normalization processing on attribute information of a variable to obtain a standard variable according to another embodiment of the present invention is specifically described as follows:
s201, acquiring attribute information of each variable.
S202, judging whether the variable is a standard variable or not based on attribute information of the variable for each variable; if the variable is a specification variable, executing S203; if the variable is not a specification variable, S204 is executed.
When judging whether the variable is a standard variable, judging whether the variable name description, the scope, the data type and other information in the attribute information are correct, and if so, determining that the variable is the standard variable; and if the incorrect information exists, determining that the variable is not a standard variable, and each item of information has a corresponding judgment standard. Illustratively, the attribute information of the variable a is: variable _ A1_ int8, wherein Variable is Variable name description, A1 is scope, int8 is data type; illustratively, the canonical scope set is { A, B, C, D }, and the scope in variable a does not belong to the canonical scope set, and the variable name description and data type in variable a are both correct, so variable a is not a canonical variable. Illustratively, the attribute information of the variable b is: variable _ B _ int8, the scope in Variable a belongs to a canonical scope set, so Variable B is a canonical Variable.
And S203, determining the variable as a standard variable.
Continuing with the example illustration in S202, variable b is determined as the standard variable.
S204, modifying the attribute information of the variable based on a preset modification rule, and determining the variable as a standard variable after obtaining the modified attribute information.
It should be noted that, there are different correction rules for different information items in the attribute information, and as exemplarily described in S202, when the attribute information of the Variable a is corrected, the scope in the attribute information of the Variable a is changed to a, that is, the modified attribute information of the Variable a is Variable _ a _ int8, at this time, the Variable a may be determined as the standard Variable.
In the method provided by the embodiment of the invention, after the variable is determined not to be the standard variable, the variable can be corrected, so that the accuracy of the created data dictionary can be improved.
And S104, extracting the characteristic information of each standard variable, and creating a data object of each standard variable based on the characteristic information of each standard variable.
In the method provided by the embodiment of the present invention, the characteristic information of the standard variable includes, but is not limited to, the position, length, meaning, and the like of the variable.
It should be noted that, when determining the feature information of the standard variable, a character string recognition algorithm may be used to recognize the attribute information of the standard variable, so as to obtain the feature information of the standard variable from the attribute information; it should be noted that the variable name description in the attribute information is used for understanding the meaning of the variable, and the scope is used for determining the valid range of the variable when the code is generated; the data type is used for the simulation of the data module and the type definition of variables in the code.
And after the characteristic information of the standard variable is obtained, creating a data object of the standard variable according to the characteristic information of the standard variable.
And S105, obtaining a data dictionary of the data module based on the data objects of the standard variables.
The process of creating the data dictionary has universality, a component can be created for the method provided by the invention, the component is integrated in a tool kit of a Matlab platform, a GUI window is established, and the automatic generation of the data dictionary is realized by calling the component.
Referring to fig. 3, a flowchart of a method for obtaining a data dictionary of a data module based on data objects of each standard variable according to another embodiment of the present invention is specifically described as follows:
s301, determining whether a historical data dictionary exists in the data module; if the data module has a historical data dictionary, executing S302; if the data module does not have the data dictionary, S303 is executed.
When the data dictionary of the data module is obtained based on the data object of each standard variable, it may be determined whether the data module has a history data dictionary, where the history data dictionary is a data dictionary already created by the data module.
When determining whether the historical data dictionary exists in the data module, determining whether the data dictionary corresponding to the module identifier exists in a dictionary database according to the module identifier of the data module, and if the corresponding data dictionary exists, determining the data dictionary corresponding to the module identifier as the historical data dictionary of the data module; and if the corresponding data dictionary does not exist, determining that the historical data dictionary does not exist in the data module.
Optionally, it may also be determined whether the data module has a created data dictionary record, and if the data module has the created data dictionary record, the data dictionary corresponding to the latest data dictionary record is used as the historical data dictionary of the data module; and if the data module does not have the record of creating the data dictionary, determining that the data module does not have the historical data dictionary.
And S302, updating the historical data dictionary based on each data object, and taking the updated data dictionary as the data dictionary of the data module.
And under the condition that the data module has a historical data dictionary, performing root updating on the historical data dictionary according to each data object.
Referring to fig. 4, a flowchart of a method for updating a history data dictionary according to another embodiment of the present invention is specifically described as follows:
s401, determining whether a historical data object corresponding to the data object exists in a historical data dictionary or not for each data object; if the historical data dictionary has the historical data object corresponding to the data object, executing S402; if there is no history data object corresponding to the data object in the history data dictionary, S403 is executed.
S402, updating the data of the historical data object corresponding to the data object in the historical data dictionary based on the characteristic information of the data object.
And updating the characteristic information of the data object into the historical data dictionary by calling a bottom API (application programming interface) of the data module, specifically, updating the characteristic information of the historical data object in the historical data dictionary based on the characteristic information of the data object.
And S403, adding the data object into the historical data dictionary.
And calling a bottom API (application programming interface) of the data module, and specifically, accessing the bottom API of the Simulink through Matlab or Python scripts so as to add the data object to the historical data dictionary.
In the method provided by the embodiment of the invention, the data in the historical data dictionary can be quickly updated by calling the bottom API, so that the iterative update of the data dictionary is realized, the updated data dictionary does not need to be associated with the data module again, and the existing data dictionary is not repeatedly created but the data objects in the existing data dictionary are directly modified and newly added, so that the process of creating the data dictionary can be shortened, and the efficiency of creating the data dictionary is improved. By calling the API interface, the automatic creation of the data dictionary and the automatic addition of the data objects are realized, the generation process is more accurate under the conditions of large number of data dictionaries and complex types, and the data dictionaries can be created in batches.
S303, generating a data dictionary of the data module based on each data object, and associating the data dictionary with the data module.
In the method provided by the embodiment of the present invention, under the condition that the data module has no history data dictionary, each data object is packed as an element, so as to generate a data dictionary, and the generated data dictionary is associated with the data module.
In the method provided by the embodiment of the invention, a data module of a data dictionary is determined to be created, and a bottom file of the data module is scanned to obtain each variable of the data module; normalizing the attribute information of each variable to obtain each standard variable; extracting the characteristic information of each standard variable, and creating a data object of each standard variable based on the characteristic information of each standard variable; and obtaining a data dictionary of the data module based on the data objects of the standard variables. According to the method, when the data dictionary of the data module is created, all variables of the data module can be obtained by scanning the bottom file of the data module, after the attribute information of each variable is subjected to standardization processing, all standard variables are obtained, and after the data object is created for each standard variable, the data dictionary is obtained based on all data objects, so that the process of generating the data dictionary is effectively shortened, the process of generating the data dictionary is simpler and more convenient, the time spent is shorter, and the working efficiency of programmers is effectively improved.
In the method provided by the embodiment of the present invention, the data model is composed of a plurality of data modules, and after the data dictionary of the data module is obtained, a data dictionary corresponding to the data model and a corresponding code may be constructed, and a specific process may refer to fig. 5, and the following description is provided:
s501, determining a data model to which a data module belongs;
s502, acquiring each data dictionary corresponding to the data model, and combining the data dictionaries corresponding to the data models to obtain a total data dictionary corresponding to the data model;
s503, encrypting the overall data dictionary and the data model, and compiling the encrypted overall data dictionary and the encrypted data model to obtain a source code corresponding to the data model.
It should be noted that the data model may be an embedded software model created by using Matlab, and the data model is composed of a plurality of data modules, where the plurality of data modules include a main data module and a plurality of reference data modules, and it should be noted that there may be a hierarchy in each data module.
When the data dictionaries are combined, the data dictionaries of the main data module and the reference data modules are respectively identified through the hierarchical calling of the model, and the data dictionaries are combined into one data dictionary, namely the overall data dictionary.
Preferably, the purpose of using the encryption algorithm is to prevent others from reversing when the model and the dictionary are delivered externally, so that the technology is protected from being leaked.
Preferably, the source code is generated for compiling and integrating with codes of other modules; code may be automatically generated by a plug-in to the MBD tool and corresponding software may be integrated with source code corresponding to the data model to bring the data model and the global data dictionary into use.
In the method provided by the embodiment of the invention, the data dictionaries are combined into one data dictionary, so that the corresponding overall data dictionary can be established for the data model, the process is simple and convenient, and a convenient mode is provided for establishing the corresponding data dictionary for the data model.
In the method provided by the embodiment of the invention, on the premise that the data model meets the defined specifications and standards, the data dictionary of the data module can be automatically generated through a Matlab command window, a right-click menu or a single GUI interface. Furthermore, the method provided by the invention can simultaneously generate the data dictionaries of all the data modules in one data model, can also generate the data dictionaries of partial data modules, and can also generate a data dictionary of a certain attribute classification. If the data is generated for the first time, a data dictionary is newly established and a data module is associated; if the data dictionary is generated, the generated data dictionary is linked to the existing data dictionary, iterative updating operations such as modification, object creation and the like are completed, and the process of generating the data dictionary is simpler, more convenient and faster. The embedded software development based on the model is more and more widely applied, and repeated iterative optimization is needed in the development process, so that the workload of defining and maintaining the data dictionary is huge. The invention can reduce the workload of defining and maintaining the data dictionary, reduce repeated work and improve the working efficiency.
Corresponding to the method shown in fig. 1, an embodiment of the present invention provides a data dictionary generating apparatus, which is used for supporting the implementation of the method shown in fig. 1 in real life, and the apparatus may be arranged in a computer terminal, and with reference to fig. 6, a structural intention of the data dictionary generating apparatus provided in the embodiment of the present invention is specifically described as follows:
a first determining unit 601, configured to determine a data module for which a data dictionary needs to be created;
a scanning unit 602, configured to scan a bottom file of the data module to obtain each variable of the data module;
the processing unit 603 is configured to perform normalization processing on the attribute information of each variable to obtain each standard variable;
an extracting unit 604, configured to extract feature information of each of the standard variables, and create a data object of each of the standard variables based on the feature information of each of the standard variables;
an obtaining unit 605, configured to obtain a data dictionary of the data module based on the data object of each standard variable.
In the device provided by the embodiment of the invention, a data module of a data dictionary is determined to be created, and a bottom file of the data module is scanned to obtain each variable of the data module; normalizing the attribute information of each variable to obtain each standard variable; extracting the characteristic information of each standard variable, and creating a data object of each standard variable based on the characteristic information of each standard variable; and obtaining a data dictionary of the data module based on the data objects of the standard variables. According to the method and the device, when the data dictionary of the data module is created, all variables of the data module can be obtained by scanning the bottom file of the data module, after the attribute information of each variable is subjected to standardization processing, all standard variables are obtained, and after the data object is created for each standard variable, the data dictionary is obtained based on all data objects, so that the flow of generating the data dictionary is effectively shortened, the process of generating the data dictionary is simplified, the time spent is shorter, and the working efficiency of programmers is effectively improved.
In the apparatus provided in the embodiment of the present invention, the processing unit 603 in the apparatus may be configured to:
the acquiring subunit is used for acquiring the attribute information of each variable;
a judging subunit, configured to, for each of the variables, judge whether the variable is a normative variable based on attribute information of the variable;
the first determining subunit is used for determining the variable as a standard variable if the variable is a standard variable;
and the correcting subunit is used for correcting the attribute information of the variable based on a preset correction rule if the variable is not a standard variable, and determining the variable as the standard variable after obtaining the corrected attribute information.
In the apparatus provided in the embodiment of the present invention, the obtaining unit 605 in the apparatus may be configured to:
the second determining subunit is used for determining whether the data module has a historical data dictionary;
the updating subunit is configured to update the historical data dictionary based on each data object if the data module has the historical data dictionary, and use the updated data dictionary as the data dictionary of the data module;
and the generation subunit is configured to generate a data dictionary of the data module based on each data object and associate the data dictionary with the data module if the data module does not have a historical data dictionary.
In the apparatus provided in the embodiment of the present invention, the update subunit in the apparatus may be configured to:
a determining module, configured to determine, for each data object, whether a history data object corresponding to the data object exists in the history data dictionary;
the updating module is used for updating the data of the historical data object corresponding to the data object in the historical data dictionary based on the characteristic information of the data object if the historical data object corresponding to the data object exists in the historical data dictionary;
and the adding module is used for adding the data object into the historical data dictionary if the historical data object corresponding to the data object does not exist in the historical data dictionary.
In the apparatus provided in the embodiment of the present invention, the apparatus may be further configured to:
the second determining unit is used for determining the data model to which the data module belongs;
the acquisition unit is used for acquiring each data dictionary corresponding to the data model and combining the data dictionaries corresponding to the data model to obtain an overall data dictionary corresponding to the data model;
and the encryption unit is used for encrypting the overall data dictionary and the data model and compiling the encrypted overall data dictionary and the data model to obtain a source code corresponding to the data model.
An embodiment of the present invention further provides a storage medium, where the storage medium includes a stored instruction, where when the instruction runs, a device where the storage medium is located is controlled to perform the following operations:
determining a data module needing to create a data dictionary;
scanning a bottom file of the data module to obtain all variables of the data module;
normalizing the attribute information of each variable to obtain each standard variable;
extracting the characteristic information of each standard variable, and creating a data object of each standard variable based on the characteristic information of each standard variable;
and obtaining a data dictionary of the data module based on the data objects of the standard variables.
An electronic device is provided in an embodiment of the present invention, and its structural diagram is shown in fig. 7, which specifically includes a memory 701 and one or more instructions 702, where the one or more instructions 702 are stored in the memory 701, and are configured to be executed by one or more processors 703 to perform the following operations according to the one or more instructions 702:
determining a data module needing to create a data dictionary;
scanning a bottom file of the data module to acquire each variable of the data module;
carrying out standardization processing on the attribute information of each variable to obtain each standard variable;
extracting the characteristic information of each standard variable, and creating a data object of each standard variable based on the characteristic information of each standard variable;
and obtaining a data dictionary of the data module based on the data objects of the standard variables.
The specific implementation procedures and derivatives thereof of the above embodiments are within the scope of the present invention.
All the embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, the system or system embodiments, which are substantially similar to the method embodiments, are described in a relatively simple manner, and reference may be made to some descriptions of the method embodiments for relevant points. The above-described system and system embodiments are only illustrative, wherein the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.