Method for transmitting and pushing alarm data to Web page
Through the WebSocket protocol and XML formatted data exchange, the semantic loss and insufficient real-time performance in web page data transmission and push are solved, efficient and accurate push of alarm data is achieved, and the compatibility and stability of the system are improved.
Patent Information
- Application Number
- CN202411303870.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-10
AI Technical Summary
During the process of data transmission and pushing of web pages, there are problems such as semantic loss, format incompatibility and insufficient real-time performance, which makes it impossible for users to directly understand and operate data. The data interoperability between different systems is complex and difficult to achieve efficient and accurate Data exchange and real-time push.
Using the WebSocket protocol to realize two-way communication between a web browser and a web server, data analysis and storage is performed through TCP sockets and Redis database, XML is used as the data exchange format, and combined with Netty library and Jedis client to realize alarm data Generate, push and display to ensure that data maintains semantic and structural information during transmission, and improves real-time and accuracy.
Through XML formatted data exchange, compatibility and flexibility between different systems are enhanced, real-time and accuracy of data transmission are improved, data integration complexity is reduced, information circulation and sharing is ensured, and system Reliability and stability.
Smart Images

Figure CN119109916A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of data transmission and processing, and relates to a method for transmitting and pushing alarm data to a Web page. Background Art
[0002] With the rapid development of Internet technology, the World Wide Web (WWW or Web) has become the main platform for information exchange and sharing around the world. Traditionally, people obtain information through traditional media such as television, newspapers, magazines and radio, but these methods have limitations in terms of one-way information transmission and timeliness. With the popularization of computer networks, especially the Internet, users' demand for information acquisition has undergone profound changes. They are no longer satisfied with passively receiving information, but hope to actively select, obtain and understand the required information in real time.
[0003] In the Web environment, information is usually stored in the form of databases. In order to optimize retrieval and management efficiency, these databases are structured according to the inherent properties of information. However, when this information needs to be transmitted to the Web browser for users to browse, it will face a key technical challenge: in the process of converting data from the database to HTML format, its original semantics and structural information are often difficult to retain completely. Currently commonly used conversion methods, such as CGI (Common Gateway Interface), ASP (Active Server Pages), JSP (JavaServer Pages), PHP (Hypertext Preprocessor), etc., can realize dynamic data generation and HTML page rendering, but in the conversion process, the original meaning of the data (such as the semantics of the field, data type, etc.) is usually simplified or lost, resulting in users being unable to directly understand and operate the data in the browser according to the original meaning.
[0004] In addition, due to the diversity of technology stacks involved in Web applications, including different operating systems, database management systems, and programming languages, the differences between different systems in data formats, communication protocols, etc. also increase the complexity of data interoperability, making it difficult to achieve efficient and accurate data exchange and understanding between different systems, especially in scenarios where key information such as alarm data needs to be pushed in real time. Traditional data conversion and transmission methods often cannot meet users' high requirements for data real-time, accuracy, and availability.
[0005] Therefore, in view of the problems of semantic loss, format incompatibility and lack of real-time performance in the current Web page data transmission and push process, it is urgent to build an innovative method to achieve efficient transmission and push of alarm data to Web pages, ensure that the data can maintain its original semantic and structural information during the transmission process, and at the same time improve the real-time and accuracy of data transmission, so as to meet users' needs for efficient and accurate information acquisition. Summary of the invention
[0006] The purpose of the present invention is to solve the problems of semantic loss, format incompatibility and lack of real-time performance in the process of Web page data transmission and push in the prior art, and to provide a method for transmitting and pushing alarm data to a Web page.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions: A method for transmitting and pushing alarm data to a Web page, comprising the following steps: Generate alarm data, establish alarm rule configuration, collect data to be monitored, process data and make alarm judgments, and generate alarm data to be pushed; Establish a connection, create a TCP socket on the web server, and the web browser sends a request to the web server to establish a WebSocket connection through JavaScript, and realizes a two-way communication connection between the web browser and the web server through the TCP socket; Data parsing and storage: The terminal parses the received alarm data through the gateway and writes the parsed data into the MySQL database and the Redis database respectively according to the type of reported data; Data encapsulation: the Web server encapsulates the alarm data to be pushed into text or binary data packets and prepares to send them through the WebSocket protocol; Alarm data subscription and push judgment: The WebSocket protocol subscribes to alarm information from the alarm channel of the Redis database; when the Redis database pushes new alarm information, the WebSocket protocol extracts the alarm content and the corresponding Web browser information, and determines whether this alarm information needs to be pushed to a specific Web browser; Alarm data push and display: The WebSocket protocol will determine the alarm data that needs to be pushed and format it through the built-in XML conversion function of the Web server, and then use the TCP socket to push it directly to the corresponding Web browser. After the Web browser receives the pushed data, it updates and displays the corresponding Web page to display the alarm information.
[0008] The alarm data generation is specifically as follows: Alarm rule configuration: establish and configure alarm rules, including threshold rules, change rate rules and missing rules, and define the specific conditions for triggering alarms; Data collection: collects the data that needs to be monitored from multiple data sources, including server performance data, network traffic data, and received data; Data processing: cleaning the collected data, removing noise, errors or irrelevant information, and performing necessary conversion operations to ensure that the data format matches the requirements of the alarm rules; Alarm judgment: According to the preset alarm rules, the processed data is judged and analyzed in real time or regularly. When the data meets any alarm condition, the next step is executed; Alarm data generation: When the data meets the alarm conditions, the system generates alarm data. The alarm data contains the specific information that triggers the alarm, including the alarm type, occurrence time, related data sources and specific data values.
[0009] The alarm rules include threshold rules, change rate rules and missing rules, specifically: The threshold rule includes setting one or more data thresholds, and triggering an alarm when the collected data exceeds or falls below the threshold; the change rate rule focuses on the speed of data change, and triggers an alarm when the data change rate exceeds a preset range; the missing rule is used to detect whether the data arrives on time or whether there is any missing, and triggers an alarm if the data does not arrive as expected or is missing.
[0010] The two-way communication connection between the web browser and the web server is realized as follows: Web server TCP socket creation: Create a TCP socket on the Web server to establish a WebSocket connection. WebSocket connection request: The web browser sends a WebSocket connection request to the web server through JavaScript, requesting an upgrade through the HTTP protocol to establish a WebSocket connection; The WebSocket connection is established. After the Web server receives the WebSocket connection request, it uses the Netty library to process the request and establishes a two-way WebSocket connection with the Web browser through Netty's WebSocket support library. Data sending and receiving: The web browser sends data to the web server through the method in JavaScript, and the web server receives this data through the Netty library. At the same time, the web server sends data to the web browser through the Netty library, and the web browser listens and receives data through the onmessage event.
[0011] The data analysis and storage are specifically as follows: Netty port monitoring, the Netty server calls the specified port to listen and wait for the connection request from the terminal device; Data reception and analysis: When the terminal device reports data, the Netty port receives the data, analyzes the data, and determines whether it is alarm data based on the analysis results; Alarm data publishing: if it is judged to be alarm data, the publish method of the Jedis client is used to publish the alarm information to the Redis database; Historical data storage: write non-alarm historical data into the MySQL database.
[0012] The Redis database is deployed in a cluster, including at least three master nodes and three slave nodes. When the alarm information is published to the Redis database through the Jedis client, the Redis database distributes the alarm information to each node for storage.
[0013] The data encapsulation is specifically: WebSocket object creation: Create a WebSocket object on the Web client and establish a connection with the server by specifying the URL and optional protocol; Data format definition, which defines the fields and data types in TCP data packets, used to encapsulate alarm data; Data encapsulation: according to the defined data format, the actual alarm data is encapsulated into a data packet that conforms to the format.
[0014] The fields in the TCP data packet include version number, alarm time, system number, group number, alarm point number, alarm type and alarm value.
[0015] The alarm data subscription and push judgment is specifically as follows: Redis alarm channel subscription: The WebSocket server subscribes to the alarm channel through the Redis subscription function and receives alarm information from the Redis database; Alarm information extraction and judgment: When new alarm information in the Redis database is pushed to the subscribed channel, the WebSocket server extracts the alarm content and identifies the Web browser user corresponding to the alarm. Based on the user's permissions and connection status, it determines whether the alarm information needs to be pushed to the corresponding Web browser. Alarm push is bound to permissions. For Web browser users who meet the push conditions, the WebSocket server pushes the alarm information to the user in real time through the established WebSocket connection.
[0016] The push and display of alarm data are specifically as follows: Alarm data extraction and XML conversion, after the WebSocket server extracts the alarm data, it converts the alarm data into XML format through the built-in XML converter of the Web server; Data compression: Before sending alarm data to the Web browser via TCP socket, the system uses compression algorithm to compress the alarm data to reduce the amount of data transmission. TCP socket push: the compressed alarm data is sent to the connected Web browser via TCP socket; Web browser display: The Web browser receives and decompresses the data transmitted by the TCP socket, parses the alarm data in XML format, and displays the corresponding alarm information on the Web page.
[0017] Compared with the prior art, the present invention has the following beneficial effects: The method of transmitting and pushing alarm data to a Web page in the present invention greatly enhances the flexibility and compatibility of data between different systems, platforms and applications by using XML as the data exchange format. The structured characteristics of XML make data easy to read, understand and maintain, reducing the complexity of data integration and interoperability. The standardized data format enables different systems to easily understand and process data from other systems, promoting the circulation and sharing of information.
[0018] The application of Websocket push mode in alarm information processing has significantly improved the real-time and accuracy of alarms. By pushing alarm information to relevant users or systems in real time, Websocket reduces information delay and improves the response speed of alarms. The full-duplex communication feature ensures accurate data transmission, reduces data loss or errors caused by network problems, and enhances the reliability and stability of the system.
[0019] As a data storage and message middleware, Redis reduces the coupling between the gateway and the Websocket protocol. Even when the network is abnormal or the Websocket service has problems, Redis can ensure the stable storage and transmission of data, thereby ensuring the normal communication between the gateway and the terminal and the continuity of data writing to the Redis database. Secondly, Redis supports multiple programs to subscribe to messages at the same time, realizing the real-time distribution and synchronization of data between different modules in the system, and promoting close collaboration and efficient operation between modules within the system. In addition, Redis also acts as a cache system, reducing the number of visits to the backend database, improving the system's processing power and response speed, and reducing network traffic and costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 It is a flowchart of the method for transmitting and pushing alarm data to a Web page in the present invention; Figure 2 It is a specific flow chart of the method for transmitting and pushing alarm data to a Web page in the present invention; Figure 3 A flowchart of alarm data generation for the method of transmitting and pushing alarm data to a Web page in the present invention; Figure 4 A data writing flow chart of the method for transmitting and pushing alarm data to a Web page in the present invention; Figure 5 This is an architecture diagram of the Websocket alarm push system in the method of transmitting and pushing alarm data to a Web page in the present invention. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0023] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. 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.
[0024] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0025] The present invention is further described in detail below in conjunction with the accompanying drawings: See also Figure 1 and Figure 2 , is a flow chart of a method for transmitting and pushing alarm data to a Web page in the present invention, and the method specifically comprises the following steps: S1, alarm data generation, establishing alarm rule configuration, collecting data to be monitored, data processing and alarm judgment, and generating alarm data to be pushed.
[0026] The alarm data is generated as follows: S1.1, alarm rule configuration, establish and configure alarm rules, alarm rules include threshold rules, change rate rules and missing rules, define the specific conditions for triggering alarms. The threshold rules include setting one or more data thresholds, and triggering alarms when the collected data exceeds or falls below the threshold; the change rate rules focus on the speed of data change, and trigger alarms when the data change rate exceeds the preset range; the missing rules are used to detect whether the data arrives on time or whether there is a missing, and trigger an alarm if the data does not arrive as expected or is missing.
[0027] S1.2, data collection, collects the data that needs to be monitored from multiple data sources, including server performance data, network traffic data and received data.
[0028] S1.3, data processing, cleans the collected data, removes noise, errors or irrelevant information, and performs necessary conversion operations to ensure that the data format matches the alarm rule requirements.
[0029] S1.4, alarm judgment, based on the preset alarm rules, the processed data is judged and analyzed in real time or periodically. When the data meets any alarm condition, the next step is executed.
[0030] S1.5, alarm data generation. When the data meets the alarm conditions, the system generates alarm data. The alarm data contains the specific information that triggers the alarm, including the alarm type, occurrence time, related data sources and specific data values.
[0031] S2, establish a connection, create a TCP socket on the Web server, the Web browser sends a request to the Web server to establish a WebSocket connection through JavaScript, and a two-way communication connection is realized between the Web browser and the Web server through the TCP socket.
[0032] S2.1, Web server TCP socket creation, creates a TCP socket on the Web server for establishing a WebSocket connection.
[0033] S2.2, WebSocket connection request, the web browser sends a WebSocket connection request to the web server through JavaScript, requesting to upgrade through the HTTP protocol to establish a WebSocket connection.
[0034] S2.3, WebSocket connection is established. After receiving the WebSocket connection request, the Web server uses the Netty library to process the request and establishes a two-way WebSocket connection with the Web browser through Netty's WebSocket support library.
[0035] S2.4, data sending and receiving, the web browser sends data to the web server through the method in JavaScript, and the web server receives this data through the Netty library; at the same time, the web server sends data to the web browser through the Netty library, and the web browser listens and receives data through the onmessage event.
[0036] S3, data analysis and storage, the terminal analyzes the received alarm data through the gateway, and writes the analyzed data into the MySQL database and the Redis database respectively according to the type of reported data.
[0037] S3.1, Netty port monitoring, the Netty server calls the specified port to listen and wait for the connection request from the terminal device.
[0038] S3.2, data reception and analysis. When the terminal device reports data, the Netty port receives the data through the channelRead method of the GatewayHandler class inherited from ChannelInboundHandlerAdapter, analyzes the data, and determines whether it is alarm data based on the analysis results.
[0039] S3.3, alarm data release. If it is judged as alarm data, the publish method of the Jedis client is used to publish the alarm information to the Redis database. The Redis database adopts a cluster deployment method, including at least three master nodes and three slave nodes. When the alarm information is published to the Redis database through the Jedis client, the Redis database will distribute the alarm information to each node for storage.
[0040] S3.4, historical data storage, writes non-alarm historical data into the MySQL database.
[0041] Redis not only acts as a cache database to store real-time data and improve data access speed, but also acts as a message queue to achieve rapid distribution and processing of alarm information.
[0042] S4, data encapsulation, the Web server encapsulates the alarm data to be pushed into text or binary data packets and prepares to send them through the WebSocket protocol.
[0043] S4.1, WebSocket object creation, creates a WebSocket object on the Web client and establishes a connection with the server by specifying the URL and optional protocol.
[0044] S4.2, Data format definition, defines the fields and data types in the TCP data packet, which is used to encapsulate alarm data. The fields in the TCP data packet include version number, alarm time, system number, group number, alarm point number, alarm type and alarm value.
[0045] S4.3, data encapsulation, encapsulates the actual alarm data into a data packet that complies with the format according to the defined data format.
[0046] S5, alarm data subscription and push judgment, the WebSocket protocol subscribes to alarm information from the alarm channel of the Redis database; when the Redis database pushes new alarm information, the WebSocket protocol extracts the content of the alarm and the corresponding Web browser information, and determines whether this alarm information needs to be pushed to a specific Web browser.
[0047] S5.1, Redis alarm channel subscription, the WebSocket server subscribes to one or more alarm channels through the Redis subscription function and receives alarm information from the Redis database.
[0048] S5.2, alarm information extraction and judgment, when new alarm information in the Redis database is pushed to the subscribed channel, the WebSocket server extracts the alarm content and identifies the Web browser user corresponding to the alarm, and determines whether the alarm information needs to be pushed to the corresponding Web browser based on the user's permissions and connection status.
[0049] S5.3, alarm push is bound to permissions. For Web browser users who meet the push conditions, the WebSocket server pushes the alarm information to the user in real time through the established WebSocket connection, realizing accurate push of alarm information and permission control.
[0050] The WebSocket server maintains the status information of all connected Web browser users, ensuring that only users with valid connections can receive alarm push notifications, thereby avoiding sending invalid data to disconnected or disconnected users, further saving system resources and network bandwidth.
[0051] S6, alarm data push and display. The WebSocket protocol will format the alarm data that needs to be pushed through the built-in XML conversion function of the Web server, and then push it directly to the corresponding Web browser using the TCP socket. After the Web browser receives the pushed data, it updates and displays the corresponding Web page to display the alarm information.
[0052] S6.1, Alarm Data Extraction and XML Conversion,After the WebSocket server extracts the alarm data, it converts the alarm data into XML format through the built-in XML converter of the Web server, so that it can be parsed and displayed in the Web browser.
[0053] S6.2, data compression, before pushing the alarm data to the Web browser through the TCP socket, the system uses a compression algorithm such as GZIP or Deflate to compress the alarm data to reduce the amount of data transmission and increase the transmission speed.
[0054] S6.3, TCP socket push, the compressed alarm data is sent to the connected Web browser through the TCP socket.
[0055] S6.4, Web browser display, the Web browser receives and decompresses the data transmitted by the TCP socket, parses the alarm data in XML format, and displays the corresponding alarm information on the Web page.
[0056] The entire push process is real-time, ensuring that the alarm information can be immediately conveyed to Web browser users. At the same time, the system controls which users can receive the alarm push through the permission management function of the WebSocket server, ensuring the security and accuracy of the information.
[0057] Example 1 See also Figures 1 to 5 The present invention provides a method for transmitting and pushing alarm data to a Web page, wherein the method comprises: generating alarm data→establishing a connection→writing data→encapsulating data→extracting alarm content→sending data.
[0058] The specific steps include: Step 1: Alarm data generation includes alarm rule configuration, data collection, data processing, and alarm judgment. The alarm rule configuration is established to set threshold rules, change rate rules, and missing rules. The server performance data, network traffic data, received data, etc. that need to be monitored are collected, and the collected data is cleaned and converted. The processed data is judged according to the alarm rules. If the alarm conditions are met, the alarm data is generated.
[0059] Step 2: Create a TCP socket on the Web server. The Web browser sends a request to the Web server to establish a Websocket connection through JavaScript. The Web browser establishes a two-way connection with the Web server through the TCP socket. The Web browser sends data to the Web server through the send() method and receives the data returned by the Web server through the onmessage event. The Web server uses the Netty library to handle socket connections and data transmission and reception. Netty is a client / server network application framework based on JavaNIO. It hides the complex network operations behind it and provides an easy-to-use API framework. The Netty framework is an efficient thread model based on EventLoop. It is a high-performance, asynchronous event-driven NIO framework. All IO operations are asynchronous and non-blocking. The high-performance Netty can handle the connection and data transmission and reception of tens of thousands of terminals.
[0060] Step 3: Netty framework listens to port 9300 through the bind() method and waits for the terminal to connect. When the terminal reports data, the channelRead method of the GatewayHandler class inherited from ChannelInboundHandlerAdapter receives the data and parses the alarm, and then publishes the alarm to the Redis database through the publish method of jedis. Redis is used as both a cache database and a message queue. The Redis server is deployed in a cluster of 6 Redis nodes, including 3 master nodes and 3 slave nodes. It can automatically distribute data to different nodes, improve performance, and continue to provide services when some nodes fail, improving the high availability of the system. The channelRead method writes historical data to the MySQL database for long-term persistence. Historical data will be used for trip analysis and alarm statistics.
[0061] Step 4, create a Websocket object: var socket = new websocket (url, [protocol]); url: specifies the URL of the connection; protocol: optional, specifies the acceptable sub-protocol; When the Web server needs to encapsulate the alarm data into text or binary data packets and send them to the Websocket protocol, the following steps need to be followed: Define the data format. First, define the fields and data types in the TCP data packet. For example, the version number is an integer, the alarm time is a UNIX timestamp or a string in a specific format, the system number, group number, and alarm point number are all integers or strings, and the alarm type and alarm value are defined according to actual needs.
[0062] Encapsulate data, according to the defined data format, encapsulate the actual alarm data into a data packet that conforms to the format, and then serialize the data, that is, convert the data structure or object state into a format that can be stored or transmitted.
[0063] Step 5. The Websocket server subscribes to the alarm channel from the Redis database. When an alarm message is pushed from the Redis database, the Websocket protocol extracts the alarm content and the Web browser corresponding to the alarm, and then determines whether the alarm message needs to be pushed to the corresponding Web browser. In this way, the alarm push can be bound to the Web browser authority. Only the Web browser user who has established a connection will receive the alarm push, reducing unnecessary data transmission. Only necessary data is transmitted, avoiding the transmission of a large amount of useless information. For example, the data transmission volume can be reduced by sending only the changed part instead of the entire page. The network traffic of Websocket transmission is (2+50)×1000=52000B, saving a lot of network traffic.
[0064] Step 6: After the alarm data extracted by the Websocket server is converted through the built-in XML of the Web server, it is pushed to the corresponding Web browser for display using the TCP socket. The Web browser displays the pushed Web page. Before sending the alarm data, the alarm data is compressed using the compression algorithms GZIP and Deflate. Alarm data compression can reduce the amount of data transmission and increase the generation speed.
[0065] Example 2 A method for transmitting and pushing alarm data to a Web page in the present invention specifically comprises the following steps: Step 1: The web browser uses the socket file to make various requests to the web server.
[0066] Step 2: Use the Websocket protocol to transmit the request made during the request process to the Redis database in the Web server.
[0067] Step 3: Use the Websocket protocol to extract data from the Redis database.
[0068] Step 4: Use the Websocket protocol to transmit the extracted data to the Web browser through the onmessage event, and display the above requested interface on the Web browser.
[0069] Example 3 A method for transmitting and pushing alarm data to a Web page in the present invention specifically comprises the following steps: Step 1: The web browser creates an EventSource object and continuously makes requests to the web server through the Websocket protocol.
[0070] Step 2: The Web server responds to the Web browser in a data format that includes event, data, and id, which constitute the Websocket message frame.
[0071] Step 3: After the web browser receives the response data from the web server, it finds the event listener corresponding to the EventSource object according to the event value and receives the Server-Sent event notification.
[0072] Step 4: The web browser uses the EventSource object to receive event notifications sent by the web server.
[0073] The present invention can exchange data between incompatible systems through XML. The data stored in computer systems and database systems are in various forms. Converting data into XML format for storage will greatly reduce the complexity of exchanging data. It can also make the data readable by different programs. XML can make full use of data. XML is independent of software, hardware and application programs. Data can be used by more users and devices, not just limited to browsers based on HTML standards. Other clients and applications can process XML documents as data sources, just like operating databases. XML data can be processed by various "readers".
[0074] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for transmitting and pushing alarm data to a Web page, characterized in that: The following steps are involved: Generate alarm data, establish alarm rule configuration, collect data to be monitored, process data and make alarm judgments, and generate alarm data to be pushed; Establish a connection, create a TCP socket on the web server, and the web browser sends a request to the web server to establish a WebSocket connection through JavaScript, and realizes a two-way communication connection between the web browser and the web server through the TCP socket; Data parsing and storage: The terminal parses the received alarm data through the gateway and writes the parsed data into the MySQL database and the Redis database respectively according to the type of reported data; Data encapsulation: the Web server encapsulates the alarm data to be pushed into text or binary data packets and prepares to send them through the WebSocket protocol; Alarm data subscription and push judgment: The WebSocket protocol subscribes to alarm information from the alarm channel of the Redis database; when the Redis database pushes new alarm information, the WebSocket protocol extracts the alarm content and the corresponding Web browser information, and determines whether this alarm information needs to be pushed to a specific Web browser; Alarm data push and display: The WebSocket protocol will determine the alarm data that needs to be pushed and format it through the built-in XML conversion function of the Web server, and then use the TCP socket to push it directly to the corresponding Web browser. After the Web browser receives the pushed data, it updates and displays the corresponding Web page to display the alarm information.
2. A method for transmitting and pushing alarm data to a Web page as claimed in claim 1, characterized in that: The alarm data generation is specifically as follows: Alarm rule configuration: establish and configure alarm rules, including threshold rules, change rate rules and missing rules, and define the specific conditions for triggering alarms; Data collection: collects the data that needs to be monitored from multiple data sources, including server performance data, network traffic data, and received data; Data processing: cleaning the collected data, removing noise, errors or irrelevant information, and performing necessary conversion operations to ensure that the data format matches the requirements of the alarm rules; Alarm judgment: According to the preset alarm rules, the processed data is judged and analyzed in real time or regularly. When the data meets any alarm condition, the next step is executed; Alarm data generation: When the data meets the alarm conditions, the system generates alarm data. The alarm data contains the specific information that triggers the alarm, including the alarm type, occurrence time, related data sources and specific data values.
3. A method for transmitting and pushing alarm data to a Web page as claimed in claim 2, characterized in that: The alarm rules include threshold rules, change rate rules and missing rules, specifically: The threshold rule includes setting one or more data thresholds, and triggering an alarm when the collected data exceeds or falls below the threshold; the change rate rule focuses on the speed of data change, and triggers an alarm when the data change rate exceeds a preset range; the missing rule is used to detect whether the data arrives on time or whether there is any missing, and triggers an alarm if the data does not arrive as expected or is missing.
4. A method for transmitting and pushing alarm data to a Web page as claimed in claim 1, characterized in that: The two-way communication connection between the web browser and the web server is realized as follows: Web server TCP socket creation: Create a TCP socket on the Web server to establish a WebSocket connection. WebSocket connection request: The web browser sends a WebSocket connection request to the web server through JavaScript, requesting an upgrade through the HTTP protocol to establish a WebSocket connection; The WebSocket connection is established. After the Web server receives the WebSocket connection request, it uses the Netty library to process the request and establishes a two-way WebSocket connection with the Web browser through Netty's WebSocket support library. Data sending and receiving: The web browser sends data to the web server through the method in JavaScript, and the web server receives this data through the Netty library. At the same time, the web server sends data to the web browser through the Netty library, and the web browser listens and receives data through the onmessage event.
5. A method for transmitting and pushing alarm data to a Web page as claimed in claim 1, characterized in that: The data analysis and storage are specifically as follows: Netty port monitoring, the Netty server calls the specified port to listen and wait for the connection request from the terminal device; Data reception and analysis: When the terminal device reports data, the Netty port receives the data, analyzes the data, and determines whether it is alarm data based on the analysis results; Alarm data publishing: if it is judged to be alarm data, the Jedis client's publish method is used to publish the alarm information to the Redis database; Historical data storage: write non-alarm historical data into the MySQL database.
6. A method for transmitting and pushing alarm data to a Web page as claimed in claim 5, characterized in that: The Redis database is deployed in a cluster, including at least three master nodes and three slave nodes. When the alarm information is published to the Redis database through the Jedis client, the Redis database distributes the alarm information to each node for storage.
7. A method for transmitting and pushing alarm data to a Web page as claimed in claim 1, characterized in that: The data encapsulation is specifically: WebSocket object creation: Create a WebSocket object on the Web client and establish a connection with the server by specifying the URL and optional protocol; Data format definition, which defines the fields and data types in TCP data packets, used to encapsulate alarm data; Data encapsulation: according to the defined data format, the actual alarm data is encapsulated into a data packet that conforms to the format.
8. A method for transmitting and pushing alarm data to a Web page as claimed in claim 7, characterized in that: The fields in the TCP data packet include version number, alarm time, system number, group number, alarm point number, alarm type and alarm value.
9. A method for transmitting and pushing alarm data to a Web page as claimed in claim 1, characterized in that: The alarm data subscription and push judgment is specifically as follows: Redis alarm channel subscription: The WebSocket server subscribes to the alarm channel through the Redis subscription function and receives alarm information from the Redis database; Alarm information extraction and judgment: When new alarm information in the Redis database is pushed to the subscribed channel, the WebSocket server extracts the alarm content and identifies the Web browser user corresponding to the alarm. Based on the user's permissions and connection status, it determines whether the alarm information needs to be pushed to the corresponding Web browser. Alarm push is bound to permissions. For Web browser users who meet the push conditions, the WebSocket server pushes the alarm information to the user in real time through the established WebSocket connection.
10. A method for transmitting and pushing alarm data to a Web page as claimed in claim 1, characterized in that: The push and display of alarm data are specifically as follows: Alarm data extraction and XML conversion, after the WebSocket server extracts the alarm data, it converts the alarm data into XML format through the built-in XML converter of the Web server; Data compression: Before sending alarm data to the Web browser via TCP socket, the system uses compression algorithm to compress the alarm data to reduce the amount of data transmission. TCP socket push: the compressed alarm data is sent to the connected Web browser via TCP socket; Web browser display: The Web browser receives and decompresses the data transmitted by the TCP socket, parses the alarm data in XML format, and displays the corresponding alarm information on the Web page.
Citation Information
Cited By
Binary communication data generation method and device and related product
CN121000794A
