Data processing method, device, equipment and storage medium based on Lua scripting language
By adopting data processing methods based on Lua scripting language in the automated data acquisition system, the rapid deployment problem of different electric room acquisition control needs is solved, programming complexity and development costs are reduced, and deployment efficiency is improved.
Patent Information
- Application Number
- CN202210236543.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-10
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-03-10
AI Technical Summary
When facing the acquisition and control needs of different electric rooms, existing automated data acquisition technologies require different settings interfaces, resulting in the pre-written settings interface that cannot meet the needs of rapid deployment, and professional software engineers have high programming requirements, and long development costs and implementation time.
Using a data processing method based on the Lua scripting language, the signal collected by the sensing device is converted into preset five-distance data, pressed into the Lua stack, and the Lua execution script is executed to generate control signals, and sent to the downlink device to perform corresponding operations.
The intermediate interface formed by Wuyao naming is simplified, so that the main program is combined with Lua execution scripts is realized, and the Lua execution scripts are embedded in the main program is reduced, programming complexity and development costs are improved, and deployment efficiency is improved.
Smart Images

Figure CN114624510B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of edge computing, and in particular to a data processing method, device, equipment and storage medium based on the Lua scripting language. Background Art
[0002] With the rapid development of remote meter reading services in power distribution rooms, automated data collection has gradually replaced manual data collection. In automated data collection, data collection control is generally achieved through a pre-written setting interface.
[0003] However, in some cases, it may be necessary to set up different collection and control solutions according to different power rooms, which requires different setting interfaces. Pre-written setting interfaces cannot meet the needs of rapid deployment.
[0004] The existing technical solutions are mainly the following:
[0005] (1) Local collection and cloud control: the data collected locally is sent to the cloud for processing.
[0006] (2) Local acquisition and local control: Professional software engineers use Lua to directly obtain the original acquired data from the serial port and control the processing.
[0007] The above solution (1) will result in a very large amount of data processing in the cloud.
[0008] The above solution (2) is to use Lua language to collect and judge from the front end of the serial port or network port, and then send it to the serial port or network port for control. It requires professional engineers to write the entire program, which requires relatively high programming skills, takes a long time to implement, and has high development costs. Summary of the invention
[0009] The embodiments of the present invention provide a data processing method, device, equipment and storage medium based on Lua scripting language to improve the above problems.
[0010] An embodiment of the present invention provides a data processing method based on the Lua scripting language, which includes:
[0011] Receive signals collected by sensor equipment;
[0012] According to the properties of the signal, the signal is converted into preset five-remote control data through the main program;
[0013] Push the five remote control data into the Lua stack;
[0014] The preset Lua execution script reads and executes the five remote control data in the Lua stack to generate control signals;
[0015] The control signal in the Lua stack is taken out through the main program and sent to the downstream device, so that the downstream device performs corresponding operations according to the control signal.
[0016] Preferably, the main program adopts C language.
[0017] Preferably, the five remote data include global variables and five remote variables exchanged externally; wherein:
[0018] Global variables include:
[0019] ymq, which defines the remote pulse global variable, the type is a 32-bit signed integer;
[0020] ycq, which defines the telemetry global variable, the type is a 32-bit signed symbol;
[0021] The five remote variables exchanged externally include:
[0022] yx, which is defined as the variable of remote signal input, and its type is bit variable;
[0023] yc, which is defined as a telemetry input variable, and its type is a 32-bit signed number;
[0024] yk, which is defined as the variable of remote control output, and its type is bit variable;
[0025] yt is defined as the variable of remote control output, and its type is 32-bit signed symbol.
[0026] Preferably, before receiving the sensor data collected by the sensor device, the method further includes:
[0027] Define the signal name, attributes, and data type;
[0028] Define the type of control signal and generate a forwarding table;
[0029] Configuring an uplink application node and associating it with the forwarding table;
[0030] For the configured upstream application node, configure the Lua execution script.
[0031] The embodiment of the present invention further provides a data processing device based on the Lua scripting language, which includes:
[0032] A signal receiving unit, used to receive signals collected by the sensor device;
[0033] A conversion unit, used for converting the signal into preset five-remote control data through a main program according to the attribute of the signal;
[0034] A push unit, used for pushing the five remote control data into the Lua stack;
[0035] An execution unit, used to read and execute the five remote control data in the Lua stack through a preset Lua execution script to generate a control signal;
[0036] The sending unit is used to take out the control signal in the Lua stack through the main program and send it to the downstream device, so that the downstream device performs corresponding operations according to the control signal.
[0037] Preferably, the main program adopts C language.
[0038] Preferably, the five remote data include global variables and five remote variables exchanged externally; wherein:
[0039] Global variables include:
[0040] ymq, which defines the remote pulse global variable, the type is a 32-bit signed integer;
[0041] ycq, which defines the telemetry global variable, the type is a 32-bit signed symbol;
[0042] The five remote variables exchanged externally include:
[0043] yx, which is defined as the variable of remote signal input, and its type is bit variable;
[0044] yc, which is defined as a telemetry input variable, and its type is a 32-bit signed number;
[0045] yk, which is defined as the variable of remote control output, and its type is bit variable;
[0046] yt is defined as the variable of remote control output, and its type is 32-bit signed symbol.
[0047] Preferably, it also includes:
[0048] The signal definition unit is used to define the name, attributes and data type of the signal;
[0049] A forwarding table unit, used to define the type of control signal and generate a forwarding table;
[0050] A node configuration unit, used to configure an uplink application node and associate it with the forwarding table;
[0051] The script configuration unit is used to configure the Lua execution script for the configured upstream application node.
[0052] An embodiment of the present invention further provides a data processing device based on the Lua scripting language, which includes a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement the data processing method based on the Lua scripting language as described above.
[0053] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program. The computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement the data processing method based on the Lua scripting language as described above.
[0054] The present invention simplifies the intermediate interface formed by the five remote names to enable the main program and the Lua execution script to be combined, thereby realizing the embedding of the Lua execution script in the main program. In this way, the parameters are configured through the configuration tool under the existing product communication management machine, and then the data judgment and processing are written in the simple Lua execution script, without writing the control of collection and transmission, and the deployment is simple, time-saving, and no professional software engineers are required, which greatly improves the deployment efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the implementation mode will be briefly introduced below. Obviously, the drawings described below are only some implementation modes of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0056] Figure 1 A flowchart of a data processing method based on the Lua scripting language is provided for the first embodiment of the present invention.
[0057] Figure 2 A schematic diagram for configuring signal properties.
[0058] Figure 3 This is a schematic diagram for configuring the air conditioning switch.
[0059] Figure 4 A schematic diagram for setting up a forwarding table.
[0060] Figure 5 A schematic diagram of selecting a forwarding table.
[0061] Figure 6 A schematic diagram of embedding Lua to execute scripts.
[0062] Figure 7 A structural schematic diagram of a data processing device based on the Lua scripting language is provided for the second embodiment of the present invention. DETAILED DESCRIPTION
[0063] 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 only 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.
[0064] See also Figure 1 The first embodiment of the present invention provides a data processing method based on the Lua scripting language, which can be executed by a data processing device based on the Lua scripting language (hereinafter referred to as the data processing device), in particular, by one or more processors in the data processing device to implement the following steps:
[0065] S101, receiving a signal collected by a sensor device.
[0066] In this embodiment, the data processing device is an edge computing device, such as a gateway, etc. The data processing device can receive signals collected by a sensor device arranged on site.
[0067] For example, the sensing device may be a temperature sensor, a humidity sensor, a smoke sensor, etc., and its corresponding signal may be a temperature signal, a humidity signal or a smoke signal, etc. The present invention does not limit the sensing device.
[0068] S102, converting the signal into preset five-remote control data through a main program according to the attributes of the signal.
[0069] S103, pushing the five remote control data into the Lua stack;
[0070] S104, reading and executing the five remote control data in the Lua stack through a preset Lua execution script to generate a control signal;
[0071] S105, taking out the control signal in the Lua stack through the main program, and sending it to the downstream device, so that the downstream device performs a corresponding operation according to the control signal.
[0072] In the prior art, in order to process a newly added sensor signal, it is often necessary to write a complete program from scratch, which results in a lot of development work.
[0073] In this embodiment, in order to improve this situation, an intermediate interface formed by simplifying the five remote naming is added and combined with the Lua execution script. Specifically:
[0074] Simplified five-remote naming includes global variables and five-remote variables exchanged externally; global variables include:
[0075] ymq is a global variable of the remote pulse, and its type is a 32-bit signed integer.
[0076] ycq is a telemetry global variable, the type is a 32-bit signed integer
[0077] The five remote variables exchanged externally include:
[0078] yx remote signal input variable, type is bit variable
[0079] yc telemetry input variable, type is 32-bit signed symbol
[0080] yk remote control output variable, type is bit variable
[0081] yt remote control output variable, type is 32-bit signed symbol
[0082] Since different variables require different signals, this embodiment sets the serial number to a fixed two-digit number, starting from 00 to 99, for example: yx00 telesignal 00, yc01 telemetry 01.
[0083] Of course, it should be noted that in other embodiments of the present invention, the identification and serial number digits of the global variables and the five remote variables exchanged externally can be replaced according to actual needs. These schemes are within the protection scope of the present invention and will not be elaborated in detail in the present invention.
[0084] In this embodiment, after the signal is acquired, it can be converted into an array defined by the main program (generally in C language) according to the simplified five-remote naming mentioned above, and the corresponding five-remote data is generated. Then, the five-remote data is pushed into the Lua stack according to the naming method. Next, the corresponding Lua execution script is executed to generate the corresponding control signal, and then the control signal is retrieved back to the main program, thereby embedding the Lua execution script in the main program, realizing the reference to the Lua execution script in the main program.
[0085] To facilitate understanding of the present invention, a practical example is used below to illustrate the application of the present invention.
[0086] Take the example of controlling the switch of the air conditioner of the downstream equipment according to the temperature:
[0087] First, call the configuration tool to configure the parameters:
[0088] like Figure 2 As shown, configure the signal name, attributes, and data type.
[0089] If the name is Temperature, the property is Telemetry, and the data type is 16-bit unsigned integer.
[0090] Then, if Figure 3 As shown, configure the start signal and the shut down signal of the air conditioner switch.
[0091] Then, if Figure 4 As shown, the above configuration is saved through the forwarding table.
[0092] Then, if Figure 5 As shown, configure an upstream application node and select a saved forwarding table.
[0093] Finally, if Figure 6 As shown, write the Lua execution script according to the control logic.
[0094] In this way, the preliminary configuration work is completed.
[0095] When executing:
[0096] First, the signal collected by the sensor device (ie, the temperature signal) is stored in a five-remote array defined by a main program (eg, C language).
[0097] Then, the five remote controllers are pushed into the Lua stack according to the naming method. The specific implementation code is as follows:
[0098] sprintf(tempname,"yx%02d",i);
[0099] lua_pushinteger(L,p_Para->TaskYXpt[i]);
[0100] lua_setglobal(L,tempname);
[0101] Next, run Lua to execute the script: lua:luaL_dostring(L,p_Para->luacode);
[0102]
[0103]
[0104] When running Lua to execute the script, a control signal will be generated according to the current signal. For example, when the temperature is greater than 30 degrees, Ymq00=1; when the temperature is less than 28 degrees, Ymq00=0.
[0105] Finally, retrieve the control signal, that is, retrieve the control signal from the Lua stack back to the main program.
[0106]
[0107] As can be seen from the above, the present invention enables the main program and the Lua execution script to be combined by simplifying the intermediate interface formed by the five remote names, thereby realizing the embedding of the Lua execution script in the main program. In this way, parameter configuration is performed through the configuration tool under the existing product communication management machine, and then data judgment and processing are written in a simple Lua execution script, without the need to write collection and transmission control, and the deployment is simple, time-saving, and does not require professional software engineers, which greatly improves the deployment efficiency.
[0108] See also Figure 7 The second embodiment of the present invention further provides a data processing device based on the Lua scripting language, which includes:
[0109] A signal receiving unit 210, used to receive signals collected by a sensor device;
[0110] The conversion unit 220 is used to convert the signal into preset five remote control data according to the attribute of the signal through the main program;
[0111] A push unit 230, used for pushing the five remote data into the Lua stack;
[0112] The execution unit 240 is used to read and execute the five remote control data in the Lua stack through a preset Lua execution script to generate a control signal;
[0113] The sending unit 250 is used to take out the control signal in the Lua stack through the main program and send it to the downstream device, so that the downstream device performs corresponding operations according to the control signal.
[0114] Preferably, the main program adopts C language.
[0115] Preferably, the five remote data include global variables and five remote variables exchanged externally; wherein:
[0116] Global variables include:
[0117] ymq, which defines the remote pulse global variable, the type is a 32-bit signed integer;
[0118] ycq, which defines the telemetry global variable, the type is a 32-bit signed symbol;
[0119] The five remote variables exchanged externally include:
[0120] yx, which is defined as the variable of remote signal input, and its type is bit variable;
[0121] yc, which is defined as a telemetry input variable, and its type is a 32-bit signed number;
[0122] yk, which is defined as the variable of remote control output, and its type is bit variable;
[0123] yt is defined as the variable of remote control output, and its type is 32-bit signed symbol.
[0124] Preferably, it also includes:
[0125] The signal definition unit is used to define the name, attributes and data type of the signal;
[0126] A forwarding table unit, used to define the type of control signal and generate a forwarding table;
[0127] A node configuration unit, used to configure an uplink application node and associate it with the forwarding table;
[0128] The script configuration unit is used to configure the Lua execution script for the configured upstream application node.
[0129] The third embodiment of the present invention further provides a data processing device based on the Lua scripting language, which includes a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement the data processing method based on the Lua scripting language as described above.
[0130] The fourth embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement the data processing method based on the Lua scripting language as described above.
[0131] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention 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 data processing method based on Lua scripting language, characterized in that: include: Receive signals collected by sensor equipment; According to the properties of the signal, the signal is converted into preset five-remote control data through the main program; The five remote data include global variables and five remote variables exchanged externally; wherein: the global variables include: ymq, which defines the remote pulse global variable, the type is a 32-bit signed integer; ycq, which defines the telemetry global variable, the type is a 32-bit signed symbol number; the five remote variables exchanged externally include: yx, which is defined as the variable of the remote signal input, the type is a bit variable; yc, which is defined as the variable of the telemetry input, the type is a 32-bit signed symbol number; yk, which is defined as the variable of the remote control output, the type is a bit variable; yt, which is defined as the variable of the remote adjustment output, the type is a 32-bit signed symbol number; Push the five remote control data into the Lua stack; The preset Lua execution script reads and executes the five remote control data in the Lua stack to generate control signals; The control signal in the Lua stack is taken out through the main program and sent to the downstream device, so that the downstream device performs corresponding operations according to the control signal.
2. The data processing method based on Lua scripting language according to claim 1, characterized in that: The main program adopts C language.
3. The data processing method based on Lua scripting language according to claim 1, characterized in that: Before receiving the sensor data collected by the sensor device, it also includes: Define the signal name, attributes, and data type; Define the type of control signal and generate a forwarding table; Configuring an uplink application node and associating it with the forwarding table; For the configured upstream application node, configure the Lua execution script.
4. A data processing device based on Lua scripting language, characterized in that: include: A signal receiving unit, used to receive signals collected by the sensor device; The conversion unit is used to convert the signal into preset five remote data through the main program according to the attribute of the signal; the five remote data include global variables and five remote variables exchanged externally; wherein: the global variables include: ymq, which defines the remote pulse global variable, the type is a 32-bit signed integer; ycq, which defines the telemetry global variable, the type is a 32-bit signed symbol point number; the five remote variables exchanged externally include: yx, which is defined as the variable of the telesignal input, the type is a bit variable; yc, which is defined as the variable of the telemetry input, the type is a 32-bit signed symbol point number; yk, which is defined as the variable of the remote control output, the type is a bit variable; yt, which is defined as the variable of the remote adjustment output, the type is a 32-bit signed symbol point number; A push unit, used for pushing the five remote control data into the Lua stack; An execution unit, used to read and execute the five remote control data in the Lua stack through a preset Lua execution script to generate a control signal; The sending unit is used to take out the control signal in the Lua stack through the main program and send it to the downstream device, so that the downstream device performs corresponding operations according to the control signal.
5. The data processing device based on Lua scripting language according to claim 4, characterized in that: The main program adopts C language.
6. The data processing device based on Lua scripting language according to claim 4, characterized in that: Also includes: The signal definition unit is used to define the name, attributes and data type of the signal; A forwarding table unit, used to define the type of control signal and generate a forwarding table; A node configuration unit, used to configure an uplink application node and associate it with the forwarding table; The script configuration unit is used to configure the Lua execution script for the configured upstream application node.
7. A data processing device based on Lua scripting language, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement the data processing method based on the Lua scripting language as described in any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor of the device where the computer-readable storage medium is located to implement the data processing method based on the Lua scripting language as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Electrical equipment remote control locking characteristic simulation method based on LUA scripts
CN106647337A
Automatic testing system and method for intelligent transformer terminal based on LUA scripts
CN107544910A