## 4 Detailed Design
### Abnormal Activity Awareness  
The wearable device in this study can distinguish whether a user has acted inappropriately by referring to the collected ADL data. We have defined several criteria for determining a user's abnormal activity that may occur in a living space. First, if any appliances are not turned off when a user leaves a space, this may indicate the user is frequently forgetful. For example, when a user leaves a bathroom without flushing the toilet or moves from the kitchen to another room without turning off the gas stove, the wearable device recognizes a behavioral fault. Second is the case where a user forgets what to do in a space. If a user enters a bathroom and exits without doing anything, he or she has likely forgotten what to do. The final case is where a user remains in a space for too long a duration. Since this situation can be dangerous to the user, the wearable device alerts the user by vibrating and displaying notifications.  
Algorithm 1 illustrates the pseudocode for the abnormal activity awareness of the wearable device. The wearable device operates as an event-driven method--the execution process occurs in response to specific events and not in a fixed order. This includes position change events as it passes through doors with stationary devices installed and time events generated from the internal real-time clock (RTC) chip. The wearable device saves user activity data to activity and appliance lists and checks these lists when leaving a space to identify unfinished work. Furthermore, it counts stay time (a user stayed in a space), using the event generated as an interrupt, every minute from the RTC. Accordingly, the activity data and the number of abnormal activities of a user can be continuously recorded in the flash memory of the wearable device. Over time, the daily activity data and abnormal activity count recorded in the flash memory of the wearable device can be used to check an individual's living ability and frequency of forgetfulness.  
In addition to abnormal behavior, many activities occurring in real life can be recognized in the same way as above. The activity recognition in this paper collects single actions through home appliance operation and sensor values. It is possible to analyze various activities by analyzing the sequence and timing between these single activities. For example, the act of washing the face can be expressed as a combination of various activities, from entering the bathroom, turning on the faucet, and washing the face using a towel. In order to analyze the user's normal behavior, it is necessary to analyze the sequence, timing and time required between these series of activities. This comprehensive behavior analysis is an important factor in an ADL Test.  
Figure 3: Communication protocol between the wearable, tag, and stationary devices.  
```
1:\(event=position\)change event and time event of wearable device
2:begin
3:switch eventdo
4:caseDOOR_ENTER
5:curr_pos = INSIDE
6:stay_time = 0
7:initialize activity_list, appliance_list
8:\(DOOR\_EXIT\)
9:curr_pos = OUITSIDE
10:ifactivity_list is empty then
11:ifstay_time < MIN_STAY_TIME then
12:abnormal_cnt += 1
13:else
14:forappliance in appliance_list do
15:ifappliance_last_status == ON then
16:abnormal_cnt += 1
17:endfor
18:record activity_list in flash memory
19:caseEVERY_MINUTE
20:stay_time += 1
21:ifcurr_pos == INSIDE and stay_time < MAX_STAY_TIME then
22:abnormal_cnt += 1
23:alert user by vibrating and display notification
24:caseEND_OF_DAY
25:record abnormal_cnt in flash memory
26:abnormal_cnt = 0
27:end switch
28:end
```  
**Algorithm 1** Pseudo code for abnormal activity awareness.