Configurable diversified standard interface control creation method and product
The interface control creation method encapsulates controls as classes in a configuration file, addressing inefficiencies and incompatibilities by reducing code redundancy and optimizing memory usage.
Patent Information
- Application Number
- CN202411130109.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-13
AI Technical Summary
Existing interface control creation methods require extensive code writing, lead to code redundancy and inefficiency, cause version incompatibility, result in high error rates, and consume significant memory resources.
Encapsulate each control as a class based on object-oriented principles, using a configuration file to manage properties and execution modules, enabling version-compatible and efficient interface creation.
Reduces code writing, minimizes errors, ensures version compatibility, and optimizes memory usage by sharing fixed memory sizes and refreshing only when data is updated.
Smart Images

Figure CN119127183A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a method for creating an interface control. Background Art
[0002] Thermostat is a device used to control and adjust temperature, which is widely used in home and industrial fields. It is mainly composed of sensors, control circuits, display / operation interfaces and actuators, etc. Through the coordinated work of these components, effective control of ambient temperature can be achieved.
[0003] The display / operation interface refers to the color screen on the thermostat, which can display texts of different colors, color pictures, etc.; it is used to display thermostat parameters, such as temperature, wind speed, etc.; the screen can be clicked to operate and control the actuators, such as: cooling and heating, wind speed, etc.
[0004] With the application of color screens in thermostats, compared with traditional black and white screens, they are increasingly favored by customers in terms of dynamics, beauty, performance, etc., which makes it particularly important to design a pleasing interface, which even directly affects customer acceptance and even the success or failure of the product. However, its technical architecture is more complex than that of black and white screens, and the technical requirements for engineers are also high. The existing technical solution is to write code programs for each attribute of the control that meets the requirements of each interface one by one based on the process-oriented idea according to the product technical documents, such as position, size, background color, events, etc., and release the program version after completing the test to ensure that it meets the product requirements. When facing the development of the same series of products, the released version program must be additionally modified and a new version program must be generated. These two versions of the program can only be used in their respective products and are incompatible with each other. When the control is expanded in the case of changes in product requirements, additional expansion modules need to be added.
[0005] In short, the existing interface control creation method has the following problems:
[0006] (1) The existing technology requires a lot of code writing work. The existing technology is to write code programs for various properties of controls that meet the requirements of each interface one by one according to the product technical documentation, such as position, size, background color, events, etc. This will cause code redundancy, low efficiency, high error rate and other problems.
[0007] (2) The existing technology cannot achieve version compatibility. The existing technology is to modify the program released by this product to suit the current needs. When adjusting the interface of products in the same series, it cannot be compatible with the previous one, resulting in incompatibility between versions, an increase in code versions, and difficulty in maintenance.
[0008] (3) The existing technology takes a lot of time to expand controls. The existing technology first needs to find the location of the control in the program, and then add modules to expand the control. Therefore, when the product requirements change, the expansion of the control needs to take a lot of time to modify, resulting in a lot of time waste, low project efficiency, and may also affect the properties of other controls.
[0009] (4) The existing technology occupies a large amount of memory. In the existing technology, pointers are created for controls on each interface first, resulting in a large amount of memory usage, and the properties of the controls are refreshed in real time, resulting in constant memory usage and reduced CPU performance. Summary of the invention
[0010] The present application provides a configurable diversified standard interface control creation method and product, aiming to solve the problem that the existing control creation method requires a large amount of code writing and version incompatibility.
[0011] In a first aspect, a method for creating a configurable diversified standard interface control comprises:
[0012] Load an executable configuration file, in which each control is encapsulated as a class based on object-oriented thinking, and the class members include various properties and execution modules of the control, and the properties include characteristic values of parameters of each interface control; the configuration file also includes the program execution start address and program logic;
[0013] Determine the working mode of the device, return the corresponding interface value, and verify the validity of the interface value;
[0014] When the interface value is valid, the returned interface value is used as the starting point for interface creation, instructing the device to read the control parameter data in the configuration file from the corresponding interface and determine the validity of the control parameter data; otherwise, a prompt indicating that the interface value is invalid is returned;
[0015] When the control parameter data is valid, the characteristic value of the control parameter is assigned to the corresponding member variable, the control class is passed into its execution module as the actual parameter, and the member variable in the attribute is instantiated as the content to be displayed; otherwise, it is determined whether the control parameter data has been read;
[0016] The next control parameter data in the configuration file is read in a loop until the control parameter data is read and the creation of the control is completed.
[0017] The above solution may optionally include:
[0018] The control class includes a button class, a picture class and a slider class.
[0019] The above solution may optionally include:
[0020] The various properties of the control include position, size, background color and event, and the execution module includes a property creation module, a property initialization module, a property refresh module and a property event processing module.
[0021] In the above solution, optionally, the control class is passed into its execution module as an actual parameter, and the member variables in the properties are instantiated into the content to be displayed, including:
[0022] Use the execution module to perform creation, initialization, event registration and refresh in sequence;
[0023] Introduce a timer into the system for the execution module, and use the timer to cyclically refresh the control data.
[0024] In the above solution, optionally, it also includes:
[0025] Respond to interface control events, verify whether the interface control events are within the valid range, obtain the characteristic values of the control parameters when the interface control events are valid, and verify the validity of the characteristic values;
[0026] When the characteristic value is valid, delete all controls on the current interface, and obtain the corresponding interface value according to the characteristic value to verify the validity of the interface value at this time; otherwise, return a prompt that the characteristic value is invalid.
[0027] In the above solution, optionally, the executable configuration file is a binary file, and its generation process is as follows:
[0028] The maintenance personnel plan the controls required for each interface according to the project requirements and add the control parameters to the file. After the pre-compilation stage, the file parameters are saved to the flash area specified by the device. After compilation, an executable configuration file is finally generated.
[0029] In the above solution, optionally, each control on each interface in the configuration file has a corresponding number. When the control needs to be expanded, the maintenance personnel expand the corresponding control according to the control number.
[0030] In the above solution, optionally, each interface control shares a fixed memory size, and memory data is refreshed once each time a control is created. In real-time refresh of controls, memory data is refreshed only once when data is updated.
[0031] In the above scheme, optionally, the validity of the verification interface value is
[0032]
[0033] 1 means valid, 0 means invalid, x means interface value, d1 max Indicates the maximum value of the first-level interface. The interface value in initialization must be within the first-level interface range and greater than 0, otherwise it is invalid;
[0034] The validity of the control parameter data is determined as follows:
[0035]
[0036] 1 means valid, 0 means invalid, x means the enable flag in the control parameter data. When the enable flag is true, it means the control is valid, otherwise it is invalid.
[0037] In a second aspect, a computer program product comprises a computer program / instruction, wherein the computer program / instruction implements the steps of the method described in the first aspect when executed by a processor.
[0038] Compared with the prior art, this application has at least the following beneficial effects:
[0039] (1) The present invention does not require a large amount of code writing. Based on the object-oriented concept, the present invention encapsulates each control into a class, and realizes the creation of the interface by automatically calling standard modules such as class creation, initialization, refresh, event processing, etc.; while reducing a large amount of code writing, it improves efficiency and reduces error rate.
[0040] (2) The present invention can achieve version compatibility. The configuration file of the present invention contains the parameters of the controls on each interface, and the interface can be easily modified according to the configuration file without causing incompatibility between versions.
[0041] (3) The present invention does not need to spend a lot of time on control expansion. In the configuration file of the present invention, the controls on each interface have their corresponding numbers, and then targeted special expansion processing is performed according to the control number without affecting the properties of other controls.
[0042] (4) The present invention does not need to occupy a large amount of memory. Each interface control of the present invention shares a fixed memory size, and refreshes the memory data each time a control is created. At the same time, in the real-time refresh of the control, it is refreshed only when the data is updated, which saves a lot of memory and improves CPU performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A flowchart of a method for creating a configurable diversified standard interface control provided by an embodiment of the present application;
[0044] Figure 2 A flowchart of a method for creating a configurable diversified standard interface control provided by an embodiment of the present application;
[0045] Figure 3 A device working mode diagram of a configurable diversified standard interface control creation method provided by an embodiment of the present application;
[0046] Figure 4 A diagram showing the composition of button class members of a configurable diversified standard interface control creation method provided by an embodiment of the present application;
[0047] Figure 5 A control instantiation flow chart of a configurable diversified standard interface control creation method provided in one embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0049] In the description of this application: unless otherwise specified, "plurality" means two or more. "Including", "comprising", "having" and other expressions also mean "not limited to" (certain units, components, materials, steps, etc.).
[0050] In one embodiment, Figure 1 As shown, a configurable diversified standard interface control creation method is provided. This embodiment uses the method applied to a thermostat as an example for illustration. The method includes the following steps:
[0051] Load an executable configuration file, in which each control is encapsulated as a class based on object-oriented thinking, and the class members include various properties and execution modules of the control, and the properties include characteristic values of parameters of each interface control; the configuration file also includes the program execution start address and program logic;
[0052] Determine the working mode of the device, return the corresponding interface value, and verify the validity of the interface value;
[0053] When the interface value is valid, the returned interface value is used as the starting point for interface creation, instructing the device to read the control parameter data in the configuration file from the corresponding interface and determine the validity of the control parameter data; otherwise, a prompt indicating that the interface value is invalid is returned;
[0054] When the control parameter data is valid, the characteristic value of the control parameter is assigned to the corresponding member variable, the control class is passed into its execution module as the actual parameter, and the member variable in the attribute is instantiated as the content to be displayed; otherwise, it is determined whether the control parameter data has been read;
[0055] The next control parameter data in the configuration file is read in a loop until the control parameter data is read and the creation of the control is completed.
[0056] In the above configurable diversified standard interface control creation method, each control is encapsulated into a class based on object-oriented thinking, and the interface creation is realized by automatically calling standard modules such as class creation, initialization, refresh, event processing, etc.; while reducing a large amount of code writing, it improves efficiency and reduces error rate.
[0057] The configuration file of this embodiment includes parameters of controls on each interface. The interface can be modified very conveniently according to the configuration file without causing incompatibility between versions.
[0058] In this embodiment, if Figure 2 As shown, a general flow chart of interface control creation is also provided. In this figure, the flow chart of creating interface control is roughly composed of three parts, including parameter compilation unit, program download unit, and program execution unit;
[0059] The parameter compilation unit mainly plans the required controls on each interface according to the project requirements, and adds the control parameters to the configuration file. After completion, the parameters are saved to the flash area specified by the device after the pre-compilation stage (the interface parameter data is read from here when it is powered on). After compilation, the device executable configuration file will be generated. The configuration file is a binary file, which mainly includes the program execution start address, program logic, control parameter data, execution module, etc.
[0060] The program download unit downloads the configuration file to the device through the download interface for execution;
[0061] The program execution unit is mainly responsible for initializing the device after it is powered on. At the beginning of initialization, the device's working mode is determined. Figure 3 As shown, if it is factory mode, the factory interface value is returned directly. If not, it is determined whether the device power-on state is shutdown. If so, the shutdown interface value is returned, otherwise the startup interface value is returned.
[0062] At this time, the returned interface value is used as the interface value to be created, which is to tell the device control parameter data from which interface to start reading. At the same time, the validity of the interface value must be judged. The judgment logic is as follows:
[0063]
[0064] Among them, 1 means valid, 0 means invalid, x means interface value, d1 max Indicates the maximum value of the first-level interface. The interface value in initialization must be within the first-level interface range and greater than 0, otherwise it is invalid;
[0065] The instructing device reads the control parameter data in the configuration file from the corresponding interface and determines the validity of the control parameter data. The logic for verifying the validity of the control parameter data is
[0066]
[0067] Among them, 1 indicates valid, 0 indicates invalid, and x indicates the enable flag in the control parameter data. When the enable flag is true, it indicates that the control is valid, otherwise it is invalid.
[0068] After the data is valid, it will be assigned to the corresponding control class.
[0069] In one embodiment, the control class includes a button class, a picture class and a slider class.
[0070] In one embodiment, the various properties of the control include position, size, background color and events, and the execution module includes a property creation module, a property initialization module, a property refresh module and a property event processing module.
[0071] In this embodiment, taking the button class in the control class as an example, its member components are as follows: Figure 4 shown.
[0072] Figure 4 The button class is divided into two parts: attributes and execution module. The attributes contain some characteristic values of the button class. The data read in the future runtime will be assigned to the corresponding member variables in sequence. The execution module is to instantiate the member variables in the attributes into the content to be displayed. The creation module function is to instantiate the button, the initialization module function is to make specific settings for the instantiated button according to the read attribute parameters, the refresh module function is to expand and compatibility process the button according to the different states of the device, the event processing module function is to control the device according to the data parameters and interface jump, etc. Other module functions include picture update, character content switching, control color change and other processing; other control classes are similar to the button class.
[0073] After that, the control class is passed as the actual parameter to its execution module to perform operations such as creation and initialization in sequence. Figure 5 .
[0074] In one embodiment, the control class is passed into its execution module as an actual parameter, and the member variables in the properties are instantiated into the content to be displayed, including:
[0075] Use the execution module to perform creation, initialization, event registration and refresh in sequence;
[0076] Introduce a timer into the system for the execution module, and use the timer to cyclically refresh the control data.
[0077] The timer module in the figure above is the timer in the system, which will refresh the data of the control according to the set time period, such as temperature, humidity, time, etc. The judgment logic of whether the control is successfully created is as follows:
[0078]
[0079] Among them, 1 indicates success, 0 indicates failure, and x indicates the control pointer. When the space memory pointed to by the control is empty, it means that the memory allocated by the control does not exist and the creation fails. Otherwise, the creation is successful.
[0080] After creating a control, it will determine whether all control parameters of the current interface have been read. If not, it will loop to read the next control parameter until all are read, and the entire interface is created.
[0081] In one embodiment, responding to an interface control event, verifying whether the interface control event is within a valid range, obtaining a characteristic value of a control parameter when the interface control event is valid, and verifying the validity of the characteristic value;
[0082] When the characteristic value is valid, delete all controls on the current interface, and obtain the corresponding interface value according to the characteristic value to verify the validity of the interface value at this time; otherwise, return a prompt that the characteristic value is invalid.
[0083] In this embodiment, a button class is used as an example for explanation. Its interface control event is a button click event. In response to the interface button click event, the interface control event is verified, that is, whether the button click position is within the valid range. The judgment logic is as follows:
[0084]
[0085] Among them, 1 means valid, 0 means invalid, x means the x-axis coordinate value of the click position, y means the y-axis coordinate value of the click position, x1 means the x-axis coordinate value of the control on the interface, w means the width of the control, y1 means the y-axis coordinate value of the control on the interface, and h means the width of the control. When the click position is within the above range, it is the valid range of the button;
[0086] After the button is valid, get the control jump interface flag bit, and judge the validity of the control jump interface flag bit. The validity judgment logic is as follows:
[0087]
[0088] Among them, 1 means valid, 0 means invalid, x means the control jump interface flag, and the value is judged whether it is true or false after the flag is shifted right by 31 bits;
[0089] After the characteristic value is valid, all controls on the current interface will be deleted and the interface value in the parameter will be obtained. The validity of the interface value is different from that of the initialization. The specific judgment logic is as follows
[0090]
[0091] Among them, 1 means valid, 0 means invalid, x means interface value, d1 max Indicates the maximum value of the first-level interface, d2 min Indicates the minimum value of the secondary interface, d2 max Indicates the maximum value of the secondary interface, d3 min Indicates the minimum value of the three-level interface, d3 max It indicates the maximum value of the three-level interface. The interface is divided into three levels, that is, three interfaces are allowed to appear at the same time. At this time, the interface value must be valid within the interface range of the three levels.
[0092] Through the above process, the standard process of creating interface controls is completed;
[0093] In one embodiment, each control on each interface in the configuration file has a corresponding number. When a control needs to be expanded, the maintenance personnel expands the corresponding control according to the control number.
[0094] In the configuration file of this embodiment, each control on each interface has its corresponding number, and then a targeted special expansion process is performed according to the control number without affecting the properties of other controls. Therefore, this embodiment does not need to spend a lot of time on control expansion.
[0095] In one embodiment, each interface control shares a fixed memory size, and memory data is refreshed once each time a control is created. In real-time refresh of controls, memory data is refreshed only when data is updated.
[0096] In this embodiment, each interface control shares a fixed memory size, and memory data is refreshed once each time a control is created. In the real-time refresh of the control, the data is refreshed only when the data is updated, which saves a lot of memory and improves CPU performance. Therefore, this embodiment does not need to occupy a lot of memory.
[0097] In one embodiment, a computer program product is also provided, including a computer program / instruction, which implements the steps of the above-mentioned embodiment method when executed by a processor.
[0098] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for creating a configurable diversified standard interface control, characterized in that: include: Load an executable configuration file, in which each control is encapsulated as a class based on object-oriented thinking, and the class members include various properties and execution modules of the control, and the properties include characteristic values of parameters of each interface control; the configuration file also includes the program execution start address and program logic; Determine the working mode of the device, return the corresponding interface value, and verify the validity of the interface value; When the interface value is valid, the returned interface value is used as the starting point for interface creation, instructing the device to read the control parameter data in the configuration file from the corresponding interface and determine the validity of the control parameter data; Otherwise, a prompt indicating that the interface value is invalid is returned; When the control parameter data is valid, the characteristic value of the control parameter is assigned to the corresponding member variable, the control class is passed into its execution module as the actual parameter, and the member variable in the attribute is instantiated as the content to be displayed; otherwise, it is determined whether the control parameter data has been read; The next control parameter data in the configuration file is read in a loop until the control parameter data is read and the creation of the control is completed.
2. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: include: The control class includes a button class, a picture class and a slider class.
3. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: include: The various properties of the control include position, size, background color and event, and the execution module includes a property creation module, a property initialization module, a property refresh module and a property event processing module.
4. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: The control class is passed into its execution module as an actual parameter, and the member variables in the properties are instantiated to the content that needs to be displayed, including: Use the execution module to perform creation, initialization, event registration and refresh in sequence; Introduce a timer into the system for the execution module, and use the timer to cyclically refresh the control data.
5. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: Also includes: Respond to interface control events, verify whether the interface control events are within the valid range, obtain the characteristic values of the control parameters when the interface control events are valid, and verify the validity of the characteristic values; When the characteristic value is valid, delete all controls on the current interface, and obtain the corresponding interface value according to the characteristic value to verify the validity of the interface value at this time; otherwise, return a prompt that the characteristic value is invalid.
6. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: The executable configuration file is a binary file, and its generation process is as follows: The maintenance personnel plan the controls required for each interface according to the project requirements and add the control parameters to the file. After the pre-compilation stage, the file parameters are saved to the flash area specified by the device. After compilation, an executable configuration file is finally generated.
7. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: Each control on each interface in the configuration file has a corresponding number. When the control needs to be expanded, the maintenance personnel expand the corresponding control according to the control number.
8. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: Each interface control shares a fixed memory size. The memory data is refreshed every time a control is created. In the real-time refresh of the control, the memory data is refreshed only when the data is updated.
9. The method for creating a configurable diversified standard interface control according to claim 1, characterized in that: The validity of the verification interface value is 1 means valid, 0 means invalid, x means interface value, d1 max Indicates the maximum value of the first-level interface. The interface value in initialization must be within the first-level interface range and greater than 0, otherwise it is invalid; The validity of the control parameter data is determined as follows: 1 means valid, 0 means invalid, x means the enable flag in the control parameter data. When the enable flag is true, it means the control is valid, otherwise it is invalid.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.
