A Method and Device for Generating FMU Model Based on Linux
By generating an adaptive Linux-based FMU model in the GCAir simulation engine, the problem that existing models cannot run correctly in the GCAir simulation engine is solved, and the correct operation and real-time simulation capabilities of the model in the GCAir real-time simulation machine are realized.
Patent Information
- Application Number
- CN202211730209.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-12-30
AI Technical Summary
Existing models cannot run correctly in real-time simulation machines based on GCAir simulation engine.
By establishing an FMU pre-encapsulation model based on modeling software, encapsulate and generate a Windows-based FMU model, and use the compilation code tool to compile the model to generate a Linux-based FMU model adapted to the GCAir real-time simulation machine.
It solves the problem that existing models cannot run correctly in the GCAir simulation engine. The generated Linux-based FMU model has real-time simulation capabilities and is consistent with the simulation results of the original environment modeling software.
Smart Images

Figure CN116050112B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of model simulation, and in particular to a method and device for generating an FMU model based on Linux. Background Art
[0002] FMI (Functional Mock-up Interface) is an open, third-party standard interface protocol independent of modeling software, which can encapsulate a model into an FMU (Functional Mock-up Unit) according to the FMI protocol. Through the FMI interface, co-simulation can be achieved with other heterogeneous software that supports FMI. The simulation engine of the GCAir simulation and test integrated software developed by Beijing Shiguan Jinyang Technology Development Co., Ltd. is one of the entities that actually runs the simulation model. It receives commands from the upper computer GCAir through TCP for simulation calculation and feeds back the simulation result data to GCAir in real time.
[0003] The FMU file running on the GCAir real-time simulator needs to meet at least one of the following conditions: (1) Include the 64-bit Linux version dynamic library (*.so) of the model; (2) Include the source code of the model and the corresponding Makefile file or Configure script, and can be correctly compiled under the Linux system. Currently, the FMU models exported from common modeling software in the engineering field do not have the ability to run correctly on the GCAir real-time simulator.
[0004] Therefore, how to solve the problem that the existing models cannot run correctly on the real-time simulator based on the GCAir simulation engine is a technical problem that needs to be urgently solved by those skilled in the art. Summary of the Invention
[0005] In view of this, the embodiments of this application provide a method and device for generating an FMU model based on Linux, aiming to solve the problem that the existing models cannot run correctly on the real-time simulator based on the GCAir simulation engine.
[0006] In a first aspect, the embodiments of this application provide a method for generating an FMU model based on Linux, including:
[0007] Based on the modeling software, establish an FMU pre-encapsulation model;
[0008] Use the FMU pre-encapsulation model to encapsulate and generate an FMU model based on Windows;
[0009] Use a compilation code tool to compile the Windows-based FMU model to generate a Linux-based FMU model.
[0010] Optionally, establishing an FMU pre-packaged model based on the modeling software includes:
[0011] Set the result output interface and a fixed-step solver;
[0012] Based on the modeling software, use the result output interface and the fixed-step solver to establish an FMU pre-packaged model.
[0013] Optionally, using the FMU pre-packaged model to package and generate a Windows-based FMU model includes:
[0014] Set the save type and the path to export the model;
[0015] According to the save type and the path to export the model, package and create the Windows-based FMU model, and the Windows-based FMU model is an FMU model that retains the source code.
[0016] Optionally, using the compilation code tool to compile the Windows-based FMU model to generate a Linux-based FMU model includes:
[0017] Unzip the Windows-based FMU model to obtain a file set, and the file set includes a sources folder;
[0018] Copy multiple files of the compilation code tool to the sources folder, and the multiple files of the compilation code tool include a running file;
[0019] Run the running file in the sources folder as an administrator;
[0020] Copy the result file set to the Windows-based FMU model to generate a Linux-based FMU model, and the result file set is the multiple files of the compilation code tool in the sources folder except the running file.
[0021] Optionally, before unzipping the Windows-based FMU model to obtain a file set, the method further includes:
[0022] Unzip the Makefile program to obtain the multiple files of the compilation code tool.
[0023] Optionally, after establishing the FMU pre-packaged model based on the modeling software, the method further includes:
[0024] Obtain the operation curve of the pre-packaged FMU model;
[0025] After compiling the Windows-based FMU model using the compilation code tool to generate a Linux-based FMU model, the method further includes:
[0026] Import the Linux-based FMU model into the simulation engine, where the simulation engine includes a host computer local Windows simulation engine and a slave computer Linux real-time simulation engine;
[0027] Obtain a first simulation result, where the first simulation result is the simulation result of the host computer local Windows simulation engine;
[0028] Obtain a second simulation result, where the second simulation result is the simulation result of the slave computer Linux real-time simulation engine;
[0029] Compare the first simulation result, the second simulation result, and the operation curve of the pre-packaged FMU model to verify the simulation ability of the Linux-based FMU model.
[0030] In a second aspect, an embodiment of the present application provides a Linux-based FMU model generation device, including:
[0031] A model creation module for establishing a pre-packaged FMU model based on modeling software;
[0032] A packaging module for using the pre-packaged FMU model to package and generate a Windows-based FMU model;
[0033] A compilation module for using a compilation code tool to compile the Windows-based FMU model to generate a Linux-based FMU model.
[0034] Optionally, the compilation module includes:
[0035] A first decompression unit for decompressing the Windows-based FMU model to obtain a file set, where the file set includes a sources folder;
[0036] A first copying unit for copying multiple files of the compilation code tool to the sources folder, where the multiple files of the compilation code tool include a running file;
[0037] A running module for running the running file in the sources folder as an administrator;
[0038] A second copying unit, configured to copy the set of result files to the Windows-based FMU model to generate a Linux-based FMU model, where the set of result files are multiple files of a compilation code tool in the sources folder except for the running file.
[0039] In a third aspect, an embodiment of the present application provides a device, which includes a memory and a processor. The memory is used to store instructions or code, and the processor is used to execute the instructions or code so that the device executes the method for generating a Linux-based FMU model according to any one of the foregoing first aspects.
[0040] In a fourth aspect, an embodiment of the present application provides a computer storage medium, in which code is stored. When the code is run, the device running the code implements the method for generating a Linux-based FMU model according to any one of the foregoing first aspects.
[0041] An embodiment of the present application provides a method and a device for generating a Linux-based FMU model. When executing the method, first, based on a modeling software, an FMU pre-packaged model is established; then, using the FMU pre-packaged model, a Windows-based FMU model is generated by encapsulation; finally, using a compilation code tool, the Windows-based FMU model is compiled to generate a Linux-based FMU model. In this way, by compiling and transforming the Windows-based FMU model with a compilation code tool, it becomes a Linux-based FMU model that can be adapted to a real-time simulator, has real-time simulation capabilities, and is consistent with the simulation results of the original environment modeling software, solving the problem that the existing model cannot run correctly in a real-time simulator based on the GCAir simulation engine, and at the same time having the Windows non-real-time simulation function. Description of the Drawings
[0042] To more clearly illustrate the technical solutions in the embodiments or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, for some embodiments described below, those of ordinary skill in the art can obtain other drawings without creative efforts based on these drawings.
[0043] Figure 1 It is a configuration diagram of the IP address of the lower computer simulation engine provided by an embodiment of the present application;
[0044] Figure 2 It is a flowchart of a method for generating a Linux-based FMU model provided by an embodiment of the present application;
[0045] Figure 3Directory structure diagram of the FMU model provided by the embodiments of the present application;
[0046] Figure 4 Another method flowchart of the FMU model generation method based on Linux provided by the embodiments of the present application;
[0047] Figure 5 Schematic diagram of the result output interface provided by the embodiments of the present application;
[0048] Figure 6 Schematic diagram of the fixed-step solver setting provided by the embodiments of the present application;
[0049] Figure 7 Operating curve graph of the FMU pre-packaged model provided by the embodiments of the present application;
[0050] Figure 8 Schematic diagram of the save type provided by the embodiments of the present application;
[0051] Figure 9 Schematic diagram of the path for exporting the model provided by the embodiments of the present application;
[0052] Figure 10 Schematic diagram of the FMU model based on Windows provided by the embodiments of the present application;
[0053] Figure 11 Schematic diagram of multiple files of the compilation code tool provided by the embodiments of the present application;
[0054] Figure 12 Schematic diagram of decompressing the FMU model based on Windows provided by the embodiments of the present application;
[0055] Figure 13 Schematic diagram of copying files provided by the embodiments of the present application;
[0056] Figure 14 Schematic diagram of operation provided by the embodiments of the present application;
[0057] Figure 15 Schematic diagram of judging successful operation provided by the embodiments of the present application;
[0058] Figure 16 Schematic diagram of copying provided by the embodiments of the present application;
[0059] Figure 17 Schematic diagram of importing provided by the embodiments of the present application;
[0060] Figure 18 Schematic diagram of the engine setting provided by the embodiments of the present application;
[0061] Figure 19 Schematic diagram of the first simulation result provided by the embodiments of the present application;
[0062] Figure 20 Another schematic diagram of engine settings provided by the embodiments of the present application;
[0063] Figure 21 The second schematic diagram of simulation results provided by the embodiments of the present application;
[0064] Figure 22 A schematic structural diagram of an FMU model generation device based on Linux provided by the embodiments of the present application. Detailed implementation manners
[0065] FMI (Functional Mock-up Interface) is an open, third-party standard interface protocol independent of modeling software, which can encapsulate a model into an FMU (Functional Mock-up Unit) according to the FMI protocol. Through the FMI interface, co-simulation can be realized with other heterogeneous software that supports FMI.
[0066] The simulation engine (SimulationEngine) of the GCAir simulation and test integrated software developed by Beijing Shiguan Jinyang Technology Development Co., Ltd. is one of the entities that actually runs the simulation model. It receives commands from the upper computer GCAir through TCP for simulation calculations and feeds back the simulation result data to GCAir in real time.
[0067] When performing real-time simulation calculations, the IP address of the simulation engine of the lower computer (real-time simulation machine) can be configured in the upper computer GCAir simulation tool for real-time simulation. Refer to Figure 1 , Figure 1 The IP address configuration diagram of the lower computer simulation engine provided by the embodiments of the present application. In this way, the Linux real-time simulation engine can inherit all the functions of the Windows version simulation engine. For example, the existing GCAir simulation model can be migrated from the Windows version simulation engine to the real-time simulation engine.
[0068] When automatically recompiling the FMU, the real-time simulation engine will automatically attempt to compile the corresponding Linux dynamic library and package a new FMU to replace the old one. If the FMU file does not contain a usable Linux dynamic library, the real-time simulation engine will look for a Makefile in the source code path of the FMU. If the Makefile does not exist, it will continue to look for a Configure script. If neither exists, the FMU cannot be compiled. Therefore, the GCAir real-time simulation has certain requirements for the model, that is, the FMU file running on the GCAir real-time simulator must meet at least one of the following conditions: (1) contain the 64-bit Linux dynamic library (*.so) of the model; (2) contain the source code of the model and the corresponding Makefile or Configure script and can be correctly compiled under the Linux system.
[0069] The method provided by the embodiment of the present application is executed by a computer device and is used to solve the problem that the existing model cannot run correctly in the real-time simulator based on the GCAir simulation engine.
[0070] Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts belong to the scope of protection of the present application.
[0071] See Figure 2 , Figure 2 FIG. is a flowchart of a method for generating an FMU model based on Linux provided by an embodiment of the present application, including:
[0072] Step S201: Based on modeling software, establish a pre-packaged FMU model.
[0073] Currently, common modeling software in the engineering field includes Simulink, SimulationX, AMESim, Dymola, C / C++, Fortran, etc. These modeling software can all convert FMU files, but the exported FMU models do not have the ability to run correctly on the GCAir real-time simulator. Therefore, one of the above modeling software can be used for environment preparation and a preliminary pre-packaged FMU model can be established.
[0074] Step S202: Use the pre-packaged FMU model to package and generate a Windows-based FMU model.
[0075] Based on the modeling software, the pre-packaged FMU model can be packaged to generate a Windows-based FMU model.
[0076] Among them, the Windows-based FMU model can essentially be regarded as a compressed package. By changing its suffix name to conform to the directory structure of the FMU model, it can run correctly. See Figure 3 , Figure 3 is the directory structure diagram of the FMU model provided by the embodiments of this application. In the figure, the FMU model Simcap includes sources (including simcap.c, fmuTemplate.c, fmuTemplate.h), documentation (including index.html, and index.html includes plot_h.PNG), binaries (including win64, and win64 includes simcap.dll), modelDescription.xml, and model.png.
[0077] When the above files are provided, first use a compression tool (such as 7zip) to compress the folder simcap into simcap.zip (only the.zip compression algorithm is allowed), and then change.zip to.fmu. After obtaining simcap.fmu, this FMU can be used.
[0078] It should be noted that the names of the directory folders are all necessary, and try not to change the names; win64 represents for 64-bit computers, and the dll file is necessary; if you want to keep the code confidential, the source files under the sources folder can be not provided; model.png is the display icon of this FMU, and try to provide it; modelDescription.xml is used to provide the basic information of the FMU and is necessary.
[0079] Step S203: Use a compilation code tool to compile the Windows-based FMU model to generate a Linux-based FMU model.
[0080] The compilation code tool can perform a "makefile" compilation operation on the Windows-based FMU model, so that the compiled result is a Linux version FMU model that supports the GCAir real-time simulator to run. Preferably, the compilation code tool can be makefile_gen.exe developed by Beijing Shiguan Jinyang Technology Development Co., Ltd.
[0081] In summary, in this embodiment, the FMU model based on Windows is compiled and transformed by a code compilation tool to become a Linux-based FMU model that can be adapted to a real-time simulator, has real-time simulation capabilities, and is consistent with the simulation results of the original environment modeling software, solving the problem that the existing model cannot run correctly in the real-time simulator based on the GCAir simulation engine, and at the same time having the Windows non-real-time simulation function.
[0082] In the embodiment of the present application, there are multiple possible implementation manners for the above Figure 2 steps, which will be introduced separately below. It should be noted that the implementation manners given in the following introduction are only for illustrative purposes and do not represent all the implementation manners of the embodiment of the present application.
[0083] Refer to Figure 4 , which is another flowchart of the method for generating a Linux-based FMU model provided by the embodiment of the present application, including:
[0084] Step S401: Based on the modeling software, establish a pre-packaged FMU model.
[0085] Specifically, the result output interface and the fixed-step solver can be set first; then, based on the modeling software, using the result output interface and the fixed-step solver, a pre-packaged FMU model is established.
[0086] Taking the modeling software as Simulink as an example, the process of setting the result output interface and the fixed-step solver is introduced. Among them, the process of setting the result output interface refers to Figure 5 , Figure 5 , which is a schematic diagram of the result output interface provided by the embodiment of the present application. Defining the result output interface through Simulink can provide a basis for verifying whether the simulation results of the packaged FMU model in the GCAir simulation test integrated environment are consistent with the results of the original modeling software simulation environment; the process of setting the fixed-step solver refers to Figure 6 , Figure 6 , which is a schematic diagram of the fixed-step solver setting provided by the embodiment of the present application. The Simulink solver can be divided into two categories: variable-step solvers and fixed-step solvers. Considering the simulation requirements, a fixed-step solver must be used when generating real-time operation code, so the solver needs to be set to a fixed-step solver.
[0087] As a possible implementation manner, after establishing a pre-packaged FMU model based on the modeling software, the operation curve of the pre-packaged FMU model can be obtained. On the one hand, it can be confirmed whether the model can run normally; on the other hand, it can provide comparison data for subsequent testing and verification after packaging. Refer to Figure 7 , Figure 7This is the operating curve graph of the FMU pre-packaged model provided by the embodiment of the present application.
[0088] Step S402: Use the FMU pre-packaged model to encapsulate and generate a Windows-based FMU model.
[0089] See Figure 8 , Figure 8 This is the schematic diagram of the save types provided by the embodiment of the present application. The save types for encapsulating the Windows-based FMU model include Web view, protected model... stand-alone FMU, etc. Therefore, the save type can be selectively set to stand-alone FMU.
[0090] See Figure 9 , Figure 9 This is the schematic diagram of the path for exporting the model provided by the embodiment of the present application. The path for exporting the model can be set as needed and is not limited herein. As a possible implementation, only check "Save source code to FMU" in the export dialog box to retain the source code. In this way, according to the save type and the path for exporting the model, the created Windows-based FMU model is encapsulated as an FMU model with the source code retained.
[0091] The generated Windows-based FMU model can be seen in Figure 10 , Figure 10 This is the schematic diagram of the Windows-based FMU model provided by the embodiment of the present application.
[0092] Step S403: Unzip the Makefile program to obtain multiple files of the compilation code tool.
[0093] The Makefile program is a compilation code tool program developed by Beijing Shiguan Jinyang Technology Development Co., Ltd. Unzipping this Makefile program can obtain multiple files of the compilation code tool. The multiple files of the compilation code tool include the running file makefile_gen.exe, and also include fmi2Functions.h, fmi2FunctionTypes.h, fmi2TypesPlatform.h, Makefile, and Usage.txt file. See Figure 11 , Figure 11 This is the schematic diagram of multiple files of the compilation code tool provided by the embodiment of the present application.
[0094] Step S404: Unzip the Windows-based FMU model to obtain a file set.
[0095] As a possible implementation, the Windows-based FMU model can be unzipped using the compression tool 7zip. SeeFigure 12 , Figure 12 It is a schematic diagram of decompressing a Windows-based FMU model provided by an embodiment of this application. The decompressed file set includes a sources folder.
[0096] Step S405: Copy multiple files of the compilation code tool to the sources folder.
[0097] See Figure 13 , Figure 13 It is a schematic diagram of copying files provided by an embodiment of this application. After copying multiple files to the sources folder, the running file can be run, and the files in the sources folder can be used to change multiple files of the compilation code tool to implement the transformation of the FMU model.
[0098] Step S406: Run the running file in the sources folder as an administrator.
[0099] See Figure 14 , Figure 14 It is a schematic diagram of running provided by an embodiment of this application. Running the running file as an administrator changes multiple files of the compilation code tool to implement the transformation of the FMU model. After successful running, subsequent steps can be carried out. Whether the running is successful can be determined through the makefile file. See Figure 15 , Figure 15 It is a schematic diagram of judging successful running provided by an embodiment of this application. Through the content selected by the black box, it can be judged whether the current running is successful.
[0100] Step S407: Copy the result file set to the Windows-based FMU model to generate a Linux-based FMU model.
[0101] The result file set is multiple files of the compilation code tool in the sources folder except the running file. Copying the result file set to the Windows-based FMU model means copying fmi2Functions.h, fmi2FunctionTypes.h, fmi2TypesPlatform.h, and Makefile into the compressed package of the original FMU model. See Figure 16 , Figure 16 It is a schematic diagram of copying provided by an embodiment of this application. In this way, the two versions of the FMU are merged so that it has both Linux real-time and Windows non-real-time simulation functions at the same time, and the two simulation results are consistent.
[0102] Step S408: Verify the simulation ability of the Linux-based FMU model.
[0103] First, import the Linux-based FMU model into the simulation engine, which includes a host computer local Windows simulation engine and a slave computer Linux real-time simulation engine; then, obtain a first simulation result, which is the simulation result of the host computer local Windows simulation engine; next, obtain a second simulation result, which is the simulation result of the slave computer Linux real-time simulation engine; finally, compare the first simulation result, the second simulation result, and the operation curve of the pre-encapsulated FMU model to verify the simulation ability of the Linux-based FMU model. If the three are the same, it proves that the simulation ability of the Linux-based FMU model meets the preset requirements.
[0104] As a possible implementation, the simulation engine can be the GCAir simulation engine. First, the Linux-based FMU model can be imported into GCAir, see Figure 17 , Figure 17 , which is the import schematic diagram provided by the embodiment of the present application; then, set the local Windows simulation engine to obtain the first simulation result, see Figure 18 , 19 , Figure 18 , which is the engine setting schematic diagram provided by the embodiment of the present application, Figure 19 , which is the first simulation result schematic diagram provided by the embodiment of the present application; then, change the slave computer Linux real-time simulation engine to obtain the second simulation result, see Figure 20 , 21 , Figure 20 , which is another engine setting schematic diagram provided by the embodiment of the present application, Figure 21 , which is the second simulation result schematic diagram provided by the embodiment of the present application; finally, compare the first simulation result, the second simulation result, and the operation curve of the pre-encapsulated FMU model to verify the simulation ability of the Linux-based FMU model.
[0105] In summary, in this embodiment, by expanding the compilation code tool to compile the Windows-based FMU model, it provides a feasible implementation plan for transforming the Windows-based FMU model into a Linux-based FMU model that can be adapted to a real-time simulator, has real-time simulation capabilities, and is consistent with the simulation results of the original environment modeling software, solves the problem that the existing model cannot run correctly in the real-time simulator based on the GCAir simulation engine, and at the same time has the Windows non-real-time simulation function; moreover, by obtaining the simulation results and comparing them with those before the transformation, the simulation ability of the transformed FMU model is verified, which is beneficial to improving the accuracy of this method.
[0106] The above are some specific implementation manners of the Linux-based FMU model generation method provided by the embodiments of the present application. Based on this, the present application also provides a corresponding device. The device provided by the embodiments of the present application will be introduced from the perspective of functional modularization below.
[0107] See Figure 22 The structural schematic diagram of the Linux-based FMU model generation device shown in the figure. The device includes a model creation module 2201, a packaging module 2202, and a compilation module 2203.
[0108] The model creation module 2201 is used to establish an FMU pre-packaged model based on modeling software;
[0109] The packaging module 2202 is used to use the FMU pre-packaged model to package and generate a Windows-based FMU model;
[0110] The compilation module 2203 is used to use a compilation code tool to compile the Windows-based FMU model to generate a Linux-based FMU model.
[0111] As a possible implementation manner, the model creation module 2201 includes:
[0112] The first setting unit is used to set a result output interface and a fixed-step solver;
[0113] The model creation unit is used to establish an FMU pre-packaged model based on the modeling software by using the result output interface and the fixed-step solver.
[0114] As a possible implementation manner, the packaging module 2202 includes:
[0115] The second setting unit is used to set a save type and a path for exporting the model;
[0116] The packaging unit is used to package and create the Windows-based FMU model according to the save type and the path for exporting the model. The Windows-based FMU model is an FMU model that retains source code.
[0117] As a possible implementation manner, the compilation module 2203 includes:
[0118] The first decompression unit is used to decompress the Windows-based FMU model to obtain a file set, and the file set includes a sources folder;
[0119] The first copying unit is used to copy multiple files of the compilation code tool to the sources folder. The multiple files of the compilation code tool include a running file;
[0120] A running module, configured to run the running file in the sources folder as an administrator;
[0121] A second copying unit, configured to copy the result file set to the Windows-based FMU model to generate a Linux-based FMU model, where the result file set is multiple files of a compilation code tool in the sources folder except the running file.
[0122] As a possible implementation manner, the device further includes:
[0123] A second decompression unit, configured to decompress the Makefile program to obtain multiple files of the compilation code tool.
[0124] As a possible implementation manner, the device further includes:
[0125] A curve acquisition module, configured to acquire the running curve of the FMU pre-packaged model;
[0126] A model import module, configured to import the Linux-based FMU model into a simulation engine, where the simulation engine includes a host computer local Windows simulation engine and a slave computer Linux real-time simulation engine;
[0127] A first simulation module, configured to obtain a first simulation result, where the first simulation result is the simulation result of the host computer local Windows simulation engine;
[0128] A second simulation module, configured to obtain a second simulation result, where the second simulation result is the simulation result of the slave computer Linux real-time simulation engine;
[0129] A comparison module, configured to compare the first simulation result, the second simulation result, and the running curve of the FMU pre-packaged model to verify the simulation ability of the Linux-based FMU model.
[0130] The embodiment of the present application further provides a corresponding device and a computer storage medium for implementing the solution provided by the embodiment of the present application.
[0131] Wherein, the device includes a memory and a processor, the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes the Linux-based FMU model generation method described in any embodiment of the present application.
[0132] The computer storage medium stores code, and when the code is run, the device running the code implements the Linux-based FMU model generation method described in any embodiment of the present application.
[0133] In the embodiments of the present application, the "first", "second" (if any) in the names such as "first" and "second" are only used as name identifiers and do not represent the first and second in order.
[0134] From the description of the above embodiments, those skilled in the art can clearly understand that all or part of the steps in the above embodiment methods can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, and the computer software product can be stored in a storage medium, such as a read-only memory (ROM) / RAM, magnetic disk, optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment or some parts of the embodiments of the present application.
[0135] Each embodiment in this specification is described in a progressive manner. The same or similar parts between each embodiment can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0136] The above description is only an exemplary embodiment of the present application and is not used to limit the protection scope of the present application.
Claims
1. A method for generating an FMU model based on Linux, characterized in that, the method includes: Based on modeling software, establish a pre-packaged FMU model; Using the pre-packaged FMU model, encapsulate and generate an FMU model based on Windows; Unzip the Makefile program to obtain multiple files of the compilation code tool; Using the compilation code tool, compile the FMU model based on Windows to generate an FMU model based on Linux; specifically including: unzip the FMU model based on Windows to obtain a file set, the file set includes a sources folder; copy the multiple files of the compilation code tool to the sources folder, the multiple files of the compilation code tool include a running file; run the running file in the sources folder as an administrator; copy the result file set to the FMU model based on Windows to generate an FMU model based on Linux, the result file set is the multiple files of the compilation code tool in the sources folder except the running file.
2. The method according to claim 1, characterized in that, the establishing a pre-packaged FMU model based on modeling software includes: Set the result output interface and the fixed-step solver; Based on the modeling software, use the result output interface and the fixed-step solver to establish a pre-packaged FMU model.
3. The method according to claim 1, characterized in that, the using the pre-packaged FMU model to encapsulate and generate an FMU model based on Windows includes: Set the save type and the path for exporting the model; According to the save type and the path for exporting the model, encapsulate and create the FMU model based on Windows, and the FMU model based on Windows is an FMU model that retains the source code.
4. The method according to claim 1, characterized in that, after establishing the pre-packaged FMU model based on the modeling software, the method further includes: Obtain the running curve of the pre-packaged FMU model; after using the compilation code tool to compile the FMU model based on Windows to generate an FMU model based on Linux, the method further includes: Import the FMU model based on Linux into the simulation engine, and the simulation engine includes a host computer local Windows simulation engine and a slave computer Linux real-time simulation engine; Obtain a first simulation result, and the first simulation result is the simulation result of the host computer local Windows simulation engine; Obtain a second simulation result, and the second simulation result is the simulation result of the slave computer Linux real-time simulation engine; Compare the first simulation result, the second simulation result and the running curve of the pre-packaged FMU model to verify the simulation ability of the FMU model based on Linux.
5. An apparatus for generating an FMU model based on Linux, characterized in that, the apparatus includes: A model creation module for establishing a pre-packaged FMU model based on modeling software; A packaging module for generating a Windows-based FMU model by packaging using the pre-packaged FMU model; A second decompression unit for decompressing the Makefile program to obtain multiple files of the compilation code tool; A compilation module for compiling the Windows-based FMU model using the compilation code tool to generate a Linux-based FMU model; The compilation module includes: A first decompression unit for decompressing the Windows-based FMU model to obtain a file set, and the file set includes a sources folder; A first copying unit for copying the multiple files of the compilation code tool to the sources folder, and the multiple files of the compilation code tool include a running file; A running module for running the running file in the sources folder as an administrator; A second copying unit for copying the result file set to the Windows-based FMU model to generate a Linux-based FMU model, and the result file set is the multiple files of the compilation code tool in the sources folder except the running file.
6. A device, characterized in that, the device includes a memory and a processor, the memory is used for storing instructions or codes, and the processor is used for executing the instructions or codes so that the device executes the method for generating a Linux-based FMU model according to any one of claims 1 to 4.
7. A computer storage medium, characterized in that, the computer storage medium stores codes, and when the codes are run, the computer storage device running the codes implements the method for generating a Linux-based FMU model according to any one of claims 1 to 4.
Citation Information
Patent Citations
Simulation model interface adaptation development system and working method thereof
CN111367511A