SCADE model to c code mapping tool

CN117075874BActive Publication Date: 2026-10-23BEIJING JIAODA SIGNAL TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311099333.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-29
Publication Date
2026-10-23
Estimated Expiration
2043-08-29

AI Technical Summary

Technical Problem

这些工具通常提供了诸如语法高亮、代码折叠、代码搜索等基本功能,但是它们并不能提供直接从模型到代码的映射

Benefits of technology

[0016]本发明映射工具不仅提供了一种直观的方式来理解SCADE模型和生成的C代码之间的关系,也极大地简化了代码的阅读和调试过程。开发者不再需要在模型和代码之间来回切换,或者手动查找代码或者模型元素,解决现有技术中无法直观显示SCADE模型与对应C代码之间关系的问题,从而大大提高了开发效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117075874B_ABST
    Figure CN117075874B_ABST
Patent Text Reader

Abstract

The mapping tool of the SCADE model and the C code of the application comprises a model file parsing module, a mapping file parsing module, a C file parsing module, a model redrawing module, a mapping relationship module, a code rendering module and an interface display module, the mapping tool can display the SCADE model and the corresponding C code file simultaneously, and track the corresponding relationship between each model element in the SCADE model and each part of the code in the C code file, and can automatically jump between the two and highlight display. The mapping tool of the application not only provides an intuitive way to understand the relationship between the SCADE model and the generated C code, but also greatly simplifies the reading and debugging process of the code. The developer no longer needs to switch between the model and the code, or manually search for the code or the model element, solving the problem that the relationship between the SCADE model and the corresponding C code cannot be intuitively displayed in the prior art, thereby greatly improving the development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention is a tool for establishing a mapping relationship between a SCADE model and the generated C code. This tool is suitable for embedded software development driven by SCADE models, and can quickly switch between the SCADE model and the corresponding C code to display the correspondence between the model and the C code. Background Technology

[0002] In the field of embedded software development, using MBD (Model-Based Development) tools such as SCADE has become a common approach. MBD tools describe the behavior of embedded software through graphical modeling and can automatically generate corresponding code. They offer advantages such as high development efficiency, fewer errors, low maintenance costs, and high reusability.

[0003] However, while SCADE can generate high-quality C code, it doesn't provide sufficient support to help developers understand and debug it. SCADE-generated code is often very complex, containing numerous control structures and data operations. SCADE doesn't offer any tools to show the correspondence between the model and the generated C code. This means that when developers read the generated code, they cannot identify which code segment corresponds to which element in the model, making it impossible to quickly locate the model that needs modification based on the C code. Meanwhile, existing code analysis and understanding tools typically focus only on the source code itself, ignoring the relationship between the source code and its original model. These tools usually provide basic functions such as syntax highlighting, code folding, and code search, but they don't provide a direct mapping from model to code. This makes the code difficult for humans to understand, a problem that severely impacts development efficiency.

[0004] Therefore, developing a tool that can map the relationship between SCADE models and generated C code is of significant practical importance for improving the efficiency of SCADE model-driven development. Such a tool can help developers quickly locate the correspondence between the model and the code, thereby greatly improving debugging efficiency and development convenience. Summary of the Invention

[0005] This invention provides a tool that can map between SCADE models and C code, enabling bidirectional mapping between models and code.

[0006] This invention provides a mapping tool between SCADE models and C code. The mapping tool is opened as a standalone program and is not associated with SCADE. When developers use it, they can open it by double-clicking the exe file of the mapping tool.

[0007] This tool includes modules for model file parsing, mapping file parsing, C file parsing, model redrawing, mapping relationships, code rendering, and user interface display.

[0008] The model file parsing module reads and parses the SCADE model file .xscade;

[0009] The mapping file parsing module is used to parse the mapping file mapping.xml generated by SCADE;

[0010] The C file parsing module is used to parse C code files generated by SCADE;

[0011] The model redrawing module is used to draw the parsed .xscade model files graphically and display the graphical appearance of the model through the interface display module.

[0012] The code rendering module is used to highlight C code according to the syntax of the C language;

[0013] The mapping module is used to perform mutual indexing between each model element in the model and each part of the code in the C code file, and send the index information to the model redrawing module and the C code rendering module respectively, so as to highlight the indexed model elements and code;

[0014] The interface display module is the interface for interaction with developers. It is used for project settings, indexing various models and C code files, and can display the appearance of the redrawn SCADE model and the rendered C code in tabs.

[0015] The mapping tool can simultaneously display the SCADE model and its corresponding C code file, and track the correspondence between each model element in the SCADE model and each part of the C code file. It can automatically jump between the two and highlight the corresponding parts.

[0016] This invention's mapping tool not only provides an intuitive way to understand the relationship between SCADE models and generated C code, but also greatly simplifies the code reading and debugging process. Developers no longer need to switch back and forth between models and code, or manually search for code or model elements, solving the problem in existing technologies where the relationship between SCADE models and corresponding C code cannot be intuitively displayed, thereby greatly improving development efficiency. Attached Figure Description

[0017] Figure 1 This is a structural block diagram of the mapping tool of the present invention;

[0018] Figure 2 This is a schematic diagram of the model code mapping of the present invention;

[0019] Figure 3 This is a schematic diagram of the SCADE file output and input files of the present invention;

[0020] Figure 4 This is an example of a mapping.xml file for this invention;

[0021] Figure 5 Displaying the model in SCADE

[0022] Figure 6 The model is displayed in the mapping tool of this invention;

[0023] Figure 7 This is the pop-up window that appears when clicking on a state machine model element in SCADE according to the present invention.

[0024] Figure 8 This is a highlighted C code diagram of the present invention;

[0025] Figure 9 This is the pop-up window that appears when you double-click the C code in this invention;

[0026] Figure 10 This is a highlighted diagram of the state machine model of the SCADE of the present invention;

[0027] Figure 11 This is an example of an IBD model of SCADE in a preferred embodiment of the present invention;

[0028] Figure 12 This is a pop-up window when clicking on an IBD model element in SCADE in a preferred embodiment of the present invention.

[0029] Figure 13 This is a C code highlighting diagram from a preferred embodiment of the present invention;

[0030] Figure 14 This is the pop-up window that appears when double-clicking C code in a preferred embodiment of the present invention;

[0031] Figure 15 This is a highlighted image of the IBD model of SCADE in a preferred embodiment of the present invention. Detailed Implementation

[0032] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that the existing situations referred to in this specification do not represent publicly disclosed prior art, but are merely for the purpose of elucidating the key technologies and innovations of the present invention.

[0033] This invention's mapping tool is a desktop application developed based on Qt. It is used as a standalone program and is unrelated to SCADE. Developers can open it by double-clicking the tool's .exe file. The tool includes modules for model file parsing, mapping file parsing, C file parsing, model redrawing, mapping relationships, code rendering, and user interface display, such as... Figure 1 As shown. Wherein:

[0034] a) The model file parsing module reads and parses the SCADE model file .xscade;

[0035] b) The mapping file parsing module is used to parse the mapping file mapping.xml generated by SCADE;

[0036] c) The C file parsing module is used to parse C files generated by SCADE;

[0037] d) The model redrawing module is used to draw the parsed .xscade model files graphically and display the graphical appearance of the model through the interface display module;

[0038] e) The code rendering module is used to highlight C code according to the syntax of the C language;

[0039] f) The mapping module is used to perform mutual indexing between each model element in the model and each part of the code in the C code file, and send the index information to the model redrawing module and the C code rendering module respectively, so as to highlight the indexed model elements and code;

[0040] g) The interface display module is the interface for interaction with developers. It is used for project settings, indexing various models and C code files, and can display the appearance of the redrawn SCADE model and the rendered C code in tabs.

[0041] This mapping tool can simultaneously display the SCADE model and its corresponding C file, and trace the correspondence between each model element in the SCADE model and each part of the code in the C file. It can automatically jump between the two and highlight the relevant information. Figure 2 As shown, it specifically includes:

[0042] 1. Model-to-Code Mapping: When a developer clicks on a model element in a SCADE model, this invention locates the corresponding C code for that element, automatically switches to the code display interface, shows the corresponding code and its C file, and scrolls the display window to the corresponding code location, highlighting it. This allows developers to immediately see the implementation details of the model element without having to manually search for it in the code.

[0043] 2. Code-to-Model Mapping: When a developer double-clicks a code segment in a C file, this invention locates the corresponding model element, automatically switches to the model display interface, shows the model containing the model element, and highlights the corresponding model element. This allows developers to immediately see the model element corresponding to the code segment and its position within the entire SCADE model.

[0044] SCADE models are mainly divided into two categories: state machine models and IBD (Internal Block Diagram) models. These two types of models can be used to develop all embedded software functions. In the process of developing embedded software using SCADE, developers first use SCADE's graphical interface to create and edit the software model and save it as a .xscade file. After the model passes the check and its correctness is ensured, C code is generated by calling SCADE's code generator KCG, and a mapping.xml file is generated simultaneously. Figure 3 As shown.

[0045] The .xscade file is the SCADE model file, used to store the SCADE model data. The mapping.xml file contains the C code and the relationship between the model and the .xscade file, such as... Figure 4 As shown. This file <model>The content contains SCADE model elements, and <generated> <c>The content contains C code corresponding to the model elements, which are associated with each other via ID.

[0046] The model file (.xscade), the C code file, and the mapping file (mapping.xml) are the inputs to the mapping tool of this invention, such as... Figure 3 As shown. The mapping tool of this invention implements the following three main functions based on these three types of files:

[0047] 1. Model parsing and display: This is achieved through the model file parsing, model redrawing, and interface display modules.

[0048] This tool is used to parse .xscade model files and extract model information, including model view information, structure, and elements. The model view graphically displays the model's structure and the relationships between its elements. When you need to find the corresponding C code from a SCADE model element, you should first expand the model view directory, which is a tree structure where each node represents a model view. Double-click the tree node containing the model you want to view to open it. When opening the model, this invention will draw and render the model file based on the model information, including highlighting where necessary. This invention maintains consistency between the model display and the display in the SCADE tool. Figure 5 , Figure 6 The image shows a comparison between the SCADE model opened and displayed in this invention and its display in the SCADE software. Figure 5 For displaying the model in SCADE, Figure 6 To illustrate the display of the model in the mapping tool of this invention, the left side of the figure shows the tree structure of the model directory. The model directory in this invention is consistent with the model directory of the SCADE software.

[0049] 2. Code Reading and Display: Implemented through C file parsing, code rendering, and interface display modules. It reads C code files, displays them as text, renders the C code text according to C language syntax when the file is opened, and highlights the code where needed.

[0050] 3. Model-Code Mapping: Implemented through a mapping file parsing and mapping relationship module. This module parses the mapping.xml file and obtains the mapping relationship between the model and code, enabling automatic navigation. When a developer clicks on any model element in the model view, the system will automatically navigate to the corresponding C code location based on the mapping relationship and highlight the relevant code snippet. Conversely, when a developer double-clicks on any code snippet in the C code view, the system will automatically navigate to the corresponding model element based on the mapping relationship and highlight it.

[0051] The working interface of the tool after startup is as follows: Figure 6 As shown. It mainly consists of 5 parts, namely: 1. "Project Directory" button: located at the top of the interface, used to specify the SCADE project directory;

[0052] 2. "SCADE Model" Directory: Located in the middle left of the interface, it displays the SCADE model directory structure;

[0053] 3. "C Code" directory: Located at the bottom left of the interface, it displays a list of C code generated by the SCADE model;

[0054] 4. The model code display window is located on the right side of the interface and displays the various model views and C code text in a tabbed manner.

[0055] The following example illustrates the specific usage of the mapping tool of this invention by mapping a typical SCADE state machine model to C code:

[0056] 1. Project Directory Settings: Each time the application runs, the developer needs to first click the "Project Directory" button on the displayed interface, such as... Figure 6 As shown at the top. Specify the project directory of the SCADE project in the opened browser. After completing the project directory setting, this invention will call the model file parsing, mapping file parsing, and C file parsing modules to automatically search, read, and parse the .xscade model files, C code files, and mapping file mapping.xml in the project directory. By parsing the model files and code files, a model view directory and a code file directory are generated and displayed on the left side of this invention's tool. The model directory displays the hierarchical structure of the SCADE model in a tree structure, such as... Figure 6 The left side shows the opened "Alert->Faultztl->Faultztl_1" model directory.

[0057] 2. Model-to-code mapping:

[0058] 1) When it is necessary to find the C code corresponding to a SCADE model, the developer can double-click any tree node in the model directory. At this time, the present invention will call the model redrawing module to redraw the model corresponding to the parsed node, generate the model view to be viewed, and call the interface display module to display it. For example Figure 6 The image on the right shows the SCADE model in the directory "Alert->Faultztl_1" opened by double-clicking the tree node "Faultztl_1". This model is a state machine. "Faultztl_1" is the model view number and also the name of the tab that displays the model view.

[0059] 2) When a developer wants to view the C code corresponding to a specific model element, they simply click on that element in the model view interface. For example, clicking on the state "WaitingState" in state machine "SM1" will cause the invention to call the mapping module to index the C code corresponding to that state. A prompt box will then pop up, such as... Figure 7 As shown. It indicates which element of which model the clicked model element belongs to, and displays the corresponding C code snippet in which C file. For example... Figure 7 The "model" is displayed as "Alert Faultztl", which means that the model is consistent with the actual model.

[0060] The model element displays "WaitingState," which is the state just selected. The corresponding C code is "_122SSMst_WaitingState_SM1," and the C file it resides in is [file name missing].

[0061] "FaultZtl_Alert.c"

[0062] 3) After clicking the "OK" button, the tool will automatically switch to the C code display interface, call the code rendering module to render the C code file "FaultZtl_Alert.c" that was just found, and call the interface display module to display it, highlighting the C code "_122SSMst_WaitingState_SM1" corresponding to the model element, such as... Figure 8 As shown. This completes the conversion from the SCADE model element "WaitingState" to C code.

[0063] The mapping of "_122SSMst_WaitingState_SM1".

[0064] 3. Mapping from code to model:

[0065] 1) When it is necessary to find the SCADE model corresponding to C code, the developer locates the code file containing the elements of the corresponding SCADE model in the C file directory, double-clicks to open it, and the tool of this invention will call the code rendering module to render according to the C code syntax and call the interface display module to display it, such as... Figure 9 The image shows the C code file "FaultZtl_Alert.c" that is opened and displayed in the tool of this invention.

[0066] 2) To view the model element corresponding to a specific C code segment, simply double-click the C code segment, for example, "SSM_st_IdleState_SM2_WorkingState_SM1". This invention will then call the mapping module to index the model element corresponding to that code. A prompt box will then appear, indicating which part of which file the double-clicked C code belongs to, and which model element of which SCADE model it corresponds to. Figure 9 As shown.

[0067] 3) Click the "OK" button. This invention will invoke the model redrawing module to redraw the SCADE model found earlier, and invoke the interface display module to display it, while highlighting the model elements corresponding to the C code. (Code here)

[0068] The model element corresponding to "SSM_st_IdleState_SM2_WorkingState_SM1" is the "IdleState" state within state machine "SM2" under the state "WorkingState" state within state machine "SM1". For example... Figure 10 As shown.

[0069] Through the above implementation methods, the present invention provides an intuitive way to understand the relationship between the SCADE model and the generated C code, realizes the correspondence between the SCADE model and the C code, facilitates developers to switch between the model and the code, and accurately locates the model that needs to be modified and the corresponding code.

[0070] Preferred embodiment

[0071] In addition to the typical SCADE state machine model mentioned above, the following section uses the typical SCADE IBD model as an example to demonstrate how the mapping tool of this invention can be used to map representative models and C code. The detailed steps are as follows:

[0072] 1. Project Directory Settings: Click the "Project Directory" button and specify the SCADE project directory in the opened browser. After completing the project directory settings, the model view directory and code file directory will be generated as follows: Figure 11 As shown.

[0073] 2. Model-to-code mapping:

[0074] 1) Expand the SCADE model directory: "Brake->BrakeCancel->NbCancel", then double-click...

[0075] "IBD_NbCancel1" opens the graphical display of the model, such as Figure 11 As shown.

[0076] 2) Click the model element named "_LLTSMCancelNb_iNbCancel TSMCancelNb" in the image. A prompt box will then appear as follows: Figure 12 As shown. The model is displayed as "BrakeBrakeCancel NbCancel", consistent with the previously expanded model. The "TSMCancelNb" displayed for the model elements is the name of the selected model element; here, the name has been removed.

[0077] The string "_LLTSMCancelNb_iNbCancel TSMCancelNb" represents the path and repeated redundant characters. The corresponding C code is "TSMCancelNb_Brake_BrakeCancel".

[0078] The C file containing the C code is "NbCancel_Brake_BrakeCancel.c".

[0079] 3) After clicking "OK", the tool will automatically pop up the C file and highlight the keywords, such as... Figure 13 As shown.

[0080] 3. Mapping from code to model:

[0081] 1) At this point, if you want to view the "NbCancel_Brake_BrakeCancel.c" C code file...

[0082] To access the model element corresponding to "InOutDiffCancelNb_Brake_BrakeCancel", simply double-click the C code snippet. A prompt box will then appear, as shown below. Figure 14 As shown, the prompt indicates which part of which file the double-clicked C code belongs to, and which model element of which SCADE model it corresponds to.

[0083] 2) Click the "OK" button. This tool will switch to the SCADE model display interface, showing the SCADE model you just found. The model element corresponding to the C code will be highlighted at the bottom as "InOutDiffCancelNb". Figure 15 As shown.

[0084] The technical advantages of the mapping tool of this invention are as follows:

[0085] The beneficial effects of this invention mainly include the following:

[0086] Improved development efficiency: This invention allows developers to quickly switch between SCADE models and generated C code, greatly reducing the time spent searching for the corresponding model or code, thereby improving development efficiency.

[0087] Enhancing Code Understanding and Debugging Capabilities: The tools of this invention can help developers better understand and debug the generated C code. Developers can intuitively see what the C code corresponding to each model element is, and what the model element corresponding to each piece of C code is, which is very helpful for understanding and debugging the code.

[0088] Enhancing the advantages of model-driven development: A key advantage of model-driven development is the ability to design and implement systems at a high level of abstraction. The tools in this invention further amplify this advantage by allowing developers to visually see how high-level models are translated into low-level C code.

[0089] Improve code reading and comprehension: By simultaneously displaying the SCADE model and its corresponding C code, developers can intuitively understand the relationship between the model and the code, making it easier to comprehend the code logic and structure. This helps improve the efficiency of code reading and comprehension.

[0090] Accelerate code maintenance and debugging: When code needs to be modified or debugged, developers can use this tool to quickly locate the module and code that needs to be addressed, eliminating the need for tedious manual searching. This can greatly improve the efficiency of code maintenance and debugging.

[0091] Reducing Development Complexity: In large software projects, the correspondence between models and code is often complex and easily confused. This tool's automatic navigation and highlighting features help developers accurately navigate to relevant code, reducing the risk of confusion and errors during development, thereby reducing development complexity.

[0092] Improved Development Efficiency: By intuitively displaying the correspondence between models and code, and providing automatic navigation and highlighting features, this tool enhances developer productivity. Developers can more quickly understand the relationship between code and models, reducing the time spent repeatedly switching and searching, thereby improving development efficiency.

[0093] In summary, this invention provides developers with a better experience in reading, maintaining, and debugging code by offering intuitive model and code displays, automatic navigation and highlighting functions, and features that improve development efficiency and reduce complexity, thereby enhancing the efficiency and quality of software development.

[0094] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.< / c> < / generated> < / model>

Claims

1. A mapping tool between a SCADE model and C code, wherein the mapping tool is opened as a standalone program and is not associated with the SCADE. When the developer uses it, he / she can open it by double-clicking the exe file of the mapping tool; This tool includes modules for model file parsing, mapping file parsing, C file parsing, model redrawing, mapping relationships, code rendering, and user interface display. The model file parsing module reads and parses the SCADE model file .xscade; The mapping file parsing module is used to parse the mapping file mapping.xml generated by SCADE; The C file parsing module is used to parse C code files generated by SCADE; The model redrawing module is used to draw the parsed .xscade model files graphically and display the graphical appearance of the model through the interface display module. The code rendering module is used to highlight C code according to the syntax of the C language; The mapping module is used to perform mutual indexing between each model element in the model and each part of the code in the C code file, and send the index information to the model redrawing module and the C code rendering module respectively, so as to highlight the indexed model elements and code; The interface display module is the interface for interaction with developers. It is used for project settings, indexing various models and C code files, and can display the appearance of the redrawn SCADE model and the rendered C code in tabs. The mapping tool can simultaneously display the SCADE model and its corresponding C code file, and track the correspondence between each model element in the SCADE model and each part of the C code file. It can automatically jump between the two and highlight the corresponding parts.

2. The mapping tool according to claim 1, characterized in that, When a developer clicks on a model element in a SCADE model, the mapping tool finds the corresponding C code for that model element, automatically switches to the code display interface, displays the corresponding code and the C code file it belongs to, and scrolls the display window to the corresponding code position and highlights it. When a developer double-clicks a code segment in a C code file, the mapping tool finds the model element corresponding to that code segment, automatically switches to the model display interface, displays the model containing that model element, and highlights the corresponding model element.

3. The mapping tool according to claim 2, characterized in that, The model file (.xscade), C code file, and mapping file (mapping.xml) are the inputs to the mapping tool. The mapping tool performs the following functions based on these three types of files: 1) model parsing and display; 2) code reading and display; 3) model code mapping.

4. The mapping tool according to claim 3, characterized in that, The model parsing and display functions are implemented through a model file parsing module, a model redrawing module, and an interface display module; used to parse .xscade model files and extract model information, including model view information, structure, and each element; the model view graphically displays the structure of the model and the relationships between model elements.

5. The mapping tool according to claim 3, characterized in that, The code reading and display function is implemented through a C file parsing module, a code rendering module, and an interface display module; it is used to read C code files, display them in text format, render the displayed text of C code according to C language syntax when the file is opened, and highlight the code where it needs to be highlighted.

6. The mapping tool according to claim 3, characterized in that, The model-code mapping function is implemented through a mapping file parsing module and a mapping relationship module; it is used to parse the mapping.xml file and obtain the mapping relationship between the model and the code, and to achieve automatic navigation. When a developer clicks on any model element in the model view, the mapping tool will automatically jump to the corresponding C code location based on the mapping relationship and highlight the relevant code snippet; When a developer double-clicks any code snippet in the C code view, the mapping tool will automatically jump to the corresponding model element based on the mapping relationship and highlight it.

Citation Information

Patent Citations

  • IMA-oriented AADL multi-paradigm modeling and C code automatic generation method

    CN112114801A

  • Software agility test tool

    CN116225961A