## 3 Materials and Methods  
### WSN Challenges in a Lake-Water Quality Monitoring Environment  
In the lake water quality monitoring project, a number of monitoring nodes are distributed throughout the water and are connected to a sufficient number of water quality sensors. The data are aggregated to the gateway node through a ZigBee [17] WSN, and are sent to the remote center server by GPRS (general packet radio service) modules that act as gateway nodes. Any further data processing is conducted by software on the server. The architecture of the water quality monitoring system is shown in Figure 1. The system is composed of three layers: (1) sensing and communication; (2) decision making; and (3) application. Each layer is divided into components with different functions. Figure 1: Structure of water-quality monitoring system. The sensing and communication layer is composed of monitoring nodes and gateway nodes. The monitoring area collects the water quality data, and contains a sufficient quantity of monitoring nodes. The decision-making layer mainly stores, analyzes, and manages the water quality data. It includes a water quality database in the remote monitoring center, and a model for assessing water quality. A user can remotely log in to this layer. The application layer mainly records interactions between the monitoring system and users. A user can check various types of data using the website. Because the monitoring task is performed in a lake area, which is usually a harsh or dangerous environment, reconfiguring the WSN manually is difficult. Therefore, it is a challenge that the WSN should have the flexibility of self-configuration with smart decision support for special purposes. For example, to save energy, sensor nodes could take advantage of long periods of idle time between interesting events. For this reason, the requirements of WSN in lake water quality monitoring enumerated from the point of view of smart decision support are as follows:  
1. Flexibility in monitoring requirement. Given the varied requirements of the users, WSN configuration should be adapted to their target scenario. The flexibility of interaction between WSN and users is needed. 2. Flexibility in task scheduling and execution. Many changing and unpredictable situations are observed in lake water environments. For example, some monitoring indicators (such as the pH level of water) may be particularly abnormal in a certain area or over a certain period and should be given close attention. The WSN should have flexibility in task scheduling and execution, and it should be able to re-plan how to proceed from this abnormal state. 3. Flexibility in resource management [18]. WSN nodes have extremely limited energy, memory, and computing resources. Thus, the use of resources should not be static and predefined. The WSN should be able to change its resource configuration depending on the contextual information. For example, the WSN can switch the sample frequency and communication frequency to very slow if the battery has minimal power. 4. Flexibility in data management. Large amounts of data are generated during water monitoring, but not all of these data are usable. The WSN can change some data sampling behaviors flexibly to make them suitable for different situations. Some irrelevant data are filtered to save data management time. The focus of those requirements is to explore the capabilities of semantic rules in the area of self-configuration. The WSN, depending on the information extracted from its context, can decide autonomously on the configuration of its resources and services. The present study regards the reasoning engine as a middleware decision layer within the decision-making layer. The proposed middleware structure is service oriented. The decision-making layer provides services for the upper layer. The design has different functions to make it more flexible, so that it can easily adapt to unexpected changes. The proposed middleware based on the ontology includes diagnosis management and decision reasoning functions.