def isStateChange = eventDataMap["isStateChange"]
def unit = eventDataMap["unit"]
def data = eventDataMap["data"]
- def minSize
- def smallest
- //make search efficient
- if (app1.eventList.size() == app2.eventList.size()) {
- minSize = app1.eventList.size()
- smallest = "equal"
- } else if (app1.eventList.size() < app2.eventList.size()) {
- minSize = app1.eventList.size()
- smallest = "app1"
- } else {
- minSize = app2.eventList.size()
- smallest = "app2"
- }
-
- for (int i = 0;i < minSize;i++) {
- if (app1.eventList[i] == name) {
- evt.add(new Event())
- evt[-1].value = value
- evt[-1].name = name
- evt[-1].deviceId = deviceId
- evt[-1].descriptionText = descriptionText
- evt[-1].displayed = displayed
- evt[-1].linkText = linkText
- evt[-1].displayName = linkText
- evt[-1].isStateChange = isStateChange
- evt[-1].unit = unit
- evt[-1].data = data
- app1.functionList[i](evt[-1])
- }
+ for (int i = 0;i < app2.eventList.size();i++) {
if (app2.eventList[i] == name) {
- evt.add(new Event())
- evt[-1].value = value
- evt[-1].name = name
- evt[-1].deviceId = deviceId
- evt[-1].descriptionText = descriptionText
- evt[-1].displayed = displayed
- evt[-1].linkText = linkText
- evt[-1].displayName = linkText
- evt[-1].isStateChange = isStateChange
- evt[-1].unit = unit
- evt[-1].data = data
- app2.functionList[i](evt[-1])
+ def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
+ if (app2.functionList[i] instanceof String) {
+ String toCall = app2.functionList[i]
+ app2."$toCall"(event)
+ }
+ else
+ app2.functionList[i](event)
}
}
- if (smallest == "app1") {
- for (int i = minSize;i < app2.eventList.size();i++) {
- if (app2.eventList[i] == name) {
- evt.add(new Event())
- evt[-1].value = value
- evt[-1].name = name
- evt[-1].deviceId = deviceId
- evt[-1].descriptionText = descriptionText
- evt[-1].displayed = displayed
- evt[-1].linkText = linkText
- evt[-1].displayName = linkText
- evt[-1].isStateChange = isStateChange
- evt[-1].unit = unit
- evt[-1].data = data
- app2.functionList[i](evt[-1])
- }
- }
- } else if (smallest == "app2") {
- for (int i = minSize;i < app1.eventList.size();i++) {
- if (app1.eventList[i] == name) {
- evt.add(new Event())
- evt[-1].value = value
- evt[-1].name = name
- evt[-1].deviceId = deviceId
- evt[-1].descriptionText = descriptionText
- evt[-1].displayed = displayed
- evt[-1].linkText = linkText
- evt[-1].displayName = linkText
- evt[-1].isStateChange = isStateChange
- evt[-1].unit = unit
- evt[-1].data = data
- app1.functionList[i](evt[-1])
+ for (int i = 0;i < app1.eventList.size();i++) {
+ if (app1.eventList[i] == name) {
+ def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
+ if (app1.functionList[i] instanceof String) {
+ String toCall = app1.functionList[i]
+ app1."$toCall"(event)
}
+ else
+ app1.functionList[i](event)
}
- }
+ }
}