An OpcUA-based real-time data acquisition method and device and medium
By leveraging the OpcUA subscription and publish mechanism and time-series database data aggregation, the problems of complex system architecture and unoptimized resources in existing technologies are solved, enabling efficient real-time collection and transmission of large amounts of data in bare metal, private cloud, and edge cloud environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNITED NETWORK COMM GRP CO LTD
- Filing Date
- 2024-08-16
- Publication Date
- 2026-06-12
Smart Images

Figure CN119031276B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a real-time data acquisition method, device and medium based on OpcUA. Background Technology
[0002] With the continuous development of industrial information technology, more and more enterprises are transforming into digital smart factories. However, in actual production, various devices use different protocols, and the interconnection of these devices involves heterogeneous networks, integration of multiple generations of devices, and data fusion issues. Therefore, the OPC Foundation launched the OpcUA (Open Platform Communications Unified Architecture) communication specification.
[0003] As a vendor-independent, open, and standard technology, the OpcUA specification provides a good solution to the heterogeneity and information silo problems between software and hardware. It enables devices with different protocols to uniformly convert data formats into the OpcUA data format for communication, and through the subscription and publication mechanism of the OpcUA specification, device data can be transmitted to the subscriber in real time.
[0004] However, real-time collection of data from underlying equipment sensors to production, processes, and energy consumption leads to a surge in the amount of data collected and transmitted. Therefore, how to collect and transmit large amounts of data in a unified and efficient manner has become an urgent technical problem to be solved. Summary of the Invention
[0005] The technical problem to be solved by this application is to address the above-mentioned shortcomings of the prior art by providing a real-time data acquisition method, device and medium based on OpcUA to solve the problems existing in the prior art.
[0006] Firstly, this application provides a real-time data acquisition method based on OpcUA, applied to a server OpcUAServer, the method comprising:
[0007] S1. Generate a list of OpcUA Servers based on the pre-set OpcUA Server information;
[0008] S2. Establish an OpcUA communication connection with the OpcUA acquisition node based on the list information, and obtain device tag information from the OpcUA acquisition node;
[0009] S3. Create a super table and sub-tables for the time-series database based on the device tag information;
[0010] S4. Based on the device tag information, classify and group the device tags, and send data collection tasks to the OpcUA collection nodes in groups.
[0011] S5. After receiving the real-time data sent by the OpcUA acquisition node, save the real-time data to the super table and sub-table of the time series database.
[0012] In some embodiments, at least one of the following is included:
[0013] The list information includes at least one of the following: URL address, username, password, SSL certificate, request timeout, service name, and publication cycle;
[0014] The device tag information includes at least one of the following: tag name, tag annotation, tag group, namespace, NodeID, NodePath, data type of collection point, data address of collection point, and scanning rate of collection point.
[0015] In some embodiments, S3 includes:
[0016] S31. Traverse the data types of the collection points and mark the numeric types that need to be converted. The data types of the collection points include at least one of integer, boolean, floating-point, and string types.
[0017] S32. Create a corresponding supertable for each numeric type;
[0018] S33. Based on the numerical type of the device tag and the super table of the corresponding numerical type, create a corresponding sub-table for each device tag.
[0019] In some embodiments, S33 involves creating a corresponding sub-table for each device tag, including:
[0020] Determine if the number of device tags exceeds a preset threshold;
[0021] If so, then create a thread pool and create the sub-table in parallel in a multi-threaded environment;
[0022] If not, the sub-table is created serially in a single-threaded environment.
[0023] In some embodiments, at least one of the following is included:
[0024] The table name of the supertable corresponds to the numeric type.
[0025] The fields of the super table include timestamps and their corresponding numeric types;
[0026] The label column of the super table includes device label name, label annotation, label group, data collection point address, NodeID, and NodePath;
[0027] The surface of the sub-table is a combination of label groups and label names;
[0028] The tag column of the sub-table inherits from the supertable and consists of the corresponding attribute values of the device tag.
[0029] In some embodiments, S4, classifying and grouping device tags according to the device tag information includes:
[0030] S41. Determine the transmission weight of each data stream corresponding to each device tag based on the device tag information;
[0031] S42. Determine the total transmission weight corresponding to each device tag based on the transmission weight of each data stream corresponding to each device tag;
[0032] S43. Classify and group device tags according to the total transmission weight corresponding to each device tag.
[0033] In some embodiments, S41, the data stream transmission weight of each device tag is calculated according to the following formula:
[0034] QZ = CON × FAC ÷ RATE
[0035] Where QZ is the data stream transmission weight, CON is a constant, FAC is the numerical type coefficient, and RATE is the scanning rate of the acquisition point.
[0036] In some embodiments, S43 includes:
[0037] S43a. Sort the M device labels in descending order of total transmission weight to obtain a dataset in descending order, where M is an integer greater than or equal to 1.
[0038] S43b. Divide the first N device labels in the dataset into N groups in sequence, where each group contains one device label, N is an integer greater than or equal to 1, and M is greater than or equal to N;
[0039] S43c, The (N+i)th device tag in the dataset is summed with the transmission weights of the existing device tags in the N groups in turn, the target group with the smallest sum is determined, and the (N+i)th device tag is assigned to the target group, where i is an integer greater than or equal to 1;
[0040] S43d, Increment the value of i by one, and return to the step of summing the transmission weights of the (N+i)th device tag in the dataset with the existing device tags in the N groups, until all device tags have been grouped.
[0041] In some embodiments, S5 includes:
[0042] After receiving real-time data sent by the OpcUA acquisition node, the real-time data is cached to the corresponding classification group according to the device tag and classification group information;
[0043] Once the amount of data in the categorized group cache reaches a preset threshold, the real-time data is written into the super table and sub-tables of the time-series database.
[0044] Secondly, this application provides a real-time data acquisition device based on OpcUA, applied to a server OpcUAServer, the device comprising:
[0045] The list generation module is configured to generate a list of OpcUAServer information based on pre-set OpcUAServer information.
[0046] The device tag acquisition module is configured to establish an OpcUA communication connection with the OpcUA acquisition node based on the list information, and acquire device tag information from the OpcUA acquisition node.
[0047] The database creation module is configured to create a super table and sub-tables of a time-series database based on the device tag information;
[0048] The classification and grouping module is configured to classify and group device tags according to the device tag information, and send data collection tasks to the OpcUA collection node in units of groups.
[0049] The data storage module is configured to save the real-time data sent by the OpcUA acquisition node to the super table and sub-table of the time series database after receiving the real-time data.
[0050] Thirdly, this application provides a real-time data acquisition device based on OpcUA, including a memory and a processor. The memory stores a computer program, and the processor is configured to run the computer program to implement the real-time data acquisition method based on OpcUA described in the first aspect.
[0051] Fourthly, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the real-time data acquisition method based on OpcUA described in the first aspect.
[0052] This application provides a real-time data acquisition method, apparatus, and readable storage medium based on OpcUA. Specifically, it generates a list of OpcUA Servers based on pre-set OpcUA Server information; establishes an OpcUA communication connection with the OpcUA acquisition node based on the list information and obtains device tag information from the OpcUA acquisition node; creates a super table and sub-tables of a time-series database based on the device tag information; categorizes and groups device tags based on the device tag information, and sends data acquisition tasks to the OpcUA acquisition node in groups; after receiving real-time data sent by the OpcUA acquisition node, saves the real-time data to the super table and sub-tables of the time-series database. This application provides an efficient real-time data acquisition method based on the OpcUA subscription and publish mechanism. First, it balances and optimizes the transmission of real-time data streams for subscription and publication based on the number, type, and attributes of device tags at the acquisition point. Second, it greatly reduces the transmission of related data information while maintaining high write and relational query performance by leveraging the data aggregation mechanism of the time-series database super table and sub-tables. Finally, through software architecture optimization, it can uniformly and efficiently achieve real-time acquisition and transmission of large amounts of data. Attached Figure Description
[0053] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0054] Figure 1 This is a diagram of the existing OpcUA data acquisition and transmission system architecture.
[0055] Figure 2 This is a diagram illustrating the architecture of the OpcUA data acquisition and transmission system provided in an embodiment of this application.
[0056] Figure 3 A flowchart illustrating a real-time data acquisition method based on OpcUA, provided for an embodiment of this application;
[0057] Figure 4 A schematic diagram illustrating the super table and sub-tables for creating a time-series database, provided in an embodiment of this application;
[0058] Figure 5 A schematic diagram of the structure of a real-time data acquisition device based on OpcUA provided in an embodiment of this application;
[0059] Figure 6 This is a schematic diagram of another real-time data acquisition device based on OpcUA provided in an embodiment of this application.
[0060] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0061] To enable those skilled in the art to better understand the technical solution of this application, the embodiments of this application will be further described in detail below with reference to the accompanying drawings.
[0062] It is understood that the specific embodiments and accompanying drawings described herein are merely for explaining this application and are not intended to limit this application.
[0063] It is understood that, without conflict, the various embodiments and features in the embodiments of this application can be combined with each other.
[0064] It is understood that, for ease of description, only the parts relevant to this application are shown in the accompanying drawings, while parts unrelated to this application are not shown in the drawings.
[0065] It is understood that each unit or module involved in the embodiments of this application may correspond to only one entity structure, or may be composed of multiple entity structures, or multiple units or modules may be integrated into one entity structure.
[0066] It is understood that the terms "first," "second," etc., used in the embodiments of this application are used to distinguish different objects or to distinguish different treatments of the same object, rather than to describe a specific order of objects.
[0067] It is understood that, without conflict, the functions and steps marked in the flowcharts and block diagrams of this application may occur in a different order than those marked in the accompanying drawings.
[0068] It is understood that the flowcharts and block diagrams of this application illustrate the possible architecture, functions, and operations of systems, apparatuses, devices, and methods according to various embodiments of this application. Each block in a flowchart or block diagram may represent a unit, module, program segment, or code, containing executable instructions for implementing the specified function. Furthermore, each block or combination of blocks in the block diagrams and flowcharts may be implemented using a hardware-based system to implement the specified function, or using a combination of hardware and computer instructions.
[0069] It is understood that the units and modules involved in the embodiments of this application can be implemented by software or by hardware. For example, the units and modules can be located in the processor.
[0070] Figure 1The following is a diagram of the existing OpcUA data acquisition and transmission system architecture, such as... Figure 1 As shown, the data acquisition network consists of OPCUA acquisition nodes, TSN switches, and a network management server, wherein:
[0071] (1) OPCUA data acquisition node, using OPCUA tag data to determine the real-time requirements of different data for different nodes;
[0072] (2) Each port of the TSN switch uses a queue with different priorities to control the data passing through the port, thereby realizing the management and control of the data flow;
[0073] (3) The network management server reads each tag in the OPCUA to obtain the size of the data volume of different nodes and the real-time requirements of different data, and designs corresponding optimization methods to meet the real-time requirements of the data flow of each node, avoid the situation where the real-time requirements cannot be met due to data congestion, and at the same time ensure the network bandwidth.
[0074] Currently, the basic principle of data acquisition and transmission based on the OpcUA specification is as follows: First, determine the number, type, and real-time requirements of OpcUA tags (collection points) in a single node. This determines the data volume of a single node and the bandwidth requirements of each node in the data acquisition system. Data flow optimization is then performed through a network management server, and finally, data flow control is achieved through a TSN switch. In summary, existing technologies, based on the number, type, and attribute information of device tags in the OpcUA Server, optimize data flow through a network management server and a TSN switch, thereby effectively improving the real-time performance of data flow in the data acquisition system.
[0075] However, existing technologies have the following drawbacks:
[0076] First, it requires the use of network management servers and TSN switches for data flow control, resulting in a complex system architecture that cannot form a unified solution applicable to environments such as bare metal, private cloud, and edge cloud.
[0077] Second, with the improvement of cloud network technology and performance, communication bandwidth is no longer the main bottleneck, and innovative technologies such as compression, transmission and storage of time-series real-time data have not been fully utilized to further optimize resource consumption.
[0078] In view of the shortcomings of the prior art, this application provides an efficient real-time data acquisition method and system based on the OpcUA subscription and publish mechanism, which can realize the server's data acquisition and storage of multiple acquisition nodes in a network architecture without the need for a TSN switch.
[0079] The main concept of this invention is as follows:
[0080] This application provides a method and system for efficient real-time data acquisition based on the OpcUA subscription and publish mechanism. First, based on the number, type, and attributes of the device tags at the collection points, the real-time data stream transmission of subscription and publication is optimized in a balanced manner. Second, by leveraging the data aggregation mechanism of the super table and sub-tables of the time-series database, the transmission of related data information is greatly reduced while maintaining high write and relational query performance. Finally, through the optimization and adjustment of the software architecture, the real-time acquisition and transmission of large amounts of data can be achieved in a unified and efficient manner.
[0081] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0082] This application provides a real-time data acquisition method based on OPCUA. The processing flow of this method can be implemented by electronic devices, such as computers, handheld smart terminals, etc. For ease of explanation, the embodiments of this application are described with the computer as the execution subject.
[0083] Figure 2 The architecture diagram of the OpcUA data acquisition and transmission system provided in the embodiments of this application is as follows: Figure 2 As shown, the data acquisition network consists of OPCUA acquisition nodes and an OpcUA server for network management. Compared with existing methods, this application does not require the setting of a TSN switch, thus greatly simplifying the system architecture and enabling the technical solution to be applied to special environments such as bare metal, private cloud, and edge cloud.
[0084] Figure 3 A schematic diagram of the real-time data acquisition method based on OPCUA provided in the embodiments of this application is shown below. Figure 3 As shown, this application provides a real-time data acquisition method based on OpcUA, applied to the OpcUA Server. The method includes S1-S5, as follows:
[0085] S1. Generate a list of OpcUA Servers based on the pre-set OpcUA Server information;
[0086] Specifically, users can configure the information of the OpcUA Servers to be connected in the OpcUA Server, which will then be used by the OpcUA Server to generate a list of OpcUA Servers.
[0087] Optionally, the list information includes at least one of the following: URL address, username, password, SSL certificate, request timeout, service name, and publishing cycle;
[0088] S2. Establish an OpcUA communication connection with the OpcUA acquisition node based on the list information, and obtain device tag information from the OpcUA acquisition node;
[0089] Specifically, based on the list information and the OpcUA communication protocol, the OpcUA Server establishes connections with each OpcUA acquisition node in sequence and obtains all device tag information from the OpcUA acquisition nodes.
[0090] Optionally, the device tag information includes at least one of the following: tag name, tag annotation, tag group, namespace, NodeID, NodePath, data type of collection point, data address of collection point, and scanning rate of collection point.
[0091] S3. Create a super table and sub-tables for the time-series database based on the device tag information;
[0092] Specifically, the OpcUA Server creates a super table and sub-tables for the time-series database based on the full set of device tag information. The super table and sub-tables are a data aggregation mechanism provided by the time-series database for the same type of collection points, which can greatly reduce the amount of data transmission and improve the performance of data insertion and query.
[0093] Figure 4 This is a schematic diagram illustrating the super table and sub-tables for creating a time-series database, as provided in an embodiment of this application. Figure 4 As shown, in some embodiments, S3 includes:
[0094] S31. Traverse the data types of the collection points and mark the numeric types that need to be converted. The data types of the collection points include at least one of integer, boolean, floating-point, and string types.
[0095] S32. Create a corresponding supertable for each numeric type;
[0096] Optionally, the table name of the super table is the corresponding numeric type, and the field columns of the super table include timestamps and corresponding numeric types; the tag columns of the super table include device tag name, tag annotation, tag group, data collection point address, NodeID, and NodePath;
[0097] S33. Based on the numerical type of the device tag and the super table of the corresponding numerical type, create a corresponding sub-table for each device tag.
[0098] Optionally, the surface of the sub-table is a combination of tag groups and tag names; the tag columns of the sub-table, which are inherited from the super-table, are the corresponding attribute values of the device tags.
[0099] Specifically, based on the numerical type of the device tag and the super table corresponding to the numerical type, a sub-table is created for each device tag. The combination of tag group and tag name is used as the sub-table name. The tag column inherited from the super table in the sub-table is specified as the corresponding attribute value of the device tag. After that, only the tag group, tag name, timestamp, and tag value information are needed to complete the real-time data storage, thereby greatly reducing the data traffic of data transmission and database write.
[0100] In some embodiments, S33, creating a corresponding sub-table for each device tag includes: determining whether the number of device tags is greater than a preset threshold; if so, creating a thread pool and creating the sub-table in parallel in a multi-threaded environment; if not, creating the sub-table serially in a single-threaded environment.
[0101] Specifically, if the number of device tags is large, such as hundreds of thousands, hundreds of thousands of sub-tables need to be created, which will take a long time. A thread pool can be created to execute the sub-table creation steps in parallel.
[0102] S4. Based on the device tag information, classify and group the device tags, and send data collection tasks to the OpcUA collection nodes in groups.
[0103] Specifically, the OpcUA Server uses a grouping strategy to classify and group device tags based on the full set of device tag information. The grouping strategy mainly uses tag grouping, data type of collection point, and collection point scanning rate as parameters to balance the real-time data stream transmission pressure of each group.
[0104] In some embodiments, S4, classifying and grouping device tags according to the device tag information includes:
[0105] S41. Determine the transmission weight of each data stream corresponding to each device tag based on the device tag information;
[0106] In some embodiments, S41, the data stream transmission weight of each device tag is calculated according to the following formula:
[0107] QZ = CON × FAC ÷ RATE
[0108] Where QZ is the data stream transmission weight, CON is a constant with a possible value of 1000 milliseconds, FAC is the numeric type coefficient with possible values of 1.12 for Boolean numeric types, 1.16 for integer numeric types, 1.2 for floating-point numeric types, and 1.3 for string numeric types, and RATE is the sampling point scanning rate in milliseconds.
[0109] S42. Determine the total transmission weight corresponding to each device tag based on the transmission weight of each data stream corresponding to each device tag;
[0110] S43. Classify and group device tags according to the total transmission weight corresponding to each device tag.
[0111] In some embodiments, S43 includes:
[0112] S43a. Sort the M device labels in descending order of total transmission weight to obtain a dataset in descending order, where M is an integer greater than or equal to 1.
[0113] S43b. Divide the first N device labels in the dataset into N groups in sequence, where each group contains one device label, N is an integer greater than or equal to 1, and M is greater than or equal to N;
[0114] S43c, The (N+i)th device tag in the dataset is summed with the transmission weights of the existing device tags in the N groups in turn, the target group with the smallest sum is determined, and the (N+i)th device tag is assigned to the target group, where i is an integer greater than or equal to 1;
[0115] S43d, Increment the value of i by one, and return to the step of summing the transmission weights of the (N+i)th device tag in the dataset with the existing device tags in the N groups, until all device tags have been grouped.
[0116] Specifically, the M device labels to be processed are first sorted, and a sorted dataset is generated in descending order of total transmission weight, denoted as [D1,D2,...,DM], where D1 is the largest data and DM is the smallest data.
[0117] Then, the sorted dataset D is divided into N groups according to the following rules:
[0118] (1) Set N groups, denoted as [G1, G2, ..., GN], where N is the empirical value of the total number of device tags. For example, the total number of device tags takes the value of 5 in the range of (0, 1000], and the value of 10 in the range of (1000, 10000], etc.
[0119] The largest element D1 in the dataset is assigned to group G1, the second largest element D2 is assigned to group G2, and so on, until the Nth largest element DN is assigned to group GN.
[0120] (2) For subsequent data, grouping starts from the (N+1)th largest data DA (A = N+1):
[0121] For each existing group Gi (i = 1, 2, ..., N), calculate the sum of DA and all elements in Gi to obtain the sum Sij, where Sij is the sum of the i-th group.
[0122] Determine the group with the smallest sum, i.e., min(S1A,S2A,...,SNA), and then divide the data DA into the group with the smallest sum Sij.
[0123] Repeat the above steps until all M data points have been assigned to their respective groups.
[0124] S5. After receiving the real-time data sent by the OpcUA acquisition node, save the real-time data to the super table and sub-table of the time series database.
[0125] In some embodiments, S5 includes: after receiving real-time data sent by the OpcUA acquisition node, caching the real-time data to the corresponding classification group according to the device tag and classification grouping information; when the amount of data cached in the classification group reaches a preset threshold, writing the real-time data into the super table and sub-table of the time series database.
[0126] Specifically, in parallel tasks, the OpcUA Server establishes connections with associated OpcUA acquisition nodes based on the OpcUA Server list information, enabling each parallel task to establish an independent subscription and publish communication channel with the OpcUA acquisition nodes. The OpcUA Server subscribes to the device tag data under the group from the OpcUA acquisition nodes and waits for the OpcUA acquisition nodes to transmit data asynchronously. The OpcUA acquisition nodes periodically send the device tag data to the subscription OpcUA Server according to the publishing cycle. The device tag data includes NodeID, NodePath, timestamp, and tag value. The OpcUA Server can associate the device tag and its classification group information through NodeID and NodePath, and cache the real-time data under the classification group until the cache reaches the set threshold, triggering the batch writing of data to the super table and sub-table of the time-series database.
[0127] This application provides an efficient real-time data acquisition method based on the OpcUA subscription and publish mechanism. First, based on the number, type, and attributes of the device tags at the collection points, the real-time data stream transmission of subscription and publication is optimized in a balanced manner. Second, by leveraging the data aggregation mechanism of the super table and sub-tables of the time-series database, the transmission of related data information is greatly reduced while maintaining high write and relational query performance. Finally, through the optimization and adjustment of the software architecture, the real-time acquisition and transmission of large amounts of data can be achieved in a unified and efficient manner.
[0128] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0129] Figure 5 A schematic diagram of a real-time data acquisition device based on OPCUA provided in an embodiment of this application is shown below. Figure 5 As shown, this application provides 10. A real-time data acquisition device based on OpcUA, applied to an OpcUA Server, the device comprising:
[0130] The list generation module 11 is configured to generate a list of OpcUAServer information based on the preset OpcUAServer information.
[0131] The device tag acquisition module 12 is configured to establish an OpcUA communication connection with the OpcUA acquisition node based on the list information, and acquire device tag information from the OpcUA acquisition node.
[0132] The database creation module 13 is configured to create a super table and sub-tables of a time-series database based on the device tag information;
[0133] The classification and grouping module 14 is configured to classify and group device tags according to the device tag information, and send data collection tasks to the OpcUA collection node in units of groups.
[0134] The data storage module 15 is configured to save the real-time data sent by the OpcUA acquisition node to the super table and sub-table of the time series database after receiving the real-time data.
[0135] Regarding the limitations on the OPCUA-based real-time data acquisition device, please refer to the limitations on the OPCUA-based real-time data acquisition method in the above embodiments of this application, which will not be repeated here.
[0136] Figure 6 Another schematic diagram of the OPCUA-based real-time data acquisition device provided in the embodiments of this application is shown below. Figure 6 As shown, in some embodiments, this application provides a real-time data acquisition device based on OPCUA, including a memory 22 and a processor 21. The memory stores a computer program, and the processor is configured to run the computer program to execute the real-time data acquisition method based on OPCUA in the above embodiments of this application.
[0137] The memory is connected to the processor. The memory can be flash memory, read-only memory or other types of memory. The processor can be a central processing unit or a microcontroller.
[0138] In some embodiments, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the OpcUA-based real-time data acquisition method in the above embodiments of this application.
[0139] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules, or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other memory technologies, CD-ROM (Compact Disc Read-Only Memory), DVD or other optical disc storage, cartridges, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer.
[0140] It is understood that the above embodiments are merely exemplary implementations used to illustrate the principles of this application, and this application is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and substance of this application, and these modifications and improvements are also considered to be within the scope of protection of this application.
Claims
1. A real-time data acquisition method based on OpcUA, characterized in that, Applied to the OpcUA Server, the method includes: S1. Generate a list of OpcUA Servers based on the pre-set OpcUA Server information; S2. Establish an OpcUA communication connection with the OpcUA acquisition node based on the list information, and obtain device tag information from the OpcUA acquisition node; S3. Create a super table and sub-tables for the time-series database based on the device tag information; S4. Based on the device tag information, classify and group the device tags, and send data collection tasks to the OpcUA collection nodes in groups. S5. After receiving the real-time data sent by the OpcUA acquisition node, save the real-time data to the super table and sub-table of the time series database. S3 includes: S31. Traverse the data types of the collection points and mark the numeric types that need to be converted. The data types of the collection points include at least one of integer, boolean, floating-point, and string types. S32. Create a corresponding supertable for each numeric type; S33. Based on the numerical data type corresponding to the device tag and the super table of the corresponding numerical data type, create a corresponding sub-table for each device tag; In step S4, the device tags are categorized and grouped according to the device tag information, including: S41. Determine the transmission weight of each data stream corresponding to each device tag based on the device tag information; S42. Determine the total transmission weight corresponding to each device tag based on the transmission weight of each data stream corresponding to each device tag; S43. Classify and group device tags according to the total transmission weight corresponding to each device tag; In S41, the data stream transmission weight for each device tag is calculated according to the following formula: QZ=CON×FAC÷RATE Where QZ is the data stream transmission weight, CON is a constant with a value of 1000 milliseconds; FAC is the numeric type coefficient, with specific values of 1.12 for Boolean numeric types, 1.16 for integer numeric types, 1.2 for floating-point numeric types, and 1.3 for string numeric types; RATE is the sampling point scanning rate, in milliseconds. S43 includes: S43a. Sort the M device labels in descending order of total transmission weight to obtain a dataset in descending order, where M is an integer greater than or equal to 1. S43b. Divide the first N device labels in the dataset into N groups in sequence, where each group contains one device label, N is an integer greater than or equal to 1, and M is greater than or equal to N; S43c, The (N+i)th device tag in the dataset is summed with the transmission weights of the existing device tags in the N groups in turn, the target group with the smallest sum is determined, and the (N+i)th device tag is assigned to the target group, where i is an integer greater than or equal to 1; S43d, Increment the value of i by one, and return to the step of summing the transmission weights of the (N+i)th device tag in the dataset with the existing device tags in the N groups, until all device tags have been grouped.
2. The real-time data acquisition method based on OpcUA according to claim 1, characterized in that, Includes at least one of the following: The list information includes at least one of the following: URL address, username, password, SSL certificate, request timeout, service name, and publication cycle; The device tag information includes at least one of the following: tag name, tag annotation, tag group, namespace, NodeID, NodePath, data type of collection point, data address of collection point, and scanning rate of collection point.
3. The real-time data acquisition method based on OpcUA according to claim 1, characterized in that, In S33, a corresponding sub-table is created for each device tag, including: Determine if the number of device tags exceeds a preset threshold; If so, then create a thread pool and create the sub-table in parallel in a multi-threaded environment; If not, the sub-table is created serially in a single-threaded environment.
4. The real-time data acquisition method based on OpcUA according to claim 1 or 3, characterized in that, Includes at least one of the following: The table name of the supertable corresponds to the numeric type. The fields of the super table include timestamps and their corresponding numeric types; The label column of the super table includes device label name, label annotation, label group, data collection point address, NodeID, and NodePath; The surface of the sub-table is a combination of label groups and label names; The tag column of the sub-table inherits from the supertable and consists of the corresponding attribute values of the device tag.
5. The real-time data acquisition method based on OpcUA according to claim 1, characterized in that, S5 includes: After receiving real-time data sent by the OpcUA acquisition node, the real-time data is cached to the corresponding classification group according to the device tag and classification group information; Once the amount of data in the categorized and grouped cache reaches a preset threshold, the real-time data is written into the super table and sub-tables of the time-series database.
6. A real-time data acquisition device based on OpcUA, characterized in that, The device, applied to the OpcUA Server, includes: The list generation module is configured to generate a list of OpcUA Server information based on pre-set OpcUA Server information. The device tag acquisition module is configured to establish an OpcUA communication connection with the OpcUA acquisition node based on the list information, and acquire device tag information from the OpcUA acquisition node. The database creation module is configured to create a super table and sub-tables of a time-series database based on the device tag information; The classification and grouping module is configured to classify and group device tags according to the device tag information, and send data collection tasks to the OpcUA collection node in units of groups. The data storage module is configured to save the real-time data sent by the OpcUA acquisition node to the super table and sub-table of the time series database after receiving the real-time data. Specifically, the database creation module is used to: traverse the data types of the collection points, mark the numerical types that need to be converted, and the data types of the collection points include at least one of integer, boolean, floating-point, and string types; create a corresponding super table for each numerical type; and create a corresponding sub table for each device tag based on the numerical type to be converted and the corresponding super table of numerical types. The process of classifying and grouping device tags based on the device tag information includes: determining the transmission weight of each data stream corresponding to each device tag based on the device tag information; determining the total transmission weight corresponding to each device tag based on the transmission weight of each data stream corresponding to each device tag; and classifying and grouping device tags based on the total transmission weight corresponding to each device tag. The data stream transmission weight for each device tag is calculated using the following formula: QZ=CON×FAC÷RATE Where QZ is the data stream transmission weight, CON is a constant with a value of 1000 milliseconds; FAC is the numeric type coefficient, with specific values of 1.12 for Boolean numeric types, 1.16 for integer numeric types, 1.2 for floating-point numeric types, and 1.3 for string numeric types; RATE is the sampling point scanning rate, in milliseconds. The process of grouping device tags based on their total transmission weight includes: sorting M device tags in descending order of total transmission weight to obtain a dataset in descending order, where M is an integer greater than or equal to 1; dividing the first N device tags in the dataset into N groups, where each group contains one device tag, N is an integer greater than or equal to 1, and M is greater than or equal to N; summing the transmission weights of the (N+i)th device tag in the dataset with the existing device tags in the N groups, determining the target group with the smallest sum, and assigning the (N+i)th device tag to the target group, where i is an integer greater than or equal to 1; incrementing the value of i by one, and returning to the step of summing the transmission weights of the (N+i)th device tag in the dataset with the existing device tags in the N groups, until all device tags are grouped.
7. A real-time data acquisition device based on OpcUA, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to implement the OpcUA-based real-time data acquisition method as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the real-time data acquisition method based on OpcUA as described in any one of claims 1-5.