# Context-Aware System for Information Flow Management in Factories of the Future
## 3 Context-Aware Application
### Context Engine Architecture  
This section proposes a solution for the Context Engine architecture, considering the presented scenario. The proposal aims to provide a flexible, easily scalable, and maintainable solution since the application is in the prototype phase and subject to future adaptations based on new system requirements. Moreover, it should have the capability to integrate with other systems. Based on previously conducted research on context-aware applications, which is presented in [34], a context-aware application should feature a mechanism capable of acquiring, building, reasoning and disseminating contexts/data. To simplify these tasks, they have been divided into independent components, with each component responsible for executing its respective functions. This results in an approach that facilitates the development and independent maintenance of each component's functionalities. The proposed architecture is subdivided into three components/applications: Context Acquisition (responsible for detecting and acquiring contexts), Context Builder (responsible for constructing relevant information for the system), and Context Server (responsible for reasoning and disseminating contexts). In addition, the application has its own database called Context DataBase for storing the application's contexts and other relevant information. Figure 2 illustrates the architecture of the _Context Engine_ and its relationship with other parts of the CA-FoFS system. The integration layer plays a crucial role as an intermediary in connecting data sources to the _Context Engine_. Its responsibility includes providing authorized data to this application, offering an access point, and normalizing them into a common format. DataServices is an embedded interface in the architecture designed to assist Context Engine components. Whenever these components need access to company data, they use  
Figure 2: Context Engine Architecture. this interface, which manages information requests directed to the integration layer. Within this interface, the necessary logic is defined to fulfill these requests. The Context Acquisition component is responsible for querying the integration layer and checking for changes in the data of certain classes. Periodically, this component will make requests to the integration layer through the DataServices interface. When it identifies modifications in the data, the component must assess the relevance of this data. This process is fundamental for identifying important events immediately and triggering alerts when necessary. These alerts are sent to the \"Notification and Alert System\" (NAS), a notification and alert service located in the services layer. The Context Builder has the responsibility of receiving data from other applications in the CA-FoFS system or from IoT devices on the factory's production lines. This data is transmitted intermediately between these applications or devices and the Context Engine through the services layer. Subsequently, this data is processed and stored to obtain relevant information for the system, potentially triggering alerts to the NAS when necessary. Additionally, this component is responsible for removing old data if it is no longer relevant to the system and is only consuming memory resources. The Context Server assumes logical functions related to application data, responsible for acquiring high-level contextual information through data processing functions. These data are acquired through the integration layer, using the DataServices interface, as well as from the application's own database. Additionally, this component distributes contextual information to stakeholders, providing access to context data. It offers a set of query and information services that can be used by CA-FoFS system applications to obtain relevant data. The Context Database is the dedicated database for the Context Engine, where essential data for its operation is stored. These data come from the Context Acquisition and Context Builder components.