A code generation method and system for a SysML model and a medium

By pre-setting GCK model mapping rules and component call libraries, the code for SysML models is automatically generated, which improves the development efficiency of aircraft systems and solves the problem of low efficiency in converting SysML models to design code.

CN119668591BActive Publication Date: 2025-11-07SHENZHEN SHIGUAN DIGITAL INTELLIGENCE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The development efficiency of aircraft systems in the current technology is low, mainly due to the low efficiency of converting SysML models into design code.

Method used

By using preset GCK model mapping rules, the model element data of the target SysML model is determined, and the target GCK model is automatically generated based on the preset GCK model component call library. The preset code conversion tool is used to achieve automated code generation.

Benefits of technology

It improves the code generation efficiency of SysML models and the development efficiency of aircraft systems, solving the problem of low development efficiency of aircraft systems in existing technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119668591B_ABST
    Figure CN119668591B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a code generation method and system for a SysML model and a medium, in the method, a plurality of target model element data in a target SysML model are acquired, element mapping is carried out based on a preset GCK model mapping rule, target GCK model elements corresponding to the target model element data are determined. Subsequently, according to the target GCK model elements and the preset GCK model mapping rule, a GCK model component corresponding to each of the target GCK model elements is called from a preset GCK model component call library to establish a target GCK model. Finally, the target GCK model is code converted by a preset code conversion tool to obtain a target code, effectively improving the code generation efficiency of the SysML model and the development efficiency of the aircraft system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

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

[0002] In the design and development process of an aircraft system, specific components and engines in the aircraft are determined mainly through a SysML (Systems Modeling Language) model, and the SysML model is converted into corresponding design code, so as to complete the development and design of the aircraft system. However, in the traditional development process, after the SysML model is completed, the SysML model is manually converted into actual design code by an engineer. In this way, the code generation efficiency is low, and the development efficiency of the aircraft system is low.

[0003] Therefore, how to solve the problem of low development efficiency of the aircraft system in the prior art has become a technical problem to be solved by the person skilled in the art. SUMMARY

[0004] In order to improve the development efficiency of the aircraft system, the embodiments of the present application provide a code generation method and system for a SysML model and a medium.

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

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

[0007] Obtaining a plurality of 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;

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

[0009] According to the target GCK model elements and the preset GCK model mapping rule, calling GCK model components corresponding to the target GCK model elements from a preset GCK model component call library to establish a target GCK model; the target GCK model is converted from the target SysML model;

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

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

[0012] The GCK model components corresponding to the target GCK model elements are called from the preset GCK model component calling library according to the target GCK model elements and the preset GCK model mapping rule to establish the target GCK model, including:

[0013] The GCK model components corresponding to the target GCK model elements are called from the preset GCK model component calling library according to the target GCK model elements.

[0014] The connection mechanism and the communication rule between the GCK model components are established by the connection mechanism mapping rule to obtain the target GCK model.

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

[0016] The target GCK model and the target SysML model are subjected to consistency verification 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] According to the consistency verification result, the preset GCK model mapping rule or the target SysML model is adjusted, including:

[0020] When the structure verification result is abnormal, the preset GCK model mapping rule is adjusted to enable a component in the target SysML model to correctly map a component in the target GCK model.

[0021] When the behavior verification result is abnormal, a state machine in the target SysML model is subjected to behavior mode adjustment to enable the behavior mode of the target SysML model to be consistent with the target GCK model.

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

[0023] In a possible implementation, before the target SysML model element data is obtained, the method further includes:

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

[0025] The target SysML model is subjected to model checking according to the component view data.

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

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

[0028] The target code is subjected to code checking 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 obtaining module is configured to obtain target model element data in a target SysML model; the target model element data is used to represent component composition of the target SysML model and connection mechanisms among components.

[0031] An element mapping module is configured to perform element mapping based on a preset GCK model mapping rule to determine target GCK model elements corresponding to the target model element data.

[0032] A component calling module is configured to call GCK model components corresponding to the target GCK model elements from a preset GCK model component calling library according to the target GCK model elements and the preset GCK model mapping rule to establish a target GCK model; the target GCK model is converted from the target SysML model.

[0033] A code conversion module is configured to convert the target GCK model into target code by using a preset code conversion tool. The preset code conversion tool is based on the preset GCK model component library to call a driver.

[0034] In a third aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program. The program is executed by a processor to implement the code generation method for the SysML model in any possible manner of the first aspect.

[0035] Compared with the prior art, the present application has the following beneficial effects: the embodiments of the present application provide a code generation method, system and medium for the SysML model. In the method, first, based on the preset GCK model mapping rule, the target GCK model elements corresponding to the 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. Then, the target GCK model elements are taken as the reference basis to call the corresponding GCK model components from the preset GCK model component 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 describability. Therefore, based on the preset GCK model component library to drive the corresponding preset code conversion tool, 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 development efficiency of the aircraft system in the prior art. BRIEF DESCRIPTION OF DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

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

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

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

[0040] To make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the embodiments and the accompanying drawings. It should be particularly noted that the embodiments described in the embodiments of the present application are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present 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 as the usual meanings understood by those of ordinary skill in the art to which the present application belongs. The terms "first", "second" and similar terms used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. The terms "include" or "contain" and similar terms mean that the elements or objects before the terms cover the elements or objects listed after the terms and their equivalents, and do not exclude other elements or objects. The terms "connect" or "connected" and similar terms are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The terms "up", "down", "left", "right" and the like are only used to represent relative positional relationships, and 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 an aircraft system, the specific components and engines in the aircraft are mainly determined through a SysML model, and are converted into corresponding design code, so as to complete the development and design of the aircraft system. However, in the traditional development process, after the SysML model is completed, the SysML model is manually converted into actual design code by engineers, and the code generation efficiency is low in this way, and the development efficiency of the aircraft system is low.

[0043] Therefore, how to solve the problem of low development efficiency of the aircraft system in the prior art has become a technical problem to be solved by those skilled in the art.

[0044] To solve the above problems, the embodiment of the present application provides a code generation method, system and medium for a SysML model. In the method, first, based on a preset GCK model mapping rule, a plurality of target model element data in a target SysML model are determined to individually correspond to a target GCK model element, so as to provide a reference basis for model conversion of the target SysML model to the target GCK model. Subsequently, the target GCK model element is taken as a reference basis, a corresponding GCK model component is called from a preset GCK model component call library, and model construction is performed based on the preset GCK model mapping rule, so as to establish a target GCK model corresponding to the target SysML model, and realize model conversion of the target SysML model to the target GCK model. Since GCK is a general modeling language, it has wide generality and describability, and thus on the basis of the preset GCK model component call library, a corresponding preset code conversion tool can be driven to automatically and quickly determine a target code directly mapped by various target GCK model elements, so as to realize automatic code generation for the target SysML model, effectively improve the code generation efficiency of the SysML model and the development efficiency of the aircraft system, and solve the problem of low aircraft system development efficiency in the prior art.

[0045] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0046] Next, the code generation method for a SysML model provided by the embodiment of the present application will be described in combination with specific embodiment drawings. Referring to Figure 1 , the figure is a flowchart of a code generation method for a SysML model provided by the embodiment of the present application, which specifically includes the following steps:

[0047] S101: Obtain a plurality of 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 (General Component Modeling Kit) model is a design model constructed based on a general modeling language. Since the model is described by a general modeling language, the elements and components in the GCK model are closer to actual programming concepts and requirements, and thus code automatic generation for the GCK model can be realized.

[0049] Therefore, embodiments of the present application aim to convert a target SysML model into a corresponding target GCK model, and realize code automatic generation for the target SysML model by code automatic generation for the target GCK model, so as to improve the design and development efficiency of an aircraft system through code automatic generation for the target SysML model.

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

[0051] The target model elements of each component in the target SysML model can be acquired by a corresponding analysis tool. Specifically, the target SysML model is imported into a standard SysML tool (for example, IBM Rational Rhapsody) by using a standard SysML tool, so as to analyze detailed information of each component (for example, a part, a port, and an interface) in the target SysML model. The information includes the name, type, attribute, behavior description of each component, and the connection manner and data flow between components. The information data about each component in the target SysML model is used as multiple target model element data in the target SysML model, and is also used as a reference basis for conversion of the target SysML model into the target GCK model.

[0052] In a possible implementation manner, in order to ensure the integrity, correctness, and consistency of the target SysML model, model checking can be performed on the target SysML model by using component view data of the target SysML model.

[0053] Specifically, reference can be made to Figure 2An example component view structure diagram of a target SysML model is shown. As can be seen from the diagram, the component view of the target SysML model can be roughly divided into a package view, a component definition diagram, a component structure diagram, a parameter diagram, a timing diagram, an activity diagram, and a 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, diversified model checking of the target SysML model can be performed, such as syntax and semantic checking, requirement checking, and model consistency checking. In this way, through the diversified component view data of the target SysML model, it can be ensured that there is no implicit problem 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] In S102, element mapping is performed based on a preset GCK model mapping rule to determine target GCK model elements corresponding to the target model element data.

[0055] After determining the plurality of target model element data in the target SysML model for representing element composition and connection relationship, based on the preset GCK model mapping rule, it can be determined that each model component in the target SysML model is mapped to a corresponding component of the GCK model, that is, a corresponding target GCK model element.

[0056] In the preset GCK model mapping rule of the embodiments of the present application, element mapping rules and connection mechanism mapping rules are specifically included. The element mapping rules are used to represent the mapping rules of each model element and component in the SysML model to the corresponding model element and component in the GCK model. 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 represent how to map the connection and communication mechanism between each element and component in the SysML model to a plurality of elements and components in the GCK model. Exemplarily, the connection mechanism can be a connector and a constraint, which is not limited in the embodiments.

[0057] For example, assume that there is a flight control system component "AttitudeControl" in the target SysML model, which has input ports "RollIn" and "PitchIn", output ports "RollOut" and "PitchOut". According to the preset GCK model mapping rule, the component is converted into a component "AttitudeControlComponent", input interfaces "RollInterface" and "PitchInterface", and output interfaces "RollOutputInterface" and "PitchOutputInterface" in the target GCK model. In this way, through the preset GCK model mapping rule, the specific GCK model element to which each element in the target SysML model is mapped can be determined, so as to convert 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 rule, a GCK model component corresponding to each of the target GCK model elements is called from a preset GCK model component call library to establish a target GCK model; the target GCK model is converted from the target SysML model.

[0059] Correspondingly, after determining the target GCK model elements corresponding to the target SysML model, the corresponding model components are called from the preset GCK model component call library through the determined target GCK model elements, so as to establish the target GCK model. Since each element and component in the target GCK model has a one-to-one mapping relationship with the elements 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 replace the code generation link of the target SysML model in subsequent automatic code generation for the target GCK model.

[0060] The preset GCK model component call library is a call library containing various GCK model elements and components, which is preset by the embodiment of the application. Based on various SysML models, the embodiment of the 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 abstraction level and richer semantics, so that the upgrade structure and development behavior of the aircraft system can be more accurately expressed, and the automatic generation of code is more efficient and reliable. Through the preset GCK model component call library, the preconfigured model elements and components can be more efficiently utilized and combined in the modeling process of the target GCK model, so as to quickly establish the target GCK model, realize the conversion of 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 extended according to actual needs and project changes to ensure effective conversion of the model.

[0061] As can be known from the foregoing description of the preset GCK model mapping rule, the preset GCK model mapping rule includes element mapping rules and connection mechanism mapping rules. In the process of establishing the target GCK model, after the corresponding GCK model components are called from the preset GCK model component call library through the target GCK model elements, the connection mechanism and communication rules between the GCK model components in the model need to be determined based on the connection mechanism mapping rules, so as to establish the connection between the GCK model components 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, the consistency of the target GCK model and the target SysML model needs to be verified, and the preset GCK model mapping rule or the target SysML model between the two is adjusted according to the consistency verification result between the two.

[0063] Specifically, the consistency verification between the two includes structure verification and behavior verification, and the corresponding consistency verification results are also divided into structure verification results and behavior verification results. When the structure 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, so when the structure verification result is abnormal, the preset GCK model mapping rule needs to be adjusted 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 the behavior mode in the target SysML model is different from the target GCK model, at this time, the behavior mode of the state machine in the target SysML model needs to be adjusted to ensure that the behavior mode of the target SysML model is consistent with the target GCK model.

[0065] S104: code conversion is performed on the target GCK model by using a preset code conversion tool to obtain target code; the preset code conversion tool is driven based on the preset GCK model component calling library.

[0066] Finally, the target GCK model converted from the target SysML model is automatically generated by using the preset code conversion tool based on the preset GCK model component calling library. Since the preset code conversion tool is based on the corresponding component calling library, the code conversion tool can read and parse the target GCK model file, and finally the automatic code generation is realized.

[0067] In particular, in the embodiment of the present application, each model component in the preset GCK model component calling library has a corresponding code automatic generation template and a code automatic generation architecture. Therefore, when the target GCK model is automatically converted by using the preset code conversion tool, the generation template and the generation architecture corresponding to each component and element in the target GCK model can be used to generate the code corresponding to each component and state machine in the target GCK model on the basis of 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, so as to automatically generate the target code.

[0068] Correspondingly, in order to ensure that the target code meets the functional and quality standards, a static analysis tool can be further used to check the target code to ensure the syntax correctness of the code, and obtain a corresponding code checking result. In a possible implementation manner, a series of functional tests, integration tests and other tests can be further performed on the target code to ensure the effectiveness of the target code, and details are not described herein.

[0069] The embodiment of the present application provides a code generation method and system for a SysML model and a medium, in the method, first, based on a preset GCK model mapping rule, a plurality of target model element data in a target SysML model are determined to individually correspond to target GCK model elements, so as to provide a reference basis for model conversion of the target SysML model to a target GCK model. Subsequently, taking each target GCK model element as a reference basis, a corresponding GCK model component is called from a preset GCK model component call library, and model construction is performed based on the preset GCK model mapping rule, so as to establish a target GCK model corresponding to the target SysML model, and model conversion of the target SysML model to the target GCK model is realized. Since GCK belongs to a general modeling language, it has wide generality and describability, so on the basis of the preset GCK model component call library, a corresponding preset code conversion tool can be driven, and various target code directly mapped by target GCK model elements can be automatically and quickly determined, so as to realize automatic code generation for the target SysML model, effectively improve the code generation efficiency of the SysML model and the development efficiency of the aircraft system, and solve the problem of low aircraft system development efficiency in the prior art.

[0070] The embodiment of the present application provides a code generation system for a SysML model, and the code generation system for a SysML model described below can be correspondingly referred to the code generation method for a SysML model described above.

[0071] Referring to Figure 3 The figure is a structural schematic diagram of a code generation system for a SysML model provided by the embodiment of the present application, and specifically includes the following modules:

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

[0073] The element mapping module 200 is used for element mapping based on a preset GCK model mapping rule, so as to determine target GCK model elements corresponding to each target model element data;

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

[0075] The code conversion module 400 is configured to perform code conversion on the target GCK model by using a preset code conversion tool to obtain target code, and the preset code conversion tool is based on the preset GCK model component calling library driver.

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

[0077] According to each target GCK model element, the GCK model component corresponding to each target GCK model element is called from the preset GCK model component calling library.

[0078] The connection mechanism and the communication rule between the GCK model components are established by using the connection mechanism mapping rule, and the target GCK model is obtained.

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

[0080] The consistency verification module is configured to perform 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 specifically further configured to:

[0083] When the structure verification result is abnormal, the preset GCK model mapping rule is adjusted to enable the components in the target SysML model to correctly map the components in the target GCK model.

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

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

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

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

[0088] performing model checking on the target SysML model according to the component view data.

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

[0090] In a possible implementation, the code generation system for a SysML model further comprises a code checking module configured to perform 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, the embodiments of the present application also provide a computer readable storage medium, which stores computer instructions for causing a computer to perform the code generation method for a SysML model according to any of the above embodiments.

[0092] The computer readable medium of the embodiments of the present application includes permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology to store information. The information can be computer readable instructions, data structures, program modules 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 technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.

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

[0094] It should be noted that each of the embodiments described in the specification of the present application adopts a progressive manner, and the same or similar parts between the embodiments can be mutually referred to. Each embodiment focuses on the differences from other embodiments. In particular, for the method, system and medium, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment. The above-described method, system and medium are only illustrative, and the units described as separate units can or can not be physically separated, and the units described as units can or can not be physical units, that is, they can be located in one place or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment scheme according to actual needs. Those skilled in the art can understand and implement it without creative labor.

[0095] The above is only one specific embodiment of the present application, but the protection scope of the present application is not limited to this. Any skilled person in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A code generation method for a SysML model, characterized in that, The method comprises the following steps: acquiring a plurality of 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; element mapping is performed 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; a GCK model component corresponding to each target GCK model element is called from a preset GCK model component calling library according to each target GCK model element and the preset GCK model mapping rule, so as to establish a target GCK model; the target GCK model is converted from the target SysML model; code conversion is performed on the target GCK model by using a preset code conversion tool, so as to obtain target code; the preset code conversion tool is driven based on the preset GCK model component calling library; the preset GCK model mapping rule comprises a connection mechanism mapping rule; the calling of the GCK model component corresponding to each target GCK model element from the preset GCK model component calling library according to each target GCK model element and the preset GCK model mapping rule, so as to establish a target GCK model, comprises the following steps: the GCK model component corresponding to each target GCK model element is called from the preset GCK model component calling library according to each target GCK model element; the connection mechanism and the communication rule between the GCK model components are established by using the connection mechanism mapping rule, so as to obtain the target GCK model.

2. The method of claim 1, wherein, After the calling of the GCK model component corresponding to each target GCK model element from the preset GCK model component calling library according to each target GCK model element and the preset GCK model mapping rule, so as to establish a target GCK model, the method further comprises the following steps: consistency verification is performed on the target GCK model and the target SysML model, so as to obtain a consistency verification result; the preset GCK model mapping rule or the target SysML model is adjusted according to the consistency verification result.

3. The method of claim 2, wherein, the consistency verification result comprises a structure verification result and a behavior verification result; the adjustment of the preset GCK model mapping rule or the target SysML model according to the consistency verification result comprises the following steps: when the structure verification result is abnormal, the preset GCK model mapping rule is adjusted, 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.

4. The method of claim 1, wherein, each model component in the preset GCK model component calling library has a separately corresponding code automatic generation template and a code automatic generation architecture.

5. The method of claim 1, wherein, Before the acquiring the plurality of target model element data in the target SysML model, the method further comprises: acquiring component view data of the target SysML model; performing model checking on the target SysML model according to the component view data.

6. The method of claim 5, wherein, The component view data comprises package view, component definition view, component structure view, parameter view, timing view, activity view and state machine view; and the model checking comprises syntax and semantic checking, requirement checking and model consistency checking.

7. The method of claim 1, wherein, After the code conversion of the target GCK model by the preset code conversion tool to obtain the target code, the method further comprises: performing code checking on the target code based on a static analysis tool to obtain a code checking result.

8. A code generation system for SysML models, characterized in that, comprises: an element acquiring module configured to acquire a plurality of target model element data in a target SysML model; the target model element data is used to represent component composition of the target SysML model and connection mechanism between components; an element mapping module 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; a component calling module configured to call a GCK model component corresponding to each of the target GCK model elements from a preset GCK model component calling library according to each of the target GCK model elements and the preset GCK model mapping rule to establish a target GCK model; the target GCK model is converted from the target SysML model; a code conversion module configured to perform code conversion on the target GCK model by a preset code conversion tool to obtain a target code; the preset code conversion tool is driven based on the preset GCK model component calling library; the preset GCK model mapping rule comprises a connection mechanism mapping rule; the calling of the GCK model component 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 comprises: the calling of the GCK model component 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; establishing connection mechanism and communication rule between each of the GCK model components by the connection mechanism mapping rule to obtain the target GCK model.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the code generation method for the SysML model in any one of claims 1-7.

Citation Information

Patent Citations

  • Code automatic generation method based on SysML model

    CN116909544A

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

    CN117406980A