XML-based Lustre code online generation tool design method

By designing an online Lustre code generation tool based on XML, the OnModel tool's difficulty and low efficiency in generating Lustre code when processing XML files is solved, real-time code generation and functional improvement are achieved, and model processing efficiency and performance are improved.

CN118916012AActive Publication Date: 2024-11-08BEIJING INST OF COMP TECH & APPL

Patent Information

Application Number
CN202411231578.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-11-08
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

In model-driven system engineering, when OnModel tool faces persistent XML files in different formats, Lustre code generation is difficult and response is not timely enough, resulting in the tool's functions are not flexible enough when dealing with huge and complex models and low running efficiency.

Method used

Design an online Lustre code generation tool based on XML. By constructing an XML-based syntax parser, it is divided into four functional modules: controller, service, transform and util, providing different interfaces to process XML files, and deploying them in the form of microservices. , generate Lustre code in real time to return to the front end in json format.

Benefits of technology

Implement the parsing of the persistent XML file of the OnModel tool and the generation of Lustre code, which improves the code generation efficiency and supports the improvement of tool functions and performance optimization, especially when facing complex models, avoiding the time overhead caused by plug-in calls, and reducing Memory load.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916012A_ABST
    Figure CN118916012A_ABST
Patent Text Reader

Abstract

The invention relates to an XML-based Lustre code online generation tool design method, and belongs to the field of code online generation. The method comprises the following steps: firstly, analyzing a Lustre grammar rule, carrying out relation mapping on the Lustre grammar rule and a label in an XML file, and constructing an XML-based grammar analyzer by calling a jdom2 library; functional modules of the tool are divided according to Lustre grammar rules, architecture design is carried out based on a SpringBoot framework, and interfaces are divided according to different functions; a data interaction format mode with a front-end tool is defined, the data interaction format mode comprises a port, a request mode, input and output, a file format and the like, it is guaranteed that a request submitted to a rear end is responded timely and correctly, and a corresponding Lustre code is generated. According to the method, the development work of the XML-based Lustre code online generation tool Xml2Lustre can be completed, support is provided for the realization of OnModel tool functions, and the performance is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of online code generation, and in particular relates to a design method for an XML-based Lustre online code generation tool. Background Art

[0002] Model-Based Systems Engineering (MBSE) is a system engineering method that uses models rather than documents as core artifacts throughout the entire life cycle of system development. Compared with traditional software development methods, it can effectively solve problems such as information islands, consistency issues, poor traceability, and low development efficiency. At the same time, with the increase in system complexity, especially in the fields of aerospace, automobiles, defense, and medical care, the advantages of MBSE are gradually emerging.

[0003] With the improvement of my country's independent research and development capabilities for industrial software, benchmarking tools in the MBSE field are also developing rapidly. Among them, OnModel, as a model-based detailed design tool independently developed by our unit, has expanded Lustre as a model language and has realized a basic tool chain from visual modeling to code generation. Lustre code generation is a key link in the entire tool chain. In the actual modeling process, when facing persistent files (XML files) of different formats, there are still difficulties in Lustre code generation and the response is not timely. As a result, when facing large and complex models, the tool has problems such as insufficient flexibility and completeness of functions and runtime jams.

[0004] Aiming at the functional requirements of the OnModel tool in actual use scenarios, the present invention deploys it in a microservice mode based on SpringBoot, provides different interfaces to process XML files of different formats, generates Lustre code online in real time, and returns it to the front-end modeling tool in json format for visual display. It realizes the real-time code generation of types, variables, equations and other data types in the actual use of the OnModel tool, enriches its modeling functions and improves its operating efficiency, and on this basis realizes the improvement and optimization of the OnModel tool functions. Summary of the invention

[0005] 1. Technical issues to be resolved

[0006] The technical problem to be solved by the present invention is how to provide a design method for an XML-based Lustre code online generation tool to solve the problem of the OnModel tool in the key step of model code Lustre generation.

[0007] (II) Technical solution

[0008] In order to solve the above technical problems, the present invention proposes a design method for an XML-based Lustre code online generation tool, which includes the following steps:

[0009] Step 1: Construct an XML-based parser

[0010] According to the persistent XML file format, combined with Lustre grammar rules and binding keywords and XML tags, XML-based parsing rules are formulated, and an XML-based grammar parser is constructed to realize the translation process from XML content to Lustre code;

[0011] Step 2: Divide the functional modules according to actual functional requirements and provide different interfaces to the outside world

[0012] The Xml2Lustre tool is divided into four functional modules: controller, service, transform and util.

[0013] The controller module is responsible for providing interfaces with different functions. The front-end modeling platform calls different interfaces according to the content of the XML file to be converted, thereby generating the required Lustre code.

[0014] The service module handles the actual business logic and processes the request after receiving the request from the controller module;

[0015] The transform module is a conversion module that provides conversion of different Lustre syntaxes and code generation;

[0016] The util module provides auxiliary functions for indentation and string formatting during code generation;

[0017] Step 3: Formulate interaction rules and data formats with the front-end modeling platform

[0018] The Xml2Lustre tool is deployed in the form of microservices. The front-end modeling platform sends a post request to send the XML data to be converted to the corresponding functional interface in the format of file path or file content. After generating the corresponding Lustre code in real time, it is returned to the front-end modeling platform in the json data format for display.

[0019] (III) Beneficial effects

[0020] The present invention proposes a design method for an XML-based Lustre code online generation tool. The present invention proposes an XML-based Lustre code online generation method and completes the development of the Xml2Lustre tool. The effect is as follows: Figure 5As shown, the tool has the following main features:

[0021] (1) By parsing the content of the XML file and binding it with the keywords in the Lustre grammar rules, the persistent XML file of the OnModel tool can be parsed and the corresponding Lustre code can be generated to support the improvement of the subsequent functions and performance optimization of the OnModel tool.

[0022] (2) Provide different Lustre code generation strategies based on the actual functional requirements of the OnModel tool during use, especially in the process of implementing the compatible benchmarking tool Scade, which involves batch definition of types, batch reading of equations, and other situations that require batch processing of XML fragments. The Lustre code generation strategies provided in this tool (TypeList2LustreController, EquationList2LustreController and other interfaces) can effectively solve these problems.

[0023] (3) Deployment based on microservices. Compared with the interactive method of calling plug-ins, the service-based interactive method can avoid the time overhead of calling plug-ins each time, especially when facing complex and large modeling tasks, effectively improving code generation efficiency and reducing the memory overhead of the tool. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 This is a flowchart of the operation of the Xml2Lustre tool of the present invention;

[0025] Figure 2 This is a schematic diagram of the analysis results;

[0026] Figure 3 It is a schematic diagram of the calling relationship of each module;

[0027] Figure 4 This is a test diagram using the interface testing tool PostMan;

[0028] Figure 5 This is the effect diagram of the Xml2Lustre tool. DETAILED DESCRIPTION

[0029] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.

[0030] In view of the actual functions and performance requirements of OnModel, a model-based software analysis, design and verification tool developed by our unit, users need to generate corresponding Lustre codes according to different forms of XML data during the modeling process, and realize the construction of the model and subsequent functions on this basis. The present invention can generate corresponding Lustre codes in real time according to different requests from the visual modeling front end and perform visual display, ensuring the efficiency of code generation while providing more complete functions, and providing support for the realization of subsequent functions of the OnModel tool.

[0031] The present invention provides a design method for an XML-based online Lustre code generation tool Xml2Lustre. The tool can generate Lustre code including objects such as function blocks, expressions, type definitions and numerical values, ensure the smooth development and implementation of subsequent functional modules such as static analysis, code generation, and data association and definition, and provide strong support for OnModel, a model-based software analysis, design and verification tool with high security and high reliability. First, the Lustre grammar rules are parsed and mapped with the tags in the XML file, and an XML-based grammar parser is constructed by calling the jdom2 library; the functional modules of the tool are divided according to the Lustre grammar rules, and the architecture is designed based on the Spring Boot framework, and the interface is divided according to the different functions; the data interaction format with the front-end tool is defined, including the port, request mode, input and output, and file format, etc., to ensure timely and correct response to the request submitted to the back end, and generate the corresponding Lustre code. The present invention can complete the development of the XML-based online Lustre code generation tool Xml2Lustre, provide support for the realization of the OnModel tool function and optimize the performance.

[0032] The purpose of the present invention is to solve the problem of Lustre generation, a key step of model code, for OnModel, a self-developed tool of our unit in the field of MBSE, so as to realize real-time generation of corresponding Lustre code when facing different persistent XML files, and to display it on the front end. The present invention provides a design method of an XML-based Lustre code online generation tool, which is an Xml2Lustre tool, and the method comprises:

[0033] Step 1: Construct an XML-based parser

[0034] According to the persistent XML file format involved in the actual modeling process of the OnModel tool, including complete functions, equations, types and other data content that need to be converted, combined with Lustre grammar rules and binding keywords and XML tags, XML-based parsing rules are formulated, and an XML-based syntax parser is constructed to realize the translation process from XML content to Lustre code.

[0035] Step 2: Divide the functional modules according to actual functional requirements and provide different interfaces to the outside world

[0036] Based on the syntax parser built in the first step and the actual functional requirements of the OnModel tool, the Xml2Lustre tool is divided into four functional modules, namely controller, service, transform and util.

[0037] The controller module is responsible for providing interfaces with different functions. The front-end modeling platform calls different interfaces according to the content of the XML file to be converted, thereby generating the required Lustre code.

[0038] The service module handles the actual business logic and processes the request after receiving the request from the controller module;

[0039] The transform module is a conversion module that provides conversion of different Lustre syntaxes and code generation;

[0040] The util module provides auxiliary functions such as indentation and string formatting during code generation.

[0041] Step 3: Formulate interaction rules and data formats with the front-end modeling platform

[0042] The Xml2Lustre tool is deployed in the form of microservices. The front-end modeling platform sends a post request to send the XML data to be converted to the corresponding functional interface in the format of file path or file content. After generating the corresponding Lustre code in real time, it is returned to the front-end modeling platform in the json data format for display.

[0043] Embodiment 1:

[0044] The Xml2Lustre tool operation process is as follows Figure 1 As shown, the specific implementation steps are:

[0045] The first step is to construct an XML-based grammar parser

[0046] Considering that Lustre grammar rules are expressed in Backus-Naur form, the present invention first formulates parsing rules for XML tags using Backus-Naur form of Lustre grammar during the construction of XML grammar parser, extracts key tags in XML and maps and binds them with Lustre keywords, where some keyword mapping rules are as follows:

[0047] 1. Program and Declaration (Decls) Structure

[0048]

[0049] 2. Function (Operator) internal structure

[0050]

[0051]

[0052] 3. TypeBlock definition

[0053]

[0054]

[0055] Based on this rule, the XML content can be parsed and the corresponding Lustre code can be automatically generated in real time. The parsing results are as follows: Figure 2 shown.

[0056] The second step is to divide the functional modules according to the actual functional requirements and provide different interfaces to the outside world

[0057] During the construction of the Xml2Lustre tool, it is divided into four modules: controller, service, transform, and util from the functional logic level. The calling relationship of each module is as follows: Figure 3 As shown, where:

[0058] 1. Controller module

[0059] This module provides an interface to the outside world, and the front-end modeling platform interacts with data through this interface. The present invention provides four interfaces: EquationList2LustreController, ExpressionList2LustreController, File2LustreController, and TypeList2LustreController, which respectively realize the functions of batch generation of equations, batch generation of expressions, generation of complete functions, and batch generation of type definitions.

[0060] 2. Service module

[0061] This module is the business logic processing module of the controller module, including: EquationList2LustreService, ExpressionList2LustreService, File2LustreService, TypeList2LustreService, which respectively realize the processing of batch generation of equations, batch generation of expressions, generation of complete functions, and batch generation of type definitions. The controller implements the corresponding specific functions in each interface by calling the service module. The pseudo code of some implementation processes is as follows. TypeList2LustreService processes predefined types, array types, enumeration types, and structure types respectively:

[0062]

[0063]

[0064] 3. Transform module

[0065] Based on the XML parsing rules in the first step, this module defines the key modules involved in Lustre, including Program, Operator, TypeBlock, etc., and formulates specific parsing rules for the syntax of each key module. It is responsible for the specific implementation of the mapping rules designed in the first step. Some of its pseudo codes are as follows:

[0066]

[0067]

[0068] 4. Util module

[0069] This module is responsible for providing tool functions such as file processing, code indentation, namespace, symbol priority, etc. to optimize the Lustre code generation process.

[0070] The third step is to formulate interaction rules and data formats with the front-end modeling platform

[0071] The Xml2Lustre tool runs as a microservice on the local port 8057 (http: / / 127.0.0.1:8057 / xxxx). The front-end modeling platform generates the corresponding Lustre code in real time by sending an http request, which includes the interface name and data field of the controller module, including the corresponding interface information and XML data. The code is encapsulated in json format and returned to the front-end modeling platform in json format for parsing. Finally, the parsed content is rendered and displayed, completing the online generation process of the entire Lustre code. Figure 4 As shown, the tool of the present invention is tested by the interface testing tool PostMan.

[0072] Embodiment 2:

[0073] The implementation of Xml2Lustre is mainly based on the following steps:

[0074] The first step is to build an XML-based parser, parse the tags in the XML file through the jdom2 tool, and implement the mapping and binding between tags and Lustre code keywords in combination with Lustre grammar rules, and define corresponding error messages for abnormal situations.

[0075] The second step is to divide the functional modules in the present invention according to the actual functions required by the OnModel tool and the Lustre grammar rules, and provide different interfaces to the outside to handle different Lustre code generation requests;

[0076] The third step is to limit the data interaction format and impose constraints on the operation port, request method, input and output file formats, etc., considering that this tool needs to interact with the front-end modeling platform. Through the above three steps, this tool can be deployed in the form of microservices. When users are modeling through OnModel, OnModel sends different types of XML data by calling different interfaces. After receiving the request, this tool generates the corresponding Lustre code online to provide support for the function implementation of the OnModel tool.

[0077] Technical effects of the present invention:

[0078] The present invention proposes an XML-based Lustre code online generation method and completes the development of the Xml2Lustre tool, which has the following effects: Figure 5 As shown, the tool has the following main features:

[0079] (1) By parsing the content of the XML file and binding it with the keywords in the Lustre grammar rules, the persistent XML file of the OnModel tool can be parsed and the corresponding Lustre code can be generated to support the improvement of the subsequent functions and performance optimization of the OnModel tool.

[0080] (2) Provide different Lustre code generation strategies based on the actual functional requirements of the OnModel tool during use, especially in the process of implementing the compatible benchmarking tool Scade, which involves batch definition of types, batch reading of equations, and other situations that require batch processing of XML fragments. The Lustre code generation strategies provided in this tool (TypeList2LustreController, EquationList2LustreController and other interfaces) can effectively solve these problems.

[0081] (3) Deployment based on microservices. Compared with the interactive method of calling plug-ins, the service-based interactive method can avoid the time overhead of calling plug-ins each time, especially when facing complex and large modeling tasks, effectively improving code generation efficiency and reducing the memory overhead of the tool.

[0082] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A design method for an XML-based Lustre code online generation tool, characterized in that: The method comprises the following steps: Step 1: Construct an XML-based parser According to the persistent XML file format, combined with Lustre grammar rules and binding keywords and XML tags, XML-based parsing rules are formulated, and an XML-based grammar parser is constructed to realize the translation process from XML content to Lustre code; Step 2: Divide the functional modules according to actual functional requirements and provide different interfaces to the outside world The Xml2Lustre tool is divided into four functional modules: controller, service, transform and util. The controller module is responsible for providing interfaces with different functions. The front-end modeling platform calls different interfaces according to the content of the XML file to be converted, thereby generating the required Lustre code. The service module handles the actual business logic and processes the request after receiving the request from the controller module; The transform module is a conversion module that provides conversion of different Lustre syntaxes and code generation; The util module provides auxiliary functions for indentation and string formatting during code generation; Step 3: Formulate interaction rules and data formats with the front-end modeling platform The Xml2Lustre tool is deployed in the form of microservices. The front-end modeling platform sends the XML data to be converted to the corresponding functional interface in the format of file path or file content by sending a post request. After generating the corresponding Lustre code in real time, it is returned to the front-end modeling platform in the json data format for display.

2. The XML-based Lustre code online generation tool design method according to claim 1, characterized in that: The binding rules in the first step include: Program and Decls binding rules, Operator binding rules, and TypeBlock binding rules.

3. The XML-based Lustre code online generation tool design method according to claim 2, characterized in that: In the first step, Lustre grammar rules are expressed in Backus-Naur Form. In the process of constructing an XML grammar parser, the Backus-Naur Form of Lustre grammar is used to formulate parsing rules for XML tags, and key tags in XML are extracted and mapped and bound with Lustre keywords.

4. The XML-based Lustre code online generation tool design method according to claim 1, characterized in that: The controller module provides an interface to the outside world, through which the front-end modeling platform interacts with data. The provided interfaces include: EquationList2LustreController, ExpressionList2LustreController, File2LustreController, and TypeList2LustreController, which respectively implement the functions of batch generation of equations, batch generation of expressions, generation of complete functions, and batch generation of type definitions.

5. The XML-based Lustre code online generation tool design method according to claim 4, characterized in that: The service module is the business logic processing module of the controller module, including: EquationList2LustreService, ExpressionList2LustreService, File2LustreService, and TypeList2LustreService, which respectively implement the processing of batch generation of equations, batch generation of expressions, generation of complete functions, and batch generation of type definitions. The controller implements the corresponding specific functions in each interface by calling the service module.

6. The XML-based Lustre code online generation tool design method according to claim 5, characterized in that: TypeList2LustreService processes predefined types, array types, enumeration types, and structure types separately.

7. The XML-based Lustre code online generation tool design method according to claim 5, characterized in that: Based on the parsing rules of XML in the first step, the transform module defines the Program, Operator, and TypeBlock key modules involved in Lustre, and formulates specific parsing rules for the syntax of each key module, and is responsible for the specific implementation of the mapping rules designed in the first step.

8. The XML-based Lustre code online generation tool design method according to claim 7, characterized in that: The util module is responsible for providing file processing, code indentation, namespace, and symbol priority functions to optimize the Lustre code generation process.

9. The method for designing an XML-based Lustre online code generation tool according to any one of claims 1 to 8, characterized in that: The Xml2Lustre tool runs on the local machine in the form of a microservice. The front-end modeling platform generates the corresponding Lustre code in real time by sending an http request, which includes the interface name and data field of the controller module, including the corresponding interface information and XML data. The code is encapsulated in json format and returned to the front-end modeling platform in json format for parsing. Finally, the parsed content is rendered and displayed, completing the online generation process of the entire Lustre code.

10. The XML-based Lustre code online generation tool design method according to claim 9, characterized in that: The Xml2Lustre tool runs as a microservice on port 8057 of the local machine.

Citation Information

Patent Citations

  • Method and device for deploying Lustre file system and client

    CN106502742A

  • Method and device for generic function conversion in process of converting SCADE model into Lustre model

    CN115221465A

  • Model-based visual software development tool implementation method

    CN115964033A

  • Extensible Lustre code generation method based on XML

    CN116126304A

  • Model formalized verification method based on extended Lustre language

    CN116150005A

Cited By

  • Embedded human-computer interface code generation method based on OpenGL

    CN120029620A

  • Method for generating embedded man-machine interface code based on OpenGL

    CN120029620B