Disclosure of Invention
The invention aims to overcome the defects in the prior art, provides a high-capacity decoupling flexible master station system and a control method, supports data interaction of a distributed system based on a network communication soft bus technology, combines a program design mode, templates class-object and microservices think as a real-time data server working mode, can effectively and dynamically expand various real-time inquiry or display clients without adding a real-time data server code module, and is simple and efficient in maintenance of a software program module.
In order to achieve the above purpose, the invention is realized by adopting the following technical scheme:
in a first aspect, the present invention provides a high capacity decoupling flexible primary station system comprising: the DCS master station system real-time database, a plurality of real-time data servers and a plurality of real-time clients; the real-time clients are respectively connected with the real-time data servers in a one-to-one correspondence manner by adopting a TCP soft bus manner, and the real-time data servers are connected with a DCS master station system real-time database by adopting a shared memory function interface manner, wherein the real-time clients comprise any one or more of a real-time picture client, an alarm client and a real-time curve client;
the real-time client is connected with the real-time data server in a read-write behavior interface mode established based on a message mechanism;
the DCS master station system real-time database comprises a main database and a standby database which are synchronously arranged;
the real-time clients also comprise a read-write mode of a shared memory and are connected with the real-time database of the DCS master station system.
In a second aspect, the present invention provides a control method of a high capacity decoupling flexible master station system according to any one of the preceding claims, applied to a real time data server, comprising:
receiving a link establishment signal sent by a first real-time client side by taking any picture as a unit, and establishing a tcp link with the real-time client side by taking the picture;
establishing a server-client picture new thread, acquiring initialization information and real-time data information of the picture to establish a multi-dimensional index zone linked list, wherein the multi-dimensional index zone linked list comprises a picture index zone and a picture data zone which are respectively used for storing picture objects and picture data information points;
receiving real-time data information of any picture sent by a second real-time client, searching whether the picture index mark exists in a picture index area, if not, establishing a picture data area and a picture index area of the picture, and if so, sharing the picture data area and synchronously updating the picture index area;
inquiring/dynamically registering and notifying a data point objected set in the picture communication link thread to a DCS master station system real-time database; if new data is acquired from a DCS master station system real-time database, judging whether a configuration script exists in the objected point, if so, locking and writing the configuration script into a picture data area after the script runs data for reprocessing; and pushing the registration data points to all real-time clients establishing tcp links in the picture index area.
Further, when the real-time data server establishes a link signal with the real-time client, the method further includes:
and acquiring initialization information sent by the client, judging whether the initialization information is in a pre-established white list, and if so, establishing a tcp link with the real-time client by using the picture.
Further, the initialization information includes ip address information of the real-time client.
Further, the real-time data information includes the picture object and picture data information points, wherein the picture object or the virtual picture object is set up as an index flag.
Further, when the real-time client switches the frames or closes the frames, the tcp link established with the real-time data server is closed, if the tcp link of the frame is closed but the number of links is still more than 0, the index area information is synchronously updated, and the frame data area is not deleted; if all tcp links of the picture are closed, the relevant information of the picture index area is released, and the picture data area is still in a cache state and is not deleted immediately.
Furthermore, the real-time data server performs the searching and inquiring of the pictures by adopting two modes of a hash table and a list table, and synchronously maintains and updates the double tables, wherein,
by adopting a hash table query mode, the index region result can be immediately queried through retrieving the picture object;
the list table inquiring mode is adopted, the list table is provided with an object address pointer of a picture object data area, first-in first-out is adopted, the last use is to place the tail of the queue, if the object exists in the list, the current object is removed from the original position in the list and added to the tail of the list queue, and when the picture quantity reaches the set cache quantity, the corresponding index area is detected from the direction of the head of the queue and no effective information is deleted.
Further, after the real-time data server establishes a link with the real-time client, classifying the picture data points, including query and change notification, wherein the query is one-time query or multiple-time query, and the query is timing query and forwarding; the change notification point objected starts a registration notification mode and establishes association relations of a plurality of corresponding picture index areas and data areas for forwarding.
Further, the real-time client writes the real-time database of the DCS master station system in a manner of remote control or manual number setting to the real-time database, judges whether to update the data area according to the returned result, and forwards and pushes corresponding information to other real-time clients.
Further, when the real-time client closes the tcp link established with the real-time data server, the real-time data server immediately releases the thread corresponding to the picture communication link from the picture index area maintenance list, and removes the client information; when the tcp link number of the picture index area corresponding to different clients is 0, the real-time data server stops inquiring and acquiring data from a DCS master station system real-time database, the registered registration notification point cancels the registration notification, and the picture data is not refreshed any more by the real-time data server; after the re-linking of the corresponding tcp link of the picture is successful, the real-time data server re-starts to inquire and acquire data from the real-time database of the DCS master station system again, re-registers the registration notification, re-starts and refreshes the data, and selects whether to re-establish the picture data area according to whether the cache queue of the picture data area reaches a preset condition or not.
Furthermore, two sets of interface functions are adopted among the DCS master station system real-time database, the plurality of real-time data servers and the plurality of real-time clients to realize real-time data read-write operation, the two sets of interface functions comprise a shared memory function interface mode and a message mechanism read-write behavior interface mode, a function dictionary table is arranged in the real-time data servers to index and accurately match the two sets of interface functions, and two sets of mode interface functions are established to correspond to each other in a bridging association relation.
Compared with the prior art, the invention has the beneficial effects that:
the invention provides a high-capacity decoupling flexible master station system and a control method, which are based on a network communication soft bus technology to support data interaction of a distributed system, and combine a program design mode, wherein template class-object and micro-service thinking are used as real-time data server working modes. Stable performance, reliability and high efficiency, and has wide application prospect.
Detailed Description
The invention is further described below with reference to the accompanying drawings. The following examples are only for more clearly illustrating the technical aspects of the present invention, and are not intended to limit the scope of the present invention.
Example 1
This embodiment describes a high capacity decoupling flexible master station system comprising: the DCS master station system real-time database, a plurality of real-time data servers and a plurality of real-time clients; the real-time clients are respectively connected with the real-time data servers in a one-to-one correspondence manner by adopting a TCP soft bus manner, and the real-time data servers are connected with a DCS master station system real-time database by adopting a shared memory function interface manner, wherein the real-time clients comprise any one or more of a real-time picture client, an alarm client and a real-time curve client;
the real-time client is connected with the real-time data server in a read-write behavior interface mode established based on a message mechanism;
the DCS master station system real-time database comprises a main database and a standby database which are synchronously arranged;
the real-time clients also comprise a read-write mode of a shared memory and are connected with the real-time database of the DCS master station system.
Example 2
The present embodiment provides a control method of the high-capacity decoupling flexible master station system according to any one of embodiment 1, applied to a real-time data server, including:
receiving a link establishment signal sent by a first real-time client side by taking any picture as a unit, and establishing a tcp link with the real-time client side by taking the picture;
establishing a server-client picture new thread, acquiring initialization information and real-time data information of the picture to establish a multi-dimensional index zone linked list, wherein the multi-dimensional index zone linked list comprises a picture index zone and a picture data zone which are respectively used for storing picture objects and picture data information points;
receiving real-time data information of any picture sent by a second real-time client, searching whether the picture index mark exists in a picture index area, if not, establishing a picture data area and a picture index area of the picture, and if so, sharing the picture data area and synchronously updating the picture index area;
inquiring/dynamically registering and notifying a data point objected set in the picture communication link thread to a DCS master station system real-time database; if new data is acquired from a DCS master station system real-time database, judging whether a configuration script exists in the objected point, if so, locking and writing the configuration script into a picture data area after the script runs data for reprocessing; and pushing the registration data points to all real-time clients establishing tcp links in the picture index area.
The application process of the control method of the high-capacity decoupling flexible master station system provided by the embodiment specifically relates to the following steps:
as shown in fig. 4 and fig. 5, based on the scheme of the template class-object and micro-service idea real-time data server mode, in view of the most complex real-time client, the present invention takes the object real-time data server 1 and real-time clients 1-n generated by the real-time data server class template as an example to illustrate the workflow, and other real-time data servers and real-time query or browsing clients work logic flows are similar to this. Each real-time client interacts with the commercial database data, and the invention is not described. In design and implementation, the following design points and technical features are followed:
(1) The calling process reads the configuration file, and parameters such as IP, port (Port), real-time server number and the like are transmitted to establish a plurality of real-time server running instances.
(2) The real-time data Server 1 works in Server mode according to IP and Port, and the TCP soft bus also works in Server mode to start interception. The real-time clients 1-n work in the Client mode, the TCP soft bus also works in the Client mode, and the first step of active chain establishment is carried out by taking each picture page of the Client as a unit. The real-time data server 1 checks whether the parameters are within the white list according to the ip address of the client. If yes, agreeing to build the chain. If not, the link is broken. Every time a frame is switched, the original frame link is closed, and a new tcp link is established for a new frame.
It is noted that, instead of using the whole client x of the real-time frame as the tcp link unit, the maintenance unit is designed for the tcp link per frame of the client. In all the clients of different categories, the real-time clients generally have the most pictures, the pictures are required to be frequently switched, the complexity is high, other real-time query software can perform similar reasoning and determination according to the number of data points, the actual conditions of operation behaviors and the like, and virtual picture objects similar to the pictures are established and used as keywords of an index area. The real-time data server thus establishes a picture data area and an index area in units of pictures, and establishes a bi-directional association relationship with each other 2.
Hiding or closing the picture, etc., the communication link is disconnected. Even if different picture clients can open a plurality of pictures, only a plurality of currently displayed working pictures are in an effective working state, and the hidden pictures are in the working state data which are not displayed currently and are not required to be refreshed, so that a server-side link does not need to be maintained in a working and data area.
Therefore, each picture is taken as design maintenance granularity, and the storage quantity and processing complexity of various data points in the data area of the real-time data server can be greatly reduced. The number of clients that can be supported by the real-time data server side is objectively increased. The data interaction pressure of the two parties is greatly reduced, the real-time data interaction efficiency and capacity are improved, and the unnecessary refreshing of the real-time data of the two parties is prevented.
(3) If the link is an effective link in the white list, a new thread of a server-Client picture is established, client information is acquired, and the ip information and threads of clients, picture objects and other multidimensional index zone linked lists are established.
(4) When a real-time client x opens any new picture, the link normally starts to send initialization information and real-time data information, and the information points are analyzed and decomposed at a server side, so that a picture data area is established. And uses the picture object as index mark unit. The objects of the same picture are unique in the host system regardless of which real-time client, and these picture objects and data information points are determined by the configuration software, configuration model software, etc. of the host system. When any real-time client runs, only the picture is loaded, and a data maintenance area is built according to information points in the picture. Pictures have global uniqueness and identity. The data area using the picture object as an index key has global uniqueness and identity, and the picture data area is shared by a plurality of identical pictures of the real-time client simultaneously running.
Whenever the real-time data server accepts a client x new picture initialization, it retrieves whether the picture index exists. If the thread does not exist, creating a thread, a picture index area such as a picture object, a tcp link and the like and a picture information point data area; if the information exists, the picture data area is shared, and the new threads of the index area, the new tcp links and the like are synchronously updated; this screen link is closed whenever the screen is switched or turned off. If the tcp link is closed but the number of links is still greater than 0, the index area information is updated synchronously, and the picture data area is not deleted. If the last tcp link of the picture is also closed. The relevant information of the picture index area is released, and the picture data area is still in a buffer state and is not deleted immediately. And realizing synchronous updating of the picture index area and caching of the picture data area.
The picture inquiry adopts a double-table maintenance mode: one is a hash table, the picture file uniquely identifies the objected, and as a key word, the index area result can be immediately queried in the hash. The other is list table, which is the object address pointer of the picture object data area, first in first out, and last in use, the tail of the queue is placed. If the object is already in the list, the current object is removed from the list in-situ and added to the list tail when used, thus forming the most recently used tail strategy. When the number of pictures reaches the set buffer number, deleting the corresponding index area when no effective information is detected from the head of the queue. The double table is synchronously maintained and updated. The design idea of the latest object is kept, and the rapidity of object access and the novelty of latest use are improved. This avoids frequent creation or deletion of picture data areas, picture index areas. The access rapidity is improved.
(5) The real-time data server 1 classifies the picture data points, including query (one query/multiple queries) and change notification class 2. The query is a timed query and forwarded. The change notification point objected starts a registration notification mode and establishes association relations of a plurality of corresponding picture index areas and data areas for forwarding. The hash table of the same object point in the same picture is unique at the end of the real-time data server 1 and is used for quickly indexing or accessing the data information of the same object point.
(6) The real-time data server 1 queries/dynamically registers the real-time database for a set of data points objected within the picture communication link thread. If new data is obtained from the real-time library, whether a configuration script exists in the objected point or not can be combined, if yes, after the script runs the data for reprocessing, the data is locked and written into the hash data area, so that the data is operated once in the real-time data server 1, and repeated operation on each client is not needed. And the operation pressure of the client computer is reduced. And pushing all the picture clients of the Client linked list to the registration class data points.
(7) The real-time client x remotely controls, manually writes the real-time database into the real-time database, and according to the returned result, whether to update the point data area or not, and forwards and pushes corresponding information to other picture clients.
(8) And the real-time data server immediately releases resources such as threads corresponding to the picture communication link from the picture index area maintenance list and removes the client information. When the tcp link number of the picture index area corresponding to different clients is 0, which indicates that the clients of the picture corresponding to the links are all closed, the real-time server 1 stops inquiring and acquiring data from the real-time database, the registered registration notification point cancels the registration notification, and the picture data is not refreshed any more. After the tcp link is successfully re-established (greater than 0), the real-time data server 1 re-starts to acquire data from the real-time database query, re-registers the registration notification, and re-starts refreshing the data. But the picture data area is not required to be re-established, so that the process time for establishing the data area is saved, and the efficiency is improved. And when the picture data area buffer queue reaches the preset condition, the index area and the data area of the picture data area buffer queue completely release resources. The index area and the data area are deleted synchronously. If the picture is built again corresponding to the client, a picture index area and a picture data area are newly built as in the first time of building the link.
(9) The real-time data read-write operation interface function realizes 2 sets, one set of shared memory mode, and one set of message mechanism adopting function name as key word realizes interface mode. In fig. 4, the interaction between the real-time data server 1 … n and the real-time database (which may also include the original real-time image, the original alarm interface, the original real-time curve, etc.) adopts the existing shared memory function interface mode, while the interaction between the remote clients and the real-time data server 1 … n adopts the message mechanism read-write behavior interface mode.
The real-time data server 1 … n internally sets a function dictionary table to index and accurately match two sets of interface functions, establishes two sets of mode interface functions to be in one-to-one correspondence bridging association relationship, and is similar to Remote Procedure Call (RPC) in operation. The various types of client code thus need not be changed. By replacing the 2-socket interface function, the local binding or remote separation working mode with the real-time library can be realized. This minimizes various client code changes, smoothing compatible upgrades, as shown in FIG. 6.
The control method of the high-capacity decoupling flexible master station system provided by the invention has the following effects:
(1) The master station system generally comprises interface display tools such as a real-time picture, a real-time curve, a real-time alarm and the like, and generally realizes data interaction with a real-time database in a shared memory mode, and has a strong coupling binding relationship with the real-time database. Decoupling of these modules from the real-time database is achieved in the present design by a dynamic real-time data server.
(2) And setting a real-time data server as a data interaction medium, and adopting a TCP soft bus to support interaction between a plurality of real-time clients, so that various clients can be distributed and deployed, and extension deployment is realized. A black list and a white list may be provided.
(3) Based on the template class-object and micro-service idea real-time data server mode, if only one real-time data server app is adopted, the one-to-many small-capacity real-time data server mode can be regarded as a special case, and has compatibility and flexibility of data interaction of various clients, but has strong module and capacity expansion capability.
(4) Based on the template class-object and micro-service idea real-time data server mode, if a plurality of real-time data servers are adopted, the excellent real-time performance and high-capacity data concurrent processing can be compared with the point-to-point professional real-time data server mode. Compared with the mode that each professional real-time data server needs to be realized, the mode code has the advantages of less code development quantity, simple maintenance work, no programming and compiling, dynamic expansion of the architecture at any time and any place, and hot plug function.
(5) When the real-time data server runs, a script can be run on related data points according to the configuration information, the real-time data can be reprocessed and stored or pushed and forwarded to other clients, the real-time running requirement of the clients is reduced, and the performance configuration of the client computer is reduced.
(6) The invention uses picture page as unit to build TCP soft bus to build link and close link, the real-time data server uses link id, picture object, client ip to build picture index area and picture data area. And 2, establishing a two-way association relation. Therefore, the real-time online data points of each picture are not more, more real-time clients can be supported, and the design is ingenious, simple and efficient. Other client principles can consult the picture to set virtual objects as appropriate.
(7) The real-time data server end adopts an index area and a data area to be arranged separately. The index area is synchronously updated according to different client links, and the picture index area and the data area 2 synchronously implement a caching strategy. The picture inquiry adopts double combination of hash and linked list, and the double list is synchronous, so that the aim of quickly hitting the data area to access the object is fulfilled, meanwhile, the first-in first-out is fulfilled, the latest object is moved to the tail of the queue, the invalid data area object is firstly removed and released from the head of the queue, the design thought of the latest data area object is reserved, and the rapidity and the latest use novelty of the data area object are improved. The picture index area and the data area are synchronously cached, maintained and deleted.
(8) The real-time data server 1 classifies the picture data points, including query (one query/multiple queries) and change notification class 2. The query is a timed query and forwarded. The change notification point objected starts a registration notification mode and establishes association relations of a plurality of corresponding picture index areas and data areas for forwarding. The hash table of the same object point in the same picture is unique at the end of the real-time data server 1 and is used for quickly indexing or accessing the data information of the same object point.
(9) The micro-service architecture principle simplifies the design of a real-time library and realizes load balancing. Because the clients do not share the memory to bind the real-time databases, the number of the real-time databases is greatly reduced, and only one main real-time database and one standby real-time database can be set, so that the synchronization is simple, and the complexity of the synchronous design and implementation of the real-time databases is greatly reduced. Meanwhile, different real-time databases can be correspondingly distributed according to information such as the number of clients, data traffic and the like by load balancing deployment of real-time data server app instances.
(10) The real-time data read-write operation interface function realizes 2 sets, one set of existing shared memory mode, and one set of message mechanism with function name as key word. The real-time data server sets a function dictionary table to index and accurately match two sets of socket functions, establishes a one-to-one corresponding bridging association relationship between the two parties, and is similar to remote procedure call during operation. The various types of client code thus need not be changed. By replacing the 2-socket interface function, the local binding or remote separation working mode with the real-time library can be realized. Therefore, the code changes of various clients can be reduced as much as possible, and the upgrade is smooth and compatible.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.