Data acquisition method, device and equipment based on OPCUA
By monitoring and switching to the highest priority OPCUA acquisition module in the OPCUA data acquisition system, the problem of data loss in OPCUA service failover is solved, faster failover and data completion are achieved, and the reliability of the system is improved. flexibility.
Patent Information
- Application Number
- CN202410849168.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-11-19
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The failover method of existing OPCUA services cannot ensure that the data acquisition link of all devices is normal, which may lead to loss of device data and may lose data from other devices during the switching process.
By using the OPCUA-based data acquisition method, by monitoring the connection status of each device to be collected and the OPCUA acquisition module, periodically switch to the OPCUA acquisition module with the highest priority and no abnormality, ensuring the continuity and reliability of data acquisition, and Data completion is performed during the switching process to avoid loss.
It realizes equipment-level failover, improves switching performance and flexibility, ensures the reliability and integrity of data acquisition, reduces fault identification and switching time, and ensures the robustness and high availability of the system.
Smart Images

Figure CN118984268A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data acquisition, and in particular to an OPC UA-based data acquisition method, device and equipment. Background Art
[0002] In the Internet of Things industry, the Open Platform Communications Unified Architecture (OPCUA) protocol has always been a universal standard communication protocol, and is widely recognized for its ability to collect and integrate data in a unified manner. At the same time, the Internet of Things industry has always had extremely high requirements for the stability and high availability of the OPCUA acquisition module. The previous fault switching method was the master-slave switching of the entire OPCUA service. Usually a single OPCUA service would provide data acquisition functions for multiple devices. When the link of the OPCUA primary service of a certain device is abnormal, but the link of the OPCUA backup service is normal, all devices connected to the OPCUA primary service are switched to the OPCUA backup service. However, in the above solution, it cannot be guaranteed that the acquisition links of the two OPCUA services of other devices are normal. There may be abnormal links in the OPCUA backup services of other devices. At this time, if you do not switch, the data of the abnormal device will be lost. If you switch, the data of other devices may be lost. Summary of the invention
[0003] In view of the problems existing in the prior art, an embodiment of the present invention provides a data collection method, device and equipment based on OPC UA.
[0004] The present invention provides an OPCUA-based data acquisition method, which is applied to a data acquisition system. The system comprises: a first control module and at least two OPCUA acquisition modules, wherein the first control module is respectively connected to the at least two OPCUA acquisition modules, and at least one device to be acquired is respectively connected to the at least two OPCUA acquisition modules. The OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module. The method comprises the following steps.
[0005] The main OPC UA acquisition module is used to periodically monitor the connection status of each device to be collected and the main OPC UA acquisition module; the main OPC UA acquisition module is used to collect data from each device to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPC UA acquisition module to the upper-level application module.
[0006] When the connection status between the device to be collected and the main OPCUA collection module is abnormal, the connection between the device to be collected and the main OPCUA collection module is switched to a connection with an OPCUA collection module other than the main OPCUA collection module among the at least two OPCUA collection modules, and the switched OPCUA collection module is used as the main OPCUA collection module.
[0007] According to an OPCUA-based data acquisition method provided by the present invention, the method also includes: using the first control module to periodically monitor the port status of the main OPCUA acquisition module; when the port status of the main OPCUA acquisition module is abnormal, switching the connection between the first control module and the main OPCUA acquisition module to a connection with an OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules; the connection type between the main OPCUA acquisition module and the first control module is a main connection.
[0008] According to an OPCUA-based data acquisition method provided by the present invention, the data acquisition system also includes: a second control module, the second control module is respectively connected to the at least two OPCUA acquisition modules, and the method also includes: in the event of a failure of the first control module, switching the connection between the main OPCUA acquisition module and the first control module to the connection with the second control module, marking the connection type between the main OPCUA acquisition module and the second control module as a main connection, and changing the connection type between the main OPCUA acquisition module and the first control module to a non-main connection.
[0009] According to a data collection method based on OPCUA provided by the present invention, the method also includes: using the control module corresponding to the main connection to report the data collected by the main OPCUA collection module; the collected data includes at least one of the following: business data, link status information between the main OPCUA collection module and the device to be collected, link status information between the main OPCUA collection module and the control module corresponding to the main connection; the link status information includes at least one of the following: connection status, network status.
[0010] According to an OPCUA-based data acquisition method provided by the present invention, the OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules is an OPCUA acquisition module with the highest priority and without abnormality.
[0011] The method further includes: when the connection status between the device to be collected and the main OPC UA collection module is abnormal, marking the connection status between the device to be collected and the main OPC UA collection module as abnormal.
[0012] According to a data acquisition method based on OPCUA provided by the present invention, the method also includes: if the data of the device to be collected in the control module corresponding to the main connection is lost during the switching of the OPCUA acquisition module, the data of the device to be collected collected in the switched OPCUA acquisition module within the first preset time range before the switching is uploaded to the control module corresponding to the main connection.
[0013] According to a data acquisition method based on OPCUA provided by the present invention, the method also includes: if the data of the device to be collected in the upper-layer application module is lost during the switching of the control device, the data of the device to be collected in the switched control module within a second preset time range before the switching is uploaded to the upper-layer application module by using the switched control module.
[0014] According to an OPCUA-based data acquisition method provided by the present invention, the at least one device to be collected includes at least two device groups, each of the device group includes multiple devices to be collected; the connection between the device to be collected and the main OPCUA acquisition module is switched to the connection with the OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules, including: for each of the device groups, when there are abnormal connections between the devices to be collected and the main OPCUA acquisition module whose number is greater than or equal to a preset threshold in the device group, all the devices to be collected in the device group are switched to the connection with the OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules.
[0015] The present invention also provides an OPCUA-based data acquisition device, which is applied to a data acquisition system. The system includes: a first control module and at least two OPCUA acquisition modules. The first control module is respectively connected to the at least two OPCUA acquisition modules, and at least one device to be collected is respectively connected to the at least two OPCUA acquisition modules. The OPCUA acquisition module with the highest priority and no abnormalities among the at least two OPCUA acquisition modules is the main OPCUA acquisition module. The device includes: a monitoring module and a processing module.
[0016] A monitoring module is used to use the main OPC UA acquisition module to periodically monitor the connection status between each device to be collected and the main OPC UA acquisition module; the main OPC UA acquisition module is used to collect data from each device to be collected and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPC UA acquisition module to the upper-level application module.
[0017] A processing module is used to switch the connection between the device to be collected and the main OPCUA collection module to a connection with an OPCUA collection module other than the main OPCUA collection module among the at least two OPCUA collection modules when the connection status between the device to be collected and the main OPCUA collection module is abnormal, and use the switched OPCUA collection module as the main OPCUA collection module.
[0018] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the OPC UA-based data acquisition method described above is implemented.
[0019] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the OPC UA-based data acquisition method as described above is implemented.
[0020] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the OPC UA-based data acquisition method described above is implemented.
[0021] The OPCUA-based data acquisition method, device and equipment provided by the present invention are applied to a data acquisition system, wherein the system comprises: a first control module and at least two OPCUA acquisition modules, wherein the first control module is respectively connected to the at least two OPCUA acquisition modules, and at least one device to be acquired is respectively connected to the at least two OPCUA acquisition modules, wherein the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, and the main OPCUA acquisition module is used to periodically monitor the connection status between each device to be acquired and the main OPCUA acquisition module; when the connection status between the device to be acquired and the main OPCUA acquisition module is abnormal, the connection between the device to be acquired and the main OPCUA acquisition module is switched to a connection with an OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules. In the above scheme, device-level fault switching can be realized, so more flexible switching can be realized, and the switching performance is better. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is one of the flow charts of the OPCUA-based data acquisition method provided by the present invention.
[0024] Figure 2 It is a schematic diagram of the application architecture of the OPC UA-based data acquisition method provided by the present invention.
[0025] Figure 3 It is a schematic diagram of the control signaling sending principle of the OPC UA-based data acquisition method provided by the present invention.
[0026] Figure 4 This is the second flow chart of the OPCUA-based data acquisition method provided by the present invention.
[0027] Figure 5 It is a structural schematic diagram of the OPC UA-based data acquisition device provided by the present invention.
[0028] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0030] Combine the following Figure 1-Figure 6 The technical solution of the embodiment of the present invention is described in detail with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0031] Figure 1 It is one of the flow charts of the data collection method provided by the present invention, such as Figure 1 As shown, the method is applied to a data acquisition system, the system comprising: a first control module, at least two OPCUA acquisition modules, the first control module is respectively connected to the at least two OPCUA acquisition modules, at least one device to be acquired is respectively connected to the at least two OPCUA acquisition modules, the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, the method comprises the following steps 101, 102 and 103.
[0032] Step 101, use the main OPC UA acquisition module to periodically monitor the connection status of each device to be collected and the main OPC UA acquisition module; the main OPC UA acquisition module is used to collect data from each device to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPC UA acquisition module to the upper application module.
[0033] Specifically, to achieve device-level fault switching, the OPC UA acquisition module will periodically determine the connection status of each device, and trigger automatic switching when the status is abnormal.
[0034] Optionally, in order to ensure a fixed switching order between OPC UA acquisition modules, it is necessary to pre-set the priority of at least two OPC UA acquisition modules to avoid confusion in reported data. When an abnormality occurs in the connection corresponding to the OPC UA acquisition module with a higher priority, the first control module is automatically switched to the connection with the highest priority OPC UA acquisition module with no problem.
[0035] For example, the monitoring period may be 100 ms.
[0036] Step 102: When the connection status between the device to be collected and the main OPC UA collection module is abnormal, the connection between the device to be collected and the main OPC UA collection module is switched to a connection with an OPC UA collection module other than the main OPC UA collection module among at least two OPC UA collection modules, and the switched OPC UA collection module is used as the main OPC UA collection module.
[0037] Specifically, the OPC UA acquisition module accesses various devices to collect and integrate data, and pushes the collected data to the first control program through the main OPC UA acquisition module. Optionally, the OPC UA acquisition module communicates with the device to be collected through a variety of communication protocols, such as serial communication protocols Modbus, IEC104, etc. Among them, IEC104 is a communication protocol widely used in industries such as power and urban rail transit.
[0038] When the connection status between the device to be collected and the main OPCUA collection module is abnormal, switching is triggered to switch the connection between the device to be collected and the main OPCUA collection module to a connection with other OPCUA collection modules except the main OPCUA collection module among at least two OPCUA collection modules, and the switched OPCUA collection module is used as the main OPCUA collection module. Subsequently, the first control program uploads the data collected by the main OPCUA collection module to the upload application module.
[0039] The method of this embodiment uses the main OPCUA acquisition module to periodically monitor the connection status of each device to be collected and the main OPCUA acquisition module; when the connection status of the device to be collected and the main OPCUA acquisition module is abnormal, the connection between the device to be collected and the main OPCUA acquisition module is switched to a connection with an OPCUA acquisition module other than the main OPCUA acquisition module among at least two OPCUA acquisition modules, and the switched OPCUA acquisition module is used as the main OPCUA acquisition module. In the above scheme, device-level fault switching can be realized, so more flexible switching can be achieved, and the switching performance is better.
[0040] Optionally, the method further includes the following steps.
[0041] The first control module is used to periodically monitor the port status of the main OPC UA acquisition module.
[0042] When the port status of the main OPC UA acquisition module is abnormal, the connection between the first control module and the main OPC UA acquisition module is switched to a connection with an OPC UA acquisition module other than the main OPC UA acquisition module among the at least two OPC UA acquisition modules; the connection type between the main OPC UA acquisition module and the first control module is a main connection.
[0043] Specifically, the first control program periodically scans the port status of the OPC UA acquisition module. When the port status of the acquisition module is abnormal, such as the port is disconnected or the acquisition program is abnormal, the OPC UA acquisition module switching will be automatically triggered.
[0044] For example, a scan cycle of 100ms can ensure that when an abnormality occurs in the OPC UA acquisition module, the control program can quickly identify it and trigger a switch. The entire process will not exceed 300MS, so there is a faster fault identification process.
[0045] The main connection is mainly used by the upper-layer application module (such as the upper-layer service) to send control commands to the device. When the connection corresponding to the OPC UA acquisition module with a higher priority is abnormal, the main connection mark is automatically switched to the connection corresponding to the highest priority OPC UA acquisition module without any problem, to ensure that the control command is sent normally and mark the main connection currently used by each device.
[0046] Optionally, the data acquisition system also includes: a second control module, the second control module is respectively connected to the at least two OPCUA acquisition modules, and the method also includes: in the event of a failure of the first control module, switching the connection between the main OPCUA acquisition module and the first control module to the connection with the second control module, marking the connection type between the main OPCUA acquisition module and the second control module as a main connection, and changing the connection type between the main OPCUA acquisition module and the first control module to a non-main connection.
[0047] Specifically, the control module is deployed in active-standby mode (i.e., deployed through a redundant mechanism), and the OPCUA acquisition module pushes the collected data to two control modules (the first control module and the second control module) through the OPCUA protocol. The first control module and the second control module implement active-standby mode through internal communication, and only the primary control module transmits the collected data upward at the same time. The internal redundant mechanism implements the redundant switching function of the two control modules.
[0048] After switching the connection between the main OPC UA acquisition module and the first control module to the connection with the second control module, the connection type between the main OPC UA acquisition module and the second control module can be marked as a main connection, and the connection type between the main OPC UA acquisition module and the first control module can be changed to a non-main connection.
[0049] Optionally, the method also includes: using the control module corresponding to the main connection to report the data collected by the main OPCUA acquisition module; the collected data includes at least one of the following: business data, link status information between the main OPCUA acquisition module and the device to be collected, link status information between the main OPCUA acquisition module and the control module corresponding to the main connection; the link status information includes at least one of the following: connection status, network status.
[0050] Specifically, the collected data may include: collected business data, and in addition, the connection status and network status between the main OPCUA collection module and the device may be uploaded as link status information, or the link status information between the main OPCUA collection module and the control module corresponding to the main connection may be uploaded so that the main control module can report data.
[0051] Optionally, the OPC UA acquisition module other than the main OPC UA acquisition module among the at least two OPC UA acquisition modules is an OPC UA acquisition module with the highest priority and without abnormality.
[0052] The method further includes: when the connection status between the device to be collected and the main OPC UA collection module is abnormal, marking the connection status between the device to be collected and the main OPC UA collection module as abnormal.
[0053] Specifically, to avoid loss of collected data, when an exception occurs in the connection corresponding to an OPC UA collection module with a higher priority, the connection is automatically switched to the connection of the highest priority OPC UA collection module that has not experienced an exception. In addition, the connection type corresponding to the switched OPC UA collection module can be marked as the main connection.
[0054] For example, Figure 2 As shown, the first control module and the second control module are connected to two OPCUA acquisition modules (also called acquisition programs) through the OPCUA protocol at the same time. Both OPCUA acquisition modules can perform data acquisition (also can be collected simultaneously). For example, the first control module is the main control module, and the connection between the main control module and the two OPCUA acquisition modules also needs to distinguish between the main and standby. The main connection is mainly for the upper-layer application module (such as the upper-layer service) to send control information to the device. When an exception occurs in the connection corresponding to an OPCUA acquisition module with a higher priority, the main connection mark is automatically switched to the connection of the highest priority OPCUA acquisition module that has not experienced an exception, to ensure that the control information is sent normally, and mark the main connection currently used by each device. This mark is used for sending upper-layer data. As shown Figure 3As shown, when the control information sent by the upper-layer application module is received, the link corresponding to the main connection mark, that is, the OPCUA acquisition module corresponding to the main connection, is determined, and the control information is sent down to the OPCUA acquisition module corresponding to the main connection, and the OPCUA acquisition module corresponding to the main connection sends the control information to the connected device.
[0055] Optionally, for data upload: Since the control module corresponding to the main connection is connected to multiple OPCUA acquisition modules at the same time, it will receive real-time collected data pushed by multiple OPCUA acquisition modules at the same time. When the control module corresponding to the main connection obtains the collected data, it determines whether the multiple OPCUA acquisition modules are the main OPCUA acquisition modules, reports the data collected by the main OPCUA acquisition module, and determines the connection status of the device to be collected. If the connection is normal, it will be retained, otherwise it will be abandoned, and then data deduplication will be performed before reporting.
[0056] Optionally, the first control module and the second control module are connected via a socket.
[0057] Specifically, the control modules are deployed in an active-standby mode, and the active-standby control modules are connected using a socket. Assuming that the first control module is the active control module initially, when the active control module fails, the standby control module starts working.
[0058] In the above implementation, high availability is achieved by controlling the master / slave mode of the module.
[0059] Optionally, the method also includes: if the data of the device to be collected in the control module corresponding to the main connection is lost during the switching of the OPC UA acquisition module, the data of the device to be collected collected in the switched OPC UA acquisition module within a first preset time range before the switching is uploaded to the control module corresponding to the main connection.
[0060] Specifically, the control module corresponding to the main connection can perform data completion verification. For example, when the connection corresponding to the device is abnormal, the switching process of the OPCUA acquisition module may cause data loss of the device. Therefore, the control module corresponding to the main connection automatically reads the data of the device within the first preset time range before the switching in the switched OPCUA acquisition module and uploads it, that is, uploads the data within the lost time period.
[0061] Optionally, the method also includes: if the data of the device to be collected in the upper application module is lost during the switching of the control device, using the switched control module to upload the data of the device to be collected in the switched control module within a second preset time range before the switching to the upper application module.
[0062] Specifically, data loss may occur during the master-slave switching of the control device. Therefore, the switched control module (the main control module at this time) can be used to upload the data of the device to be collected reported by the main OPCUA acquisition module in the switched control module within the second preset time range before the switching to the upper-layer application module.
[0063] In the above implementation manner, the reliability of data collection can be improved by performing data completion.
[0064] Optionally, the at least one device to be collected includes at least two device groups, each of which includes a plurality of devices to be collected; the step of switching the connection between the device to be collected and the main OPC UA acquisition module to a connection with an OPC UA acquisition module other than the main OPC UA acquisition module among the at least two OPC UA acquisition modules includes: For each of the device groups, when there are abnormal connections between the devices to be collected and the main OPCUA collection module, whose number is greater than or equal to a preset threshold, in the device group, all the devices to be collected in the device group are switched to connections with OPCUA collection modules other than the main OPCUA collection module among the at least two OPCUA collection modules.
[0065] Specifically, the OPCUA mechanism can support grouping of devices. The devices to be collected in the same device group can be switched according to a unified strategy when switching. For example, if the connection between the devices to be collected in the device group that is greater than or equal to a preset threshold and the main OPCUA collection module is abnormal, then the probability of abnormalities in other devices to be collected is relatively high. All devices to be collected in the device group can be uniformly switched to link with another OPCUA collection module. The other OPCUA collection module can be an OPCUA collection module with the highest priority and no abnormalities except the main OPCUA collection module.
[0066] In the above implementation, the risk of loss of collected data can be avoided in advance, thereby improving the reliability of data collection.
[0067] For example, Figure 4 As shown, the method includes the following steps.
[0068] The control module cyclically determines the connection status of each acquisition link to determine whether the connection status is normal.
[0069] If the connection status is normal, the connection status of the link is updated to be available; if the connection status is abnormal, the connection status of the link is updated to be unavailable.
[0070] Determine whether the current link has a main connection mark. If so, cancel the main connection mark of the current link and switch the main connection mark to the connection of the highest priority OPC UA acquisition module that has no problems.
[0071] After receiving the collected data, the control module obtains the connection status of the corresponding link.
[0072] Determine whether the connection status of the current link is available. If the channel status is available, put the collected data into an internal queue, deduplicate the collected data, and upload the deduplicated data; discard the duplicate data.
[0073] If the channel status is unavailable, the collected data is discarded.
[0074] In summary, the method of the embodiment of the present invention has a faster fault judgment speed. When the hardware CPU computing power is sufficient, the switching can be completed within 100ms-300ms, and the fault switching speed is faster. The switching granularity is smaller: device-level failures can be identified and switched. Compared with similar products, it has more flexible switching capabilities and the smallest impact range. After the switch is successful, data completion verification is automatically performed to ensure data consistency. The cross-connection method further ensures the robustness of the system, and the complete high-availability redundancy mechanism can ensure the normal operation of the service under any circumstances.
[0075] The OPCUA-based data acquisition device provided by the present invention is described below. The OPCUA-based data acquisition device described below and the OPCUA-based data acquisition method described above can refer to each other.
[0076] Figure 5 This is one of the structural schematic diagrams of the OPCUA-based data acquisition device provided by the present invention. Figure 5 As shown, the OPCUA-based data acquisition device provided in this embodiment is applied to a data acquisition system, wherein the system comprises: a first control module and at least two OPCUA acquisition modules, wherein the first control module is respectively connected to the at least two OPCUA acquisition modules, and at least one device to be acquired is respectively connected to the at least two OPCUA acquisition modules, wherein the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, and the device comprises: a monitoring module 510 and a processing module 520.
[0077] The monitoring module 510 is used to use the main OPC UA acquisition module to periodically monitor the connection status of each device to be collected and the main OPC UA acquisition module; the main OPC UA acquisition module is used to collect data from each device to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPC UA acquisition module to the upper application module; The processing module 520 is used to switch the connection between the device to be collected and the main OPCUA collection module to a connection with an OPCUA collection module other than the main OPCUA collection module among the at least two OPCUA collection modules when the connection status between the device to be collected and the main OPCUA collection module is abnormal, and use the switched OPCUA collection module as the main OPCUA collection module.
[0078] Optionally, the monitoring module 510 is further configured to utilize the first control module to periodically monitor the port status of the main OPC UA acquisition module.
[0079] The processing module 520 is also used to switch the connection between the first control module and the main OPCUA acquisition module to a connection with an OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules when the port status of the main OPCUA acquisition module is abnormal; the connection type between the main OPCUA acquisition module and the first control module is a main connection.
[0080] Optionally, the data acquisition system also includes: a second control module, which is connected to the at least two OPCUA acquisition modules respectively, and the processing module 520 is also used to: in the event of a failure of the first control module, switch the connection between the main OPCUA acquisition module and the first control module to the connection with the second control module, mark the connection type between the main OPCUA acquisition module and the second control module as a main connection, and change the connection type between the main OPCUA acquisition module and the first control module to a non-main connection.
[0081] Optionally, the processing module 520 is also used to: use the control module corresponding to the main connection to report the data collected by the main OPCUA acquisition module; the collected data includes at least one of the following: business data, link status information between the main OPCUA acquisition module and the device to be collected, link status information between the main OPCUA acquisition module and the control module corresponding to the main connection; the link status information includes at least one of the following: connection status, network status.
[0082] Optionally, the OPC UA acquisition module other than the main OPC UA acquisition module among the at least two OPC UA acquisition modules is an OPC UA acquisition module with the highest priority and without abnormality.
[0083] The processing module 520 is further configured to: when the connection status between the device to be collected and the main OPC UA collection module is abnormal, mark the connection status between the device to be collected and the main OPC UA collection module as abnormal.
[0084] Optionally, the processing module 520 is also used for: if the data of the device to be collected in the control module corresponding to the main connection is lost during the switching of the OPC UA acquisition module, the data of the device to be collected collected in the switched OPC UA acquisition module within the first preset time range before the switching is uploaded to the control module corresponding to the main connection.
[0085] Optionally, the processing module 520 is also used for: if the data of the device to be collected in the upper-layer application module is lost during the switching of the control device, the data of the device to be collected in the switched control module within a second preset time range before the switching is uploaded to the upper-layer application module using the switched control module.
[0086] Optionally, the at least one device to be collected includes at least two device groups, each of which includes multiple devices to be collected; the processing module 520 is specifically used to: for each device group, when there are devices to be collected in the device group whose number is greater than or equal to a preset threshold and whose connection with the main OPCUA acquisition module is abnormal, switch all devices to be collected in the device group to be connected to an OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules.
[0087] The device of the embodiment of the present invention is used to execute the method in any method embodiment of the aforementioned control device side. Its implementation principle and technical effect are similar and will not be repeated here.
[0088] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6As shown, the electronic device may include: a processor 610, a communications interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communications interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the data acquisition method based on OPCUA, which is applied to a data acquisition system, and the system includes: a first control module and at least two OPCUA acquisition modules, wherein the first control module is respectively connected to the at least two OPCUA acquisition modules, and at least one device to be acquired is respectively connected to the at least two OPCUA acquisition modules, and the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, and the method includes: using the main OPCUA acquisition module to periodically monitor the communication between each device to be acquired and the main OPCUA acquisition module. The connection status of the collection module; the main OPCUA acquisition module is used to collect data from each of the devices to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPCUA acquisition module to the upper-level application module; when the connection status between the device to be collected and the main OPCUA acquisition module is abnormal, the connection between the device to be collected and the main OPCUA acquisition module is switched to the connection with the OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules, and the switched OPCUA acquisition module is used as the main OPCUA acquisition module.
[0089] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0090] On the other hand, the present invention also provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the OPCUA-based data acquisition method provided by the above methods, the method is applied to a data acquisition system, the system includes: a first control module, at least two OPCUA acquisition modules, the first control module is respectively connected to the at least two OPCUA acquisition modules, at least one device to be collected is respectively connected to the at least two OPCUA acquisition modules, the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, the method includes: using the main O The PCUA acquisition module periodically monitors the connection status between each device to be collected and the main OPCUA acquisition module; the main OPCUA acquisition module is used to collect data from each device to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPCUA acquisition module to the upper-layer application module; when the connection status between the device to be collected and the main OPCUA acquisition module is abnormal, the connection between the device to be collected and the main OPCUA acquisition module is switched to a connection with an OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules, and the switched OPCUA acquisition module is used as the main OPCUA acquisition module.
[0091] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the OPCUA-based data acquisition method provided by the above-mentioned methods, and the method is applied to a data acquisition system, the system comprising: a first control module, at least two OPCUA acquisition modules, the first control module is respectively connected to the at least two OPCUA acquisition modules, at least one device to be collected is respectively connected to the at least two OPCUA acquisition modules, the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, the method comprises: using the main OPCUA acquisition module to periodically monitor each The main OPCUA acquisition module is used to collect data from each device to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPCUA acquisition module to the upper-layer application module; when the connection status between the device to be collected and the main OPCUA acquisition module is abnormal, the connection between the device to be collected and the main OPCUA acquisition module is switched to the connection with an OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules, and the switched OPCUA acquisition module is used as the main OPCUA acquisition module.
[0092] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0093] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data collection method based on open platform communication unified architecture OPCUA, characterized in that: Applied to a data acquisition system, the system includes: a first control module, at least two OPCUA acquisition modules, the first control module is connected to the at least two OPCUA acquisition modules respectively, at least one device to be acquired is connected to the at least two OPCUA acquisition modules respectively, the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, and the method includes: The main OPC UA acquisition module is used to periodically monitor the connection status of each device to be collected and the main OPC UA acquisition module; the main OPC UA acquisition module is used to collect data from each device to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPC UA acquisition module to the upper application module; When the connection status between the device to be collected and the main OPCUA collection module is abnormal, the connection between the device to be collected and the main OPCUA collection module is switched to a connection with an OPCUA collection module other than the main OPCUA collection module among the at least two OPCUA collection modules, and the switched OPCUA collection module is used as the main OPCUA collection module.
2. The OPCUA-based data acquisition method according to claim 1, characterized in that: The method further comprises: utilizing the first control module to periodically monitor the port status of the main OPC UA acquisition module; When the port status of the main OPC UA acquisition module is abnormal, the connection between the first control module and the main OPC UA acquisition module is switched to a connection with an OPC UA acquisition module other than the main OPC UA acquisition module among the at least two OPC UA acquisition modules; the connection type between the main OPC UA acquisition module and the first control module is a main connection.
3. The OPCUA-based data acquisition method according to claim 2, characterized in that: The data acquisition system further includes: a second control module, wherein the second control module is connected to the at least two OPC UA acquisition modules respectively. The method further includes: In the event of a failure of the first control module, the connection between the main OPC UA acquisition module and the first control module is switched to the connection with the second control module, and the connection type between the main OPC UA acquisition module and the second control module is marked as a main connection, and the connection type between the main OPC UA acquisition module and the first control module is changed to a non-main connection.
4. The OPCUA-based data acquisition method according to claim 3, characterized in that: The method also includes: using the control module corresponding to the main connection to report the data collected by the main OPCUA acquisition module; the collected data includes at least one of the following: business data, link status information between the main OPCUA acquisition module and the device to be collected, and link status information between the main OPCUA acquisition module and the control module corresponding to the main connection; the link status information includes at least one of the following: connection status, network status.
5. The OPCUA-based data acquisition method according to any one of claims 1 to 4, characterized in that: The OPCUA acquisition module other than the main OPCUA acquisition module among the at least two OPCUA acquisition modules is an OPCUA acquisition module with the highest priority and without abnormality; The method further comprises: In the case where the connection status between the device to be collected and the main OPC UA collection module is abnormal, the connection status between the device to be collected and the main OPC UA collection module is marked as abnormal.
6. The OPCUA-based data acquisition method according to any one of claims 2 to 4, characterized in that: The method further comprises: If the data of the device to be collected in the control module corresponding to the main connection is lost during the switching of the OPC UA collection module, the data of the device to be collected collected in the first preset time range before the switching in the switched OPC UA collection module will be uploaded to the control module corresponding to the main connection.
7. The OPCUA-based data acquisition method according to claim 3 or 4, characterized in that: The method further comprises: If the data of the device to be collected in the upper application module is lost during the switching of the control device, the switched control module is used to upload the data of the device to be collected in the switched control module within a second preset time range before the switching to the upper application module.
8. The OPCUA-based data acquisition method according to any one of claims 1 to 4, characterized in that: The at least one device to be collected includes at least two device groups, each of which includes a plurality of devices to be collected; the step of switching the connection between the device to be collected and the main OPC UA collection module to a connection with an OPC UA collection module other than the main OPC UA collection module among the at least two OPC UA collection modules includes: For each of the device groups, when there are abnormal connections between the devices to be collected and the main OPCUA collection module, whose number is greater than or equal to a preset threshold, in the device group, all the devices to be collected in the device group are switched to connections with OPCUA collection modules other than the main OPCUA collection module among the at least two OPCUA collection modules.
9. A data acquisition device based on OPCUA, characterized in that: Applied to a data acquisition system, the system includes: a first control module, at least two OPCUA acquisition modules, the first control module is respectively connected to the at least two OPCUA acquisition modules, at least one device to be acquired is respectively connected to the at least two OPCUA acquisition modules, the OPCUA acquisition module with the highest priority and no abnormality among the at least two OPCUA acquisition modules is the main OPCUA acquisition module, and the device includes: A monitoring module, used to use the main OPC UA acquisition module to periodically monitor the connection status of each device to be collected and the main OPC UA acquisition module; the main OPC UA acquisition module is used to collect data from each device to be collected, and upload the collected data to the first control module; the first control module is used to upload the data collected by the main OPC UA acquisition module to the upper application module; A processing module is used to switch the connection between the device to be collected and the main OPCUA collection module to a connection with an OPCUA collection module other than the main OPCUA collection module among the at least two OPCUA collection modules when the connection status between the device to be collected and the main OPCUA collection module is abnormal, and use the switched OPCUA collection module as the main OPCUA collection module.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the OPC UA-based data acquisition method as described in any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the OPC UA-based data acquisition method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the OPC UA-based data acquisition method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Data-center-based multiple-connection air conditioner control system and implementation method
CN104359196A
Communication control method and device, sub-equipment and communication system
CN110247833A
Dual-computer mutual backup method of data acquisition system and system thereof
CN112698989A
Equipment switching method and device, electronic equipment and storage medium
CN113297013A
Oil depot Internet of Things equipment state monitoring and automatic switching method
CN114095519A
