# Research on a Real-Time Control System for Discrete Factories Based on Digital Twin Technology
## 2 Methods
### Development of System Software
#### 2.3.2 Element/Process Virtualization
Applying 3D MAX and WebGL technologies and defining driving variables such as product location, status, process for virtualization, the product state models can be obtained as shown in Figure 5.  
In the figure, the models, respectively represent gear blank, extruded spline, deep hole, hobbing gear, gear blank, pulling keyhole, hobbing gear, finish product. These products can achieve translation, rotation, and scaling through subsequent process virtualization. 3. Device virtualization methods  
The main devices for producing dual gears include broaching machines, gear hobbing machines, milling machines, laser-marking machines, CNC lathes, cleaning machines, tooth-rolling machines, deep-hole-drilling machines, hole-grinding machines, cylindrical grinders, gear grinding machines, press-fitting machines, stackers, and AGVs. A kind of cleaning device, which is used to clean the finished product, is shown in the left half of Figure 6. By applying some 3D MAX and WebGL virtualization techniques, such as mapping and fusion, to virtualize the device, a virtual device was obtained, as shown in the right half of Figure 6.  
Figure 4: Product of the dual gear factory. Scene virtualization methods  
The annual output of the dual gear factory is 100,000 pairs of dual gears. It is necessary to sort out and improve the initial entity dual gear factory according to the requirements of digital twin technology. The physical factory is reconstructed to adapt to the digital factory after fully understanding the drawings and processes of automotive and motorcycle gears, and deeply analyzing the product features, production quantity, process route, service department, delivery time, as well as factory facility planning, equipment selection, production layout, and management design. The overall layout of the factory is then organized and drawn, as shown in Figure 7.  
When virtualizing the dual gear factory based on the 3D MAX and WebGL technologies, the physical factory should be divided into components and blocks. Some simulation techniques such as mapping and fusion are applied in order to virtualize the components and blocks, and simulation models are built for material products, production devices, facility environments, and production processes to achieve the virtualization of the physical factory. Corresponding to the physical dual gear factory in Figure 8 and following a series of modeling, calculating, programming, and other operations, a virtual dual gear factory is generated, as shown in Figure 8.  
Figure 5: Product states model diagram for the dual gear. Figure 3:0 The model of a cleaning machine virtualization. Process virtualization methods  
The production activities in the virtual factory can usually be composed of methods such as translation, rotation, and scaling. If the spatial position coordinate vector of the virtualization model is assumed to be (and the reference ratio, x y z r) and the reference ratio r = 1, the transformation expression for translation, rotation, and scaling is as follows:  
\[\left[x^{\prime}\ y^{\prime}\ z^{\prime}\ 1\right]=\left[x\ y\ z 1\right] \begin{bmatrix}a&b&c&d\\ e&f&g&h\\ i&j&k&l\\ m&n&o&p\end{bmatrix}  \tag{1}\]  
In the formula, (\(x\ y\ z\) 1) is the original coordinate vector being transformed, and (\(x^{\prime}\ y^{\prime}\ z^{\prime}\) 1) is the transformed coordinate vector. By changing this fourth-order transformation matrix, the translation transformation, rotation transformation, and scaling transformation of the virtual model can be achieved. Figure 8: A virtual factory corresponding to the physical factory. Figure 7: A schematic diagram of the initial dual gear factory. The translation transformation expression is shown in Equation (2). \[\left[x^{\prime}\ y^{\prime}\ z^{\prime}\ 1\right]=\left[x\ y\ z\ 1\right] \begin{bmatrix}1 &0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ p_{x}&p_{y}&p_{z}&1\end{bmatrix}  \tag{2}\]  
Through this expression, the virtual model has translated \(Px\), \(Py\), and \(Pz\) distances along the \(X\), \(Y\), and \(Z\) axes, respectively.