X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=blobdiff_plain;f=MotionSensor%2FMotionSensors.groovy;h=5c03ebf677c2cf90700d63c2d859e8129b5966a0;hp=85167131551b73f787be48e6525bb806a5e2db8c;hb=6da0a8cedec52b542e0d5046632ae1c166e260cf;hpb=9b8d2370b896feb3d8bae8f1aed9c15ea85da222 diff --git a/MotionSensor/MotionSensors.groovy b/MotionSensor/MotionSensors.groovy index 8516713..5c03ebf 100644 --- a/MotionSensor/MotionSensors.groovy +++ b/MotionSensor/MotionSensors.groovy @@ -19,17 +19,18 @@ public class MotionSensors { private String motionLatestValue = "inactive" - MotionSensors(Closure sendEvent, int deviceNumbers) { + MotionSensors(Closure sendEvent, int deviceNumbers, boolean init) { this.sendEvent = sendEvent this.deviceNumbers = deviceNumbers this.motionSensors = [] - def init = Verify.getBoolean() if (init) { this.motion = "inactive" + this.currentMotion = "inactive" this.motionLatestValue = "inactive" } else { this.motion = "active" + this.currentMotion = "active" this.motionLatestValue = "active" } motionSensors.add(new MotionSensor(id, label, displayName, this.motion, this.motionLatestValue)) @@ -38,10 +39,10 @@ public class MotionSensors { //By Model Checker def setValue(LinkedHashMap eventDataMap) { if (eventDataMap["value"] != motionSensors[0].motion) { + this.motionLatestValue = eventDataMap["value"] + this.motion = eventDataMap["value"] + this.currentMotion = eventDataMap["value"] motionSensors[0].setValue(eventDataMap["value"]) - this.motionLatestValue = motionSensors[0].motionLatestValue - this.motion = motionSensors[0].motion - this.currentMotion = motionSensors[0].motion sendEvent(eventDataMap) } } @@ -59,10 +60,16 @@ public class MotionSensors { def find(Closure Input) { motionSensors.find(Input) } + def sort(Closure Input) { + motionSensors.sort(Input) + } def collect(Closure Input) { motionSensors.collect(Input) } - + + def currentState(String deviceFeature) { + currentValue(deviceFeature) + } def currentValue(String deviceFeature) { motionSensors[0].currentValue(deviceFeature)//It is called if we have only one device @@ -73,7 +80,11 @@ public class MotionSensors { } def statesSince(String info, Date dateObj) { - return motionSensors[0].statesSince(info, dateObj) + return motionSensors[0].statesSince() + } + + def eventsSince(Date dateObj) { + return motionSensors[0].statesSince() } def getAt(int ix) {