Data acquisition method and device, storage medium and electronic device

By obtaining the service node table and configuration information table in the client's data acquisition method, establishing a mapping relationship and determining the target policy, and using subscription and pulling strategies to collect data from the server, the problem of low data acquisition efficiency and reliability of the client is solved. , realizes efficient and reliable data collection.

CN119402554APending Publication Date: 2025-02-07HUANENG MANZHOULI WIND POWER CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411454899.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The prior art is difficult to effectively improve the efficiency and reliability of client data acquisition in industrial automation systems. Although the server improves data reliability through dual-machine hot standby, it is impossible to ensure the efficiency and reliability of client data acquisition.

Method used

By implementing a data acquisition method on the client, obtain the service node table and configuration information table of multiple service nodes, establish a mapping relationship between the client and the service node and the server, and determine the configuration information table of the target service node according to the configuration information table of the target service node The target policy for collecting data from the server adopts a subscription policy, a pull policy or a subscription and the pull policy collects data from the server.

Benefits of technology

Improves real-time and flexibility of data acquisition, and through a combination of subscription and pull, data integrity and high reliability can be ensured even in the event of network instability or server failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402554A_ABST
    Figure CN119402554A_ABST
Patent Text Reader

Abstract

The invention discloses a data collection method and device, a storage medium, an electronic device and a computer program product, and the method comprises the steps: obtaining a service node table and a configuration information table of a plurality of service nodes, the service node table being used for indicating the address of a server corresponding to the service node, and the configuration information table being used for indicating the address of the server corresponding to the service node; the configuration information table is used for indicating a strategy of acquiring data from the server side by the service node; according to the service node table, establishing a mapping relationship between the client and the service node and between the client and the server; according to the configuration information table of the target service node, a target strategy for collecting data from the server is determined, and the target strategy comprises one of a subscription strategy, a pull strategy and a subscription and pull strategy; and collecting data of the target service node from the server by adopting a target strategy according to the mapping relationship. The client can flexibly select the data acquisition mode according to the target strategy in the configuration information table, is suitable for different data acquisition scenes and requirements, and ensures the integrity and high reliability of the data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data collection, and more specifically, to a data collection method and device, a storage medium, an electronic device, and a computer program product. Background Art

[0002] With the rapid development of automation and information technology, the requirements for the efficiency and reliability of data acquisition are getting higher and higher. In industrial automation systems, the efficiency and reliability of data acquisition are crucial to production efficiency, production process monitoring, and production safety. How to improve the efficiency and reliability of data acquisition is a problem that needs to be solved at present.

[0003] In the related art, the reliability of data is usually improved by using a dual-machine hot standby method on the server side, that is, two servers are used to work simultaneously to ensure the continuous provision of high-availability data to the client, thereby improving the reliability of the data collected by the client.

[0004] However, the related art only improves the reliability of data provided by the server, but cannot guarantee the efficiency and reliability of client data collection. Summary of the invention

[0005] Embodiments of the present application provide a data collection method and device, a storage medium, an electronic device, and a computer program product.

[0006] According to one aspect of an embodiment of the present application, a data collection method is provided, which is applied to a client, and the method includes: obtaining a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the server corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the server; according to the service node table, a mapping relationship is established between the client and the service node and the server; according to the configuration information table of the target service node, a target strategy for collecting data from the server is determined, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy; according to the mapping relationship, the target strategy is adopted to collect data of the target service node from the server.

[0007] In an exemplary embodiment, the target strategy is used to collect data of the target service node from the server according to the mapping relationship, including: when the target strategy is a subscription strategy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and the data of the address of the server corresponding to the target service node is subscribed to collect data from the server and obtain changes in the data from the server in real time; when the target strategy is a pull strategy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and the data of the address of the server corresponding to the target service node is pulled at a preset time interval; when the target strategy is a subscription and pull strategy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and the data of the address of the server corresponding to the target service node is subscribed to, and the data of the address of the server corresponding to the target service node is pulled at a preset time interval.

[0008] In an exemplary embodiment, after the steps of determining the address of the server corresponding to the target service node according to the mapping relationship, subscribing to the data of the address of the server corresponding to the target service node, and pulling the data of the address of the server corresponding to the target service node at a preset time interval, data collection also includes: comparing the first data of the target service node collected through the subscription strategy with the second data of the target service node collected through the pull strategy; when the first data and the second data are inconsistent, updating the data of the target service node to the second data.

[0009] In an exemplary embodiment, the data collection method also includes: acquiring changes in the multiple service nodes in real time; when it is determined that a newly added service node exists, collecting data of the newly added service node from the server end according to the service node table and configuration information table of the newly added service node; when it is determined that the service node is deleted, stopping collecting data of the deleted service node from the server end; when it is determined that the configuration information table of the service node is modified, collecting data of the service node from the server end according to the modified configuration information table; when it is determined that the configuration information table of the service node is deleted, stopping collecting data of the service node whose configuration information table is deleted from the server end.

[0010] In an exemplary embodiment, the data collection method also includes: when the client accesses the server, obtaining a distributed lock configuration table; determining whether the target service node of the server is occupied and locked according to the distributed lock configuration table; when it is determined that the target service node of the server is not occupied and locked, the client applies to lock the target service node; when the client successfully locks the target service node, the client collects data from the target service node and updates the distributed lock configuration table, wherein the updated distributed lock configuration table indicates that the target service node is occupied and locked; wherein, when it is determined that the target service node of the server is occupied and locked, the client cannot collect data of the target service node from the server.

[0011] In an exemplary embodiment, when the client successfully locks the target service node, the client collects data from the target service node and updates the distributed lock configuration table, the data collection method also includes: detecting the connection status between the client and the server; when the connection status is normal, determining whether the time for the client to collect data from the target service node exceeds a preset time according to the distributed lock configuration table; when the time for the client to collect data from the target service node exceeds the preset time, disconnecting the client from the target service node and updating the distributed lock configuration table, wherein the updated distributed lock configuration table indicates that the target service node is not occupied and locked; when the connection status is abnormal, disconnecting the client from the target service node and updating the distributed lock configuration table, wherein the updated distributed lock configuration table indicates that the target service node is not occupied and locked.

[0012] According to another aspect of the embodiment of the present application, a data collection device is also provided, the device comprising:

[0013] An information acquisition module, used to acquire a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the service end corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the service end;

[0014] A mapping establishment module, used to establish a mapping relationship between the client and the service node and the server according to the service node table;

[0015] A strategy determination module, used to determine a target strategy for collecting data from the server according to a configuration information table of a target service node, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy;

[0016] The data collection module is used to collect the data of the target service node from the server end according to the mapping relationship and using the target strategy.

[0017] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned data collection method when running.

[0018] According to another aspect of the embodiments of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the data collection method through the computer program.

[0019] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.

[0020] The above-mentioned data collection method and device, storage medium, electronic device, and computer program product, the method first obtains the service node table and configuration information table of multiple service nodes. Then, according to the service node table, a mapping relationship between the client and the service node and the server is established, and according to the configuration information table of the target service node, the target strategy for collecting data from the server is determined. According to the mapping relationship, the target strategy is adopted to collect the data of the target service node from the server. The client can flexibly select the data collection method according to the target strategy in the configuration information table, and can subscribe to data in real time to improve the real-time nature of the collected data, or pull data on demand to save resources, or combine real-time subscription to data and on-demand pulling of data to improve the real-time nature and flexibility of data collection. By combining subscription and pulling, the integrity and high reliability of the data can be ensured even in the case of network instability or server failure. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0023] Figure 1 It is a hardware structure block diagram of the data collection method of the embodiment of the present application;

[0024] Figure 2 is a flow chart of a data collection method according to an embodiment of the present application;

[0025] Figure 3 This is a second flow chart of a data collection method according to an embodiment of the present application;

[0026] Figure 4 This is a third flow chart of a data collection method according to an embodiment of the present application;

[0027] Figure 5 This is a fourth flow chart of a data collection method according to an embodiment of the present application;

[0028] Figure 6 is a schematic diagram of database status monitoring according to an embodiment of the present application;

[0029] Figure 7 This is a fifth flow chart of a data collection method according to an embodiment of the present application;

[0030] Figure 8 This is a sixth flow chart of a method for collecting data according to an embodiment of the present application;

[0031] Fig. 9 It is a structural block diagram of a data collection device according to an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0034] The method embodiments provided in the embodiments of the present application can be executed in a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 1 is a hardware structure block diagram of a computer terminal of the data collection method of the embodiment of the present application. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a microprocessor (Microprocessor Unit, referred to as MPU) or a programmable logic device (Programmable logic device, referred to as PLD)) and a memory 104 for storing data. In an exemplary embodiment, the computer terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Equivalent functions or comparisons shown Figure 1 A different configuration with more features is shown.

[0035] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data collection method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0036] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0037] In this embodiment, a data collection method is provided. Figure 2 : is a flow chart of an optional data collection method according to an embodiment of the present application, the process includes the following steps S200-S230:

[0038] Step S200: obtaining a service node table and a configuration information table of multiple service nodes.

[0039] Among them, the service node table is used to indicate the address of the server corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the server. The role of the service node table is to manage the connection configuration information between the OPC UA client and the server. The client will establish a connection with the server based on the information in this table, such as the address of the server. When a new service node needs to be subscribed, a new row can be added to the table, and the client will read the newly added configuration information to create or update the connection with the corresponding server. Similarly, if the service node no longer needs to be subscribed, the row can be deleted from the table, and the client will release the connection with the server based on the row ID and the previously established association relationship to ensure the rational use of resources. By maintaining this service node table, dynamic configuration and management of client data collection operations can be achieved, improving the flexibility and efficiency of data collection. At the same time, this method facilitates monitoring of the connection status between the client and the server to ensure the continuity and reliability of data collection. The configuration information table is a database table used to store relevant information about the data points that the OPC UA client needs to subscribe to from the OPC UA server. By configuring the information table, you can dynamically configure which data points on the server need to be subscribed by the OPC UA client and how the client collects data from these data points. When there are new data points that need to be monitored, you can add corresponding records in the configuration table. When the data of a data point is no longer needed, you can cancel the subscription by deleting the corresponding record. This configurable data collection method improves the flexibility and maintainability of the system.

[0040] Exemplarily, the service node table is shown in Table 1 below.

[0041] Table 1. Service Node Table

[0042]

[0043] The configuration information table is shown in Table 2 below.

[0044] Table 2. Configuration information table

[0045]

[0046] Specifically, the client can read the service node table (Table 1) and the configuration information table (Table 2) from the relational database. The service node table contains the unique identifier (id) of the service node, the server address (end point), the creation time (date_created), and the last update time (last_updated). The configuration information table records the unique identifier (id) of the point code, the associated service node identifier (endpoint_id), the identifier of the point code (node_id), the browse name of the point code (browse_name), the data collection mode / strategy (mode), and the data pulling interval (interval) in the pull mode.

[0047] It should be noted that the OPC Unified Architecture (OPC UA) protocol is a communication standard. It is a cross-platform, service-oriented communication architecture designed to provide secure, reliable, and interoperable data exchange between devices, systems, and software in the field of industrial automation and manufacturing. OPC UA not only supports traditional industrial fieldbus technology, but also supports Ethernet and Internet technology, allowing industrial equipment to be seamlessly connected to enterprise information systems.

[0048] Step S210: Establish a mapping relationship between the client, the service node and the server according to the service node table.

[0049] Among them, the client can create a connection with the server according to the information in the service node table, and establish a mapping relationship between the id of the service node in the service node table and the client, ensuring that each service node has a corresponding client connection, that is, a mapping relationship is established between the client and the service node and the server.

[0050] Step S220: determining a target strategy for collecting data from the server according to the configuration information table of the target service node.

[0051] The client can directly read the target policy corresponding to the target service node from the configuration information table. The target policy includes one of a subscription policy, a pull policy, and a subscription and pull policy.

[0052] The subscription strategy is that the client will send a subscription request to the server, requesting that the client be notified when the data point corresponding to the target service node changes. After receiving the subscription request, the server will monitor these data points in real time, and actively send the data changes to the client when the data changes. This strategy is suitable for application scenarios that require real-time monitoring of data changes because it can provide almost instant data update notifications. The disadvantage is that if the network connection is unstable, data push may be lost, and the server's push load will increase relatively.

[0053] In the pull strategy, the client periodically requests the data of the data point corresponding to the target service node from the server. The frequency (interval) of data requests is determined by the client, usually set through the interval field. This strategy is suitable for scenarios where the data update frequency is not high or the network environment is unreliable and the client needs to ensure data acquisition. It does not rely on the active push of the server, which reduces the resource consumption of the server, but the real-time performance is worse than the subscription strategy.

[0054] The subscription and pull strategy combines the above two strategies. The client subscribes to data points in real time and pulls them periodically. Real-time subscription ensures that data changes can be captured in a timely manner, while periodic pulls serve as a backup mechanism to verify the integrity and consistency of data acquisition. If the real-time subscribed data is lost, the client can complete the data through periodic pull operations. This strategy provides higher data integrity and reliability, but it also consumes relatively large computing resources and network resources.

[0055] Step S230: According to the mapping relationship, data of the target service node is collected from the server using the target strategy.

[0056] The corresponding data point of the target service node in the server is determined according to the mapping relationship, and then the target strategy is adopted to collect the data of the target service node.

[0057] In this embodiment, the service node table and configuration information table of multiple service nodes are first obtained. Then, according to the service node table, a mapping relationship between the client and the service node and the server is established, and according to the configuration information table of the target service node, a target strategy for collecting data from the server is determined. According to the mapping relationship, the target strategy is adopted to collect data of the target service node from the server. The client can flexibly select the data collection method according to the target strategy in the configuration information table. It can subscribe to data in real time to improve the real-time nature of the collected data, or pull data on demand to save resources, or combine real-time subscription to data and on-demand pulling of data to improve the real-time nature and flexibility of data collection. By combining subscription and pulling, the integrity and high reliability of the data can be ensured even in the case of network instability or server failure.

[0058] In one embodiment, Figure 3 As shown, step S230, according to the mapping relationship, adopts the target strategy to collect the data of the target service node from the server. It includes: steps S300-S320, wherein:

[0059] Step S300, when the target policy is a subscription policy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and the data of the address of the server corresponding to the target service node is subscribed to collect data from the server and obtain data changes from the server in real time.

[0060] Specifically, when the target policy is a subscription policy, the client will connect to the corresponding OPC UA server based on the mapping relationship read from the relational database (i.e., the relationship between the endpoint field in the service node table and the client instance). The client uses the subscription function of the OPC UA protocol to obtain data changes of the target service node from the server in real time.

[0061] Step S310, when the target strategy is a pull strategy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and data of the address of the server corresponding to the target service node is pulled at a preset time interval.

[0062] Specifically, in pull mode, the client does not actively subscribe to changes in data points, but requests data (pulls data) from the OPC UA server at a fixed time according to the preset interval field value (in seconds). The pull strategy is suitable for scenarios with low data update frequency. Compared with the subscription strategy, it reduces the consumption of communication and computing resources and improves system efficiency.

[0063] Exemplarily, the pull time range satisfies the following conditions:

[0064] t∈(t last ,t last+30min ]

[0065] That is, pull it at least once within 30 minutes.

[0066] Step S320, when the target strategy is a subscription and pull strategy, determine the address of the server corresponding to the target service node according to the mapping relationship, subscribe to the data of the address of the server corresponding to the target service node, and pull the data of the address of the server corresponding to the target service node at a preset interval.

[0067] Specifically, when a subscription and pull strategy is adopted, the client not only subscribes to changes in data points, but also pulls data regularly, so that when the server push mechanism fails or the network is unstable, pulling can be used as a supplementary data acquisition method.

[0068] In this embodiment, by providing three different data collection strategies, the most suitable collection strategy can be selected according to the actual application scenario and requirements (data update frequency, network status), thereby improving the efficiency of data collection and saving computer resources. By flexibly configuring the data collection strategy, the reliability and efficiency of OPC UA client data collection are significantly improved, adapting to the high requirements for data collection in the fields of industrial automation and intelligent manufacturing.

[0069] In one embodiment, Figure 4 As shown, in step S320, when the target strategy is a subscription and pull strategy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and the data of the address of the server corresponding to the target service node is subscribed, and the data of the address of the server corresponding to the target service node is pulled at a preset interval. After that, the data collection method also includes: steps S400-S410. Among them:

[0070] Step S400: comparing first data of the target service node collected by the subscription strategy with second data of the target service node collected by the pull strategy.

[0071] Among them, data is collected through both subscription strategy and pull strategy, that is, the client receives data change notifications from the server in real time, and also pulls data at regular intervals.

[0072] Step S410: When the first data and the second data are inconsistent, update the data of the target service node to the second data.

[0073] Among them, the total amount of data in the pulling cycle can be compared with the stored data. If the total amount of data is found to be inconsistent, it indicates that data may be lost. The reason for the data loss is due to network fluctuations. The first data collected in real time through the subscription strategy may be inaccurate, and the second data is more accurate because it is pulled at a fixed time. Therefore, at this time, the client can update the data of the target service node to the second data, or it can pull the second data again and update the storage.

[0074] For example, the pull strategy may be used to check whether the data currently collected through the subscription strategy is consistent with the total amount of data stored in the library on an hourly basis. If they are inconsistent, the pulled data is rewritten into the library.

[0075] In this embodiment, the client collects data through both the subscription strategy and the pull strategy. On the one hand, it can obtain data in real time, and on the other hand, it can regularly perform data integrity checks on the data collected through the pull strategy to ensure high reliability and integrity of the data.

[0076] In one embodiment, Figure 5As shown, the data collection method also includes: steps S500-S540.

[0077] in:

[0078] Step S500: acquiring changes of multiple service nodes in real time.

[0079] Among them, the client can continuously monitor the changes of multiple service nodes in the relational database, and also obtain the changes of the service node table and the configuration information table. This can be achieved through database triggers, database log files, or using the change data capture (CDC) function provided by the database. When a service node or configuration information is added, deleted, or modified in the database, the client responds to the change in a timely manner by subscribing to the event notification of the database.

[0080] Step S510: When it is determined that there is a newly added service node, data of the newly added service node is collected from the server according to the service node table and the configuration information table of the newly added service node.

[0081] Specifically, when the client detects that a new row has been added to the service node table, that is, a new service node has been added, the client will perform the following steps: Read the newly added service node table: Get detailed information about the newly added service node, including the server address, data collection strategy, etc. Create a new client instance: Based on the configuration information of the newly added service node, the client creates a new OPC UA client instance. Data collection: According to the target strategy (subscription, pull, or subscription and pull) in the configuration information table, the client starts to collect data from the newly added service node.

[0082] Step S520: When it is determined that the service node is deleted, stop collecting data of the deleted service node from the server.

[0083] Specifically, when the client detects that a row in the service node table has been deleted, it means that the corresponding service node has been deleted and no longer needs data collection. The client will perform the following steps: Determine the deleted service node: Through the mapping relationship with the database, the client identifies the deleted service node ID. Release client resources: The client cancels all data collection tasks related to the deleted service node, including subscription and pull tasks, and releases the connection resources with the server. Stop data collection: The client stops collecting data from the deleted service node from the server to ensure the effective use of resources and the stability of the system.

[0084] Step S530: When it is determined that the configuration information table of the service node is modified, data of the service node is collected from the server according to the modified configuration information table.

[0085] Specifically, when the configuration information table is modified (including adding new rows or modifying row data), the client will reconfigure the data collection mode according to the modified policy: Determine the modified configuration information: The client reads the updated configuration information, including parameters such as data collection mode and pull interval. Reconfigure data collection: The client adjusts the connection status with the server according to the new policy, such as canceling the existing subscription, re-subscribing, or setting a new pull task. Data collection update: The client starts collecting data according to the modified policy to ensure that the collection policy is consistent with the latest configuration information.

[0086] Step S540: when it is determined that the configuration information table of the service node is deleted, stop collecting data of the service node whose configuration information table is deleted from the server.

[0087] Specifically, when a row in the configuration information table is deleted, the client will stop data collection for the corresponding service node: Determine the deleted configuration information: Through the mapping relationship with the database, the client identifies the service node whose configuration information has been deleted. Cancel data subscription and pull: The client stops all data collection operations for the service node corresponding to the deleted configuration information, including subscription and pull tasks. Resource release: The client releases the connection resources with the server to ensure the reasonable allocation and management of system resources.

[0088] For example, Figure 6 As shown, a log file may be obtained from a relational database, which includes multiple service nodes. Changes of multiple service nodes may be obtained from the log file, thereby monitoring changes of multiple service nodes. Then, based on the changes of multiple service nodes, corresponding measures such as steps S510-S540 are taken.

[0089] In this embodiment, by obtaining the changes of multiple service nodes in real time and dynamically adjusting the client's operation and data collection strategy according to the changes of multiple service nodes, the flexibility and adaptability of the system are improved. By timely responding to the deletion of service nodes and the modification of configuration information, unnecessary data collection and resource consumption are avoided, and resource utilization is improved. When the configuration information is modified or deleted, the client can ensure the consistency of the data collection strategy with the latest configuration information, avoiding confusion and inconsistency in data collection. By real-time monitoring and responding to changes in service nodes, it is ensured that data collection can still maintain continuity and reliability even in an industrial automation environment where service nodes change frequently. The adjustment of all data collection strategies is based on the changes in the relational database, making system maintenance and configuration changes simple and efficient, and reducing manual intervention. In summary, by real-time monitoring and responding to changes in service nodes, dynamic adjustment of data collection strategies is achieved, resource allocation is optimized, and the accuracy and reliability of data collection are improved. It is suitable for data collection needs in the fields of industrial automation, intelligent manufacturing, etc.

[0090] In one embodiment, Figure 7 As shown, the data collection method also includes: steps S700-S750.

[0091] in:

[0092] Step S700: When the client accesses the server, a distributed lock configuration table is obtained.

[0093] When the client tries to access the server, it first reads the distributed lock configuration table from the relational database, which records the lock status information of all target service nodes, including the lock name, current lock holder, lock creation time, lock time, last update time, expiration time, etc. By querying this table, the client can find out whether the target service node has been locked by other clients.

[0094] Exemplarily, the distributed lock configuration table is shown in Table 3 below. It is used for clients distributed on different servers to compete for lock resources. OPC UA clients running on multiple servers may need to access the same OPC UA Server or its data points at the same time. In order to avoid data conflicts and maintain data consistency, the use of distributed locks can ensure that at any time, only one client can access a specific OPC UA server or its data points.

[0095] Table 3. Distributed lock configuration table

[0096]

[0097] Step S710, determining whether the target service node of the server is occupied and locked according to the distributed lock configuration table. If it is determined that the target service node of the server is not occupied and locked, execute step S720. If it is determined that the target service node of the server is occupied and locked, execute step S700.

[0098] Specifically, if the target service node is not locked, that is, the owner field in the table is empty or the expire_on field time has expired, the client can try to acquire the lock. If the target service node is locked, that is, the owner field is filled with the ID of another client and the expire_on field time has not expired, the current client needs to wait and return to step S700 to try to acquire the lock again.

[0099] Step S720: The client applies to lock the target service node.

[0100] Specifically, when the target service node is not locked, the current client applies to lock the service node through a distributed lock mechanism. The lock request includes a unique identifier (ID) of the client and a desired lock duration.

[0101] Step S730, determining whether the client successfully locks the target service node. If the client successfully locks the target service node, executing step S740. If the client fails to lock the target service node, executing step S750.

[0102] Specifically, the distributed lock mechanism checks the lock request. If successful, the owner field in Table 3 is updated to the ID of the current client, and the date_locked and expire_on fields are updated to record the lock time and expiration time. If the lock fails, the client will not be able to continue the data collection operation, but will execute step S750 to release the resources and wait for the next opportunity.

[0103] Step S740: The client collects data from the target service node and updates the distributed lock configuration table.

[0104] The updated distributed lock configuration table indicates that the target service node has been occupied and locked. Specifically, the target service node may be locked using the client ID, and the locking duration may be set.

[0105] Specifically, if the lock is successful, the client collects data from the target service node and updates the distributed lock configuration table to ensure that other clients can recognize that the service node is occupied. After the lock is successful, the client needs to periodically update the lock holder information and the lock expiration time while performing data collection operations to maintain the effective status of the lock.

[0106] Wherein, when it is determined that the target service node of the server is occupied and locked, the client cannot collect data of the target service node from the server.

[0107] Step S750, cancel collecting data of the target service node, and return to step S700.

[0108] Specifically, when the attempt to lock the target service node fails, the client will cancel the data collection operation on the current service node and return to step S700, that is, re-acquire the distributed lock configuration table and wait for the next attempt.

[0109] In this embodiment, the distributed lock mechanism can effectively prevent multiple clients from accessing the same service node at the same time, avoid data conflicts and inconsistencies, ensure the accuracy and security of data collection, and is suitable for scenarios with concurrent access by multiple clients, such as online trading systems, social networks, etc. When multiple clients try to access the same resource at the same time, the distributed lock can ensure that only one client obtains the lock and performs operations, and other clients need to wait for the lock to be released to avoid resource competition. During the data collection process, if the client updates the data at the same time, data inconsistency or loss may occur. Distributed locks can prevent this from happening and ensure the correctness and integrity of the data. When the client holding the lock fails, other clients can detect that the lock holder has failed, thereby trying to obtain the lock and continue the data collection task to ensure the high availability of the system. The distributed lock configuration table strategy enhances the reliability of the OPC UA client during the data collection process, ensuring that data collection can still be carried out stably even in the case of network fluctuations or server failures. In summary, the use of a distributed lock mechanism can significantly improve the stability and reliability of data collection.

[0110] In one embodiment, Figure 8 As shown, in step S720, when it is determined that the target service node of the server is not occupied and locked, the client collects data from the target service node and updates the distributed lock configuration table. Afterwards, the data collection method also includes: steps S800-S820. Among them:

[0111] Step S800, detecting whether the connection status between the client and the server is normal. If the connection status is normal, executing step S810. If the connection status is abnormal, executing step S820.

[0112] Specifically, the client will periodically (for example, every minute) detect the connection status between it and the OPC UA server, so as to timely determine whether the connection status is normal.

[0113] Step S810, determining whether the duration of the client collecting data from the target service node exceeds the preset duration according to the distributed lock configuration table. If the duration of the client collecting data from the target service node exceeds the preset duration, executing step S820. If the duration of the client collecting data from the target service node does not exceed the preset duration, returning to executing step S800.

[0114] Specifically, when the client establishes a connection with a specific server and obtains data, it will determine whether the duration of data collection exceeds the preset threshold based on the information in the distributed lock configuration table. The preset duration is a time limit set to prevent the client from occupying server resources for a long time, causing other clients to be unable to collect data. When the client successfully obtains the distributed lock and starts collecting data from the target service node, a start time is recorded. While collecting data, the client will periodically check whether the difference between the current time and the start time exceeds the preset duration. If the duration of data collection exceeds the preset duration, the client will actively disconnect from the target service node, update the distributed lock configuration table, release the lock resources, and indicate that the target service node is not occupied and locked.

[0115] Step S820: disconnect the client from the target service node and update the distributed lock configuration table.

[0116] Among them, the updated distributed lock configuration table indicates that the target service node is not occupied and locked.

[0117] Specifically, if the connection status is abnormal, it means that there is a network problem or other communication failure between the client and the server. At this time, the client will disconnect from the target service node and update the distributed lock configuration table to release the lock resources so that other clients can try to connect and collect data.

[0118] Specifically, after the client detects an anomaly, it immediately disconnects from the server to avoid unnecessary data transmission. In the lock configuration table, the "holder" field of the lock is cleared, and the "expiration time" of the lock is set to the current time, indicating that the lock has been released and the target service node is in an unlocked state. Update or add a log in the fault point log record to record the details of this connection anomaly, including time, client ID, server ID and other information, to facilitate subsequent problem analysis and tracking.

[0119] In this embodiment, by detecting the connection status and setting the data collection duration, it is possible to effectively avoid the waste of resources and data collection delay caused by the client occupying the service node for a long time, thereby improving the overall performance and user experience of the system. Even if a single client or server fails, other clients can quickly take over the data collection task to reduce data loss and collection interruption. Through the mechanism of distributed locks and preset durations, it is possible to avoid occupying server resources for a long time, thereby improving the overall data collection efficiency and stability of the system. The client can automatically detect and handle connection anomalies without manual intervention, thereby enhancing the system's automatic recovery capability and fault tolerance.

[0120] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.

[0121] In this embodiment, a data collection device is also provided, and the data collection device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0122] Fig. 9 1 is a structural block diagram of an optional data collection device according to an embodiment of the present application. Fig. 9 As shown, including:

[0123] The information acquisition module 901 is used to acquire a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the server corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the server.

[0124] The mapping establishment module 902 is used to establish a mapping relationship between the client and the service node and the server according to the service node table.

[0125] The strategy determination module 903 is used to determine the target strategy for collecting data from the server according to the configuration information table of the target service node, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy.

[0126] The data collection module 904 is used to collect the data of the target service node from the server end according to the mapping relationship and using the target strategy.

[0127] Through the above-mentioned device, the service node table and configuration information table of multiple service nodes are first obtained. Then, according to the service node table, a mapping relationship between the client and the service node and the server is established, and according to the configuration information table of the target service node, the target strategy for collecting data from the server is determined. According to the mapping relationship, the target strategy is adopted to collect the data of the target service node from the server. The client can flexibly select the data collection method according to the target strategy in the configuration information table. It can subscribe to data in real time to improve the real-time nature of the collected data, or pull data on demand to save resources, or combine real-time subscription to data and on-demand pulling of data to improve the real-time nature and flexibility of data collection. By combining subscription and pulling, the integrity and high reliability of the data can be ensured even in the case of network instability or server failure.

[0128] In an exemplary embodiment, the data acquisition module 904 further includes:

[0129] The first data collection unit is used to determine the address of the server corresponding to the target service node according to the mapping relationship when the target policy is a subscription policy, and subscribe to the data of the address of the server corresponding to the target service node, so as to collect data from the server and obtain data changes from the server in real time.

[0130] The second data collection unit is used to determine the address of the server corresponding to the target service node according to the mapping relationship when the target strategy is a pull strategy, and to pull the data of the address of the server corresponding to the target service node at a preset time interval.

[0131] The third data collection unit is used to determine the address of the server corresponding to the target service node according to the mapping relationship when the target strategy is a subscription and pull strategy, and subscribe to the data of the address of the server corresponding to the target service node, and pull the data of the address of the server corresponding to the target service node at a preset time interval.

[0132] In an exemplary embodiment, the above device further includes:

[0133] The comparison module is used to compare the first data of the target service node collected by the subscription strategy with the second data of the target service node collected by the pull strategy.

[0134] The updating module is used to update the data of the target service node to the second data when the first data and the second data are inconsistent.

[0135] In an exemplary embodiment, the above device further includes:

[0136] The change status acquisition module is used to acquire the change status of multiple service nodes in real time.

[0137] The first processing module is used to collect data of the newly added service node from the server according to the service node table and the configuration information table of the newly added service node when it is determined that there is a newly added service node.

[0138] The second processing module is used to stop collecting data of the deleted service node from the server when it is determined that the service node is deleted.

[0139] The third processing module is used to collect data of the service node from the server according to the modified configuration information table when it is determined that the configuration information table of the service node is modified.

[0140] The fourth processing module is used to stop collecting data of the service node whose configuration information table is deleted from the server when it is determined that the configuration information table of the service node is deleted.

[0141] In an exemplary embodiment, the above device further includes:

[0142] The distributed lock configuration table acquisition module is used to obtain the distributed lock configuration table when the client accesses the server.

[0143] The lock judgment module is used to determine whether the target service node of the server is occupied and locked according to the distributed lock configuration table.

[0144] The locking module is used for the client to apply for locking the target service node when it is determined that the target service node of the server is not occupied and locked.

[0145] The lock update module is used to collect data from the target service node and update the distributed lock configuration table when the client successfully locks the target service node.

[0146] Among them, the updated distributed lock configuration table indicates that the target service node has been occupied and locked.

[0147] Wherein, when it is determined that the target service node of the server is occupied and locked, the client cannot collect data of the target service node from the server.

[0148] In an exemplary embodiment, the above device further includes:

[0149] The status detection module is used to detect the connection status between the client and the server.

[0150] The duration judgment module is used to determine whether the duration for the client to collect data from the target service node exceeds a preset duration according to the distributed lock configuration table when the connection status is normal.

[0151] The first cancellation module is used to disconnect the client from the target service node and update the distributed lock configuration table when the time for the client to collect data from the target service node exceeds a preset time, wherein the updated distributed lock configuration table indicates that the target service node is not occupied and locked.

[0152] The second cancellation module is used to disconnect the client from the target service node when the connection state is abnormal, and update the distributed lock configuration table, wherein the updated distributed lock configuration table indicates that the target service node is not occupied and locked.

[0153] An embodiment of the present application further provides a storage medium, which includes a stored program, wherein the program executes any of the above methods when it is run.

[0154] Optionally, in this embodiment, the storage medium may be configured to store program codes for executing the following steps:

[0155] S1, obtaining a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the server corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the server.

[0156] S2: According to the service node table, a mapping relationship between the client and the service node and the server is established.

[0157] S3, determining a target strategy for collecting data from the server according to the configuration information table of the target service node, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy.

[0158] S4, according to the mapping relationship, adopt the target strategy to collect the data of the target service node from the server.

[0159] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0160] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0161] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0162] S1, obtaining a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the server corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the server.

[0163] S2: According to the service node table, a mapping relationship between the client and the service node and the server is established.

[0164] S3, determining a target strategy for collecting data from the server according to the configuration information table of the target service node, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy.

[0165] S4, according to the mapping relationship, adopt the target strategy to collect the data of the target service node from the server.

[0166] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0167] An embodiment of the present application further provides a computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores the computer program product, and when the computer program is executed by a processor, the steps of the method in each embodiment of the present application are implemented.

[0168] Optionally, in this embodiment, the above computer program may be configured to implement the following steps when executed by a processor:

[0169] S1, obtaining a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the server corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the server.

[0170] S2: According to the service node table, a mapping relationship between the client and the service node and the server is established.

[0171] S3, determining a target strategy for collecting data from the server according to the configuration information table of the target service node, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy.

[0172] S4, according to the mapping relationship, adopt the target strategy to collect the data of the target service node from the server.

[0173] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0174] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0175] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data collection method, characterized in that: Applied to a client, the method comprises: Acquire a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the service end corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the service end; According to the service node table, a mapping relationship between the client and the service node and the server is established; Determine a target strategy for collecting data from the server according to the configuration information table of the target service node, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy; According to the mapping relationship, the target strategy is adopted to collect data of the target service node from the server.

2. The method according to claim 1, characterized in that: The step of collecting data of the target service node from the server using the target strategy according to the mapping relationship includes: In the case where the target policy is a subscription policy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and the data of the address of the server corresponding to the target service node is subscribed to collect data from the server and obtain the change of the data from the server in real time; In the case where the target strategy is a pull strategy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and data of the address of the server corresponding to the target service node is pulled at a preset time interval; When the target strategy is a subscription and pull strategy, the address of the server corresponding to the target service node is determined according to the mapping relationship, and the data of the address of the server corresponding to the target service node is subscribed to, and the data of the address of the server corresponding to the target service node is pulled at a preset time interval.

3. The method according to claim 2, characterized in that After the steps of determining the address of the server corresponding to the target service node according to the mapping relationship, subscribing to the data of the address of the server corresponding to the target service node, and pulling the data of the address of the server corresponding to the target service node at a preset interval, the method further includes: Compare the first data of the target service node collected by the subscription strategy with the second data of the target service node collected by the pull strategy; When the first data and the second data are inconsistent, the data of the target service node is updated to the second data.

4. The method according to claim 1, characterized in that The method further comprises: Obtaining changes in the multiple service nodes in real time; When it is determined that there is a newly added service node, data of the newly added service node is collected from the server according to a service node table and a configuration information table of the newly added service node; When it is determined that the service node is deleted, stop collecting data of the deleted service node from the server; When it is determined that the configuration information table of the service node is modified, collecting data of the service node from the server according to the modified configuration information table; When it is determined that the configuration information table of the service node is deleted, the data of the service node whose configuration information table is deleted is stopped from being collected from the server.

5. The method according to claim 1, characterized in that The method further comprises: When the client accesses the server, a distributed lock configuration table is obtained; Determine, according to the distributed lock configuration table, whether the target service node of the server is occupied and locked; When it is determined that the target service node of the server is not occupied and locked, the client applies to lock the target service node; When the client successfully locks the target service node, the client collects data from the target service node and updates the distributed lock configuration table. Wherein, the updated distributed lock configuration table indicates that the target service node has been occupied and locked; Wherein, when it is determined that the target service node of the server is occupied and locked, the client cannot collect data of the target service node from the server.

6. The method according to claim 5, characterized in that When the client successfully locks the target service node, after the client collects data from the target service node and updates the distributed lock configuration table, the method further includes: Detecting the connection status between the client and the server; When the connection state is normal, determining whether the duration for the client to collect data from the target service node exceeds a preset duration according to the distributed lock configuration table; When the duration for which the client collects data from the target service node exceeds a preset duration, disconnecting the client from the target service node and updating the distributed lock configuration table, wherein the updated distributed lock configuration table indicates that the target service node is not occupied and locked; In the case where the connection state is abnormal, the connection between the client and the target service node is disconnected, and the distributed lock configuration table is updated, wherein the updated distributed lock configuration table indicates that the target service node is not occupied and locked.

7. A data collection device, characterized in that: The device comprises: An information acquisition module, used to acquire a service node table and a configuration information table of multiple service nodes, wherein the service node table is used to indicate the address of the service end corresponding to the service node, and the configuration information table is used to indicate the strategy of the service node to obtain data from the service end; A mapping establishment module, used to establish a mapping relationship between the client and the service node and the server according to the service node table; A strategy determination module, used to determine a target strategy for collecting data from the server according to a configuration information table of a target service node, wherein the target strategy includes one of a subscription strategy, a pull strategy, and a subscription and pull strategy; The data collection module is used to collect the data of the target service node from the server end according to the mapping relationship and using the target strategy.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 6 when executed.

9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 through the computer program.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.