Method and apparatus for generating test panels for simulation models

By automating the generation of test panels, the problems of low efficiency and poor adaptability in manual construction of existing technologies are solved. This method enables efficient and accurate generation of simulation model test panels, adapting to different levels of nested models and improving the quality of development and testing.

CN122331871APending Publication Date: 2026-07-03CHERY AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610415210.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-31
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In existing visual simulation modeling platforms, the test panels for the simulation models under test rely on manual construction, which is inefficient, prone to component and parameter mapping errors, has poor adaptability, and cannot quickly adapt to simulation models with different nested levels, resulting in a cumbersome simulation testing process and insufficient accuracy.

Method used

By acquiring the basic information of the simulation model to be tested in the visualization simulation modeling platform, calling the module retrieval interface to traverse the model and subsystems, determining the full-dimensional structured information of the effective constant parameter module, constructing the core test logic of the callback function driven by the user-triggered control component, generating script code, and realizing the automated generation of the test panel.

Benefits of technology

It significantly improves development efficiency, reduces human error, ensures accurate mapping between components and parameter modules, adapts to nested models of varying complexity, and enhances test quality and real-time performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122331871A_ABST
    Figure CN122331871A_ABST
Patent Text Reader

Abstract

This invention provides a method and apparatus for generating test panels for simulation models, relating to the technical field of test tool generation. The method includes: acquiring information about the simulation model to be tested from a visual simulation modeling platform and verifying its editable state; calling the module retrieval interface of the visual simulation modeling platform, and, in conjunction with a user-defined search depth, retrieving all valid constant parameter modules and full-dimensional structured information from the model; constructing core test logic and generating script code based on a preset panel template, automatically converting it to an application designer-compatible format, and simultaneously generating a test architecture file; finally generating a visual interface containing a control panel, data observation area, and status information panel. This addresses many drawbacks of manually creating panels, improves development efficiency, adapts to different versions of application designers, and enhances the quality of model development and testing on the visual simulation modeling platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of test tool generation, and in particular to a method and apparatus for generating test panels of simulation models. Background Technology

[0002] Currently, the test panels for simulation models under test in visual simulation modeling platforms mostly rely on manual construction. This requires manually matching model parameters and control components, writing callback functions and test logic, which is not only inefficient but also prone to problems such as incorrect component and parameter mapping and failed callback binding.

[0003] Meanwhile, manually constructed panels have poor adaptability and cannot quickly adapt to simulation models with different nested levels. Furthermore, the test configuration is disconnected from the panel functions, resulting in a cumbersome simulation testing process and insufficient accuracy, making it difficult to meet the needs of efficient and accurate simulation model testing. Summary of the Invention

[0004] The purpose of this invention is to provide a method and apparatus for generating test panels for simulation models, so as to alleviate the technical problem of low development efficiency of test panels in visualization simulation modeling platforms.

[0005] In a first aspect, the present invention provides a method for generating a test panel for a simulation model, comprising: Obtain the basic model information of the simulation model to be tested in the visualization simulation modeling platform; wherein, the basic model information includes the hierarchical structure of the simulation model to be tested, the hierarchical structure of the multi-layered nested subsystems and internal nested modules under the simulation model to be tested; Based on the basic information of the model corresponding to the qualified simulation model to be tested, the module retrieval interface of the visualization simulation modeling platform is called, as well as the nesting level set by the user. The module retrieval interface is controlled to traverse the simulation model to be tested and the multi-layer nested subsystem to determine the effective constant parameter module and the full-dimensional structured information of the effective constant parameter module. Based on the full-dimensional structured information and the preset panel template, the core test logic is constructed to respond to the change event of the user-triggered control component drive callback function, forming the script code used to generate the test panel.

[0006] In an optional implementation, the step of calling the module retrieval interface of the visualization simulation modeling platform based on the basic information of the verified simulation model to be tested, and the user-defined nesting level, to control the module retrieval interface to traverse the simulation model to be tested and the multi-layered nested subsystems, and to determine the effective constant parameter module and the full-dimensional structured information of the effective constant parameter module, includes: Based on the basic model information corresponding to the verified simulation model to be tested, the module retrieval interface of the visualization simulation modeling platform is called. The target pattern for nesting level is determined in response to user input operation commands; wherein, the target pattern includes a fixed level limitation pattern with a preset maximum retrieval nesting level and an unlimited recursive scanning pattern that automatically identifies the level results of the simulation model under test; Based on the target pattern traversal control parameters, the module retrieval interface is controlled to traverse the simulation model to be tested and the multi-layer nested subsystem according to the rules corresponding to the target pattern to obtain candidate constant parameter modules; The candidate constant parameter modules are subjected to triple verification of visibility, running status, and naming uniqueness through a multi-dimensional screening mechanism. Valid constant parameter modules that pass the verification are retained and their full-dimensional structured information is extracted. The full-dimensional structured information includes the name, path, parameter value, hierarchical level, and adjustable range of the valid constant parameter modules.

[0007] In an optional implementation, the steps of constructing core test logic that responds to change events triggered by user-triggered control component callback functions, based on the full-dimensional structured information and a preset panel template, and forming script code for generating the test panel, include: Build the core test logic: The parameter types and adjustable ranges in the full-dimensional structured information are identified based on a preset panel template. Match the corresponding control component according to the parameter type, establish a mapping relationship between each control component and the corresponding valid constant parameter module, configure the operating range of the control component based on the adjustable range, and generate a change event; The change event and the callback function driven by the change event are bound together to enable the interactive operation of the control component and the real-time synchronization of the model parameters in the effective constant parameter module. The independent code blocks for the newly added testing functions are modularly encapsulated and combined with the core testing logic to form script code for generating test panels.

[0008] In an optional implementation, the step of binding the change event and the callback function driven by the change event to perform real-time synchronization between the interactive operation of the control component and the model parameters in the effective constant parameter module includes: The interactive control components of the test panel's operation unit; the binding of the change events with the associated callback functions; In response to the user's interactive operation on the interactive control component, which serves as the operation unit of the test panel, the change event is controlled to trigger the callback function, the latest value of the interactive control component is obtained in real time, and the parameter modification interface of the visualization simulation modeling platform is called to synchronously update the latest value to the corresponding valid constant parameter module according to the mapping relationship.

[0009] In an optional implementation, the method further includes: The line-by-line parsing mapping algorithm identifies the class definitions, component definitions, callback functions, and functional logic of the script code line by line, and maps them into a markup language structure compatible with the application designer, forming functional code for a test panel that can be run independently. Perform triple verification on the transformed functional code: compare the interface position and display order of the control components in the test panel before and after the transformation, verify the binding relationship between the callback function and the control component, and verify the validity of the simulated execution results of the core test logic.

[0010] In an optional implementation, the method further includes: Based on the basic model information corresponding to the verified simulation model to be tested, the test framework interface of the visualization simulation modeling platform is called. Based on the configuration instructions input by the user, the nested subsystem corresponding to the simulation model under test or the core module to which the effective constant parameter module belongs is selected, the corresponding test signal source is configured, and the control component for receiving results in the test panel is bound to generate a standardized test architecture file for simulating specific modules in the simulation model under test.

[0011] In an optional implementation, the method further includes: Based on the function code corresponding to the script code and the test architecture file, a visual graphical interface for the test panel is generated; wherein, the visual graphical interface includes the control components and the data observation area; the data observation area displays the core adjustable parameter units of the effective constant parameter module in the simulation model under test; Clean up temporary variables and cache files generated, and release runtime resources.

[0012] Secondly, the present invention provides a test panel generation device for a simulation model, comprising: The acquisition module acquires the basic model information of the simulation model to be tested in the visualization simulation modeling platform; wherein, the basic model information includes the hierarchical structure of the simulation model to be tested, the hierarchical structure of the multi-layer nested subsystems and internal nested modules under the simulation model to be tested; The module determines the module by calling the module retrieval interface of the visualization simulation modeling platform based on the basic information of the model corresponding to the qualified simulation model to be tested, as well as the nesting level set by the user, and controlling the module retrieval interface to traverse the simulation model to be tested and the multi-layer nested subsystem to determine the effective constant parameter module and the full-dimensional structured information of the effective constant parameter module. The generation module, based on the full-dimensional structured information and the preset panel template, constructs the core test logic that responds to the change event of the user-triggered control component drive callback function, forming the script code used to generate the test panel.

[0013] Thirdly, the present invention provides an electronic device including a memory, a processor, and a program stored in the memory and capable of running on the processor, wherein the processor executes the program to implement the method as described in any of the foregoing embodiments.

[0014] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed, implements the method described in any of the foregoing embodiments.

[0015] This invention provides a method and apparatus for generating test panels for simulation models. First, the complete hierarchical structure information of the simulation model to be tested is obtained from a visual simulation modeling platform. This is achieved by calling the platform's application programming interface (API) functions to collect the model name, path, version, and hierarchical structure, and verifying the model's editability to ensure complete information and normal editability, providing reliable support for subsequent processes. Second, based on the verified model information, the module retrieval interface of the visual simulation modeling platform is called. Combined with the user-defined search depth (nesting level), the interface traverses the model and subsystems, filters valid constant parameter modules, and extracts full-dimensional structured information such as module name, path, and parameter values. An optimized retrieval algorithm is used to improve retrieval efficiency, replace manual screening, and reduce human error. Finally, combining the full-dimensional structured information with a preset panel template, string concatenation technology is used to match corresponding control components, generate change events and callback functions, construct core test logic, and form script code, achieving automatic script generation and ensuring accurate mapping between components and valid constant parameter modules. The aforementioned technical means work together to address the problems of low efficiency, incomplete functionality, and poor real-time performance in manually creating test panels for visual simulation modeling platforms. They have automated the generation of test panels, laying the foundation for subsequent application designers to perform format conversion, test architecture configuration, and visual interface generation. This effectively improves the development efficiency and testing quality of models on visual simulation modeling platforms and adapts to nested visual simulation modeling platform models of varying complexity.

[0016] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained through the structures particularly pointed out in the description and the drawings.

[0017] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0018] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0019] Figure 1 A flowchart of a method for generating a test panel for a simulation model provided in an embodiment of the present invention; Figure 2 A schematic diagram of the functional modules of a test panel generation device for a simulation model provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the hardware architecture of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] Simulink is a visualization simulation and model-based design platform widely used in the design and testing of control systems, signal processing, and communication systems. During Simulink model development, engineers often need to create test panels to adjust parameters in real time, observe signal output, and control the simulation process to verify the model's correctness and performance. Currently, the creation of Simulink model test panels suffers from several shortcomings: manual creation is inefficient, requiring manual addition of UI components and writing of callback functions in the MATLAB App Designer, with moderately complex panels taking hours or even days; automation is lacking, as existing tools cannot automatically generate panels based on the model structure, requiring custom development; functionality is incomplete, only including basic parameter adjustment and signal display, lacking complete simulation control and signal configuration functions; code reusability is poor, with different models having different panel code structures; and real-time performance is poor, with issues such as untimely parameter updates and delayed signal display, severely impacting development efficiency and testing quality.

[0022] Based on this, the present invention provides a method and apparatus for generating test panels for simulation models. By calling the application programming interface function of the visualization simulation modeling platform through a script, the valid constant parameter module is automatically retrieved, thereby realizing the automatic generation of test panels for the model on the visualization simulation modeling platform. This significantly improves development efficiency, reduces development difficulty, and enhances the development and testing quality of the model on the visualization simulation modeling platform.

[0023] To facilitate understanding of this embodiment, a method for generating a test panel for a simulation model disclosed in this embodiment of the invention will first be described in detail. This method can be applied to computer equipment equipped with a matrix laboratory, a visual simulation modeling platform, and an application designer.

[0024] Figure 1 A flowchart illustrating a method for generating a test panel for a simulation model, as provided in an embodiment of the present invention.

[0025] like Figure 1 As shown, the method includes the following steps: S102, Obtain the basic information of the simulation model to be tested in the visualization simulation modeling platform (Simulink), and verify whether the simulation model to be tested is in an editable state; The basic information of the model includes the hierarchical structure of the simulation model under test, the hierarchical structure of the multi-layered nested subsystems and internal nested modules under the simulation model under test; Here, by calling the Simulink API functions gcs and bdroot, the name, full path, version, and hierarchical structure (including nested subsystems and internal modules) of the currently opened simulation model to be tested are obtained. At the same time, the editable status of the model is verified to exclude locked or uneditable models. This verification operation can ensure that the obtained basic model information is complete and accurate, providing reliable support for subsequent retrieval of effective constant parameter modules (Constant modules) and panel generation, avoiding process interruption, improving method stability, and adapting to the characteristics of Simulink models.

[0026] S104. Based on the basic information of the model corresponding to the verified simulation model to be tested, the module retrieval interface of the visualization simulation modeling platform (Simulink) is called, along with the nesting level (search depth) set by the user. The module retrieval interface is controlled to traverse the simulation model to be tested and the multi-layer nested subsystems to determine the effective constant parameter module (Constant module) and the full-dimensional structured information of the effective constant parameter module. Here, the Simulink API function `find_system` is called, setting the search depth (default 1, expandable) and `BlockType` to `Constant`. Combined with the user-defined nesting level, the system traverses the model and subsystems, retrieving all `Constant` modules and extracting comprehensive information such as module name, full path, and current parameter values. This optimized retrieval algorithm enables fast and accurate retrieval of `Constant` modules, supports nested models and subsystems, and improves retrieval efficiency by more than 30% compared to traditional methods. It replaces manual screening, reduces errors, and adapts to Simulink models of varying complexity.

[0027] In some embodiments, step S104 may also be implemented by the following steps: Step 1.1. Based on the basic model information corresponding to the verified simulation model to be tested, call the module retrieval interface (find_system function) of the visualization simulation modeling platform (Simulink). Here, using the verified basic information of the model as the trigger condition, the program calls the Simulink built-in find_system function to establish a connection between the function and the model information and configure the basic search parameters. This ensures that the find_system function can accurately obtain the Simulink model structure information, providing interface support for the subsequent Constant module traversal search, ensuring the smooth start of the search process and improving search efficiency.

[0028] 1.2. Determine the target pattern of the nesting level in response to user input commands; Among them, the target modes include a fixed-level limiting mode with a preset maximum retrieval nesting level (search depth) and an unlimited recursive scanning mode that automatically identifies the hierarchical results of the simulation model under test. Specifically, it receives user input commands, parses the search depth requirements in the commands, determines the corresponding target mode, limits the maximum search depth in the fixed mode (e.g., default 1), and automatically identifies the Simulink model hierarchy and performs a full scan in the adaptive mode. It adapts to the testing needs of different users. For complex nested models, the adaptive mode can be selected to achieve full-level search, while for simple models, the fixed mode can be selected to improve search efficiency, balancing flexibility and efficiency, and matching the nested characteristics of Simulink models.

[0029] 1.3. Based on the target pattern, the control module retrieval interface (find_system function) traverses the simulation model to be tested and the multi-layer nested subsystem according to the rules corresponding to the target pattern to obtain candidate constant parameter modules (candidate Constant modules). Here, based on the determined target pattern, the traversal control parameters (such as SearchDepth and BlockType) of the find_system function are configured. The control function traverses the Simulink model and subsystems according to the rules, and filters out candidate modules with BlockType Constant. This enables automatic filtering of candidate Constant modules, reduces manual intervention, ensures that the filtering results meet the testing requirements, and optimizes the traversal logic according to the target pattern, thus significantly improving the retrieval efficiency.

[0030] 1.4. A multi-dimensional filtering mechanism is used to perform triple checks on the visibility, running status, and naming uniqueness of candidate constant parameter modules. Valid constant parameter modules (Constant modules) that pass the checks are retained and their full-dimensional structured information is extracted. The full-dimensional structured information includes the name, path, parameter value, hierarchy, and adjustable range of the valid constant parameter module; Here, a multi-dimensional filtering mechanism is adopted to verify the visibility (whether it can be controlled by the panel), running status (whether it is in normal running state), and naming uniqueness (to avoid module name conflicts) of candidate Constant modules. Invalid modules are eliminated, and the get_param function is called to extract full-dimensional structured information. This method can ensure the validity and uniqueness of valid Constant modules, avoid invalid modules from affecting subsequent panel generation, and at the same time, the extracted full-dimensional information provides accurate data for component matching and range configuration, laying the foundation for subsequent M-script code generation.

[0031] In practical applications, step S104 may specifically include the following steps: First, after the Simulink model under test passes the verification, the computer device, based on the acquired basic model information, activates the Simulink built-in find_system function (module retrieval interface) through a preset interface call command. This enables the function to establish a communication connection with the Simulink model under test, ensuring that the function can read the hierarchical structure and module information of the model and configure the basic call parameters of the function.

[0032] Secondly, the computer device responds to the user's operation commands input through the interactive interface, parses the nesting level (search depth) requirements contained in the commands, and determines the corresponding target pattern. If the user needs to limit the search scope, the fixed-level limitation mode is selected, and the maximum search nesting level is set (default 1, only searching the current level of Constant modules); if the user needs to comprehensively search all Constant modules of the model, the adaptive mode is selected, and the find_system function automatically identifies the hierarchical structure of the Simulink model under test, performs unlimited recursive scanning, and covers all nested subsystems and internal modules.

[0033] In addition, based on the determined target pattern, corresponding traversal control parameters are generated, and parameters such as SearchDepth and BlockType of the find_system function are configured to control the function to traverse the root node, multi-level nested subsystems and inner nested modules of the Simulink model to be tested according to the pattern rules, and filter out all candidate constant parameter modules with BlockType Constant and store them in a temporary cache.

[0034] Finally, a multi-dimensional screening mechanism is used to perform triple verification on candidate Constant modules: first, module visibility is verified to remove hidden modules that cannot be controlled by the panel; second, running status is verified to remove faulty or inactive modules; and finally, naming uniqueness is verified to remove modules with duplicate names to avoid subsequent component mapping conflicts. Valid Constant modules that pass verification are retained, and the `get_param` function is called to extract full-dimensional structured information for each module, including its name, storage path, current parameter values, hierarchy, and adjustable range. This information is then organized for subsequent steps.

[0035] S106. Based on the full-dimensional structured information and the preset panel template (RealTimeScopeApp template), construct the core test logic for responding to the change event of the callback function driven by the user's interaction with the control component, and form the script code (M script code) used to generate the test panel. Here, by combining the full-dimensional information of the Constant module with the RealTimeScopeApp template, string concatenation technology is used to match the corresponding UI components (such as the Spinner input box), generate change events and callback functions, construct the core test logic, and integrate them into M-script code. At this point, the core test logic and M-script code can be automatically generated, avoiding the tedious process of manually writing code, ensuring accurate mapping between components and the Constant module, and a clear code structure, providing core support for subsequent .mlapp format conversion and panel generation.

[0036] In some embodiments, step S106 may be implemented by the following steps: 2.1. Constructing core test logic: Identifying parameter types and adjustable ranges in full-dimensional structured information based on a preset panel template (RealTimeScopeApp template); Here, the preset RealTimeScopeApp template is invoked. Through the parameter recognition algorithm built into the template, the full-dimensional structured information of the Constant module is parsed to extract the parameter type and adjustable range. Combined with the characteristics of Simulink model parameters, the recognition is completed. This enables the automatic recognition of parameter type and adjustable range, providing a basis for subsequent UI component matching and range configuration, ensuring the compatibility between the component and the Constant module parameters, and meeting the parameter control requirements of the Simulink model.

[0037] 2.2. Match the corresponding control component (UI component) according to the parameter type, establish a mapping relationship between each control component and the corresponding valid constant parameter module (Constant module), configure the operating range of the control component based on the adjustable range, and generate change events; Based on the aforementioned embodiments, according to the identified parameter type, a corresponding UI component (such as a Spinner input box for numerical parameters) is matched for each Constant module, establishing a one-to-one unique mapping relationship between the component and the Constant module. The adjustable range of the parameter is configured as the component's operating range, and change events are automatically generated. This achieves precise binding between UI components and Constant modules, ensuring that each component corresponds to a unique Constant module, the range configuration fits the adjustable range of the parameter to avoid adjustments exceeding the range, and the change events provide triggering conditions for subsequent real-time parameter synchronization.

[0038] 2.3. Bind the change event and the callback function driven by the change event to control the interactive operation of the component and the real-time synchronization of the model parameters in the effective constant parameter module (Constant module); Here, the generated change events are bound to a preset callback function. The callback function adopts an efficient parameter passing mechanism with built-in parameter reading and Simulink API (set_param function) calling logic to realize the linkage between component operations and model parameters. This enables real-time synchronization between user operations on UI components and Constant module parameters with a latency of less than 100ms, improving the interactive response speed and accuracy of the test panel and solving the problem of poor real-time performance in existing technologies.

[0039] As an optional embodiment, step 2.3 can also be implemented through the following refined steps: 3.1. Bind the interactive control components (UI components) of the operation units in the test panel to the change events and associated callback functions; First, the UI component is clearly defined as the core operation unit of the test panel. Change events are bound to corresponding callback functions through program instructions to establish the linkage between events and functions. The callback function follows the event-driven design principle. This ensures that UI component operations can accurately trigger the execution of callback functions, providing a stable triggering mechanism for parameter synchronization, avoiding parameter synchronization anomalies caused by the failure of event-function binding, and ensuring real-time performance.

[0040] 3.2. In response to user interaction with the interactive control component, which serves as the operation unit of the test panel, the control change event triggers a callback function to obtain the latest value of the interactive control component in real time, and calls the parameter modification interface (set_param function) of the visualization simulation modeling platform (Simulink) to synchronously update the latest value to the corresponding valid constant parameter module (Constant module) according to the mapping relationship. Here, in response to user UI component operations (such as adjusting the value of the Spinner input box), a change event is triggered, driving the execution of the callback function. The callback function reads the latest value of the component in real time, calls Simulink's set_param function, finds the corresponding module according to the preset component-Constant module mapping relationship, and completes the value update. This achieves zero-delay synchronization between UI component operations and Constant module parameters, ensuring that user operations can be quickly fed back into the Simulink model, improving the interactive experience of the test panel and the accuracy of parameter control, and solving the shortcomings of poor real-time performance in existing technologies.

[0041] Specifically, step 2.3 first clarifies that the UI interaction control component is the core operation unit of the test panel. Users can adjust the parameters of the Simulink model by operating this component (such as adjusting the Spinner input box or clicking the simulation control button). The computer device binds the previously generated change events with the associated callback functions through program instructions. After binding, the association between the events and functions is stored. The callback functions adopt an event-driven design to ensure that the corresponding callback function is accurately called when the event is triggered, avoiding binding errors or failures.

[0042] Secondly, when a user interacts with the UI control components on the test panel (such as adjusting the value of the Spinner input box), the computer device immediately responds to the operation, triggering a control change event. After the event is triggered, the associated callback function is automatically executed. The callback function first obtains the latest value of the UI control component in real time, then calls Simulink's parameter modification interface (set_param function), and simultaneously reads the preset mapping relationship between UI components and Constant modules to find the corresponding Constant module for the UI component.

[0043] Finally, the set_param function is used to synchronize the latest values ​​of the acquired components to the corresponding Constant module, completing the real-time synchronization between user operations and Simulink model parameters. The entire process is done without manual intervention, ensuring the timeliness and accuracy of parameter updates, avoiding numerical deviations, and solving the problem of poor real-time performance of existing manual panels.

[0044] 2.4. Modularly encapsulate the independent code blocks of the newly added test functions and combine them with the core test logic to form script code (M script code) for generating test panels. This invention enables the creation of independent code blocks for new test functions such as simulation control (start, stop, pause), signal configuration (sampling rate, signal selection), display adjustment (axis range, color), and chart settings (data window, trigger method). These blocks are modularly encapsulated and combined with core test logic, using string concatenation technology to generate M-script code. This approach achieves modular integration of test functions. The code adopts object-oriented programming principles, inherits from the matlab.apps.AppBase class, and has a clear structure and strong maintainability. The integrated M-script code can be directly used for subsequent format conversion, improving code reusability.

[0045] For example, firstly, the computer device calls the preset RealTimeScopeApp template, which has a built-in parameter recognition algorithm that can parse the full-dimensional structured information of the Constant module, accurately identify the parameter type (such as frequency, amplitude and other numerical parameters) and the adjustable range of the parameters of each module, and combine the characteristics of Simulink model parameters to provide a precise basis for subsequent UI component matching.

[0046] Secondly, based on the identified parameter type, a corresponding UI control component is matched for each Constant module. For example, numeric parameters are matched with a Spinner input box. A one-to-one unique mapping relationship is established between each UI control component and its corresponding Constant module, and the mapping table is stored for subsequent parameter synchronization. At the same time, the adjustable range of the identified parameters is directly configured as the operating range of the corresponding UI control component to prevent users from exceeding the adjustable range of the parameters during operation. After configuration, a change event is automatically generated to respond to user component operations.

[0047] In addition, the generated change events are bound to the corresponding callback functions. These callback functions use an efficient parameter passing mechanism and have built-in logic for parameter reading and Simulink API (set_param function) calls. When the user interacts with the UI control components, the change events are triggered, which in turn drives the callback functions to execute, achieving real-time synchronization between the UI control component operations and the model parameters in the Constant module, with latency controlled within 100ms.

[0048] Finally, the newly added test functions, such as simulation control (starting, stopping, and pausing simulation; setting simulation time step and total time), signal configuration (selecting and configuring display signals; setting sampling rate and data type), display adjustment (setting axis range, color, and grid lines), and chart settings (setting trigger method and data window size), were each written as independent code blocks and modularly encapsulated. These encapsulated code blocks were then integrated with the core test logic constructed above. Using string concatenation technology, complete M-script code for generating test panels was generated. The code inherits from the matlab.apps.AppBase class, has a clear structure, and is easy to maintain and further develop.

[0049] In a preferred embodiment of practical application, the test panel for this simulation model can be generated successfully. The user opens the target Simulink model in MATLAB. The computer device obtains the name of the currently active model by calling the Simulink API function `gcs`, and then calls the `bdroot` function to obtain the model's complete path, version, and hierarchical structure. This structure covers the simulation model under test (root node) itself, its subordinate multi-level nested subsystems, and the hierarchical relationships of all internal nested modules, ensuring that the obtained information comprehensively covers the core structure of the Simulink model. Next, the Simulink platform's model status verification interface is called to check whether the simulation model under test is in an editable state. If the model is locked or not editable, the user is prompted to unlock it and re-execute the steps. If the verification is successful, the process proceeds to the next step.

[0050] Furthermore, based on the verified model's basic information, the computer device calls Simulink's API function `find_system` (module retrieval interface), simultaneously receiving the user-defined nesting level (search depth, default 1, expandable). This interface is then used to traverse the root node, all multi-level nested subsystems, and internal nested modules of the simulation model under test according to the set depth, initially filtering out candidate modules with `BlockType` set to `Constant`. Then, through preset filtering rules, valid `Constant` modules are identified, and their full-dimensional structured information, including name, storage path, current parameter values, hierarchy, and adjustable range, is extracted and stored in a temporary database.

[0051] Finally, the computer device calls the preset RealTimeScopeApp template, combines it with the full-dimensional structured information of the Constant module stored in the temporary database, identifies the parameter type and adjustable range, matches the corresponding UI control components (such as a label and a Spinner input box for each Constant module), generates change events and associated callback functions, constructs the core test logic that can respond to user interaction operations and realize real-time parameter synchronization, and uses string concatenation technology to integrate all the logic to generate M-script code for generating the test panel.

[0052] Based on the foregoing embodiments, the method of this invention further includes: 4.1. Line-by-line parsing and mapping algorithm: The algorithm identifies the class definitions, component definitions, callback functions, and functional logic of the script code (M-script code) line by line and maps them to a markup language structure compatible with the MATLAB App Designer, forming functional code for a test panel that can be run independently; the M-script code is automatically converted to .mlapp format by calling the m2mlapp function. Here, a line-by-line parsing mapping algorithm is first used to parse the M-script code line by line, identify class definitions, UI component definitions, callback functions, and functional logic in the code, and map them into a markup language structure that MATLAB App Designer can recognize. The m2mlapp function is then called to complete the format conversion. This achieves full compatibility between the M-script code and MATLAB App Designer. The generated .mlapp file can be directly edited and run in App Designer without additional modifications, improving the compatibility of the method and adapting to different versions of MATLAB.

[0053] 4.2. Perform triple verification on the converted functional code (.mlapp format): compare the interface position and display order of the control components in the test panel before and after conversion, verify the binding relationship between the callback function and the control component, and verify the validity of the simulated execution results of the core test logic; The converted .mlapp code is then subjected to triple validation, verifying component layout consistency, callback binding validity, and core logic feasibility to ensure that the converted code is functionally complete and error-free, meeting the requirements of MATLAB AppDesigner. This is to avoid issues such as component layout errors, callback binding failures, and logical anomalies during the code conversion process, ensuring the integrity and stability of the test panel's functionality, and ensuring that the converted .mlapp file is functionally consistent with the original M-script code.

[0054] In practical applications, firstly, the computer device invokes a line-by-line parsing mapping algorithm to parse the M-script code generated in the aforementioned embodiments line by line, accurately identifying class definitions (inherited from the matlab.apps.AppBase class), UI interactive control component definitions, callback functions, and various functional logics within the code, ensuring that no core code fragments are missed. After parsing, these code fragments are mapped into a markup language structure recognizable by MATLAB App Designer, forming independently runnable test panel functional code. Subsequently, the m2mlapp function is called to automatically convert the generated M-script code into .mlapp format. During the conversion process, the system automatically handles format conversion, UI component mapping, callback function conversion, and other tasks, ensuring that the converted .mlapp file is functionally consistent with the original M-script code.

[0055] Secondly, triple validation is performed on the converted .mlapp format functional code to ensure the accuracy and completeness of the code conversion. First, the interface position and display order of the UI interaction control components in the test panel before and after conversion are compared to ensure that the component layout is correct and the order is not reversed, conforming to the layout requirements of the RealTimeScopeApp template. Second, the binding relationship between callback functions and UI interaction control components is verified to ensure that the corresponding callback function is accurately triggered by the change event of each component. Finally, the core test logic is simulated to verify that the core processes such as parameter synchronization and simulation control can run normally and are compatible with the MATLABApp Designer runtime environment.

[0056] In addition, if any problems are found during the verification process, the code conversion step will be automatically returned for re-conversion until all three verifications are passed, ensuring that the generated .mlapp format functional code can stably support the operation of the test panel and can be directly opened, edited and run in MATLAB App Designer.

[0057] In some embodiments, the method for generating a test panel for a simulation model provided in this invention may further include: 5.1. Based on the basic model information corresponding to the verified simulation model to be tested, call the test framework interface (sltest.harness.create function) of the visualization simulation modeling platform (Simulink). Based on the verified Simulink model's basic information, the built-in Simulink function `sltest.harness.create` is called to establish a connection between the function and the model information, providing interface support for the generation of test architecture files. This ensures that the test framework interface can accurately obtain information such as the subsystems and modules of the Simulink model, supporting subsequent operations such as test signal source configuration and module selection, guaranteeing the smooth generation of test architecture files, and adapting to the characteristics of the Simulink test framework.

[0058] 5.2. Based on the configuration instructions input by the user, select the core module to which the nested subsystem or effective constant parameter module (Constant module) of the simulation model to be tested belongs, configure the corresponding test signal source (such as Constant, SineWave, etc.), and bind the control components (such as Scope, ToWorkspace, etc.) used for result reception in the test panel, and generate a standardized test architecture file for simulating specific modules in the simulation model to be tested. Here, responding to user-input configuration commands, the system selects the subsystem or core module to be tested, configures the corresponding test signal source, binds the result receiving component in the test panel, and calls the sltest.harness.create function to integrate all configuration information and generate a standardized test architecture file. This allows for personalized configuration of test rules, and the generated standardized test architecture file can be used in conjunction with the test panel to perform specialized simulation tests on specific modules of the Simulink model. It supports various test scenarios and requirements, improving the relevance and flexibility of testing.

[0059] The specific application is as follows: First, based on the basic information of the verified Simulink model to be tested, the computer device calls the Simulink built-in test framework interface (sltest.harness.create function) through program instructions, so that the function establishes a communication connection with the Simulink model to be tested, ensuring that the function can read relevant information such as the model's subsystems and Constant modules, providing support for subsequent test architecture configuration.

[0060] Secondly, responding to configuration commands input by the user through the interactive interface, the system parses the test objectives contained in the commands, selects a specific nested subsystem in the Simulink model to be tested, or the core module to which the Constant module belongs, and clarifies the target object of the specific test. Then, based on the selected test objective, the system configures the corresponding test signal source. The user can select the signal type (such as Constant, SineWave, etc.) and signal parameters (such as frequency and amplitude) according to the test requirements to complete the configuration of the test signal source.

[0061] In addition, the configured test signal source is bound to the control components (such as Scope, ToWorkspace, etc.) in the test panel used to receive test results, ensuring that the signal data generated during the test can be accurately transmitted to the result receiving component for easy user observation. Finally, the sltest.harness.create function is called to integrate all configuration information, including the selected test module, the configured test signal source, and the bound result receiving component, to generate a standardized test architecture file. This file cannot run independently and must be used in conjunction with the test panel function code for specialized simulation testing of specific modules of the Simulink model, supporting multiple test scenarios.

[0062] Based on the aforementioned embodiments, the method for generating test panels for simulation models can also be visualized, including: 6.1. Based on the functional code (.mlapp format) corresponding to the script code and the test architecture file, generate a visual graphical interface for the test panel; The visual graphical interface includes a left control panel, a central TimeScope display area, and a right status information panel. The left control panel includes simulation control, signal configuration, display settings, and chart configuration. The central TimeScope display area is used to display model signals in real time. The right status information panel displays the simulation status and operation log. The data observation area (central TimeScope display area) displays the core adjustable parameter units of the effective constant parameter module (Constant module) in the simulation model under test. Here, combining the converted .mlapp format functional code from the aforementioned embodiments with the generated test architecture file, a visual graphical interface conforming to the RealTimeScopeApp template is rendered. The interface is divided into three areas: left, center, and right, each implementing a corresponding function. The core adjustable parameters of the Constant module are displayed in the central TimeScope area. In this way, a visual interface that users can directly operate and observe is generated, realizing the integration of test operation and result observation. The real-time display of the core adjustable parameter unit makes it easy for users to accurately grasp the running status of the Simulink model, and the functions are complete and meet the test requirements.

[0063] 6.2. Clean up temporary variables and cache files to release runtime resources; clear temporary variables by calling the clear function and delete temporary files by calling the delete function; By calling the `clear` function in the program to clean up temporary variables generated during the process and calling the `delete` function to delete temporary files, the computer's operating resources are released. This avoids redundant data occupying operating resources, improves the operating efficiency of the computer, ensures the long-term stable operation of the test panel, completes the closed loop of the entire test panel generation process, and provides a good environment for subsequent test panel generation or simulation testing.

[0064] In some embodiments, the computer device first calls the converted .mlapp format test panel function code, and simultaneously reads the standardized test architecture file generated in the aforementioned embodiments. It then combines the interface rendering logic of the function code with the test configuration information in the test architecture file to generate a visual graphical interface for the test panel that conforms to the RealTimeScopeApp template. This interface is divided into three areas: a left control panel containing simulation control, signal configuration, display settings, and chart configuration functions; a central TimeScope display area for real-time display of the Simulink model's signal output; and a right-hand status information panel for displaying simulation status and operation logs. Each UI control component is labeled with its corresponding Constant module name and parameter information. The central TimeScope display area (data observation area) displays the real-time values ​​and operating status of the Constant module's core adjustable parameter units, facilitating intuitive observation of test results by the user.

[0065] Secondly, after the visual graphical interface is generated and delivered to the user, the computer device uses preset resource cleanup instructions to call the clear function to clean up temporary variables generated throughout the process, and calls the delete function to delete redundant data such as temporary files and intermediate code. This redundant data will occupy the computer device's operating resources and may affect the device's operating efficiency and the response speed of the test panel.

[0066] Finally, resource cleanup is performed to free up computer resources, ensuring the test panel can operate stably for a long time and completing the closed loop of the entire test panel generation process. Users can double-click the generated .mlapp file to open the test panel app, adjust the Constant module parameters in real time, observe signal output, and complete the testing of the Simulink model.

[0067] In some embodiments, such as Figure 2 As shown, an embodiment of the present invention provides a test panel generation device for a simulation model, comprising: The acquisition module acquires the basic information of the simulation model to be tested in the visualization simulation modeling platform and verifies whether the simulation model to be tested is in an editable state; wherein, the basic information of the model includes the hierarchical structure of the simulation model to be tested, the hierarchical structure of the multi-level nested subsystems and internal nested modules under the simulation model to be tested; The module determines the module by calling the module retrieval interface of the visualization simulation modeling platform based on the basic information of the model corresponding to the qualified simulation model to be tested, as well as the nesting level set by the user, and controlling the module retrieval interface to traverse the simulation model to be tested and the multi-layer nested subsystem to determine the effective constant parameter module and the full-dimensional structured information of the effective constant parameter module. The generation module, based on the full-dimensional structured information and the preset panel template, constructs the core test logic for responding to changes in the callback function driven by user interaction with the control components, forming script code for generating the test panel.

[0068] The present invention provides an embodiment of an electronic device. In this embodiment, the electronic device may be, but is not limited to, a personal computer (PC), a laptop computer, a monitoring device, a server, or other computer device with analysis and processing capabilities.

[0069] As an exemplary embodiment, see [reference]. Figure 3 The electronic device 110 includes a communication interface 111, a processor 112, a memory 113, and a bus 114. The processor 112, the communication interface 111, and the memory 113 are connected via the bus 114. The memory 113 is used to store a computer program that supports the processor 112 in executing the above-described method. The processor 112 is configured to execute the program stored in the memory 113.

[0070] The machine-readable storage medium mentioned in this article can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, etc. For example, machine-readable storage media can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.

[0071] Non-volatile media can be non-volatile memory, flash memory, storage drives (such as hard disk drives), any type of storage disk (such as optical discs, DVDs, etc.), or similar non-volatile storage media, or combinations thereof.

[0072] It is understood that the specific operation methods of each functional module in this embodiment can be referred to the detailed description of the corresponding steps in the above method embodiment, and will not be repeated here.

[0073] The computer-readable storage medium provided in the embodiments of the present invention stores a computer program. When the computer program code is executed, it can implement the method described in any of the above embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.

[0074] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0075] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms installation, connection, and linking should be interpreted broadly. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to the internal communication between two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0076] In the description of this invention, it should be noted that the terms center, up, down, left, right, vertical, horizontal, inner, and outer, indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms first, second, and third are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0077] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit them. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the scope of the technology disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention.

Claims

1. A test panel generation method for simulation models, characterized by, include: Obtain the basic model information of the simulation model to be tested in the visualization simulation modeling platform; wherein, the basic model information includes the hierarchical structure of the simulation model to be tested, the hierarchical structure of the multi-layered nested subsystems and internal nested modules under the simulation model to be tested; Based on the basic information of the model corresponding to the qualified simulation model to be tested, the module retrieval interface of the visualization simulation modeling platform is called, as well as the nesting level set by the user. The module retrieval interface is controlled to traverse the simulation model to be tested and the multi-layer nested subsystem to determine the effective constant parameter module and the full-dimensional structured information of the effective constant parameter module. Based on the full-dimensional structured information and the preset panel template, the core test logic is constructed to respond to the change event of the user-triggered control component drive callback function, forming the script code used to generate the test panel.

2. The method of claim 1, wherein, Based on the basic model information corresponding to the verified simulation model under test, the module retrieval interface of the visualization simulation modeling platform is invoked, along with the user-defined nesting level. The module retrieval interface is then controlled to traverse the simulation model under test and the multi-layered nested subsystems to determine the valid constant parameter module and its full-dimensional structured information. This process includes: Based on the basic model information corresponding to the verified simulation model to be tested, the module retrieval interface of the visualization simulation modeling platform is called. The target pattern for nesting level is determined in response to user input operation commands; wherein, the target pattern includes a fixed level limitation pattern with a preset maximum retrieval nesting level and an unlimited recursive scanning pattern that automatically identifies the level results of the simulation model under test; Based on the target pattern traversal control parameters, the module retrieval interface is controlled to traverse the simulation model to be tested and the multi-layer nested subsystem according to the rules corresponding to the target pattern to obtain candidate constant parameter modules; The candidate constant parameter modules are subjected to triple verification of visibility, running status, and naming uniqueness through a multi-dimensional screening mechanism. Valid constant parameter modules that pass the verification are retained and their full-dimensional structured information is extracted. The full-dimensional structured information includes the name, path, parameter value, hierarchical level, and adjustable range of the valid constant parameter modules.

3. The method of claim 1, wherein, Based on the comprehensive structured information and the preset panel template, the core test logic for constructing a response to user-triggered change events in the control component's callback function, and the steps for generating the script code for the test panel, include: Build the core test logic: The parameter types and adjustable ranges in the full-dimensional structured information are identified based on a preset panel template. Match the corresponding control component according to the parameter type, establish a mapping relationship between each control component and the corresponding valid constant parameter module, configure the operating range of the control component based on the adjustable range, and generate a change event; The change event and the callback function driven by the change event are bound together to enable the interactive operation of the control component and the real-time synchronization of the model parameters in the effective constant parameter module. The independent code blocks for the newly added testing functions are modularly encapsulated and combined with the core testing logic to form script code for generating test panels.

4. The method of claim 3, wherein, The steps of binding the change event and the callback function driven by the change event to perform real-time synchronization between the interactive operation of the control component and the model parameters in the effective constant parameter module include: The interactive control components of the test panel's operation unit; the binding of the change events with the associated callback functions; In response to the user's interactive operation on the interactive control component, which serves as the operation unit of the test panel, the change event is controlled to trigger the callback function, the latest value of the interactive control component is obtained in real time, and the parameter modification interface of the visualization simulation modeling platform is called to synchronously update the latest value to the corresponding valid constant parameter module according to the mapping relationship.

5. The method of claim 1, wherein, The method further includes: The line-by-line parsing mapping algorithm identifies the class definitions, component definitions, callback functions, and functional logic of the script code line by line, and maps them into a markup language structure compatible with the application designer, forming functional code for a test panel that can be run independently. Perform triple verification on the transformed functional code: compare the interface position and display order of the control components in the test panel before and after the transformation, verify the binding relationship between the callback function and the control component, and verify the validity of the simulated execution results of the core test logic.

6. The method according to claim 1 or 5, characterized in that, The method further includes: Based on the basic model information corresponding to the verified simulation model to be tested, the test framework interface of the visualization simulation modeling platform is called. Based on the configuration instructions input by the user, the nested subsystem corresponding to the simulation model under test or the core module to which the effective constant parameter module belongs is selected, the corresponding test signal source is configured, and the control component for receiving results in the test panel is bound to generate a standardized test architecture file for simulating specific modules in the simulation model under test.

7. The method of claim 6, wherein, The method further includes: Based on the function code corresponding to the script code and the test architecture file, a visual graphical interface for the test panel is generated; wherein, the visual graphical interface includes the control components and the data observation area; the data observation area displays the core adjustable parameter units of the effective constant parameter module in the simulation model under test; Clean up temporary variables and cache files generated, and release runtime resources.

8. A test panel generation device for a simulation model, characterized in that, include: The acquisition module acquires the basic model information of the simulation model to be tested in the visualization simulation modeling platform; wherein, the basic model information includes the hierarchical structure of the simulation model to be tested, the hierarchical structure of the multi-layer nested subsystems and internal nested modules under the simulation model to be tested; The module determines the module by calling the module retrieval interface of the visualization simulation modeling platform based on the basic information of the model corresponding to the qualified simulation model to be tested, as well as the nesting level set by the user, and controlling the module retrieval interface to traverse the simulation model to be tested and the multi-layer nested subsystem to determine the effective constant parameter module and the full-dimensional structured information of the effective constant parameter module. The generation module, based on the full-dimensional structured information and the preset panel template, constructs the core test logic that responds to the change event of the user-triggered control component drive callback function, forming the script code used to generate the test panel.

9. An electronic device, characterized in that, It includes a memory, a processor, and a program stored in the memory and capable of running on the processor, wherein the processor executes the program to implement the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed, implements the method described in any one of claims 1-7.