Design Method of Lustre Code Online Generation Tool Based on XML

By constructing an online Lustre code generation tool based on an XML-based syntax parser and microservice deployment, the difficulties faced by the OnModel tool in generating Lustre code were resolved, efficient and flexible code generation and functional improvement were achieved, and the tool's operating efficiency and memory management were improved.

CN118916012BActive Publication Date: 2025-09-26BEIJING INST OF COMP TECH & APPL
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

When generating Lustre code, existing OnModel tools face generation difficulties, untimely responses, and insufficient flexibility and functionality when faced with persistent XML files of different formats. This can cause tool runtime lags, especially when dealing with complex and large modeling tasks.

Method used

An XML-based online Lustre code generation tool is designed. By constructing an XML-based syntax parser, it is divided into four functional modules: controller, service, transform, and util. It is deployed as a microservice, provides different interfaces for processing XML files, generates Lustre code in real time, and returns it in JSON format for front-end display.

Benefits of technology

It achieves efficient parsing of the OnModel tool's persistent XML files and real-time generation of Lustre code, improving code generation efficiency, reducing memory overhead, meeting the needs of complex modeling tasks, and improving tool functionality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916012B_ABST
    Figure CN118916012B_ABST
Patent Text Reader

Abstract

The present invention relates to a design method for an XML-based online Lustre code generation tool, belonging to the field of online code generation. The present invention first parses Lustre grammar rules and performs relationship mapping with tags in XML files, then constructs an XML-based grammar parser by calling the jdom2 library. The tool's functional modules are divided according to Lustre grammar rules, and the architecture is designed based on the SpringBoot framework, with interfaces divided according to different functions. The data interaction format with the front-end tool is defined, including ports, request methods, input and output, and file formats, to ensure timely and correct responses to requests submitted to the back-end and generate corresponding Lustre code. The present invention can complete the development of Xml2Lustre, an XML-based online Lustre code generation tool, providing support for the implementation of OnModel tool functions and optimizing performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present 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), a systems engineering approach, utilizes models, rather than documents, as core artifacts throughout the entire system development lifecycle. Compared to traditional software development methods, it effectively addresses issues such as information silos, consistency issues, poor traceability, and low development efficiency. Furthermore, with increasing system complexity, MBSE's advantages are becoming increasingly apparent, particularly in sectors such as aerospace, automotive, defense, and healthcare.

[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, 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. However, in the actual modeling process, when faced with persistent files (XML files) of different formats, there are still difficulties in Lustre code generation and the response is not timely enough. As a result, the tool has problems such as insufficient flexibility and completeness of functions and runtime lag when facing large and complex models.

[0004] This invention targets the functional requirements of the OnModel tool in actual usage scenarios, deploys it in a microservices manner 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. This realizes the real-time code generation of types, variables, equations and other data types during 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 Lustre model code generation.

[0007] (2) Technical solution

[0008] 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] Based on the persistent XML file format, combined with Lustre grammar rules and binding keywords and XML tags, we formulate XML-based parsing rules and construct an XML-based grammar parser to achieve the translation process from XML content to Lustre code.

[0011] Step 2: Divide 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 based on 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 it from the controller module;

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

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

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

[0018] The Xml2Lustre tool is deployed as a microservice. The front-end modeling platform sends a post request to the XML data to be converted in the format of file path or file content to the corresponding functional interface. 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] (3) 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. Its 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 implementation of the Scade function compatible with the benchmarking tool, 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 situations.

[0023] (3) Deployment based on microservices. Compared with the interaction method of calling plug-ins, the service-based interaction method can avoid the time overhead caused by each plug-in call, 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 the flowchart of the Xml2Lustre tool operation of the present invention;

[0025] Figure 2 Schematic diagram of the analysis results;

[0026] Figure 3 A diagram showing the calling relationship between modules;

[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 with reference to the accompanying drawings and examples.

[0030] To meet the practical functional and performance requirements of OnModel, our in-house developed model-based software analysis, design, and verification tool, users must generate corresponding Lustre code from various forms of XML data during the modeling process, thereby enabling model construction and subsequent functionality. This paper implements Xml2Lustre, an XML-based online Lustre code generation tool. This tool can instantly generate corresponding Lustre code based on different requests from the visual modeling front-end and present it visually. This ensures efficient code generation while providing more comprehensive functionality, supporting the implementation of the OnModel tool's subsequent functionality.

[0031] The present invention provides a design method for an XML-based online Lustre code generation tool, Xml2Lustre. This tool can generate Lustre code including objects such as function blocks, expressions, type definitions, and numerical values, ensuring the smooth development and implementation of subsequent functional modules such as static analysis, code generation, and data association and definition, and providing strong support for OnModel, a highly secure and reliable model-based software analysis, design, and verification tool. First, Lustre grammar rules are parsed and mapped to tags in XML files. An XML-based syntax parser is constructed by calling the jdom2 library. The tool's functional modules are divided according to Lustre grammar rules, and the architecture is designed based on the Spring Boot framework, with interfaces divided according to different functions. The data interaction format with the front-end tool is defined, including ports, request methods, input and output, and file formats, ensuring timely and correct responses to requests submitted to the back-end, and generating corresponding Lustre code. The present invention can complete the development of the XML-based online Lustre code generation tool, Xml2Lustre, providing support for the implementation of the OnModel tool's functions and optimizing performance.

[0032] The purpose of this invention is to solve the key problem of Lustre model code generation for OnModel, a tool developed by our company in the MBSE field. This allows real-time generation of corresponding Lustre code for different persistent XML files and displays it on the front end. This invention provides a design method for an XML-based online Lustre code generation tool, the Xml2Lustre tool, which includes:

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

[0034] Based on 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 needs 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 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: 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 based on 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 it from the controller module;

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

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

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

[0042] The Xml2Lustre tool is deployed as a microservice. The front-end modeling platform sends a post request to the XML data to be converted in the format of file path or file content to the corresponding functional interface. 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] Example 1:

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

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

[0046] Considering that Lustre grammar rules are expressed in Backus-Naur Form, during the construction of the XML parser, the present invention first formulates parsing rules for XML tags using the Backus-Naur Form of the Lustre grammar, extracts key tags from the XML, and maps and binds them to Lustre keywords. Some of the 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 between these modules 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, and TypeList2LustreService, which respectively implement the 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 part of the implementation process 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 key modules involved in Lustre, including Program, Operator, and TypeBlock. It also formulates specific parsing rules based on the syntax of each key module and is responsible for implementing the mapping rules designed in the first step. Some of its pseudo code is 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 port 8057 of the local machine (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] Example 2:

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

[0074] The first step is to build an XML-based parser. Using the jdom2 tool, we parse the tags in the XML file. We then use Lustre grammar rules to map tags to Lustre code keywords and define error messages for exceptions.

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

[0076] The third step, given that this tool needs to interact with the front-end modeling platform, requires limiting the data exchange format and imposing constraints on the operating port, request method, and input and output file formats. Through these three steps, this tool can be deployed as a microservice. During the modeling process using OnModel, OnModel sends different types of XML data by calling different interfaces. Upon receiving the request, the tool generates the corresponding Lustre code online, providing support for the OnModel tool's functionality.

[0077] Technical effects of the present invention:

[0078] This paper 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 implementation of the Scade function compatible with the benchmarking tool, 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 situations.

[0081] (3) Deployment based on microservices. Compared with the interaction method of calling plug-ins, the service-based interaction method can avoid the time overhead caused by each plug-in call, 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 Based on the persistent XML file format, combined with Lustre grammar rules and binding keywords and XML tags, we formulate XML-based parsing rules and construct an XML-based grammar parser to achieve the translation process from XML content to Lustre code. Step 2: Divide 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 based on 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 it from the controller module; The transform module is a conversion module that provides conversion and code generation for different Lustre syntaxes; The util module provides auxiliary functions for indentation and string formatting during code generation; Step 3: Develop interaction rules and data formats with the front-end modeling platform The Xml2Lustre tool is deployed as a microservice. The front-end modeling platform sends a post request to the XML data to be converted in the format of file path or file content to the corresponding functional interface. 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 online code generation tool design method according to claim 2, characterized in that: In the first step, Lustre grammar rules are expressed using Backus-Naur Form. During the construction of the XML parser, the Backus-Naur Form of the Lustre grammar is used to formulate parsing rules for XML tags, extract key tags from the XML, and map and bind them to 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 method for designing an XML-based Lustre online code generation tool according to claim 4, wherein: 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 method for designing an XML-based Lustre online code generation tool according to claim 5, wherein: TypeList2LustreService processes predefined types, array types, enumeration types, and structure types separately.

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

8. The method for designing an XML-based Lustre online code generation tool according to claim 7, wherein: 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, wherein: The Xml2Lustre tool runs on the local machine as 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 request 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 entire online generation process of the Lustre code.

10. The method for designing an XML-based Lustre online code generation tool according to claim 9, wherein: 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

  • Model formalized verification method based on extended Lustre language

    CN116150005A