A graphical user interface generation method and device
By generating deletion, deletion, deletion, deletion, deletion, deletion, and deletion interface layout files based on the protocol interface definition document in the UAV ground detection software, the problems of low development efficiency and difficult interface adjustment are solved, and the automatic generation of interface layout and control collection is realized. Improved user experience and system maintainability.
Patent Information
- Application Number
- CN202410946895.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-16
AI Technical Summary
The development efficiency of the existing graphical user interface of UAV ground detection software is low, the probability of manual software failure is high, and it is difficult to flexibly adjust the interface layout and control style to adapt to the needs of different UAVs.
By generating an initial protocol definition configuration file based on the protocol interface definition document, adding data class tags, obtaining the current interface layout file, determining the target position of the data class in the interface, dynamically generating a collection of controls to form the final interface layout file, and realizing the automation of interface design. and flexibility.
It improves the efficiency and accuracy of protocol definition, reduces the tediousness and errors of manually writing configuration files, enhances the intuitiveness and flexibility of interface design, reduces development costs and the possibility of errors, and ensures the consistency and beauty of the interface. , adapt to different data structures and display needs.
Smart Images

Figure CN118484191B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method and device for generating a graphical user interface. Background Art
[0002] UAV ground detection software is an indispensable part of the UAV development process. It is responsible for real-time monitoring, status detection and parameter calibration of the UAV to ensure the safety and stability of the UAV when performing tasks. This type of software usually includes three modules: data parsing unit, data display unit and data transmission coding unit. The graphical user interface (GUI) serves as a bridge for users to interact with the software. Its development quality directly affects the user experience and the overall performance of the software. The main functions of this type of software include setting specific parameter combinations for the UAV, obtaining feedback information after setting, completing the status detection of the UAV and calibrating the parameters for specific flight missions.
[0003] In the development of the graphical user interface of the UAV ground detection software, two main technical methods are currently used. 1. Manually arrange the control combination and write the interface layout file: Based on the interface definition document of the UAV ground detection protocol, the developer uses the interface development tool to manually arrange the control combination in a WYSIWYG manner and write the corresponding interface layout file. 2. Dynamically create a graphical user interface based on the configuration file: The developer writes the configuration file based on the interface definition document to define the parsing and display methods of the data. At runtime, the target program uses a unified configuration parsing engine to dynamically create a graphical user interface based on the content of the configuration file.
[0004] However, the development efficiency of existing technologies is low, the probability of artificially introducing software failures is high, and it is difficult to flexibly adjust the interface layout and control style to meet the needs of different specific drones. Summary of the invention
[0005] In an embodiment of the present application, a graphical user interface generation method is provided to solve the problems of low development efficiency of the prior art, high probability of artificially introducing software failures, and difficulty in flexibly adjusting the interface layout and control style to meet the needs of different specific drones.
[0006] In the first aspect, an embodiment of the present application provides a method for generating a graphical user interface, the method comprising: generating an initial protocol definition configuration file based on a protocol interface definition document; adding data class tags to fields in the initial protocol definition configuration file to generate a final protocol definition configuration file; wherein the data class corresponds to a sub-area in the graphical user interface; obtaining a current interface layout file as the initial interface layout file; determining a target position of each data class in the initial interface layout file and a corresponding interface generation template based on a data binding file; generating a corresponding control set for the fields under each data class in the final protocol definition configuration file based on preset generation rules in the file of the interface generation template; and adding the control set to the corresponding target position in the initial interface layout file to form a final interface layout file.
[0007] In a possible implementation, the target location includes the corresponding initial interface layout file name and the parent control name of the displayed location.
[0008] In a possible implementation, the data binding file further includes an operation strategy before generation, and the operation strategy includes whether to clear all child items of the target parent control container.
[0009] In a possible implementation, the interface generation template includes a name and parameters, the name includes one or more control types, and the parameters are used to determine the number of columns of the generation unit and the column where each control type is located.
[0010] In one possible implementation, the generating of the initial protocol definition configuration file based on the protocol interface definition document includes: reading the protocol interface definition document; identifying target data in the protocol interface definition document according to a preset data definition, and converting the target data into data of a first data structure; and formatting the data of the first data structure to generate the initial protocol definition configuration file.
[0011] In a possible implementation, the fields under each data class in the final protocol definition configuration file are generated into a corresponding control set based on the preset generation rules in the file of the interface generation template, including: reading the final protocol definition configuration file and aggregating based on the data class label; converting each aggregated data class into a corresponding first multi-branch tree; obtaining the preset generation rules of the corresponding data class in the file of the interface generation template; and generating a control tree corresponding to the corresponding first multi-branch tree as a control set based on the preset generation rules.
[0012] In a possible implementation, the adding of the control set to the corresponding target position in the initial interface layout file to form a final interface layout file includes: generating an initial multi-branch tree based on the initial interface layout file, and generating corresponding access path identifiers for the control container nodes in the interface layout file to form an association table of control names and corresponding access path identifiers, wherein each control container corresponds to a data class; obtaining the control name corresponding to the control tree; querying the access path identifier corresponding to the control name based on the association table; adding the control tree to the corresponding control container node of the initial multi-branch tree based on the access path identifier to form a final multi-branch tree; and generating a final interface layout file based on the final multi-branch tree.
[0013] In a possible implementation, the data class label includes multiple layers of classification names from high to low.
[0014] In the second aspect, an embodiment of the present application provides a graphical user interface generation device, which includes: a file generation module, which is used to generate an initial protocol definition configuration file based on a protocol interface definition document; a label adding module, which is used to add data class labels to the fields in the initial protocol definition configuration file to generate a final protocol definition configuration file, wherein the data class corresponds to a sub-area in the graphical user interface; an acquisition module, which is used to acquire the current interface layout file as the initial interface layout file; a determination module, which is used to determine the target position of each data class in the initial interface layout file and the corresponding interface generation template based on the data binding file; a collection generation module, which is used to generate a corresponding control set for the fields under each data class in the final protocol definition configuration file based on the preset generation rules in the file of the interface generation template; and an adding position module, which is used to add the control set to the corresponding target position in the initial interface layout file to form a final interface layout file.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores executable instructions, and when a computer executes the executable instructions, the method described in the first aspect or any possible implementation method of the first aspect can be implemented.
[0016] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects:
[0017] The embodiment of the present application provides a graphical user interface generation method, which generates an initial protocol definition configuration file based on a protocol interface definition document, significantly improves the efficiency and accuracy of the protocol definition, and reduces the tediousness and errors of manually writing configuration files. By adding a data class tag to the field of the protocol definition configuration file, a direct mapping of the data class and the graphical user interface sub-area is achieved. This mapping makes the interface design more intuitive and convenient for developers to understand and maintain. The current interface layout file is obtained as the initial layout, and the target position of the data class in the interface is determined in combination with the data binding file, so that the interface layout is more flexible. Developers can adjust the position of the data class as needed to quickly adapt to different interface design requirements. According to the preset generation rules in the data class field in the final protocol definition configuration file and the file of the interface generation template, the corresponding control set is dynamically generated. This dynamic generation method makes interface development more flexible and can adapt to different data structures and display requirements. By automatically generating interface layout files and control sets, the workload of developers is reduced and the development cost is reduced. At the same time, since the link of manually writing code is reduced, the possibility of errors is also reduced. Due to the clear and clear mapping relationship between the data class and the graphical interface sub-area, and the mechanism of dynamically generating controls, the entire system is easy to expand and maintain. When the protocol or interface changes, you only need to update the corresponding configuration file or template file to quickly adapt to the new requirements. Through the automatically generated interface layout and control set, the consistency and aesthetics of the interface can be ensured, and the user experience can be improved. At the same time, since the control set is dynamically generated according to the data class field, the accuracy of the data can be ensured. The development efficiency problem of manually editing the graphical interface is solved, and the problem of manually editing the graphical interface easily introducing software defects is avoided. In addition, compared with a method of using a text configuration file with a DSL (English: Domain Specific Language Chinese: Domain Specific Language) effect to directly control the target program to present a graphical user interface, this solution can conveniently and flexibly adjust the interface layout and support various personalized customization controls. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments of the present application or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 A flowchart of a method for generating a graphical user interface provided in an embodiment of the present application;
[0020] Figure 2A specific flow chart for generating an initial protocol definition configuration file based on a protocol interface definition document provided in an embodiment of the present application;
[0021] Figure 3 A specific flow chart for generating a corresponding set of controls based on the preset generation rules in the interface generation template file for the fields under each data class in the final protocol definition configuration file provided in the embodiment of the present application;
[0022] Figure 4 A specific flow chart of adding a control set to a corresponding target position in an initial interface layout file to form a final interface layout file provided in an embodiment of the present application;
[0023] Figure 5 A schematic diagram of the relationship between the data class and the graphical user interface provided in the embodiment of the present application;
[0024] Figure 6 A schematic diagram of an initial interface layout without content provided in an embodiment of the present application;
[0025] Figure 7 A schematic diagram of an initial interface layout with content provided in an embodiment of the present application;
[0026] Figure 8 A schematic diagram of possible content interfaces of the initial interface layout file provided in an embodiment of the present application;
[0027] Fig. 9 A schematic diagram of a tree structure corresponding to the contents of the initial interface layout file provided in an embodiment of the present application;
[0028] Fig.10 A schematic diagram of a tree structure of converting each aggregated data class into a corresponding first multi-branch tree provided in an embodiment of the present application;
[0029] Fig.11 A schematic diagram of the tree structure of the initial interface layout file corresponding to the data class provided in the embodiment of the present application;
[0030] Fig.12 A schematic diagram of the interface layout and the control tree provided in an embodiment of the present application;
[0031] Fig.13 A schematic diagram of a first result of a generation interface provided in an embodiment of the present application;
[0032] Fig.14 A schematic diagram of a second result of the generation interface provided in an embodiment of the present application;
[0033] Fig.15 A schematic diagram of a graphical user interface generation device provided in an embodiment of the present application;
[0034] Fig.16 A schematic diagram of a graphical user interface generation server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0036] The following describes some of the techniques involved in the embodiments of the present application to facilitate understanding, and they should be considered as merely exemplary. Therefore, it should be appreciated by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, some descriptions of well-known functions and structures are omitted in the following description.
[0037] The ground detection data of the UAV system is usually composed of multiple data frames, including the measurement information, status information, fault information, etc. of the UAV's onboard equipment, which are encoded into the UAV's detection data frame and sent to the ground detection system at a certain period. One of the main responsibilities of the ground detection system is to intuitively and accurately reflect the measurement data and status of the UAV in the ground detection process. In the process of ground detection software development, a data frame communication protocol document is generally provided, which is usually called an interface definition document (ICD). The inspection data frame defined in the UAV interface definition document is usually composed of multiple data frames and multiple data fields within the frame. Due to the limitation of the maximum frame length, the data and status of a device are usually scattered in multiple data frames. In the protocol frame configuration file, each field is associated with a data class label. The purpose of the data class label is to facilitate the aggregation of related fields to form a virtual data class.
[0038] The ground detection data of the UAV system involves the transmission of multiple data frames, which contain various key information of the UAV onboard equipment, such as measurement data, status updates, and fault reports. These detailed data are encoded into specific detection data frames and then sent to the ground detection system according to a predetermined cycle. One of the core tasks of the ground detection system is to ensure that the real-time status and data changes of the UAV in the ground detection process can be accurately and intuitively reflected. During the development phase of the ground detection software, in order to ensure the correct transmission and parsing of data, a detailed data frame communication protocol document is usually provided. This document is usually called an interface definition document (ICD). In the interface definition document, the specific structure of the data frame is defined, including multiple data fields in each data frame. Due to the limitations of the communication protocol and the consideration of the maximum frame length, the data and status information of a device are often scattered in multiple data frames for transmission. In order to facilitate data integration and processing, each data field in the interface definition document is associated with a specific data class label. The role of these labels is to classify fields with common attributes or functions into one category to form a virtual data class. Through this method, the generated graphical user interface is user-friendly. The final interface will display a lot of data. The relevant data will be displayed together so that users can easily see the data they want to see. Secondly, it is convenient for interface mapping. A data class is a minimum area of the interface. It is convenient to modify and adjust the local interface, without the need to modify the text configuration file of the interface as in the prior art, and then directly control the regeneration of the target program based on the modified file.
[0039] The present application embodiment provides a method for generating a graphical user interface, such as Figure 1 As shown, the method includes steps S101 to S106. Among them, Figure 1 This is only an execution order shown in the embodiment of the present application, and does not represent the only execution order of a graphical user interface generation method. If the final result can be achieved, Figure 1 The steps shown may be performed in parallel or reversed.
[0040] S101: Generate an initial protocol definition configuration file based on a protocol interface definition document.
[0041] Specifically, the protocol interface definition document is an interface definition document (ICD) of the UAV ground detection protocol, and the initial protocol definition configuration file is a file in an extensible markup language (XML) format.
[0042] Figure 2 A specific flow chart for generating an initial protocol definition configuration file based on a protocol interface definition document provided in an embodiment of the present application, such as Figure 2 As shown, it includes steps S201 to S203.
[0043] S201: Read the protocol interface definition document.
[0044] Specifically, automated tools or software can be used to read the interface definition document (ICD) of the drone ground detection protocol. This protocol interface definition document contains various protocol information required for communication between the drone and the ground station, including data frame format, field definition, etc.
[0045] S202: Identify target data in the protocol interface definition document according to a preset data definition, and convert the target data into data of a first data structure.
[0046] Specifically, the preset data definition is a user-defined formatted text that describes the characteristics or patterns of the target data and can accurately extract the required target data from the document. The preset data definition uses the preset data definition to accurately extract the required data components from the document. For example, if the first data contains multiple fields, such as "field 1", "field 2" and "field 3", and these fields have a specific arrangement order and format in the document, then the preset data definition can locate and extract the values of these fields based on these structural information. The target data is the specific information that needs to be extracted from the first data structure for the protocol interface definition document. The target data can be key table content, but it can also be any other type of data, such as specific fields, parameters, attributes, etc. Once the target data is extracted, it will be converted into data of the first data structure. The first data structure contains information such as the byte offset value of the corresponding field, the number of bytes occupied, the bit segment offset, the field name, the data unit, the encoding format, the minimum resolution of the data, the remarks, the display dictionary (text information corresponding to different values), etc.
[0047] S203: Format the data of the first data structure to generate an initial protocol definition configuration file.
[0048] Specifically, the initial protocol definition configuration file is usually saved in XML format because it has good readability and extensibility.
[0049] S102: Add data class labels to the fields in the initial protocol definition configuration file to generate a final protocol definition configuration file, wherein the data class corresponds to a sub-area in the graphical user interface, and the data class label includes multiple layers of classification names from high to low.
[0050] The above solution solves the development efficiency problem of manually editing graphical interfaces and avoids the problem that manually editing graphical interfaces easily introduces software defects. In addition, compared with a method that uses a text configuration file with a DSL (English: Domain Specific Language Chinese: Domain Specific Language) effect to directly control the target program to present a graphical user interface, this solution can conveniently and flexibly adjust the interface layout and support various personalized customization controls.
[0051] Specifically, the initial protocol definition configuration file contains a detailed definition of the drone detection data frame, including multiple data frames and the data fields within them. For each data field in the initial protocol definition configuration file, a data class label is manually configured for it. This data class label is used to identify the data class to which the field belongs, that is, a set of fields with common attributes or functions. The data class label can contain multiple layers of classification names from high to low to organize the data more clearly logically. Each data class logically corresponds to a sub-area in the graphical user interface (GUI). This means that when the data is sent from the drone and processed, the fields belonging to the same data class will be displayed in the same sub-area of the graphical user interface. Each field under the data class will be mapped to a set of controls in the corresponding sub-area of the graphical user interface. These controls are responsible for displaying the actual data of the field, such as text lists, charts, indicator lights, etc. The type and layout of the controls depend on the type and importance of the field. After completing the data class label configuration for all fields, save the initial protocol definition configuration file as the final protocol definition configuration file. The final protocol definition configuration file now contains the data class label information for each field, so that subsequent data processing and graphical user interface display can be organized according to data classes. Before the final protocol definition configuration file is used in an actual system, necessary validation and testing can be performed to ensure the correct configuration of data class labels and the accuracy of the graphical user interface display.
[0052] Figure 5 The following is a schematic diagram of the relationship between the data class and the graphical user interface provided in the embodiment of the present application. Figure 5 As shown, the graphical user interface is divided into different sub-areas for displaying the data received from the drone. These sub-areas correspond to specific data classes, each of which contains a group of fields with common attributes or functions. For example, data class 1 corresponds to sub-area 1 in the graphical user interface, which is a text list area for displaying the actual data of all fields under data class 1. Similarly, data class 2 corresponds to sub-area 2 in the graphical user interface, which is also a text list area for displaying the data of fields under data class 2. Through this mapping relationship, users can intuitively view and understand the various information sent by the drone.
[0053] Furthermore, the general forms of the initial protocol definition configuration file and the final protocol definition configuration file are as follows:<?xml version="1.0" encoding="UTF-8"?> <icd-def> <block id="1" name="DiJianShuJuZhen1" title="地检数据帧1"> <segment>< / segment> < / block> < / icd-def> .
[0054] Specifically, in the configuration file, <segment>The tag represents a data field, and the class attribute is used to specify the data class label to which the field belongs. The data class label adopts a hierarchical structure, such as "Class 1. Class 2. Class 3", where the high-level classification name comes first and the low-level classification name comes after, connected by a dot (".").
[0055] Use the preset data definition to identify the target data in the protocol interface definition document, where the preset data definition defines the correspondence between the table header column and the data type. The following is an example of two preset data definitions. Preset data definition 1 is: ByteOffset=byte sequence number; ByteCount=byte count; Name=parameter name; Unit=unit; Format=format; Scale=resolution; Comment=comment; preset data definition 2 is: BitOffset=BIT, bit; Name=definition; Dict=validity, description, comment, status word.
[0056] In the preset data definition, the word on the left side of the equal sign indicates the type of data, and the word on the right side of the equal sign indicates the possible header name. Multiple possible header names are separated by commas, and different data type definitions are separated by semicolons. By reading these preset data definitions, an expression object (such as e1) is constructed. The object e1 contains multiple states and operations, of which the two most important operations are matching operations and extraction operations. The matching operation is used to identify whether the header of the table matches the header described by the preset data definition or satisfies a similarity relationship; the extraction operation obtains the column position of the data from the preset data definition statement according to the data type parameter, and then extracts data of the specified type from the table. It should be noted that the above-mentioned preset data definitions are only exemplary, and this application is not limited to the above-mentioned preset data definitions.
[0057] Furthermore, in the present application, the detailed steps of generating an initial protocol definition configuration file based on the protocol interface definition document and adding data class tags to the fields in the initial protocol definition configuration file to generate a final protocol definition configuration file are as follows.
[0058] 1. Read the preset data definitions and construct an expression object e1. This object contains the matching rules and extraction rules between the data fields and the table column headers.
[0059] 2. Use the Word document operation API provided by Microsoft to open the interface definition document and obtain the document object d1, which is the initial protocol definition configuration file.
[0060] 3. Extract all table objects from document object d1 and store them in list L1.
[0061] 4. Traverse each table object t1 in L1 and check whether its first row data r1 matches the definition in expression e1.
[0062] 5. If there is a match, add the table object t1 to the list L2 for subsequent processing.
[0063] 6. Traverse each table object t2 in the list L2.
[0064] 7. Traverse each row of data r2 in t2 and extract field information from r2 using the rules in the expression object e1.
[0065] 8. The extracted field information includes field name n1, offset position o1, number of bytes c1, encoding parameter p1 and dictionary list i1.
[0066] 9. Create a data structure b1 using these field information and add b1 to the list L3.
[0067] 10. Convert the data structure b1 in list L3 into an XML subtree.
[0068] 11. Merge this XML subtree into the XML document object X1.
[0069] 12. Repeat the above steps until all table objects in L2 are processed.
[0070] 13. Format the XML document object X1 to ensure that the generated XML file conforms to the expected format and structure.
[0071] 14. Save the formatted X1 as the final protocol definition configuration file, which now contains all relevant information extracted from the interface definition document.
[0072] S103: Acquire the current interface layout file as the initial interface layout file.
[0073] Specifically, the current interface layout file refers to a basic or original interface layout to which no data binding and control addition has been performed, and the current interface layout file is used as the initial interface layout file.
[0074] Figure 6 This is a schematic diagram of the initial interface layout without content provided in the embodiment of the present application. Figure 6 As shown, the initial interface layout may have only a basic structure without controls for displaying data. Figure 7 A schematic diagram of an initial interface layout with content provided in an embodiment of the present application, such as Figure 7 As shown, the initial interface layout can add controls for displaying data to the specified area of the layout.
[0075] S104: Determine the target position of each data class in the initial interface layout file and the corresponding interface generation template based on the data binding file.
[0076] Figure 8 This is a schematic diagram of possible content interfaces of the initial interface layout file provided in the embodiment of the present application. Figure 8 As shown, multiple display pages may be included, and each display page may include multiple display areas.
[0077] Specifically, the data binding file is a structured document that needs to be manually written in advance. It describes how to map the virtual data class to the specific location in the interface layout and the interface generation template used. The target location of each data class (virtual data class) in the initial interface layout file is determined according to the rules specified in the data binding file, where the target location includes the corresponding initial interface layout file name and the parent control name of the displayed location.
[0078] Furthermore, the data binding file also includes a pre-generation operation strategy, which includes whether to clear all child items of the target parent control container to ensure that the newly added control does not conflict with the existing control. The pre-generation operation strategy refers to the operation that needs to be performed before the control collection is added to the initial interface layout file.
[0079] Specifically, the system needs to parse the data binding file and read the mapping rules and interface generation template information. According to the mapping rules in the data binding file, the system will match each virtual data class with the target location in the initial interface layout file. The target location is determined by the name of the initial interface layout file and the name of the parent control. Assign a corresponding interface generation template to each data class. Based on the control type and parameter information in the template, the system will know how to generate interface controls for the data class. Before adding the control collection to the initial interface layout file, the system will perform corresponding operations according to the pre-generation operation strategy, such as clearing the child items of the target parent control container.
[0080] Specifically, the interface generation template includes a name and parameters, and the name includes one or more control types, such as a label control, a text control, a button control, etc. The parameters are used to determine the number of columns of the generation unit and the columns in which each control type is located. The control types include but are not limited to label controls and text controls.
[0081] S105: Generate a corresponding control set based on the preset generation rules in the interface generation template file for the fields under each data class in the final protocol definition configuration file.
[0082] Specifically, the final protocol definition configuration file contains data class information extracted from the interface definition document.
[0083] The preset generation rules in the interface generation template file include information such as control type (such as label control, text control, etc.), the number of control columns, and the columns where each control type is located. Based on these rules, control sets corresponding to data class fields are generated. These control sets will be used to update the initial interface layout file and generate the final interface layout file.
[0084] Figure 3 The specific flow chart of generating the corresponding control set based on the preset generation rules in the interface generation template file of the fields under each data class in the final protocol definition configuration file provided by the embodiment of the present application is as follows Figure 3 As shown, it includes steps S301 to S304.
[0085] S301: Read the final protocol definition configuration file and perform aggregation based on data class tags.
[0086] Specifically, the final protocol definition configuration file usually contains all data class definitions of the application, and aggregates the data classes based on data class labels (such as class names or type identifiers) for subsequent processing.
[0087] S302: Convert each aggregated data class into a corresponding first multi-branch tree.
[0088] Fig. 9 A tree structure diagram corresponding to the content of the initial interface layout file provided in the embodiment of the present application. Fig. 9 As shown, each layout window can have multiple display pages, and each display page can have multiple display areas.
[0089] Specifically, after the data classes are aggregated, each data class is converted into a first multi-branch tree (i.e., a tree structure of the data class). The first multi-branch tree represents the hierarchical structure and field relationships of the data class. The nodes of the tree can represent fields in the data class, and the child nodes can represent sub-fields or attributes of the fields.
[0090] Fig.10 The embodiment of the present application provides a schematic diagram of converting each aggregated data class into a tree structure of a corresponding first multi-branch tree. Fig.10 As shown, each data class can include multiple fields.
[0091] S303: Obtaining preset generation rules of corresponding data classes in the file of the interface generation template.
[0092] Specifically, refer to the interface generation template file, which contains the generation rules for how to convert data classes into interface controls. Find the corresponding preset generation rules in the interface generation template file according to the data class label. These rules define how to create and layout interface controls based on the fields of the data class.
[0093] S304: Generate a control tree corresponding to the corresponding first multi-branch tree as a control set based on a preset generation rule.
[0094] Specifically, after the generation rules are obtained, a control tree can be generated according to the first multi-branch tree and the preset generation rules, and the control tree is used as a control set. Each node of the control tree represents an interface control, and the relationship between controls (such as parent-child relationship) reflects their layout and hierarchy on the interface.
[0095] S106: Add the control set to the corresponding target position in the initial interface layout file to form a final interface layout file.
[0096] Figure 4 The specific flow chart of adding the control set to the corresponding target position in the initial interface layout file to form the final interface layout file provided in the embodiment of the present application is as follows: Figure 4 As shown, it includes steps S401 to S405.
[0097] S401: Generate an initial multi-branch tree based on the initial interface layout file, and generate corresponding access path identifiers for the control container nodes in the interface layout file to form an association table of control names and corresponding access path identifiers, wherein each control container corresponds to a data class.
[0098] Fig.11 This is a schematic diagram of the tree structure of the initial interface layout file corresponding to the data class provided in the embodiment of the present application. Fig.11 As shown, the tree structure describes the initial user interface layout file, wherein each control container node, i.e., a vertical list container, corresponds to a data class. A data class usually contains multiple fields, which are displayed on the interface through corresponding controls. In this embodiment, in order to simplify the representation, it is assumed that each data class corresponds to multiple text box controls for displaying different field values in the data class.
[0099] S402: Obtain the control name corresponding to the control tree.
[0100] S403: Query the access path identifier corresponding to the control name based on the association table.
[0101] S404: Adding the control tree to the corresponding control container node of the initial multi-branch tree based on the access path identifier to form a final multi-branch tree.
[0102] S405: Generate a final interface layout file based on the final multi-branch tree.
[0103] An embodiment is listed below to illustrate the above process. Of course, other embodiments are also possible, and the present application is not limited to this embodiment.
[0104] The final interface layout file is read, which contains the data class definition required by the application. The system uses a parser to parse the configuration file into a second data structure, where the second data structure is a list containing several first data structures. Each first data structure represents a data class and contains the field information and attributes of the data class.
[0105] Obtain the preset generation rules of the corresponding data class in the file of the interface generation template. The file of the interface generation template contains rules for guiding how to convert the first data structure in the second data structure into a set of interface controls. These rules define how to generate corresponding interface controls according to the field information of the data class, and specify the layout and style of the controls.
[0106] Read the initial interface layout file, which describes the initial layout of the user interface. Use the layout parser to process the initial interface layout file into a multi-branch tree A. Each node of the multi-branch tree A represents a control or control container on the interface, and the relationship between the nodes reflects the hierarchy and layout relationship of the controls on the interface. To facilitate subsequent operations, generate an identifier A for each node representing a control container. Identifier A is an access path from the root node of the tree to the current node, which is used to uniquely identify a control container node. The system also generates an association table A, in which the key value is the control name and the value is the corresponding identifier A.
[0107] When the interface layout is modified, such as adding or deleting controls, it can be regarded as a modification of the multi-branch tree A. This modification usually involves adding or deleting subtrees in the tree, resulting in a new multi-branch tree A'. If only the content inside the interface structure is modified without changing the overall layout, then these changes mainly occur near the leaf nodes. In multi-branch trees A and A', identifier A can be used to uniquely identify and track equivalent nodes before and after the change. Among them, multi-branch tree A is the initial multi-branch tree, and multi-branch tree A' is the final multi-branch tree.
[0108] Using identifier A instead of the control name as the node identifier has the following advantages: first, it avoids confusion caused by controls with the same name; second, the corresponding node can be directly accessed according to the path information in identifier A; finally, by comparing the identifiers A of two nodes, their relationship in the same tree can be determined.
[0109] According to the preset generation rules, the second data structure is converted into a group of multi-trees, called multi-tree group A. This group of multi-trees represents the interface layout content corresponding to the data class field information. For example, if a data class contains four fields a, b, c, and d, and you want to display these fields in a list, first convert the data class into a tree structure, and then generate a corresponding control tree for each field node.
[0110] According to the user's operation or preset rules, the corresponding identifier A is queried from the association table A according to the control name. Using this identifier A, the control container node in the multi-tree A can be located. Then, the multiple multi-trees (i.e., control trees) in the multi-tree group A are added as subtrees to these control container nodes to complete the merging operation of the interface layout.
[0111] Fig.12 This is a schematic diagram of the interface layout and the control tree provided in the embodiment of the present application. Fig.12 As shown, there is an interface layout window, which contains two empty sub-areas, called display area 1 and display area 2. These two sub-areas correspond to two control container nodes in the multi-tree A. There is a set consisting of multi-tree groups A, which represent interface control trees generated based on the second data structure. In this example, the multi-tree group A contains three root nodes, namely layout container 1, layout container 2 and layout container 3. Each layout container node may contain one or more interface control nodes, which describe specific display elements on the interface (such as text boxes, buttons, etc.). Read the interface layout file and query the corresponding identifier A from the association table according to the control name. This identifier A is a path that indicates the location from the root node of the multi-tree A to a specific control container node. Use these identifiers A to locate the control container node in the multi-tree A (in this example, the display area 1 node). Add each multi-tree in the multi-tree group A (i.e., layout container 1, layout container 2 and layout container 3) as a subtree to the display area 1 node. After completing this merging process, an updated multi-tree A' is obtained, which contains the original layout (display area 1 and display area 2) and the newly added control tree (layout container 1, layout container 2 and layout container 3). This new multi-tree A' describes the modified interface layout and is ready to be formatted as a final interface layout file for subsequent user interface rendering and display. Convert the merged multi-tree A into a user interface layout description, which is usually a description file or code snippet that contains information such as the type, location, and properties of the interface elements. This description file is saved as the final interface layout file and can be directly used for user interface rendering and display.
[0112] Furthermore, the detailed steps for dynamically generating and modifying the user interface layout in this application are as follows.
[0113] 1. First read the data binding file and create a binding information table BT1 based on its content.
[0114] 2. Read the final protocol definition configuration file and create a data class list DL1 based on it.
[0115] 3. Create an empty association table TM1 to store control tree objects and their corresponding interface layout file names.
[0116] 4. Traverse each entry I1 in the binding information table BT1.
[0117] 5. Get the name N1 of the interface layout file from entry I1.
[0118] 6. Try to use N1 as the keyword to get the control tree object from the associated table TM1 and assign it to the variable T1.
[0119] 7. If T1 is empty, use N1 to load the corresponding interface layout file from the external memory, create the interface layout object T1, and add it to the association table TM1.
[0120] 8. Traverse the control tree in the interface layout object T1 and generate an association table CB1 of control name-access path identifier.
[0121] 9. Get the generation template name N2 from entry I1, load the corresponding interface generation template, and create a generation template object M1.
[0122] 10. Get the name N3 of the data class from entry I1 and use N3 to get the data class object C1 from the data class list DL1.
[0123] 11. Create an empty control tree list CT1.
[0124] 12. Traverse the field information collection in C1, process each field S1 using the generated template object M1, and add the generated control tree object to CT1.
[0125] 13. Get the control name C2 from entry I1, and use C2 to query the corresponding control path identifier in the association table CB1. After finding the corresponding control node CN1, use the generated template object M1 to process the control interface CN1, and add each control tree in CT1 to the CN1 node in turn.
[0126] 14. After processing all entries in the binding information table BT1, traverse the association table TM1, format the modified interface objects according to the UI file format, and save them to the external memory.
[0127] Specifically, the above process ensures that the user interface layout can be dynamically generated and modified according to the data binding file and the data class list, thereby achieving efficient binding and display of the interface and data.
[0128] Furthermore, in the above embodiment, the ui files of QT graphical interface technology are used as user interface layout definition files. These files are essentially in XML document format, and the composition structure of the interface is defined in the form of a multi-branch tree. Each tree node represents a control itself or the attribute value of a control. In order to uniquely identify the XML document node in the ui file, an expression in XPath format is used, which is called identifier A. For example, the expression "ui / widget / layout[1] / item[1] / widget[2]" means starting from the root node "ui", selecting the "widget" node, the first "layout" node, the first "item" node and the second "widget" node in turn, so as to accurately locate the target control node. In order to establish a correspondence between the data class and the interface display, a data binding file is introduced, which is a text file in XML format. This file describes how to embed the content of the data class into the control tree of the graphical user interface. The data binding file contains multiple <item>Entries, each of which specifies the name of the UI file, the name of the parent control at the target location, the data class label name, the prefix name of the generated control, the maximum number of rows, the operation strategy before generation, and the name of the interface generation template. The specific content and format of the data binding file are as follows.
[0129] <bind> <item ui="page1.ui" widget="layout1" class="数据类1" prefix="data1" maxRow="12" begin="ClearItems" process="LabelTextLine" / > <item ui="page2.ui" widget="gridLayout_3" class="数据类2" prefix="data2" maxRow="5" begin="SetIndex(1)" process="process=" LabelTextLine(0,3,4)"" / > …< / bind> The format of the interface generation template name is "name[(parameter 1, parameter 2)]", where name is a required item and parameter is optional content, which is used to affect the final interface generation effect. For example, "LabelTextLine(0,3,4)" means generating a combined label control and text control, where 4 columns are used as the smallest generation unit, the label is placed in the column numbered 0, and the text box is placed in the column numbered 3.
[0130] Fig.13 This is a schematic diagram of the first result of the generation interface provided in the embodiment of the present application. Fig.13 As shown in the figure, the control corresponding to field 1 is an input box (or text edit box), in which the user can enter text. Similarly, the control corresponding to field 2 is also an input box, allowing the user to enter text. Fig.14 This is a schematic diagram of a second result of the generation interface provided in the embodiment of the present application. Fig.14 As shown in the figure, Field 1 and Field 2 correspond to a combination of three controls. The first two controls are labels or static texts, which are used to display the prompt message "Text", and the third control is an input box, which allows users to enter text.
[0131] The present application embodiment also provides a graphical user interface generation device 1500, such as Fig.15 As shown, the device includes: a file generation module 1501, a tag adding module 1502, an acquisition module 1503, a determination module 1504, a collection generation module 1505 and a position adding module 1506.
[0132] The file generation module 1501 is used to generate an initial protocol definition configuration file based on the protocol interface definition document.
[0133] The label adding module 1502 is used to add data class labels to the fields in the initial protocol definition configuration file to generate a final protocol definition configuration file, wherein the data class corresponds to a sub-area in the graphical user interface.
[0134] The acquisition module 1503 is used to acquire the current interface layout file as the initial interface layout file.
[0135] The determination module 1504 is used to determine the target position of each data class in the initial interface layout file and the corresponding interface generation template based on the data binding file.
[0136] The generation set module 1505 is used to generate a corresponding control set based on the preset generation rules in the interface generation template file for the fields under each data class in the final protocol definition configuration file.
[0137] The adding position module 1506 is used to add the control set to the corresponding target position in the initial interface layout file to form a final interface layout file.
[0138] Some modules in the apparatus described in the present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0139] The devices or modules described in the above application embodiments can be implemented by computer chips or entities, or by products with certain functions. For the convenience of description, the above devices are described in various modules according to their functions. When implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware. Of course, the module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.
[0140] The methods, devices or modules described in this application can be implemented in the form of computer-readable program codes. The controller can be implemented in any appropriate manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program codes (such as software or firmware) that can be executed by the (micro)processor, logic gates, switches, application-specific integrated circuits (English: Application Specific Integrated Circuit, referred to as: ASIC), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program codes, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included in it for implementing various functions can also be regarded as structures within the hardware component. Or even, the means for realizing various functions may be regarded as both a software module for realizing the method and a structure within a hardware component.
[0141] like Fig.16 As shown, an embodiment of the present application also provides a graphical user interface generation server, including a memory 1601 and a processor 1602; the memory 1601 is used to store computer executable instructions; the processor 1602 is used to execute computer executable instructions to implement a graphical user interface generation method described above in an embodiment of the present application.
[0142] The embodiment of the present application also provides a computer-readable storage medium, which stores executable instructions. When a computer executes the executable instructions, it can implement the graphical user interface generation method described above in the embodiment of the present application.
[0143] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary hardware. Based on this understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, or it can be reflected in the implementation process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the method described in the embodiment of the present application.
[0144] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. All or part of this application can be used in many general or special computer system environments or configurations.
[0145] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present application.< / item> < / segment>
Claims
1. A method for generating a graphical user interface, characterized in that: include: Generate an initial protocol definition configuration file based on the protocol interface definition document; Adding data class tags to fields in the initial protocol definition configuration file to generate a final protocol definition configuration file; wherein the data class corresponds to a sub-area in the graphical user interface; Get the current interface layout file as the initial interface layout file; Determine the target position of each data class in the initial interface layout file and the corresponding interface generation template based on the data binding file; Generate a corresponding control set based on the preset generation rules in the interface generation template file for the fields under each data class in the final protocol definition configuration file; The method of generating a corresponding control set based on the preset generation rules in the file of the interface generation template for the fields under each data class in the final protocol definition configuration file comprises: reading the final protocol definition configuration file and aggregating based on the data class labels; converting each aggregated data class into a corresponding first multi-branch tree; obtaining the preset generation rules of the corresponding data class in the file of the interface generation template; and generating a control tree corresponding to the corresponding first multi-branch tree as a control set based on the preset generation rules; Adding the control set to the corresponding target position in the initial interface layout file to form a final interface layout file; The adding of the control set to the corresponding target position in the initial interface layout file to form a final interface layout file includes: generating an initial multi-branch tree based on the initial interface layout file, and generating corresponding access path identifiers for the control container nodes in the interface layout file; adding the control tree to the corresponding control container nodes of the initial multi-branch tree based on the access path identifier to form a final multi-branch tree; and generating a final interface layout file based on the final multi-branch tree.
2. The method for generating a graphical user interface according to claim 1, characterized in that: The target location includes the corresponding initial interface layout file name and the parent control name of the displayed location.
3. The method for generating a graphical user interface according to claim 2, characterized in that: The data binding file also includes an operation strategy before generation, and the operation strategy includes whether to clear all child items of the target parent control container.
4. The method for generating a graphical user interface according to claim 1, wherein: The interface generation template includes a name and parameters, the name includes one or more control types, and the parameters are used to determine the number of columns of the generation unit and the column where each control type is located.
5. The method for generating a graphical user interface according to claim 1, characterized in that: The generating of the initial protocol definition configuration file based on the protocol interface definition document includes: Read the protocol interface definition document; Identify target data in the protocol interface definition document according to a preset data definition, and convert the target data into data of a first data structure; The data of the first data structure is formatted to generate an initial protocol definition configuration file.
6. The method for generating a graphical user interface according to claim 1, characterized in that: Also includes: Forming an association table of control names and corresponding access path identifiers, wherein each of the control containers corresponds to a data class; Get the control name corresponding to the control tree; The access path identifier corresponding to the control name is queried based on the association table.
7. The method for generating a graphical user interface according to claim 1, characterized in that: The data class labels include multi-level classification names from high to low.
8. A graphical user interface generating device, characterized in that: include: A file generation module is used to generate an initial protocol definition configuration file based on a protocol interface definition document; A label adding module, used for adding a data class label to a field in the initial protocol definition configuration file to generate a final protocol definition configuration file, wherein the data class corresponds to a sub-area in the graphical user interface; An acquisition module is used to acquire the current interface layout file as the initial interface layout file; A determination module, used to determine the target position of each data class in the initial interface layout file and the corresponding interface generation template based on the data binding file; A generation set module is used to generate a corresponding control set based on the preset generation rules in the file of the interface generation template for the fields under each data class in the final protocol definition configuration file; the generation of the corresponding control set based on the preset generation rules in the file of the interface generation template for the fields under each data class in the final protocol definition configuration file comprises: reading the final protocol definition configuration file, and aggregating based on the data class label; converting each aggregated data class into a corresponding first multi-branch tree; obtaining the preset generation rules of the corresponding data class in the file of the interface generation template; and generating a control tree corresponding to the corresponding first multi-branch tree as a control set based on the preset generation rules; An adding position module is used to add the control set to the corresponding target position in the initial interface layout file to form a final interface layout file; adding the control set to the corresponding target position in the initial interface layout file to form a final interface layout file includes: generating an initial multi-branch tree based on the initial interface layout file, and generating a corresponding access path identifier for the control container node in the interface layout file; adding the control tree to the corresponding control container node of the initial multi-branch tree based on the access path identifier to form a final multi-branch tree; generating a final interface layout file based on the final multi-branch tree.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores executable instructions, and when a computer executes the executable instructions, the method according to any one of claims 1 to 7 can be implemented.
Citation Information
Patent Citations
Interface creating method and platform based on XML document description
CN101334728A
Data processing method and device, equipment and storage medium
CN112818176A
Data processing method and device based on industrial Internet of Things
CN114791903A
Static page generation method and device, storage medium and electronic equipment
CN116126327A
WEB page element positioning method and device based on template, equipment and storage medium
CN116821532A
