Component visualization method, device, computer equipment and storage medium
By obtaining and reflecting the class objects and instance objects of the virtual test components on the virtual test platform, dynamically expanding the virtual test components, solving the problem of insufficient scalability of the virtual test platform in the existing technology, realizing flexible loading and display of components, and improving the test efficiency.
Patent Information
- Application Number
- CN202210093614.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-26
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2042-01-26
AI Technical Summary
When adding virtual test components to existing virtual test platforms, they need to modify the code, which leads to poor scalability and the process of increasing the components is time-consuming and labor-intensive, making it difficult to meet the needs of multiple test equipment.
By obtaining the class objects of the virtual test components, reflecting the instance objects, and generating graph node objects and menu item objects on the virtual test platform, dynamic expansion of the virtual test components is achieved and modifications to the platform code are avoided.
It realizes the scalability of the virtual test platform, simplifies the process of adding virtual test components, improves the test efficiency, and can dynamically load and display virtual test components without modifying the platform code.
Smart Images

Figure CN114416266B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of virtual experiment technology, and in particular to a component visualization method, device, computer equipment and storage medium. Background Art
[0002] In recent years, with the continuous development of science and technology, the needs and requirements for weapons and equipment testing and aircraft flight testing have continued to increase.
[0003] In the existing virtual test platform, the virtual test components have been integrated with the platform during the development phase of the platform. The platform can meet the requirements of virtual test tasks when there are fewer types of test equipment.
[0004] However, with the increasing number of test equipment types, due to the low scalability of the virtual test platform, it is necessary to modify the code of the virtual test platform to add virtual test components to the platform, and it is necessary to repeatedly modify the code to ensure that the newly added virtual test components can meet the test requirements. The process of adding new virtual test components is time-consuming and labor-intensive, which is not conducive to the expansion and application of the platform. Summary of the invention
[0005] The purpose of the present invention is to provide a component visualization method, device, computer equipment and storage medium to address the deficiencies in the above-mentioned prior art, so as to realize dynamic expansion of virtual test components on a virtual test platform and improve the scalability of the virtual test platform.
[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0007] In a first aspect, an embodiment of the present application provides a component visualization method, which is applied to a virtual test platform, and the method includes:
[0008] Acquire a class object of a virtual test component, wherein the class object includes: class attributes and class methods of the virtual test component;
[0009] Reflecting the class object to generate an instance object of the virtual test component, wherein the instance object includes: instance attributes corresponding to the class attributes and instance methods corresponding to the class methods;
[0010] Generating a graphic node object on a planning area of the virtual test platform;
[0011] According to the instance method, a menu item object corresponding to the instance method is generated;
[0012] The menu item object and the instance attribute are mapped to the graphic node object, so as to display the virtual test component on the virtual test platform by using the graphic node object.
[0013] Optionally, the obtaining of the class object of the virtual test component includes:
[0014] According to the component type of the virtual test component, a class object corresponding to the component type is obtained from a preset component class object set as the class object of the virtual test component.
[0015] Optionally, before obtaining, according to the component type of the virtual test component, a class object corresponding to the component type from a preset component class object set as the class object of the virtual test component, the method further includes:
[0016] Acquire a class file of the virtual test component, wherein the class file includes: component properties and operation methods of the virtual test component;
[0017] The class file is loaded as the class object and stored in the component class object set.
[0018] Optionally, after generating the graphic node object on the planning area of the virtual test platform, the method further includes:
[0019] According to the component type of the virtual test component, an icon corresponding to the component type is obtained as a component icon;
[0020] The component icon is injected into the graphic node object, so as to display the virtual test component by using the graphic node object according to the component icon.
[0021] Optionally, the method further includes:
[0022] receiving a user's selection operation on a menu item object of the virtual test component;
[0023] According to the target menu item object selected by the selection operation, obtaining the target class method corresponding to the target menu item object from the class object;
[0024] Execute the target class method.
[0025] Optionally, the obtaining of the class file of the virtual test component includes:
[0026] Generate a class diagram of the test equipment using a metamodel according to the property information and equipment functions of the test equipment;
[0027] Using a code converter, converting the class diagram of the test equipment into a test training definition language of the virtual test component;
[0028] Mapping the test training definition language into a virtual test component code corresponding to the virtual test platform;
[0029] Obtaining a filling operation method for attribute information input by a user for the test device;
[0030] The component class file is generated according to the virtual test component code and the filling operation method.
[0031] Optionally, the method further includes:
[0032] Acquire attribute information of the test equipment through a server;
[0033] In response to a modification operation on the attribute information, the attribute information of the test device is modified so that the test device obtains the modified attribute information from the server and updates the attribute information.
[0034] In a second aspect, an embodiment of the present application further provides a component visualization device, which is applied to a virtual test platform, and the device includes:
[0035] A class object acquisition module, used to acquire the class object of the virtual test component, wherein the class object includes: class attributes and class methods of the virtual test component;
[0036] An instance object generation module, used for reflecting the class object to generate an instance object of the virtual test component, wherein the instance object includes: instance attributes corresponding to the class attributes and instance methods corresponding to the class methods;
[0037] A graphic node object generation module, used to generate a graphic node object on the planning area of the virtual test platform;
[0038] A menu item object generation module, used to generate a menu item object corresponding to the instance method according to the instance method;
[0039] A mapping and display module is used to map the menu item object and the instance attribute to the graphic node object, so as to display the virtual test component on the virtual test platform using the graphic node object.
[0040] Optionally, the class object acquisition module is specifically configured to acquire, according to the component type of the virtual test component, a class object corresponding to the component type from a preset component class object set as the class object of the virtual test component.
[0041] Optionally, the device further comprises:
[0042] A class file acquisition module, used to acquire the class file of the virtual test component, wherein the class file includes: component attributes and operation methods of the virtual test component;
[0043] The class object loading module is used to load the class file into the class object and store it in the component class object set.
[0044] Optionally, the device further comprises:
[0045] A component icon acquisition module, used to acquire, according to the component type of the virtual test component, an icon corresponding to the component type as a component icon;
[0046] An icon injection module is used to inject the component icon into the graphic node object, so as to display the virtual test component using the graphic node object according to the component icon.
[0047] Optionally, the device further comprises:
[0048] A selection module, used for receiving a user's selection operation on a menu item object of the virtual test component;
[0049] A class method acquisition module, used for acquiring a target class method corresponding to the target menu item object from the class object according to the target menu item object selected by the selection operation;
[0050] An execution module is used to execute the target class method.
[0051] Optionally, the class file acquisition module includes:
[0052] A class diagram generating unit, used to generate a class diagram of the test equipment using a metamodel according to the attribute information and equipment functions of the test equipment;
[0053] A code conversion unit, used for converting the class diagram of the test equipment into a test training definition language of the virtual test component by using a code converter;
[0054] A code mapping unit, used for mapping the test training definition language into a virtual test component code corresponding to the virtual test platform;
[0055] A filling operation method acquisition unit, used to acquire a filling operation method input by a user for attribute information of the test device;
[0056] The class file generating unit is used to generate the component class file according to the virtual test component code and the filling operation method.
[0057] Optionally, the device further comprises:
[0058] An attribute information acquisition module, used to acquire the attribute information of the test equipment through a server;
[0059] The attribute information modification module is used to respond to the modification operation on the attribute information and modify the attribute information of the test device so that the test device obtains the modified attribute information from the server and updates the attribute information.
[0060] In a third aspect, an embodiment of the present application also provides a computer device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the computer device is running, the processor communicates with the storage medium through the bus, and the processor executes the program instructions to perform the steps of the component visualization method as described in any of the above embodiments.
[0061] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the component visualization method as described in any of the above embodiments are executed.
[0062] The beneficial effects of this application are:
[0063] The present application provides a component visualization method, device, computer equipment and storage medium, which are applied to a virtual test platform. The method includes: obtaining a class object of a virtual test component, wherein the class object includes: class attributes and class methods of the virtual test component, reflecting the class object to generate an instance object of the virtual test component, wherein the instance object includes: instance attributes corresponding to the class attributes and instance methods corresponding to the class methods, generating a graphic node object on the planning area of the virtual test platform, generating a menu item object corresponding to the class method according to the instance method, mapping the menu item object and the instance attributes to the graphic node object, so as to display the virtual test component on the virtual test platform using the graphic node object. Through the present application, the virtual test component and the virtual test platform can be decoupled, so that the virtual test component can be loaded into the virtual test platform when the test is needed, without modifying the code of the virtual test platform, realizing the dynamic expansion of the virtual test component on the virtual test platform, improving the scalability of the virtual test platform, and improving the efficiency of virtual testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0065] Figure 1 A schematic diagram of a component visualization method provided in an embodiment of the present application;
[0066] Figure 2 A schematic diagram of an interface of a virtual test platform provided in an embodiment of the present application;
[0067] Figure 3 A schematic diagram of an interface of another virtual test platform provided in an embodiment of the present application;
[0068] Figure 4 A flowchart of another component visualization method provided in an embodiment of the present application;
[0069] Figure 5 A flowchart of another component visualization method provided in an embodiment of the present application;
[0070] Figure 6 A schematic diagram of the entire process of a component visualization method provided in an embodiment of the present application;
[0071] Figure 7 A flowchart of another component visualization method provided in an embodiment of the present application;
[0072] Figure 8 A flowchart of another component visualization method provided in an embodiment of the present application;
[0073] Fig. 9 A schematic diagram of a flow chart of yet another component visualization method provided in an embodiment of the present application;
[0074] Fig.10 A schematic diagram of the structure of the communication between a virtual test platform and a test device provided in an embodiment of the present application;
[0075] Fig.11 A schematic diagram of the structure of a component visualization device provided in an embodiment of the present application;
[0076] Fig.12 A schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0078] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0079] In the description of the present invention, it should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0080] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0081] Before describing the solution of this application in detail, the virtual test platform used in this application is explained. The virtual test platform runs on computer equipment and is a platform for simulating test environments and test equipment. During the test process of the test equipment, test environments in large areas and multiple regions are involved. The test environments have large spans, long distances, and are independent of each other. It is difficult to complete unified deployment, unified command, and joint testing of the test equipment resources in each test environment. Therefore, by building a virtual test platform, the test environments in multiple different regions can be interconnected for unified management, command, and deployment, and the reuse of resources and information sharing in different test sites can be achieved.
[0082] In order to introduce test equipment resources into a virtual test platform, the present application provides a component visualization method, apparatus, computer equipment and storage medium to dynamically introduce the test equipment into the virtual test platform in the form of a virtual test component.
[0083] The following is a detailed description of a component visualization method, apparatus, computer device and storage medium provided in the present application.
[0084] Please refer to Figure 1 , is a flow chart of a component visualization method provided in an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0085] S20: Acquire the class object of the virtual test component, wherein the class object includes: class attributes and class methods of the virtual test component.
[0086] In this embodiment, a class object of a virtual test component is generated in advance by coding according to the attribute information and device functions of the test device. The virtual test component is used to represent the test device in the virtual test platform. The class object of the virtual test component includes: class attributes and class methods of the virtual test component, wherein the class attributes represent the attribute information of the test device, the class methods represent the device functions of the test device and the filling operation method of the attribute information, and the filling operation method of the attribute information is the operation method pre-entered for the attribute information, and is used to represent the method executed for the attribute information, such as the modification of the attribute information, etc. The class object of the virtual test component is stored at a preset location. When it is necessary to generate a virtual test component corresponding to the test device on the virtual test platform, the class object of the virtual test component can be obtained from the preset location.
[0087] S30: Reflecting the class object to generate an instance object of the virtual test component, wherein the instance object includes: instance attributes corresponding to the class attributes and instance methods corresponding to the class methods.
[0088] In this embodiment, the class attributes of the virtual test component are specified in the class object, but on the virtual test platform, it is not possible to assign values to the class attributes or change the attribute information of the class attributes through the class object. The class object needs to be reflected as an instance object to convert the class attributes into instance attributes and the class methods into instance methods, so as to realize the assignment of attributes of the virtual test component through instance attributes.
[0089] In an optional implementation, the class object may be reflected as an instance object via the newInstance() method.
[0090] For examples, please refer to Figure 2 , is a schematic diagram of an interface of a virtual test platform provided in an embodiment of the present application, such as Figure 2 As shown, the virtual test component in the planning area is a virtual radar component. The virtual radar component has a name attribute. The class object of the virtual radar component only stipulates that the virtual radar component has a name attribute. After the reflection generates an instance object, the name attribute can be assigned in the attribute modification area, such as setting the name of the virtual radar component to radar 1.
[0091] S40: Generate a graphic node object on the planning area of the virtual test platform.
[0092] In this embodiment, in order to facilitate the use of virtual test components for virtual tests, it is necessary to display the virtual test components in the virtual test platform. This embodiment generates a graphic node object for each instance object in the planning area of the virtual test platform. The graphic node object is used to represent the object of the virtual test component in the planning area, and each graphic node object has a corresponding instance object.
[0093] In an optional implementation, a Zest framework-based graphic node object may be generated for each instance object.
[0094] S50: According to the instance method, a menu item object corresponding to the instance method is generated.
[0095] In this embodiment, all instance methods of the virtual test component are obtained from the instance object, a corresponding menu item object is generated for each instance method, and a reflection calling mechanism is set for each menu item object. That is, when the menu item object to be executed is selected in the planning area, the reflection calling mechanism is used to obtain the class method corresponding to the menu item object from the class object to execute the corresponding class method.
[0096] For examples, please refer to Figure 3 , is a schematic diagram of an interface of another virtual test platform provided in an embodiment of the present application, such as Figure 3 As shown, the virtual GPS (Global Positioning System) device component has multiple menu item objects, such as power on, power off, record data, import data, receive on, receive off, and each menu item object corresponds to a device function of the test device.
[0097] S60: Map the menu item object and the instance attribute to the graphic node object, so as to display the virtual test component on the virtual test platform by using the graphic node object.
[0098] In this embodiment, the aforementioned S30-S50 respectively generate instance attributes, graphic user nodes and menu item objects of the virtual test component. It is necessary to map the menu item objects and instance attributes to the graphic node objects to establish a corresponding relationship between the graphic user nodes and the instance attributes and menu item objects, so as to display the virtual test components on the virtual test platform using graphic user nodes, and the graphic user nodes have the attribute information and device functions of the test equipment corresponding to the virtual test components.
[0099] In an optional implementation manner, the above S20 includes:
[0100] According to the component type of the virtual test component, a class object corresponding to the component type is obtained from a preset component class object set as the class object of the virtual test component.
[0101] In this embodiment, the preset component class object set includes class objects of multiple component types, and the multiple component types are displayed in the component class object display area of the virtual test platform. The user selects the component type required for the test from the component type display area, and obtains the class object corresponding to the component type from the component class object set as the class object of the virtual test component based on the component type of the virtual test component selected by the user.
[0102] For example, Figure 2 or Figure 3 As shown, a variety of component types are displayed in the component class object collection, and the component type can be specifically represented by a component icon corresponding to each component type.
[0103] The component visualization method provided by the embodiment of the present application is applied to a virtual test platform, and the method includes: obtaining a class object of a virtual test component, wherein the class object includes: class attributes and class methods of the virtual test component, reflecting the class object to generate an instance object of the virtual test component, wherein the instance object includes: instance attributes corresponding to the class attributes and instance methods corresponding to the class methods, generating a graphic node object on the planning area of the virtual test platform, generating a menu item object corresponding to the class method according to the instance method, mapping the menu item object and the instance attributes to the graphic node object, so as to display the virtual test component on the virtual test platform using the graphic node object. Through the embodiment of the present application, the virtual test component and the virtual test platform can be decoupled, so that the virtual test component can be loaded into the virtual test platform when the test is needed, without modifying the code of the virtual test platform, and realizing the dynamic expansion of the virtual test component on the virtual test platform, thereby improving the scalability of the virtual test platform and improving the efficiency of virtual testing.
[0104] Based on the above embodiments, the present application also provides a component visualization method. Figure 4 , which is a flow chart of another component visualization method provided in an embodiment of the present application, such as Figure 4 As shown, before obtaining the class object from the component class object collection, the method further includes:
[0105] S11: Acquire a class file of a virtual test component, wherein the class file includes: component properties and operation methods of the virtual test component.
[0106] In this embodiment, the class file of the virtual test component is generated by coding in advance according to the attribute information and device functions of the test device, and the class file includes: the component attributes and operation methods of the virtual test component, and the class file of the virtual test component is stored in a preset path. After the virtual test platform is started, the preset path is loaded into the virtual test platform to scan the class files under the preset path to obtain the class files of the virtual test component.
[0107] S12: Load the class file as a class object and store it in a component class object collection.
[0108] In this embodiment, since the virtual test platform cannot directly identify the virtual test component from the class file, the class file needs to be loaded as a class object, so that the virtual test component can be identified outside the virtual test platform and the class object can be converted into an instance object. After the class file is loaded as a class object, the class object is stored in a component class object set, so that the class object of the virtual test component can be obtained from the component class object set according to the component type.
[0109] In an optional implementation, the Class.forName() method may be used to load a class file as a class object.
[0110] The component visualization method provided in the embodiment of the present application obtains the class file of the virtual test component, wherein the class file includes: component attributes and operation methods of the virtual test component, and loads the class file as a class object and stores it in a component class object collection. The embodiment of the present application decouples the virtual test component from the virtual test platform, so that when the test requires, the class file is loaded as a class object to load the virtual test component into the virtual test platform, thereby realizing dynamic expansion of the virtual test component on the virtual test platform and improving the scalability of the virtual test platform.
[0111] Based on the above embodiments, the present application also provides a component visualization method. Figure 5 , which is a flow chart of another component visualization method provided in an embodiment of the present application, such as Figure 5 As shown, after S30, the method further includes:
[0112] S71: According to the component type of the virtual test component, an icon corresponding to the component type is obtained as a component icon.
[0113] In this embodiment, in addition to storing the class files of the virtual test components, the preset path also stores the component icons of the virtual test components, and the class files and the component icons together constitute a complete virtual test component. In addition to loading the class files from the preset path to the virtual test platform, the component type is determined according to the class files, and the component type and the address of the component icon constitute a key-value pair, wherein the component type is the key and the address of the component icon is the value.
[0114] The user selects the component type required for the test from the component type display area to determine the address of the component icon corresponding to the component type based on the component type and key-value pair of the virtual test component selected by the user, and obtain the component icon and the name of the component icon from the address of the component icon.
[0115] S72: Inject the component icon into the graphic node object to display the virtual test component using the graphic node object according to the component icon.
[0116] In this embodiment, in order to enable each graphic node object to be displayed according to the component icon of the virtual test component, the name of the component icon and the component icon are set to the corresponding attributes of the graphic node object, so that the graphic node object displays the virtual test component with the component icon, thereby completing the visualization of the virtual test component.
[0117] In an optional implementation, two component icons of different sizes of virtual test components are stored in a preset path. After the virtual test platform is started, the preset path is loaded into the virtual test platform, the small component icons under the preset path are scanned, the component type is displayed according to the small component icon in the component class object display area, and the large component icon is set to the corresponding attribute of the graphic node object.
[0118] The component visualization method provided in the embodiment of the present application obtains the icon corresponding to the component type as the component icon according to the component type of the virtual test component, and injects the component icon into the graphic node object, so as to display the virtual test component according to the component icon using the graphic node object. Through the embodiment of the present application, each virtual test component can be displayed in the virtual test platform according to the corresponding component icon, so that the user can determine the type of the virtual test component according to the component icon, thereby improving the test efficiency.
[0119] Based on the above examples, please refer to Figure 6 , which is a schematic diagram of the entire process of a component visualization method provided in an embodiment of the present application, such as Figure 6 As shown, after the virtual test platform is started, the preset path where the virtual test component is located is loaded, the class file and component icon are scanned from the preset path, the class file is loaded as a class object using the Class.forName() method, and stored in the component class object collection, and the key-value pair consisting of the component icon address and the component type is saved in the hash table (HashMap).
[0120] According to the component type input by the user, the class object corresponding to the component type is obtained from the component class object collection, and the class object is reflected as an instance object through the newInstance() method. The class method to be executed is obtained from the class object using the getDeclaredMethod reflection method, and a corresponding menu item object is generated for each instance method in the instance object, and the class method is injected into the corresponding menu item object. At the same time, a graph node object is generated for each instance object in the planning area of the virtual test platform, and the instance attribute (data attribute) and the Image attribute of the component icon are injected into the graph node object, and the graph node object and the menu item object are mapped to display the virtual test component on the virtual test platform.
[0121] Based on the above embodiments, the present application also provides a component visualization method. Figure 7 , which is a flow chart of another component visualization method provided in an embodiment of the present application, such as Figure 7 As shown, the method also includes:
[0122] S81: receiving a user's selection operation on a menu item object of a virtual test component.
[0123] In this embodiment, the user selects a virtual test component in the planning area of the virtual test platform, views at least one menu item object corresponding to the virtual test component, and selects a target menu item object from the at least one menu item object.
[0124] S82: According to the target menu item object selected by the selection operation, a target class method corresponding to the target menu item object is obtained from the class object.
[0125] In this embodiment, according to the target menu item object selected by the selection operation, the target class method corresponding to the target menu item object is obtained from the class object of the virtual test component by executing the getMethod method.
[0126] S83: Execute the target class method.
[0127] In this embodiment, after the target class method corresponding to the target menu item object is acquired, the target class method is executed, and the test function of the test equipment corresponding to the target class method can be executed on the virtual test component.
[0128] For example, the virtual test component is a virtual radar component, the target menu item object is power on, and the class method corresponding to power on is obtained from the class object of the virtual radar component. The class method is executed to power on the virtual radar component.
[0129] The component visualization method provided in the embodiment of the present application receives a user's selection operation on a menu item object of a virtual test component, obtains a target class method corresponding to the target menu item object from a class object according to the target menu item object selected in the selection operation, and executes the target class method. Through the embodiment of the present application, the virtual test component can simulate the device function of the test device to realize a virtual test on the test device.
[0130] Based on the above embodiments, the present application also provides a component visualization method. Figure 8 , which is a flow chart of yet another component visualization method provided in an embodiment of the present application, such as Figure 8 As shown, the above S11 includes:
[0131] S111: Generate a class diagram of the test equipment using a metamodel based on the property information and equipment functions of the test equipment.
[0132] In this embodiment, a Unified Modeling Language (UML) class diagram supported by TDL syntax is created based on a metamodel. The UML class diagram consists of three parts. The first part is the class name, which can represent the name of the test equipment. The second part is the attribute of the class, which is used to represent the attribute information of the test equipment. The third part is the operation of the class, which is used to represent the equipment function of the test equipment.
[0133] S112: Using a code converter, convert the class diagram of the test equipment into a test training definition language of the virtual test component.
[0134] Specifically, after generating the class diagram of the test equipment, it is necessary to convert the class diagram of the test equipment into code. In this embodiment, a code converter is used to convert the class diagram into a test training definition language. The full name of the test training enabling architecture DefineLanguage is the test training enabling architecture definition language, which can also be called TDL code.
[0135] S113: Mapping the test training definition language into a virtual test component code corresponding to the virtual test platform.
[0136] In this embodiment, based on the generated test training definition language, a mapping mechanism between the test training definition language and the virtual test platform is constructed to convert the test training definition language into a virtual test component code that can be recognized by the virtual test platform. For example, the virtual test component agent is a Java code.
[0137] In an optional implementation, the code generator in the FreeMaker template engine is used to convert the code string beginning with TENA:: in the trial training definition language into Java code.
[0138] The code generator includes: a Java class generator, a property generator and a method generator. The property generator identifies the property code from the test training definition language, and the method generator identifies the method code from the test training definition language. The Java class generator converts both the property code and the method code into Java code. In this embodiment, the FreeMaker template engine is integrated into the UML class diagram generation software in the form of a plug-in. Therefore, the code generator exists as a code generation plug-in in the UML class diagram generation software.
[0139] S114: Obtaining a filling operation method for the attribute information input by the user for the test equipment.
[0140] In this embodiment, the developer uses the Eclipse development platform to fill in the code for the attribute information of the virtual test component according to the attribute information of the virtual test component and the business logic requirements related to the attribute information. By filling in the Getter and Setter methods related to the attribute information, it is possible to execute related functions for the attribute information of the virtual test component. For example, the setName method can provide the function of changing the name for the name attribute.
[0141] S115: Generate a component class file according to the virtual test component code and the filling operation method.
[0142] In this embodiment, the virtual test resource code and the filling operation method are compiled into a component class file using a Java compilation tool so that they can be run on different virtual test platforms. The generated component class file and two component icon files together constitute a complete virtual test component.
[0143] In an optional implementation, when a new virtual test component needs to be added to the virtual test platform, it is only necessary to add a new component class file to the preset path; when a virtual test component needs to be deleted from the virtual test platform, it is only necessary to delete the component class file from the preset path and restart the virtual test platform. There is no need to modify the virtual test platform, thereby realizing dynamic expansion of virtual test components in the virtual test platform.
[0144] The component visualization method provided in the embodiment of the present application generates a class diagram of the test equipment using a metamodel according to the attribute information and device functions of the test equipment, converts the class diagram of the test equipment into a test training definition language of the virtual test component using a code converter, maps the test training definition language into a virtual test component code corresponding to the virtual test platform, obtains the filling operation method input by the user for the attribute information of the test equipment, and generates a component class file according to the virtual test component code and the filling operation method. The component class file of each virtual test component is generated by the embodiment of the present application to decouple the virtual test component from the virtual test platform, and the virtual test component is loaded into the virtual test platform only when the test is needed, without modifying the code of the virtual test platform, so as to realize the dynamic expansion of the virtual test component on the virtual test platform and improve the scalability of the virtual test platform.
[0145] Based on the above embodiments, the present application also provides a component visualization method. Fig. 9 , which is a flow chart of yet another component visualization method provided in an embodiment of the present application, such as Fig. 9 As shown, the method also includes:
[0146] S91: Obtaining attribute information of the test equipment through the server.
[0147] For examples, please refer to Fig.10 , is a structural diagram of a virtual test platform and a test device communicating with each other provided in an embodiment of the present application, such as Fig.10 As shown, in this embodiment, the virtual test component and the test device communicate through a server, such as an ActiveMQ server. The test device sends its own attribute information to the server regularly, and the virtual test platform obtains the attribute information from the server regularly and parses and displays it.
[0148] S92: In response to the modification operation on the attribute information, modify the attribute information of the test device so that the test device obtains the modified attribute information from the server and updates the attribute information.
[0149] In this embodiment, the virtual test platform receives a modification operation input by a user for the attribute information of the virtual test component, and modifies the attribute information of the virtual test component. After the virtual test platform modifies the attribute information of the virtual test component, the virtual test component sends the modified attribute information to the server, and multiple test devices connected to the server in communication obtain the modified attribute information from the server and parse the attribute information. If it is determined that the target test device corresponding to the attribute information is itself, the attribute information of itself is updated to the modified attribute information.
[0150] The component visualization method provided in the embodiment of the present application obtains the attribute information of the test equipment through the server, responds to the modification operation on the attribute information, modifies the attribute information of the test equipment, so that the test equipment obtains the modified attribute information from the server and updates the attribute information. Through the embodiment of the present application, the attribute information of the test equipment can be remotely obtained, and the attribute information of the test equipment can also be remotely modified, thereby improving the efficiency of virtual testing.
[0151] Based on the above embodiments, the present application also provides a virtual device for an application component visualization method. Fig.11 , is a structural diagram of a component visualization device provided in an embodiment of the present application, such as Fig.11 As shown, the device comprises:
[0152] The class object acquisition module 10 is used to acquire the class object of the virtual test component, wherein the class object includes: class attributes and class methods of the virtual test component;
[0153] The instance object generation module 20 is used to generate instance objects of virtual test components by reflecting class objects, wherein the instance objects include: instance attributes corresponding to class attributes and instance methods corresponding to class methods;
[0154] A graphic node object generation module 30 is used to generate a graphic node object on the planning area of the virtual test platform;
[0155] A menu item object generating module 40, for generating a menu item object corresponding to the instance method according to the instance method;
[0156] The mapping and display module 50 is used to map the menu item objects and instance attributes to the graphic node objects, so as to display the virtual test components on the virtual test platform by using the graphic node objects.
[0157] Optionally, the class object acquisition module 10 is specifically configured to acquire, according to the component type of the virtual test component, a class object corresponding to the component type from a preset component class object set as the class object of the virtual test component.
[0158] Optionally, the device further comprises:
[0159] A class file acquisition module is used to acquire the class file of the virtual test component, wherein the class file includes: component attributes and operation methods of the virtual test component;
[0160] The class object loading module is used to load class files into class objects and store them in the component class object collection.
[0161] Optionally, the device further comprises:
[0162] A component icon acquisition module is used to acquire an icon corresponding to a component type as a component icon according to the component type of the virtual test component;
[0163] The icon injection module is used to inject the component icon into the graphic node object so as to display the virtual test component by using the graphic node object according to the component icon.
[0164] Optionally, the device further comprises:
[0165] A selection module, used for receiving a user's selection operation on a menu item object of a virtual test component;
[0166] The class method acquisition module is used to acquire the target class method corresponding to the target menu item object from the class object according to the target menu item object selected by the selection operation;
[0167] Execution module, used to execute the target class method.
[0168] Optional, class file acquisition module, including:
[0169] A class diagram generating unit, used for generating a class diagram of the test equipment by using a meta model according to the attribute information and equipment functions of the test equipment;
[0170] A code conversion unit, used for converting the class diagram of the test equipment into a test training definition language of the virtual test component by using a code converter;
[0171] A code mapping unit, used for mapping the test training definition language into a virtual test component code corresponding to the virtual test platform;
[0172] A filling operation method acquisition unit, used to acquire a filling operation method input by a user for attribute information of a test device;
[0173] The class file generation unit is used to generate a component class file according to the virtual test component code and the filling operation method.
[0174] Optionally, the device further comprises:
[0175] An attribute information acquisition module, used to acquire attribute information of the test equipment through a server;
[0176] The attribute information modification module is used to respond to the modification operation on the attribute information and modify the attribute information of the test equipment so that the test equipment obtains the modified attribute information from the server and updates the attribute information.
[0177] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0178] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system on chip (SoC).
[0179] Please refer to Fig.12, is a schematic diagram of a computer device provided in an embodiment of the present application, the computer device 100 includes: a processor 101, a storage medium 102 and a bus, the storage medium 102 stores program instructions executable by the processor 101, when the computer device 100 is running, the processor 101 and the storage medium 102 communicate through the bus, and the processor 101 executes the program instructions to execute the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.
[0180] Optionally, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor at runtime, it is used to execute the above method embodiment.
[0181] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0182] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0183] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0184] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: Processor) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.
[0185] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A component visualization method, characterized in that: Applied to a virtual test platform, the method comprises: Acquire a class file of a virtual test component, wherein the class file includes: component properties and operation methods of the virtual test component; Loading the class file as a class object and storing it in a component class object collection; Acquire the class object of the virtual test component from the component class object set, wherein the class object includes: class attributes and class methods of the virtual test component, the class attributes represent attribute information of the test device, the class methods represent device functions of the test device and a filling operation method of the attribute information; Reflecting the class object to generate an instance object of the virtual test component, wherein the instance object includes: instance attributes corresponding to the class attributes and instance methods corresponding to the class methods; Generating a graphic node object on a planning area of the virtual test platform; According to the instance method, a menu item object corresponding to the instance method is generated; Mapping the menu item object and the instance attribute to the graphic node object, so as to display the virtual test component on the virtual test platform using the graphic node object, wherein the graphic node object has the attribute information and device function of the test device corresponding to the virtual test component; The method further comprises: receiving a user's selection operation on a menu item object of the virtual test component; According to the target menu item object selected by the selection operation, obtaining the target class method corresponding to the target menu item object from the class object; Execute the target class method.
2. The method according to claim 1, characterized in that The step of obtaining the class object of the virtual test component includes: According to the component type of the virtual test component, a class object corresponding to the component type is obtained from a preset component class object set as the class object of the virtual test component.
3. The method according to claim 2, characterized in that After generating the graphic node object on the planning area of the virtual test platform, the method further includes: According to the component type of the virtual test component, an icon corresponding to the component type is obtained as a component icon; The component icon is injected into the graphic node object, so as to display the virtual test component by using the graphic node object according to the component icon.
4. The method according to claim 1, characterized in that The step of obtaining the class file of the virtual test component includes: Generate a class diagram of the test equipment using a metamodel according to the property information and equipment functions of the test equipment; Using a code converter, converting the class diagram of the test equipment into a test training definition language of the virtual test component; Mapping the test training definition language into a virtual test component code corresponding to the virtual test platform; Obtaining a filling operation method for attribute information input by a user for the test device; The component class file is generated according to the virtual test component code and the filling operation method.
5. The method according to claim 4, characterized in that The method further comprises: Acquire attribute information of the test equipment through a server; In response to a modification operation on the attribute information, the attribute information of the test device is modified so that the test device obtains the modified attribute information from the server and updates the attribute information.
6. A component visualization device, characterized in that: Applied to a virtual test platform, the device comprises: A class file acquisition module, used to acquire a class file of a virtual test component, wherein the class file includes: component attributes and operation methods of the virtual test component; A class object loading module, used for loading the class file into a class object and storing it in a component class object collection; A class object acquisition module, used to acquire the class object of the virtual test component from the component class object set, wherein the class object includes: class attributes and class methods of the virtual test component, the class attributes represent the attribute information of the test equipment, the class methods represent the equipment functions of the test equipment and the filling operation method of the attribute information; An instance object generation module, used for reflecting the class object to generate an instance object of the virtual test component, wherein the instance object includes: instance attributes corresponding to the class attributes and instance methods corresponding to the class methods; A graphic node object generation module, used to generate a graphic node object on the planning area of the virtual test platform; A menu item object generation module, used to generate a menu item object corresponding to the instance method according to the instance method; A mapping display module, used for mapping the menu item object and the instance attribute to the graphic node object, so as to display the virtual test component on the virtual test platform by using the graphic node object, wherein the graphic node object has the attribute information and device function of the test device corresponding to the virtual test component; The device also includes: A selection module, used for receiving a user's selection operation on a menu item object of the virtual test component; A class method acquisition module, used for acquiring a target class method corresponding to the target menu item object from the class object according to the target menu item object selected by the selection operation; An execution module is used to execute the target class method.
7. A computer device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the computer device is running, the processor and the storage medium communicate via the bus, and the processor executes the program instructions to perform the steps of the component visualization method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the component visualization method according to any one of claims 1 to 5 are executed.
Citation Information
Patent Citations
Lightweight virtual test range object model component construction method
CN110705091A