Mode switching method and device and serial port screen
Obtaining and encapsulating control parameters through Lua programming technology solves the problem of cumbersome serial port screen mode switching, achieves fast switching and flexible management, and improves operating efficiency and user experience.
Patent Information
- Application Number
- CN202410796629.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-06-19
AI Technical Summary
Traditional serial port screens require repeated input or selection of parameter values when switching modes, resulting in cumbersome operations, low user operation efficiency and prone to errors.
Lua programming technology is used to obtain control parameters, determine the mode to be switched, and use the Convert function to encapsulate the control parameters in the corresponding state variables of the Select control and store them in the Flash address to achieve mode switching and visual parameter updates.
It simplifies the mode switching process, improves operating efficiency and user experience, reduces the risk of operating errors, and enhances the flexible management of control status and the convenience of mode switching.
Smart Images

Figure CN118796733A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent industrial control technology, and in particular to a mode switching method and a serial port screen. Background Art
[0002] In the field of modern industrial control, serial port screens, as a common human-computer interaction device, are widely used in various automation equipment and instruments.
[0003] However, the traditional serial port screen has some problems in the control state management and mode switching, such as cumbersome operation, inconvenient state switching, etc., resulting in low user operation efficiency and easy operation errors. Specifically, the user operation is cumbersome, and it is necessary to click the screen multiple times to switch different modes or adjust the control state, resulting in low operation efficiency. In addition, the management and preservation of the control state are not flexible enough, and users often need to set parameters repeatedly, which increases the complexity of operation and the risk of user operation errors. Therefore, the existing serial port screen solution has at least the following disadvantages: traditional serial port screen: weak logic, need to be enumerated, large Flash, high cost; Android / Linux screen: high cost; when users set parameters in the existing serial port screen technology, they may need to repeatedly enter or select parameter values, which is cumbersome. This cumbersome parameter setting process may increase the user's operation burden and the possibility of error. In view of the problem that the current serial port screen needs to repeatedly enter or select parameter values when switching modes, resulting in cumbersome operation, it is necessary to further study the mode switching method. Summary of the invention
[0004] The embodiments of the present invention provide a mode switching method, device and serial port screen to solve the problem that the serial port screen needs to repeatedly input or select parameter values when switching modes, resulting in cumbersome operations.
[0005] On the one hand, the present invention provides a mode switching method, which is applied to a serial port screen, comprising:
[0006] Get control parameters based on Lua programming technology;
[0007] Determine the waiting mode corresponding to the control parameters;
[0008] According to the mode to be switched, the Convert function is used to encapsulate the control parameters in the corresponding state variables of the Select control. The state variables are used to update the Select control. The Select control includes two or more state address groups with different priority levels. Each state address group includes two or more state address blocks with different priority levels. The state variables are stored in the state address blocks. The mode selection corresponds to the state address block one by one.
[0009] Store the state variables in the corresponding Flash address;
[0010] The mode is switched according to the mode to be switched and the state variable and the visualization parameters in the updated Flash address are displayed.
[0011] Furthermore, after the step of storing the state variable in the corresponding Flash address, the method further includes:
[0012] The assignment displays the result of storing the state variable in the corresponding Flash address.
[0013] Furthermore, the control parameters include Parameter1, Parameter2 and Parameter3.
[0014] Furthermore, the mode to be switched corresponds to the data in the Schedule table in the Select control, and the step of determining the mode to be switched corresponding to the control parameter includes:
[0015] The waiting mode is selected first according to the value of Parameter1;
[0016] When the value of Parameter1 is 0, the waiting mode is selected according to the value of Parameter2;
[0017] When the values of Parameter1 and Parameter2 are both 0, the waiting mode is selected according to the value of Parameter3.
[0018] Furthermore, according to the mode to be switched, the step of encapsulating the control parameter in the corresponding state variable of the Select control using the Convert function includes:
[0019] When the value of Parameter1 is not 0, the control parameter is encapsulated in State1 in the Schedule table;
[0020] When the value of Parameter1 is 0 and the value of Parameter2 is not 0, the control parameters are encapsulated in State2 in the Schedule table;
[0021] When the values of Parameter1 and Parameter2 are both 0, and the value of Parameter3 is not 0, the control parameters are encapsulated in State3 in the Schedule table.
[0022] In order to solve the problem that the current serial port screen needs to repeatedly input or select parameter values when switching modes, resulting in cumbersome operations, the present invention discloses a mode switching method, which is applied to the serial port screen, including: obtaining control parameters based on Lua programming technology; judging the to-be-cut mode corresponding to the control parameters; according to the to-be-cut mode, using the Convert function to encapsulate the control parameters in the corresponding state variables of the Select control, the state variables are used to update the Select control, the Select control includes two or more state address groups with different priority levels, each state address group includes two or more state address blocks with different priority levels, the state variables are stored in the state address blocks, and the mode selection corresponds to the state address blocks one by one; storing the state variables in the corresponding Flash address; switching the mode according to the to-be-cut mode and the state variables and displaying the visual parameters in the updated Flash address.
[0023] Compared with the prior art, the present invention has the following advantages:
[0024] Through Lua programming technology, the control parameters are obtained at one time, the corresponding mode judgment and state variable encapsulation and update in Flash are completed, and finally the mode is switched and the corresponding Flash is displayed, which solves the problem that the serial port screen needs to repeatedly enter or select parameter values when switching modes, resulting in cumbersome operations.
[0025] In another aspect, the present invention provides a mode switching device, comprising:
[0026] Acquisition module, used to obtain control parameters based on Lua programming technology;
[0027] A judgment module, used to judge the to-be-cut mode corresponding to the control parameter;
[0028] The encapsulation module is used to encapsulate the control parameters into the corresponding state variables of the Select control using the Convert function according to the mode to be switched. The state variables are used to update the Select control. The Select control includes two or more state address groups with different priority levels. Each state address group includes two or more state address blocks with different priority levels. The state variables are stored in the state address blocks. The mode selection corresponds to the state address block one by one.
[0029] A storage module is used to store the state variables into the corresponding Flash address;
[0030] The switching module is used to switch the mode according to the mode to be switched and the state variable and display the visualization parameters in the updated Flash address.
[0031] Furthermore, it also includes:
[0032] The display module is used to assign the display state variable to the result stored in the corresponding Flash address.
[0033] Furthermore, the control parameters include Parameter1, Parameter2 and Parameter3.
[0034] Furthermore, the judgment module is also used for:
[0035] The waiting mode is selected first according to the value of Parameter1;
[0036] When the value of Parameter1 is 0, the waiting mode is selected according to the value of Parameter2;
[0037] When the values of Parameter1 and Parameter2 are both 0, the waiting mode is selected according to the value of Parameter3;
[0038] The package module is also used to:
[0039] When the value of Parameter1 is not 0, the control parameter is encapsulated in State1 in the Schedule table;
[0040] When the value of Parameter1 is 0 and the value of Parameter2 is not 0, the control parameters are encapsulated in State2 in the Schedule table;
[0041] When the values of Parameter1 and Parameter2 are both 0, and the value of Parameter3 is not 0, the control parameters are encapsulated in State3 in the Schedule table.
[0042] On the other hand, the present invention provides a serial port screen, including a screen and the above-mentioned mode switching device. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0044] Figure 1 is a flow chart of a mode switching method according to an embodiment of the present invention.
[0045] Figure 2 FIG. 4 is a schematic diagram of a mode switching device according to another embodiment of the present invention. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] See also Figure 1 , a mode switching method according to an embodiment of the present invention comprises the following steps:
[0048] Step 11, obtaining control parameters based on Lua programming technology.
[0049] In the embodiment of the present invention, the control parameters include multiple values such as Parameter1, Parameter2 and Parameter3.
[0050] Step 12, determining the to-be-cut mode corresponding to the control parameter.
[0051] In this step, the mode to be switched corresponds to the data in the Schedule table in the Select control. Step 12 may specifically include:
[0052] The waiting mode is selected first according to the value of Parameter1;
[0053] When the value of Parameter1 is 0, the waiting mode is selected according to the value of Parameter2;
[0054] When the values of Parameter1 and Parameter2 are both 0, the waiting mode is selected according to the value of Parameter3.
[0055] Step 13, according to the mode to be switched, use the Convert function to encapsulate the control parameters in the corresponding state variables of the Select control. The state variables are used to update the Select control. The Select control includes two or more state address groups with different priority levels. Each state address group includes two or more state address blocks with different priority levels. The state variables are stored in the state address blocks, and the mode selection corresponds one-to-one to the state address blocks.
[0056] In the embodiment of the present invention, step 13 may specifically include:
[0057] When the value of Parameter1 is not 0, the control parameter is encapsulated in State1 in the Schedule table; that is, Parameter1 corresponds to the state address group with a high priority level;
[0058] When the value of Parameter1 is 0 and the value of Parameter2 is not 0, the control parameters are encapsulated in State2 in the Schedule table; Parameter2 corresponds to the state address group with medium priority;
[0059] When the values of Parameter1 and Parameter2 are both 0, and the value of Parameter3 is not 0, the control parameters are encapsulated in State3 in the Schedule table; Parameter3 corresponds to the state address group with a low priority.
[0060] Step 14, store the state variable into the corresponding Flash address.
[0061] In the embodiment of the present invention, after step 14, the method further includes:
[0062] The assignment displays the result of the state variable being stored in the corresponding Flash address. That is, the data in the Select table will be stored in the corresponding Flash address, and the assignment displays when reading the data.
[0063] Step 15: Switch the mode according to the mode to be switched and the state variable and display the visualization parameters in the updated Flash address.
[0064] In this step, the corresponding mode is switched to display the data stored in the flash, or the data is stored in the corresponding flash.
[0065] The existing serial port screen generally controls the state switching of the serial port screen through the host computer development software or through the single-chip microcomputer MCU. However, after downloading the project through the development software, it is difficult to affect the controls of the serial port screen, and the control state cannot be adjusted in real time. And by sending serial port instructions to set the serial port screen state through the single-chip microcomputer MCU, it is impossible to switch all the control states at the same time. The embodiment of the present invention obtains the control parameters at one time through the Lua programming technology, completes the corresponding judgment of the mode to be cut and the encapsulation of the state variables and the update in Flash, and finally switches the mode and displays the corresponding Flash, which solves the problem that the current serial port screen needs to repeatedly input or select parameter values when switching modes, resulting in cumbersome operations.
[0066] The embodiment of the present invention uses a Lua script control operating system, so that users can implement complex logical operations, automatically sort according to the rules, reduce the logical operations of the user's mainboard, and improve the operating efficiency and user experience of the serial port screen. The control operating system realizes flexible management of the control state and rapid switching of modes through functions such as initialization function, timing callback function, and timer timeout callback function, so that users can easily operate and control the serial port screen device. The technical advantage is that it simplifies the operation process of the serial port screen and enhances user interactivity. The expected effect is to improve system stability, reduce operating errors, and bring a more intelligent and convenient operating experience to the field of industrial control. In the future, the control operating system is expected to be widely used in industrial automation, intelligent instrumentation and other fields, and play an important role in improving industrial production efficiency and quality.
[0067] See also Figure 2 A mode switching device 20 according to another embodiment of the present invention can be used to implement the corresponding steps of the above method embodiment, including:
[0068] An acquisition module 21 is used to acquire control parameters based on Lua programming technology;
[0069] A judgment module 22, used for judging the to-be-switched mode corresponding to the control parameter;
[0070] The encapsulation module 23 is used to encapsulate the control parameters into the corresponding state variables of the Select control by using the Convert function according to the mode to be switched. The state variables are used to update the Select control. The Select control includes two or more state address groups with different priority levels. Each state address group includes two or more state address blocks with different priority levels. The state variables are stored in the state address blocks. The mode selection corresponds to the state address block one by one.
[0071] The storage module 24 is used to store the state variables into the corresponding Flash address;
[0072] The switching module 25 is used to switch the mode according to the mode to be switched and the state variable and display the visualization parameters in the updated Flash address.
[0073] As one implementation manner, the mode switching device 20 further includes:
[0074] The display module is used to assign the display state variable to the result stored in the corresponding Flash address.
[0075] Furthermore, the control parameters include Parameter1, Parameter2 and Parameter3.
[0076] Furthermore, the determination module 22 is also used for:
[0077] The waiting mode is selected first according to the value of Parameter1;
[0078] When the value of Parameter1 is 0, the waiting mode is selected according to the value of Parameter2;
[0079] When the values of Parameter1 and Parameter2 are both 0, the waiting mode is selected according to the value of Parameter3;
[0080] The encapsulation module 23 is also used for:
[0081] When the value of Parameter1 is not 0, the control parameter is encapsulated in State1 in the Schedule table;
[0082] When the value of Parameter1 is 0 and the value of Parameter2 is not 0, the control parameters are encapsulated in State2 in the Schedule table;
[0083] When the values of Parameter1 and Parameter2 are both 0, and the value of Parameter3 is not 0, the control parameters are encapsulated in State3 in the Schedule table.
[0084] On the other hand, the present invention provides a serial port screen, including a screen and the above-mentioned mode switching device 20.
[0085] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0086] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A mode switching method, applied to a serial port screen, characterized in that: include: Get control parameters based on Lua programming technology; Determine the to-be-cut mode corresponding to the control parameter; According to the mode to be switched, the control parameter is encapsulated in the corresponding state variable of the Select control by using the Convert function, the state variable is used to update the Select control, the Select control includes two or more state address groups with different priority levels, each state address group includes two or more state address blocks with different priority levels, the state variable is stored in the state address block, and the mode selection corresponds to the state address block one by one; Storing the state variable in the corresponding Flash address; The mode is switched according to the mode to be switched and the state variable, and the updated visualization parameters in the Flash address are displayed.
2. The mode switching method according to claim 1, characterized in that: After the step of storing the state variable in the corresponding Flash address, the method further includes: The assignment displays the result of storing the state variable in the corresponding Flash address.
3. The mode switching method according to claim 1, characterized in that: The control parameters include Parameter1, Parameter2 and Parameter3.
4. The mode switching method according to claim 3, characterized in that: The mode to be cut corresponds to the data in the Schedule table in the Select control, and the step of determining the mode to be cut corresponding to the control parameter includes: Preferentially selecting the to-be-cut mode according to the value of Parameter 1; When the value of Parameter 1 is 0, the waiting mode is selected according to the value of Parameter 2; When the values of Parameter1 and Parameter2 are both 0, the to-be-cut mode is selected according to the value of Parameter3.
5. The mode switching method according to claim 4, characterized in that: The step of encapsulating the control parameter in the corresponding state variable of the Select control by using the Convert function according to the to-be-cut mode includes: When the value of Parameter1 is not 0, encapsulate the control parameter in State1 in the Schedule table; When the value of Parameter1 is 0 and the value of Parameter2 is not 0, the control parameter is encapsulated in State2 in the Schedule table; When the values of Parameter1 and Parameter2 are both 0, and the value of Parameter3 is not 0, the control parameters are encapsulated in State3 in the Schedule table.
6. A mode switching device, characterized in that: include: The acquisition module is used to obtain control parameters based on Lua programming technology; A judgment module, used for judging the to-be-switched mode corresponding to the control parameter; An encapsulation module, used for encapsulating the control parameters into corresponding state variables of the Select control by using a Convert function according to the mode to be switched, wherein the state variables are used to update the Select control, wherein the Select control includes two or more state address groups with different priority levels, each state address group includes two or more state address blocks with different priority levels, the state variables are stored in the state address blocks, and the mode selection corresponds one-to-one to the state address blocks; A storage module, used for storing the state variable into a corresponding Flash address; A switching module is used to switch the mode according to the mode to be switched and the state variable and to display the updated visualization parameters in the Flash address.
7. The mode switching device according to claim 6, characterized in that: Also includes: The display module is used to assign and display the result of storing the state variable in the corresponding Flash address.
8. The mode switching device according to claim 6, characterized in that: The control parameters include Parameter1, Parameter2 and Parameter3.
9. The mode switching device according to claim 8, characterized in that: The judging module is also used for: Preferentially selecting the to-be-cut mode according to the value of Parameter 1; When the value of Parameter 1 is 0, the waiting mode is selected according to the value of Parameter 2; When the values of Parameter1 and Parameter2 are both 0, the to-be-cut mode is selected according to the value of Parameter3; The packaging module is also used for: When the value of Parameter1 is not 0, the control parameter is encapsulated in State1 in the Schedule table; When the value of Parameter1 is 0 and the value of Parameter2 is not 0, the control parameter is encapsulated in State2 in the Schedule table; When the values of Parameter1 and Parameter2 are both 0, and the value of Parameter3 is not 0, the control parameters are encapsulated in State3 in the Schedule table.
10. A serial port screen, characterized in that: The serial port screen comprises a screen and a mode switching device as described in any one of claims 6 to 9.
Citation Information
Patent Citations
Serial use-right control device and method
CN101908025A
Background picture replacing method and device
CN104239085A
Method for realizing synchronous frame display by double-serial-port screen
CN111240619A
Method and apparatus for setting values of parameters
US20160283187A1
