Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a method and a system for displaying industrial data in real time.
The invention provides a real-time industrial data display method, which comprises the following steps:
a data configuration step: configuring industrial data needing to be displayed in real time;
page viewing step: viewing an industrial data real-time display page;
an address acquisition step: enabling the client to acquire a subscription address;
a service connection step: enabling a client to be connected with a Websocket service;
a data subscription step: enabling a client to subscribe Websocket industrial data service;
data receiving and displaying: and enabling the client to receive and display the industrial data sent by the server.
Preferably, the data configuring step:
and configuring the industrial data needing to be displayed in real time through the application page.
Preferably, the address obtaining step includes:
acquiring industrial data to be displayed on a page, extracting an industrial data ID (identity) and establishing a mapping relation of the page;
sending the industrial data ID to a server;
enabling the server to obtain the ID of the current login user;
enabling the server side to obtain the industrial data ID and then carry out data authority verification, and reserving the industrial data ID which passes the data verification;
generating a subscription address, associating and marking the subscription address with the verified industrial data ID and the current login user ID as subscription, and storing the subscription address into the distributed cache service;
enabling the server to return the subscription address to the client;
the industrial data ID refers to a unique identifier defined for each industrial data.
Preferably, the service connecting step includes:
enabling the client to initiate Websocket connection to the server;
after receiving the Websocket connection, the server redirects the server to the cluster service according to a load balancing strategy;
the cluster service checks whether the client logs in or not, and connection is refused if the client does not log in;
and establishing the Websocket connection by the client side passing the verification.
Preferably, the data subscribing step includes:
enabling the client to subscribe through the acquired subscription address;
after receiving the Websocket subscription, the server redirects a subscription request to the distributed cluster service according to a load balancing strategy;
the cluster service checks whether the client has the following 3 conditions: the user logs in, the subscription address state is not subscribed, and the current login user ID is consistent with the current subscription user ID: rejecting the subscription request for clients that do not satisfy the condition; the client side which passes the verification receives the subscription;
the server side modifies the subscription address state stored in the distributed cache service into a subscribed state, and records the mapping relation between the ID of the subscribed user and the subscription address;
monitoring the change of industrial data subscribed by a user, and entering a data receiving and displaying step to continue executing if the change is detected; otherwise, the monitoring is continued.
Preferably, the data receiving and presenting step comprises:
when monitoring that the industrial data changes, the server side sends the industrial data to the client side through the mapping relation between the industrial data ID and the subscription address;
and when the client receives the industrial data, updating the page industrial data through the established mapping relation.
The industrial data real-time display system provided by the invention can be realized through the steps and flows of the industrial data real-time display method provided by the invention. The method for displaying the industrial data in real time can be understood as a preferred example of the industrial data real-time displaying system by those skilled in the art.
The invention provides an industrial data real-time display system, which comprises:
a data configuration module: configuring industrial data needing to be displayed in real time;
a page viewing module: viewing an industrial data real-time display page;
an address acquisition module: enabling the client to acquire a subscription address;
a service connection module: enabling a client to be connected with a Websocket service;
a data subscription module: enabling a client to subscribe Websocket industrial data service;
the data receiving and displaying module: and enabling the client to receive and display the industrial data sent by the server.
Preferably, the data configuration module:
configuring industrial data needing to be displayed in real time through an application page;
the address acquisition module includes:
acquiring industrial data to be displayed on a page, extracting an industrial data ID (identity) and establishing a mapping relation of the page;
sending the industrial data ID to a server;
enabling the server to obtain the ID of the current login user;
enabling the server side to obtain the industrial data ID and then carry out data authority verification, and reserving the industrial data ID which passes the data verification;
generating a subscription address, associating the subscription address with the verified industrial data ID and the current login user ID, marking the subscription address as an unsubscribed address, and storing the unsubscribed address in the distributed cache service;
enabling the server to return the subscription address to the client;
the industrial data ID refers to a unique identifier defined for each industrial data.
Preferably, the service connection module includes:
enabling the client to initiate Websocket connection to the server;
after receiving the Websocket connection, the server redirects the server to the cluster service according to a load balancing strategy;
the cluster service checks whether the client logs in or not, and connection is refused if the client does not log in;
and establishing the Websocket connection by the client side passing the verification.
Preferably, the data subscription module includes:
enabling the client to subscribe through the acquired subscription address;
after receiving the Websocket subscription, the server redirects a subscription request to the distributed cluster service according to a load balancing strategy;
the cluster service checks whether the client has the following 3 conditions: the user logs in, the subscription address state is not subscribed, and the current login user ID is consistent with the current subscription user ID: rejecting the subscription request for clients that do not satisfy the condition; the client side which passes the verification receives the subscription;
the server side modifies the subscription address state stored in the distributed cache service into a subscribed state, and records the mapping relation between the ID of the subscribed user and the subscription address;
monitoring the change of industrial data subscribed by a user, and calling a data receiving and displaying module if the change is detected; otherwise, continuing monitoring;
the data receiving and displaying module comprises:
when monitoring that the industrial data changes, the server side sends the industrial data to the client side through the mapping relation between the industrial data ID and the subscription address;
and when the client receives the industrial data, updating the page industrial data through the established mapping relation.
Compared with the prior art, the invention has the following beneficial effects:
1. the invention solves the problem that a plurality of addresses need to be subscribed when a plurality of industrial data are checked simultaneously by adopting a mode that the client side acquires the subscribed addresses.
2. The invention realizes high availability of service under the condition of high concurrency and single service failure by adopting a mode of redirecting to the cluster service by adopting a load balancing strategy.
3. The invention solves the problems of user data range authority verification and prevention of the subscription address from being used maliciously for multiple times by adopting a Websocket connection and subscription verification mode.
4. The invention solves the problems of server resource waste and untimely industrial data display caused by the regular polling of the industrial data by the server side in a mode of monitoring the change of the industrial data.
Detailed Description
The present invention will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the invention, but are not intended to limit the invention in any way. It should be noted that it would be obvious to those skilled in the art that various changes and modifications can be made without departing from the spirit of the invention. All falling within the scope of the present invention.
The invention provides a real-time industrial data display method, which comprises the following steps:
a data configuration step: configuring industrial data needing to be displayed in real time;
page viewing step: viewing an industrial data real-time display page;
an address acquisition step: enabling the client to acquire a subscription address;
a service connection step: enabling a client to be connected with a Websocket service;
a data subscription step: enabling a client to subscribe Websocket industrial data service;
data receiving and displaying: and enabling the client to receive and display the industrial data sent by the server.
Specifically, the data configuration step:
and configuring the industrial data needing to be displayed in real time through the application page.
Specifically, the address obtaining step includes:
acquiring industrial data to be displayed on a page, extracting an industrial data ID (identity) and establishing a mapping relation of the page;
sending the industrial data ID to a server;
enabling the server to obtain the ID of the current login user;
enabling the server side to obtain the industrial data ID and then carry out data authority verification, and reserving the industrial data ID which passes the data verification;
generating a subscription address, associating the subscription address with the verified industrial data ID and the current login user ID, marking the subscription address as an unsubscribed address, and storing the unsubscribed address in the distributed cache service;
enabling the server to return the subscription address to the client;
the industrial data ID refers to a unique identifier defined for each industrial data.
Specifically, the service connection step includes:
enabling the client to initiate Websocket connection to the server;
after receiving the Websocket connection, the server redirects the server to the cluster service according to a load balancing strategy;
the cluster service checks whether the client logs in or not, and connection is refused if the client does not log in;
and establishing the Websocket connection by the client side passing the verification.
Specifically, the data subscribing step includes:
enabling the client to subscribe through the acquired subscription address;
after receiving the Websocket subscription, the server redirects a subscription request to the distributed cluster service according to a load balancing strategy;
the cluster service checks whether the client has the following 3 conditions: the user logs in, the subscription address state is not subscribed, and the current login user ID is consistent with the current subscription user ID: rejecting the subscription request for clients that do not satisfy the condition; the client side which passes the verification receives the subscription;
the server side modifies the subscription address state stored in the distributed cache service into a subscribed state, and records the mapping relation between the ID of the subscribed user and the subscription address;
monitoring the change of industrial data subscribed by a user, and entering a data receiving and displaying step to continue executing if the change is detected; otherwise, the monitoring is continued.
Specifically, the data receiving and displaying step includes:
when monitoring that the industrial data changes, the server side sends the industrial data to the client side through the mapping relation between the industrial data ID and the subscription address;
and when the client receives the industrial data, updating the page industrial data through the established mapping relation.
The industrial data real-time display system provided by the invention can be realized through the steps and flows of the industrial data real-time display method provided by the invention. The method for displaying the industrial data in real time can be understood as a preferred example of the industrial data real-time displaying system by those skilled in the art.
The invention provides an industrial data real-time display system, which comprises:
a data configuration module: configuring industrial data needing to be displayed in real time;
a page viewing module: viewing an industrial data real-time display page;
an address acquisition module: enabling the client to acquire a subscription address;
a service connection module: enabling a client to be connected with a Websocket service;
a data subscription module: enabling a client to subscribe Websocket industrial data service;
the data receiving and displaying module: and enabling the client to receive and display the industrial data sent by the server.
Specifically, the data configuration module:
configuring industrial data needing to be displayed in real time through an application page;
the address acquisition module includes:
acquiring industrial data to be displayed on a page, extracting an industrial data ID (identity) and establishing a mapping relation of the page;
sending the industrial data ID to a server;
enabling the server to obtain the ID of the current login user;
enabling the server side to obtain the industrial data ID and then carry out data authority verification, and reserving the industrial data ID which passes the data verification;
generating a subscription address, associating the subscription address with the verified industrial data ID and the current login user ID, marking the subscription address as an unsubscribed address, and storing the unsubscribed address in the distributed cache service;
enabling the server to return the subscription address to the client;
the industrial data ID refers to a unique identifier defined for each industrial data.
Specifically, the service connection module includes:
enabling the client to initiate Websocket connection to the server;
after receiving the Websocket connection, the server redirects the server to the cluster service according to a load balancing strategy;
the cluster service checks whether the client logs in or not, and connection is refused if the client does not log in;
and establishing the Websocket connection by the client side passing the verification.
Specifically, the data subscription module includes:
enabling the client to subscribe through the acquired subscription address;
after receiving the Websocket subscription, the server redirects a subscription request to the distributed cluster service according to a load balancing strategy;
the cluster service checks whether the client has the following 3 conditions: the user logs in, the subscription address state is not subscribed, and the current login user ID is consistent with the current subscription user ID: rejecting the subscription request for clients that do not satisfy the condition; the client side which passes the verification receives the subscription;
the server side modifies the subscription address state stored in the distributed cache service into a subscribed state, and records the mapping relation between the ID of the subscribed user and the subscription address;
monitoring the change of industrial data subscribed by a user, and calling a data receiving and displaying module if the change is detected; otherwise, continuing monitoring;
the data receiving and displaying module comprises:
when monitoring that the industrial data changes, the server side sends the industrial data to the client side through the mapping relation between the industrial data ID and the subscription address;
and when the client receives the industrial data, updating the page industrial data through the established mapping relation.
The present invention will be described more specifically below with reference to preferred examples.
Preferred example 1:
a method for displaying industrial data in real time based on Websocket can display industrial data in real time through Websocket in application. The method comprises the following steps:
when Websoket connection is carried out, the server side can redirect to cluster service according to a load balancing strategy;
when the Websocket subscribes industrial real-time data, user authority verification is carried out to ensure data security;
recording the mapping relation between the user and the industrial real-time data in the Websocket server, providing an industrial real-time value as required, and reducing resource consumption of the server and the client.
As shown in fig. 1, the specific process is as follows:
step 1: configuring industrial data requiring real-time presentation
And configuring the industrial data needing to be displayed in real time by the user through the application page.
Step 2: real-time display page for viewing industrial data
And step 3: client obtains subscription address (display page using code obtained through restful api interface)
(1) The industrial data needing to be displayed on the page are obtained, an industrial data ID (a unique identifier defined for each industrial data in the system, for example, the water inlet temperature of a certain factory is an industrial data, the unique identifier is defined to be 1 in the system, and the industrial data ID is 1) is extracted, and the mapping relation of the page is established.
(2) And sending the industrial data ID to the server.
(3) The server acquires the ID of the current login user.
(3) And the server performs authority verification after acquiring the industrial data ID and retains the industrial data ID passing the data verification.
(4) And generating a subscription address, associating the subscription address with the verified industrial data ID and the current login user ID, marking the subscription address as an unsubscribed address, and storing the subscribed address in the distributed cache service.
(5) And the server returns the subscription address to the client.
And 4, step 4: client-connected Websocket service
(1) The client initiates a Websocket connection to the server.
(2) Load balancing (L load Balance) means that the load balancing is distributed to a plurality of operation units for execution, such as a Web server, an FTP server, an enterprise key application server and other key task servers, so as to jointly complete work tasks.
(3) The cluster service checks whether the client logs in or not, and connection is refused if the client does not log in. The cluster service check means that the server side has a service for checking whether the client side logs in, and the service uses the cluster service. A cluster service refers to a deployment of multiple services.
(4) And establishing the Websocket connection by the client side passing the verification.
And 5: client subscription Websocket industrial data service
(1) And the client subscribes through the subscription address acquired in the step 3.
(2) And after the server receives the Websocket subscription, the server redirects the subscription request to the distributed cluster service according to the load balancing strategy in the step 4.
(3) The cluster service checks whether the client has the following 3 conditions: the user logs in, the subscription address state is not subscribed, and the current login user ID is consistent with the current subscription user ID. The subscription request is denied to users that do not satisfy the condition.
(4) And the client which passes the verification receives the subscription.
(5) And the server side changes the state of the subscription address stored in the distributed cache service into the subscribed state, and records the mapping relation between the ID of the subscription user and the subscription address.
(6) Monitoring the change of the industrial data subscribed by the user, and entering the step 6 to continue executing when the change is monitored.
Step 6: the client receives and displays the industrial data sent by the server
(1) And when monitoring that the industrial data changes, the server side sends the industrial data to the client side through the mapping relation between the industrial data ID and the subscription address.
(2) And when the client receives the industrial data, updating the page industrial data through the mapping relation established in the step 3.
In the description of the present application, it is to be understood that the terms "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like indicate orientations or positional relationships based on those shown in the drawings, and are only for convenience in describing the present application and simplifying the description, but do not indicate or imply that the referred device or element must have a specific orientation, be constructed in a specific orientation, and be operated, and thus, should not be construed as limiting the present application.
Those skilled in the art will appreciate that, in addition to implementing the systems, apparatus, and various modules thereof provided by the present invention in purely computer readable program code, the same procedures can be implemented entirely by logically programming method steps such that the systems, apparatus, and various modules thereof are provided in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Therefore, the system, the device and the modules thereof provided by the present invention can be considered as a hardware component, and the modules included in the system, the device and the modules thereof for implementing various programs can also be considered as structures in the hardware component; modules for performing various functions may also be considered to be both software programs for performing the methods and structures within hardware components.
The foregoing description of specific embodiments of the present invention has been presented. It is to be understood that the present invention is not limited to the specific embodiments described above, and that various changes or modifications may be made by one skilled in the art within the scope of the appended claims without departing from the spirit of the invention. The embodiments and features of the embodiments of the present application may be combined with each other arbitrarily without conflict.