## 2 Materials and Methods
### Modeling of Flexible Automation Production Systems  
Reference Architecture Model for Industry 4.0 (RAMI 4.0) [27] offers a structured description of the fundamental requirements of I4.0-compliant systems, exploring: (1) hierarchical levels of a manufacturing system networked via the Internet; (2) the lifecycle of systems and products; and (3) the Information Technology management layers of I4.0 project implementation. In RAMI 4.0, any technical asset of the factory has a digital representation as an I4.0 component, which are provided with digital interfaces to interact with other I4.0 components. Hence, the I4.0 component is the combination of objects from both the physical world and the information world, offering dedicated functionalities and flexible services to other I4.0 Components [30]. As stated in [27], I4.0 components have two main features:  
1. The _Asset_ is a physical or a logical object owned by or under the custodial duties of an organization, having either a perceived or actual value to the organization. 2. The _Asset Administration Shell_ (AAS) is the digitalization of an asset. In other words, and AAS is the interface that connects the physical asset through I4.0 communications such as OPC Unified Architecture (OPC UA) [31]. It is also in charge of offering the I4.0 component's services to the Industry 4.0 (e.g., [32] presents an AAS model able to represent International Electrotechnical Commission (IEC) 61131-3 standard compliant programs and the relevant relationships with Programmable Logic Controllers and each device of the controlled plant). According to the glossary of Platform Industrie 4.0 [33], the AAS concept can be directly related to the concept of Digital Twin (DT). However, several works in the literature apply the DT concept to refer exclusively to highly accurate simulation models. In the authors' understanding, both meanings are correct as both, in different ways, are related to the Asset behavior. In this work, the first one applies. Following this concept, Automation Production Systems (APSs) could be viewed as a set of two types of I4.0 connected Components: (1) Controller and (2) Plant, which offer production services. Their main features are the following:  
* Controller I4.0 Component: \(\bigcirc\) Asset (_ControllerAsset_): The Programmable Logic Controller (PLC), the primary controller for such type of systems, and the I/O boards; \(\bigcirc\) AAS (_AAS\(\_\)Controller_): automatizes the production by means of its I/Os. * Plant I4.0 Component: \(\bigcirc\) Asset (_PlantAsset_): physical station and the sensors and actuators connected to controller's I/Os;AAS (_AAS_Plant_): offers a production service (which contains the control logic and data). This work goes a step further, and it defines Flexible Automation Production Systems (FAPSs) as those APSs that support flexibility through reconfiguration according to QoS parameters, such as control system availability in the event of controller failure or workload balancing. Hence, this work provides support for developing flexible applications at production level, using PLCs as primary controllers. To achieve this, during the design of the FAPSs it must be stated which controllers can potentially automate the production of every _PlantAsset_ in order to download the corresponding Control Logic Software Module (a Program Organization Unit--POU- if IEC 61131-3 standard [34] is used). The runtime platform manages the execution of every control software module (henceforth Production Service-PS-), ensuring that it is only running in a unique controller of the system (active controller), and the others acting as tracking controllers. Besides, applying dynamic reconfiguration to assure specific QoS (e.g., availability of the control system, efficient use of resources or any other QoS), implies both QoS supervision (by means of mechanisms like heartbeat or workload, respectively, in all controllers) and guaranteeing reconfiguration feasibility, avoiding unpredictable effects in the manufacturing process.