## 6 Showcasing the Implementation of Parametric Event Transformation in a Smart Farming Domain
### Scenario Events (IoT and Business)
#### 6.2.2 Second Scenario (with Three Variations)  
The second scenario concerns the calculation of the greenhouse temperature as a result of the average of the last available temperatures of the corresponding sensors for a predetermined hopping time window as shown in Figure 7. In this case, we set the hop size to be one (1) minute and the window size to be five (5) minutes. The scenario has three variations that differ in terms of the number of temperatures of the respective sensors required to calculate the average and, finally, for the temperature produced to be valid.  
In **variation A**, the final temperature is valid if at least one sensor has sent a temperature with an event timestamp within the predefined time window.  
In **variation B**, the final temperature is valid if the majority of sensors, i.e., at least four sensors installed in the greenhouse, have sent a temperature with an event timestamp within the predefined time window.  
In **variation C**, the final temperature is valid if at least six sensors, i.e., all the sensors installed in the greenhouse, have sent a temperature with an event timestamp within the predefined time window.  
It is clarified that the variations are independent and do not overlap or negate each other. Although the description presents a common logical basis, the instantiations are independent and arise from the corresponding parameters, i.e., the physical quantity, the minimum number of sensors that must contribute to calculating the average, the time window hop size, and the time window duration.  
The selection of the last temperature of each sensor for the predetermined time window is based on the event timestamp, i.e., the time when the sensor senses (measures) the data. More specifically, there may be none, one, or several temperatures in the predetermined time window for a sensor. Based on the logic of the scenario, only the last available temperature of each sensor (in the predefined time window) will be used if it exists (by contributing to the calculation of the average temperature).  
It is noted that there is no triggering behavior in each window. The window is re-evaluated on the predefined fixed time intervals, independent of the actual content of the data stream (i.e., independent of the records). For clarity, a triggering behavior could include the re-evaluation of the temperature each time a new record occurs.  
The farmer can, of course, customize the execution of the scenario. In addition to variation selection, the standard user parameters for all variations are:  
1. The hop size of the hopping time window (in seconds or minutes).
2. The window size of the hopping time window (in seconds or minutes).  
Figure 7: Hopping time windowed event stream.  
3. The timestamp based on which the sorting will be done (event timestamp or ingestion timestamp).  
For variations A and C, there are no other parameters. For variation B, the user parameter is the number of sensors taken into account for the calculation of the average (integer number from 1 to 6).  
It is reminded that the calculation happens every minute. However, one more variation of this scenario would be for the computation mentioned above to occur every time a new IoT Event is generated, that is, a combination of the session time window and hopping time window, which would serve the requirement of knowing the temperature every time a sensor senses a change in the greenhouse, which represents a near real-time approach.  
It is also clarified that a valid air temperature is a temperature measured, transmitted, and ingested in the prescribed time window.  
The first scenario is totally served by the _Time Windowed Moving Average Calculation_ Composite Transformation as presented in Section 5.