## 3 Materials and Methods
### Design of Data Acquisition Module Based on OPC UA Protocol  
#### 3.1.1 Building an OPC UA Server  
In this article, the custom-written OPC UA Server and OPC UA Client are deployed on the same PC (computer) and are responsible for the data collection of the devices on this unit. Therefore, the OPC UA server is used to realize the object modeling and construction of the internal equipment of the production workshop, and the OPC UA server can model the internal equipment of the production workshop and expose the equipment data for users to access in a unified manner.  
The design idea of the data acquisition module based on the OPC UA protocol is as follows: firstly, it is classified according to the communication protocol of all devices in the production workshop, and the equipment with built-in OPC UA server or the equipment that can communicate indirectly through the PLC node can directly use the customized OPC UA client to communicate with it. Suppose the device does not support the OPC UA server. In this case, the device is modeled using OPC UA, and the OPC UA node is mapped one by one to achieve unified OPC UA communication across the entire manufacturing workshop, as shown in Figure 2.  
Figure 1: Real-time data acquisition and processing architecture based on the OPC UA protocol.  
The data collection layer includes an OPC UA server and the data collection program. The OPC UA communication module can collect data, equipment status information, and actual processing status information of the bottom-level equipment in the manufacturing workshop, such as PLCs, sensors, and motors, and send them to the upper layer of the system. The OPC UA server module establishes a node address space model for those devices that do not support the OPC UA protocol, thereby realizing unified communication of the entire manufacturing workshop based on the OPC UA protocol. The code is shown in Appendix A. The specific development process is as follows:  
1. Define the device type. Before creating an OPC UA object for the device, the device type must be defined.
2. Define the device object. According to the previous device object model, encapsulate the device object model, reference the device and the parameters and methods related to the device by node, and then create a namespace for the device so that users can access the target device through this address space.
3. Bind real-time data, connect to the OPC UA server, bind the device parameters to the data tags in the OPC UA server, and provide real-time data for the device parameters. Develop a read-write interface and a historical read interface. For other systems to obtain device data, a data access interface needs to be developed.
4. Develop access interfaces, including read/write interfaces and historical read interfaces. Through these interfaces, users can browse the device's specific parameters.
5. Create a public data access address. By configuring the OPC UA server, specify the public address for data access. This address is used for other systems to establish communication connections with the data center.
6. Data storage management. In order to extract more value from device parameter information, the device's real-time data needs to be saved.