Multi-thread-based power grid monitoring real-time data display method, system and equipment and storage medium
Through multi-threading technology, the modules are combined in the power grid monitoring system for real-time data display, the problem of inefficient real-time data display of the power grid monitoring system is solved, rapid refresh and push are achieved, and response speed and system maintainability are improved.
Patent Information
- Application Number
- CN202411299222.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-14
AI Technical Summary
The power grid monitoring system is inefficient in real-time data display, resulting in slow detection and processing of potential safety hazards, and the inability to quickly refresh the data of multiple applications.
Using multi-threading technology, through the combination of WEB graphics display module, WEB graphics service module, real-time data calculation module and real-time data push module, WebSocket connection is established, data analysis, cache, calculation and serialization is carried out, and real-time data refresh and Push.
It improves CPU utilization, meets the real-time data refresh needs of multiple applications, significantly accelerates the response speed, and improves the maintainability and reusability of the power grid monitoring system.
Smart Images

Figure CN119315702A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power grid control, and in particular to a method, system, device and storage medium for displaying real-time data of power grid monitoring based on multi-threading. Background Art
[0002] With the rapid development of modern society, electricity has become a necessity in people's daily life and work. In order to ensure the stability and safety of power grid operation, power grid monitoring systems have come into being.
[0003] The power grid monitoring system is an intelligent system specially used to monitor the operation status of the power grid and ensure the safety of power supply. It can timely discover potential safety hazards by real-time monitoring of various data generated by the power grid during operation, and remind the operation and maintenance personnel to take corresponding measures in time through early warning and alarm mechanisms, so as to ensure the stable operation of the power grid.
[0004] In the actual operation of the power grid, various data generated by the operation will be stored separately according to different applications. In order to quickly and timely discover potential safety hazards, the power grid monitoring system needs to quickly display a large amount of power grid operation data scattered in various applications on the monitoring screen. Therefore, it is necessary to design a fast and efficient real-time data display method for the power grid monitoring system. Summary of the invention
[0005] Purpose of the invention: The present invention aims to provide a multi-threaded power grid monitoring real-time data display method to solve the problem of low efficiency of real-time data display in power grid monitoring systems; another purpose of the present invention is to provide a multi-threaded power grid monitoring real-time data display system, device and storage medium.
[0006] Technical solution: The multi-threaded power grid monitoring real-time data display method of the present invention comprises the following steps:
[0007] (1) The WEB graphics display module sends a request to the WEB graphics service module to establish a WebSocket connection;
[0008] (2) The WEB graphics service module parses the received request message and caches it using a classification algorithm;
[0009] (3) The real-time data calculation module starts the scheduled query function and uses multi-threading technology to calculate the changed data object set and send the calculation results to the real-time data push module;
[0010] (4) The real-time data push module uses multi-threading technology to serialize the received data set into JSON and pushes the result to the WEB graphic display module;
[0011] (5) The WEB graphic display module parses the received results, refreshes the dynamic data, and updates the page.
[0012] Furthermore, step (1) is as follows: the WEB graphics display module creates a request message, defines the client unique identifier clientID and the data identifier set keyIDs in the request message, and sends the message to the WEB graphics service module via an Http request, and the WEB graphics display module and the WEB graphics service module establish a WebSocket connection.
[0013] Furthermore, step (2) is specifically as follows:
[0014] (21) The WEB graphic service module receives the request message sent by the WEB graphic display module and parses the request message;
[0015] (22) caching the client ID and the data ID set keyIDs in a key-value pair manner;
[0016] (23) The data identifier keyID in the data identifier set keyIDs is cached according to the application number AppID, and the cache is cached in a key-value pair manner, where the Key is the application number and the Value is the data object set corresponding to the application number.
[0017] Furthermore, step (3) is as follows:
[0018] (31) The real-time data calculation module initializes the thread pool;
[0019] (32) Start the scheduled task to periodically execute the computing task at fixed time intervals;
[0020] (33) looping through the key-value pairs cached in step (23), creating a thread task for each application number, and submitting the thread task to the thread pool of step (31). The application number and the data object set corresponding to the application number will be set as member variables of the thread task;
[0021] (34) The call() method in each thread task reads the corresponding data result from the specified application according to the application number in the thread task and the data object set corresponding to the application number, sets the read data result into the data object, uses the comparison algorithm to filter out the changed data object set and returns it to the main thread;
[0022] (35) The main thread first loops through the set of changed data objects filtered out in step (34), and then loops through the key-value pairs cached in step (22). The changed data objects are added to the set of data objects returned to each client through a hash algorithm, and the changed data object set is sent to the real-time data push module.
[0023] Furthermore, step (4) is specifically as follows:
[0024] (41) The real-time data push module completes thread pool initialization;
[0025] (42) looping through the changed data object set returned in step (35), creating a thread task for each client unique identifier clientID in each loop, and submitting the thread task to the thread pool created in step (41);
[0026] (43) When creating a thread task, the data object set returned to each client will be set as a member variable of the thread task;
[0027] (44) The call() method in each thread task serializes the data object set returned to the client in the thread task into JSON, and after serialization is completed, pushes the data to the WEB graphics display module through WebSocket.
[0028] Furthermore, step (5) is specifically as follows: after receiving the data object set to be refreshed, the WEB graphic display module parses the data object set to be refreshed, completes the update of the corresponding dynamic data according to the data identifier, and realizes the refresh of real-time data.
[0029] The multi-threaded power grid monitoring real-time data display system of the present invention includes the following modules:
[0030] WEB graphic display module, used to display real-time data of power grid monitoring;
[0031] WEB graphics service module, used for parsing request messages and categorizing and caching data;
[0032] Real-time data calculation module, used for scheduled query of real-time data and calculation of data changes;
[0033] Real-time data push module, used for serialization and data push of real-time data.
[0034] Furthermore, the real-time data calculation module performs a timed query of real-time data and calculation of data changes, as follows:
[0035] (31) The real-time data calculation module initializes the thread pool;
[0036] (32) Start the scheduled task to periodically execute the computing task at fixed time intervals;
[0037] (33) looping through the key-value pairs cached in step (23), creating a thread task for each application number, and submitting the thread task to the thread pool of step (31). The application number and the data object set corresponding to the application number will be set as member variables of the thread task;
[0038] (34) The call() method in each thread task reads the corresponding data result from the specified application according to the application number in the thread task and the data object set corresponding to the application number, sets the read data result into the data object, uses the comparison algorithm to filter out the changed data object set and returns it to the main thread;
[0039] (35) The main thread first loops through the changed data object set filtered out in step (34), then loops through the key-value pairs cached in step (22), adds the changed data objects to the data object set returned to each client through a hash algorithm, and sends the changed data object set to the real-time data push module;
[0040] The real-time data push module performs real-time data serialization and data push, as follows:
[0041] (41) The real-time data push module completes thread pool initialization;
[0042] (42) looping through the changed data object set returned in step (35), creating a thread task for each client unique identifier clientID in each loop, and submitting the thread task to the thread pool created in step (41);
[0043] (43) When creating a thread task, the data object set returned to each client will be set as a member variable of the thread task;
[0044] (44) The call() method in each thread task serializes the data object set returned to the client in the thread task into JSON, and after serialization is completed, pushes the data to the WEB graphics display module through WebSocket.
[0045] The computer device of the present invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the steps of the above method are implemented when the processor executes the computer program.
[0046] The computer-readable storage medium of the present invention stores a computer program thereon, and the computer program implements the steps of the above method when executed by a processor.
[0047] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: 1. The present invention uses multi-threading to improve CPU utilization, meets the real-time data refresh requirements of multiple applications in the power grid monitoring system, solves the problem of low efficiency in real-time data display in the power grid monitoring system, and speeds up the response speed; 2. The present invention adopts a modular design, each module only focuses on specific functions, and achieves a high cohesion and low coupling design by clearly defining the interfaces between modules, thereby improving the maintainability and reusability of the power grid monitoring system. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a schematic diagram of the process of the present invention;
[0049] Figure 2 This is a structural diagram of the real-time data display system for power grid monitoring based on multi-threading. DETAILED DESCRIPTION
[0050] The present invention will be further described below in conjunction with the accompanying drawings.
[0051] like Figure 1 As shown, the multi-threaded power grid monitoring real-time data display method of the present invention includes the following steps:
[0052] (1) The WEB graphics display module creates a request message method: First, a JSON object is created to create a request message. Then, two attributes, the client ID and the data ID set keyIDs, are added to the created JSON object. Finally, an Http request is sent to the WEB graphics service module through Ajax. The request method is POST.
[0053] (2) Method for establishing a WebSocket connection between the WEB graphics display module and the WEB graphics service module: The WEB graphics service module uses the spring-boot-starter-websocket framework to build a WebSocket server, and the WEB graphics display module uses the WebSocket API in JavaScript to establish a connection with the WEB graphics service module. The WEB graphics display module monitors the onopen (connection established successfully), onmessage (message received), and onclose (connection closed) events of WebSocket.
[0054] (3) Web graphics service module caching method: The web graphics service module parses the received request message and caches the client ID and the data ID set keyIDs. The caching algorithm includes the following steps:
[0055] (31) After receiving the request message sent by the client, the WEB graphics service module first parses the message to obtain the two attributes of the client unique identifier clientID and the data identifier set keyIDs;
[0056] (32) Then the data identification set keyIDs is converted into a java.util.HashSet data structure, and then java.util.concurrent.ConcurrentHashMap is used to cache the client unique identifier clientID and the data identification set keyIDs;
[0057] (33) Finally, the data identifier keyID in the data identifier set keyIDs is cut by the delimiter to obtain the application number AppID of each data identifier, and a data object keyObj is created for each data identifier. The data structure of the cache container is <application number AppID, sub-cache container>. When the sub-cache container corresponding to the application number in the cache container does not exist, a sub-cache container is created. The data structure of the sub-cache container is <data identifier keyID, data object keyObj>, and the data identifier keyID and the data object keyObj are cached in the sub-cache container. Both the cache container and the sub-cache container use the java.util.concurrent.ConcurrentHashMap data structure.
[0058] (4) Real-time data calculation module calculation method: Create an independent thread for each application. Each thread task is responsible for the data calculation function of a data identifier set of an independent application. These thread tasks are executed through the thread pool and the returned results are summarized, including the following steps:
[0059] (41) Use java.util.concurrent.ExecutorService to create a thread pool, which is mainly used to execute the thread tasks created in step (52);
[0060] (42) loop through the key-value pairs cached in step (33), create a thread task for each application number, the thread task inherits the java.util.concurrent.Callable interface, and submit the thread task to the thread pool created in step (41). The application number appID and the data object collection corresponding to the application number will be set as member variables of the thread task;
[0061] (43) The call() method in each thread task reads the corresponding data result from the specified application according to the application ID appID in the thread task and the data object set corresponding to the application ID, and sets the read data result to the data object. The main thread obtains the return value of each thread through the java.util.concurrent.Future class and summarizes it;
[0062] (44) Summarize the data object set returned by each thread task, compare the current value of each data object with the last refresh value by traversing, filter out the data objects that have changed in this refresh, summarize these changed data objects, and store them using the java.util.list collection;
[0063] (45) First, the data object set filtered out in step (44) that has been refreshed and changed is looped through, and then the key-value pairs cached in step (32) are looped through. Finally, the changed data object is added to the data object set returned to each client through a hash algorithm and sent to the real-time data push module.
[0064] (5) Data serialization method of real-time data push module: Create independent thread tasks for each client ID to complete the JSON serialization of the return value, and execute these thread tasks through the thread pool, including the following steps:
[0065] (51) Use java.util.concurrent.ExecutorService to create a thread pool, which is mainly used to execute the thread tasks created in step (52);
[0066] (52) looping through the data object set returned to each client in step (45), creating a thread task for each loop, the thread task inherits the java.util.concurrent.Callable interface, and the thread task will be submitted to the thread pool created in step (51);
[0067] (53) When creating a thread task, the data object set returned to each client will be set as a member variable of the thread task;
[0068] (54) The call() method in each thread task uses FastJSON to serialize its own data object set into JSON. After serialization is completed, the data is pushed to the front-end page through WebSocket.
[0069] (6) After receiving the data object set to be refreshed, the WEB graphic display module triggers the onmessage method. In this method, the data object set to be refreshed is first parsed, and then the value of all dynamic data is updated by traversal, and finally all real-time data on the page is refreshed.
[0070] The multi-threaded power grid monitoring real-time data display system of the present invention comprises:
[0071] WEB graphic display module: used to display real-time data of power grid monitoring;
[0072] WEB graphics service module: used for parsing request messages and classifying and caching data;
[0073] Real-time data calculation module: used for scheduled query of real-time data and calculation of data changes;
[0074] Real-time data push module: used for serialization and data push of real-time data.
[0075] Furthermore, the real-time data calculation module performs a timed query of real-time data and calculation of data changes, as follows:
[0076] (31) The real-time data calculation module initializes the thread pool;
[0077] (32) Start the scheduled task to periodically execute the computing task at fixed time intervals;
[0078] (33) looping through the key-value pairs cached in step (23), creating a thread task for each application number, and submitting the thread task to the thread pool of step (31). The application number and the data object set corresponding to the application number will be set as member variables of the thread task;
[0079] (34) The call() method in each thread task reads the corresponding data result from the specified application according to the application number in the thread task and the data object set corresponding to the application number, sets the read data result into the data object, uses the comparison algorithm to filter out the changed data object set and returns it to the main thread;
[0080] (35) The main thread first loops through the changed data object set filtered out in step (34), then loops through the key-value pairs cached in step (22), adds the changed data objects to the data object set returned to each client through a hash algorithm, and sends the changed data object set to the real-time data push module;
[0081] The real-time data push module performs real-time data serialization and data push, as follows:
[0082] (41) The real-time data push module completes thread pool initialization;
[0083] (42) looping through the changed data object set returned in step (35), creating a thread task for each client unique identifier clientID in each loop, and submitting the thread task to the thread pool created in step (41);
[0084] (43) When creating a thread task, the data object set returned to each client will be set as a member variable of the thread task;
[0085] (44) The call() method in each thread task serializes the data object set returned to the client in the thread task into JSON, and after serialization is completed, pushes the data to the WEB graphics display module through WebSocket.
[0086] The computer device of the present invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the steps of the above method are implemented when the processor executes the computer program.
[0087] The computer-readable storage medium of the present invention stores a computer program thereon, and the computer program implements the steps of the above method when executed by a processor.
Claims
1. A multi-threaded power grid monitoring real-time data display method, characterized in that: The following steps are involved: (1) The WEB graphics display module sends a request to the WEB graphics service module to establish a WebSocket connection; (2) The WEB graphics service module parses the received request message and caches it using a classification algorithm; (3) The real-time data calculation module starts the scheduled query function and uses multi-threading technology to calculate the changed data object set and send the calculation results to the real-time data push module; (4) The real-time data push module uses multi-threading technology to serialize the received data set into JSON and pushes the result to the WEB graphic display module; (5) The WEB graphic display module parses the received results, refreshes the dynamic data, and updates the page.
2. The multi-threaded power grid monitoring real-time data display method according to claim 1 is characterized in that: Step (1) is as follows: the WEB graphics display module creates a request message, defines the client unique identifier clientID and the data identifier set keyIDs in the request message, and sends the message to the WEB graphics service module via an Http request. The WEB graphics display module and the WEB graphics service module establish a WebSocket connection.
3. The multi-threaded power grid monitoring real-time data display method according to claim 2 is characterized in that: Step (2) is as follows: (21) The WEB graphic service module receives the request message sent by the WEB graphic display module and parses the request message; (22) caching the client ID and the data ID set keyIDs in a key-value pair manner; (23) The data identifier keyID in the data identifier set keyIDs is cached according to the application number AppID, and the cache is cached in a key-value pair manner, where the Key is the application number and the Value is the data object set corresponding to the application number.
4. The method for displaying real-time data of power grid monitoring based on multithreading according to claim 3 is characterized in that: Step (3) is as follows: (31) The real-time data calculation module initializes the thread pool; (32) Start the scheduled task to periodically execute the computing task at fixed time intervals; (33) looping through the key-value pairs cached in step (23), creating a thread task for each application number, and submitting the thread task to the thread pool of step (31). The application number and the data object set corresponding to the application number will be set as member variables of the thread task; (34) The call() method in each thread task reads the corresponding data result from the specified application according to the application number in the thread task and the data object set corresponding to the application number, sets the read data result into the data object, uses the comparison algorithm to filter out the changed data object set and returns it to the main thread; (35) The main thread first loops through the set of changed data objects filtered out in step (34), and then loops through the key-value pairs cached in step (22). The changed data objects are added to the set of data objects returned to each client through a hash algorithm, and the changed data object set is sent to the real-time data push module.
5. The method for displaying real-time data of power grid monitoring based on multithreading according to claim 4 is characterized in that: Step (4) is as follows: (41) The real-time data push module completes thread pool initialization; (42) looping through the changed data object set returned in step (35), creating a thread task for each client unique identifier clientID in each loop, and submitting the thread task to the thread pool created in step (41); (43) When creating a thread task, the data object set returned to each client will be set as a member variable of the thread task; (44) The call() method in each thread task serializes the data object set returned to the client in the thread task into JSON, and after serialization is completed, pushes the data to the WEB graphics display module through WebSocket.
6. The method for displaying real-time data of power grid monitoring based on multithreading according to claim 5 is characterized in that: Step (5) is specifically as follows: after receiving the data object set to be refreshed, the WEB graphic display module parses the data object set to be refreshed, completes the update of the corresponding dynamic data according to the data identifier, and realizes the refresh of real-time data.
7. A multi-threaded power grid monitoring real-time data display system, characterized in that: Includes the following modules: WEB graphic display module, used to display real-time data of power grid monitoring; WEB graphics service module, used for parsing request messages and categorizing and caching data; Real-time data calculation module, used for scheduled query of real-time data and calculation of data changes; Real-time data push module, used for serialization and data push of real-time data.
8. The multi-threaded power grid monitoring real-time data display system according to claim 7 is characterized in that: The real-time data calculation module performs regular query of real-time data and calculation of data changes, as follows: (31) The real-time data calculation module initializes the thread pool; (32) Start the scheduled task to periodically execute the computing task at fixed time intervals; (33) looping through the key-value pairs cached in step (23), creating a thread task for each application number, and submitting the thread task to the thread pool of step (31). The application number and the data object set corresponding to the application number will be set as member variables of the thread task; (34) The call() method in each thread task reads the corresponding data result from the specified application according to the application number in the thread task and the data object set corresponding to the application number, sets the read data result into the data object, uses the comparison algorithm to filter out the changed data object set and returns it to the main thread; (35) The main thread first loops through the changed data object set filtered out in step (34), then loops through the key-value pairs cached in step (22), adds the changed data objects to the data object set returned to each client through a hash algorithm, and sends the changed data object set to the real-time data push module; The real-time data push module performs real-time data serialization and data push, as follows: (41) The real-time data push module completes thread pool initialization; (42) looping through the changed data object set returned in step (35), creating a thread task for each client unique identifier clientID in each loop, and submitting the thread task to the thread pool created in step (41); (43) When creating a thread task, the data object set returned to each client will be set as a member variable of the thread task; (44) The call() method in each thread task serializes the data object set returned to the client in the thread task into JSON, and after serialization is completed, pushes the data to the WEB graphics display module through WebSocket.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.