The manufacturing industry is undergoing a digital revolution, often referred to as Industry 4.0. The aim of this revolution is to transform the factories into, so called, smart factories. These smart factories will be modular, decentralized, and interconnected, to achieve higher level automation and flexibility. Additionally, a smart factory will have a digital twin, a virtual replica that allows testing, monitoring, and visualization of the factory behavior. As these factories are aimed to be completely automated, ensuring correctness and safety of the control logic in each sub-system of the factory is of utmost importance. The need for having digitalized tools that support operators and engineers was identified in a survey that was conducted to understand the problems faced during maintenance of manufacturing systems. To this end, this thesis provides an architecture that can be applied on old legacy systems as well as new state-of-the-art systems to collect data from the factory floor. The data obtained can be visualized in the form of Gantt charts to help operators keep track of the execution of the station. Furthermore, a model that captures the behavior of the system can be created by applying Process Mining algorithms to the collected data. Model-based techniques have shown to be beneficial in developing control logic for highly automated and flexible manufacturing systems, as these techniques offer tools to test and formally verify the control logic to guarantee its correctness. These formal tools operate on such a model of the behavior of the system. However, manually constructing a model on which these tools can be applied is a tedious and error prone task, seldom deemed to be worth the effort. Thus, supporting engineers to build models will improve the adoption of formal tools within the manufacturing industry. In order to obtain a formal model during the early development phase of the manufacturing system, this thesis studies the possibility to automatically infer a model of a system by interacting with its digital twin. The suggested L+ algorithm, an extension of the well-known L* algorithm, shows that it is possible to automatically build formal models in this way. Additionally, certain shortcomings are identified and need to be addressed before being able to these methods in a practical setting.