# An IoT-Based Framework for Smart Water Supply Systems Management
## 6 Results and Discussion  
This section evaluates the REFlex Water architecture, a solution for intelligent water management that uses IoT, Complex Event Processing, and declarative processes. The evaluation demonstrates the practical use of REFlex Water through a real water distribution system installed in a Brazilian city. Additionally, the section discusses the advantages of declarative business processes in the context of water distribution systems, whose behavior is usually difficult to foresee. Traditional workflow management systems that use imperative process modeling language (e.g., BPMN) are useful for modeling static and standardized systems. However, they do not provide an adequate response when dealing with dynamic and chaotic processes (e.g., healthcare, disaster prevention, and water systems) [25]. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Operation** & **HTTP verb** & **Description** \\ \hline /v2/entities & (POST, GET, PATCH, DELETE) & Create, list, update or delete sensors \\ /v2/subscriptions & (POST, GET, PATCH, DELETE) & Create, list, update or delete subscriptions \\ /notices & POST & Send an event/notification to Perseo \\ /rules & (POST, GET, DELETE) & Add rule, list all rules or delete \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Operations available at REFlex Water. Figure 11: Perseo rule. The management of water supply systems requires a team of professionals with different skills and levels of experience. Such professionals need to adapt to unexpected situations that may occur in this scenario [17; 18; 26]. In this context, declarative processes may offer the required flexibility, and maintain control over water management policies [26]. Figure 12 illustrates a scenario to demonstrate the practical use of the REFlex Water framework. Notice the presence of water specialists at the Infrastructure level and Water managers at the Application level. The REFlex Water API acts as a gateway receiving data from sensors and forwarding it to Orion FIWARE, which in turn sends it to a CEP server that processes and analyzes the data. Afterwards, the Orion FIWARE and STH-Comet updates the monitoring interface (Figure 13) used by water managers to visualize the current time series data stored by Cygnus. Table 5 shows the data that updates the monitoring interface (Figure 13) and displays the time series. The paper includes a set of algorithms to explain the dynamics used in the schema in Figure 12:  
* Algorithm 1: Orion checks the sensors for new data. When a sensor reads the data, it sends it to Orion informing the identifier of the monitored item (e.g., Tank-1) and the payload. * Algorithm 2: When Orion receives the data from the sensors, it checks for Cygnus signatures: if any, Orion forwards the data to Cygnus, which records the information in the MongoDB component. Orion executes the same process on the Perseo component signature. Such verifications are required because the FIWARE records historical data and CEP analysis only for subscriber components. Figure 12: A scenario for the REFlex Water framework. * Algorithm 3: After Cygnus receives Orion's data, it saves it in the MongoDB component. * Algorithm 4: Perseo records the data, and checks if there are any rules associated with that data. if so, and if the rule is valid, it applies the rule seeking to identify a pattern. When it recognizes a pattern, it triggers an alert. ```
Result: Sending data from sensors System initialized; ifnew_read()then  sendRead(NODE_ID, PAYLOAD);  end if
```  
**Algorithm 1**Sending data from sensors \begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Pump 1** & **Pump 2** & **Task** \\ \hline
**Time (hours)** & **Flow (lps)** & **Flow (lps)** & **Level (m)** \\ \hline  
(-4.90\) & 23.75 & 180.08 \\
20:00 & 16.72 & 0.00 & 180.00 \\
21:00 & 14.75 & \(-0.93\) & 180.06 \\
22:00 & 14.39 & 0.00 & 180.05 \\
23:00 & 24.16 & 0.00 & 180.05 \\
24:00 & 24.43 & 0.00 & 180.00 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Summary of data collected from the pumps and tank.