# Supporting Elderly People by Ad Hoc Generated Mobile Applications Based on Vocal Interaction
## 3 The MicroApp Generator
The MicroApp Generator also handles the native sensors (accelerometer, gyroscope, temperature, proximity and brightness) with specific services, similarly to how the GPS sensor is handled by the service _Location_. The MicroApp Generator allows the user to define a constraint to be satisfied before starting the service execution (i.e., _pre-condition_). A pre-condition can be defined as mandatory or non-mandatory. A _mandatory_ pre-condition, represented by a red diamond on the service representation, forces the application to stop if the pre-condition is not satisfied. A _non-mandatory_ pre-condition, represented by a green diamond, enables the application to go on without executing the service, and the MicroApp Engine is in charge of defining a new control flow that excludes the services that are dependent on the stopped one. An example of using pre-conditions is shown in Figure 1e, where the service _AirConditioner.Set_ takes as input the required temperature to be reached (i.e., 21 Celsius degrees) and it is executed in case the environmental temperature measured by the mobile device sensor satisfies the pre-condition (i.e., initial temperature to be higher than 26 Celsius degrees). Finally, Figure 1f shows a service that exploits a home automation service. In particular, the service _Camera.Start_ is in charge to start a camera connected to the home automation system, which URI is provided by a static parameter, outputs the video-stream. The MicroApp Generator offers context awareness features [1]. In particular, it collects the context information such as user position, current time, network connection, and environmental information. Depending on the user context, it detects the services available on the Web or in the user environment. In addition, Contingency Management is supported. The MicroApp Generator verifies if the involved services are available and tries to replace unavailable services, such as faults or network connectivity problems. A MicroApp is designed by generating an application model, represented by an Extensible Markup Language XML file and constituted by a sequence of steps, where each step requires the execution of a single service. Each service exposes a description of its user interface that enables to generate automatically the MicroApp user interface. Figure 2 shows two examples of app generated by the MicroApp Generator, useful for enhancing communication. The app in Figure 2a (namely _Intercept Call_ and _Send SMS_ lets a person that is unable to answer a phone call, to dictate some text and then send it as an SMS to the caller contact. The service _Phone.InterceptorCall_ is a background service that intercepts an incoming call and provides to the preview service the contact info. Then, the service _Text.Text_ takes in input a text by the user, which is provided as input to the service _SMS.Send_. _Who Is?_ is an example of cross-device notification. When the bell rings, the camera on the door is activated. The user can see who is ringing on the TV in the living room and let them in by triggering an event on the mobile device that is able to open the door. The application model is shown in Figure 2b. In particular, the _Ring.Interceptor_ service detects the ring event and activates the camera installed on the home's door. The _Camera.Record_ home automation service produces as output the video stream. Thus, the user can see who is ringing both on the TV in the living room (_TV.Play_) and also on the device screen (_Media.PlayVideo_). By pronouncing the \"open\" word, the user activates the _Door.Open_ service. Finally, the result messages are spoken and displayed on the screen device. The MicroApp model implicitly handles loops: each parameter represents a collection of objects of the same type. Thus, the data-flow of a MicroApp is represented by a directed acyclic graph. The vertices represent services and edges connections between the output and input parameters. Each service has a set of inputs provided by other services and, in turn, it provides inputs for other services.