## 3 MOVICLOUD Platform
### Communication of the Agent Platform with the Visualization Tool  
One of the essential tasks within the platform is to establish a communication between JADE and the 3D environment, so that there is a real correspondence between what happens in the agent platform and the visualization that will take place on the 3D platform. Within the agent platform, there is an agent in charge of managing communications in the JADE side.  
For this purpose, the communication between the agent platform and the 3D environment is done through Transmission Control Protocol (TCP) sockets. In the Unity side, a module dedicated to the management of the requests made by the agent platform and vice versa is included. The tasks of creation, elimination and interaction between agents executed on the platform must be updated in the 3D environment, and the tasks of creation, elimination and interaction between agents executed from the 3D interface, must be carried out first in the agent platform for being later updated in Unity. For the implementation of the communication module hosted in Unity, IKVM.NET is used. It allows the execution of compiled Java code in MICROSOFT.NET. The communication will be divided into 2 blocks:  
1. Sockets dedicated to carrying out the tasks in JADE and their corresponding update in Unity.
2. Sockets dedicated to the performance of the tasks initialized from the Unity interface, which must be done first in JADE and then updated in Unity.  
For the simulation of tasks in JADE that will be updated later in Unity, three elements are used: two sockets, one for sending tasks and another for the confirmation of the performed tasks, and a table with which will keep a record of these tasks (Figure 7).  
* **UnityTasks**, stores tasks that have not yet been updated.
* **JadeProducer**, it allows to send tasks to Unity through a TCP socket. In Unity, there will be a resource (**UnityConsumer**) which is listening to the requests that are being produced.
* **JadeConsumer**, opens a TCP socket to receive information regarding the performed tasks. In Unity, **UnityProducer** is in charge of sending the confirmation of the performed tasks.  
Figure 7: Java Agent Development Environment (JADE)-Unity communication.  
Regarding the tasks that are performed in Unity and later updated in JADE, UnityTasks resides on the Unity side, since it is in charge of making requests and must verify that everything that is done in JADE is updated later in Unity. Figure 8 shows the scheme that follows this communication, where a TCP socket will be used. JADE is the server which will listen to the requests performed from Unity. Each request in Unity is a new client that requests a connection to the server, so throughout the execution several clients can coexist. The requests made from Unity can be of three different types: creation of agents, elimination of agents or assignment of tasks to agents.  
The **Communication Agent (CA)** is in charge of attending the requests that arrive from Unity, carrying out the tasks that correspond according to the frame exchanged. The frame that is sent in each request contains the components shown in Figure 9.  
Figure 8: Unity-JADE communication.  
Figure 9: Communication frame.