Interface variable read-write optimization method and device and medium

By using hierarchical configuration files to manage interface control properties in interface variable reading and writing, the problems of complex software structure and difficult maintenance caused by the high coupling of interface variable reading and writing methods in the prior art are solved, and the flexibility and scalability of the interface are achieved.

CN119718459APending Publication Date: 2025-03-28CETC BEIJING ELECTRONICS EQUIP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411704468.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the prior art, the interface variable reading and writing methods are highly coupled, which makes the software structure complex and difficult to maintain. When adding or modifying parameters, code needs to be added or modified in multiple modules, which increases the workload of development and maintenance.

Method used

By creating interface variable management configuration files, it is divided into interface layer, control layer and control attribute layer. All attributes of interface control and their corresponding values ​​are integrated and saved into a unified configuration file to achieve the separation of interface UI display and read and write.

Benefits of technology

When developing software, the management of interface variables through configuration files reduces the complexity of code and maintenance workload, and improves the flexibility and scalability of the interface.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718459A_ABST
    Figure CN119718459A_ABST
Patent Text Reader

Abstract

The invention discloses an interface variable read-write optimization method and device and a medium, and belongs to the technical field of upper and lower computer communication. The method comprises the steps of creating an interface variable management configuration file; reading contents in the interface variable management configuration file to a mapping set; creating an object pointer, and storing the control attribute of the current interface; when an interface is opened or a window is switched, assigning a corresponding address to the object pointer according to the name of the interface; when the interface is refreshed, all attributes of all controls of the current interface are traversed in sequence; the control type is judged, preset operation is carried out according to the control type, and the preset operation comprises direct display when the control type is a character and marking of a modified value when the control type is an edit box or a pull-down check box; and when the interface clicks confirmation, traversing the mapping set, and issuing the marked and modified value to the programmable logic controller. According to the method, UI display and read-write are separated, and when a new item is newly added or deleted, only the configuration file needs to be modified, and software does not need to be modified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of communication between upper and lower computers, and more specifically, to an interface variable reading and writing optimization method, device and medium. Background Art

[0002] With the continuous development of industrial automation technology, industrial computer platforms based on Windows operating systems have been widely used in various industrial control applications. Specifically, the software runs on an industrial computer platform equipped with Windows system, and the industrial computer is connected to the PLC through a network cable. The software interface has text, edit boxes, drop-down check boxes and other items. The interface can read and write variables in the PLC and variables stored in the hard disk.

[0003] However, the existing interface variable reading and writing methods have some significant shortcomings, which affect the maintainability and scalability of the software. The existing technology is highly coupled in software structure, and the interface, communication, and file reading and writing modules are closely connected. This coupling leads to a complex software structure and is difficult to maintain. When adding or modifying parameters, it is necessary to add or modify code in multiple modules. There are too many things to modify, which increases the workload of development and maintenance. Summary of the invention

[0004] In order to overcome the technical problems existing in the above prior art, the present invention provides an interface variable reading and writing optimization method, device and medium.

[0005] In order to solve the above technical problems, the technical solution of the present invention is as follows:

[0006] A method for optimizing reading and writing of interface variables comprises the following steps:

[0007] Create an interface variable management configuration file, the interface variable management configuration file is divided into three levels, the three levels are the interface layer, the control layer and the control attribute layer;

[0008] Read all contents in the interface variable management configuration file into a mapping set;

[0009] Create an object pointer to store the control properties of the current interface;

[0010] When opening an interface or switching windows, assign the corresponding address to the object pointer according to the interface name;

[0011] When refreshing the interface, all properties of all controls in the current interface are traversed in sequence;

[0012] Determine the control type, and perform a preset operation according to the control type, wherein the preset operation includes directly displaying when the control type is text, and marking the modified value when the control type is an edit box or a drop-down check box;

[0013] When the interface clicks OK, the mapping set is traversed and the values ​​marked as modified are sent to the programmable logic controller.

[0014] Furthermore, the content stored in the interface layer is a list of interface names, the content stored in the control layer is a list of controls under each interface, and the content stored in the control attribute layer is a list of attributes for each control.

[0015] Furthermore, the control properties include variable name, title, default value, maximum value, minimum value, data format and unit, and the data format includes integer and decimal.

[0016] Further, the interface variable management configuration file is read, and all contents in the interface variable management configuration file are read into the jValueMap mapping set;

[0017] Create a JsonValue object pointer, which is used to store all control properties of the current interface.

[0018] Furthermore, when the interface is opened or the window is switched, the address of the content stored in the jValueMap mapping set is assigned to the JsonValue object pointer according to the interface name.

[0019] Further, when the control type is an edit box, it is determined whether the value is within a preset threshold range, and whether the value has been modified;

[0020] Values ​​that are within the preset threshold range and have not been modified are displayed in black text on a white background;

[0021] Values ​​that are not within the preset threshold range or have been modified are displayed in red letters on a white background, and the modified values ​​are marked in the object pointer.

[0022] Furthermore, when the control type is a drop-down check box, the option content corresponding to the displayed value is displayed in black text on a white background if it has not been modified, and in red text on a white background if it has been modified, and the modified value is marked in the object pointer.

[0023] Furthermore, when the interface clicks Confirm, the mapping set is traversed, all values ​​marked as modified are sent to the PLC, and all values ​​marked as modified are saved in the interface variable management configuration file.

[0024] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the aforementioned method for optimizing the reading and writing of interface variables when executing the computer program.

[0025] A computer-readable storage medium stores a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of the aforementioned interface variable reading and writing optimization method.

[0026] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:

[0027] The present invention provides an interface variable reading and writing optimization method, device and medium. When developing software based on the MFC framework, all properties of interface controls and all properties of their corresponding values ​​are integrated and saved as a unified configuration file. The present invention separates the interface UI display from reading and writing. When adding or deleting a new project, only the configuration file needs to be modified, and the software does not need to be modified. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0029] Figure 1 It is a flowchart of an interface variable reading and writing optimization method provided in one embodiment of the present application;

[0030] Figure 2 It is a schematic diagram of the principle of an interface variable reading and writing optimization method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0032] Embodiment 1:

[0033] like Figure 1 As shown, the present invention provides a technical solution:

[0034] A method for optimizing reading and writing of interface variables comprises the following steps:

[0035] Create an interface variable management configuration file, which is divided into three levels, namely the interface level, the control level and the control attribute level; the content of each level has a clear definition and structure to ensure the consistency and integrity of the data;

[0036] When entering the software, the interface variable management configuration file is read, and all contents in the interface variable management configuration file are read into the mapping set;

[0037] Create an object pointer to store the control properties of the current interface;

[0038] When opening an interface or switching windows, assign the corresponding address to the object pointer according to the interface name;

[0039] When refreshing the interface, all properties of all controls in the current interface are traversed in sequence;

[0040] Determine the control type, and perform a preset operation according to the control type, wherein the preset operation includes directly displaying when the control type is text, and marking the modified value when the control type is an edit box or a drop-down check box;

[0041] When the interface clicks OK, the mapping set is traversed and the values ​​marked as modified are sent to the programmable logic controller.

[0042] Furthermore, the interface variable management configuration file is created using the JSON configuration file format, which has good readability and extensibility, and is easy to modify and update during the development and maintenance process.

[0043] Furthermore, the interface variable management configuration file is divided into three layers, and the contents stored in the layers are:

[0044] [Screen 1, 2, 3...]

[0045] [Control 1, 2, 3...]

[0046] [Control properties 1, 2, 3... (variable name, title, default value, maximum and minimum values, data format (integer / decimal), unit, etc.)]

[0047] That is to say, the software design method based on the MFC framework associates controls such as text, edit boxes, drop-down check boxes, etc. on the interface with configuration files. The configuration files include variable names, titles, default values, maximum and minimum values, data formats (integer / decimal), units, etc.; this is to solve the problem that when the existing method adds controls, there are too many items to be associated and the code is complicated.

[0048] Embodiment 2:

[0049] Based on Example 1, the content stored in the interface layer is a list of interface names, the content stored in the control layer is a list of controls under each interface, and the content stored in the control attribute layer is a list of attributes for each control.

[0050] That is, the interface layer stores a list of all available interface names, with each name corresponding to an interface. The control layer stores a list of all controls on each interface, with each control having a unique identifier. The control property layer stores detailed property information for each control, including variable name, title, default value, maximum and minimum values, data format (integer / decimal), unit, etc. Through this hierarchical structure, the configuration file can clearly display the controls and their properties of each interface, making it easier for developers to design and debug interfaces.

[0051] Furthermore, when the software starts, the system automatically reads the interface variable management configuration file and loads its contents into the mapping set in memory; the key-value pair structure of the mapping set ensures fast retrieval and efficient management. For example, you can use the interface name as the key and the corresponding control list as the value, and then use the control identifier as the key and the corresponding control attribute list as the value. The process of reading the configuration file includes parsing the file content, verifying the data format and integrity, and filling the data into the mapping set. If any errors are found during the parsing process, the system will record the log and prompt the user to check and correct them.

[0052] Further, if Figure 2 As shown, read the interface variable management configuration file, and read all the contents in the interface variable management configuration file into the jValueMap mapping set;

[0053] Create a JsonValue object pointer: pValueCur, which is used to store all the control properties of the current interface. Object pointers are used to store the control properties of the current interface. This method not only saves memory, but also improves the efficiency of data access. The dynamic management characteristics of object pointers ensure that resources can be quickly released and reallocated when switching interfaces, avoiding memory leaks and unnecessary performance overhead.

[0054] Further reference Figure 2 , when opening an interface or switching windows, the address of the content stored in the jValueMap mapping set is assigned to the JsonValue object pointer: pValueCur according to the interface name. When the user opens a new interface or switches to another window, the system will search for the corresponding control property list from the mapping set according to the name of the current interface, and assign the address of the list to the object pointer. In this way, the object pointer always points to the control properties of the current interface, ensuring the accuracy and real-time nature of the interface data. In order to improve the user experience, some transition animations or prompt information can also be added in this step to inform the progress of the user interface switching.

[0055] Furthermore, when refreshing the interface, the system will traverse the properties of all controls in the current interface and perform different processing according to the control type; the traversal process can be performed in the order of controls to ensure that the properties of each control can be checked and updated; for each control, the system will check its type and perform preset operations. For example, for text controls, the corresponding value is directly displayed; for edit boxes or drop-down check boxes, check whether the value has been modified and mark it accordingly.

[0056] Continue to refer Figure 2 , the preset operations of the control type are as follows:

[0057] Text control: directly reads the value from the control property and displays it. If the value changes, the system automatically updates the display.

[0058] Edit box: First check whether the value is within the preset threshold range (i.e., whether it is within the specified maximum and minimum range), and then determine whether the value has been modified. If the value is within the range and has not been modified, it is displayed in black text on a white background; if the value is not within the range or has been modified, it is displayed in red text on a white background and marked in the object pointer pValueCur.

[0059] Drop-down checkbox: Displays the option content corresponding to the value. If the value has not been modified, it is displayed in black text on a white background; if the value has been modified, it is displayed in red text on a white background and marked in the object pointer pValueCur.

[0060] Through these preset operations, the system can automatically handle different types of controls, reduce the workload of developers, and improve the consistency of the interface and user experience.

[0061] Furthermore, when the interface clicks Confirm, the mapping set (the total object jValueMap) is traversed, all values ​​marked as modified are checked, and all values ​​marked as modified are sent to the PLC; the sending process includes data format conversion and communication protocol processing to ensure that the data can be correctly transmitted to the PLC. In addition, the system will also save all values ​​marked as modified to the interface variable management configuration file so that the latest data can be loaded at the next startup.

[0062] In this embodiment, by storing the controls and their attribute information in the configuration file, the associated items in the code are reduced, making the code more concise and easy to maintain. The hierarchical structure of the configuration file allows only the configuration file to be updated when adding or modifying controls, without modifying a large amount of code, thereby improving the flexibility and scalability of the interface. The system can automatically handle different types of controls and display colors of different states, thereby improving the user's operating experience and the intuitiveness of the interface. By marking the modified values ​​and sending these modified values ​​to the PLC when confirming, the consistency and accuracy of the data are ensured.

[0063] Embodiment 3:

[0064] The present invention provides a technical solution:

[0065] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the aforementioned method for optimizing the reading and writing of interface variables when executing the computer program.

[0066] In this embodiment, the computer system suitable for implementing the electronic device of the embodiment of the present invention includes a central processing unit (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) or the program loaded from the storage part to the random access memory (RAM), such as executing the method described in the above embodiment. In RAM, various programs and data required for system operation are also stored. CPU, ROM and RAM are connected to each other through a bus. Input / output (I / O) interface is also connected to the bus.

[0067] The following components are connected to the I / O interface: an input part including a keyboard, a mouse, etc.; an output part including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as needed. Removable media, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., are installed on the drive as needed so that a computer program read therefrom is installed into the storage part as needed.

[0068] Embodiment 4:

[0069] The present invention provides a technical solution:

[0070] A computer-readable storage medium stores a computer program executable by an electronic device, and when the computer program is run on the electronic device, the electronic device executes the steps of the aforementioned interface variable reading and writing optimization method. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0071] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0072] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0073] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0074] Although example embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above example embodiments are merely exemplary and are not intended to limit the scope of the present application to this. Those of ordinary skill in the art may make various changes and modifications therein without departing from the scope and spirit of the present application. All these changes and modifications are intended to be included within the scope of the present application as required by the appended claims.

[0075] Similarly, it should be understood that in order to streamline the present application and help understand one or more of the various application aspects, in the description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the method of the present application should not be interpreted as reflecting the following intention: the claimed application requires more features than the features clearly stated in each claim. More specifically, as reflected in the corresponding claims, the application point is that the corresponding technical problem can be solved with less than all the features of a single disclosed embodiment. Therefore, the claims following the specific embodiment are hereby explicitly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present application.

[0076] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present application and form different embodiments. For example, in the claims, any one of the claimed embodiments can be used in any combination.

[0077] It should be noted that the above embodiments illustrate rather than limit the present application, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets should not be construed as a limitation to the claims. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names.

Claims

1. A method for optimizing the reading and writing of interface variables, characterized in that: The following steps are involved: Create an interface variable management configuration file, the interface variable management configuration file is divided into three levels, the three levels are the interface layer, the control layer and the control attribute layer; Read all contents in the interface variable management configuration file into a mapping set; Create an object pointer to store the control properties of the current interface; When opening an interface or switching windows, assign the corresponding address to the object pointer according to the interface name; When refreshing the interface, all properties of all controls in the current interface are traversed in sequence; Determine the control type, and perform a preset operation according to the control type, wherein the preset operation includes directly displaying when the control type is text, and marking the modified value when the control type is an edit box or a drop-down check box; When the interface clicks OK, the mapping set is traversed and the values ​​marked as modified are sent to the programmable logic controller.

2. The method for optimizing the reading and writing of interface variables according to claim 1, characterized in that: The content stored in the interface layer is a list of interface names, the content stored in the control layer is a list of controls under each interface, and the content stored in the control attribute layer is a list of attributes for each control.

3. The method for optimizing reading and writing interface variables according to claim 1, characterized in that: The control properties include variable name, title, default value, maximum value, minimum value, data format and unit, and the data format includes integer and decimal.

4. The method for optimizing reading and writing interface variables according to claim 1, characterized in that: Read the interface variable management configuration file, and read all the contents in the interface variable management configuration file into the jValueMap mapping set; Create a JsonValue object pointer, which is used to store all control properties of the current interface.

5. The method for optimizing reading and writing interface variables according to claim 4, characterized in that: When the interface is opened or the window is switched, the address of the content stored in the jValueMap mapping set is assigned to the JsonValue object pointer according to the interface name.

6. The method for optimizing the reading and writing of interface variables according to claim 1, characterized in that: When the control type is an edit box, determining whether the value is within a preset threshold range, and determining whether the value has been modified; Values ​​that are within the preset threshold range and have not been modified are displayed in black text on a white background; Values ​​that are not within the preset threshold range or have been modified are displayed in red letters on a white background, and the modified values ​​are marked in the object pointer.

7. The method for optimizing reading and writing interface variables according to claim 1, characterized in that: When the control type is a drop-down check box, the option content corresponding to the displayed value is displayed in black text on a white background for the unmodified value and in red text on a white background for the modified value, and the modified value is marked in the object pointer.

8. The method for optimizing reading and writing interface variables according to claim 1, characterized in that: When the interface clicks Confirm, the mapping set is traversed, all values ​​marked as modified are sent to the PLC, and all values ​​marked as modified are saved in the interface variable management configuration file.

9. An electronic device, characterized in that: The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and is characterized in that the processor implements the steps of the interface variable reading and writing optimization method described in any one of claims 1 to 8 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of the interface variable reading and writing optimization method described in any one of claims 1 to 8.