# Context-Aware System for Information Flow Management in Factories of the Future
## 3 Context-Aware Application
### Development of the Applications  
To enable testing and validation of the Context Engine applications during their development, ensuring no interference with the normal operation of the Continental Advanced Antenna company's database, two applications were exclusively developed for testing purposes. These applications simulate the company's database and the integration layer with which the application needs to integrate to obtain this data. The first application, called ContinentalTestDb, was developed in a web environment using ASP:NET Core MVC and the C# language. Initially, a simulated database was created to replicate the structure of the company's database, as shown in Figure 4. Subsequently,  
Figure 3: Integration and Communication with External Applications. the application was integrated with this simulated database. Its main objective was to simplify the tasks related to data insertion and manipulation, incorporating logical rules to ensure database consistency. This approach provided a controlled and flexible environment for testing, allowing different scenarios to be explored and the system's behavior to be validated against different sets of data. The second application, named _ContinentalTestAPI_, aimed to simulate the _integration layer_ of the CA-FoFS architecture. It was developed as a web API using ASP:NET Core in C#. This application replicates the expected behavior of the _integration layer_, allowing for more reliable testing of the _Context Engine_ components. This is because these components already interact seamlessly with an application similar to the _integration layer_, making requests for information to an API and receiving information in JSON format. The development of the _Context Engine_ applications began at a later stage. The Context Acquisition was designed as a console application in C#. During its development, a crucial challenge arose in determining how to check for changes in the company's database accessed through requests to the _integration layer_ via API. Initial research revealed that custom methods are often required to determine changes in data, involving triggers,  
Figure 4: Class Diagram of the Experimental Data Model. adding columns to store last modification dates, or even storing changes in additional tables [35]. However, none of these options were viable, as it was not intended to interfere with or modify the company's data system, and permission to do so was not given. The solution found was to make data requests to the API and store this data in the Context Engine's own database, allowing the comparison of information in subsequent requests to detect changes. The subsequent development of the functionalities of this application was relatively straightforward. With the identified changes, it was only necessary to check their relevance and, if affirmative, send the corresponding alert through an HTTP POST request to the NAS. Table 1 describes the various services and features that Context Acquisition uses to perform its functions. Both the _Context Builder_ and the _Context Server_ were developed as web APIs using ASP.NET Core in the C# language. The _Context Builder_ receives information from other applications through HTTP POST requests, processes this information, and stores it in the database if necessary. This component includes information reception services, such as receiving data about the absence of a component on a production line. This information is sent by an IoT device (a smartwatch) available to the company's operators on the production lines. Based on this information, the _Context Builder_ sends alerts to the NAS. Another responsibility of this component is the removal of old data from the database if it is no longer needed for the system. To perform this task, background tasks were implemented in the application, which are executed at predefined time intervals to check for data that is no longer relevant, subsequently proceeding with its removal. Table 2 describes the services and functionalities provided by Context Builder.