Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.
For the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".
One embodiment of a control method based on a user interface according to the present invention is shown in fig. 1, and includes:
s100, acquiring a control file; the control file comprises control information of each control; the control information comprises a control type, a control ID, a control coordinate, a control name and a control configuration parameter;
s200, generating a user interface according to the control information;
s400, receiving a request message;
s500, calling corresponding control configuration parameters according to the request message;
s600, sending the control configuration parameters to a target address; the target address is the address of the request message.
Specifically, in this embodiment, because the design and implementation of the user interface are very important in the test software, if a new function is added, the corresponding user interface of the function must be added synchronously, but if an interface similar to the previous function is added, the work is repeated, the work efficiency is reduced, a large amount of human and material resources are wasted, and the maintenance is difficult. The invention generates the user interface by acquiring the control file, the control file can be the control file obtained according to the control information initially set by the user or the adjustment information obtained after the adjustment by the later-stage user according to the requirements, the adjustment content can be any one or the combination of a plurality of control types, control coordinates, control IDs, control names or control configuration parameters, if the control information is newly added or changed, the new user interface can be regenerated according to the adjusted control information to replace the original user interface, the code rewriting by developers is not needed, the development time is reduced, the generation and updating speed of the user interface is improved, the control efficiency is improved, and the control configuration parameters can be timely called by the equipment requesting to acquire the control configuration parameters for operation work due to the fact that the called control configuration parameters can be real-timely, the work efficiency is improved.
Another embodiment of a control method based on a user interface according to the present invention, as shown in fig. 2, includes:
s010 obtains the control information;
s020 storing the control information according to an XML format to obtain the control file;
s100, acquiring a control file; the control file comprises control information of each control; the control information comprises a control type, a control ID, a control coordinate, a control name and a control configuration parameter;
s200, generating a user interface according to the control information;
s400, receiving a request message;
s500, calling corresponding control configuration parameters according to the request message;
s600, sending the control configuration parameters to a target address; the target address is the address of the request message.
Specifically, in this embodiment, an abbreviation of xml (extentsiblemarkup language) extensible markup language is a meta language used to define other languages. XML is a subset of the Standard Generalized Markup Language (SGML), well suited for Web transport, and provides a uniform way to describe and exchange structured data that is independent of the application or vendor. Because the XML format is used for storing the control information to obtain the control file, the obstacle of inherent data can be reduced, the application system can access all data in the same mode, the searching is quicker and more efficient, the comparison and the collection of the data are more convenient, the data can be gradually modified without being greatly adjusted, the most important is that the transmission of repeated data can be reduced, and the use efficiency of a network system is enhanced.
Another embodiment of a control method based on a user interface according to the present invention, as shown in fig. 3, includes:
s011, acquiring the control type;
s012, detecting whether the control type accords with a preset control type; if yes, go to step S013;
s013 generates the control ID;
s014 acquiring the control coordinates, the control name and the control configuration parameters;
s020 storing the control information according to an XML format to obtain the control file;
specifically, in this embodiment, the control type is selected by the user, the control type must conform to the preset control type, the preset control type includes any one or more of a static text control, an edit box control, a single selection control, a drop-down list control, a button control, and a TAB control, and if the control type is legal, the control ID is dynamically generated. The control ID is the identification of the control identity, the controls of the same type in the same dialog box resource are sequentially increased from small to large according to natural numbers, and a user needs to appoint or preset control coordinates, control names and control configuration parameters, and all control information is generated into character strings in an XML format and stored. The coordinates are the abscissa X, the ordinate Y of the control relative to the upper left corner of the rectangular design area, and the width and height of the control. The control name is the name of the control, which will be defined by the system as the variable name later. The control configuration parameter is a data attribute of the control and is the purpose of creating the control, and the control configuration parameter is defined as a variable container value by the system later. The invention generates all the information of the control into a character string in an XML format and stores the character string in the control file, thereby reducing the transmission of repeated data and strengthening the use efficiency of a network system.
S100, acquiring a control file; the control file comprises control information of each control; the control information comprises a control type, a control ID, a control coordinate, a control name and a control configuration parameter;
s210, analyzing the control file to obtain the control information;
s220, generating a corresponding control according to the control type, the control ID and the control name;
s230, controlling the layout of the control on the interface according to the control coordinate;
s240, initializing the control according to the control configuration parameters to generate the user interface;
specifically, in this embodiment, different control coordinates can be selected according to business requirements or test requirements to perform interface layout, a common control is laid out at a position where the interface is conspicuous, and since the control file describes the control type, the control name, the control ID, and the control configuration parameters, the interface layout does not need to be debugged again, so that the interface development efficiency is improved, and the design difficulty of the user interface is reduced. In addition, if the user adds a function of the user interface, but the added function is similar to the function of the original user interface, the user interface may only need to slightly add some controls; or if the user adjusts the coordinates of a certain control in the user interface, the work is repeated if interface program codes are rewritten, the work efficiency is reduced, a large amount of manpower and material resources are wasted, and the maintenance is difficult. The method and the device can regenerate a new user interface according to the adjusted control information to replace the original user interface no matter the control information is newly added or changed, developers do not need to rewrite codes, development time is reduced, the generation and updating speed of the user interface is increased, and control efficiency is improved. In the process of supporting the use of the user interface, the user interface is changed according to the requirements of the user, the code of the user interface can be repeatedly used, and the control information is defined and set to generate the control file in the subsequent project, so that the interface development cost is reduced, and the use flexibility of the user interface is improved.
S310, acquiring an XML character string in the control file;
s320, generating a relational expression of the control name and the control configuration parameters according to the XML character string;
s400, receiving a request message;
s510, calling corresponding control configuration parameters according to the request message and the relational expression; the request message comprises a control name requested to be used;
s600, sending the control configuration parameters to a target address; the target address is the address of the request message.
Specifically, in the embodiment, the control information of each control is automatically analyzed and recorded, the control file is automatically loaded, all control information of the user interface originally dispersed in the program code is concentrated in an XML character string, unified management on the control is facilitated, and the risk of recompiling and acting during interface change and modification is reduced. Firstly, loading a control file, calculating the total number of controls, and then sequentially judging whether the parameters of each control are legal. And if the data is legal, analyzing the XML character string. The character string contains the control name and the control configuration parameter, and we need to translate the XML character string into an expression, for example:
<Edit name="ComPort"id="1"left="100"top="10"right="200"bottom="22"value="3"/Edit>
the translation into an expression is: $ ComPort ═ 3 ";
the expression is then handed to the manager for processing, the manager defines a variable container (e.g. map < string > m _ vTable), and we correspondingly pack the left and right sides of the expression into the container, which is equivalent to establishing a set of correspondence table of variable names and variable values. The process actually completes the conversion from the expression to the variable container, so that after the expression is converted into the variable container, when a terminal or a module corresponding to a target address for sending the request message requests to use the control configuration parameters, the manager can feed back the corresponding variable value to the equipment or the module for sending the request message, thereby realizing the real-time access of other modules of the system to data, increasing the real-time sharing function of the parameters and the equipment or the module for sending the request message, and improving the control efficiency.
One embodiment of a user interface based control apparatus 100 of the present invention, as shown in fig. 4, includes:
a first obtaining module 110, which obtains a control file; the control file comprises control information of each control; the control information comprises a control type, a control ID, a control coordinate, a control name and a control configuration parameter;
the first generation module 120 generates a user interface according to the control information;
a receiving module 130 for receiving the request message;
the calling module 140 calls the corresponding control configuration parameters according to the request message;
the sending module 150 sends the control configuration parameters to a target address; the target address is the address of the request message.
Specifically, in this embodiment, a corresponding user interface is generated according to the control file, and the corresponding control is displayed on the user interface, so that a real-time dynamic visual display control function is realized, the convenience of use of the user is improved, and the use experience of the user is improved.
The device embodiment corresponding to the method embodiment has the same effects as the method embodiment, and details are not repeated herein, and the effects of the method embodiment are specifically described.
Another embodiment of a control device based on a user interface according to the present invention is a preferred embodiment of the previous embodiment, and the other parts are the same as the previous embodiment, and includes: the device comprises a first acquisition module, a first generation module, a receiving module, a calling module and a sending module.
In addition, the method further comprises the following steps:
the second acquisition module is used for acquiring the control information;
and the storage module is used for storing the control information according to an XML format to obtain the control file.
Specifically, this embodiment is a device embodiment corresponding to the method embodiment, and the effects thereof are the same as the method embodiment, and are not described herein again, specifically, the effects of the method embodiment are described in detail.
Preferably, the second obtaining module includes:
the first acquisition unit is used for acquiring the control type;
the detection unit is used for detecting whether the control type accords with a preset control type;
the first generation unit is used for generating the control ID when the detection unit detects that the control type accords with the preset control type;
the second acquisition unit is used for acquiring the control coordinates, the control name and the control configuration parameters;
the preset control type comprises any one or more of a static text control, an edit box control, a radio control, a drop-down list control, a button control and a TAB control.
Specifically, this embodiment is a device embodiment corresponding to the method embodiment, and the effects thereof are the same as the method embodiment, and are not described herein again, specifically, the effects of the method embodiment are described in detail.
Preferably, the generating module includes:
the analysis unit is used for analyzing the control file to obtain the control information;
the second generation unit generates a corresponding control according to the control type, the control ID and the control name;
the control unit controls the layout of the control on the interface according to the control coordinates;
and the third generation unit initializes the control according to the control configuration parameters and generates the user interface.
Specifically, this embodiment is a device embodiment corresponding to the method embodiment, and the effects thereof are the same as the method embodiment, and are not described herein again, specifically, the effects of the method embodiment are described in detail.
Preferably, the method further comprises the following steps:
the second acquisition module is used for acquiring the XML character string in the control file;
the second generation module generates a relational expression of the control name and the control configuration parameters according to the XML character string;
the calling module is also used for calling corresponding control configuration parameters according to the request message and the relational expression; the request message includes a control name requested for use.
Specifically, this embodiment is a device embodiment corresponding to the method embodiment, and the effects thereof are the same as the method embodiment, and are not described herein again, specifically, the effects of the method embodiment are described in detail.
An example of a control method based on a user interface according to the present invention, as shown in fig. 5, includes:
s10, defining a control and storing information;
s20, redrawing the control;
s30, defining a variable container and assigning values;
and S40, the module uses the control configuration parameters in real time.
Specifically, in this example, the control customizer is used to define control information, which includes a control type, a control ID, control coordinates, a control name, and control configuration parameters, and store the control information as a control file in an XML format. A control customizer is a software module that defines the kind of control, and the information necessary for a certain type of control. Types of controls include static text controls, edit box controls, radio controls, drop down list controls, button controls, TAB controls, and the like. Each control has some information representing its own characteristics, such as control ID, control coordinates, control name (used later as variable name), control configuration parameters (used later as variable values). We specify that each control is collocated with a control file, and the title of the control file is consistent with the name of its corresponding control, which is for convenience to see the use of each control. In addition, a special symbol is added to the head or tail of the control name, such as "$", to serve as the control name corresponding to the control, and clear guidance is provided for subsequent calling. The information representing the control features is stored in an XML format to facilitate recall. And dynamically redrawing and configuring a user interface according to the stored control file, namely, redrawing the interface once due to each time of information storage, wherein the redrawing of the interface is realized by a redrawing module for analyzing the control file, dynamically creating a control according to the type, the ID and the name of the control defined by the file, then laying out the control according to the control coordinate defined by the control file, and finally initializing the default value of each control according to the configuration parameters of the control. The method comprises the steps of generating variable names for all the controls according to names, assigning values to variable containers according to control configuration parameters, namely defining the corresponding relation between the variable names and variable values by the control names and the control configuration parameters in control files, and if the variable names and the variable values are expressed by expressions, defining a variable container in advance, wherein the variable container can be a two-dimensional array but not limited to a two-dimensional array and is used for storing the variable names and the variable values. The manager is a software module for calculating and accessing variables, which acts between the expression and the variable container, and is a conversion device of the expression and the variables. And sending a request message to access and call the control configuration parameters, namely sending the request message by other modules, acquiring the control configuration parameters in real time by virtue of a manager, and converting the control configuration parameters into the required data type. The method comprises the steps of defining control types, control IDs, control coordinates, control names and control configuration parameters by using a control customizer, storing the information into a control file in an XML format, dynamically redrawing a configuration user interface according to the stored control file, generating variable containers for the controls according to the names, assigning values to the variable containers according to the control configuration parameters, and accessing the variable containers to call the control configuration parameters.
An example of a control method based on a user interface according to the present invention is shown in fig. 6, and includes:
s11, detecting whether the control type designed by the user is legal; if yes, go to step S12; otherwise, return to step S11;
s12, creating a control ID;
s13, specifying control coordinates, control names and control configuration parameters;
s14, detecting whether the control coordinates, the control name and the control configuration parameters are legal or not; if yes, go to step S15;
and S15, generating the XML format character string.
Specifically, the present example is the specific step of the above example S10, S1: the control customizer is used to define the type, ID, coordinates, control name (variable name), control configuration parameters of the control, and store these information as XML formatted files.
The type of control is selected by the user and must be one of a static text control, an edit box control, a radio control, a drop down list control, a button control, a TAB control, etc. If the control type is legal, then the control ID is dynamically generated. The control ID is the identification of the control identity, and the controls of the same type in the same dialog box resource are sequentially increased from small to large according to the natural number. And (3) the user specifies coordinates, control names and control configuration parameters, and all control information is generated into character strings in an XML format and stored. The coordinates are the abscissa X, the ordinate Y of the control relative to the upper left corner of the rectangular design area, and the width and height of the control. The control name is the name of the control, which will be defined by the system as the variable name later. The control configuration parameters are data attributes of the control, and are the purpose of creating the control, and all the information of the control is generated into a character string in an XML format and is stored in a control file.
A legal XML string is given as follows:
<Edit name="ComPort"id="1"left="100"top="10"right="200"bottom="22"value="3"/Edit>
the above string defines that the control type is "Edit" (Edit box control), its name is Comport (port number-a configuration name that is common in the testing arts), the control ID is 1, the coordinates are in the upper left corner (100, 10), the length is 200, the height is 22, and its control configuration parameter is 3.
An example of a control method based on a user interface according to the present invention is shown in fig. 7, and includes:
s21, loading a control file;
s22, detecting whether the control file is legal; if yes, go to step S23;
s23, analyzing the XML character string in the control file;
s24, creating a control;
s25, layout control;
s26, initializing the control according to the control parameter;
s27, judging whether drawing is finished or not; if yes, go to step S28; otherwise, return to step S23;
and S28, refreshing and displaying the interface.
Specifically, this example is the specific step of the above example S20, that is, the configuration user interface is dynamically redrawn according to the stored XML data information, that is, the control file is loaded first, the XML data information is adjusted to obtain a new control file, whether the file parameter of the new control file is legal is determined, then the information of each control is sequentially analyzed, the control and the layout are dynamically created according to the type, name, ID, and coordinate of the control, data is initialized for the control according to the data attribute, and finally, the adjusted configuration user interface is displayed.
An example of a control method based on a user interface according to the present invention is shown in fig. 8, and includes:
s31, loading a control file;
s32, detecting whether the control file is legal; if yes, go to step S33;
s33, analyzing the XML character string in the control file, and converting and generating an expression according to the XML character string;
s34, storing the expression into a variable container;
s35, judging whether the storage is finished; if yes, go to step S36; otherwise, return to step S33;
and S36, finishing the conversion storage process.
Specifically, in this example, the specific step of the above example S30 is to generate a variable container for each control according to a name, assign a value to the variable container according to the control configuration parameter, load the control file first, calculate the total number of controls, and then sequentially determine whether the parameter of each control is legal. And if the data is legal, analyzing the XML character string. The character string contains the control name and the control configuration parameter, and we need to translate the XML character string into an expression, for example:
<Edit name="ComPort"id="1"left="100"top="10"right="200"bottom="22"value="3"/Edit>
the translation into an expression is: $ ComPort ═ 3 ";
the expression is then handed to the manager for processing, the manager defines a variable container (e.g. map < string > m _ vTable), and we correspondingly pack the left and right sides of the expression into the variable container, which is equivalent to establishing a set of correspondence table of variable names and variable values. This process in essence completes a large turn of the expression into a variable container.
An example of a control method based on a user interface according to the present invention is shown in fig. 9, and includes:
s41, receiving a request message;
s42, judging whether to allow the request message; if yes, go to step S43; otherwise, go to step S41;
s43, calling corresponding control configuration parameters;
and S44, sending the corresponding control configuration parameters to the equipment or module sending the request message.
Specifically, in this example, which is a specific step of the above example S40, other modules of the system access the variable container to call the control configuration parameter. After the expression is transferred into the variable container, when the device or module sending the request message requests to use the control configuration parameters, the manager can feed back the corresponding control configuration parameters to the target address according to the corresponding relation of the expression, so that the device or module sending the request message corresponding to the target address can access the data in real time. As shown in fig. 10, which is a user-defined XML file, and the software configuration interface generated according to the XML file is shown in fig. 11, it can be seen that the software configuration interface generated according to the code of fig. 10, where reference numerals 1-6 in fig. 10 correspond to the controls generated in fig. 11, respectively, includes:
note1 configures dialog box size:
the dialog box name is defined as Config, 500 wide and 320 high.
Note2TabCtrl size:
a TabCtrl control is arranged in the definition dialog box, coordinates (10, 10) at the upper left corner, width 470, height 200, and parameter Visible ═ 1.
Note3 paginated titles:
the title is defined as "first page", and the ID is 0.
Note4 static text control:
the definition name is ComPort, ID is 1, coordinates (10, 13) in the upper left corner, width is 100, and height is 22.
Note5 edit box control:
the definition name is ComPort, ID is 1, coordinates (100, 10) in the upper left corner, width is 200, height is 22, and data is 3.
Note6 radio button control:
the name PowerSupply (whether programmable power is used or not) is defined, ID is 1, coordinates at the top left corner (10, 100), width 100, height 22, and data is 0.
The invention realizes flexible addition and adjustment of test software configuration items through one-time coding, applies control configuration parameters to the test software in real time, avoids continuous development work caused by requirement change, realizes adjustment of parameters represented by interface elements, and then records, stores and shares the parameters to other components of the test software in real time. The invention can realize the addition of real-time parameter types, also increases the real-time sharing of the parameters and the equipment or the module which sends the request message, reduces the time for re-developing the code and saves the development cost.
It should be noted that the above embodiments can be freely combined as necessary. The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.