Op c communication method, medium and equipment for production line simulation

By using the OPC client for recursive traversal and asynchronous processing of PLCs, the problem of time-consuming node traversal in production line simulation was solved, achieving efficient simulation state updates and resource optimization, reducing lag, and ensuring synchronization between the simulation and the actual production line.

CN116567049BActive Publication Date: 2026-02-06GUANGDONG UNIV OF TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310533418.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-11
Publication Date
2026-02-06
Estimated Expiration
2043-05-11

AI Technical Summary

Technical Problem

In existing production line simulations, traversing PLC nodes takes a long time, resulting in excessive computer resource consumption, causing simulation animation stuttering and untimely acquisition of equipment status.

Method used

The OPC client recursively traverses the OPC server to obtain the interface node of the device PLC, monitors the child nodes, and updates the simulation state using callback functions. This separates data processing and communication thread processing, avoiding the waste of irrelevant resources.

Benefits of technology

This reduces lag during the simulation process, ensures that the simulated visuals match the actual production line process, and improves simulation efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116567049B_ABST
    Figure CN116567049B_ABST
Patent Text Reader

Abstract

The application discloses an OPC communication method, medium and equipment for production line simulation, and the method comprises the following steps: obtaining the URL of an OPC server; creating an OPC client based on the URL of the OPC server; recursively traversing the OPC server through the OPC client to obtain the Interface node of a device PLC; recursively traversing the Interface node to obtain the subnode data and monitor the subnode; when the subnode data is monitored to change, a callback function is called to update the simulation state. The application recursively traverses the OPC server through the OPC client to obtain the Interface node of the device PLC, recursively traverses the Interface node, monitors the refreshing condition of the subnode, obtains the changed subnode data to update the simulation state, guarantees the normal refreshing of the node, avoids the waste of computer resources caused by other irrelevant traversing, and reduces the lag condition in the simulation process.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of OPC communication and specifically relates to an OPC communication method, medium and device for production line simulation. BACKGROUND

[0002] The existing production line simulation PLC reading technology generally traverses all existing nodes of the PLC, then traverses the child nodes under the nodes in turn, and then filters the signal nodes to obtain the required signal data, but it is time-consuming to read the node data through the node NamespaceIndex and Identifier, and if the number of nodes is large, a large amount of resources will be occupied during the production line simulation, resulting in distortion such as delay and lag.

[0003] For a large and complex production line, the number of nodes set in the PLC is large, and if all the nodes are traversed in each frame and the signals are refreshed, a large amount of computer resources will be occupied during the signal refreshing, causing the simulation animation to lag, and also causing the current state of each device in the production line to be unable to be obtained in time and accurately. SUMMARY

[0004] In order to overcome the above technical defects, the application provides an OPC communication method for production line simulation to reduce the lag of production line simulation and realize consistency between the simulation picture and the actual production line process.

[0005] In order to solve the above problems, the application discloses the following technical solutions:

[0006] An OPC communication method for production line simulation, comprising the following steps:

[0007] Obtaining the URL of an OPC server;

[0008] Creating an OPC client based on the URL of the OPC server;

[0009] Recursively traversing the OPC server through the OPC client to obtain the Interface node of a device PLC;

[0010] Recursively traversing the Interface node to obtain the child node data and monitoring the child node;

[0011] When the change of the child node data is monitored, a callback function is called to update the simulation state.

[0012] Further, the method further comprises the following steps:

[0013] Obtaining user information from the OPC server, the user information comprising a user account and a user password.

[0014] Further, the step of recursively traversing the OPC server by the OPC client to obtain the Interface node of the PLC of the device comprises the following steps:

[0015] controlling the OPC client to connect with the OPC server;

[0016] logging in the OPC server by the OPC client according to the user information;

[0017] recursively traversing the OPC server to obtain the Interface node of the PLC of the device.

[0018] Further, the step of recursively traversing the Interface node to obtain the data of the child node and monitoring the child node comprises the following steps:

[0019] starting from the NamespaceIndex and the Identifier in the Interface node, recursively traversing to find and obtain the data of the child node, the data of the child node comprising the identity information and the current value of the child node;

[0020] if all the child nodes in the current Interface node have been obtained, judging whether the Identifier reaches the boundary;

[0021] if the Identifier reaches the boundary, judging whether the NamespaceIndex reaches the boundary;

[0022] if the NamespaceIndex reaches the boundary, setting a callback function for the obtained child node to monitor.

[0023] Further, the step of calling the callback function to update the simulation state when the data of the child node is monitored to change comprises the following steps:

[0024] when the data of the child node is monitored to change, calling the callback function to obtain the object of the child node after the change, the object comprising a data packet, the data packet comprising the identity information and the current value after the change of the child node;

[0025] calling the idle processing thread in the thread pool to process the data packet to obtain an updated signal;

[0026] updating the simulation state of the production line according to the updated signal.

[0027] Further, the method further comprises the following steps:

[0028] if the Identifier does not reach the boundary, updating the Identifier;

[0029] Starting from the NamespaceIndex and the updated Identifier in the Interface node, recursive traversal is performed again.

[0030] Further comprising the following steps:

[0031] If the NamespaceIndex does not reach the boundary, the Identifier is updated.

[0032] Starting from the NamespaceIndex and the updated Identifier in the Interface node, recursive traversal is performed again.

[0033] Further comprising the following steps:

[0034] The communication thread is called to keep the OPC client in a running communication state.

[0035] Compared with the prior art, the application has the following beneficial effects:

[0036] The application discloses an OPC communication method for production line simulation.

[0037] The application further discloses a computer readable storage medium, which is a computer readable storage medium, and has a computer program stored thereon.

[0038] The application further discloses a computer device, which comprises:

[0039] A processor;

[0040] A memory for storing instructions executable by the processor;

[0041] The processor is configured to execute the instructions to implement the communication method. BRIEF DESCRIPTION OF DRAWINGS

[0042] The specific embodiments of the application will be further described in detail below with reference to the accompanying drawings, in which:

[0043] Figure 1 A flowchart of the communication method described in Embodiment 1;

[0044] Figure 2 A schematic diagram of the device described in Embodiment 3. DETAILED DESCRIPTION

[0045] The preferred embodiments of the present application will be described herein below with reference to the accompanying drawings, in which it should be understood that the preferred embodiments described herein are intended for explaining and illustrating the present application, and are not intended for limiting the present application.

[0046] Embodiment 1

[0047] As Figure 1 The embodiment discloses an OPC communication method for production line simulation, comprising the following steps:

[0048] S1, obtaining the URL of the OPC server.

[0049] Specifically, after step S1, the following steps are further included:

[0050] Obtaining user information from the OPC server, wherein the user information comprises a user account and a user password.

[0051] S2, creating an OPC client based on the URL of the OPC server.

[0052] Specifically, after step S2, the following steps are further included:

[0053] Defining a first string variable.

[0054] Assigning the user information to the first string variable.

[0055] S3, recursively traversing the OPC server through the OPC client to obtain the Interface node of the device PLC.

[0056] Specifically, step S3 comprises the following steps:

[0057] Controlling the OPC client to connect with the OPC server.

[0058] Logging in the OPC server through the OPC client and the first string variable.

[0059] Recursively traversing the OPC server to obtain the Interface node of the device PLC.

[0060] S4, recursively traversing the Interface node to obtain the subnode data and monitoring the subnode.

[0061] Specifically, step S4 comprises the following steps:

[0062] Starting from the NamespaceIndex and the Identifier in the Interface node, recursively traversing to find and obtain the subnode data, wherein the subnode data comprises the identity information and the current value of the subnode.

[0063] If all the child nodes in the current Interface node have been acquired, it is determined whether the Identifier reaches the boundary.

[0064] If the Identifier reaches the boundary, it is determined whether the NamespaceIndex reaches the boundary.

[0065] If the NamespaceIndex reaches the boundary, the acquired child nodes are set with a callback function for monitoring.

[0066] In the above embodiment, if the Identifier does not reach the boundary, the Identifier is updated.

[0067] The NamespaceIndex and the updated Identifier in the Interface node are taken as the starting point, and the recursive traversal is performed again.

[0068] In the above embodiment, if the NamespaceIndex does not reach the boundary, the Identifier is updated.

[0069] The NamespaceIndex and the updated Identifier in the Interface node are taken as the starting point, and the recursive traversal is performed again.

[0070] S5, when the child node data change is monitored, the callback function is called to update the simulation state.

[0071] Specifically, step S5 includes the following steps:

[0072] When the data change of the child node is monitored, the callback function is called, the changed child node object is acquired, and the object includes the processed data packet, and the data packet includes the identity information of the child node and the changed current value.

[0073] The idle processing thread in the thread pool is called to process the data packet, and the updated signal is obtained.

[0074] According to the updated signal, the simulation state of the production line is updated.

[0075] In the above embodiment, the following steps are further included:

[0076] The communication thread is called to keep the OPC client in a running communication state. After the OPC client and the OPC server are successfully connected, the OPC client and the OPC server always keep the connection state, and the OPC client can receive the information of the PLC of the equipment at any time.

[0077] The application obtains the Interface node of the PLC of the equipment by recursively traversing the OPC server through the OPC client, recursively traverses the Interface node, monitors the refreshing condition of the child node, acquires the changed child node data to update the simulation state, ensures the normal refreshing of the node, avoids the waste of computer resources caused by other irrelevant traversals, and reduces the lag condition in the simulation process. In addition, the processing thread and the communication thread are respectively called, the communication thread is called to keep the communication connection between the OPC client and the OPC server, another processing thread is called to process the data packet when the child node changes, the updated signal is obtained, the data processing and the communication are separately performed, the asynchronous processing callback is adopted, the signal blockage is avoided, the error and the lag condition of the simulation are reduced, the simulation picture is consistent with the process of the actual production line.

[0078] Embodiment 2

[0079] The embodiment discloses a computer readable storage medium, which is a computer readable storage medium, and a computer program is stored on the computer readable storage medium.

[0080] Embodiment 3

[0081] As Figure 2 , the embodiment discloses a computer device, which comprises:

[0082] a processor;

[0083] a memory for storing instructions executable by the processor;

[0084] The processor is configured to execute the instructions to implement the method of the embodiment 1.

[0085] The above is only a preferred embodiment of the application, and does not limit the application in any form. Any modification, equivalent change and modification of the above embodiment without departing from the technical solution of the application, according to the technical essence of the application, are still within the scope of the technical solution of the application.

Claims

1. An OPC communication method for production line simulation, characterized by, The method comprises the following steps: Obtaining the URL of the OPC server; Creating an OPC client based on the URL of the OPC server; Recursively traversing the OPC server through the OPC client to obtain the Interface node of the PLC of the device; Recursively traversing the Interface node to obtain the data of the child node and monitoring the child node; When the change of the data of the child node is monitored, a callback function is called to update the simulation state; The step of recursively traversing the OPC server through the OPC client to obtain the Interface node of the PLC of the device comprises the following steps: Controlling the OPC client to connect with the OPC server; Logging in the OPC server through the OPC client according to the user information; Recursively traversing the OPC server to obtain the Interface node of the PLC of the device; The step of recursively traversing the Interface node to obtain the data of the child node and monitoring the child node comprises the following steps: Taking the NamespaceIndex and the Identifier in the Interface node as the starting point, recursively traversing to find and obtain the data of the child node, the data of the child node comprising the identity information and the current value of the child node; If all the child nodes in the current Interface node have been obtained, determining whether the Identifier reaches the boundary; If the Identifier reaches the boundary, determining whether the NamespaceIndex reaches the boundary; If the NamespaceIndex reaches the boundary, setting a callback function for the obtained child node to monitor; The step of calling the callback function to update the simulation state when the change of the data of the child node is monitored comprises the following steps: When the change of the data of the child node is monitored, calling the callback function to obtain the object of the child node after the change, the object comprising a data packet, the data packet comprising the identity information and the current value after the change of the child node; Calling the idle processing thread in the thread pool to process the data packet to obtain the updated signal; According to the updated signal, updating the simulation state of the production line.

2. The communication method according to claim 1, characterized by, After the step of obtaining the URL of the OPC server, the method further comprises the following steps: Obtaining the user information from the OPC server, the user information comprising a user account and a user password.

3. The communication method of claim 1, wherein, The method further comprises the following steps: If the Identifier does not reach the boundary, updating the Identifier; Taking the NamespaceIndex in the Interface node and the updated Identifier as the starting point, recursively traversing again.

4. The communication method of claim 1, wherein, The method further comprises the following steps: If the NamespaceIndex does not reach the boundary, updating the Identifier; Taking the NamespaceIndex in the Interface node and the updated Identifier as the starting point, recursively traversing again.

5. The communication method of claim 1, wherein, The method further comprises the following steps: Calling the communication thread to keep the OPC client in a running communication state.

6. A computer-readable storage medium, characterized in that, The computer program is stored in a computer readable storage medium, and when the computer program is executed, the communication method according to any one of claims 1-5 is implemented.

7. A computer device, comprising: comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of any of claims 1-5.