Code generation method and system for SysML model and medium

By presetting GCK model mapping rules and component call library, the automated conversion of SysML model to GCK model is realized, which solves the problem of inefficient aircraft system development in traditional methods and improves code generation and development efficiency.

CN119668591AActive Publication Date: 2025-03-21SHENZHEN SHIGUAN DIGITAL INTELLIGENCE TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411726859.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-03-21
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

During the development of traditional aircraft systems, the conversion efficiency of SysML model to design code is low, resulting in inefficient development.

Method used

By presetting GCK model mapping rules, determine the correspondence between SysML model elements and GCK model elements, call the GCK model component call library to build the target GCK model, and generate the target code through the code conversion tool.

Benefits of technology

The automatic transformation of SysML model to GCK model is realized, which improves the code generation efficiency and aircraft system development efficiency, and solves the problem of inefficient development in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119668591A_ABST
    Figure CN119668591A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a code generation method and system for a SysML model and a medium, and the method comprises the steps: obtaining multiple pieces of target model element data in a target SysML model, and carrying out the element mapping based on a preset GCK model mapping rule, so as to determine a target GCK model element corresponding to each piece of target model element data; and then, according to each target GCK model element and a preset GCK model mapping rule, calling a GCK model component corresponding to each target GCK model element from a preset GCK model component calling library, so as to establish a target GCK model. And finally, performing code conversion on the target GCK model through a preset code conversion tool to obtain a target code, so that the code generation efficiency of the SysML model and the development efficiency of an aircraft system are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a code generation method, system and medium for a SysML model. Background Art

[0002] In the design and development process of aircraft systems, SysML (Systems Modeling Language) models are mainly used to determine the specific components and engines in the aircraft, and then convert them into corresponding design codes to complete the development and design of aircraft systems. However, in the traditional development process, after completing system modeling through SysML models, engineers often need to manually convert the constructed SysML models into actual design codes. The code generation efficiency under this method is low, and the development efficiency of aircraft systems is low.

[0003] Therefore, how to solve the problem of low development efficiency of aircraft systems in the prior art has become a technical problem that technical personnel in this field urgently need to solve. Summary of the invention

[0004] Based on the above problems, in order to improve the development efficiency for aircraft systems, the embodiments of the present application provide a code generation method, system and medium for SysML models.

[0005] The embodiments of the present application disclose the following technical solutions:

[0006] In a first aspect, an embodiment of the present application provides a code generation method for a SysML model, comprising:

[0007] Acquire multiple target model element data in the target SysML model; the target model element data is used to characterize the component composition of the target SysML model and the connection mechanism between the components;

[0008] Perform element mapping based on a preset GCK model mapping rule to determine a target GCK model element corresponding to each of the target model element data; the preset GCK model is a general modeling language model;

[0009] According to each of the target GCK model elements and the preset GCK model mapping rules, calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library to establish a target GCK model; the target GCK model is obtained by converting the target SysML model;

[0010] The target GCK model is converted into code by a preset code conversion tool to obtain a target code; the preset code conversion tool calls a library driver based on the preset GCK model component.

[0011] In a possible implementation, the preset GCK model mapping rule includes: a connection mechanism mapping rule;

[0012] The step of calling the GCK model components corresponding to the target GCK model elements from the preset GCK model component calling library according to the target GCK model elements and the preset GCK model mapping rules to establish the target GCK model includes:

[0013] According to each of the target GCK model elements, calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library;

[0014] Through the connection mechanism mapping rules, the connection mechanism and communication rules between the GCK model components are established to obtain the target GCK model.

[0015] In a possible implementation, after calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library according to each of the target GCK model elements and the preset GCK model mapping rule to establish the target GCK model, the method further includes:

[0016] Performing consistency verification on the target GCK model and the target SysML model to obtain a consistency verification result;

[0017] According to the consistency verification result, the preset GCK model mapping rule or the target SysML model is adjusted.

[0018] In a possible implementation, the consistency verification result includes: a structure verification result and a behavior verification result;

[0019] The adjusting the preset GCK model mapping rule or the target SysML model according to the consistency verification result includes:

[0020] When the structure verification result is abnormal, adjusting the preset GCK model mapping rule so that the components in the target SysML model can correctly map the components in the target GCK model;

[0021] When the behavior verification result is abnormal, the behavior mode of the state machine in the target SysML model is adjusted so that the behavior mode of the target SysML model is consistent with the target GCK model.

[0022] In a possible implementation, each model component in the preset GCK model component call library has a corresponding code automation generation template and code automation generation architecture.

[0023] In a possible implementation manner, before obtaining the plurality of target model element data in the target SysML model, the method further includes:

[0024] Obtaining component view data of the target SysML model;

[0025] Model verification is performed on the target SysML model according to the component view data.

[0026] In a possible implementation, the component view data includes: package view, component definition diagram, component structure diagram, parameter diagram, timing diagram, activity diagram and state machine diagram; the model verification step includes: syntax and semantic verification, requirement verification and model consistency verification.

[0027] In a possible implementation, after converting the target GCK model into a code by using a preset code conversion tool to obtain a target code, the method further includes:

[0028] The target code is checked based on a static analysis tool to obtain a code checking result.

[0029] In a second aspect, an embodiment of the present application provides a code generation system for a SysML model, including:

[0030] An element acquisition module, used to acquire multiple target model element data in the target SysML model; the target model element data is used to characterize the component composition of the target SysML model and the connection mechanism between the components;

[0031] An element mapping module, used to perform element mapping based on a preset GCK model mapping rule to determine a target GCK model element corresponding to each of the target model element data;

[0032] A component calling module, used to call the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library according to each of the target GCK model elements and the preset GCK model mapping rules, so as to establish a target GCK model; the target GCK model is obtained by converting the target SysML model;

[0033] The code conversion module is used to perform code conversion on the target GCK model through a preset code conversion tool to obtain a target code; the preset code conversion tool calls a library driver based on the preset GCK model component.

[0034] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any possible code generation method for a SysML model in the first aspect.

[0035] Compared with the prior art, the present application has the following beneficial effects: The embodiment of the present application provides a code generation method, system and medium for a SysML model. In the method, firstly, based on the preset GCK model mapping rules, the target GCK model elements corresponding to each of the multiple target model element data in the target SysML model are determined to provide a reference basis for the model conversion from the target SysML model to the target GCK model. Subsequently, each target GCK model element is used as a reference basis to call the corresponding GCK model component from the preset GCK model component call library, and the model is constructed based on the preset GCK model mapping rules, thereby establishing a target GCK model corresponding to the target SysML model, and realizing the model conversion from the target SysML model to the target GCK model. Since GCK is a universal modeling language with wide versatility and descriptiveness, it can automatically and quickly determine the target codes directly mapped to various target GCK model elements based on the preset GCK model component call library to drive the corresponding preset code conversion tool, thereby realizing automatic code generation for the target SysML model, effectively improving the code generation efficiency for the SysML model and the development efficiency of the aircraft system, and solving the problem of low efficiency in aircraft system development in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0037] Figure 1 A flowchart of a code generation method for a SysML model provided in an embodiment of the present application;

[0038] Figure 2 A schematic diagram of a component view structure of a target SysML model provided in an embodiment of the present application;

[0039] Figure 3 A schematic diagram of the structure of a code generation system for a SysML model provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical solutions and advantages of this application more clear, the following is a further detailed description of this application in combination with specific embodiments and with reference to the accompanying drawings. It should be noted that the embodiments described in the embodiments of this application are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0041] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "include" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right", etc. are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0042] As described above, in the design and development process of aircraft systems, SysML models are mainly used to determine the specific components and engines in the aircraft, and then converted into corresponding design codes to complete the development and design of aircraft systems. However, in the traditional development process, after completing system modeling through SysML models, engineers often need to manually convert the constructed SysML models into actual design codes. The code generation efficiency under this method is low, and the development efficiency for aircraft systems is low.

[0043] Therefore, how to solve the problem of low development efficiency of aircraft systems in the prior art has become a technical problem that technical personnel in this field urgently need to solve.

[0044] In order to solve the above problems, the embodiments of the present application provide a code generation method, system and medium for SysML models. In the method, firstly, based on the preset GCK model mapping rules, the target GCK model elements corresponding to each of the multiple target model element data in the target SysML model are determined to provide a reference basis for the model conversion from the target SysML model to the target GCK model. Subsequently, each target GCK model element is used as a reference basis to call the corresponding GCK model component from the preset GCK model component call library, and the model is constructed based on the preset GCK model mapping rules, so as to establish the target GCK model corresponding to the target SysML model, and realize the model conversion from the target SysML model to the target GCK model. Since GCK is a universal modeling language with wide versatility and descriptiveness, it can automatically and quickly determine the target codes directly mapped to various target GCK model elements based on the preset GCK model component call library to drive the corresponding preset code conversion tool, thereby realizing automatic code generation for the target SysML model, effectively improving the code generation efficiency for the SysML model and the development efficiency of the aircraft system, and solving the problem of low efficiency in aircraft system development in the prior art.

[0045] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0046] Next, the code generation method for the SysML model provided by the embodiment of the present application will be introduced in conjunction with the specific embodiment drawings. Figure 1 , which is a flow chart of a code generation method for a SysML model provided in an embodiment of the present application, and specifically includes the following steps:

[0047] S101: Acquire multiple target model element data in a target SysML model; the target model element data is used to represent the component composition of the target SysML model and the connection mechanism between the components.

[0048] The GCK (Generic Component Modelling Kit) model is a design model built based on a general modeling language. Since the model is described by a highly general modeling language, the elements and components in the GCK model are closer to actual programming concepts and requirements, so automatic code generation for the GCK model can be achieved.

[0049] In view of this, in order to improve the design and development efficiency of the aircraft system by automatically generating code for the target SysML model, the embodiment of the present application aims to convert the target SysML model into a corresponding target GCK model, and realize the automatic code generation for the target SysML model by automatically generating code for the target GCK model.

[0050] Therefore, the core of this application is the automatic conversion of the target SysML model to the target GCK model. First, it is necessary to obtain the target model element data of each model component in the target SysML model, so as to understand the component composition in the target SysML model and the connection mechanism between the components.

[0051] Among them, the target model elements of each component in the target SysML model can be obtained through the corresponding parsing tools. Specifically, the target SysML model is imported into the standard SysML tool through a standard SysML tool (such as IBM Rational Rhapsody), so as to parse the detailed information of each component (such as parts, ports, interfaces) in the target SysML model, which includes the name, type, attribute, behavior description of each component, and the connection mode and data flow between components. These information data about each component in the target SysML model, as multiple target model element data in the target SysML model, also serve as a reference for converting the target SysML model to the target GCK model.

[0052] In a possible implementation, in order to ensure the integrity, correctness and consistency of the target SysML model, the target SysML model may be model-checked using component view data of the target SysML model.

[0053] For details, please refer to Figure 2A schematic diagram of the component view structure of a target SysML model is shown. It can be seen from the figure that the component view of the target SysML model can be roughly divided into package view, component definition diagram, component structure diagram, parameter diagram, timing diagram, activity diagram and state machine diagram. Through the model verification tool for the target SysML model, various types of view data can be read, and through the diversified component view data, the target SysML model can be subjected to diversified model verification, such as syntax and semantic verification, requirement verification and model consistency verification. In this way, through the diversified component view data of the target SysML model, it can be ensured that there are no hidden problems in the syntax, requirements and model consistency, thereby ensuring the quality of the target SysML model and providing a data basis for subsequent model conversion.

[0054] S102: Perform element mapping based on a preset GCK model mapping rule to determine a target GCK model element corresponding to each target model element data; the preset GCK model is a general modeling language model.

[0055] After determining multiple target model element data used to characterize element composition and connection relationships in the target SysML model, based on the pre-set preset GCK model mapping rules, it can be determined that each model component in the target SysML model is mapped to the component corresponding to the GCK model, that is, the corresponding target GCK model element.

[0056] The preset GCK model mapping rules of the embodiment of the present application specifically include element mapping rules and connection mechanism mapping rules, wherein the element mapping rules are used to characterize the mapping rules of each model element and component in the SysML model to the corresponding model elements and components in the GCK model, and these rules need to cover the main modeling elements in SysML, such as components, ports, state machines, and parameters, etc. On the other hand, the connection mechanism mapping rules are used to characterize how to map the connection and communication mechanism between each element and component in the SysML model to multiple elements and components in the GCK model. Exemplarily, the connection mechanism can be a connector and a constraint, which is not limited in this embodiment.

[0057] For example, suppose there is a flight control system component "AttitudeControl" in the target SysML model, which has input ports "Roll In" and "Pitch In", and output ports "Roll Out" and "PitchOut". According to the preset GCK model mapping rules, this component is converted into a component "AttitudeControlComponent" in the target GCK model, with input interfaces "Roll Interface" and "Pitch Interface", and output interfaces "RollOutput Interface" and "PitchOutput Interface". In this way, by using the preset GCK model mapping rules, the GCK model elements to which each element in the target SysML model is specifically mapped can be determined, thereby converting the target SysML model into the target GCK model.

[0058] S103: According to each of the target GCK model elements and the preset GCK model mapping rules, calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library to establish a target GCK model; the target GCK model is obtained by converting the target SysML model.

[0059] Accordingly, after determining the target GCK model element corresponding to the target SysML model, the target GCK model is established by calling the corresponding model component from the preset GCK model component call library through the determined target GCK model element. Since each element and component in the target GCK model has a one-to-one mapping relationship with the element in the target SysML model, the target GCK model can be used as the GCK model converted from the target SysML model, so as to facilitate the subsequent automatic code generation for the target GCK model, instead of the code generation link for the target SysML model.

[0060] Among them, the preset GCK model component call library is a call library pre-set in the embodiment of the present application, which contains various GCK model elements and components. Based on the various SysML models, the embodiment of the present application introduces a series of unique elements and components in the call library. These elements and components have a one-to-one mapping relationship with the elements and components in the SysML model, and these elements and components have a higher level of abstraction and richer semantics, so they can more accurately express the upgrade structure and development behavior of the aircraft system, making the automatic generation of code more efficient and reliable. By presetting the GCK model component call library, in the modeling process of the target GCK model, the pre-configured model elements and components can be more efficiently utilized and combined, so as to quickly establish the target GCK model, realize the conversion from the target SysML model to the target GCK model, and improve the overall development efficiency of the flight system. In actual application scenarios, the call library can also be updated and expanded according to actual needs and project changes to ensure the effective conversion of the model.

[0061] From the description of the preset GCK model mapping rules in the previous text, it can be seen that the preset GCK model mapping rules include element mapping rules and connection mechanism mapping rules. In the process of establishing the target GCK model, after calling the corresponding GCK model component from the preset GCK model component call library through each target GCK model element, it is necessary to further determine the connection mechanism and communication rules between each GCK model component in the model based on the connection mechanism mapping rules, so as to establish the connection between each GCK model component to obtain the target GCK model.

[0062] In a possible implementation, after obtaining the target GCK model, in order to ensure the model consistency between the target GCK model and the target SysML model, it is necessary to perform consistency verification on the target GCK model and the target SysML model, and adjust the preset GCK model mapping rules between the two or the target SysML model according to the consistency verification result between the two.

[0063] Specifically, the consistency verification between the two includes structural verification and behavioral verification, and the corresponding consistency verification results are also divided into structural verification results and behavioral verification results. When the structural verification result is abnormal, it proves that the components in the target SysML model do not maintain the correct mapping relationship with the components in the target GCK model. Therefore, when the structural verification result is abnormal, it is necessary to adjust the preset GCK model mapping rules to ensure that the components in the target SysML model can be correctly mapped to the components in the target GCK model.

[0064] Correspondingly, when the behavior verification result is abnormal, it indicates that there is a difference between the behavior mode in the target SysML model and the target GCK model. At this time, it is necessary to adjust the behavior mode of the state machine in the target SysML model to ensure that the behavior mode of the target SysML model is consistent with that of the target GCK model.

[0065] S104: converting the target GCK model into a code by using a preset code conversion tool to obtain a target code; the preset code conversion tool calls a library driver based on the preset GCK model component.

[0066] Finally, the preset code conversion tool driven by the preset GCK model component call library is used to automatically generate code for the target GCK model converted from the target SysML model. Since the preset code conversion tool is driven by the corresponding component call library, it can ensure that the code conversion tool can read and parse the target GCK model file, thereby realizing automatic code generation.

[0067] In particular, in an embodiment of the present application, each model component in the preset GCK model component call library has a corresponding code automation generation template and code automation generation architecture. Therefore, when the target GCK model is automatically converted to code through the preset code conversion tool, the generation templates and generation architectures corresponding to each component and element in the target GCK model can be used to cover the generation code corresponding to each component and state machine in the target GCK model on the basis of determining the overall structure and framework of the code. In the actual code conversion process, each component instance in the target GCK model is matched with the corresponding code generation template for instantiation processing, thereby automatically generating the target code.

[0068] Accordingly, in order to ensure that the target code meets its functional and quality standards, a static analysis tool can be further used to perform code checking on the target code to ensure that the syntax of the code is correct and obtain corresponding code checking results. In a possible implementation, a series of policy tests such as functional testing and integration testing can be further performed on the target code to ensure the validity of the target code, which will not be described in detail in this embodiment.

[0069] The embodiment of the present application provides a code generation method, system and medium for SysML model. In the method, firstly, based on the preset GCK model mapping rule, the target GCK model elements corresponding to each of the multiple target model element data in the target SysML model are determined to provide a reference basis for the model conversion from the target SysML model to the target GCK model. Subsequently, each target GCK model element is used as a reference basis to call the corresponding GCK model component from the preset GCK model component call library, and the model is constructed based on the preset GCK model mapping rule, so as to establish the target GCK model corresponding to the target SysML model, and realize the model conversion from the target SysML model to the target GCK model. Since GCK is a general modeling language, it has wide versatility and descriptiveness. Therefore, on the basis of driving the corresponding preset code conversion tool through the preset GCK model component call library, the target code directly mapped by various target GCK model elements can be automatically and quickly determined, so as to realize the automatic code generation for the target SysML model, effectively improve the code generation efficiency for the SysML model and the development efficiency of the aircraft system, and solve the problem of low efficiency of aircraft system development in the prior art.

[0070] A code generation system for a SysML model provided in an embodiment of the present application is introduced below. The code generation system for a SysML model described below and the code generation method for a SysML model described above can refer to each other.

[0071] See also Figure 3 , which is a schematic diagram of the structure of a code generation system for a SysML model provided in an embodiment of the present application, specifically including the following modules:

[0072] The element acquisition module 100 is used to acquire a plurality of target model element data in the target SysML model; the target model element data is used to characterize the component composition of the target SysML model and the connection mechanism between the components;

[0073] An element mapping module 200, configured to perform element mapping based on a preset GCK model mapping rule to determine a target GCK model element corresponding to each of the target model element data;

[0074] The component calling module 300 is used to call the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library according to each of the target GCK model elements and the preset GCK model mapping rules, so as to establish a target GCK model; the target GCK model is obtained by converting the target SysML model;

[0075] The code conversion module 400 is used to perform code conversion on the target GCK model through a preset code conversion tool to obtain a target code; the preset code conversion tool calls a library driver based on the preset GCK model component.

[0076] In a possible implementation, the preset GCK model mapping rule includes: a connection mechanism mapping rule; the component calling module 300 is specifically used to:

[0077] According to each of the target GCK model elements, calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library;

[0078] Through the connection mechanism mapping rules, the connection mechanism and communication rules between the GCK model components are established to obtain the target GCK model.

[0079] In a possible implementation, the code generation system for the SysML model further includes: a consistency verification module; the consistency verification module is used to:

[0080] Performing consistency verification on the target GCK model and the target SysML model to obtain a consistency verification result;

[0081] According to the consistency verification result, the preset GCK model mapping rule or the target SysML model is adjusted.

[0082] In a possible implementation, the consistency verification module is further configured to:

[0083] When the structure verification result is abnormal, adjusting the preset GCK model mapping rule so that the components in the target SysML model can correctly map the components in the target GCK model;

[0084] When the behavior verification result is abnormal, the behavior mode of the state machine in the target SysML model is adjusted so that the behavior mode of the target SysML model is consistent with the target GCK model.

[0085] In a possible implementation, each model component in the preset GCK model component call library has a corresponding code automation generation template and code automation generation architecture.

[0086] In a possible implementation, the code generation system for the SysML model further includes: a model verification module; the model verification module is specifically used to:

[0087] Obtaining component view data of the target SysML model;

[0088] Model verification is performed on the target SysML model according to the component view data.

[0089] In a possible implementation, the component view data includes: package view, component definition diagram, component structure diagram, parameter diagram, timing diagram, activity diagram and state machine diagram; the model verification step includes: syntax and semantic verification, requirement verification and model consistency verification.

[0090] In a possible implementation, the code generation system for the SysML model further includes: a code checking module, wherein the code checking module is configured to perform a code checking on the target code based on a static analysis tool to obtain a code checking result.

[0091] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the code generation method for the SysML model as described in any of the above embodiments.

[0092] The computer-readable media of the embodiments of the present application include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0093] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the code generation method for the SysML model as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0094] It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for methods, systems and media, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The methods, systems and media described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0095] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A code generation method for a SysML model, characterized in that: include: Get multiple target model element data in the target SysML model; The target model element data is used to characterize the component composition of the target SysML model and the connection mechanism between the components; Perform element mapping based on a preset GCK model mapping rule to determine a target GCK model element corresponding to each of the target model element data; the preset GCK model is a general modeling language model; According to each of the target GCK model elements and the preset GCK model mapping rules, calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library to establish a target GCK model; the target GCK model is obtained by converting the target SysML model; The target GCK model is converted into code by a preset code conversion tool to obtain a target code; the preset code conversion tool calls a library driver based on the preset GCK model component.

2. The method according to claim 1, characterized in that The preset GCK model mapping rules include: connection mechanism mapping rules; The step of calling the GCK model components corresponding to the target GCK model elements from the preset GCK model component calling library according to the target GCK model elements and the preset GCK model mapping rules to establish the target GCK model includes: According to each of the target GCK model elements, calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library; Through the connection mechanism mapping rules, the connection mechanism and communication rules between the GCK model components are established to obtain the target GCK model.

3. The method according to claim 1, characterized in that After calling the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library according to each of the target GCK model elements and the preset GCK model mapping rules to establish the target GCK model, the method further includes: Performing consistency verification on the target GCK model and the target SysML model to obtain a consistency verification result; According to the consistency verification result, the preset GCK model mapping rule or the target SysML model is adjusted.

4. The method according to claim 3, characterized in that The consistency verification results include: structure verification results and behavior verification results; The adjusting the preset GCK model mapping rule or the target SysML model according to the consistency verification result includes: When the structure verification result is abnormal, adjusting the preset GCK model mapping rule so that the components in the target SysML model can correctly map the components in the target GCK model; When the behavior verification result is abnormal, the behavior mode of the state machine in the target SysML model is adjusted so that the behavior mode of the target SysML model is consistent with the target GCK model.

5. The method according to claim 1, characterized in that Each model component in the preset GCK model component call library has a corresponding code automation generation template and code automation generation architecture.

6. The method according to claim 1, characterized in that Before acquiring the plurality of target model element data in the target SysML model, the method further comprises: Obtaining component view data of the target SysML model; Model verification is performed on the target SysML model according to the component view data.

7. The method according to claim 3, characterized in that The component view data includes: package view, component definition diagram, component structure diagram, parameter diagram, timing diagram, activity diagram and state machine diagram; the model verification steps include: syntax and semantic verification, requirement verification and model consistency verification.

8. The method according to claim 1, characterized in that After the target GCK model is converted into code by a preset code conversion tool to obtain the target code, the method further includes: The target code is checked based on a static analysis tool to obtain a code checking result.

9. A code generation system for a SysML model, characterized in that: include: An element acquisition module is used to acquire multiple target model element data in the target SysML model; The target model element data is used to characterize the component composition of the target SysML model and the connection mechanism between the components; An element mapping module, used to perform element mapping based on a preset GCK model mapping rule to determine a target GCK model element corresponding to each of the target model element data; A component calling module, used to call the GCK model components corresponding to each of the target GCK model elements from the preset GCK model component calling library according to each of the target GCK model elements and the preset GCK model mapping rules, so as to establish a target GCK model; the target GCK model is obtained by converting the target SysML model; The code conversion module is used to perform code conversion on the target GCK model through a preset code conversion tool to obtain a target code; the preset code conversion tool calls a library driver based on the preset GCK model component.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the code generation method for a SysML model described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Model-to-code conversion method and device, electronic equipment and storage medium

    CN115048089A

  • Code automatic generation method based on SysML model

    CN116909544A

  • Model-driven development method and device, equipment and storage medium

    CN117406980A

  • Verification of computer-executable code generated from a model

    WO2012170675A2