CN116909544A - Automatic code generation method based on SysML model - Google Patents

Automatic code generation method based on SysML model Download PDF

Info

Publication number
CN116909544A
CN116909544A CN202310902130.3A CN202310902130A CN116909544A CN 116909544 A CN116909544 A CN 116909544A CN 202310902130 A CN202310902130 A CN 202310902130A CN 116909544 A CN116909544 A CN 116909544A
Authority
CN
China
Prior art keywords
model
sysml
component
code
target language
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310902130.3A
Other languages
Chinese (zh)
Inventor
王甜甜
杨培豪
金勤超
吴翔虎
王亦平
苏小红
王克朝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Harbin Institute of Technology
Original Assignee
Harbin Institute of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Harbin Institute of Technology filed Critical Harbin Institute of Technology
Priority to CN202310902130.3A priority Critical patent/CN116909544A/en
Publication of CN116909544A publication Critical patent/CN116909544A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

A code automatic generation method based on a SysML model belongs to the technical field of computers, and comprises the following steps: 1. according to the SysML specification, carrying out multi-level model verification on the established SysML model to ensure that the SysML model is legal and effective; 2. according to the established model content file, combining various views in the model, converting and analyzing the SysML model; 3. performing component definition and management; 4. normalizing code mapping template construction; 5. and (5) carrying out automatic generation of the layering codes to generate final target language codes. The invention can uniformly cooperate the MBSE and the MDA method, provides a specific means for realizing the SysML model, effectively reduces the model design development difficulty, improves the design development capability of the model SysML model in the MBSE method, and ensures the efficiency and quality of the system model development realization.

Description

Automatic code generation method based on SysML model
Technical Field
The invention belongs to the technical field of computers, relates to an automatic code generation method, and in particular relates to an automatic target language code generation method based on a SysML model.
Background
Model-based system engineering (MBSE) is a formal way of applying modeling methods to support system requirements, design, analysis, verification, and validation activities that begin at a conceptual design stage, throughout the development process and subsequent lifecycle stages. In the MBSE approach, the system model is the center of the design, and each decision made in the design is captured as a model element (or relationship between elements) that is located at a single location in the system model. The model with good form can be constructed and read, is the core of the MBSE method, and in the process of constructing the model, each modeling language is a standardized medium for communication, and the defined rules can endow clear meanings to elements and relations of the model.
The system modeling language (SysML) is a modeling language commonly used in MBSE methods to create models of system architecture, behavior, requirements, and constraints, and can perform many system and supersystem specification, analysis, design, and validation tasks. The system supported by SysML may include hardware devices, software inputs, personnel, procedures, facilities, and other man-made and natural system elements. The SysML can help to realize the canonical definition and architecture design of the system, and the SysML supports to construct a system model from four aspects of a structural model, a behavior model, a demand model and a parameter model, wherein the structural model emphasizes the hierarchy of the system and the interconnection relation between objects; the behavior model emphasizes the behavior of objects in the system, including their activities, interactions, and states; the demand model emphasizes retrospective relationships between demands and satisfies relationships of designs to the demands; the parametric model emphasizes constraint relationships between properties of the system or component.
Model Driven Architecture (MDA), a software design method, is used to separate business logic from the underlying platform to improve portability, interoperability and reusability of software. The MDA is based on a model conversion technology, and abstract models (such as a calculation irrelevant model, a platform irrelevant model and a platform relevant model) with different layers are converted with each other, so that automatic development of software is realized. Based on the development process of MDA, business personnel firstly construct a Calculation Independent Model (CIM) through analysis and modeling in the business field to describe the requirements; then converting the Computing Independent Model (CIM) into a Platform Independent Model (PIM) by combining the related standard specification; based on a Platform Independent Model (PIM), different platform dependent models (PSM) can be constructed according to different implementation environments, and finally the platform dependent models (PSM) are converted into target codes to complete the development process.
Model-based system engineering (MBSE) is closely related to Model Driven Architecture (MDA). Both MBSE and MDA use modeling techniques, but MBSE focuses more on modeling at the system level, while MDA focuses more on modeling at the software level. The MBSE and MDA may cooperate with each other, for example, using MDA in the MBSE as a development method for a software subsystem, or using MBSE in the MDA as a method for software requirement analysis and architecture design. Particularly, the process of generating the object code from the SysML language model in the MBSE method to the MDA is an important implementation mode for uniformly cooperating the MBSE method and the MDA method, and the characteristics of formalization, visualization, verifiability, reusability and the like of the model can be utilized, so that the efficiency and quality of design, development and implementation of the system model are improved, and the dynamic modeling and control of a complex system are realized.
Therefore, in the process of performing model development and implementation based on the MBSE method, a reliable and efficient automatic object code generation method based on the SysML model is needed, the workload of code developers is reduced, unnecessary ambiguity is avoided from being introduced in the development process, and the quality and efficiency of system model implementation are ensured.
Disclosure of Invention
In order to solve the problems, the invention provides a code automatic generation method based on a SysML model. The method automatically generates the high-efficiency object code capable of accurately expressing the model information based on the SysML model constructed by the modeling personnel, the generated object code considers the hierarchical nested relation among model elements, and the generated object code has reasonable structural design, clear hierarchy and high expandability and supports the multiplexing of codes by utilizing the component management concept; meanwhile, in the process of generating the target language code, the mapping template on which the code is generated strictly complies with the code specification standard related to the industry, so that the safety, usability and high reliability of the code are ensured. The method can be used on any platform supporting the modeling of the SysML model, and the generated target language code is safe, efficient and accurate, so that a specific means is provided for the implementation of the SysML model, the model design development difficulty can be effectively reduced, the design development capability of the model in the MBSE method is improved, and the efficiency and the quality of the system model development implementation are ensured.
The invention aims at realizing the following technical scheme:
a code automatic generation method based on a SysML model comprises the following steps:
step one, performing multi-level model verification on the established SysML model according to the SysML specification to ensure that the SysML model is legal and effective;
step two, converting and analyzing the SysML model according to the established model content file and combining various views in the model;
step three, defining and managing components;
step four, constructing a normalized code mapping template;
and fifthly, automatically generating the layering codes to generate final target language codes.
In a further embodiment, the first step is specifically: checking the model by combining seven views of a package diagram, a module definition diagram, an internal module diagram, a parameter diagram, a time sequence diagram, an activity diagram and a state machine diagram in the SysML model; the rules of verification include model self-checking consistency and phase consistency.
In a further embodiment, the step two model content files include a sysplex model modeling element content file and a sysplex model view content file: the SysML model modeling element content file only contains basic data related to the SysML model, such as definition information of each modeling element, connection relation among the modeling elements and hierarchical relation among the modeling elements; the SysML model view content file contains information about the graphical representation of the model view, model elements. The second step is specifically as follows:
step two, performing hierarchical analysis on a SysML model structure diagram to obtain hierarchical structure relations among model modeling elements;
step two, performing SysML model activity diagram synchronization processing, and analyzing activity diagram nodes contained in the activity diagram and connection relations among the nodes;
step two, performing flow processing of a SysML model state machine diagram, analyzing states of modules represented by the state machine diagram, and performing possible conversion between the states when responding to an event;
and step two, performing flow processing of the SysML model timing diagram, analyzing a message interaction sequence among all components of a module represented in the timing diagram, and how all components interact through operation calling and asynchronous signals.
In a further embodiment, in the third step, the component refers to an encapsulated, abstract, reusable and replaceable unit that can be used in different software systems in the modeling process of the model system, and the code generation process can directly take the component unit as granularity. To facilitate the exchange and integration of component models by different modeling tools, components are represented and stored in an XML file format conforming to the XMI standard. The flow of the third step is specifically as follows:
step three, defining components. Realizing description definition of component attribute, interface information of the component, dependency relationship of the component, applicable position, entering and exiting conditions and basic framework information required by the component, and generating component description items;
and step three, managing the components. The component description items are inserted into the component description file and the primitive symbols for the component are built in the system to support graphical modeling of the SysML model. The component management not only manages the self description information of the component, but also manages the generation information of the target language code corresponding to the component, and prepares the high-efficiency code corresponding to the component module in advance before the code of the SysML model is automatically generated, and directly combines and pastes the high-efficiency code in the code generation process. The high-efficiency code is a code which can reduce the resource consumption of running time, memory occupation, energy consumption and the like as much as possible while meeting the functional requirement, and has the characteristics of low redundancy and meeting the industry coding standard.
In a further embodiment, the third step specifically includes three ways of defining the component, and a combination of one or more of these ways is utilized in specifically defining the component:
a1, define the component using meta-object Mechanism (MOF). The MOF is taken as a specification to design a meta-model component, and the component definition process takes an instance of a meta-model directly as a component or takes an instance of an extended meta-model stereotype indirectly as a component;
a2, defining a component by using the SysML model created before. After the SysML model is created, the specific modeling modules contained in the defined components are configured. The component contains information of selected modules in the system and only generates a target language code corresponding to the SysML module in the contained range;
a3, defining the components through a component warehouse. The components are imported directly from the existing component repository for use and may be modified based on the imported components to define the specific components required by the user. The component repository may be stored to the cloud or locally.
In a further embodiment, the generating information sources of the target language code corresponding to the component in the third step include:
b1, if the component is defined by the established SysML model and the model has undergone the process of automatically generating target language codes, the component adopts the target language codes of the results of the previous generation process as pre-generated target language codes;
b2, if the component is directly imported and used by the component warehouse, and the component warehouse marks the automatic generation information of the target language code accompanied by the component when imported, the information is used as the target language generation code of the component;
and B3, except the two cases, the component management calls a code automatic generation method based on the SysML model, and all components utilized in the established SysML model are guaranteed to contain target language code information. The process of automatically generating the calling code is a recursive process until the solved model does not contain components other than itself, without generating object language code information, to obtain the predefined component object language code.
In a further embodiment, the specific flow of the fourth step is to analyze the code specification in the industry according to the code specification standard related in the industry. And then combining the characteristics of each model element of the SysML and the grammar rules of the target language to determine the mapping relation between the SysML model elements and the target language code elements, and constructing a safe and efficient target language code mapping template.
In a further embodiment, the input of step five comprises: the model converts and analyzes the content, the component information and the code mapping template information. The flow of the fifth step specifically comprises the following steps:
step five, generating the overall framework code of the program. And analyzing the nested hierarchical relationship of each model element in the SysML, deeply analyzing layer by layer, and generating a data structure and a method or a function interface by using a code mapping template according to each view information of the SysML model to form a program overall frame code.
And fifthly, generating program unit codes. And developing and analyzing layer by layer according to the nested hierarchical relationship of the SysML model, and generating the realization codes of the functions by using a code mapping template according to the information of the calling sequence relationship among the various views and the model elements.
And fifthly, generating code fusion and generating target language codes. And combining codes according to the component library description file and combining the overall program framework codes and the program unit codes to generate target language codes.
Compared with the prior art, the invention has the following advantages:
1. the invention has universality: the invention automatically generates codes based on the SysML model, and not aiming at a single programming language, all target code generating tasks based on the SysML model can adopt the steps of the code generating flow.
2. When the target language code is generated, the hierarchical nesting relation among the model elements is considered, and the concept of component management is combined, so that the reasonable structural design and clear hierarchy of the generated target language code are ensured, and the generated target language code has high reusability and high expandability.
3. When the code mapping template is constructed, the related coding standard in the industry is introduced into the construction process of the template and the code generation mapping process, so that the safety, the high efficiency and the high reliability of the generated code are ensured.
4. According to the code automatic generation method based on the SysML model, the MBSE and the MDA method are unified and cooperated, a specific means is provided for realizing the SysML model, the model design development difficulty can be effectively reduced, the model design development capability in the MBSE method is improved, and the system model development and realization efficiency and quality are ensured.
Drawings
Fig. 1 is a general flow chart of a method for automatically generating codes based on the SysML model.
Fig. 2 is a structural relationship of all views contained in the sysplex model.
Detailed Description
The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings and examples, and it is apparent that the described examples are only some, but not all, of the examples of the invention, and all other examples obtained by those skilled in the art without making any inventive effort are within the scope of the present invention.
The invention provides a code automatic generation method based on a SysML model, the framework of the method is shown in figure 1, and the method comprises the following steps:
and step one, carrying out multi-level model verification on the established SysML model according to the SysML specification, and ensuring that the SysML model of the target code to be generated is legal and effective.
In this step, the sysplex model has nine views in total, as shown in fig. 2, and the verification of the model is performed by combining seven views of a package diagram, a module definition diagram, an internal module diagram, a parameter diagram, a timing diagram, an activity diagram, and a state machine diagram in the sysplex model, and the basis of code generation is the seven views in the sysplex model. The other two views (a requirement graph and a use graph) are used for generating test cases, and do not belong to the category of automatic generation of target language codes.
Preferably, the content of the multi-level SysML model verification comprises the self-verification consistency and the phase consistency of the SysML model. The self-checking consistency is used for verifying the correctness of the modeling graphics, the constraint of the SysML grammar rule and the data consistency between the nested graphics; the phase consistency is used to verify that model element information embodied between the various views of the model is consistent.
And step two, converting and analyzing the SysML model according to the established model content file and combining various views in the model.
Preferably, the model content files in this step include a SysML model modeling element content file and a SysML model view content file. The modeling element content file only contains basic data related to the SysML model, namely definition information of each modeling element, connection relation information among the modeling elements and hierarchical relation among the modeling elements, and does not contain any view related information; the SysML model view content file contains information about the graphical representation of the model view and model elements, such as the type of view the model contains, the name of the view, the style and location of each primitive in the view, and information representing the style of connection of the connection relationship links between the primitives.
In particular, the present embodiment stores model contents in an XML file format conforming to the metadata exchange standard (XMI). The storage mode supports different SysML modeling tools, can exchange SysML modeling data, can accurately exchange model data without information loss as long as the modeling of data exchange accords with XMI standard, and is convenient for the exchange and integration of models. It should be noted that XML is not the only way to store the sysplex model, but the sysplex model may be represented and stored in other file formats, such as JSON data format, and stored in a database in the form of a program binary stream.
Preferably, in the process of model conversion and analysis, the embodiment firstly converts the model, reads the locally stored model in a certain data format, and converts the locally stored model into the model in the process of dynamic operation in the program, so that the SysML modeling tool can acquire the model; after the model conversion is completed, the model is analyzed, and the model analysis specifically comprises the following steps:
step two, performing hierarchical analysis on the SysML model structure diagram to obtain hierarchical structure relations among model modeling elements. The element types of the SysML model include package, model library, view, module, constraint module, activity, interaction, state machine, requirement, profile information. The SysML structure diagram analyzed in the step comprises a module definition diagram, an internal module diagram, a package diagram and a parameter diagram, and the structure hierarchy of the SysML model is analyzed by combining a SysML modeling element content file to obtain a nesting relationship between model modeling elements, such as a nesting model B in a certain package A, wherein the nesting of the model B comprises an activity C.
And step two, performing SysML model activity diagram synchronization processing, and analyzing activity diagram nodes and connection relations among the nodes contained in the activity diagram. Each active node of the active graph can be distributed to different model modules according to a distribution mechanism in the SysML, the active action represented by the active node is represented by the module, and if the active node is not distributed, the node of the active graph is realized by a model element containing the active graph by default; the connection between the nodes represents the transfer of information between the nodes, including the transfer of control and substance flows, and this step is responsible for resolving the above information contained in the activity map.
And step two, performing flow processing of the SysML model state machine diagram. This step resolves the states of the modules represented by the state machine diagram and possible transitions between the states in response to events. The state machine diagram can be used as an input item for declaring the development stage of a period to accurately describe the behavior of a module.
And step two, performing flow processing of the SysML model timing diagram. This step parses the sequence of message interactions between the components of the modules represented in the timing diagram and how the components interact through operation calls and asynchronous signals. The timing diagram is typically used as a detailed design tool in the SysML model, enabling the precise specification of an action as an input to the lifecycle development stage.
And thirdly, defining and managing the components.
The component in the third step refers to an encapsulated, abstract, reusable and replaceable unit which can be used in different software systems in the modeling process of the model system, and can represent the specific structure, behavior or function of the system. The components can be provided with various interfaces, each interface is represented by different graphic symbols, complex interaction can be carried out between the components, and several common components can be matched for use, and a connecting structure with a fixed mode is generated between the components to form a larger component, so that a common component model can be stored. In building a system, it does not start with the smallest component, but rather starts with some sub-model already on a scale. When automatically generating codes based on the SysML model, the code generation efficiency and reusability are ensured by directly taking the components as granularity and utilizing the reusable codes related to the modeling components in the component library instead of starting from the minimum unit.
Preferably, the description file of the component in the embodiment is represented by an XML format file conforming to the XMI standard, so that a plurality of SysML modeling tools can conveniently exchange SysML component models, and exchange and integrate the models. The component management and development steps in this embodiment include two steps of component definition and component management:
and step three, defining the components. Component definition realizes component attribute, interface information of component, dependency relationship of component, applicable position, entering and exiting condition, definition of basic framework information description required by component, and generates component description item. There are three ways to implement the definition of the components: the component definition may be performed using a combination of one or more of meta-object mechanism definition (MOF), by creating a finished SysML model definition, and by component repository definition.
First, utilizing meta-object Mechanism (MOF) definition refers to designing a meta-model component with MOF as a specification. The MOF method provides an extensible metadata management approach that provides a framework to support various metadata, allowing new types of metadata to be added on demand, by layering the metadata. The component definition process takes an instance of a meta-model directly as a component, or takes an instance of an extended meta-model stereotype indirectly as a component;
second, by building a finished SysML model definition component is meant that when a SysML model in the system is created, the newly defined component can be configured to contain which specific modeling modules in the system. The defined assembly only contains the information of the selected module in the system, and when the target language code is generated, only the target language code corresponding to the SysML module in the contained range is generated.
Third, defining components by component repository refers to importing components directly from an existing component repository and may be modified based on the imported components to define specific components desired by the user. The component warehouse can be a cloud component database realized by different manufacturers, and can also be a component pool stored locally by a computer. Preferably, the component warehouse of the embodiment accords with a general warehouse meta-model standard (CWM), and the general warehouse meta-model standard is a standard for describing and exchanging data warehouse and business intelligent metadata, so that metadata sharing and exchanging between each data warehouse and business intelligent tools can be realized, thereby improving the development efficiency of the data warehouse and reducing the integration cost.
And step three, performing component management. Component management inserts component description items into component description files and builds primitive symbols for the components in the system to support graphical modeling of the SysML model. In order to support automatic code generation, the component manages not only the self description information of the component, but also the generation information of the target language code corresponding to the component, and prepares the high-efficiency code corresponding to the component module in advance before the automatic code generation action of the SysML model. The high-efficiency code is a code which can reduce the resource consumption of running time, memory occupation, energy consumption and the like as much as possible while meeting the functional requirement, and has the characteristics of low redundancy and meeting the industry coding standard. The plurality of component description information and the code information automatically generated by the components form a component library, and a header file and an input file are directly provided for the code automatic generation process.
Specifically, the information of the target language code corresponding to the component in the third step is obtained by the following aspects: if the component is defined by the established SysML model and the model has undergone the process of automatically generating target language codes, the component adopts the previously generated result target language codes as pre-generated target language codes; if the component is directly imported and used by a component warehouse (a public component warehouse and a local component warehouse), and the component warehouse marks the automatic generation information of the target language code accompanied by the component when imported, the code information carried by the component is directly used as the target language code of the component; in addition, in order to realize that the components have predefined target language code information, the component management calls a code automatic generation method based on the SysML model, and all components utilized in the established SysML model are guaranteed to contain the target language code information. In particular, the process of calling for automatic generation of code is a recursive process until the solution model contains no components other than itself, without the generated object language code information.
And fourthly, constructing a normalized code mapping template.
In this step, the code specification in the industry is analyzed according to the code specification standard related to the industry. And then combining the characteristics of each model element of the SysML and the grammar rules of the target language to determine the mapping relation between the SysML model elements and the target language code elements, and constructing a safe and efficient target language code mapping template.
Preferably, the specifications of the software programming referred to in the present embodiment include the GJB/Z102A-2012 standard and the GJB5369-2005 standard. The software programming specifications in the GJB/Z102A-2012 include programming language generic requirements, software complexity control, annotation requirements and methods, pointer usage, etc.; the GJB5369-2005 standard specifies a C language security subset, and specifies the programming specification that the space embedded software code should follow from 15 aspects of declarative definition class, layout writing class, branch control class, pointer use class, jump control class, operation processing class, procedure call class, statement use class, call return class, program annotation class, loop control class, type conversion class, initialization class, comparison judgment class, and name, symbol and variable use class, the code conforming to the C language security subset is generally considered to be a highly reliable, efficient, maintainable standard code.
It should be noted that, according to different target languages, the software programming specifications of the selected references are also different, and the code language specification needs to be flexibly selected, so as to ensure that the target code is efficient, safe and effective.
And fifthly, automatically generating the layering codes to generate final target language codes.
The input of the step comprises the model conversion and analysis content in the step two, the component management and development information in the step three and the constructed normalized code mapping template content in the step four. The method comprises the steps of analyzing a system layer to obtain all module information and connection information, then performing deep analysis from the system layer to a specific bottom layer, supplementing the specific module information, combining object codes carried by components with frame codes and unit codes, and finally generating object language codes.
Step five, generating the overall framework code of the program. And analyzing the nested hierarchical relationship of each model element in the SysML, deeply analyzing layer by layer, and generating a data structure and a method or a function interface by using a code mapping template according to the packet diagram, the module definition diagram, the internal module diagram, the parameter diagram, the state diagram and the time sequence diagram information. Preferably, generating an event response function and an event distribution function according to the state diagram; and establishing tasks and synchronous relations thereof according to the activity diagrams, obtaining branch logic variables and conversion conditions and behaviors between states according to a state model of each task, and establishing entry and exit relations between the branch logic variables and the states to form a program overall frame code.
And fifthly, generating program unit codes. And developing and analyzing layer by layer according to the nested hierarchical relationship of the SysML model, and generating the realization codes of each function by using a code mapping template according to the calling sequence relationship information among each view and each model element.
And fifthly, generating code fusion and generating target language codes. The codes are combined according to the component library description file in combination with the overall program framework code and the program unit code to generate final target language codes, and the codes are provided in an ANSIC form.
Furthermore, it should be understood that although the present disclosure describes embodiments, not every embodiment is provided with a separate embodiment, and that this description is provided for clarity only, and that the disclosure is not limited to the embodiments described in detail below, and that the embodiments described in the examples may be combined as appropriate to form other embodiments that will be apparent to those skilled in the art.

Claims (10)

1. The automatic code generation method based on the SysML model is characterized by comprising the following steps of:
step one, performing multi-level model verification on the established SysML model according to the SysML specification to ensure that the SysML model is legal and effective;
step two, converting and analyzing the SysML model according to the established model content file and combining various views of the model;
step three, defining and managing components;
step four, constructing a normalized code mapping template;
and fifthly, automatically generating the layering codes to generate final target language codes.
2. The automatic code generation method based on the SysML model according to claim 1, wherein: the model verification of the first step is carried out based on seven views of a package diagram, a module definition diagram, an internal module diagram, a parameter diagram, a time sequence diagram, an activity diagram and a state machine diagram in the SysML model, and the verification content comprises model self-verification consistency and phase consistency.
3. The automatic code generation method based on the SysML model according to claim 1, wherein: in the second step, the model content file comprises a SysML model modeling element content file and a SysML model view content file.
4. The automatic code generation method based on the SysML model according to claim 1, wherein the specific steps of the second step are as follows:
step two, performing hierarchical analysis on a SysML model structure diagram to obtain hierarchical structure relations among model modeling elements;
step two, performing SysML model activity diagram synchronization processing, and analyzing activity diagram nodes contained in the activity diagram and connection relations among the nodes;
step two, performing the process of the SysML model state machine diagram, analyzing the states of the modules represented by the state machine diagram, and performing possible conversion among the states when responding to the event;
and step two, performing flow processing of a SysML model time sequence diagram, analyzing a message interaction sequence among all components of a module represented in the time sequence diagram, and how all components interact through operation calling and asynchronous signals.
5. The automatic code generating method based on the SysML model according to claim 1, wherein the components in the third step refer to packaged, abstract, reusable and replaceable units which can be used in different software systems in the modeling process of the model system, and the components can be directly used as granularity in the code generating process.
6. The automatic code generation method based on the SysML model according to claim 1, wherein the specific steps of the third step are as follows:
step three, component definition: the method comprises the steps of realizing definition of component attributes, interface information of components, dependency relationship of the components, applicable positions, entering and exiting conditions and basic framework information required by the components, and generating component description items;
step three, component management: the component description items are inserted into the component description files, primitive symbols of the components are built in the system to support graphical modeling of the SysML model, the component management not only manages self description information of the components, but also manages generation information of target language codes corresponding to the components, high-efficiency codes corresponding to the component modules are prepared in advance before the codes of the SysML model are automatically generated, and the high-efficiency codes are directly combined and pasted in the code generation process.
7. The automatic code generation method based on the SysML model according to claim 6, wherein the specific manner of component definition comprises a combination of one or more of A1, A2 and A3, wherein,
a1, defining a component by utilizing a meta-object mechanism MOF: the MOF is taken as a specification to design a meta-model component, and the component definition process takes an instance of a meta-model directly as a component or takes an instance of an extended meta-model stereotype indirectly as a component;
a2, defining a component by utilizing a SysML model created before: after the SysML model is created, configuring a specific modeling module contained in a defined component, wherein the component contains information of a selected module in the system, and only generates a corresponding target language code of the SysML module in a contained range;
a3, defining components through a component warehouse: the components are directly imported from the existing component warehouse for use, the components can be modified on the basis of the imported components, the specific components required by the user are defined, and the component warehouse can be stored in the cloud or local.
8. The automatic code generation method based on the SysML model according to claim 7, wherein the source of the generated information of the target language code corresponding to the component comprises:
b1, if the component is defined by the established SysML model and the model has undergone the process of automatically generating target language codes, the component adopts the target language codes of the results of the previous generation process as pre-generated target language codes;
b2, if the component is directly imported and used by the component warehouse, and the component warehouse marks the automatic generation information of the target language code accompanied by the component when imported, the information is used as the target language generation code of the component;
and B3, except the two cases, the component management calls a code automatic generation method based on the SysML model, so that all components utilized in the established SysML model are guaranteed to contain target language code information, and the process of calling the code automatic generation is a recursive process until the solved model does not contain components except the solved model and without the generated target language code information, so that the predefined component target language code is obtained.
9. The automatic code generation method based on the SysML model according to claim 1, wherein the specific flow of the normalized code mapping template construction in the fourth step is: firstly, according to the code specification standard related in the industry, analyzing the code specification in the industry, and then combining the characteristics of each SysML model element and the grammar rule of the target language to determine the mapping relation between the SysML model element and the target language code element, so as to construct a safe and efficient target language code mapping template.
10. The automatic code generation method based on the sys ml model according to claim 1, wherein the step five of performing the input of the hierarchical code automatic generation stage includes: the model converts and analyzes the content, the component information and the code mapping template information, and the steps comprise:
step five, generating overall frame codes of the program: analyzing the nested hierarchical relationship of each model element in the SysML, deeply analyzing layer by layer, and generating a data structure and a method or a function interface by using a code mapping template according to each view information of the SysML model to form a program overall frame code;
step five, generating program unit codes: according to the nested hierarchical relationship layer-by-layer unfolding analysis of the SysML model, according to the contents of calling sequence relationships among various views and model elements, generating implementation codes of various functions by using a code mapping template;
fifthly, code fusion is generated, and target language codes are generated: and combining codes according to the component library description file and combining the overall program framework codes and the program unit codes to generate target language codes.
CN202310902130.3A 2023-07-21 2023-07-21 Automatic code generation method based on SysML model Pending CN116909544A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310902130.3A CN116909544A (en) 2023-07-21 2023-07-21 Automatic code generation method based on SysML model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310902130.3A CN116909544A (en) 2023-07-21 2023-07-21 Automatic code generation method based on SysML model

Publications (1)

Publication Number Publication Date
CN116909544A true CN116909544A (en) 2023-10-20

Family

ID=88356246

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310902130.3A Pending CN116909544A (en) 2023-07-21 2023-07-21 Automatic code generation method based on SysML model

Country Status (1)

Country Link
CN (1) CN116909544A (en)

Similar Documents

Publication Publication Date Title
CN107273117B (en) Programming-friendly agile code automatic generation system
CN107291450B (en) Programming-friendly agile code automatic generation method
CN101777004B (en) Method and system for realizing BPEL sub-process multiplexing based on template in service-oriented environment
CN104360859B (en) A kind of visual service development method and system
Pescador et al. Pattern-based development of domain-specific modelling languages
EP3163436A1 (en) Visual software modeling method based on software meta-view for constructing software view
US20050108684A1 (en) Method and system for generating an application object repository from application framework metadata
Wang et al. An automatic model-to-model mapping and transformation methodology to serve model-based systems engineering
Jézéquel Model‐Driven Engineering for Software Product Lines
CN113626026B (en) Code generation method supporting complex model structure conversion
CN117492723A (en) Automatic industrial software code generation method based on data and behavior model
CN117648833B (en) Simulink-to-SysML model generation method and device
Fraternali et al. Multi-level tests for model driven web applications
Bicevskis et al. Practitioners view on domain specific business process modeling
CN116909544A (en) Automatic code generation method based on SysML model
Malavolta Software Architecture Modeling by Reuse, Composition and Customization
Nikolaidou et al. Enterprise information system engineering: A model-based approach based on the zachman framework
Stanev et al. Method for information systems automated programming
Crelier et al. Design principles for integration of model-driven quality assurance tools
Quinton Cloud Environment Selection and Configuration: A Software Product Lines-Based Approach
Chen et al. Navigation Flow Modeling as a Basis for the Automatic Generation of Android APPs.
Nagl An Integrative Architecture Language Approach
Rath et al. Declarative specification of domain specific visual languages
Stanev et al. Architecture knowledge for software generation
Kulkarni D3. 1.1. Requirement-product-process ontology

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination