CN114721776A - Method for generating Modelica simulation component of Matlab language - Google Patents

Method for generating Modelica simulation component of Matlab language Download PDF

Info

Publication number
CN114721776A
CN114721776A CN202210365973.XA CN202210365973A CN114721776A CN 114721776 A CN114721776 A CN 114721776A CN 202210365973 A CN202210365973 A CN 202210365973A CN 114721776 A CN114721776 A CN 114721776A
Authority
CN
China
Prior art keywords
state
function
file
inputting
entering
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.)
Pending
Application number
CN202210365973.XA
Other languages
Chinese (zh)
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.)
China Three Gorges University CTGU
Original Assignee
China Three Gorges University CTGU
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 China Three Gorges University CTGU filed Critical China Three Gorges University CTGU
Priority to CN202210365973.XA priority Critical patent/CN114721776A/en
Publication of CN114721776A publication Critical patent/CN114721776A/en
Pending legal-status Critical Current

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
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • 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
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45516Runtime code conversion or optimisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention relates to a method for generating a Modelica simulation component of Matlab language, which comprises the following steps: acquiring dynamic libraries to be converted and Matlab functions from a specified folder one by one; analyzing to obtain a return value type, a function name and a function parameter list of each Matlab function; generating a project file and a source code file; generating an external function which accords with Modelica use specifications for each Matlab function in a code file; compiling the generated project into a dynamic library file; and establishing an mo file corresponding to the external language function, introducing the external function into the Modelica function, and generating the Modelica component. The invention provides an automatic conversion method for batch generation of Modelica components by a dynamic library compiled by Matlab language, which is convenient for computer execution, replaces manpower, and greatly improves conversion efficiency.

Description

Modelica simulation component generation method of Matlab language
Technical Field
The invention belongs to the field of computer simulation, and particularly relates to a method for generating a Modelica simulation component of Matlab language.
Background
Modelica is an open-source multi-field unified modeling language, has object-oriented characteristics and non-causal relationship modeling capability, has better interactivity and stronger model expression force, and is widely applied to the multi-field simulation field.
When the Modelica is adopted for system simulation, modeling can be performed by using a Modelica language, and modeling can also be performed by using an external language function written by a C language or a Fortran language. When modeling an external language function, a common method is to write a Modelica function with the same interface as the original external language function according to the Modelica language specification, perform parameter type mapping according to a parameter mapping rule, and call the external language function to realize the Modelica function through an external keyword in a dynamic library mode. At present, the manual method has two problems: firstly, because the method needs programmers with professional knowledge to compile codes, the operation difficulty is high, and the efficiency is low; secondly, because the Modelica language can adopt a Mingw or vs compiler to compile the C language source code, when the selected compiler is different from the compiler used for manufacturing the external function dynamic library, the conventional method needs to obtain the source code of the external function, and then uses the compiler same as the Modelica to regenerate the external function dynamic library, otherwise, the modeling fails.
Disclosure of Invention
The invention aims to solve the problems, and provides a method for generating a Modelica simulation component of Matlab language, which automatically converts a dynamic library compiled by Matlab language by using a secondary packaging method to generate a Modelica component, replaces manpower, solves the problem that an external function dynamic library compiled by a non-Mingw compiler cannot be used in a Modelica environment of a selected Mingw compiler, and avoids the need of acquiring a source code; the conversion process is carried out in batch, and the conversion efficiency is greatly improved.
The invention combines the dynamic library conversion and mo file description mode to realize that the Matlab function provided by the dynamic library mode is made into a Modelica component, and the original dynamic library function is encapsulated by generating a new dynamic library, thereby realizing the compatibility of a compiler and the interface conversion.
The technical scheme of the invention is a method for generating a Modelica simulation component of Matlab language, which comprises the following steps:
step 1: acquiring dynamic libraries to be converted and Matlab functions from a specified folder one by one;
step 2: analyzing to obtain a return value type, a function name and a function parameter list of each Matlab function;
and step 3: generating a project file and a source code file;
and 4, step 4: generating an external function which accords with Modelica use specifications for each Matlab function in a code file;
step 4.1: adding include of the original dynamic library header file in the source code file;
step 4.2: deriving a function prototype from each original dynamic library output in the step 2, and generating a new function prototype in the source code, wherein the return value of the new function is an integer; the new function name is obtained by converting the name of the derived function corresponding to the original dynamic library; the parameter list of the new function is formed by adding a return value parameter of the original function on the basis of the parameter list of the original function;
step 4.3: generating a function body consisting of brace pairs;
step 4.4: generating an execution statement within the function body;
and 5: compiling the project generated in the step 3 into a dynamic library file;
step 6: and establishing an mo file corresponding to the external language function, introducing the external function into the Modelica function, and generating the Modelica component.
Step 1, acquiring a dynamic library to be converted and a Matlab function by adopting a default mode or a configuration file mode. When a default mode is adopted, traversing the dynamic library files with the extension name dll in the appointed folder, searching a header file which is the same as the main file name of the dynamic library file and has the extension name h in the current folder for each dynamic library file, if the header file does not have the extension name h, recording an error, and processing the next dynamic library file until all the dynamic library files are processed; and when the configuration file mode is adopted, reading the configuration file, sequentially reading the dynamic library file and the corresponding header file according to the file name recorded in the configuration file, removing comments from each header file in a text analysis mode, analyzing the header files in a mode of extracting the state transition diagram according to the identifier to obtain an identifier list, and then reading and obtaining the Matlab function prototype from the list in a reverse order.
The step 2 specifically comprises the following substeps:
step 2.1: firstly, acquiring a return value type and a function name of a function from an identifier list;
step 2.2: starting with the left bracket, the function is determined to include a parameter list of parameter types and parameter names according to the function parameter analysis state transition diagram.
Preferably, the function parameter analysis state transition diagram includes a set of states {0, 1, 2, 3, 5, 7, 8, 9, 11, 12, 13, 22}, where state 0 is an initial state.
The state processing flow of the function parameter analysis comprises the following steps:
1) in the state 0, inputting a blank and continuously keeping the state 0; inputting letters to enter a state 1; input ")" enter state 8; otherwise, state 9 is entered;
2) in the state 1, inputting letters and numbers and keeping the state 1; inputting a space to enter a state 2; input "+" goes to state 3; enter "," enter state 5; input ")" enter state 8; entering "(", ";" or other entry state 9;
3) in the state 2, inputting a blank and keeping the state 2, and inputting letters to enter the state 11; input "+" into state 3; input "," enter state 5; input ")" enter state 8; enter other entry state 9;
4) in the state 3, inputting a star and keeping the blank in the state 3; input "," enter state 5; input ")" enter state 8; entering letters into state 12; enter other entry state 9;
5) in the state 5, inputting a blank and keeping the state 5; inputting letters to enter a state 1; enter other entry state 9;
6) in the state 7, inputting a blank and keeping the state 7; enter other entry state 9;
7) in the state 8, inputting a blank and keeping the state 8; input "; "enter state 7; enter other entry state 9;
8) in the state 9, returning to-1, and ending the state processing flow;
9) in the state 11, inputting letters and numbers to keep the state 11; enter a space entry state 22; input "," enter state 5; input ")" enter state 8; enter other entry state 9;
10) in the state 12, inputting letters and numbers to keep the state 12; input space enter state 13; input "," enter state 5; input ")" enter state 8; enter other entry state 9;
11) in the state 13, the input space continues to be maintained in the state 13; input "," enter state 5; input ")" enter state 8; enter other entry state 9;
12) in the state 22, inputting a space continues to maintain the state 22; entering letters into state 11; enter "," enter state 5; input ")" enter state 8; the other entry state 9 is entered.
The step 3 specifically comprises the following substeps:
step 3.1: generating a project file with Mingw specification in a program mode;
step 3.2: generating a C language source code file, wherein the file name of the source code file is obtained by converting the file name of an original dynamic library; and adds the source code file to the project generated in step 3.1.
The step 6 specifically comprises the following substeps:
step 6.1: generating a Modelica language function name according to an external function name, and generating a function name prefix according to a certain rule to avoid renaming;
step 6.2: mapping the Input and Output types and the data types of the parameters into Input and Output of Modelica language and corresponding data types according to the language specification;
step 6.3: and generating a function name, a dynamic library file path and a header file path which are referenced by the external, generating a component installation guide file in an XML format, uniformly outputting related dynamic library files, static library files, mo files and XML files to the same folder, and determining whether to compress and package according to application requirements.
In step 4.4, for the dynamic library adopting the mwArray data type, firstly generating a temporary variable of the mwArray type for each parameter in the newly generated function parameter list in the function body, and assigning values for the newly generated temporary variable in different assignment modes according to the parameter combination type such as a common type and an array type; calling the original dynamic library function by using temporary variables, wherein the calling result is an mwArray type variable, and the mwArray is reversely converted into the parameter type of the function prototype and then returned.
Compared with the prior art, the invention has the beneficial effects that:
1) the invention provides an automatic conversion method and an automatic conversion system for batch generation of Modelica components by a dynamic library compiled by Matlab language, which are convenient for computer execution, replace manpower, save time and labor, greatly improve conversion efficiency and facilitate cross-language modeling simulation on a Modelica simulation platform;
2) the invention solves the problem that a compiler selected by a Modelica simulation system and a compiler used for manufacturing a Matlab function dynamic library are not simultaneously difficult to convert due to the limitation of a Modelica self interface.
Drawings
The invention is further illustrated by the following figures and examples.
Fig. 1 is a schematic diagram of a Modelica module batch production system according to an embodiment of the present invention.
Fig. 2 is an input/output schematic diagram of a Modelica component batch generation system according to an embodiment of the present invention.
FIG. 3 is a diagram of identifier extraction state transition according to an embodiment of the present invention.
FIG. 4 is a functional parameter analysis state transition diagram according to an embodiment of the present invention.
Fig. 5 is a schematic diagram of a configuration file according to an embodiment of the present invention.
Fig. 6 is a schematic diagram of header file contents according to an embodiment of the present invention.
Detailed Description
Example one
As shown in fig. 1, the Modelica component batch generation system includes:
the batch extraction component is used for acquiring original files such as dynamic libraries, header files and the like to be processed in batches from the folder;
the function analysis component is used for analyzing and obtaining a return value type, a function name and a function parameter list of each export function of the corresponding dynamic library from the header file to be processed, wherein the function parameter list comprises an input and output type, a parameter data type and a parameter name of a parameter;
the project generating component is used for generating a new external dynamic library project which accords with Modelica specifications and realizes the encapsulation and calling of an original dynamic library;
the function generation component generates an external function which accords with the Modelica use specification, and the generated external function has different prototypes and function realization codes according to different languages adopted by the original dynamic library;
the project compiling component automatically calls a system compiler to compile the newly generated project and source code files into a dynamic library which accords with the Modelica use specification, and finishes compiling the dynamic library engineering and the source code;
and the Modelica component generating part is used for establishing a corresponding mo file for the external function and generating the Modelica component.
The method for generating the Modelica simulation component of the Matlab language of the system comprises the following steps:
step 1: acquiring dynamic libraries to be converted and Matlab functions from a specified folder one by one;
and acquiring a dynamic library to be converted and a Matlab function by adopting a default mode. The folder designated by the user comprises one or more dynamic library files to be processed and corresponding header files thereof. In a default mode, traversing the dynamic library files with the extension name dll in the folder, searching a header file with the extension name h in the current folder for each dynamic library file, wherein the header file has the content shown in fig. 6, if the header file has no record error, processing the next dynamic library file, and ending the processing until all the dynamic library files are processed.
Step 2: analyzing to obtain a return value type, a function name and a function parameter list of each Matlab function;
step 2.1: firstly, acquiring a return value type and a function name of a function from an identifier list;
step 2.2: starting with the left brackets, the function is determined to include a parameter list of parameter types and parameter names according to the function parameter analysis state transition diagram shown in fig. 4.
And step 3: generating a project file and a source code file;
step 3.1: generating a project file with Mingw specification in a program mode;
step 3.2: generating a C language source code file, wherein the source code file name is obtained by converting the original dynamic library file name; and adds the source code file to the project generated in step 3.1.
And 4, step 4: generating an external function which accords with Modelica use specifications for each Matlab function in a code file;
step 4.1: adding include of original dynamic library head file in source code file;
step 4.2: deriving a function prototype from each original dynamic library output in the step 2, generating a new C language function prototype in the source code, wherein the type of a return value of the new function is an integer int type; when the original function is successfully called, returning to 0; calling unsuccessfully to return an integer value indicating an error code; the new function name is obtained by converting the name of the derived function corresponding to the original dynamic library;
uniformly putting input and output parameters related to functions into a parameter list of a new function, wherein const modification is added to the input parameters before variables;
step 4.3: generating a function body consisting of brace pairs;
step 4.4: an execution statement is generated within the function body.
And 5: and calling a Mingw compiler to compile the newly-built project and source code files to generate new dynamic library files and static library files.
Step 6: building an mo file corresponding to an external language function, introducing the external function into a Modelica function, generating a Modelica component, and calling the original dynamic library function by the component file through an annnotion through a newly-built dynamic library function;
step 6.1: generating a Modelica language function name according to an external function name, and generating a function name prefix according to a certain rule in order to avoid duplicate names;
step 6.2: mapping the Input and Output types and the data types of the parameters into Input and Output of Modelica language and corresponding data types according to the language specification;
step 6.3: generating a function name, a dynamic library file path and a header file path which are referenced by the external; the new dynamic library file, the static library file, the header file, the original dynamic library file and the mo file are put together, and the Modelica language model can be used.
The folders specified in the embodiment are dynamic libraries a.dll, b.dll and c.dll and corresponding header files cheadfora.h, cheadforb.h and cheadforc.h. The cheedfora. h document has the declaration of AFUN1, AFUN2, AFUN3 and other functions. Similar cheadforb.h and cheadforc.h files have function declarations of BFUN1, BFUN2, CFUN1, CFUN2 and the like. A.dll, A.lib, B.dll, B.lib, C.dll, C.lib, CHEADForA.h, CHEADForB.h, CHEADForC.h and related files are stored in directory DIR. Embodiments require the use of functions AFUN1, AFUN2, AFUN3, BFUN1, BFUN2, CFUN1, CFUN2, etc. in a simulation system based on a modeica modeling simulation platform.
As shown in fig. 2, the directory DIR of the designated folder is passed as an input parameter to the Modelica component batch generation system of the present invention, the Modelica component batch generation system generates Modelica components in a batch manner, and Matlab functions in the original dynamic library are used as external functions in each Modelica component. The Modelica component can be used in a Modelica simulation system as a native function.
Example two
In the second embodiment, the Modelica component batch generation system which is the same as the first embodiment is adopted.
The method for generating the Modelica simulation component of the Matlab language comprises the following steps:
step 1: acquiring dynamic libraries to be converted and Matlab functions from a specified folder one by one;
and acquiring the dynamic library to be converted and the Matlab function by adopting a configuration file mode, reading the configuration file in the configuration file mode, and sequentially reading the dynamic library file and the corresponding header file according to the file name recorded in the configuration file. And (3) removing comments from each header file in a text analysis mode, analyzing the header files in an identifier extraction state transition diagram mode shown in FIG. 3 to obtain an identifier list, and reading the identifier list in a reverse order from the list to obtain a Matlab function prototype.
Step 2: analyzing to obtain a return value type, a function name and a function parameter list of each Matlab function;
step 2.1: firstly, acquiring a return value type and a function name of a function from an identifier list;
step 2.2: starting with the left brackets, the function is determined to include a parameter list of parameter types and parameter names according to the function parameter analysis state transition diagram shown in fig. 4.
And step 3: generating a project file and a source code file;
step 3.1: generating a project file with Mingw specification in a program mode;
step 3.2: generating a C language source code file, wherein the file name of the source code file is obtained by converting the file name of an original dynamic library; and adds the source code file to the project generated in step 3.1.
And 4, step 4: generating an external function which accords with Modelica use specifications for each Matlab function in a code file;
step 4.1: adding include of the original dynamic library header file in the source code file;
step 4.2: deriving a function prototype from each original dynamic library output in the step 2, generating a new C language function prototype in the source code, wherein the type of a return value of the new function is an integer int type; when the original function is successfully called, returning to 0; calling unsuccessfully to return an integer value indicating an error code; the new function name is obtained by converting the name of the derived function corresponding to the original dynamic library;
uniformly putting input and output parameters related to functions into a parameter list of a new function, wherein const modification is added to the input parameters before variables;
step 4.3: generating a function body consisting of brace pairs;
step 4.4: generating an execution statement within the function body;
for a dynamic library which is written by Matlab and adopts an mwArray data type, firstly, generating a temporary variable of the mwArray type for each parameter in a newly generated function parameter list in a function body correspondingly, and assigning values for the newly generated temporary variable in different assignment modes according to parameter combination types such as common types and array types; and calling the original dynamic library function by using temporary variables, wherein the calling result is an mwArray type variable, and the mwArray is required to be reversely converted into the parameter type of the function prototype and then returned.
And 5: and calling a Mingw compiler to compile the newly-built project and source code files to generate new dynamic library files and static library files.
Step 6: the method comprises the steps of establishing an mo file corresponding to an external language function, introducing the external function into a Modelica function to generate a Modelica component, and calling an original dynamic library function through a newly-built dynamic library function by the component file through annnotion;
step 6.1: generating a Modelica language function name according to an external function name, and generating a function name prefix according to a certain rule in order to avoid duplicate names;
step 6.2: mapping the Input and Output types and the data types of the parameters into Input and Output of Modelica language and corresponding data types according to the language specification;
step 6.3: generating a function name, a dynamic library file path and a header file path which are referenced by the external; the new dynamic library file, the static library file, the header file, the original dynamic library file and the mo file are put together, and the Modelica language model can be used.
In the embodiment, under the original dynamic library folder to be packaged, a text configuration file as shown in fig. 5 is prepared, in which each dynamic library under the folder, a corresponding header file, and a compiler to be used are written. And the packaging program is used for packaging the dynamic libraries generated by different compilers under the same folder by reading the configuration file.

Claims (7)

  1. The method for generating the Modelica simulation component of the Matlab language is characterized by comprising the following steps of:
    step 1: acquiring dynamic libraries to be converted and Matlab functions from a specified folder one by one;
    step 2: analyzing to obtain a return value type, a function name and a function parameter list of each Matlab function;
    and step 3: generating a project file and a source code file;
    and 4, step 4: generating an external function which accords with Modelica use specifications for each Matlab function in a code file;
    step 4.1: adding include of the original dynamic library header file in the source code file;
    step 4.2: deriving a function prototype from each original dynamic library output in the step 2, and generating a new function prototype in the source code, wherein the return value of the new function is an integer; the new function name is obtained by converting the name of the derived function corresponding to the original dynamic library; the parameter list of the new function is formed by adding a return value parameter of the original function on the basis of the parameter list of the original function;
    step 4.3: generating a function body consisting of brace pairs;
    step 4.4: generating an execution statement within the function body;
    and 5: compiling the project generated in the step 3 into a dynamic library file;
    step 6: and establishing an mo file corresponding to the external language function, introducing the external function into the Modelica function, and generating the Modelica component.
  2. 2. The Modelica simulation component generation method according to claim 1, wherein step 1 adopts a default mode or a configuration file mode to obtain a dynamic library and a Matlab function to be converted;
    when a default mode is adopted, traversing the dynamic library files with the extension name dll in the appointed folder, searching a header file which is the same as the main file name of the dynamic library file and has the extension name h in the current folder for each dynamic library file, if the header file does not have the extension name h, recording an error, and processing the next dynamic library file until all the dynamic library files are processed;
    and when the configuration file mode is adopted, reading the configuration file, sequentially reading the dynamic library file and the corresponding header file according to the file name recorded in the configuration file, removing comments from each header file in a text analysis mode, analyzing the header files in a mode of extracting the state transition diagram according to the identifier to obtain an identifier list, and then reading and obtaining the Matlab function prototype from the list in a reverse order.
  3. 3. The Modelica simulation component generation method according to claim 2, wherein the step 2 comprises:
    step 2.1: firstly, acquiring a return value type and a function name of a function from an identifier list;
    step 2.2: starting with the left bracket, the function is determined to include a parameter list of parameter types and parameter names according to the function parameter analysis state transition diagram.
  4. 4. The Modelica simulation component generation method according to claim 3, wherein the function parameter analysis state transition diagram includes a set of states {0, 1, 2, 3, 5, 7, 8, 9, 11, 12, 13, 22}, where state 0 is an initial state, and a state processing flow of function parameter analysis includes:
    1) in the state 0, inputting a blank and continuously keeping the state 0; inputting letters in a state 0, and entering a state 1; input in state 0 ")", enter state 8; otherwise, state 9 is entered for state 0;
    2) in the state 1, inputting letters and numbers and keeping the state 1; inputting a blank in the state 1 and entering the state 2; inputting star in the state 1 and entering the state 3; inputting 'and' in the state 1, and entering the state 5; input in state 1 ")", go to state 8; entering "(", ";" or other characters) in state 1, and entering state 9;
    3) in the state 2, inputting a blank and keeping the state 2; inputting letters in the state 2, and entering the state 11; inputting "" in a state 2, and entering a state 3; input in state 2, enter state 5; input in state 2 ")", go to state 8; inputting other characters in the state 2, and entering the state 9;
    4) in the state 3, inputting a star and keeping the blank in the state 3; inputting 'and' in the state 3, and entering the state 5; input in state 3 ")", go to state 8; inputting letters in the state 3, and entering the state 12; inputting other characters in the state 3, and entering the state 9;
    5) in the state 5, inputting a blank and keeping the state 5; inputting letters in a state 5, and entering a state 1; inputting other characters in the state 5, and entering the state 9;
    6) in the state 7, inputting a blank and keeping the state 7; inputting other characters in the state 7, and entering the state 9;
    7) in the state 8, inputting a blank and keeping the state 8; input at state 8 "; ", go to state 7; inputting other characters in the state 8, and entering the state 9;
    8) in the state 9, returning to-1, and ending the state processing flow;
    9) in the state 11, inputting letters and numbers to keep the state 11; inputting a blank in the state 11, and entering the state 22; inputting, "in the state 11, and entering the state 5; input in state 11 ")", go to state 8; inputting other characters in the state 11, and entering the state 9;
    10) in the state 12, inputting letters and numbers to keep the state 12; inputting a blank in the state 12, and entering the state 13; inputting, "in the state 12, and entering the state 5; input in state 12 ")", go to state 8; inputting other characters in the state 12, and entering the state 9;
    11) in the state 13, the input space continues to be maintained in the state 13; inputting, "in the state 13, and entering the state 5; input in state 13 ")", go to state 8; inputting other characters in the state 13, and entering the state 9;
    12) in the state 22, inputting a space continues to maintain the state 22; inputting letters in the state 22, and entering the state 11; input of "," in the state 22, and enter the state 5; input in state 22 ")", go to state 8; other characters are input in state 22 and state 9 is entered.
  5. 5. The Modelica simulation component generation method according to claim 4, wherein step 3 comprises:
    step 3.1: generating a project file with Mingw specification in a program mode;
    step 3.2: generating a C language source code file, wherein the file name of the source code file is obtained by converting the file name of an original dynamic library; and adds the source code file to the project generated in step 3.1.
  6. 6. The Modelica simulation component generation method according to claim 5, wherein step 6 comprises:
    step 6.1: generating a Modelica language function name according to an external function name, and generating a function name prefix according to a certain rule to avoid duplication of names;
    step 6.2: mapping the Input and Output types and the data types of the parameters into Input and Output of Modelica language and corresponding data types according to the language specification;
    step 6.3: and generating a function name, a dynamic library file path and a header file path which are referenced by the external, generating a component installation guide file in an XML format, uniformly outputting related dynamic library files, static library files, mo files and XML files to the same folder, and determining whether to compress and package according to application requirements.
  7. 7. The Modelica simulation component generation method according to claim 6, wherein in step 4.4, for a dynamic library adopting an mwArray data type, firstly generating a temporary variable of the mwArray type for each parameter in a newly generated function parameter list in a function body, and assigning values to the newly generated temporary variable in different assignment modes according to the parameter combination type; calling the original dynamic library function by using temporary variables, wherein the calling result is an mwArray type variable, and the mwArray is reversely converted into the parameter type of the function prototype and then returned.
CN202210365973.XA 2021-04-13 2021-04-13 Method for generating Modelica simulation component of Matlab language Pending CN114721776A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210365973.XA CN114721776A (en) 2021-04-13 2021-04-13 Method for generating Modelica simulation component of Matlab language

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110395230.2A CN113220309B (en) 2021-04-13 2021-04-13 Multi-language Modelica component batch generation system and method
CN202210365973.XA CN114721776A (en) 2021-04-13 2021-04-13 Method for generating Modelica simulation component of Matlab language

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202110395230.2A Division CN113220309B (en) 2021-04-13 2021-04-13 Multi-language Modelica component batch generation system and method

Publications (1)

Publication Number Publication Date
CN114721776A true CN114721776A (en) 2022-07-08

Family

ID=77087133

Family Applications (3)

Application Number Title Priority Date Filing Date
CN202210365983.3A Active CN114706592B (en) 2021-04-13 2021-04-13 Modelica simulation component generation method facing object and process language
CN202210365973.XA Pending CN114721776A (en) 2021-04-13 2021-04-13 Method for generating Modelica simulation component of Matlab language
CN202110395230.2A Active CN113220309B (en) 2021-04-13 2021-04-13 Multi-language Modelica component batch generation system and method

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202210365983.3A Active CN114706592B (en) 2021-04-13 2021-04-13 Modelica simulation component generation method facing object and process language

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202110395230.2A Active CN113220309B (en) 2021-04-13 2021-04-13 Multi-language Modelica component batch generation system and method

Country Status (1)

Country Link
CN (3) CN114706592B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114722537B (en) * 2022-04-18 2024-06-04 成都工元科技有限公司 Pressure vessel design method, apparatus and medium
CN115033232B (en) * 2022-04-30 2024-05-31 杭州电子科技大学 Open source library packaging method and system of programmable logic controller
CN117806852B (en) * 2024-03-01 2024-05-14 傲拓科技股份有限公司 Interface calling method, device, storage medium and processor

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5522079A (en) * 1993-06-14 1996-05-28 International Business Machines Corporation Compiler merging new and preexisting modules while preserving function order
CN101840334B (en) * 2010-04-16 2013-04-17 中国电子科技集团公司第二十八研究所 Software component service packaging method
US8769486B2 (en) * 2011-01-06 2014-07-01 The Mathworks, Inc. Dynamically generating statically-typed proxies for dynamically-typed functions
CN102402638B (en) * 2011-12-20 2014-11-26 黄天驰 Modelica-language-based simulation modeling method for hydraulic hoisting mechanism
US10296313B2 (en) * 2014-11-18 2019-05-21 Roger James Poon Safely consuming dynamically-typed code from a statically-typed programming language
CN105335213A (en) * 2015-10-28 2016-02-17 苏州同元软控信息技术有限公司 Method for realizing simulation report automatic generation through embedding Modelica model in Word file
DE102016124623A1 (en) * 2016-12-16 2018-06-21 Dspace Digital Signal Processing And Control Engineering Gmbh Method for creating a model compatible with a simulation device
CN106681727B (en) * 2016-12-30 2020-10-02 苏州同元软控信息技术有限公司 Modelica external function graphical editing system and implementation method thereof
CN106681726B (en) * 2016-12-30 2019-11-08 苏州同元软控信息技术有限公司 Python model conversion is the method for Modelica model
US10872027B2 (en) * 2018-04-18 2020-12-22 The Mathworks, Inc. Run-time or compile-time error solutions for locating missing program elements in a programming environment
CN111414695A (en) * 2020-03-19 2020-07-14 苏州同元软控信息技术有限公司 Modelica-based joint simulation system and construction method thereof
CN112115604B (en) * 2020-09-14 2023-07-21 苏州同元软控信息技术有限公司 Combined simulation method and system for Modelica model and Simulink model and electronic equipment

Also Published As

Publication number Publication date
CN114706592A (en) 2022-07-05
CN113220309A (en) 2021-08-06
CN114706592B (en) 2024-04-19
CN113220309B (en) 2022-05-06

Similar Documents

Publication Publication Date Title
CN113220309B (en) Multi-language Modelica component batch generation system and method
CN108920133B (en) Cross-language programming method and device, electronic equipment and storage medium
CN106648662B (en) Report generation device and method based on project cost calculation description language BCL
US20130152061A1 (en) Full fidelity parse tree for programming language processing
Tassi Deriving proved equality tests in Coq-elpi: Stronger induction principles for containers in Coq
CN116450616A (en) General heterogeneous relational database SQL migration method based on parse tree
CN113805890A (en) Method, device, terminal, system and storage medium for migrating applets across applications
CN110457013B (en) Program component configuration device and method
CN110362792B (en) Method and device for converting RN file into applet file and conversion equipment
Waddington et al. High-fidelity C/C++ code transformation
WO2014040766A1 (en) Computer-implemented method for computer program translation
CN111158665B (en) Code generation method and device, electronic equipment and storage medium
CN110110299B (en) Text conversion method, device and server
CN111221519B (en) Python-based CLI automatic export method
CN113835688B (en) Object packaging method of scientific computing language interpreter
CN115509519A (en) Front-end UI component library construction method and system
CN115268918A (en) Automatic conversion method from C + + code to C code based on rule template
CN110018816B (en) Virtual machine control system based on C/C + + compiling system and control method thereof
CN113760360A (en) File generation method, device, equipment and storage medium
Bichler A flexible code generator for MOF-based modeling languages
Kramer et al. Reflection in attribute grammars
CN111857678B (en) Code generation method, device, electronic equipment and computer storage medium
CN117827171A (en) Method and device for generating project source codes through json schema file
CN118092937A (en) Compiling method for converting ST language into C language supporting IEC61131 standard
CN117389547A (en) Encapsulation and debugging method for user side maturation algorithm block

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