## 2 Materials and Methods
### Creation of a Proactive System Based on Predictions
Afterwards, the system proceeds to communicate the results or actions that must be put into practice [42]. Sometimes, they are sent to humans (M2H-machine to human communication), and other times, they are sent to machines via M2M (machine to machine). In order to generate a tool capable of representing the reality of the manufacturing process, specifically, the production of molds and parts flowing in the investment casting workflow, it is necessary to be able to represent the flow of these molds in the lost wax casting process and the events that occur in it. In this case, the data obtained from the primary coating, secondary coating, melting, and inspection areas will be transformed into a sequence of enqueued elements that are sequentially characterized in each stage and digitally represented as a FIFO queue. Hence, our digital twin was formally defined as a queue \(Q\) of \(z\) discrete molds, where \(V\) is the sum of \(PC+SC+M+I\) molds (\(PC\) for primary coating and previous molds, \(SC\) from primary coating to secondary coating, \(M\) from secondary coating to melting, and \(I\) for final inspections). Some variables will not be informed until the mold arrives at the specific stage where that data are gathered. In the end, the entire representation is defined as \(Qx_{n},...,x_{2},x_{1}\to Vpc_{n}...,pc_{2},pc_{1},sc_{n}...,sc_{2},sc_{1},m_{n}...,m_{2},m_{1},i_{n},..,i_{2},i_{1}\). For our use case, \(|V|=40\rightarrow|PC|=|SC1|=|M1|=|I1|=10\), and when the full set of \(PC\) molds is ready, they are all moved together to the next step, pushing them forward in the \(PC\to SC\to M\to 1\) sequence. In order to reproduce the current situation of the process, the digital twin must be able to model the movements of the molds, as explained before. In this way, it performs event-based management of the system, detecting when a group of molds reaches a new sequential step, represented by each red square in Figure 5. In fact, the digital twin operates under the following events:  
* The first event occurs when a set of molds is being generated in the primary coating stage. To detect this, the digital twin is subscribed to the PDManager storage database. During the coating process, the system collects data until the last coating has dried and the robot moves the mold to the next stage. When the full set of molds is completed, the digital twin receives this event from the database and triggers a series of tasks to digitally generate the process state, update the digital twin, perform the associated calculations, and finally, move these molds to the next step. * The second event is triggered when the secondary coating is applied. The digital twin is again subscribed to the storage, and the event is fired to indicate that some work must be performed. This second event functions similarly to the previous one but pertains to the creation of the final mold. Again, when all molds are created, the digital representation is updated, and all calculations are executed. Finally, the entire set of molds is promoted to the next stage. * The last detected event occurs when the casting is finally created. This means that the final event is fired when the metal is poured into the mold. Again, the system operates in batches of molds. The subscription to the PDManager database triggers the management process for this step. At that moment, the digital twin receives the information about the creation of the castings, and all of them are moved to the final steps. These last steps are not monitored in this research, though they could be incorporated in future developments. Nevertheless, after the completion of the castings, the quality of each casting is measured, and these data are gathered for the prediction methods. While this is not a step for the digital twin, it is crucial for anticipating the behavior of each casting concerning mechanical properties and the appearance of porosity. Due to these events and the data gathering process, the digital twin is able to characterize each mold.