# A Platform of Unmanned Surface Vehicle Swarms for Real Time Monitoring in Aquaculture Environments
## 6 Data Acquisition and Analysis  
To manage the data in the server, FIWARE is used. FIWARE is an universal set of standards for context data management (www.fiware.org/developers/). It is used together with its several allied components, like the FIWARE Context Broker, in order to manage data that is dynamic and always changing. If there is a new sensor to be added, FIWARE will accept it without any modifications or configurations needed. To use the aquatic and environment data with FIWARE, a data model adhering to the FIWARE rules had to be created. We created our own model, called \"Aquatic model\", by borrowing attributes from FIWARE own's Weather Model and Water Quality model where possible and creating other properties where needed. The aquatic model is described as follows:  
* **id:** Unique identifier
* **type:** Entity type. It must be equal to Aquatic. Figure 11: Mission start operation. Figure 10: Mission update operation. * **dateObserved:** The date and time of this observation in ISO8601 UTC format. It can be represented by a specific time instant or by an ISO8601 interval.ted by a GeoJSON geometry. * **refDevice:** A reference to the device(s) which captured this observation. * **temperature:** Air temperature. * **humidity:** Air's relative humidity observed (percentage). * **atmosphericPressure:** The atmospheric pressure observed measured in Bars. * **pH:** Aidity or basicity of an aqueous solution. * **uvIndex:** Incidence of UV light. * **ultraSonic:** Underwater distance to objects. * **underwaterPressure:** Underwater pressure observed measured in Bars. * **waterTemperature:** Water temperature. * **conductance:** Conductance of the water. * **turbidity:** Water's observed turbidity percentage. * **depth:** Observed depth at the sensor unit location. * **voltage:** Percentage of battery left. * **O\({}_{2}\):** Ratio of O\({}_{2}\) in water. * **heading:** Direction of the USV. Before the data is ready to be sent to the server, it needs to be processed and turned into a JSON message that is compliant with the Aquatic model. The received message is unpacked and a dictionary is created with each entry being a different sensor reading. Then, a JSON message will be created with the available sensors in the format of the Aquatic Model. This message is then sent into a Mosquito broker ([[https://mosquuitto.org](https://mosquuitto.org)]([https://mosquuitto.org](https://mosquuitto.org))) that is running locally in the DTSs. The Mosquito broker then has a bridge connection to the FIWARE broker in the server, so that the messages in the Mosquito broker are automatically redirected to the FIWARE broker when there is an available connection. The FIWARE broker automatically stores the information of an entity (entity is an instance of a data model, in our case the Aquatic model) in a MongoDB database ([[https://www.mongodb.com](https://www.mongodb.com)]([https://www.mongodb.com](https://www.mongodb.com))). The downside of this database is that, when new information arrives for an entity, it overwrites the previous information, leaving no historic of data. Since we want to be able to access all data gathered by our USV, not just the latest data, we use another FIWARE component called Cygnus. This component will be responsible for persisting all the data received in a PostgresSQL database. It creates a new table for each Data Model, where each line is an attribute of the data model, its value and the associated timestamp. It is from this database that we retrieve the data later for display in the dashboard and for analyzing in the alarm system. The alarm system consists of a component that is continuously analysing the data and checking if any value is abnormal, with abnormal being \"too high\" or \"too low\". The values for \"too high\" and \"too low\" are defined by the user. Using the dashboard, the user will be able to define threshold values for all sensor types which will then be used by the alarm system. When an abnormal value is detected, a notification is generated in the dashboard to warn the user.