1 /////////////////////////////////////////////////////////////////////
2 def eventHandler(LinkedHashMap eventDataMap) {
3 def value = eventDataMap["value"]
4 def name = eventDataMap["name"]
5 def deviceId = eventDataMap["deviceId"]
6 def descriptionText = eventDataMap["descriptionText"]
7 def displayed = eventDataMap["displayed"]
8 def linkText = eventDataMap["linkText"]
9 def isStateChange = eventDataMap["isStateChange"]
10 def unit = eventDataMap["unit"]
11 def data = eventDataMap["data"]
15 //make search efficient
16 if (app1.eventList.size() == app2.eventList.size()) {
17 minSize = app1.eventList.size()
19 } else if (app1.eventList.size() < app2.eventList.size()) {
20 minSize = app1.eventList.size()
23 minSize = app2.eventList.size()
27 for (int i = 0;i < minSize;i++) {
28 if (app1.eventList[i] == name) {
32 evt[-1].deviceId = deviceId
33 evt[-1].descriptionText = descriptionText
34 evt[-1].displayed = displayed
35 evt[-1].linkText = linkText
36 evt[-1].displayName = linkText
37 evt[-1].isStateChange = isStateChange
40 app1.functionList[i](evt[-1])
42 if (app2.eventList[i] == name) {
46 evt[-1].deviceId = deviceId
47 evt[-1].descriptionText = descriptionText
48 evt[-1].displayed = displayed
49 evt[-1].linkText = linkText
50 evt[-1].displayName = linkText
51 evt[-1].isStateChange = isStateChange
54 app2.functionList[i](evt[-1])
58 if (smallest == "app1") {
59 for (int i = minSize;i < app2.eventList.size();i++) {
60 if (app2.eventList[i] == name) {
64 evt[-1].deviceId = deviceId
65 evt[-1].descriptionText = descriptionText
66 evt[-1].displayed = displayed
67 evt[-1].linkText = linkText
68 evt[-1].displayName = linkText
69 evt[-1].isStateChange = isStateChange
72 app2.functionList[i](evt[-1])
75 } else if (smallest == "app2") {
76 for (int i = minSize;i < app1.eventList.size();i++) {
77 if (app1.eventList[i] == name) {
81 evt[-1].deviceId = deviceId
82 evt[-1].descriptionText = descriptionText
83 evt[-1].displayed = displayed
84 evt[-1].linkText = linkText
85 evt[-1].displayName = linkText
86 evt[-1].isStateChange = isStateChange
89 app1.functionList[i](evt[-1])