CN113238834A - Processing method and device of simulation model file and electronic equipment - Google Patents

Processing method and device of simulation model file and electronic equipment Download PDF

Info

Publication number
CN113238834A
CN113238834A CN202110602017.4A CN202110602017A CN113238834A CN 113238834 A CN113238834 A CN 113238834A CN 202110602017 A CN202110602017 A CN 202110602017A CN 113238834 A CN113238834 A CN 113238834A
Authority
CN
China
Prior art keywords
file
simulation model
link library
dynamic link
obtaining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110602017.4A
Other languages
Chinese (zh)
Other versions
CN113238834B (en
Inventor
贝晓狮
李京燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Shi Guan Jin Yang Technology Development Co ltd
Original Assignee
Beijing Shi Guan Jin Yang Technology Development Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Shi Guan Jin Yang Technology Development Co ltd filed Critical Beijing Shi Guan Jin Yang Technology Development Co ltd
Priority to CN202110602017.4A priority Critical patent/CN113238834B/en
Publication of CN113238834A publication Critical patent/CN113238834A/en
Application granted granted Critical
Publication of CN113238834B publication Critical patent/CN113238834B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application discloses a processing method and a processing device for a simulation model file and electronic equipment, wherein the method comprises the following steps: obtaining a first dynamic link library file to be processed, wherein the first dynamic link library file corresponds to a Simulink simulation model; obtaining a source file at least according to the first dynamic link library file, wherein the source file corresponds to the Simulink simulation model; compiling the source file to obtain at least a second dynamic link library file, wherein the second dynamic link library file corresponds to a target simulation model; and obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.

Description

Processing method and device of simulation model file and electronic equipment
Technical Field
The present application relates to the field of simulation technologies, and in particular, to a method and an apparatus for processing a simulation model file, and an electronic device.
Background
Matlab is a piece of modeling software commonly used by engineers, and Simulink is a visual simulation tool in MATLAB.
Therefore, in order to support the unified scheduling of the integrated simulation platform and realize the multi-source heterogeneous model integrated simulation of the complex system, the simulation model built by the Simulink needs to support the universal external interface standard.
Disclosure of Invention
In view of this, the present application provides a method and an apparatus for processing a simulation model file, and an electronic device, including:
the application provides a processing method of a simulation model file, which comprises the following steps:
obtaining a first dynamic link library file to be processed, wherein the first dynamic link library file corresponds to a Simulink simulation model;
obtaining a source file at least according to the first dynamic link library file, wherein the source file corresponds to the Simulink simulation model;
compiling the source file to obtain at least a second dynamic link library file, wherein the second dynamic link library file corresponds to a target simulation model;
and obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
The method preferably further includes, before obtaining the source file at least from the first dynamic link library file, the step of:
obtaining a first description file to be processed, wherein the first description file corresponds to the Simulink simulation model and is at least used for describing input and output structure information of the Simulink simulation model;
wherein obtaining a source file at least according to the first dynamic link library file comprises:
and obtaining a source file according to the first dynamic link library file and the first description file.
Preferably, before obtaining the simulation model file corresponding to the target simulation model at least according to the second dynamic link library file, the method further includes:
obtaining the second description file according to the source file, wherein the second description file corresponds to the target simulation type and is used for describing input and output variables of the target simulation type;
wherein obtaining a simulation model file corresponding to the target simulation model based at least on the second dynamic link library file comprises:
and acquiring a simulation model file corresponding to the target simulation model according to the second description file and the second dynamic link library file.
Preferably, in the above method, obtaining a simulation model file corresponding to the target simulation model according to the second description file and the second dynamic link library file includes:
and at least packing the second dynamic link library file and the second description file to obtain a simulation model file corresponding to the target simulation type.
Preferably, the method for compiling the source file to obtain at least a second dynamic link library file includes:
compiling the source file by using a compiler under a preset compiling environment to obtain a second dynamic link library file;
wherein the compilation environment corresponds to model parameters of the Simulink simulation model.
In the method, preferably, a parameter for executing the compilation command in the compilation environment corresponds to a model bit number of the Simulink simulation model, the compiler includes a compilation parameter corresponding to a mode parameter of the Simulink simulation model, and the mode parameter of the Simulink simulation model is a parameter of an independent simulation mode or a parameter of a joint simulation mode.
The above method, preferably, further comprises:
and detecting the file parameters of the simulation model file to obtain a detection result, wherein the detection result represents whether the simulation model file is abnormal or not.
The present application further provides a processing apparatus for a simulation model file, the apparatus comprising:
the system comprises a link library obtaining unit, a link library obtaining unit and a processing unit, wherein the link library obtaining unit is used for obtaining a first dynamic link library file to be processed, and the first dynamic link library file corresponds to a Simulink simulation model;
a source file obtaining unit, configured to obtain a source file according to at least the first dynamic link library file, where the source file corresponds to the Simulink simulation model;
a source file compiling unit, configured to compile the source file to obtain at least a second dynamic link library file, where the second dynamic link library file corresponds to a target simulation model;
and the model file obtaining unit is used for obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
The above apparatus, preferably, the apparatus further comprises:
a description file obtaining unit, configured to obtain a first description file to be processed before the source file obtaining unit obtains the source file at least according to the first dynamic link library file, where the first description file corresponds to the Simulink simulation model, and the first description file is at least used to describe input and output structure information of the Simulink simulation model;
wherein the source file obtaining unit is specifically configured to: and obtaining a source file according to the first dynamic link library file and the first description file.
The present application further provides an electronic device, including:
a memory for storing an application program and data generated by the application program running;
a processor for executing the application to implement: obtaining a first dynamic link library file to be processed, wherein the first dynamic link library file corresponds to a Simulink simulation model; obtaining a source file at least according to the first dynamic link library file, wherein the source file corresponds to the Simulink simulation model; compiling the source file to obtain at least a second dynamic link library file, wherein the second dynamic link library file corresponds to a target simulation model; and obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
According to the scheme, in the processing method, the processing device and the electronic equipment of the simulation model file, the dynamic link library file corresponding to the Simulink simulation model is obtained, so that the source file corresponding to the Simulink simulation model can be obtained according to the dynamic link library file corresponding to the Simulink simulation model, and then the source file corresponding to the Simulink simulation model is obtained according to the dynamic link library file corresponding to the + Simulink simulation model, and the source file is compiled to obtain the dynamic link library file corresponding to the target simulation model, so that the simulation model file corresponding to the target simulation model can be obtained according to the dynamic link library file corresponding to the target simulation model. Therefore, in the application, the source file is compiled after the source file is obtained through the dynamic link library file of the Simulink simulation model, so that the simulation model file corresponding to the target simulation model is obtained by using the obtained dynamic link library file, the file of the Simulink simulation model can be packaged into the file of the target simulation model, and the simulation model built by the Simulink can support the interface standard of the target simulation model, namely the universal external interface standard.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a flowchart of a processing method for a simulation model file according to an embodiment of the present application;
FIGS. 2-4 are another flow charts of a method for processing simulation model files according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a processing apparatus for a simulation model file according to a second embodiment of the present application;
fig. 6-fig. 8 are schematic structural diagrams of another processing apparatus for a simulation model file according to a second embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to a third embodiment of the present application;
fig. 10 is a schematic flowchart of a process for encapsulating the Simulink simulation model of abc to obtain an FMU file according to the embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, a flowchart of an implementation of a method for processing a simulation model file according to an embodiment of the present application is provided, where the method may be applied to an electronic device capable of data processing, such as a computer or a server. The technical scheme in the application is mainly used for packaging the corresponding file of the Simulink simulation model, and further can obtain the simulation model file of the target simulation model, such as a Functional model unit FMU (Functional Mockup Unit) model file based on FMI (Functional Mock-up Interface).
Specifically, the method in this embodiment may include the following steps:
step 101: and obtaining a first dynamic link library file to be processed.
Wherein the first dynamic link library file corresponds to a Simulink simulation model.
Specifically, in this embodiment, the first dynamic link library file may be loaded from a simulation model file derived by the Simulink simulation tool, so as to obtain a dynamic link library file corresponding to the Simulink simulation model.
For example, taking an unlitled _ win64.dll derived from Simulink as an example, in this embodiment, the unlitled _ win64.dll may be loaded by using a LoadLibrary to obtain a first dynamic link library file corresponding to the Simulink simulation model, that is, the unlitled _ win64.dll includes a plurality of interface functions, and specifically, the interface functions may be loaded by using GetProcAddress.
Step 102: and obtaining the source file at least according to the first dynamic link library file.
Wherein the source file corresponds to a Simulink simulation model.
Specifically, in this embodiment, the first dynamic link library file may be decompiled to obtain a source file corresponding to the Simulink simulation model.
For example, in this embodiment, at least the loaded untilted _ win64.dll is decompiled to obtain the source file abc.
Step 103: and compiling the source file to obtain at least a second dynamic link library file.
Wherein the second dynamic link library file corresponds to the target simulation model.
Specifically, in this embodiment, the source file may be compiled according to a simulation interface standard corresponding to the target simulation model, so as to obtain a second dynamic link library file corresponding to the target simulation model.
For example, the source file abc.cpp may be compiled according to the FMI interface standard using a cl compiler, thereby obtaining a dynamic link library file corresponding to the FMU, i.e., a.dll file.
Step 104: and obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
Specifically, in this embodiment, at least the second dynamic link library file may be packaged to obtain a simulation model file corresponding to the target simulation model.
For example, in the present embodiment, a 7Zip compression tool or other compression tools may be used to package the dynamic link library file corresponding to the FMU to obtain the. FMU file of the FMU supporting the FMI interface standard.
As can be seen from the foregoing solution, in the processing method for a simulation model file provided in the embodiment of the present application, by obtaining a dynamic link library file corresponding to a Simulink simulation model, the dynamic link library file corresponding to the Simulink simulation model can be obtained, and then after obtaining a source file corresponding to the Simulink simulation model according to the dynamic link library file corresponding to the Simulink simulation model, the source file is compiled to obtain a dynamic link library file corresponding to a target simulation model, so that a simulation model file corresponding to the target simulation model can be obtained according to the dynamic link library file corresponding to the target simulation model. It can be seen that, in this embodiment, the source file is compiled after the source file is obtained through the dynamic link library file of the Simulink simulation model, so that the simulation model file corresponding to the target simulation model is obtained by using the obtained dynamic link library file, and the file of the Simulink simulation model can be encapsulated into the file of the target simulation model, so that the simulation model built by the Simulink can support the interface standard of the target simulation model, i.e. the universal external interface standard.
In one implementation, before step 102, the method in this embodiment may further include the following steps, as shown in fig. 2:
step 105: a first description file to be processed is obtained.
The first description file corresponds to the Simulink simulation model, and is at least used for describing input and output structure information of the Simulink simulation model.
Specifically, the first description file may include one or more header files corresponding to the Simulink simulation model, such as a header file specified.h corresponding to specified _ wind 64.dll and other related header files rtwtypes.h.
The header file may also be understood as an interface description file, which includes information related to an input/output structure corresponding to the Simulink simulation model, and may also include other contents. The contents of the input and output structure bodies can be seen by looking at the unttled.h, the contents of the input and output structure bodies such as In1, Out1, errorStatus, unttled _ U, unttled _ Y and the like can be seen In the unttled.h, and each input and output structure body has a respective type, such as real _ T and the like. And rtwtypes.h may contain alias definition of type name and the like, for example, resl _ T type and the like may be reached by looking at rtwtypes.h.
Based on this, the step 102 of obtaining the source file from the first dynamic link library file can be implemented by:
step 121: and obtaining the source file according to the first dynamic link library file and the first description file.
Specifically, in this embodiment, the first dynamic link library file and the first description file may be decompiled to obtain a source file corresponding to the Simulink simulation model.
For example, in this embodiment, after a dll and h header file is exported and loaded from MATLAB, decompiling is performed on the loaded unlit _ win64.dll and header file unlit. h, where the unlit.h contains various exported functions, such as unlit _ M, untitled _ M _, unlit _ U, untitled _ Y, untitled _ initial, unlit _ step, and unlit _ terminate, and so on, so as to obtain the source file abc.
The unttled _ U is an input structure, unttled _ Y is an output structure, unttled _ initialize is an initialization interface, unttled _ step is an interface to be executed every other step, and the like.
In one implementation, before step 104, the method in this embodiment may further include the following steps, as shown in fig. 3:
step 106: and obtaining a second description file according to the source file.
The second description file corresponds to the target simulation model, and is used for describing input and output variables of the target simulation model.
Specifically, in this embodiment, the relevant input/output structure information may be read by parsing the first description file in the source file, so that the input/output structure information is processed according to the interface standard of the target simulation model, such as format conversion, and a second description file capable of describing the input/output variables of the target simulation model is obtained.
For example, in this embodiment, the executable tool such as a script may be written to parse an invalid.h file in abc.cpp according to the FMI interface standard, so as to obtain a second description file corresponding to the FMU, such as an xml file.
Based on this, step 104, when obtaining the simulation model file, can be implemented by:
step 141: and acquiring a simulation model file corresponding to the target simulation model according to the second description file and the second dynamic link library file.
Specifically, in this embodiment, at least the second dynamic link library file and the second description file may be packaged together to obtain a simulation model file corresponding to the target simulation model.
For example, in the present embodiment, a 7Zip compression tool or other compression tools may be used to package the dynamic link library file and the description file corresponding to the FMU, so as to obtain the. FMU file of the FMU supporting the FMI interface standard.
In an implementation manner, when the source file is compiled to obtain at least the second dynamic link library file in step 103, the following specific steps may be implemented:
and compiling the source file by using a compiler under a preset compiling environment to obtain a second dynamic link library file.
Wherein the compilation environment corresponds to model parameters of the Simulink simulation model.
Specifically, in this embodiment, a compiling environment may be first set, where the set compiling environment corresponds to model parameters of a Simulink simulation model obtained in advance, and the model parameters at least include a number of model bits of the Simulink simulation model, and based on this, a parameter for executing a compiling command in the compiling environment may be set to correspond to the number of model bits of the Simulink simulation model, such as 32 bits or 64 bits.
Bat in a compilation environment by calling a batch command vcvarsall in a VC setup command line compilation environment, wherein the parameter x86 is added in the batch command if the Simulink simulation model corresponds to a 32-bit FMU model, and the parameter x86_ amd64 is added in the batch command if the Simulink simulation model corresponds to a 64-bit FMU model, for example, in the present embodiment.
In addition, the compiler constructed in this embodiment includes compilation parameters corresponding to mode parameters of the Simulink simulation model, and the mode parameters of the Simulink simulation model are parameters of an independent simulation mode or a joint simulation mode, that is, the mode parameters of the Simulink simulation model are parameters representing that the Simulink simulation model is the independent simulation mode or the joint simulation mode. For example, an independent simulation mode is characterized by me, namely only a single Simulink simulation model, and a joint simulation mode is characterized by cs, namely a plurality of Simulink simulation models, and compiling parameters corresponding to mode parameters of the Simulink simulation models are added in a compiler based on the fact that the Simulink simulation models are combined into a whole.
Based on this, in step 103, the compiler added with the compiling parameter corresponding to the mode parameter is used to compile the source file in the set compiling environment, specifically, the source file can be compiled according to the FMI interface standard, so as to obtain the dynamic link library file corresponding to the FMU.
For example, a cl compiler may be used to compile the source file abc.cpp in a preset compilation environment according to the FMI interface standard, thereby obtaining a dynamic link library file corresponding to the FMU, i.e., a.dll file.
In one implementation, after step 104, the method in this embodiment may further include the following steps, as shown in fig. 4:
step 107: and detecting the file parameters of the simulation model file to obtain a detection result.
And the detection result represents whether the simulation model file is abnormal or not.
Specifically, in this embodiment, whether parameters such as the format and the interface of the simulation model file are abnormal or not may be detected by the detection tool, so as to obtain a detection result.
Referring to fig. 5, a schematic structural diagram of a processing apparatus for simulating a model file according to a second embodiment of the present application is provided, where the apparatus may be configured in an electronic device capable of performing data processing, such as a computer or a server. The technical scheme is mainly used for packaging the corresponding file of the Simulink simulation model, and further the simulation model file of the target simulation model, such as an FMU model file based on FMI, can be obtained.
Specifically, the apparatus in this embodiment may include the following functional units:
a link library obtaining unit 501, configured to obtain a first dynamic link library file to be processed, where the first dynamic link library file corresponds to a Simulink simulation model;
a source file obtaining unit 502, configured to obtain a source file according to at least the first dynamic link library file, where the source file corresponds to the Simulink simulation model;
a source file compiling unit 503, configured to compile the source file to obtain at least a second dynamic link library file, where the second dynamic link library file corresponds to the target simulation model;
a model file obtaining unit 504, configured to obtain, according to at least the second dynamic link library file, a simulation model file corresponding to the target simulation model.
As can be seen from the foregoing solution, in the processing apparatus for a simulation model file according to the second embodiment of the present application, by obtaining the dynamic link library file corresponding to the Simulink simulation model, the dynamic link library file corresponding to the Simulink simulation model can be obtained, and then after obtaining the source file corresponding to the Simulink simulation model according to the dynamic link library file corresponding to the Simulink simulation model, the source file is compiled to obtain the dynamic link library file corresponding to the target simulation model, so that the simulation model file corresponding to the target simulation model can be obtained according to the dynamic link library file corresponding to the target simulation model. It can be seen that, in this embodiment, the source file is compiled after the source file is obtained through the dynamic link library file of the Simulink simulation model, so that the simulation model file corresponding to the target simulation model is obtained by using the obtained dynamic link library file, and the file of the Simulink simulation model can be encapsulated into the file of the target simulation model, so that the simulation model built by the Simulink can support the interface standard of the target simulation model, i.e. the universal external interface standard.
In one implementation, the apparatus in this embodiment may further include the following units, as shown in fig. 6:
a description file obtaining unit 505, configured to obtain a first description file to be processed before the source file obtaining unit 502 obtains the source file at least according to the first dynamic link library file, where the first description file corresponds to the Simulink simulation model, and the first description file is at least used to describe input and output structure information of the Simulink simulation model;
the source file obtaining unit 502 is specifically configured to: and obtaining a source file according to the first dynamic link library file and the first description file.
In one implementation, the apparatus in this embodiment may further include the following units, as shown in fig. 7:
a description file obtaining unit 506, configured to obtain the second description file according to the source file before the model file obtaining unit 504 obtains the simulation model file corresponding to the target simulation model at least according to the second dynamic link library file, where the second description file corresponds to the target simulation type, and the second description file is used to describe input and output variables of the target simulation type;
the model file obtaining unit 504 is specifically configured to: and acquiring a simulation model file corresponding to the target simulation model according to the second description file and the second dynamic link library file.
In an implementation manner, the model file obtaining unit 504 is specifically configured to: and at least packing the second dynamic link library file and the second description file to obtain a simulation model file corresponding to the target simulation type.
In one implementation, when compiling the source file to obtain at least a second dynamic link library file, the source file compiling unit 503 is specifically configured to: compiling the source file by using a compiler under a preset compiling environment to obtain a second dynamic link library file; wherein the compilation environment corresponds to model parameters of the Simulink simulation model.
The compiler comprises compilation parameters corresponding to mode parameters of the Simulink simulation model, and the mode parameters of the Simulink simulation model are parameters of an independent simulation mode or a joint simulation mode.
In one implementation, the apparatus in this embodiment may further include the following units, as shown in fig. 8:
the file detection unit 507 is configured to detect a file parameter of the simulation model file to obtain a detection result, where the detection result represents whether the simulation model file is abnormal.
It should be noted that, for the specific implementation of each unit in the present embodiment, reference may be made to the corresponding content in the foregoing, and details are not described here.
Referring to fig. 9, a schematic structural diagram of an electronic device according to a third embodiment of the present application is provided, where the electronic device may be an electronic device capable of performing data processing, such as a computer or a server. The technical scheme is mainly used for packaging the corresponding file of the Simulink simulation model, and further the simulation model file of the target simulation model, such as an FMU model file based on FMI, can be obtained.
Specifically, the electronic device in this embodiment may include the following structure:
a memory 901 for storing an application program and data generated by the application program running;
a processor 902 for executing the application to implement: obtaining a first dynamic link library file to be processed, wherein the first dynamic link library file corresponds to a Simulink simulation model; obtaining a source file at least according to the first dynamic link library file, wherein the source file corresponds to the Simulink simulation model; compiling the source file to obtain at least a second dynamic link library file, wherein the second dynamic link library file corresponds to a target simulation model; and obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
As can be seen from the foregoing solution, in the electronic device provided in the third embodiment of the present application, by obtaining the dynamic link library file corresponding to the Simulink simulation model, the source file corresponding to the Simulink simulation model may be obtained according to the dynamic link library file corresponding to the Simulink simulation model, and then the source file is compiled to obtain the dynamic link library file corresponding to the target simulation model, so that the simulation model file corresponding to the target simulation model may be obtained according to the dynamic link library file corresponding to the target simulation model. It can be seen that, in this embodiment, the source file is compiled after the source file is obtained through the dynamic link library file of the Simulink simulation model, so that the simulation model file corresponding to the target simulation model is obtained by using the obtained dynamic link library file, and the file of the Simulink simulation model can be encapsulated into the file of the target simulation model, so that the simulation model built by the Simulink can support the interface standard of the target simulation model, i.e. the universal external interface standard.
It should be noted that, in the present embodiment, reference may be made to the corresponding contents in the foregoing, and details are not described here.
With reference to the above embodiment, the following description will be made of an implementation scheme of encapsulating a Simulink simulation model into an FMU model by using a simulation model of a certain celestial body or an airplane as an example, where:
firstly, preparation work is carried out in the application, namely, the unused _ win64.dll exported by Simulink, the unused. h of a header file thereof, and the rtwtypes. h of a related header file are determined, after the preparation work is finished, the dll file is loaded by LoadLibrary, and the main interface functions of the dll file, such as unused _ U, untitled _ Y, untitled _ initial and unused _ step, are loaded by GetProcadres, so that a source file SimulinktoFmu. cpp is obtained.
Based on this, the model encapsulation tool realized by the application creates a blank folder under the models folder, and moves the source file SimulinktoFmu.cpp, the header file and the like to the path. The use flow of the packaging tool is as follows:
1. opening a windows command line (shift + right key- > win command window) under the models folder path;
2. bat, wherein, there are parameters cs and SimulinkToFmu, the parameter cs represents a joint simulation mode, and the SimulinkToFmu represents a source file name of a Simulink simulation model to be packaged;
3. the command line prompts that the Everything is Ok built fmu done indicates that the packaging is successful;
4. the packaged FMU model file is viewed in the tool root directory FMU folder.
In particular, after running build _ fmu. bat, referring to fig. 10, the batch file begins and the main steps inside the script are as follows:
1. bat, wherein, if a 32-bit MFU needs to be generated, a parameter x86 is added, and if it is 64-bit, a parameter x86_ amd64 is added;
2. determine whether to generate a saved to folder and determine a compile-time added/D parameter, e.g., add/DFMI _ cosumulation at compile time if CS mode, according to whether the incoming first parameter is "CS" or "me";
3. compiling the SimulinktoFmu. cpp with cl compiling commands in combination with the relevant parameters;
4. generating a model description.xml by using an application program generatexml.exe through a parameter "simulink tofmu.cpp", wherein the file is a description file of an FMU file, namely the second description file in the foregoing, and the contents in the description file are attributes describing input and output variables and the like;
5. files such as dll, modeldescription and xml generated by compiling are placed under corresponding folders according to the requirements of FMI standard, and then 7Zip compression tools are called to compress directories comprising the files so as to form SimulinktoFmu.fmu files;
6. finally, the fmuCheck tool is invoked to check the generated fmu, testing fmu for problems.
Referring to fig. 10, the process of acquiring the simulation model file of abc includes, first, deriving DLL and h header files such as unused _ wen 64.DLL and unused. h from MATLAB, and of course, deriving functions such as unused _ U, untitled _ Y, untitled _ initial size, unused _ step, etc., and then obtaining a source file abc.cpp by loading DLL and organizing the input and output parameters in the header file, and at the same time, the model packaging tool of the present application sets the batch processing command vcvarcall of command line compiling environment by calling vc, selects 32 bits or 64 bits as the parameter for executing bat according to the command line parameter, and determines the mode of FMU according to the parameter, such as determining whether the independent simulation mode or joint simulation mode according to "cs" or "ratio", and then, in the compiling environment, compiling abc.dll, i.e. the second library in the previous text, and processing abc by using xml. And obtaining modeldescription.xml, namely the second description file, compressing abc.dll, modeldescription.xml and other files together by using 7Zip according to the FMI standard to obtain abc.fmu, and further calling an fmuCheck tool to detect abc.fmu to complete the packaging processing of the simulation model file.
Therefore, the model packaging tool for realizing the application can package the Simulink simulation model into the FMU model, and adds the variable or parameter of the Simulink simulation model into the FMU model to complete packaging.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for processing a simulation model file, the method comprising:
obtaining a first dynamic link library file to be processed, wherein the first dynamic link library file corresponds to a Simulink simulation model;
obtaining a source file at least according to the first dynamic link library file, wherein the source file corresponds to the Simulink simulation model;
compiling the source file to obtain at least a second dynamic link library file, wherein the second dynamic link library file corresponds to a target simulation model;
and obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
2. The method of claim 1, wherein prior to obtaining a source file from at least the first dynamic link library file, the method further comprises:
obtaining a first description file to be processed, wherein the first description file corresponds to the Simulink simulation model and is at least used for describing input and output structure information of the Simulink simulation model;
wherein obtaining a source file at least according to the first dynamic link library file comprises:
and obtaining a source file according to the first dynamic link library file and the first description file.
3. The method of claim 1, wherein prior to obtaining a simulation model file corresponding to the target simulation model from at least the second dynamic link library file, the method further comprises:
obtaining the second description file according to the source file, wherein the second description file corresponds to the target simulation type and is used for describing input and output variables of the target simulation type;
wherein obtaining a simulation model file corresponding to the target simulation model based at least on the second dynamic link library file comprises:
and acquiring a simulation model file corresponding to the target simulation model according to the second description file and the second dynamic link library file.
4. The method of claim 3, wherein obtaining a simulation model file corresponding to the target simulation model from the second description file and the second dynamic link library file comprises:
and at least packing the second dynamic link library file and the second description file to obtain a simulation model file corresponding to the target simulation type.
5. The method of claim 1, wherein compiling the source file to obtain at least a second dynamic link library file comprises:
compiling the source file by using a compiler under a preset compiling environment to obtain a second dynamic link library file;
wherein the compilation environment corresponds to model parameters of the Simulink simulation model.
6. The method according to claim 5, wherein parameters for executing the compilation command in the compilation environment correspond to a number of model bits of the Simulink simulation model, and wherein the compiler includes compilation parameters corresponding to mode parameters of the Simulink simulation model, and the mode parameters of the Simulink simulation model are parameters of an independent simulation mode or a joint simulation mode.
7. The method of claim 1, further comprising:
and detecting the file parameters of the simulation model file to obtain a detection result, wherein the detection result represents whether the simulation model file is abnormal or not.
8. An apparatus for processing a simulation model file, the apparatus comprising:
the system comprises a link library obtaining unit, a link library obtaining unit and a processing unit, wherein the link library obtaining unit is used for obtaining a first dynamic link library file to be processed, and the first dynamic link library file corresponds to a Simulink simulation model;
a source file obtaining unit, configured to obtain a source file according to at least the first dynamic link library file, where the source file corresponds to the Simulink simulation model;
a source file compiling unit, configured to compile the source file to obtain at least a second dynamic link library file, where the second dynamic link library file corresponds to a target simulation model;
and the model file obtaining unit is used for obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
9. The apparatus of claim 8, further comprising:
a description file obtaining unit, configured to obtain a first description file to be processed before the source file obtaining unit obtains the source file at least according to the first dynamic link library file, where the first description file corresponds to the Simulink simulation model, and the first description file is at least used to describe input and output structure information of the Simulink simulation model;
wherein the source file obtaining unit is specifically configured to: and obtaining a source file according to the first dynamic link library file and the first description file.
10. An electronic device, comprising:
a memory for storing an application program and data generated by the application program running;
a processor for executing the application to implement: obtaining a first dynamic link library file to be processed, wherein the first dynamic link library file corresponds to a Simulink simulation model; obtaining a source file at least according to the first dynamic link library file, wherein the source file corresponds to the Simulink simulation model; compiling the source file to obtain at least a second dynamic link library file, wherein the second dynamic link library file corresponds to a target simulation model; and obtaining a simulation model file corresponding to the target simulation model at least according to the second dynamic link library file.
CN202110602017.4A 2021-05-31 2021-05-31 Simulation model file processing method and device and electronic equipment Active CN113238834B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110602017.4A CN113238834B (en) 2021-05-31 2021-05-31 Simulation model file processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110602017.4A CN113238834B (en) 2021-05-31 2021-05-31 Simulation model file processing method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN113238834A true CN113238834A (en) 2021-08-10
CN113238834B CN113238834B (en) 2023-08-08

Family

ID=77135853

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110602017.4A Active CN113238834B (en) 2021-05-31 2021-05-31 Simulation model file processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN113238834B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113761745A (en) * 2021-09-08 2021-12-07 北京世冠金洋科技发展有限公司 Joint simulation method and device, storage medium and electronic equipment
CN115185539A (en) * 2022-09-06 2022-10-14 西安羚控电子科技有限公司 Method, device and storage medium for generating executable dynamic link library file
CN116501452A (en) * 2023-06-28 2023-07-28 北京世冠金洋科技发展有限公司 Model processing method, simulation platform, electronic device and storage medium

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6442752B1 (en) * 1999-08-26 2002-08-27 Unisys Corporation Method, apparatus, and computer program product for replacing a dynamic link library (dll) of a first computing environment with a dll of a second computing environment that can be invoked from the first computing environment in a transparent manner
US20020138823A1 (en) * 1999-02-05 2002-09-26 Notker Amann Method and device for transmitting simulation models between simulators
CN1997909A (en) * 2004-05-22 2007-07-11 株式会社爱德万测试 Method and system for controlling interchangeable components in a modular test system
CN106776321A (en) * 2016-11-30 2017-05-31 中国航空工业集团公司沈阳飞机设计研究所 A kind of winged guard system software emulation contrast conversion method based on dynamic link library
US20170235963A1 (en) * 2016-02-11 2017-08-17 Line Corporation Method, apparatus, system and non-transitory computer readable medium for code protection
CN107992723A (en) * 2017-11-29 2018-05-04 南京莱斯信息技术股份有限公司 A kind of Java protection of source codes methods based on dynamic link library
US20190227779A1 (en) * 2016-03-11 2019-07-25 Lzlabs Gmbh Load module compiler
CN110096338A (en) * 2019-05-10 2019-08-06 百度在线网络技术(北京)有限公司 Intelligent contract executes method, apparatus, equipment and medium
CN111367511A (en) * 2020-03-02 2020-07-03 北京中科宇航技术有限公司 Simulation model interface adaptation development system and working method thereof
CN111985055A (en) * 2020-08-28 2020-11-24 北京世冠金洋科技发展有限公司 Model packaging method and device and electronic equipment
CN112115604A (en) * 2020-09-14 2020-12-22 苏州同元软控信息技术有限公司 Modelica model and Simulink model combined simulation method and system and electronic equipment
CN112667242A (en) * 2020-12-28 2021-04-16 北京世冠金洋科技发展有限公司 Method and device for packaging C code into FMU

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020138823A1 (en) * 1999-02-05 2002-09-26 Notker Amann Method and device for transmitting simulation models between simulators
US6442752B1 (en) * 1999-08-26 2002-08-27 Unisys Corporation Method, apparatus, and computer program product for replacing a dynamic link library (dll) of a first computing environment with a dll of a second computing environment that can be invoked from the first computing environment in a transparent manner
CN1997909A (en) * 2004-05-22 2007-07-11 株式会社爱德万测试 Method and system for controlling interchangeable components in a modular test system
US20170235963A1 (en) * 2016-02-11 2017-08-17 Line Corporation Method, apparatus, system and non-transitory computer readable medium for code protection
US20190227779A1 (en) * 2016-03-11 2019-07-25 Lzlabs Gmbh Load module compiler
CN106776321A (en) * 2016-11-30 2017-05-31 中国航空工业集团公司沈阳飞机设计研究所 A kind of winged guard system software emulation contrast conversion method based on dynamic link library
CN107992723A (en) * 2017-11-29 2018-05-04 南京莱斯信息技术股份有限公司 A kind of Java protection of source codes methods based on dynamic link library
CN110096338A (en) * 2019-05-10 2019-08-06 百度在线网络技术(北京)有限公司 Intelligent contract executes method, apparatus, equipment and medium
CN111367511A (en) * 2020-03-02 2020-07-03 北京中科宇航技术有限公司 Simulation model interface adaptation development system and working method thereof
CN111985055A (en) * 2020-08-28 2020-11-24 北京世冠金洋科技发展有限公司 Model packaging method and device and electronic equipment
CN112115604A (en) * 2020-09-14 2020-12-22 苏州同元软控信息技术有限公司 Modelica model and Simulink model combined simulation method and system and electronic equipment
CN112667242A (en) * 2020-12-28 2021-04-16 北京世冠金洋科技发展有限公司 Method and device for packaging C code into FMU

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
SONG HE等: "Research on integrated simulation technology of multi-source hererogeneous model based on FMI standard", 《2018 13TH IEEE CONFERENCE ON INDUSTRIAL ELECTRONICS AND APPLICATIONS(ICIEA)》, pages 417 - 422 *
袁静等: "空间操控任务控制仿真平台设计", 《系统仿真学报》, vol. 30, no. 09, pages 3366 - 3376 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113761745A (en) * 2021-09-08 2021-12-07 北京世冠金洋科技发展有限公司 Joint simulation method and device, storage medium and electronic equipment
CN113761745B (en) * 2021-09-08 2023-08-15 北京世冠金洋科技发展有限公司 Joint simulation method and device, storage medium and electronic equipment
CN115185539A (en) * 2022-09-06 2022-10-14 西安羚控电子科技有限公司 Method, device and storage medium for generating executable dynamic link library file
CN116501452A (en) * 2023-06-28 2023-07-28 北京世冠金洋科技发展有限公司 Model processing method, simulation platform, electronic device and storage medium
CN116501452B (en) * 2023-06-28 2023-09-08 北京世冠金洋科技发展有限公司 Model processing method, simulation platform, electronic device and storage medium

Also Published As

Publication number Publication date
CN113238834B (en) 2023-08-08

Similar Documents

Publication Publication Date Title
CN113238834B (en) Simulation model file processing method and device and electronic equipment
CN111985055B (en) Model packaging method and device and electronic equipment
EP3745256A1 (en) External code integrations within a computing environment
CN106919509B (en) Client generation method and device and electronic equipment
US9038032B2 (en) Symbolic execution and automatic test case generation for JavaScript programs
CN110196720B (en) Optimization method for generating dynamic link library by Simulink
US20120030655A1 (en) Generating and Modifying Textual Code Interfaces from Graphical Programs
CN110069259B (en) ID L file-based parsing method and device, electronic equipment and storage medium
CN111209203B (en) Model verification method based on source code
US20130125092A1 (en) Generating deployable code from simulation models
CN106355049A (en) Method and device for reinforcing dynamic linking library SO file of Android installation package
CN104573193A (en) Rapid designing method for GNC (Guidance, Navigation and Control) system of spacecraft
CN114610640A (en) Fuzzy testing method and system for trusted execution environment of Internet of things
CN112667242A (en) Method and device for packaging C code into FMU
CN113688037A (en) Nuclear power plant instrument control system software configuration debugging and packaging integrated method
CN114895935A (en) Method and device for flashing vehicle ECU, electronic equipment and storage medium
CN111596905A (en) Method, device, storage medium and terminal for generating java object
CN116243923A (en) Applet processing method and device and electronic equipment
CN115237755A (en) Protocol-based check algorithm library calling method and calling equipment
CN111240972B (en) Model verification device based on source code
CN114721666A (en) Code packaging method and device
CN111444618B (en) Simulation method and device based on variable dictionary
CN110110299B (en) Text conversion method, device and server
Jung An instrumentation record language for kieker
KR100503429B1 (en) Real-time debugging method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant