Modelica language-oriented model version automatic conversion method and system

Through the automatic conversion method of model versions for the Modelica language, using version conversion scripts and difference mapping tables, the problem that user models are difficult to adapt to new versions in the Modelica model library version upgrade is solved, and automated conversion is realized, improving compatibility and maintenance efficiency.

CN119987844AActive Publication Date: 2025-05-13武汉鼎元同立科技有限公司
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510120631.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-26
Publication Date
2025-05-13
Estimated Expiration
2045-01-26

AI Technical Summary

Technical Problem

During the upgrade of the Modelica language model library version, it is difficult for the user model to directly adapt to the new version of the model library, resulting in compatibility and consistency problems.

Method used

Provides a model version automatic conversion method for Modelica language. By responding to the dependency conversion request of the user model, it loads and parses the version conversion script, generates a version difference mapping table, and converts the dependencies of the user model based on the table to make it compatible with the target version model library.

Benefits of technology

The automated dependency conversion of the user model is realized, ensuring that the user model can adapt to the new version of the model library, maintain compatibility and consistency, reduce the complexity of manual operations, and improve maintenance efficiency and compatibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987844A_ABST
    Figure CN119987844A_ABST
Patent Text Reader

Abstract

The invention relates to a Modelica language-oriented model version automatic conversion method and system, and the method comprises the steps: responding to a received conversion request for a dependency relationship of a user model, and the conversion request comprises version information of a model library on which the user model depends before and after conversion; according to version information of a model library on which the user model depends before and after conversion, at least one version conversion script is loaded, and the at least one version conversion script is used for recording version conversion information when a current version model library on which the user model depends is upgraded to a target version model library; analyzing the at least one version conversion script to obtain at least one corresponding version difference mapping table; and according to the at least one version difference mapping table, converting the dependency relationship of the user model, so that the converted user model is compatible with the target version model library. According to the method, the dependency relationship of the user model can be automatically converted, a new-version model library is adapted, and the complexity of manual operation is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of system modeling and simulation, and in particular to a method and system for automatic conversion of model versions oriented to the Modelica language. Background Art

[0002] Modelica is a declarative, multi-domain unified modeling language that is widely used in the modeling and simulation of complex physical systems. In other words, the model library built based on Modelica semantics can be used by modelers to build user models (that is, system models), and a dependency relationship will be formed between the user model and the model library.

[0003] However, during the maintenance and upgrade process of the model library built based on Modelica semantics, some change information is usually introduced, and these change information may be incompatible with the old version of the model library, thus affecting the normal use of the user model. This situation is particularly prominent in the version upgrade of large-scale model libraries. For example, when the Modelica standard library was upgraded from version 3.2.3 to version 4.0, due to a large number of adjustments to modules and interfaces, many user models that rely on the old version of the model library cannot be directly adapted to the new version of the model library. Similar problems are also very common in the upgrade of other engineering model libraries. Summary of the invention

[0004] Based on the above description, the present application provides a model version automatic conversion method and system for the Modelica language to solve the problem that during the current model library version upgrade process, the user model is difficult to directly adapt to the new version of the model library.

[0005] According to a first aspect of the present application, a method for automatic model version conversion in Modelica language is provided, comprising: In response to receiving a conversion request for a dependency relationship of a user model, the conversion request includes version information of a model library on which the user model depends before and after conversion; According to the version information of the model library on which the user model depends before and after the conversion, at least one version conversion script is loaded, wherein the at least one version conversion script is used to record the version conversion information when the current version model library on which the user model depends is upgraded to the target version model library; Parsing the at least one version conversion script to obtain at least one corresponding version difference mapping table; The dependency relationship of the user model is converted according to the at least one version difference mapping table, so that the converted user model is compatible with the target version model library.

[0006] In one or more embodiments, before the response to receiving the request for converting the dependency relationship of the user model, the method further includes: According to the preset conversion rules, multiple version conversion scripts are established, each of which is used to record the change information of the library elements when each version model library is upgraded to the next version model library; The preset conversion rules include type conversion rules, condition conversion rules, element conversion rules and variant conversion rules.

[0007] In one or more embodiments, loading at least one version conversion script according to the version information of the model library on which the user model to be converted depends before and after the conversion includes: If the model library version on which the user model before conversion depends and the model library version on which the user model after conversion depends differ by one version, a corresponding version conversion script is loaded; or If the model library version on which the user model before conversion depends and the model library version on which the user model after conversion depends differ by several versions, the corresponding several versions of conversion scripts are loaded.

[0008] In one or more embodiments, parsing the at least one version conversion script to obtain the corresponding at least one version difference mapping table includes: The conversion rules of each version conversion script are parsed, all version conversion information recorded in the version conversion script is extracted and sorted, and a corresponding version difference mapping table is generated.

[0009] In one or more embodiments, according to the at least one version difference mapping table, converting the dependency relationship of the user model on the current version model library so that the converted user model is compatible with the target version model library includes: According to the at least one version difference mapping table, searching and analyzing the dependency relationship of the user model on the current version model library to determine the dependency to be changed in the user model; The dependency relationship of the user model is converted according to the at least one version difference mapping table and the dependency to be changed in the user model.

[0010] In one or more embodiments, searching and analyzing the dependency relationship of the user model on the current version model library according to the at least one version difference mapping table to determine the dependency to be changed in the user model includes: Traversing all dependencies in the user model, and locating dependencies to be changed in statements and syntax elements of the user model according to change information of each library element in the at least one version difference mapping table; The statements include import statements, inheritance statements, equation and algorithm statements, and component declarations; and the grammatical elements include expressions, annotations, and variants.

[0011] In one or more embodiments, before searching and analyzing the dependency relationship between the user model and the current version model library according to the at least one version difference mapping table, the method further includes: Analyze the inheritance relationship of the user model to determine the base class and derived class with inheritance relationship; Locate all derived classes in the user model that are affected by the change according to the change information of the base class in the at least one version difference mapping table; According to the mechanism of dynamically extending the base class conversion rule, the change information of all derived classes affected by the change is extended in the at least one version difference mapping table.

[0012] In one or more embodiments, before the response to receiving the request for converting the dependency relationship of the user model, the method further includes: Load the current version of the model library that the user model depends on to access all components and dependencies in the current version of the model library; The version information of the model library on which the user model depends is identified. If the current version of the model library on which the user model depends is not the target version of the model library, conversion prompt information is generated and displayed on the user interface.

[0013] In one or more embodiments, the method further includes: generating a conversion log, wherein the conversion log is used to record operation information performed on the user model during the dependency conversion process of the user model.

[0014] According to a second aspect of the present application, a model version automatic conversion system for Modelica language is provided, comprising: A request response module, used to respond to a received request for conversion of a dependency relationship of a user model, wherein the conversion request includes version information of a model library on which the user model depends before and after conversion; A loading script module, used to load at least one version conversion script according to the version information of the model library on which the user model depends before and after the conversion, wherein the at least one version conversion script is used to record the version conversion information when the current version model library on which the user model depends is upgraded to the target version model library; A script parsing module, used to parse the at least one version conversion script to obtain at least one corresponding version difference mapping table; The version conversion module is used to convert the dependency relationship of the user model according to the at least one version difference mapping table, so that the converted user model is compatible with the target version model library.

[0015] According to a third aspect of the present application, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in any one of the aforementioned embodiments when executing the computer program.

[0016] According to a fourth aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described in any of the aforementioned embodiments are implemented.

[0017] Compared with the prior art, the technical solution of this application has the following beneficial technical effects: In the above-mentioned automatic model version conversion method and system for the Modelica language, by responding to the conversion request of the dependency relationship of the user model, at least one version conversion script is loaded and parsed according to the version information of the model library that the user model depends on before and after the conversion, and at least one corresponding version difference mapping table is obtained; then, according to the at least one version difference mapping table, the dependency relationship of the user model is converted so that the converted user model is compatible with the target version model library. In this way, by automatically loading and parsing the version conversion script, and automatically analyzing and modifying the user model according to the parsing results, the dependency relationship of the user model is automatically converted, ensuring that the user model can adapt to the new version model library and maintain compatibility and consistency, reducing the complexity of manual operations, and improving the maintenance efficiency and compatibility of the user model. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A schematic diagram of a flow chart of a method for automatic model version conversion in Modelica language provided in one embodiment of the present application; Figure 2 This is a schematic diagram of the structure of a version conversion script in a specific embodiment of the present application; Figure 3 This is a flow chart of step S104 in one embodiment of the present application; Figure 4 A schematic diagram of searching and analyzing a user model in a specific embodiment of the present application; Figure 5 This is a flow chart of step S104 in another embodiment of the present application; Figure 6 A schematic diagram of the principle of a method for automatic conversion of model versions in Modelica language provided by another embodiment of the present application; Figure 7 A schematic diagram of the principle of a device for automatically converting a model version in the Modelica language provided in an embodiment of the present application; Figure 8 A schematic diagram of the principles of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.

[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0021] It is understood that when used herein, the singular forms "a", "an" and "said / the" may also include plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "include / comprise" or "have" etc. specify the presence of stated features, wholes, steps, operations, components, parts or combinations thereof, but do not exclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts or combinations thereof.

[0022] See also Figure 1 , Figure 1 A flow chart of a method for automatic model version conversion in Modelica language provided by an embodiment of the present application is shown. A method for automatic model version conversion in Modelica language provided by an embodiment of the present application comprises the following steps: S101, responding to a conversion request for a dependency relationship of a user model, the conversion request including version information of a model library on which the user model depends before and after the conversion; S102: Load at least one version conversion script according to the version information of the model library that the user model depends on before and after the conversion, wherein the at least one version conversion script is used to record the version conversion information when the current version model library that the user model depends on is upgraded to the target version model library; S103, parsing at least one version conversion script to obtain at least one corresponding version difference mapping table; S104: According to at least one version difference mapping table, the dependency relationship of the user model is converted to make the converted user model compatible with the target version model library.

[0023] It should be noted that, in the present embodiment, the model library may refer to the Modelica standard library, or to a model library built based on the Modelica language and having a specific application scenario. The model library contains a large number of predefined models for engineering modeling in different fields. A user can build a system model based on a variety of model libraries, i.e., a user model, so that the user model forms a dependency relationship with multiple model libraries. When loading the user model, the platform will load the corresponding model libraries, which is convenient for the user model to perform dynamic simulation analysis. When any model library version on which the user model depends is updated, if the user wants the user model to use the corresponding new version of the model library, it is necessary to convert the dependency relationship of the user model on the current version of the model library to make it compatible with the target version model library. The target version model library refers to the new version model library, which can be the latest version model library, or the next latest version model library, or it can be specifically selected according to user needs. The corresponding version of the model library can be selected. In addition, the model library manages different library elements, such as proportions, constants, variables, types, expressions, components, etc., by means of model packages, and these library elements can be combined to obtain predefined models, and organized and managed by model packages, which is convenient for the user model to be referenced and reused when in use.

[0024] Considering the version upgrade of the model library, directly embedding the change logic into the program will lead to hard-coding problems, limiting the flexibility and scalability of the system. The change content varies significantly between different categories of model libraries or different versions of the same model library, and may involve adjustments to model attributes, component members, and other aspects. In this embodiment, by adopting a version conversion script-driven approach, the change logic is decoupled from the program, effectively avoiding the limitations of program hard coding and achieving flexible adaptation to multi-category and multi-version model libraries.

[0025] The version conversion script refers to a code script that records the version conversion information when each version of the model library is upgraded to the next version of the model library. The version conversion information refers to the change information of the library elements. In this embodiment, the model library provider can customize or edit the script content according to the needs to support the model conversion requirements of a specific field or a specific version, so as to adapt to various application scenarios. In this embodiment, the version difference mapping table is obtained by extracting the change information of the library elements from the version conversion script.

[0026] In this embodiment, by responding to a request for converting the dependency of a user model, at least one version conversion script is loaded and parsed according to the version information of the model library that the user model depends on before and after the conversion, and at least one corresponding version difference mapping table is obtained; then, according to the at least one version difference mapping table, the dependency of the user model is converted so that the converted user model is compatible with the target version model library. In this way, the dependency of the user model can be automatically converted to ensure that the user model can adapt to the new version model library and maintain compatibility and consistency, while effectively improving the accuracy and efficiency of version conversion and reducing the labor cost and maintenance difficulty of upgrading a complex model library.

[0027] In some embodiments, before responding to receiving a request to convert the dependency of the user model, the method further includes: According to the preset conversion rules, multiple version conversion scripts are established, and each version conversion script is used to record the change information of library elements when each version model library is upgraded to the next version model library; among them, the preset conversion rules include type conversion rules, conditional conversion rules, element conversion rules and variant conversion rules.

[0028] It should be noted that in this embodiment, the change logic is decoupled from the program by adopting a script-driven approach, which effectively avoids the limitations of hard-coded programs and realizes flexible adaptation of multi-category and multi-version model libraries. By abstracting four general rules of type conversion, conditional conversion, element conversion, and variant conversion, the system only needs to define unified conversion rules to flexibly write version conversion scripts to adapt to the upgrade requirements of model libraries of different categories and versions.

[0029] In this embodiment, the main function of the version conversion script is to record the change information of the library elements in the model library version upgrade and define the core rule set for version conversion. By adopting a standardized format, the version conversion script ensures the accuracy and consistency of the subsequent user model version conversion process, covering type conversion rules, conditional conversion rules, element conversion rules and variant conversion rules to adapt to the difference requirements between different versions. In this embodiment, the user model can be automatically modified according to each conversion rule, that is, each conversion rule can be regarded as a conversion command. When constructing a version conversion script, the conversion script can be customized or edited according to actual needs, so as to flexibly respond to the conversion requirements of specific fields or model library versions, and ensure the flexibility and applicability of the conversion. The version conversion information can be recorded in formats such as XML and JSON to facilitate subsequent parsing, but the storage format is not restricted and can be freely selected according to the conversion system and scenario requirements. In addition, in this embodiment, the version conversion script adopts the naming rule of "model name + old version number + To + new version number", for example, Modelica3.2.3.0To4.0.0.0, to clearly identify the conversion between different versions. This naming method is intuitive and clear, and is convenient for the management and retrieval of version conversion scripts.

[0030] See also Figure 2 , Figure 2 The schematic diagram of the structure of a version conversion script in a specific embodiment of the present application is shown, which includes four sets of version conversion information, each set of version conversion information includes a conversion rule. In practical applications, a set of version conversion information may include multiple conversion rules.

[0031] Specifically, type conversion rules: during the model library version upgrade process, the changes in the type names of predefined models during the model library version upgrade process can be recorded according to the type conversion rules. During the user model version conversion process, the packages, constants, functions, and enumerations in the user model can be replaced according to the type conversion rules, and the type names of the predefined models in the old version model library (that is, the current version model library) can be replaced with the type names of the predefined models in the new version model library (that is, the target version model library), ensuring that the user model can correctly reference the corresponding types in the new version model library.

[0032] For example, Figure 2 As shown, ConvertClass is used to represent the type conversion rule, that is, the conversion command is type conversion. className is used to record the type name of the predefined model in the old version model library, and newClassName is used to record the type change name of the predefined model in the new version model library.

[0033] Conditional conversion rules: During the model library version upgrade process, the conversion under specific conditions can be recorded based on the conditional conversion rules. This is applicable to the situation where a class in the old version of the model library has multiple corresponding items in the new version of the model library. During the user model version conversion process, based on the conditional conversion rules, the target to be converted can be determined according to the specific conditions in the user model (such as parameter values, etc.). For example, it can be determined whether the parameter is a corresponding value. If so, the dependency relationship of the user model is converted to match the corresponding type in the new version of the model library. It can be used for one-to-many conversion of types when the model library is upgraded.

[0034] For example, Figure 2 As shown, ConvertClassIf is used to represent the conditional conversion rule, that is, the conversion command is a conditional conversion. Use className to record the type name of the predefined model in the old version model library, newClassName to record the type change name of the predefined model in the new version model library, paraName to represent the parameter name, and paraValue to represent the parameter value. When the value of paraName in the sub-model to be converted in the user model is equal to paraValue, the type name of the sub-model in the user model is converted to achieve conditional conversion.

[0035] Element conversion rules: During the model library version upgrade process, the changes in component names during the model library version upgrade process can be recorded according to the element conversion rules. During the user model version conversion process, the component names in the old version of the model library can be detected and replaced according to the element conversion rules, so that all component names in the user model meet the naming standards of the new version of the model library, avoiding model errors caused by name mismatches.

[0036] For example, Figure 2 As shown, ConvertElement is used to indicate the use of element conversion rules, that is, the conversion command is element conversion, className is used to indicate the type name of the conversion, oldElementName indicates the name of the library element in the old version of the model library, and newElementName indicates the name of the library element in the new version of the model library.

[0037] Variant conversion rules: During the model library version upgrade process, the adjustment of certain variants during the model library version upgrade process can be recorded according to the variant conversion rules. According to the variant conversion rules, certain variants in the old version of the model library can be detected and replaced to make the corresponding variants in the user model compatible with the new version of the model library, such as unit changes, supplementation of missing variants, etc.

[0038] For example, Figure 2As shown, ConvertModifiers is used to indicate the use of variant conversion rules, that is, the conversion command is variant conversion, className is used to indicate the type name to be converted, oldModifItem indicates the component name in the old version model library, oldModifValue indicates the variant value in the old version model library, newModifItem indicates the component name in the new version model library, newModifValue indicates the variant value in the new version model library, and modifType indicates the variant conversion category, which can be AddModif to add a variant, AlterModif to modify a variant, and so on.

[0039] When the variant conversion category is AddModif, the variant conversion needs to add or delete the variant item in the user model. That is, when newModifValue is empty, the variant is deleted, and when it is not empty, the variant is added.

[0040] When oldModifItem is not empty, the variant item in the user model can be replaced with the specified variant. For example, if oldModifItem="A", newModifItem="B", newModifValue="A*100", and " Compc(A=C);" appears in the user model, the variant is converted to "Comp c(B=C*100);". This conversion operation is applicable to situations such as unit changes.

[0041] When the oldModifValue item in the above example is not empty and there is no variant of A in the user model, for example, oldModifValue=10, the "Comp c;" component statement in the user model is replaced by "Comp c(B=10*100);" When the variant conversion category is AlterModif, the variant conversion command takes effect only when the newModifItem variant exists in the user model. In this case, the newModifItem item in the version conversion script is required to be non-empty.

[0042] Understandably, Figure 2 The recording method of the version conversion script is only an example. As long as the version change information in the model library upgrade can be clearly and accurately represented, this embodiment does not limit the specific recording form.

[0043] In some embodiments, at least one version conversion script is loaded according to the version information of the model library on which the user models before and after the conversion depend, including: If the model library version that the user model before conversion depends on differs from the model library version that the user model after conversion depends on by one version, then a corresponding version conversion script is loaded. Alternatively, if the model library version that the user model before conversion depends on differs from the model library version that the user model after conversion depends on by several versions, then several corresponding version conversion scripts are loaded.

[0044] Specifically, each version of the model library upgrade can have its own version conversion script, so as to flexibly meet the needs of different model version conversions. In addition, this embodiment supports multiple iterative conversions of the model library. For example, the user can first upgrade the user model that depends on the 3.0.0 version model library to the user model that depends on the 3.2.0 version model library, and then further upgrade it to the user model of the 4.0.0 version model library. The entire upgrade process can be completed by loading the corresponding version conversion scripts separately, without the need for additional adjustments to the conversion logic, thereby improving the efficiency and applicability of version conversion.

[0045] In some embodiments, parsing at least one version conversion script to obtain at least one corresponding version difference mapping table includes: The conversion rules of each version conversion script are parsed, all version conversion information recorded in the version conversion script is extracted and sorted, and a corresponding version difference mapping table is generated.

[0046] Specifically, the conversion rules in the version conversion script are read and parsed, and all version conversion information recorded in the version conversion script is extracted and organized. Each version conversion script is parsed to generate a version difference mapping table. These version difference mapping tables help the conversion system identify the dependencies between the user model and the old version model library, and lay the foundation for subsequent automatic conversion operations, and provide detailed data support for the subsequent version conversion process, that is, provide a basis for searching. For example, in the process of parsing the version conversion script, when processing a set of model type name changes, a clear mapping table is generated by marking the correspondence between the old type name and the new type name for subsequent use in searching and analyzing the dependencies of the user model.

[0047] See also Figure 3 , Figure 3 A flow chart of step S104 in an embodiment of the present application is shown.

[0048] In some embodiments, according to at least one version difference mapping table, the dependency relationship of the user model on the current version model library is converted so that the converted user model is compatible with the target version model library, including: S301. According to at least one version difference mapping table, search and analyze the dependency relationship between the user model and the current version model library to determine the dependency items to be changed in the user model; S302: Transform the dependency relationship of the user model according to at least one version difference mapping table and the dependency to be changed in the user model.

[0049] Specifically, according to the change information of the library elements provided in the version difference mapping table, the dependency of the user model on the old version model library (that is, the current version model library) is searched and analyzed, so that the part to be changed, that is, the dependency to be changed, can be found in the user model quickly and accurately. Then, according to the change information of the library elements provided in the version difference mapping table and the dependency to be changed in the user model, the user model is attribute adjusted, dependency replaced and structure modified to ensure that the user model conforms to the semantics of the new version model library (that is, the target version model library) so that the user model forms a dependency relationship with the new version model library. It should be noted that during the conversion process, the system will back up the original data of the user model for comparison and rollback operations to ensure the security of the version conversion process.

[0050] See also Figure 4 , Figure 4 A schematic diagram of searching and analyzing user models in a specific embodiment of the present application is shown.

[0051] In some embodiments, in step S301, searching and analyzing the dependency relationship between the user model and the current version model library according to at least one version difference mapping table to determine the dependency to be changed in the user model includes: Traverse all dependencies in the user model, and locate the dependencies to be changed in the statements and syntax elements of the user model based on the version conversion information in at least one version difference mapping table; wherein the statements include import statements, inheritance statements, equation and algorithm statements, and component declarations; the syntax elements include expressions, annotations, and variants.

[0052] It should be noted that the dependency relationship between the user model and the model library is relatively complex, which is reflected in the form of base classes, components, import statements, expressions, etc. In this embodiment, all dependencies in the user model are traversed, and based on the change information of the library elements in one or more version difference mapping tables, the dependencies to be changed are located in the statements and syntax elements of the user model. Among them, statements include import statements, inheritance statements, component declarations or equation and algorithm statements; syntax elements include expressions, annotations or variants.

[0053] In this embodiment, for import statements: parse the import statements in the user model, identify all imported packages and components, and process multiple import statements to find out whether there is type conversion information that needs to be converted. For example, in the import statement "import Modelica.SIunits.*;", Modelica.SIunits is the type name reference information.

[0054] For inheritance statements: Find the change information in the user model inheritance statement, including analyzing the base class name and finding the change information of the variant in the inheritance statement. For example, in the inheritance statement "extends ABC(x=1);", "ABC" is the base class name and "(x=1)" is the variant information.

[0055] For component declarations: Find the change information in the component definition, including the component type name, component variant, and information in its annotations. For example, in the component declaration "P1.Comp c(y=2);", "P1.Comp" is the component type name, and "(y=2)" is the component variant information.

[0056] For equations and algorithms: Check the equations and algorithm statements in the user model and analyze the expression change information involved.

[0057] For expressions: analyze the change information in the expressions, including function call names, component reference names, enumerations, function parameters, etc. For example, in the expression "OldLibrary.FunctionName(x)", "OldLibrary.FunctionName" is the function name, and "x" is the component reference name.

[0058] For annotations: Search for names in annotations and changes in expressions, including inverse function, derivative function names, etc. For example, the annotation "annotation(derivative=foo1);" is the derivative function information.

[0059] For variants: Analyze the change information in the variant, identify and convert type redeclaration, component redeclaration, and expression.

[0060] In this way, by traversing all dependencies in the user model, based on the change information of the library elements in at least one version difference mapping table, the elements in the user model that need to be modified or replaced are identified. In this way, the dependencies to be converted can be found in the user model quickly and accurately to ensure the compatibility of the user model with the new version model library.

[0061] See also Figure 5 , Figure 5 A flow chart of step S104 in another embodiment of the present application is shown.

[0062] In some embodiments, before step S301, that is, searching and analyzing the dependency relationship between the user model and the current version model library according to at least one version difference mapping table, the method further includes: S501, analyzing the inheritance relationship in the user model, and determining the base class and derived class having the inheritance relationship in the user model; S502: Locate all derived classes in the user model that are affected by the change according to the change information of the base class in at least one version difference mapping table; S503: According to the mechanism of dynamically extending the base class conversion rule, the change information of all derived classes affected by the change is extended in at least one version difference mapping table.

[0063] It should be noted that due to the complex inheritance relationship in the model library, it is extremely cumbersome to find and process each dependency in the user model one by one, and it is easy to miss important changes, especially when it comes to implicit dependencies of derived classes, which is difficult to handle efficiently with traditional methods. However, due to the complex inheritance relationship, it is more required that the derived class accurately inherit the change information of the base class, which increases the difficulty of recording and maintaining the change information.

[0064] Specifically, by analyzing the inheritance relationship in the user model, it is ensured that the version conversion information in the version difference mapping table is also effective when the type is inherited. In this embodiment, the user model will identify the base class and the derived class at the code level, and by analyzing the inheritance relationship in the user model, the base class and the derived class with the inheritance relationship in the user model are determined. Further, based on the change information of the library elements in at least one version difference mapping table, all derived classes affected by the change in the user model are located, and the base class conversion rules are dynamically extended. In other words, according to the change information of the relevant base class in the version difference mapping table, it is dynamically extended to the derived class.

[0065] In this embodiment, by using the dynamic extension mechanism of the base class conversion rules, the decoupling of the version conversion script and the derivation relationship processing is achieved, and the implicit dependencies in the complex inheritance relationship are processed according to the dynamic extension mechanism of the derived structure. Specifically, before searching and analyzing the dependency relationship of the user model, the derivation relationship of the user model is preprocessed, all affected derived classes are automatically identified, and the base class conversion rules are dynamically extended. Through the inheritance relationship analysis, the modification logic of the base class can be accurately applied to the derived class, and there is no need to explicitly define the conversion rules of the derived class in the version conversion script, which can significantly simplify the writing of the version conversion script. For example, if the version conversion script records the change of the base class BaseClass: x → y, when the derived class DerivedClass in the user model is derived from the base class BaseClass, the system will automatically expand the version difference mapping table generated by the analysis, so that when the relevant dependencies of the user model are subsequently modified, the reference to x in the derived class DerivedClass is correctly updated to y.

[0066] In some embodiments, before responding to receiving a request to convert the dependency of the user model, the method further includes: Load the current version of the model library that the user model depends on to access all components and dependencies in the current version of the model library; and identify the version information of the model library that the user model depends on. If the current version of the model library that the user model depends on is not the target version of the model library, generate conversion prompt information and display it on the user interface.

[0067] Specifically, first load the current version of the model library that the user model depends on, and ensure that all components and dependencies in the current version of the model library are accessible for subsequent dependency analysis and conversion operations. Then identify the model library version that the user model depends on. If the current version of the model library that the user model depends on is not the target version of the model library, generate conversion prompt information to determine whether the user needs to perform version conversion, select the appropriate version conversion script for subsequent steps, and facilitate the user end to automatically convert the model library version that the user model depends on, reducing the complexity of manual conversion.

[0068] See also Figure 6 , Figure 6 A schematic diagram showing the principle of a method for automatic conversion of model versions in the Modelica language provided in another embodiment of the present application.

[0069] In some embodiments, it also includes: generating a conversion log, where the conversion log is used to record operation information of each operation step performed on the user model during the dependency conversion process of the user model.

[0070] Specifically, by recording all operation information during the version conversion process and providing detailed logs of success and failure, users can quickly locate problems and debug. In this way, the traceability and convenience of the conversion process can be enhanced, making the entire conversion process more transparent. For example, when the type name of a component in the user model is successfully replaced from the old version to the new version, the specific content of the operation will be recorded in detail in the log; and when some dependencies cannot be matched or the replacement fails, the log will generate error information and accurately locate the problem location (such as specific library elements or conversion rules). In addition, information can be organized in chronological order, which is convenient for users to intuitively trace back the operation process. Through the generated log file, users can not only quickly understand the overall progress of the conversion process, but also conduct targeted troubleshooting and corrections for failed items, thereby improving the debuggability and maintenance efficiency of the system.

[0071] In summary, through the automated script parsing and data search functions, the conversion system of this embodiment effectively reduces the complexity of manual operation, realizes high-accuracy model conversion, significantly reduces the probability of errors, and ensures a unified style of model modification. In addition, the flexible version conversion script and data search functions enable the system to adapt to different fields and diversified model conversion requirements, providing users with a wide range of application adaptation capabilities. In addition, by outputting the conversion log, the user can monitor each step in the conversion process intuitively and in detail, significantly improving the debuggability and ease of use of the system. Compared with traditional methods, the innovation of this application is to realize the fully automated conversion of complex Modelica models between different version model libraries, improve the maintenance efficiency and compatibility of user models, and is suitable for the version conversion requirements of large-scale user models.

[0072] Based on the same inventive concept, an embodiment of the present application provides a model version automatic conversion system for Modelica language, and the model version automatic conversion system for Modelica language corresponds one to one with the model version automatic conversion method for Modelica language in the above embodiment. Figure 7 As shown, the model version automatic conversion system 700 for Modelica language includes a request response module 710, a script loading module 720, a script parsing module 730 and a version conversion module 740. Each functional unit is described in detail as follows: A request response module 710 is used to respond to a received request for converting the dependency relationship of a user model, wherein the request for converting includes version information of the model library on which the user model depends before and after the conversion; A loading script module 720 is used to load at least one version conversion script according to the version information of the model library that the user model depends on before and after the conversion, and the at least one version conversion script is used to record the version conversion information when the current version model library that the user model depends on is upgraded to the target version model library; The script parsing module 730 is used to parse at least one version conversion script to obtain at least one corresponding version difference mapping table; The version conversion module 740 is used to convert the dependency relationship of the user model according to at least one version difference mapping table, so that the converted user model is compatible with the target version model library.

[0073] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as various version model libraries, various version conversion scripts, and version difference mapping tables. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps of a model version automatic conversion method for the Modelica language in the above embodiment are implemented.

[0074] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of a method for automatic model version conversion in the Modelica language in the above embodiment are implemented.

[0075] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0076] It should be understood that although the flowchart in the accompanying drawings shows the order of each step in the form of arrows, the execution of these steps is not necessarily strictly in the order indicated by the arrows. Unless otherwise specifically stated in this article, the execution of these steps can be carried out in a different order. In addition, some steps in the flowchart may consist of multiple sub-steps or multiple stages, which do not need to be completed at the same time, can be executed at different time points, and their order may not necessarily be carried out in sequence, and may even be executed alternately or in parallel with other steps or sub-steps or stages of other steps. The modules and their components shown in the structure diagram in the accompanying drawings are only schematic frameworks, and these modules may include multiple sub-modules, each of which has different independent functions.

[0077] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for automatic model version conversion based on Modelica language, characterized in that: include: In response to receiving a conversion request for a dependency relationship of a user model, the conversion request includes version information of a model library on which the user model depends before and after conversion; According to the version information of the model library on which the user model depends before and after the conversion, at least one version conversion script is loaded, wherein the at least one version conversion script is used to record the version conversion information when the current version model library on which the user model depends is upgraded to the target version model library; Parsing the at least one version conversion script to obtain at least one corresponding version difference mapping table; The dependency relationship of the user model is converted according to the at least one version difference mapping table, so that the converted user model is compatible with the target version model library.

2. The automatic model version conversion method for Modelica language according to claim 1, characterized in that: Before the response receives a request for converting the dependency relationship of the user model, the method further includes: According to the preset conversion rules, multiple version conversion scripts are established, each of which is used to record the change information of the library elements when each version model library is upgraded to the next version model library; The preset conversion rules include type conversion rules, condition conversion rules, element conversion rules and variant conversion rules.

3. The automatic model version conversion method for Modelica language according to claim 1, characterized in that: According to the version information of the model library on which the user model to be converted depends before and after the conversion, at least one version conversion script is loaded, including: If the model library version on which the user model before conversion depends and the model library version on which the user model after conversion depends differ by one version, a corresponding version conversion script is loaded; or If the model library version on which the user model before conversion depends and the model library version on which the user model after conversion depends differ by several versions, the corresponding several versions of conversion scripts are loaded.

4. The automatic model version conversion method for Modelica language according to claim 1, characterized in that: Parsing the at least one version conversion script to obtain at least one corresponding version difference mapping table includes: The conversion rules of each version conversion script are parsed, all version conversion information recorded in the version conversion script is extracted and sorted, and a corresponding version difference mapping table is generated.

5. The method for automatic model version conversion for Modelica language according to any one of claims 1 to 4, characterized in that: According to the at least one version difference mapping table, converting the dependency relationship of the user model on the current version model library so that the converted user model is compatible with the target version model library includes: According to the at least one version difference mapping table, searching and analyzing the dependency relationship of the user model on the current version model library to determine the dependency to be changed in the user model; The dependency relationship of the user model is converted according to the at least one version difference mapping table and the dependency to be changed in the user model.

6. The method for automatic model version conversion for Modelica language according to claim 5, characterized in that: According to the at least one version difference mapping table, searching and analyzing the dependency relationship of the user model on the current version model library to determine the dependency to be changed in the user model includes: Traversing all dependencies in the user model, and locating dependencies to be changed in statements and syntax elements of the user model according to change information of each library element in the at least one version difference mapping table; The statements include import statements, inheritance statements, equation and algorithm statements, and component declarations; and the grammatical elements include expressions, annotations, and variants.

7. The automatic model version conversion method for Modelica language according to claim 5, characterized in that: Before searching and analyzing the dependency relationship between the user model and the current version model library according to the at least one version difference mapping table, the method further includes: Analyze the inheritance relationship of the user model to determine the base class and derived class with inheritance relationship; Locate all derived classes in the user model that are affected by the change according to the change information of the base class in the at least one version difference mapping table; According to the mechanism of dynamically extending the base class conversion rule, the change information of all derived classes affected by the change is extended in the at least one version difference mapping table.

8. The method for automatic model version conversion in Modelica language according to any one of claims 1 to 4, characterized in that: Before the response receives a request for converting the dependency relationship of the user model, the method further includes: Load the current version of the model library that the user model depends on to access all components and dependencies in the current version of the model library; The version information of the model library on which the user model depends is identified. If the current version of the model library on which the user model depends is not the target version of the model library, conversion prompt information is generated and displayed on the user interface.

9. The method for automatic model version conversion for Modelica language according to any one of claims 1 to 4, characterized in that: Also includes: A conversion log is generated, where the conversion log is used to record operation information performed on the user model during the dependency conversion process of the user model.

10. A model version automatic conversion system for Modelica language, characterized in that: include: A request response module, used to respond to a received request for conversion of a dependency relationship of a user model, wherein the conversion request includes version information of a model library on which the user model depends before and after conversion; A loading script module, used to load at least one version conversion script according to the version information of the model library on which the user model depends before and after the conversion, wherein the at least one version conversion script is used to record the version conversion information when the current version model library on which the user model depends is upgraded to the target version model library; A script parsing module, used to parse the at least one version conversion script to obtain at least one corresponding version difference mapping table; The version conversion module is used to convert the dependency relationship of the user model according to the at least one version difference mapping table, so that the converted user model is compatible with the target version model library.

Citation Information

Patent Citations

  • Code change-based mobile application test script automatic maintenance method

    CN106021103A

  • Database version updating method and system of communication equipment and readable storage medium

    CN116244319A

  • Data version control method and device based on log

    CN117235048A

  • Model conversion method and device and storage medium

    CN118400426A

  • Data version difference comparison system and method based on data management model

    CN118733071A