CN117891462A - Modelica language-based embedded code generation method and device - Google Patents
Modelica language-based embedded code generation method and device Download PDFInfo
- Publication number
- CN117891462A CN117891462A CN202410081755.2A CN202410081755A CN117891462A CN 117891462 A CN117891462 A CN 117891462A CN 202410081755 A CN202410081755 A CN 202410081755A CN 117891462 A CN117891462 A CN 117891462A
- Authority
- CN
- China
- Prior art keywords
- controller model
- modelica
- target
- test
- language
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 60
- 238000012360 testing method Methods 0.000 claims abstract description 115
- 238000004590 computer program Methods 0.000 claims description 14
- 238000010586 diagram Methods 0.000 description 8
- 238000004891 communication Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 238000004088 simulation Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000033772 system development Effects 0.000 description 2
- 230000006399 behavior Effects 0.000 description 1
- 230000001364 causal effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000013178 mathematical model Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention provides a Modelica language-based embedded code generation method and device, wherein the method comprises the following steps: obtaining a standard comparison table corresponding to a predefined controller model, and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information; generating a corresponding target language code based on Modelica code of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model. The embedded code generation method based on Modelica language can ensure the accuracy of target language code generation.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for generating an embedded code based on a Modelica language.
Background
Embedded controllers are used in a wide range of industries, and as one of the most important components in control systems, the code writing of control algorithms is naturally also of great importance.
The traditional control algorithm is manually written by engineering personnel, has low efficiency, is not suitable for large-scale system development, and is difficult to avoid human error; the existing Modelica platform also does not have the corresponding capability to generate embedded C code.
How to accurately generate the embedded code is a technical problem to be solved at present.
Disclosure of Invention
The invention provides a Modelica language-based embedded code generation method and device, which are used for solving the defects in the prior art.
The invention provides a Modelica language-based embedded code generation method, which comprises the following steps:
obtaining a standard comparison table corresponding to a predefined controller model, and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
generating a corresponding target language code based on Modelica code of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
According to the embedded code generation method based on Modelica language provided by the invention, before the standard comparison table corresponding to the predefined controller model is obtained, the method further comprises the following steps:
responding to a demand instruction of a user, determining a plurality of target components in a component list, and establishing a connection relationship conforming to control logic among the plurality of target components; wherein the parts list is used for loading a plurality of parts;
and generating the controller model and Modelica codes of the controller model based on the connection relation conforming to control logic between the plurality of target components.
According to the embedded code generation method based on Modelica language provided by the invention, the controller model is tested based on the standard comparison table, and the method comprises the following steps:
and under the condition that all the plurality of test information tests pass the test, determining that the controller model test passes.
According to the embedded code generation method based on Modelica language provided by the invention, the controller model is tested based on the standard comparison table, and the method comprises the following steps:
determining target test information, inputting target input information contained in the target test information into the controller model, and outputting target actual output information corresponding to the target input information;
comparing target actual output information corresponding to the target input information with target standard output information corresponding to the target input information to generate a comparison result, and judging whether the controller model passes a test or not based on the comparison result;
wherein the target test information is any one of the plurality of pieces of test information.
According to the embedded code generation method based on Modelica language provided by the invention, the method for judging whether the controller model passes the test based on the comparison result comprises the following steps:
and under the condition that the comparison result indicates that the target actual output information is consistent with the target standard output information, determining that the controller model passes the test.
According to the embedded code generation method based on Modelica language provided by the invention, the Modelica code generation corresponding to the target language code based on the controller model comprises the following steps:
analyzing Modelica codes corresponding to the controller model to obtain corresponding grammar trees; the grammar tree comprises variables, operation logic and input and output port information of the controller model;
and generating corresponding target language codes based on the grammar tree.
The invention also provides an embedded code generation device based on Modelica language, which comprises:
the test module is used for acquiring a standard comparison table corresponding to a predefined controller model and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
the generation module is used for generating corresponding target language codes based on Modelica codes of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
According to the embedded code generation device based on Modelica language, the device further comprises a model generation module, and the model generation module is specifically used for:
responding to a demand instruction of a user, determining a plurality of target components in a component list, and establishing a connection relationship conforming to control logic among the plurality of target components; wherein the parts list is used for loading a plurality of parts;
and generating the controller model and Modelica codes of the controller model based on the connection relation conforming to control logic between the plurality of target components.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the embedded code generation method based on Modelica language when executing the program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a Modelica language-based embedded code Generation method as described in any of the above.
The invention also provides a computer program product comprising a computer program which when executed by a processor implements a Modelica language-based embedded code generation method as described in any one of the above.
The invention provides a method and a device for generating an embedded code based on Modelica language, which are characterized in that a standard comparison table corresponding to a predefined controller model is obtained, and the controller model is tested based on the standard comparison table, wherein the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of the controller model and standard output information corresponding to the input information; and under the condition that the test of the controller model is passed, generating corresponding target language codes based on Modelica codes of the controller model, wherein the Modelica codes are codes for realizing control logic of the controller model. Therefore, after the Modelica code of the controller model is determined, the controller model is tested, and under the condition that the test passes, the corresponding target language code is generated based on the Modelica code of the controller model, so that the accuracy of generating the target language code is ensured.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a Modelica language-based embedded code generation method provided by the invention;
FIG. 2 is one of the interface presentation diagrams of the Modelica language-based embedded code generation method provided by the present invention;
FIG. 3 is a second interface representation of the Modelica language-based embedded code generation method provided by the present invention;
FIG. 4 is a schematic diagram of the structure of the Modelica language-based embedded code generating device provided by the invention;
fig. 5 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
An embedded code generation method based on a Modelica language of the present invention is described below with reference to FIGS. 1-5.
It should be noted that, the embedded controller is quite widely applied in the industrial field, and the embedded controller is one of the most important components in the control system, and the code writing of the control algorithm is also of great importance naturally.
The traditional control algorithm is manually written by engineering personnel, has low efficiency, is not suitable for large-scale system development, and is difficult to avoid human error; the existing Modelica platform also does not have the corresponding capability to generate embedded C code. Based on the above, the present invention provides a method for generating embedded code based on Modelica language, which is used for solving at least one of the above problems.
Fig. 1 is one of flow diagrams of a method for generating an embedded code based on a Modelica language according to the present embodiment, as shown in fig. 1, where the method for generating an embedded code based on a Modelica language according to the present embodiment includes:
step 100, obtaining a standard comparison table corresponding to a predefined controller model, and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information.
It should be noted that embedded code is a specific computer program designed to run on an embedded device, such as a microcontroller, microprocessor or other dedicated hardware device. These devices are commonly used to control and monitor physical devices such as automotive engine control units, household appliances, industrial control systems, and the like. Embedded code differs significantly from desktop application code in that it must be highly optimized to minimize memory space and computing resources. This typically means that low-level languages (such as C or c++) are used, as they allow the developer to directly control the hardware.
The controller model is a mathematical model that describes how the output of the system is controlled by an input signal. In control engineering, a controller model is used to describe how to adjust the state or behavior of a system to achieve a desired goal. The controller model is typically composed of a set of mathematical equations or algorithms that describe how the system responds to different input signals. These equations or algorithms may include differential equations, transfer functions, state space models, and the like. Modelica is an open-source, non-causal, equation-based programming language for describing and modeling complex systems. The method is widely applied to the fields of multi-field system dynamics, control systems, electromechanical integrated systems and the like.
The controller model provided in this embodiment may be created using a Modelica language, and after the controller model is created, a corresponding Modelica code is generated, where the Modelica code is a code for implementing the control logic of the controller model. The modeling efficiency of the controller algorithm modeling can be greatly improved by using Modelica language to create the controller model.
Further, in the embodiment, simulation test and algorithm verification are performed on the controller model, and under the condition that the test passes, a corresponding target language code is generated based on the Modelica code of the controller model, so that the accuracy of generating the target language code is ensured.
Specifically, a standard comparison table corresponding to a predefined controller model is obtained, and the controller model is tested based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of the controller model and standard output information corresponding to the input information. That is, for the same piece of input information, the output information of the controller model is compared with the output information corresponding to the control effect that is actually required to be achieved, so as to determine whether the controller model passes the test.
Step 200, generating a corresponding target language code based on Modelica codes of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
It should be noted that the embedded code may use a variety of programming languages, with the particular choice depending on the requirements and goals of the project. The target language code of the present implementation may be different types of embedded programming language code, such as C language, c++ language, assembly language, python language, java language, and the like. The generated controller codes can be directly used for the embedded platform, so that the design efficiency is greatly improved.
The above is a description of the steps of the embedded code generation method based on the Modelica language provided in the present embodiment. As can be seen from the description of the above steps, according to the embedded code generation method based on the Modelica language provided in the present embodiment, a standard comparison table corresponding to a predefined controller model is obtained, and a test is performed on the controller model based on the standard comparison table, where the standard comparison table includes a plurality of pieces of test information, and each piece of test information includes input information of the controller model and standard output information corresponding to the input information; and under the condition that the test of the controller model is passed, generating corresponding target language codes based on Modelica codes of the controller model, wherein the Modelica codes are codes for realizing control logic of the controller model. Therefore, after the Modelica code of the controller model is determined, the controller model is tested, and under the condition that the test passes, the corresponding target language code is generated based on the Modelica code of the controller model, so that the accuracy of generating the target language code is ensured.
Based on the above embodiment, in this embodiment, before the standard lookup table corresponding to the predefined controller model is obtained in step 100, the method further includes:
responding to a demand instruction of a user, determining a plurality of target components in a component list, and establishing a connection relationship conforming to control logic among the plurality of target components; wherein the parts list is used for loading a plurality of parts;
and generating the controller model and Modelica codes of the controller model based on the connection relation conforming to control logic between the plurality of target components.
It should be noted that, before performing the above step 100, the creation of the controller model needs to be performed in advance. The present embodiment provides a parts list comprising a plurality of different types of simulation parts for implementing different functions.
Specifically, the demand instruction of the user may be, for example, an instruction to create a controller model or an instruction to create another model, which is not particularly limited in this embodiment. Responding to a demand instruction of a user for creating a controller model, determining a plurality of corresponding target components in a component list, establishing a connection relation conforming to control logic among the plurality of target components, and generating the controller model and Modelica codes of the controller model so as to realize simulation of the controller.
According to the embedded code generation method based on the Modelica language, the controller model is created by using the Modelica language, so that the modeling efficiency of the controller algorithm modeling can be greatly improved.
Based on the above embodiment, in this embodiment, step 100 tests the controller model based on the standard lookup table, including:
and under the condition that all the plurality of test information tests pass the test, determining that the controller model test passes.
According to the Modelica language-based embedded code generation method provided by the embodiment, after Modelica codes of the controller model are determined, the controller model is tested, and under the condition that the test passes, corresponding target language codes are generated based on the Modelica codes of the controller model, so that the accuracy of target language code generation is ensured.
Based on the above embodiment, in this embodiment, step 100 tests the controller model based on the standard lookup table, including:
determining target test information, inputting target input information contained in the target test information into the controller model, and outputting target actual output information corresponding to the target input information;
comparing target actual output information corresponding to the target input information with target standard output information corresponding to the target input information to generate a comparison result, and judging whether the controller model passes a test or not based on the comparison result;
wherein the target test information is any one of the plurality of pieces of test information.
The process of testing the controller model is described below in connection with specific examples.
Fig. 2 is one of the interface display diagrams of the embedded code generation method based on the Modelica language provided in this embodiment, and as shown in fig. 2, the interface includes a built controller model and a data dictionary of a control algorithm corresponding to the controller model. The data dictionary is introduced into the two input constant modules and the two output ports, and data in the control algorithm model are uniformly managed; two variables, value_a and value_b, are defined in the data dictionary, the values of which are 4.75 and 5.5 respectively, the data type is float type, and the storage mode is defined as global variable.
Fig. 3 is a second interface display diagram of the embedded code generation method based on the Modelica language according to the present embodiment, and as shown in fig. 3, output port data dictionary information is automatically generated, and is respectively out and out1, the data type is float type, and the storage mode is global variable.
Further, comparing the actual output information with standard output information corresponding to the input information in a standard comparison table to generate a comparison result, and judging whether the controller model passes the test or not based on the comparison result.
Based on the above embodiment, in this embodiment, the determining, based on the comparison result, whether the controller model passes the test includes:
and under the condition that the comparison result indicates that the target actual output information is consistent with the target standard output information, determining that the controller model passes the test.
According to the Modelica language-based embedded code generation method provided by the embodiment, after Modelica codes of the controller model are determined, the controller model is tested, and under the condition that the test passes, corresponding target language codes are generated based on the Modelica codes of the controller model, so that the accuracy of target language code generation is ensured.
Based on the above embodiment, in this embodiment, step 200 generates a corresponding target language code based on the Modelica code of the controller model, including:
analyzing Modelica codes corresponding to the controller model to obtain corresponding grammar trees; the grammar tree comprises variables, operation logic and input and output port information of the controller model;
and generating corresponding target language codes based on the grammar tree.
Specifically, the bottom layer of the pre-built controller model is provided with corresponding Modelica codes, corresponding Modelica codes are analyzed to obtain corresponding grammar trees of a key algorithm, the grammar trees comprise all variables, operation logic and input and output port information of the controller model, the corresponding grammar trees can be designated to generate specific target language codes, such as C language codes, and the types of variable data have a one-to-one mapping relation. The finally generated target language codes are respectively stored in three code files, including a main program, an initialization function and an execution function, a header file for declaring and defining a function interface and a header file for storing special variables. For the final generated target language code, the developer can use directly or by calling the form of its interface function. The variables defined in the data dictionary are declared as global variables in the generated codes, and developers can process the variables at any position in engineering, so that the efficiency of managing specific variables in the system is greatly improved.
According to the Modelica language-based embedded code generation method provided by the embodiment, after Modelica codes of the controller model are determined, the controller model is tested, and under the condition that the test passes, corresponding target language codes are generated based on the Modelica codes of the controller model, so that the accuracy of target language code generation is ensured; the generated target language code can be directly used for the embedded platform, so that the design efficiency is greatly improved.
The embedded code generating device based on the Modelica language provided by the invention is described below, and the embedded code generating device based on the Modelica language described below and the embedded code generating method based on the Modelica language described above can be correspondingly referred to each other.
Fig. 4 is a schematic structural diagram of an embedded code generating device based on a Modelica language according to the present embodiment, and as shown in fig. 4, the embedded code generating device based on a Modelica language according to the present embodiment includes:
the test module 401 is configured to obtain a standard comparison table corresponding to a predefined controller model, and test the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
a generating module 402, configured to generate a corresponding target language code based on a Modelica code of the controller model when the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
According to the embedded code generating device based on the Modelica language, a standard comparison table corresponding to a predefined controller model is obtained, and the controller model is tested based on the standard comparison table, wherein the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of the controller model and standard output information corresponding to the input information; and under the condition that the test of the controller model is passed, generating corresponding target language codes based on Modelica codes of the controller model, wherein the Modelica codes are codes for realizing control logic of the controller model. Therefore, after the Modelica code of the controller model is determined, the controller model is tested, and under the condition that the test passes, the corresponding target language code is generated based on the Modelica code of the controller model, so that the accuracy of generating the target language code is ensured.
Based on the foregoing embodiment, in this embodiment, the apparatus further includes a model generating module, specifically configured to:
responding to a demand instruction of a user, determining a plurality of target components in a component list, and establishing a connection relationship conforming to control logic among the plurality of target components; wherein the parts list is used for loading a plurality of parts;
and generating the controller model and Modelica codes of the controller model based on the connection relation conforming to control logic between the plurality of target components.
Based on the above embodiment, in this embodiment, the test module 401 is specifically configured to:
and under the condition that all the plurality of test information tests pass the test, determining that the controller model test passes.
Based on the above embodiment, in this embodiment, the test module 401 is specifically configured to:
determining target test information, inputting target input information contained in the target test information into the controller model, and outputting target actual output information corresponding to the target input information;
comparing target actual output information corresponding to the target input information with target standard output information corresponding to the target input information to generate a comparison result, and judging whether the controller model passes a test or not based on the comparison result;
wherein the target test information is any one of the plurality of pieces of test information.
Based on the foregoing embodiment, in this embodiment, the apparatus further includes a determining module, specifically configured to:
and under the condition that the comparison result indicates that the target actual output information is consistent with the target standard output information, determining that the controller model passes the test.
Based on the foregoing embodiment, in this embodiment, the generating module 402 is specifically configured to:
analyzing Modelica codes corresponding to the controller model to obtain corresponding grammar trees; the grammar tree comprises variables, operation logic and input and output port information of the controller model;
and generating corresponding target language codes based on the grammar tree.
Fig. 5 illustrates a physical schematic diagram of an electronic device, as shown in fig. 5, which may include: processor 510, communication interface (Communications Interface) 520, memory 530, and communication bus 540, wherein processor 510, communication interface 520, memory 530 complete communication with each other through communication bus 540. Processor 510 may invoke logic instructions in memory 530 to perform a Modelica language based embedded code generation method comprising:
obtaining a standard comparison table corresponding to a predefined controller model, and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
generating a corresponding target language code based on Modelica code of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
Further, the logic instructions in the memory 530 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of executing the method for generating embedded code based on a Modelica language provided by the above methods, the method comprising:
obtaining a standard comparison table corresponding to a predefined controller model, and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
generating a corresponding target language code based on Modelica code of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the method for generating embedded code based on Modelica language provided by the above methods, the method comprising:
obtaining a standard comparison table corresponding to a predefined controller model, and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
generating a corresponding target language code based on Modelica code of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (10)
1. The embedded code generation method based on Modelica language is characterized by comprising the following steps:
obtaining a standard comparison table corresponding to a predefined controller model, and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
generating a corresponding target language code based on Modelica code of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
2. The method for generating embedded code based on Modelica language according to claim 1, wherein before obtaining the standard lookup table corresponding to the predefined controller model, the method further comprises:
responding to a demand instruction of a user, determining a plurality of target components in a component list, and establishing a connection relationship conforming to control logic among the plurality of target components; wherein the parts list is used for loading a plurality of parts;
and generating the controller model and Modelica codes of the controller model based on the connection relation conforming to control logic between the plurality of target components.
3. The Modelica language-based embedded code generation method according to claim 1, wherein the testing the controller model based on the standard lookup table comprises:
and under the condition that all the plurality of test information tests pass the test, determining that the controller model test passes.
4. A method of generating embedded code in a Modelica language according to claim 1 or 3, wherein said testing the controller model based on the standard lookup table comprises:
determining target test information, inputting target input information contained in the target test information into the controller model, and outputting target actual output information corresponding to the target input information;
comparing target actual output information corresponding to the target input information with target standard output information corresponding to the target input information to generate a comparison result, and judging whether the controller model passes a test or not based on the comparison result;
wherein the target test information is any one of the plurality of pieces of test information.
5. The Modelica language-based embedded code generation method according to claim 4, wherein the determining whether the controller model passes the test based on the comparison result comprises:
and under the condition that the comparison result indicates that the target actual output information is consistent with the target standard output information, determining that the controller model passes the test.
6. The Modelica language-based embedded code generation method according to claim 1, wherein the Modelica code generation method based on the controller model includes:
analyzing Modelica codes corresponding to the controller model to obtain corresponding grammar trees; the grammar tree comprises variables, operation logic and input and output port information of the controller model;
and generating corresponding target language codes based on the grammar tree.
7. An embedded code generation device based on Modelica language, comprising:
the test module is used for acquiring a standard comparison table corresponding to a predefined controller model and testing the controller model based on the standard comparison table; the standard comparison table comprises a plurality of pieces of test information, and each piece of test information comprises input information of a controller model and standard output information corresponding to the input information;
the generation module is used for generating corresponding target language codes based on Modelica codes of the controller model under the condition that the controller model test passes; wherein the Modelica code is a code implementing the control logic of the controller model.
8. The embedded code generating device based on Modelica language according to claim 7, wherein the device further comprises a model generating module, in particular for:
responding to a demand instruction of a user, determining a plurality of target components in a component list, and establishing a connection relationship conforming to control logic among the plurality of target components; wherein the parts list is used for loading a plurality of parts;
and generating the controller model and Modelica codes of the controller model based on the connection relation conforming to control logic between the plurality of target components.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the Modelica language-based embedded code generation method according to any one of claims 1 to 6 when the program is executed by the processor.
10. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the Modelica language-based embedded code Generation method according to any of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410081755.2A CN117891462A (en) | 2024-01-19 | 2024-01-19 | Modelica language-based embedded code generation method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410081755.2A CN117891462A (en) | 2024-01-19 | 2024-01-19 | Modelica language-based embedded code generation method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117891462A true CN117891462A (en) | 2024-04-16 |
Family
ID=90642529
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410081755.2A Pending CN117891462A (en) | 2024-01-19 | 2024-01-19 | Modelica language-based embedded code generation method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117891462A (en) |
-
2024
- 2024-01-19 CN CN202410081755.2A patent/CN117891462A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9465718B2 (en) | Filter generation for load testing managed environments | |
US7979848B2 (en) | Systems, methods and apparatus for pattern matching in procedure development and verification | |
GB2542687A (en) | System and method for model based technology and process for safety-critical software development | |
US20050223295A1 (en) | Method for the creation of sequences for testing software | |
CN110633200A (en) | Method and device for testing intelligent contracts | |
JPH11513512A (en) | Method of manufacturing digital signal processor | |
Kautz et al. | Achievements, Failures, and the Future of Model-Based Software Engineering. | |
Delgado et al. | Fuzz testing in behavior-based robotics | |
EP4148584A1 (en) | Method and system for generating and optimizing test cases for an engineering program | |
EP4073626B1 (en) | Method and system for generating engineering diagrams in an engineering system | |
CN117891462A (en) | Modelica language-based embedded code generation method and device | |
US20230315038A1 (en) | Method and system for providing engineering of an industrial device in a cloud computing environment | |
US10488835B2 (en) | Method for configuring a tester equipped for testing an electronic control unit | |
CN112699042B (en) | Unit test case generation method and device | |
US11442845B2 (en) | Systems and methods for automatic test generation | |
Iryna et al. | Research results of functional, white box and smoke testing methods for mobile applications | |
CN113553251A (en) | Mock testing method applied to software testing | |
US20190065644A1 (en) | Method of configuring a test device designed to test an electronic control unit, and a configuration system | |
US20240241889A1 (en) | Framework for building cluster management controllers | |
US20230315613A1 (en) | Method and system for eradicating programmatical errors from engineering programs in a technical installation | |
US7580962B1 (en) | Automatic code generation for co-simulation interfaces | |
US20230161566A1 (en) | Method and system for generating engineering designs in an engineering system | |
CN118112951A (en) | Modelica language-based state machine model simulation method and device, electronic equipment and storage medium | |
Murray-Smith et al. | Methods of model verification | |
CN117331761A (en) | Method, device, equipment and storage medium for generating processor instruction verification platform |
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 |