# Agreement Technologies for Coordination in Smart Cities
## 3 Applications
### Evacuation Coordination in Smart Building
#### 3.2.2 Situation Awareness  
We assumed the existence of data provided by a smart infrastructure, as well as by the users currently in the building. In particular, we required information for identifying the location of each user in the building. There are various technological techniques to localise people in buildings. Measuring the strength of the signal of several Wi-Fi access points could be used to calculate a person's location via trilateration. However, the signal strength is easily affected by the environment (obstacles, users, etc.) making it very difficult to obtain accurate positions. Another option is using Radio-frequency identification (RFID) technology, but a lot of expensive readers would need to be installed in the building, and there are also similar trilateration problems to those for Wi-Fi. In addition, it would require providing an RFID tag to each person in the building. We opted for using beacons, a recent technology to support indoor navigation. Beacons are cheap devices that emit Bluetooth signals, which can be read by beacon readers, in particular, smartphones. Beacons send, among other information, a unique ID that allows identifying the specific sensor the user is near to, thus providing accurate user location. Besides user location, other infrastructure sensors provide different measures, such as temperature, smoke, fire, and so on. In addition, the users' smartphones built-in sensors provide information that allows detecting their activity (e.g., if the person carrying the phone is running). Sensor events (each piece of information forwarded by or read from a sensor) are processed using complex event processing (CEP), a software technology to extract the information value from event streams [34]. CEP analyses continuous streams of incoming events in order to identify the presence of complex sequences of events (event patterns). Event stream processing systems employ \"sliding windows\" and temporal operators to specify temporal relations between the events in the stream. The core part of CEP is a declarative event processing language (EPL) to express event processing rules. An event processing rule contains two parts: a condition part describing the requirements for firing the rule, and an action part that is performed if the condition matches. An event processing engine analyses the stream of incoming events and executes the matching rules. UAs exploit sensor data and infer the location and behaviour of their user. For example, data read from beacons is introduced as events of type _beaconEvent(beaconID)_. Then, the subsequent CEP rule creates _enteringSection_ and _leavingSection_ events, meaning that the user is entering and leaving a certain space, respectively. The rule describes the situation that a new _beaconEvent_\(b2\) has been read in the phone, where the beacon ID has changed. The symbol \"\(\text{-}\text{>}\)\" indicates that event _b1_ occurs before event _b2_. _CONDITION:_  
_beaconEvent AS b1 \(\text{-}\text{>}\) beaconEvent AS b2 \(\land\)_  
_b1.id \(\text{<}\text{>}\) b2.id_  
_ACTION:_  
_CREATE enteringSection(userID, b2)_  
_CREATE leavingSection(userID, b1)_  
_enteringSection_ and _leavingSection_ events, as well as others, like _runningEvent_ (generated by a CEP rule that checks if the average velocity of the user is higher than 5 km/h for the last 10 s) are forwarded to the SB agent monitoring the user's location area. SB agents receive processed events from the UA in their area. That information, as well as that obtained from smart building sensors, is incorporated into a stream of events. Again, the event stream is processed by the CEP engine generating more abstract and relevant situation awareness information. For instance, a panic event can be inferred if more than 40% of persons in a certain section of the building emit a running event. Finally, situation awareness information, in the form of events, is then transformed into a semantic representation, namely RDF facts.