Method and device for generating functional simulation unit of simulation platform
Through the combination of code generation templates and simulation models, multi-dimensional data variables are processed, and descriptive files and dynamic link library files that comply with FMI standards are generated, which solves the problem of unclear processing of multi-dimensional data variables in the FMU generation process in the existing technology, and improves the The integration and standardization of simulation models achieve compatibility of different simulation environments.
Patent Information
- Application Number
- CN202411255246.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-09-09
AI Technical Summary
When the prior art generates FMUs that comply with the FMI standard, the processing of multi-dimensional data variables is unclear, resulting in information differences between simulation model designers and users, affecting the integration and standardization of the simulation model, and increasing the burden on users.
Determine descriptive files and dynamic link library files through code generation template files and simulation models, perform structure matching and flattening operations, generate descriptive files and dynamic link library files that comply with FMI standards, and build functional simulation units to realize the simulation platform interaction between.
Improves the integration and standardization of the functional simulation unit distribution process, reduces the burden on users, and ensures the compatibility and interoperability of FMUs in different simulation environments.
Smart Images

Figure CN118760423B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method and device for generating a functional simulation unit of a simulation platform. Background Art
[0002] FMI (Functional Mock-up Interface) is the latest standard and interface for mechatronics design. In order to solve the interaction problems in different simulation programs and the need for collaborative work in simulation environments of different suppliers, this unified standard has gradually been adopted in a wide range of fields.
[0003] FMI / FMU (Functional Mock-up Unit) is a tool used to support the interaction and joint simulation of dynamic models. FMU (Functional Mock-up Unit) files are simulation model files created in accordance with the FMI (Functional Mock-up Interface) standard. In the FMU distribution process, different modeling software is involved. How to generate FMU (Functional Mock-up Unit) that meets the requirements of the FMI (Functional Mock-up Interface) standard is a factor that needs to be considered.
[0004] In Simulink (graphical simulation platform), the solution is generally to encapsulate C code into a dynamic link library file based on the FMI (functional simulation interface) standard interface, generate a descriptive file corresponding to the C code based on a preset descriptive template, and package the dynamic link library file and the descriptive file to obtain FMU. However, this method does not clearly define the processing method for models with multidimensional data variables, and only provides dynamic link library files and descriptive files in FMU (functional simulation unit). During the distribution of FMU (functional simulation unit), there is still an information gap between the designer of the simulation model and the user of the simulation model, which will lead to limitations in the control and observation of the simulation model parameters by the user of the simulation model, thereby affecting the semi-physical simulation using the simulation model and increasing the burden on the user. It cannot meet the requirements of the simulation platform for the integration and standardization of FMU (functional simulation unit). Summary of the invention
[0005] In view of the problems in the prior art, the present application provides a method and device for generating functional simulation units of a simulation platform, which can improve the integration and standardization in the distribution process of functional simulation units.
[0006] In order to solve at least one of the above problems, the present application provides the following technical solutions:
[0007] In a first aspect, the present application provides a method for generating a simulation platform function simulation unit, comprising:
[0008] Adding a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file;
[0009] Determine corresponding key variable information and model header file according to the code generation template file and the preset simulation model, perform structure matching operation according to the key variable information and the model header file, determine corresponding multidimensional array of key variable information, and determine corresponding descriptive file and dynamic link library file according to the code generation template file and the multidimensional array of key variable information;
[0010] Perform parameter matching operation on the model header file according to the model parameters of the preset simulation model to determine the corresponding model parameter variables, perform hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables to determine the corresponding hierarchical information file; obtain the port information of the preset simulation model, perform parsing operation on the port information according to the preset parsing rules to determine the corresponding data protocol file; determine the corresponding resource file according to the hierarchical information file and the data protocol file;
[0011] A function simulation unit construction operation is performed according to the descriptive file, the dynamic link library file and the resource file, a corresponding function simulation unit is determined, and a simulation program interaction operation between simulation platforms is performed according to the function simulation unit.
[0012] Furthermore, the determining corresponding key variable information and model header file according to the code generation template file and the preset simulation model includes:
[0013] Performing a key variable information extraction operation on the implementation workshop file in the code generation template file to determine corresponding key variable information, wherein the key variable information includes at least one of output information, output information and parameter information;
[0014] The corresponding model header file is determined according to the code generation template and the model configuration of the preset simulation model.
[0015] Furthermore, performing a structure matching operation according to the key variable information and the model header file to determine a corresponding multidimensional array of key variable information includes:
[0016] Perform a structure matching operation according to the key variable information and the model header file to determine a corresponding key variable information structure;
[0017] A multidimensional array extraction operation is performed on the key variable information structure to determine a corresponding multidimensional array of key variable information.
[0018] Further, the determining of the corresponding descriptive file and dynamic link library file according to the code generation template file and the key variable information multidimensional array includes:
[0019] Performing a traversal and flattening operation on the multidimensional array of key variable information according to the preset function simulation interface wrapper function to determine a corresponding one-dimensional array of key variable information;
[0020] The corresponding descriptive file and dynamic link library file are determined according to the code generation template file and the one-dimensional array of key variable information.
[0021] Further, the determining of the corresponding descriptive file and dynamic link library file according to the code generation template file and the one-dimensional array of key variable information includes:
[0022] Determine the corresponding dynamic link library file according to the preset original code generation template file and the one-dimensional array of key variable information;
[0023] The corresponding descriptive file is determined according to the preset original code generation template file, the preset descriptive file generation algorithm and the one-dimensional array of key variable information.
[0024] Further, the generating a template file according to the preset original code, the preset descriptive file generating algorithm and the one-dimensional array of key variable information to determine the corresponding descriptive file includes:
[0025] Performing a field matching operation on the one-dimensional array of key variable information according to the preset descriptive file generation algorithm to determine a corresponding unique field identifier;
[0026] A corresponding descriptive file is determined according to the unique field identifier and the preset original code generation template file.
[0027] Furthermore, performing a hierarchical parameter adding operation according to a preset iteration rule and the model parameter variable to determine a corresponding hierarchical information file includes:
[0028] Performing a hierarchical parameter adding operation on the root variable in the model parameter variable to determine the corresponding root level;
[0029] A hierarchical structure traversal operation is performed according to the root level and preset iterative traversal rules to determine a corresponding hierarchical information file.
[0030] In a second aspect, the present application provides a simulation platform function simulation unit generation device, comprising:
[0031] A code generation template generating device is used to add a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file;
[0032] A dynamic link library and description file generating device, used to determine the corresponding key variable information and model header file according to the code generation template file and the preset simulation model, perform a structure matching operation according to the key variable information and the model header file, determine the corresponding key variable information multidimensional array, and determine the corresponding descriptive file and dynamic link library file according to the code generation template file and the key variable information multidimensional array;
[0033] A resource file generating device is used to perform a parameter matching operation on the model header file according to the model parameters of the preset simulation model, determine the corresponding model parameter variables, perform a hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables, and determine the corresponding hierarchical information file; obtain the port information of the preset simulation model, perform a parsing operation on the port information according to the preset parsing rules, and determine the corresponding data protocol file; determine the corresponding resource file according to the hierarchical information file and the data protocol file;
[0034] The function simulation unit construction device is used to perform function simulation unit construction operations according to the descriptive file, the dynamic link library file and the resource file, determine the corresponding function simulation unit, and perform simulation program interaction between simulation platforms according to the function simulation unit.
[0035] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the simulation platform function simulation unit generation method when executing the program.
[0036] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the simulation platform function simulation unit generation method.
[0037] In a fifth aspect, the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the simulation platform function simulation unit generation method.
[0038] It can be seen from the above technical scheme that the present application provides a method and device for generating a functional simulation unit of a simulation platform, which determines the corresponding descriptive file and dynamic link library file through a code generation template file and a simulation model; performs parameter matching operation on the model header file according to the model parameters of the simulation model, and determines the corresponding hierarchical information file according to preset iteration rules and model parameter variables; obtains the port information of the preset simulation model, parses the port information according to the parsing rules, and determines the corresponding data protocol file; determines the corresponding resource file according to the hierarchical information file and the data protocol file; performs a functional simulation unit construction operation according to the descriptive file, the dynamic link library file and the resource file, determines the corresponding functional simulation unit, and performs simulation program interaction operations between simulation platforms according to the functional simulation unit, thereby improving the integration and standardization of the functional simulation unit distribution process. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 This is one of the flowcharts of the method for generating a simulation platform function simulation unit in an embodiment of the present application;
[0041] Figure 2 This is a second flow chart of a method for generating a simulation platform function simulation unit in an embodiment of the present application;
[0042] Figure 3 The third flowchart of the method for generating a simulation platform function simulation unit in the embodiment of the present application;
[0043] Figure 4 This is a fourth flow chart of a method for generating a simulation platform function simulation unit in an embodiment of the present application;
[0044] Figure 5 This is a fifth flow chart of a method for generating a simulation platform function simulation unit in an embodiment of the present application;
[0045] Figure 6 This is a sixth flow chart of a method for generating a simulation platform function simulation unit in an embodiment of the present application;
[0046] Figure 7 FIG7 is a flowchart of a method for generating a simulation platform function simulation unit in an embodiment of the present application;
[0047] Figure 8A structural diagram of a simulation platform function simulation unit generating device in an embodiment of the present application;
[0048] Fig. 9 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application.
[0049] Reference numerals:
[0050] Electronic device 9600, central processing unit 9100, memory 9140, communication module 9110, input unit 9120, audio processor 9130, display 9160, power supply 9170, buffer memory 9141, application / function storage unit 9142, data storage unit 9143, driver program storage unit 9144, antenna 9111, speaker 9131, microphone 9132. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0052] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0053] Considering that the existing FMU generates models for multidimensional data variables without a clear processing method, and only provides dynamic link library files and descriptive files in the FMU (functional simulation unit), there is still an information gap between the designer of the simulation model and the user of the simulation model during the distribution of the FMU (functional simulation unit), which will lead to limitations in the control and observation of the simulation model parameters by the user of the simulation model, thereby affecting the use of the simulation model for semi-physical simulation and increasing the burden on the user. The present application provides a method and device for generating a functional simulation unit of a simulation platform, which determines the corresponding descriptive file and dynamic link library file through a code generation template file and a simulation model; performs parameter matching operation on a model header file according to model parameters of the simulation model, and determines the corresponding hierarchical information file according to preset iteration rules and model parameter variables; obtains port information of a preset simulation model, performs parsing operation on the port information according to parsing rules, and determines the corresponding data protocol file; determines the corresponding resource file according to the hierarchical information file and the data protocol file; performs a functional simulation unit construction operation according to the descriptive file, the dynamic link library file and the resource file, determines the corresponding functional simulation unit, and performs simulation program interaction operation between simulation platforms according to the functional simulation unit, thereby improving the integration and standardization in the distribution process of the functional simulation unit.
[0054] In order to improve the integration and standardization of the function simulation unit distribution process, the present application provides an embodiment of a method for generating a function simulation unit of a simulation platform, see Figure 1 The simulation platform function simulation unit generation method specifically includes the following contents:
[0055] Step S101: adding a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file;
[0056] Optionally, in this embodiment, the purpose of this step is to create a code generation template framework so that an FMU (functional simulation unit) that complies with the FMI standard can be generated directly from the simulation model designed by Simulink according to the template file, without the need to manually package the dynamic link library files and descriptive files in steps to generate the FMU.
[0057] Optionally, in this embodiment, the technical means of this step is to modify the model code generation template file grt.tlc (general real-time target), add descriptive file generation and FMI wrapper (functional simulation interface wrapper function) functions, and form grtfmi.tlc (general real-time target functional simulation interface).
[0058] Optionally, in this embodiment, the code generation template file is a template file for code generation, which can convert the designed model into executable code, including the various components of the model and the interactions between them. This embodiment is mainly based on the existing model code generation template file (grt.tlc) of Simulink, and is modified and extended to add descriptive file generation and FMI wrapper functions to form a new template file (such as grtfmi.tlc). Among them:
[0059] The descriptive file generation algorithm is used to generate the corresponding descriptive file.
[0060] The FMI wrapper function is a functional mock interface wrapper function, which is a tool or library for encapsulating the mock interface of C code, so that the C code can comply with the FMI (Functional Mock-up Interface) standard.
[0061] It is understandable that the prior art generally encapsulates C code into a dynamic link library file based on the FMI (Functional Simulation Interface) standard interface, generates a descriptive file corresponding to the C code based on a preset descriptive template, and packages the dynamic link library file and the descriptive file to obtain FMU.
[0062] In the prior art, the grt.tlc template file is used to control the process of converting Simulink models into C code, but it does not directly implement the FMI interface. Therefore, the generated C code cannot meet the FMI standard. The FMI standard interface usually needs to be met through a specific implementation, which involves encapsulating the C code to ensure that it can be compatible with the FMI standard as an FMU. Therefore, for the designers of simulation models, they still need to pay attention to how to implement FMU (Functional Simulation Unit) through C code.
[0063] The above-mentioned prior art only describes the process of how to generate FMU (Functional Simulation Unit) using C code, and the generation process still needs to pay attention to its specific implementation rules. How to directly generate FMU (Functional Simulation Unit) from Simulink does not need to consider the specific implementation operation of its FMI standard interface, and the automation process has not yet been realized. Therefore, the improvement of the template file in this embodiment can realize the automatic generation of FMU based on the code generation template file. For the designer of the simulation model, there is no need to pay attention to how to implement FMU (Functional Simulation Unit) through C code, but only need to pay attention to the model design itself.
[0064] The code generation template file constructed in this step is the basis for all subsequent steps. It contains all the rules for generating FMU files. Subsequent code processing is all based on the rules in the code generation framework. The new template not only contains the original code generation logic, but also adds descriptive file generation and FMI wrapper functions to ensure that the generated code can be directly used to create FMU and support the processing of multi-dimensional data variables.
[0065] Step S102: determining corresponding key variable information and model header files according to the code generation template file and the preset simulation model, performing a structure matching operation according to the key variable information and the model header file, determining corresponding multidimensional arrays of key variable information, and determining corresponding descriptive files and dynamic link library files according to the code generation template file and the multidimensional arrays of key variable information;
[0066] Optionally, in this embodiment, the purpose of this step is to automatically generate the descriptive files and dynamic link library files required for packaging FMU according to the rules in the code generation template framework, wherein the code generation template also adds a processing method for multidimensional data variables.
[0067] Optionally, in this embodiment, the technical means of this step is to use steps such as extracting variable group names, matching structures, flattening multidimensional arrays, and generating descriptive files to reduce the burden on users.
[0068] Optionally, in this embodiment, this embodiment describes a process of constructing a descriptive file and a dynamic link library file based on a code generation template file.
[0069] Optionally, in this embodiment, corresponding key variable information and model header file are determined according to the code generation template file and the preset simulation model.
[0070] Specifically, key variable information and model header files are part of the code generation process. Among them:
[0071] The key variable information is extracted from the modelname.rtw file, which is generated by the Real-Time Workshop of the Simulink simulation platform and is a model file generated during the code generation process. The key variable information includes modelname_P (parameter variable), modelname_U (input variable), modelname_Y (output variable), etc.
[0072] Model header file, the Simulink simulation platform will generate the corresponding source code and header file according to the selected code generation template and the model configuration information. The header file (modelname.h) contains model variables, parameters, and possible structure definitions, which are the basis for the model to be implemented at the C code level.
[0073] Optionally, in this embodiment, a structure matching operation is performed based on the key variable information and the model header file to determine a corresponding multi-dimensional array of key variable information.
[0074] Specifically, first, we extract key variable group information from the model file generated by Simulink Real-Time Workshop, such as modelname_P (parameter variable), modelname_U (input variable), modelname_Y (output variable), etc., and match the corresponding structure in the generated model header file (modelname.h) so that we can process the multidimensional array in the structure later.
[0075] For example, suppose we have a Simulink model that has been generated into corresponding code and files through Real-Time Workshop. In this process, some key files are generated, including the model header file (modelname.h), which contains the declarations of variables and structures defined in the model.
[0076] In the modelname.h file, we see a structure definition similar to the following:
[0077] typedef struct {
[0078] real_T Param1; / / Assume this is a model parameter
[0079] real_T Param2; / / Another model parameter
[0080] / / ... there may be other parameters
[0081] } modelname_P; / / parameter structure
[0082] typedef struct {
[0083] real_T Input1
[10] ; / / Assume this is a 10-dimensional input array
[0084] real_T Input2; / / a scalar input
[0085] / / ... there may be other inputs
[0086] } modelname_U; / / Input structure
[0087] typedef struct {
[0088] real_T Output1; / / one output
[0089] real_T OutputArray[5][3]; / / A 5x3 two-dimensional output array
[0090] / / ... there may be other outputs
[0091] } modelname_Y; / / Output structure
[0092] The system automatically analyzes the modelname.h file and identifies these structure definitions. The system pays attention to modelname_P, modelname_U, and modelname_Y because these structure names correspond to parameter, input, and output variable groups in the Simulink model.
[0093] In the above operation, a key variable information structure is obtained through structure matching, and the key variable information structure includes declarations of variables and structures defined in the model.
[0094] Secondly, after matching the key variable information structure, it is necessary to extract the multidimensional array contained in the key variable information structure to prepare for the subsequent flattening of the multidimensional array.
[0095] It is understandable that the FMI (Functional Mock-up Interface) standard itself mainly supports scalar variables (i.e. one-dimensional variables) and does not directly support the direct interaction of multidimensional data variables. Therefore, when the Simulink model contains multidimensional arrays as input or output, these multidimensional arrays need to be converted to one-dimensional arrays before generating FMU in order to meet the requirements of the FMI standard.
[0096] Optionally, in this embodiment, corresponding descriptive files and dynamic link library files are determined based on the code generation template file and the key variable information multidimensional array.
[0097] Specifically, under the framework of the code generation template file, descriptive files and dynamic link library files can be constructed according to the extracted multi-dimensional array of key variable information.
[0098] First, the multidimensional array of key variable information is processed.
[0099] The code generation template file includes the original code generation logic, and also adds a descriptive file generation algorithm and FMI wrapper function. In the fmiwrapper.inc (functional simulation interface wrapper) in the code generation template file, the multidimensional array of key variable information is flattened into a one-dimensional array of key variable information (modelVariables) according to the row-major order traversal order.
[0100] The row priority ensures that all elements in the multidimensional array can be stored in a one-dimensional array in a certain order. During the flattening process, the FMI wrapper generates or modifies code to replace the references to the multidimensional data variables in the model with references to the flattened one-dimensional array.
[0101] For example, assuming that the Simulink model output structure modelname_Y in the above example contains a two-dimensional array OutputArray[5][3], then during the flattening process, this two-dimensional array will be converted to a one-dimensional array OutputArrayFlat
[15] (using row-first traversal order). The FMI wrapper will generate the corresponding code to manage this conversion process and describe OutputArrayFlat as a one-dimensional array variable in modelDescription.xml. In this way, when the FMU interacts with the external simulation environment, the value of this one-dimensional array variable can be correctly passed.
[0102] It is understandable that one-dimensional variables are more in line with the FMI standard, which is conducive to the subsequent generation of standard-compliant FMU files. This flat data structure is more easily accepted by different platforms and languages.
[0103] Secondly, generate the dynamic link library file.
[0104] The dynamic link library file is constructed by referencing the flattened one-dimensional array of key variable information and source code generated according to the original code generation logic.
[0105] When generating a dynamic link library, you need to implement various functions defined by the FMI standard, such as initialization, stepping, termination, etc. These functions need to be able to access the model's variables. By flattening the model variables into a one-dimensional array, these variables can be accessed and modified in these functions through simple indexing, thereby implementing the functions required by the FMI standard.
[0106] Understandably, flattened one-dimensional arrays make dynamic link libraries more versatile and compatible because they can be more easily called by different platforms and programming environments without being restricted by the multi-dimensional data structure in the original model.
[0107] Finally, generate the descriptive files.
[0108] The one-dimensional array of key variable information after referencing flattening is the basis for generating a descriptive file.
[0109] In fmiwrapper.inc (functional simulation interface wrapper), all key variables of the model (including parameters, inputs and outputs) have been flattened into a one-dimensional array (modelVariables).
[0110] The description file generation algorithm uses the variable information in the one-dimensional array to generate a unique field identifier for each variable as required by the FMI standard. This field identifier (usually a string or numeric ID) is used to uniquely identify and reference each variable in the model in the FMI interface.
[0111] The algorithm will traverse each element in the one-dimensional array and match it with the structure and variables defined in the model header file modelname.h, ensuring that each variable can be correctly mapped to the corresponding position in the one-dimensional array and assigned a unique field identifier.
[0112] Once each variable has been assigned a unique identifier, these identifiers can be used to generate a descriptive file, modelDescription.xml.
[0113] Next, a descriptive file is generated based on a template file and a unique field identifier generated according to the original code, wherein the template file includes the structure and format required to generate the descriptive file, and the algorithm fills in the placeholders in the template to generate a complete descriptive file.
[0114] Understandably, the purpose of this process is to ensure that each model variable has a clear, unique identity and is well documented in descriptive files, so that the FMU can be correctly identified and used in different simulation platforms. By automating this process, human errors can be reduced and the efficiency and accuracy of FMU generation can be improved.
[0115] Optionally, this embodiment as a whole includes the following steps:
[0116] 1. Modify the model code generation template file grt.tlc (general real-time target), add descriptive file generation and FMI wrapper functions to form grtfmi.tlc (general real-time target functional simulation interface);
[0117] 2. Extract the corresponding modelname_P, modelname_U, modelname_Y variable group names from modelname.rtw (Real-Time Workshop);
[0118] 3. According to the extracted variable group name, match the structure corresponding to the item in the generated modelname.h (model name);
[0119] 4. Flatten the multidimensional arrays corresponding to the modelname_P, modelname_U, and modelname_Y structures into a one-dimensional array of modelVariables (model variables) in the fmiwrapper.inc (functional simulation interface wrapper) according to the row-major order traversal order;
[0120] 5. The modelVariables one-dimensional array corresponds to the ScalarVariable described by the ModelVariables field in the descriptive file modelDescription.xml, and is given a unique identifier.
[0121] Through the above steps, the algorithm automatically generates dynamic link library files and descriptive files. The construction process is based on the one-dimensional array after flattening operation, which complies with the FMI standard and lays a solid foundation for the subsequent generation of FMU to be compatible with other simulation tools and environments.
[0122] Step S103: performing a parameter matching operation on the model header file according to the model parameters of the preset simulation model to determine the corresponding model parameter variables, performing a hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables to determine the corresponding hierarchical information file; obtaining the port information of the preset simulation model, performing a parsing operation on the port information according to the preset parsing rules to determine the corresponding data protocol file; determining the corresponding resource file according to the hierarchical information file and the data protocol file;
[0123] Optionally, in this embodiment, the purpose of this step is to attach an additional resource file in addition to the above-mentioned dynamic link library file and descriptive file to increase the flexibility and reusability of the strong FMU (functional simulation unit), reduce the burden on simulation model users, and avoid data errors caused by manual protocol parsing.
[0124] Optionally, in this embodiment, the technical means of this step is to achieve the above purpose by constructing a hierarchical information file and a data protocol file and attaching the two to the FMU (functional simulation unit).
[0125] Optionally, a parameter matching operation is performed on the model header file according to the model parameters of the preset simulation model to determine the corresponding model parameter variables, and a hierarchical parameter adding operation is performed according to the preset iteration rules and the model parameter variables to determine the corresponding hierarchical information file. This step is used to construct the hierarchical information file.
[0126] Specifically, first, the model-defined Parameters (variables) are identified from the header file (modelname.h) generated by the Simulink simulation platform according to the code generation template and the model configuration information. These variables may be defined through macro definitions, global variables declared with the extern keyword, or member variables in a structure.
[0127] It is worth noting that the Parameters identified in this step are different from the key variable information extracted from the model file generated by Simulink Real-Time Workshop in step S102. This Parameters information is limited to model parameter information, while the key variable information in step S102 includes not only model parameter information but also model input and output information.
[0128] Secondly, identify the root-level parameters in the model. Parameters may be organized in different levels. The root level is the highest level of parameters, without a parent, usually the top-level structure or variable, and combine their names with the level information to add layers and parameters.
[0129] In the first embodiment of this step, the prefix Parameters. is added before the root-level variable names to indicate that they belong to the parameter set of the model.
[0130] In the second embodiment of this step, the root level may not have an additional prefix.
[0131] Then, use recursive or iterative logic rules to traverse all levels in the model. For each level, match the structure variables first, then the non-structure variables at that level, until there are no more structure variables.
[0132] Finally, all the hierarchical information is integrated into a file that describes the hierarchical structure of the model, making it easier for users to understand and operate different parts of the model.
[0133] Optionally, for example, there is a model header file modelname.h that defines the parameters required by the model.
[0134] / / modelname.h
[0135] typedef struct { (structure definition)
[0136] double temperature;(temperature)
[0137] struct {
[0138] double pressure;(pressure)
[0139] double humidity;
[0140] environment;
[0141] } SensorData; (sensor)
[0142] extern double inputVoltage; (input voltage)
[0143] extern double outputSignal; (output signal)
[0144] In this example, temperature, pressure, humidity, input voltage, and output signal are parameter variable information, where:
[0145] inputVoltage and outputSignal are non-structure root-level variables. We add level prefixes to them and update them to Parameters.inputVoltage and Parameters.outputSignal, indicating that they are parameter collections.
[0146] In the above structure, we can observe that there is structure nesting, namely:
[0147] temperature belongs to the SensorData structure.
[0148] Double pressure and double humidity belong to the small structure of environment and the large structure of SensorData.
[0149] Under Rules, the prefix changes to:
[0150] SensorData.Parameters.temperature(temperature)
[0151] SensorData.environment.Parameters.double pressure
[0152] SensorData.environment.Parameters.double humidity
[0153] Finally, package the changed hierarchy information into a hierarchy information file and attach the file to the resources folder of the FMU (functional simulation unit).
[0154] It is understood that the purpose of this process is to ensure that the parameter structure of the model is clear and easy to exchange and use between different models and tools. In this way, the interoperability and reusability of the model can be ensured. The FMU generated in this way can be imported and used by other simulation tools or models to achieve model interoperability and integration.
[0155] Optionally, the port information of the preset simulation model is obtained, and the port information is parsed according to preset parsing rules to determine the corresponding data protocol file. This step is used to construct the data protocol file.
[0156] Specifically, this step involves the use of the RTSLink plug-in and SimuRTS.
[0157] First, the port information is the input port information and the output port information. In the simulation model, the input and output ports are the interfaces for the model to interact with the external environment. The input port receives external data, and the output port provides internal data for external use. All input and output ports need to be identified from the model definition.
[0158] Secondly, the input or output port may contain multi-dimensional arrays, for example, a two-dimensional array may represent the measured values at different times and under different conditions. These multi-dimensional arrays need to be parsed in order to be displayed correctly in the RTSLink plug-in. It is understood that the RTSLink plug-in allows users to define names for the elements in the multi-dimensional array, which helps to improve readability and ease of use, enabling users to refer to specific data elements by name instead of index.
[0159] The user can then define a name for each element of the array in the RTSLink plugin.
[0160] Finally, in the process of generating FMU, a data protocol file needs to be generated according to the element name defined by the user. It defines the data structure and name of the input and output ports, ensuring that the FMU can be correctly parsed and used in other simulation environments. This file is attached to the resources folder of the FMU (Functional Simulation Unit).
[0161] When the simulation is running, SimuRTS will load and parse these data protocol files, map the external input data to the input port of the FMU according to the definition in the file, and map the output port data of the FMU to the external output system. At the same time, these data will also be displayed in the front end of the SimuRTS interface in a user-friendly way so that users can monitor and analyze the simulation process.
[0162] It can be understood that this process can ensure the consistency and availability of the input and output ports of the simulation model in different simulation environments.
[0163] Optionally, this embodiment as a whole includes the following steps:
[0164] Generating a hierarchy information file includes the following steps:
[0165] 1. Match the Parameters (variables) contained in the simulation model from the generated modelname.h (model name);
[0166] 2. Find the root level, add the Parameters level to the variable name of the root variable, and use . to separate the level information from the variable name;
[0167] 3. Match the structure variables of the current level, and match the non-structure variables of the current level by iteration until there are no structure variables at the current level, and add the level parameter information separately with .;
[0168] 4. Finally, generate the corresponding hierarchical information file and attach it to the resources folder of the FMU (functional simulation unit).
[0169] Generating a data protocol file includes the following steps:
[0170] 1. Get all corresponding input and output ports from the simulation model;
[0171] 2. Parse the multidimensional arrays contained in the input and output ports and display them in the RTSLink plugin;
[0172] 3.RTSLink plugin accepts name definition for any element in a multidimensional array;
[0173] 4. During the generation of FMU (Functional Simulation Unit), the corresponding data protocol file will be generated according to the element name definition and attached to the resources folder of FMU (Functional Simulation Unit);
[0174] It is understandable that the data protocol file will be parsed in SimuRTS and directly correspond one-to-one with specific elements of the multidimensional array and displayed at the front end of the interface;
[0175] Step S104: constructing a functional simulation unit according to the descriptive file, the dynamic link library file and the resource file, determining a corresponding functional simulation unit, and performing simulation program interaction operations between simulation platforms according to the functional simulation unit.
[0176] Optionally, this step integrates the files of the above steps S102 and S103.
[0177] Specifically, in step S102, a descriptive file is obtained, which describes the model attributes, variables, interfaces and behaviors of the FMU in detail. This file is the core of the FMU and defines the basic information of the model and how to interact with other models or simulation environments.
[0178] In step S102, a dynamic link library is obtained, which is a binary file that implements the FMI specification and contains the calculation logic of the model. It implements interfaces such as initialization, operation and termination of the model.
[0179] In step S103, a resource file is obtained, which includes other files required by the model including data protocols and hierarchy information. These files are placed in the resources folder of the FMU.
[0180] Finally, package the descriptive files, dynamic link library files and resource folders together into a single file or directory structure. This packaged file or directory is FMU.
[0181] Based on the created FMU, the simulation model can be reused and integrated in different simulation environments.
[0182] This example demonstrates how this embodiment automatically packages and generates function simulation units according to updated code generation templates, so as to improve the integration and standardization of the function simulation unit distribution process.
[0183] From the above description, it can be seen that the simulation platform functional simulation unit generation method provided in the embodiment of the present application can determine the corresponding descriptive file and dynamic link library file through the code generation template file and the simulation model; perform parameter matching operations on the model header file according to the model parameters of the simulation model, and determine the corresponding hierarchy information file according to the preset iteration rules and model parameter variables; obtain the port information of the preset simulation model, parse the port information according to the parsing rules, and determine the corresponding data protocol file; determine the corresponding resource file according to the hierarchy information file and the data protocol file; perform functional simulation unit construction operations according to the descriptive files, dynamic link library files and resource files, determine the corresponding functional simulation unit, and perform simulation program interaction operations between simulation platforms according to the functional simulation unit, thereby improving the integration and standardization of the functional simulation unit distribution process.
[0184] In one embodiment of the method for generating a simulation platform function simulation unit of the present application, see Figure 2 , and can also include the following:
[0185] Step S201: performing a key variable information extraction operation on the implementation workshop file in the code generation template file to determine corresponding key variable information, wherein the key variable information includes at least one of output information, output information and parameter information;
[0186] Step S202: determining a corresponding model header file according to the code generation template and the model configuration of the preset simulation model.
[0187] Optionally, in this embodiment, key variable information and model header files are both part of the code generation process.
[0188] The key variable information is extracted from the modelname.rtw file, which is generated by the Real-Time Workshop of the Simulink simulation platform and is a model file generated during the code generation process. The key variable information includes modelname_P (parameter variable), modelname_U (input variable), modelname_Y (output variable), etc.
[0189] Model header file, the Simulink simulation platform will generate the corresponding source code and header file according to the selected code generation template and the model configuration information. The header file (modelname.h) contains model variables, parameters, and possible structure definitions, which are the basis for the model to be implemented at the C code level.
[0190] Through step S202, this embodiment obtains key variable information and model header files, which are the basis for all subsequent FMU generation processes.
[0191] In one embodiment of the method for generating a simulation platform function simulation unit of the present application, see Figure 3 , and can also include the following:
[0192] Step S301: performing a structure matching operation according to the key variable information and the model header file to determine a corresponding key variable information structure;
[0193] Step S302: performing a multi-dimensional array extraction operation on the key variable information structure to determine a corresponding multi-dimensional array of key variable information.
[0194] Optionally, in this embodiment, first, we extract key variable group information, modelname_P (parameter variable), modelname_U (input variable), modelname_Y (output variable), etc. from the model file generated by Simulink Real-Time Workshop, and match the corresponding structure in the generated model header file (modelname.h) to facilitate subsequent processing of the multidimensional array in the structure.
[0195] For example, suppose we have a Simulink model that has been generated into corresponding code and files through Real-Time Workshop. In this process, some key files are generated, including the model header file (modelname.h), which contains the declarations of variables and structures defined in the model.
[0196] In the modelname.h file, we see a structure definition similar to the following:
[0197] typedef struct {
[0198] real_T Param1; / / Assume this is a model parameter
[0199] real_T Param2; / / Another model parameter
[0200] / / ... there may be other parameters
[0201] } modelname_P; / / parameter structure
[0202] typedef struct {
[0203] real_T Input1
[10] ; / / Assume this is a 10-dimensional input array
[0204] real_T Input2; / / a scalar input
[0205] / / ... there may be other inputs
[0206] } modelname_U; / / Input structure
[0207] typedef struct {
[0208] real_T Output1; / / one output
[0209] real_T OutputArray[5][3]; / / A 5x3 two-dimensional output array
[0210] / / ... there may be other outputs
[0211] } modelname_Y; / / Output structure
[0212] The system automatically analyzes the modelname.h file and identifies these structure definitions. The system pays attention to modelname_P, modelname_U, and modelname_Y because these structure names correspond to parameter, input, and output variable groups in the Simulink model.
[0213] In the above operation, a key variable information structure is obtained through structure matching, and the key variable information structure includes declarations of variables and structures defined in the model.
[0214] Secondly, after matching the key variable information structure, it is necessary to extract the multidimensional array contained in the key variable information structure to prepare for the subsequent flattening of the multidimensional array.
[0215] Through step S302, this embodiment successfully identifies a multidimensional array from the parameters, input, and output structures of the model, laying a solid foundation for the subsequent automatic packaging and generation of FMU.
[0216] In one embodiment of the method for generating a simulation platform function simulation unit of the present application, see Figure 4 , and can also include the following:
[0217] Step S401: performing a traversal and flattening operation on the multidimensional array of key variable information according to the preset function simulation interface packaging function to determine a corresponding one-dimensional array of key variable information;
[0218] Step S402: Determine the corresponding descriptive file and dynamic link library file according to the code generation template file and the one-dimensional array of key variable information.
[0219] Optionally, in this embodiment, a multidimensional array of key variable information is processed.
[0220] The code generation template file includes the original code generation logic, and also adds a descriptive file generation algorithm and FMI wrapper function. In the fmiwrapper.inc (functional simulation interface wrapper) in the code generation template file, the multidimensional array of key variable information is flattened into a one-dimensional array of key variable information (modelVariables) according to the row-major order traversal order.
[0221] The row priority ensures that all elements in the multidimensional array can be stored in a one-dimensional array in a certain order. During the flattening process, the FMI wrapper generates or modifies code to replace the references to the multidimensional data variables in the model with references to the flattened one-dimensional array.
[0222] For example, assuming that the Simulink model output structure modelname_Y in the above example contains a two-dimensional array OutputArray[5][3], then during the flattening process, this two-dimensional array will be converted to a one-dimensional array OutputArrayFlat
[15] (using row-first traversal order). The FMI wrapper will generate the corresponding code to manage this conversion process and describe OutputArrayFlat as a one-dimensional array variable in modelDescription.xml. In this way, when the FMU interacts with the external simulation environment, the value of this one-dimensional array variable can be correctly passed.
[0223] It is understandable that one-dimensional variables are more in line with the FMI standard, which is conducive to the subsequent generation of standard-compliant FMU files. This flat data structure is more easily accepted by different platforms and languages.
[0224] The code generation template file can construct the descriptive file and the dynamic link library file according to the above one-dimensional array.
[0225] Through step S403, this embodiment successfully obtains a flattened one-dimensional variable array, which is an important basis for subsequently establishing an FMU file that complies with the FMI standard.
[0226] In one embodiment of the method for generating a simulation platform function simulation unit of the present application, see Figure 5 , and can also include the following:
[0227] Step S501: generating a template file according to the preset original code and determining a corresponding dynamic link library file according to the one-dimensional array of key variable information;
[0228] Step S502: Determine a corresponding descriptive file according to the preset original code generation template file, the preset descriptive file generation algorithm and the one-dimensional array of key variable information.
[0229] Optionally, in this embodiment, a dynamic link library file is generated.
[0230] The dynamic link library file is constructed by referencing the flattened one-dimensional array of key variable information and source code generated according to the original code generation logic.
[0231] When generating a dynamic link library, you need to implement various functions defined by the FMI standard, such as initialization, stepping, termination, etc. These functions need to be able to access the model's variables. By flattening the model variables into a one-dimensional array, these variables can be accessed and modified in these functions through simple indexing, thereby implementing the functions required by the FMI standard.
[0232] Understandably, flattened one-dimensional arrays make dynamic link libraries more versatile and compatible because they can be more easily called by different platforms and programming environments without being restricted by the multi-dimensional data structure in the original model.
[0233] Optionally, in this embodiment, a descriptive file is generated.
[0234] The one-dimensional array of key variable information after referencing flattening is the basis for generating a descriptive file.
[0235] In fmiwrapper.inc (functional simulation interface wrapper), all key variables of the model (including parameters, inputs and outputs) have been flattened into a one-dimensional array (modelVariables).
[0236] The description file generation algorithm uses the variable information in the one-dimensional array to generate a unique field identifier for each variable as required by the FMI standard. This field identifier (usually a string or numeric ID) is used to uniquely identify and reference each variable in the model in the FMI interface.
[0237] The algorithm will traverse each element in the one-dimensional array and match it with the structure and variables defined in the model header file modelname.h, ensuring that each variable can be correctly mapped to the corresponding position in the one-dimensional array and assigned a unique field identifier.
[0238] Once each variable has been assigned a unique identifier, these identifiers can be used to generate a descriptive file, modelDescription.xml.
[0239] Next, a descriptive file is generated based on a template file and a unique field identifier generated according to the original code, wherein the template file includes the structure and format required to generate the descriptive file, and the algorithm fills in the placeholders in the template to generate a complete descriptive file.
[0240] Understandably, the purpose of this process is to ensure that each model variable has a clear, unique identity and is well documented in descriptive files, so that the FMU can be correctly identified and used in different simulation platforms. By automating this process, human errors can be reduced and the efficiency and accuracy of FMU generation can be improved.
[0241] Through step S502, this embodiment successfully determines the dynamic link library file and the descriptive file. These two files are the basic files for building the FMU. Up to now, the goal of automatically building the FMU has been achieved, laying an automated foundation for subsequently improving the integration and standardization of the FMU.
[0242] In one embodiment of the method for generating a simulation platform function simulation unit of the present application, see Figure 6 , and can also include the following:
[0243] Step S601: performing a field matching operation on the one-dimensional array of key variable information according to the preset descriptive file generation algorithm to determine a corresponding unique field identifier;
[0244] Step S602: Determine a corresponding descriptive file based on the unique field identifier and the preset original code generation template file.
[0245] Optionally, in this embodiment, the process of constructing the descriptive file is further described.
[0246] Generates a descriptive file.
[0247] The one-dimensional array of key variable information after referencing flattening is the basis for generating a descriptive file.
[0248] In fmiwrapper.inc (functional simulation interface wrapper), all key variables of the model (including parameters, inputs and outputs) have been flattened into a one-dimensional array (modelVariables).
[0249] The description file generation algorithm uses the variable information in the one-dimensional array to generate a unique field identifier for each variable as required by the FMI standard. This field identifier (usually a string or numeric ID) is used to uniquely identify and reference each variable in the model in the FMI interface.
[0250] The algorithm will traverse each element in the one-dimensional array and match it with the structure and variables defined in the model header file modelname.h, ensuring that each variable can be correctly mapped to the corresponding position in the one-dimensional array and assigned a unique field identifier.
[0251] Once each variable has been assigned a unique identifier, these identifiers can be used to generate a descriptive file, modelDescription.xml.
[0252] Next, a descriptive file is generated based on a template file and a unique field identifier generated according to the original code, wherein the template file includes the structure and format required to generate the descriptive file, and the algorithm fills in the placeholders in the template to generate a complete descriptive file.
[0253] Understandably, the purpose of this process is to ensure that each model variable has a clear, unique identity and is well documented in descriptive files, so that the FMU can be correctly identified and used in different simulation platforms. By automating this process, human errors can be reduced and the efficiency and accuracy of FMU generation can be improved.
[0254] Through step S602, this embodiment further describes the generation process of the descriptive file, laying a foundation for the subsequent construction of the FMU.
[0255] In one embodiment of the method for generating a simulation platform function simulation unit of the present application, see Figure 7 , and can also include the following:
[0256] Step S701: performing a hierarchical parameter adding operation on a root variable in the model parameter variable to determine a corresponding root level;
[0257] Step S702: Perform a hierarchical structure traversal operation according to the root level and preset iterative traversal rules to determine a corresponding hierarchical information file.
[0258] Optionally, in this embodiment, in addition to the above-mentioned dynamic link library file and descriptive file, an additional resource file is attached to increase the integration and reusability of the strong FMU (functional simulation unit), reduce the burden on simulation model users, and avoid data errors caused by manual protocol parsing.
[0259] First, identify the model-defined Parameters (variables) from the header file (modelname.h) generated by the Simulink simulation platform based on the code generation template and the model configuration information. These variables may be defined through macro definitions, global variables declared with the extern keyword, or member variables in a structure.
[0260] It is worth noting that the Parameters identified in this step are different from the key variable information extracted from the model file generated by Simulink Real-Time Workshop in step S102. This Parameters information is limited to model parameter information, while the key variable information in step S102 includes not only model parameter information but also model input and output information.
[0261] Secondly, identify the root-level parameters in the model. Parameters may be organized in different levels. The root level is the highest level of parameters, without a parent, usually the top-level structure or variable, and combine their names with the level information to add layers and parameters.
[0262] In the first embodiment of this step, the prefix Parameters. is added before the root-level variable names to indicate that they belong to the parameter set of the model.
[0263] In the second embodiment of this step, the root level may not have an additional prefix.
[0264] Then, use recursive or iterative logic rules to traverse all levels in the model. For each level, match the structure variables first, then the non-structure variables at that level, until there are no more structure variables.
[0265] Finally, all the hierarchical information is integrated into a file that describes the hierarchical structure of the model, making it easier for users to understand and operate different parts of the model.
[0266] Optionally, for example, there is a model header file modelname.h that defines the parameters required by the model.
[0267] / / modelname.h
[0268] typedef struct { (structure definition)
[0269] double temperature;(temperature)
[0270] struct {
[0271] double pressure;(pressure)
[0272] double humidity;
[0273] environment;
[0274] } SensorData; (sensor)
[0275] extern double inputVoltage; (input voltage)
[0276] extern double outputSignal; (output signal)
[0277] In this example, temperature, pressure, humidity, input voltage, and output signal are parameter variable information, where:
[0278] inputVoltage and outputSignal are non-structure root-level variables. We add level prefixes to them and update them to Parameters.inputVoltage and Parameters.outputSignal, indicating that they are parameter collections.
[0279] In the above structure, we can observe that there is structure nesting, namely:
[0280] temperature belongs to the SensorData structure.
[0281] Double pressure and double humidity belong to the small structure of environment and the large structure of SensorData.
[0282] Under Rules, the prefix changes to:
[0283] SensorData.Parameters.temperature(temperature)
[0284] SensorData.environment.Parameters.double pressure
[0285] SensorData.environment.Parameters.double humidity
[0286] Finally, package the changed hierarchy information into a hierarchy information file and attach the file to the resources folder of the FMU (functional simulation unit).
[0287] It is understood that the purpose of this process is to ensure that the parameter structure of the model is clear and easy to exchange and use between different models and tools. In this way, the interoperability and reusability of the model can be ensured. The FMU generated in this way can be imported and used by other simulation tools or models to achieve model interoperability and integration.
[0288] Through step S702, this embodiment successfully constructs the hierarchical information file in the resource file, realizes a clear definition of the model parameter structure, and lays a solid foundation for standardization and integration for the subsequent use of simulation model data on different platforms.
[0289] In order to improve the integration and standardization of the function simulation unit distribution process, the present application provides an embodiment of a simulation platform function simulation unit generation device for realizing all or part of the contents of the simulation platform function simulation unit generation method, see Figure 8 The simulation platform function simulation unit generation device specifically includes the following contents:
[0290] The code generation template generation module 10 is used to add a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function, and determine a corresponding code generation template file;
[0291] A dynamic link library and description file generation module 20, used to determine the corresponding key variable information and model header file according to the code generation template file and the preset simulation model, perform a structure matching operation according to the key variable information and the model header file, determine the corresponding key variable information multidimensional array, and determine the corresponding descriptive file and dynamic link library file according to the code generation template file and the key variable information multidimensional array;
[0292] The resource file generation module 30 is used to perform a parameter matching operation on the model header file according to the model parameters of the preset simulation model, determine the corresponding model parameter variables, perform a hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables, and determine the corresponding hierarchical information file; obtain the port information of the preset simulation model, perform a parsing operation on the port information according to the preset parsing rules, and determine the corresponding data protocol file; determine the corresponding resource file according to the hierarchical information file and the data protocol file;
[0293] The function simulation unit construction module 40 is used to perform function simulation unit construction operations according to the descriptive file, the dynamic link library file and the resource file, determine the corresponding function simulation unit, and perform simulation program interaction between simulation platforms according to the function simulation unit.
[0294] From the above description, it can be seen that the simulation platform function simulation unit generation device provided in the embodiment of the present application can determine the corresponding descriptive file and dynamic link library file through the code generation template file and the simulation model; perform parameter matching operation on the model header file according to the model parameters of the simulation model, and determine the corresponding hierarchy information file according to the preset iteration rules and model parameter variables; obtain the port information of the preset simulation model, parse the port information according to the parsing rules, and determine the corresponding data protocol file; determine the corresponding resource file according to the hierarchy information file and the data protocol file; perform function simulation unit construction operation according to the descriptive file, dynamic link library file and resource file, determine the corresponding function simulation unit, and perform simulation program interaction operation between simulation platforms according to the function simulation unit, thereby improving the integration and standardization of the function simulation unit distribution process.
[0295] From the hardware level, in order to improve the integration and standardization in the distribution process of the functional simulation unit, the present application provides an embodiment of an electronic device for implementing all or part of the contents of the simulation platform functional simulation unit generation method, and the electronic device specifically includes the following contents:
[0296] Processor, memory, communication interface and bus; wherein the processor, memory and communication interface communicate with each other through the bus; the communication interface is used to realize information transmission between the simulation platform function simulation unit generation method and the core business system, user terminal and related database and other related devices; the logic controller can be a desktop computer, a tablet computer and a mobile terminal, etc., but the present embodiment is not limited thereto. In the present embodiment, the logic controller can be implemented with reference to the embodiment of the simulation platform function simulation unit generation method and the embodiment of the simulation platform function simulation unit generation method in the embodiment, and the contents thereof are incorporated herein, and the repeated parts are not repeated.
[0297] It is understandable that the user terminal may include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, a smart wearable device, etc. Among them, the smart wearable device may include smart glasses, a smart watch, a smart bracelet, etc.
[0298] In practical applications, part of the method for generating the simulation platform function simulation unit can be executed on the electronic device side as described above, or all operations can be completed in the client device. The selection can be made based on the processing capability of the client device and the limitations of the user's usage scenario. This application does not limit this. If all operations are completed in the client device, the client device may also include a processor.
[0299] The client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and other implementation scenarios may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, or a server cluster consisting of multiple servers, or a server structure of a distributed device.
[0300] Fig. 9 FIG. 9 is a schematic block diagram of the system structure of the electronic device 9600 according to an embodiment of the present application. Fig. 9 As shown, the electronic device 9600 may include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. It is worth noting that Fig. 9 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.
[0301] In one embodiment, the simulation platform function simulation unit generation method function may be integrated into the central processing unit 9100. The central processing unit 9100 may be configured to perform the following control:
[0302] Step S101: adding a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file;
[0303] Step S102: determining corresponding key variable information and model header files according to the code generation template file and the preset simulation model, performing a structure matching operation according to the key variable information and the model header file, determining corresponding multidimensional arrays of key variable information, and determining corresponding descriptive files and dynamic link library files according to the code generation template file and the multidimensional arrays of key variable information;
[0304] Step S103: performing a parameter matching operation on the model header file according to the model parameters of the preset simulation model to determine the corresponding model parameter variables, performing a hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables to determine the corresponding hierarchical information file; obtaining the port information of the preset simulation model, performing a parsing operation on the port information according to the preset parsing rules to determine the corresponding data protocol file; determining the corresponding resource file according to the hierarchical information file and the data protocol file;
[0305] Step S104: constructing a functional simulation unit according to the descriptive file, the dynamic link library file and the resource file, determining a corresponding functional simulation unit, and performing simulation program interaction operations between simulation platforms according to the functional simulation unit.
[0306] From the above description, it can be seen that the electronic device provided in the embodiment of the present application determines the corresponding descriptive file and dynamic link library file through the code generation template file and the simulation model; performs parameter matching operation on the model header file according to the model parameters of the simulation model, and determines the corresponding hierarchy information file according to the preset iteration rules and model parameter variables; obtains the port information of the preset simulation model, parses the port information according to the parsing rules, and determines the corresponding data protocol file; determines the corresponding resource file according to the hierarchy information file and the data protocol file; performs functional simulation unit construction operation according to the descriptive file, dynamic link library file and resource file, determines the corresponding functional simulation unit, and performs simulation program interaction operation between simulation platforms according to the functional simulation unit, thereby improving the integration and standardization of the functional simulation unit distribution process.
[0307] In another embodiment, the simulation platform function simulation unit generation method can be configured separately from the central processing unit 9100. For example, the simulation platform function simulation unit generation method can be configured as a chip connected to the central processing unit 9100, and the functions of the simulation platform function simulation unit generation method are realized through the control of the central processing unit.
[0308] like Fig. 9 As shown, the electronic device 9600 may also include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is worth noting that the electronic device 9600 does not necessarily have to include Fig. 9 In addition, the electronic device 9600 may also include Fig. 9 For components not shown, reference may be made to the prior art.
[0309] like Fig. 9As shown, the central processing unit 9100 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor device and / or logic device. The central processing unit 9100 receives input and controls the operation of various components of the electronic device 9600.
[0310] The memory 9140 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The above-mentioned information related to the failure may be stored, and a program for executing the relevant information may also be stored. The CPU 9100 may execute the program stored in the memory 9140 to implement information storage or processing, etc.
[0311] The input unit 9120 provides input to the central processing unit 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to provide power to the electronic device 9600. The display 9160 is used to display display objects such as images and texts. The display may be, for example, an LCD display, but is not limited thereto.
[0312] The memory 9140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 9140 may also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142, which is used to store application programs and function programs or processes for executing the operation of the electronic device 9600 through the central processor 9100.
[0313] The memory 9140 may also include a data storage unit 9143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).
[0314] The communication module 9110 is a transmitter / receiver that sends and receives signals via the antenna 9111. The communication module 9110 (transmitter / receiver) is coupled to the central processor 9100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.
[0315] Based on different communication technologies, multiple communication modules 9110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless LAN module, etc. The communication module (transmitter / receiver) 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide an audio output via the speaker 9131 and receive an audio input from the microphone 9132, thereby realizing a common telecommunication function. The audio processor 9130 may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 9130 is also coupled to the central processor 9100, so that recording can be performed on the local machine through the microphone 9132, and the sound stored on the local machine can be played through the speaker 9131.
[0316] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps in the method for generating a simulation platform function simulation unit whose execution subject is a server or a client in the above embodiments. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps in the method for generating a simulation platform function simulation unit whose execution subject is a server or a client in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0317] Step S101: adding a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file;
[0318] Step S102: determining corresponding key variable information and model header files according to the code generation template file and the preset simulation model, performing a structure matching operation according to the key variable information and the model header file, determining corresponding multidimensional arrays of key variable information, and determining corresponding descriptive files and dynamic link library files according to the code generation template file and the multidimensional arrays of key variable information;
[0319] Step S103: performing a parameter matching operation on the model header file according to the model parameters of the preset simulation model to determine the corresponding model parameter variables, performing a hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables to determine the corresponding hierarchical information file; obtaining the port information of the preset simulation model, performing a parsing operation on the port information according to the preset parsing rules to determine the corresponding data protocol file; determining the corresponding resource file according to the hierarchical information file and the data protocol file;
[0320] Step S104: constructing a functional simulation unit according to the descriptive file, the dynamic link library file and the resource file, determining a corresponding functional simulation unit, and performing simulation program interaction operations between simulation platforms according to the functional simulation unit.
[0321] From the above description, it can be seen that the computer-readable storage medium provided in the embodiment of the present application determines the corresponding descriptive file and dynamic link library file through the code generation template file and the simulation model; performs parameter matching operation on the model header file according to the model parameters of the simulation model, and determines the corresponding hierarchy information file according to the preset iteration rules and model parameter variables; obtains the port information of the preset simulation model, parses the port information according to the parsing rules, and determines the corresponding data protocol file; determines the corresponding resource file according to the hierarchy information file and the data protocol file; performs functional simulation unit construction operation according to the descriptive file, the dynamic link library file and the resource file, determines the corresponding functional simulation unit, and performs simulation program interaction operation between simulation platforms according to the functional simulation unit, thereby improving the integration and standardization of the functional simulation unit distribution process.
[0322] The embodiments of the present application also provide a computer program product capable of implementing all the steps in the method for generating a simulation platform function simulation unit in the above embodiment, where the execution subject is a server or a client. When the computer program / instruction is executed by a processor, the steps of the method for generating a simulation platform function simulation unit are implemented. For example, the computer program / instruction implements the following steps:
[0323] Step S101: adding a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file;
[0324] Step S102: determining corresponding key variable information and model header files according to the code generation template file and the preset simulation model, performing a structure matching operation according to the key variable information and the model header file, determining corresponding multidimensional arrays of key variable information, and determining corresponding descriptive files and dynamic link library files according to the code generation template file and the multidimensional arrays of key variable information;
[0325] Step S103: performing a parameter matching operation on the model header file according to the model parameters of the preset simulation model to determine the corresponding model parameter variables, performing a hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables to determine the corresponding hierarchical information file; obtaining the port information of the preset simulation model, performing a parsing operation on the port information according to the preset parsing rules to determine the corresponding data protocol file; determining the corresponding resource file according to the hierarchical information file and the data protocol file;
[0326] Step S104: constructing a functional simulation unit according to the descriptive file, the dynamic link library file and the resource file, determining a corresponding functional simulation unit, and performing simulation program interaction operations between simulation platforms according to the functional simulation unit.
[0327] From the above description, it can be seen that the computer program product provided in the embodiment of the present application determines the corresponding descriptive file and dynamic link library file through the code generation template file and the simulation model; performs parameter matching operation on the model header file according to the model parameters of the simulation model, and determines the corresponding hierarchy information file according to the preset iteration rules and model parameter variables; obtains the port information of the preset simulation model, parses the port information according to the parsing rules, and determines the corresponding data protocol file; determines the corresponding resource file according to the hierarchy information file and the data protocol file; performs functional simulation unit construction operation according to the descriptive file, dynamic link library file and resource file, determines the corresponding functional simulation unit, and performs simulation program interaction operation between simulation platforms according to the functional simulation unit, thereby improving the integration and standardization of the functional simulation unit distribution process.
[0328] It should be understood by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0329] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (apparatus), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0330] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0331] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0332] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for generating a simulation platform functional simulation unit, characterized in that: The method comprises: Adding a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file; Determine corresponding key variable information and model header file according to the code generation template file and the preset simulation model, perform structure matching operation according to the key variable information and the model header file, determine corresponding multidimensional array of key variable information, and determine corresponding descriptive file and dynamic link library file according to the code generation template file and the multidimensional array of key variable information; Perform parameter matching operation on the model header file according to the model parameters of the preset simulation model to determine the corresponding model parameter variables, perform hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables to determine the corresponding hierarchical information file; obtain the port information of the preset simulation model, perform parsing operation on the port information according to the preset parsing rules to determine the corresponding data protocol file; determine the corresponding resource file according to the hierarchical information file and the data protocol file; A function simulation unit construction operation is performed according to the descriptive file, the dynamic link library file and the resource file, a corresponding function simulation unit is determined, and a simulation program interaction operation between simulation platforms is performed according to the function simulation unit.
2. The method for generating a simulation platform function simulation unit according to claim 1, characterized in that: The step of determining corresponding key variable information and model header file according to the code generation template file and the preset simulation model includes: Performing a key variable information extraction operation on the implementation workshop file in the code generation template file to determine corresponding key variable information, wherein the key variable information includes at least one of output information, output information and parameter information; The corresponding model header file is determined according to the code generation template and the model configuration of the preset simulation model.
3. The method for generating a simulation platform function simulation unit according to claim 1, characterized in that: The performing a structure matching operation according to the key variable information and the model header file to determine a corresponding multidimensional array of key variable information includes: Perform a structure matching operation according to the key variable information and the model header file to determine a corresponding key variable information structure; A multidimensional array extraction operation is performed on the key variable information structure to determine a corresponding multidimensional array of key variable information.
4. The method for generating a simulation platform function simulation unit according to claim 1, characterized in that: Determining the corresponding descriptive file and dynamic link library file according to the code generation template file and the key variable information multidimensional array includes: Performing a traversal and flattening operation on the multidimensional array of key variable information according to the preset function simulation interface wrapper function to determine a corresponding one-dimensional array of key variable information; The corresponding descriptive file and dynamic link library file are determined according to the code generation template file and the one-dimensional array of key variable information.
5. The method for generating a simulation platform function simulation unit according to claim 4, characterized in that: Determining the corresponding descriptive file and dynamic link library file according to the code generation template file and the one-dimensional array of key variable information includes: Determine the corresponding dynamic link library file according to the preset original code generation template file and the one-dimensional array of key variable information; The corresponding descriptive file is determined according to the preset original code generation template file, the preset descriptive file generation algorithm and the one-dimensional array of key variable information.
6. The method for generating a simulation platform function simulation unit according to claim 5, characterized in that: The step of generating a template file according to the preset original code, the preset descriptive file generation algorithm and the one-dimensional array of key variable information to determine a corresponding descriptive file includes: Performing a field matching operation on the one-dimensional array of key variable information according to the preset descriptive file generation algorithm to determine a corresponding unique field identifier; A corresponding descriptive file is determined according to the unique field identifier and the preset original code generation template file.
7. The method for generating a simulation platform function simulation unit according to claim 1, characterized in that: The step of performing a hierarchical parameter adding operation according to a preset iteration rule and the model parameter variable to determine a corresponding hierarchical information file includes: Performing a hierarchical parameter adding operation on the root variable in the model parameter variable to determine the corresponding root level; A hierarchical structure traversal operation is performed according to the root level and preset iterative traversal rules to determine a corresponding hierarchical information file.
8. A device for generating a simulation platform function simulation unit, characterized in that: The device comprises: A code generation template generation module is used to add a preset original code generation template file in the simulation platform according to a preset descriptive file generation algorithm and a preset functional simulation interface packaging function to determine a corresponding code generation template file; A dynamic link library and description file generation module, used to determine the corresponding key variable information and model header file according to the code generation template file and the preset simulation model, perform a structure matching operation according to the key variable information and the model header file, determine the corresponding multidimensional array of key variable information, and determine the corresponding descriptive file and dynamic link library file according to the code generation template file and the multidimensional array of key variable information; A resource file generation module is used to perform a parameter matching operation on the model header file according to the model parameters of the preset simulation model, determine the corresponding model parameter variables, perform a hierarchical parameter adding operation according to the preset iteration rules and the model parameter variables, and determine the corresponding hierarchical information file; obtain the port information of the preset simulation model, perform a parsing operation on the port information according to the preset parsing rules, and determine the corresponding data protocol file; determine the corresponding resource file according to the hierarchical information file and the data protocol file; The function simulation unit construction module is used to perform function simulation unit construction operations according to the descriptive file, the dynamic link library file and the resource file, determine the corresponding function simulation unit, and perform simulation program interaction between simulation platforms according to the function simulation unit.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method for generating a simulation platform functional simulation unit according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for generating a simulation platform functional simulation unit according to any one of claims 1 to 7 are implemented.
