Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
authoramiraj <amiraj.95@uci.edu>
Thu, 1 Aug 2019 18:26:19 +0000 (11:26 -0700)
committeramiraj <amiraj.95@uci.edu>
Thu, 1 Aug 2019 18:26:19 +0000 (11:26 -0700)
77 files changed:
AccelerationSensor/AccelerationSensor.groovy
AccelerationSensor/AccelerationSensors.groovy
AeonKeyFob/AeonKeyFobs.groovy
Alarm/Alarm.groovy
Alarm/Alarms.groovy
AtomicState/AtomicState.groovy [deleted file]
Battery/Batteries.groovy
Battery/Battery.groovy
BeaconSensor/BeaconSensor.groovy
BeaconSensor/BeaconSensors.groovy
CarbonMonoxideDetector/CarbonMonoxideDetector.groovy
CarbonMonoxideDetector/CarbonMonoxideDetectors.groovy
ColorControl/ColorControl.groovy
ColorControl/ColorControls.groovy
ContactSensor/ContactSensor.groovy
ContactSensor/ContactSensors.groovy
DoorControl/DoorControl.groovy
DoorControl/DoorControls.groovy
EnergyMeter/EnergyMeter.groovy
EnergyMeter/EnergyMeters.groovy
Extractor/Extractor.groovy
GlobalVariables/GlobalVariablesBothApps.groovy
GlobalVariables/GlobalVariablesEachApp.groovy
GlobalVariables/test.groovy [new file with mode: 0644]
IlluminanceMeasurement/IlluminanceMeasurement.groovy
IlluminanceMeasurement/IlluminanceMeasurements.groovy
ImageCapture/ImageCaptures.groovy
Location/LocationVar.groovy
Lock/Lock.groovy
Lock/Locks.groovy
Methods/createAccessToken.groovy [new file with mode: 0644]
Methods/eventHandler.groovy
Methods/runOnce.groovy [new file with mode: 0644]
Methods/sendNotificationToContacts.groovy
Methods/setLocationMode.groovy
Methods/subscribe.groovy
Methods/unschedule.groovy
MobilePresence/MobilePresences.groovy
MotionSensor/MotionSensor.groovy
MotionSensor/MotionSensors.groovy
MusicPlayer/MusicPlayer.groovy
MusicPlayer/MusicPlayers.groovy
PowerMeter/PowerMeter.groovy
PowerMeter/PowerMeters.groovy
PresenceSensor/PresenceSensor.groovy
PresenceSensor/PresenceSensors.groovy
RelativeHumidityMeasurement/RelativeHumidityMeasurement.groovy
RelativeHumidityMeasurement/RelativeHumidityMeasurements.groovy
RelaySwitch/RelaySwitch.groovy
RelaySwitch/RelaySwitches.groovy
Runner.py
SleepSensor/SleepSensors.groovy
SmokeDetector/SmokeDetector.groovy
SmokeDetector/SmokeDetectors.groovy
SpeechSynthesis/SpeechSynthesises.groovy
StepSensor/StepSensors.groovy
Switch/Switch.groovy
Switch/Switches.groovy
SwitchLevel/SwitchLevel.groovy
SwitchLevel/SwitchLevels.groovy
TemperatureMeasurement/TemperatureMeasurement.groovy
TemperatureMeasurement/TemperatureMeasurements.groovy
Thermostat/Thermostat.groovy
Thermostat/Thermostats.groovy
Timer/SimulatedTimer.groovy
Valve/Valve.groovy
Valve/Valves.groovy
Variables and events for each device
WaterSensor/WaterSensors.groovy
appTouch/Touched.groovy
eventSimulator/colorChangeEvent.groovy [new file with mode: 0644]
eventSimulator/colorChangedEvent.groovy [deleted file]
eventSimulator/eventSimulator.groovy
eventSimulator/hueChangeEvent.groovy [new file with mode: 0644]
eventSimulator/hueChangedEvent.groovy [deleted file]
eventSimulator/saturationChangeEvent.groovy [new file with mode: 0644]
eventSimulator/saturationChangedEvent.groovy [deleted file]

index 1bec3cd303ea0785c7a499fde1525cf05b16420c..78a9bed73ee91a74c48af4af5c3c46897777a28d 100644 (file)
@@ -22,8 +22,8 @@ public class AccelerationSensor {
        }
 
        def setValue(String value) {
-               this.accelerationLatestValue = acceleration
                println("the acceleration sensor with id:$id is triggered to $value!")
+               this.accelerationLatestValue = value
                this.acceleration = value
                this.currentAcceleration = value
                this.states.add(value)
index db90c564479fd7d837faeb91818dfd4822582c45..bf24508f6eaa6d0064a55864d42123d79b1564f2 100644 (file)
@@ -17,6 +17,7 @@ public class AccelerationSensors {
        private String acceleration = "inactive"
        private String currentAcceleration = "inactive"
        private String accelerationLatestValue = "inactive"
+       
 
                
        AccelerationSensors(Closure sendEvent, int deviceNumbers) {
@@ -38,10 +39,10 @@ public class AccelerationSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != accelerationSensors[0].acceleration) {
+                       this.accelerationLatestValue = eventDataMap["value"]
+                       this.acceleration = eventDataMap["value"]
+                       this.currentAcceleration = eventDataMap["value"]
                        accelerationSensors[0].setValue(eventDataMap["value"])
-                       this.accelerationLatestValue = accelerationSensors[0].accelerationLatestValue
-                       this.acceleration = accelerationSensors[0].acceleration
-                       this.currentAcceleration = accelerationSensors[0].acceleration
                        sendEvent(eventDataMap)
                }
        }
@@ -56,6 +57,9 @@ public class AccelerationSensors {
        def each(Closure Input) {
                accelerationSensors.each(Input)
        }
+       def sort(Closure Input) {
+               accelerationSensors.each(Input)
+       }
        def find(Closure Input) {
                accelerationSensors.find(Input)
        }
index 673afa091aa7a03641f3c78eb4249e2bb9643738..bbb1a35be6885713fee4db22984a6b5e6db1f3dd 100644 (file)
@@ -37,6 +37,9 @@ public class AeonKeyFobs {
        def each(Closure Input) {
                aeonKeyFobs.each(Input)
        }
+       def sort(Closure Input) {
+               aeonKeyFobs.sort(Input)
+       }
        def find(Closure Input) {
                aeonKeyFobs.find(Input)
        }
index d3834f1d799a9f613f046380fdd6d3475d2c7b5c..446face170f690887418132786420ff969a678f0 100644 (file)
@@ -26,8 +26,8 @@ public class Alarm {
 
        //By model checker
        def setValue(String value) {
-               this.alarmLatestValue = alarm
                println("the alarm with id:$id is triggered to $value!")
+               this.alarmLatestValue = value
                this.alarm = value
                this.currentAlarm = value
        }
@@ -37,11 +37,13 @@ public class Alarm {
        def both() {
                if (alarm != "both") {
                        println("the alarm with id:$id is changed to both!")
-                       this.alarmLatestValue = this.alarm
+                       this.alarmLatestValue = "both"
                        this.alarm = "both"
                        this.currentAlarm = "both"
                        sendEvent([name: "alarm", value: "both", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "alarm.both", value: "both", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -52,33 +54,39 @@ public class Alarm {
        def off() {
                if (alarm != "off") {
                        println("the alarm with id:$id is changed to off!")
-                       this.alarmLatestValue = this.alarm
+                       this.alarmLatestValue = "off"
                        this.alarm = "off"
                        this.currentAlarm = "off"
                        sendEvent([name: "alarm", value: "off", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "alarm.off", value: "off", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
        def siren() {
                if (alarm != "siren") {
                        println("the alarm with id:$id is changed to siren!")
-                       this.alarmLatestValue = this.alarm
+                       this.alarmLatestValue = "siren"
                        this.alarm = "siren"
                        this.currentAlarm = "siren"
                        sendEvent([name: "alarm", value: "siren", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "alarm.siren", value: "siren", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
        def strobe() {
                if (alarm != "strobe") {
                        println("the alarm with id:$id is changed to strobe!")
-                       this.alarmLatestValue = this.alarm
+                       this.alarmLatestValue = "strobe"
                        this.alarm = "strobe"
                        this.currentAlarm = "strobe"
                        sendEvent([name: "alarm", value: "strobe", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "alarm.strobe", value: "strobe", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
index 1e8e68e226263d79acfd2c68ff046cb166f91cae..30c55d9b537ac70d6e9a7a3c3507b6da344914e2 100644 (file)
@@ -41,10 +41,10 @@ public class Alarms {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != alarms[0].alarm) {
+                       this.alarmLatestValue = eventDataMap["value"]
+                       this.alarm = eventDataMap["value"]
+                       this.currentAlarm = eventDataMap["value"]
                        alarms[0].setValue(eventDataMap["value"])
-                       this.alarmLatestValue = alarms[0].alarmLatestValue
-                       this.alarm = alarms[0].alarm
-                       this.currentAlarm = alarms[0].alarm
                        sendEvent(eventDataMap)
                }
        }
@@ -62,6 +62,9 @@ public class Alarms {
        def find(Closure Input) {
                alarms.find(Input)
        }
+       def sort(Closure Input) {
+               alarms.sort(Input)
+       }
        def collect(Closure Input) {
                alarms.collect(Input)
        }
@@ -69,19 +72,19 @@ public class Alarms {
        //By Apps
        def both() {
                if (alarm != "both") {
-                       alarms[0].both()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "both"
                        alarm = "both"
                        currentAlarm = "both"
+                       alarms[0].both()
                }
        }
 
        def off() {
                if (alarm != "off") {
-                       alarms[0].off()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "off"
                        alarm = "off"
                        currentAlarm = "off"
+                       alarms[0].off()
                }
        }
 
@@ -91,19 +94,19 @@ public class Alarms {
 
        def siren() {
                if (alarm != "siren") {
-                       alarms[0].siren()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "siren"
                        alarm = "siren"
                        currentAlarm = "siren"
+                       alarms[0].siren()
                }
        }
 
        def strobe() {
                if (alarm != "strobe") {
-                       alarms[0].strobe()
-                       alarmLatestValue = alarm
+                       alarmLatestValue = "strobe"
                        alarm = "strobe"
                        currentAlarm = "strobe"
+                       alarms[0].strobe()
                }
        }
 
diff --git a/AtomicState/AtomicState.groovy b/AtomicState/AtomicState.groovy
deleted file mode 100644 (file)
index a57a4a3..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-//Create a class for atomic state
-package AtomicState
-
-public class AtomicState {
-       def bucketKey
-       def accessKey
-       def bucketName
-       def isBucketCreated
-       def grokerSubdomain
-       def eventBuffer
-       def version
-       def isDisabled
-       def queue
-       def poll
-
-       AtomicState() {
-               this.version = "1.0"
-               this.accessKey = 15
-               this.bucketKey = 20
-       }
-}
index dd82b663cd5b9625842fe96ea66dfcb44842844d..d7d8f1b348e314ae440019b989d6a4d74ac6e9d6 100644 (file)
@@ -16,6 +16,7 @@ public class Batteries {
        private String displayName = "battery0"
        private int battery = 50
        private int currentBattery = 50
+       private int batteryLatestValue = 50
 
                
        Batteries(Closure sendEvent, int deviceNumbers) {
@@ -31,10 +32,11 @@ public class Batteries {
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != batteries[0].battery) {
+               if (eventDataMap["value"].toInteger() != batteries[0].battery) {
+                       this.battery = eventDataMap["value"].toInteger()
+                       this.currentBattery = eventDataMap["value"].toInteger()
+                       this.batteryLatestValue = eventDataMap["value"].toInteger()
                        batteries[0].setValue(eventDataMap["value"])
-                       this.battery = batteries[0].battery
-                       this.currentBattery = batteries[0].battery
                        sendEvent(eventDataMap)
                }
        }
@@ -49,6 +51,9 @@ public class Batteries {
        def each(Closure Input) {
                batteries.each(Input)
        }
+       def sort(Closure Input) {
+               batteries.sort(Input)
+       }
        def find(Closure Input) {
                batteries.find(Input)
        }
@@ -61,6 +66,10 @@ public class Batteries {
                batteries[0].currentValue(deviceFeature)//It is called if we have only one device
        }
 
+       def latestValue(String deviceFeature) {
+               batteries[0].latestValue(deviceFeature)//It is called if we have only one device
+       }
+
        def getAt(int ix) {
                batteries[ix]
        }
index 5358fbdb6d465bd80c2b79846618a95c28be279f..df4b01a4eb26b43ffc75fb59ab718711240000af 100644 (file)
@@ -8,6 +8,7 @@ public class Battery {
        private String displayName
        private int battery
        private int currentBattery
+       private int batteryLatestValue
 
        Battery(String id, String label, String displayName, int battery) {
                this.id = id
@@ -15,6 +16,7 @@ public class Battery {
                this.displayName = displayName
                this.battery = battery
                this.currentBattery = battery
+               this.batteryLatestValue = battery
        }
 
        //By Model Checker
@@ -22,6 +24,7 @@ public class Battery {
                println("the battery level with id:$id is changed to $value!")
                this.battery = value.toInteger()
                this.currentBattery = value.toInteger()
+               this.batteryLatestValue = value.toInteger()
        }
 
        def currentValue(String deviceFeature) {
@@ -30,4 +33,10 @@ public class Battery {
                }
        }
 
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "battery") {
+                       return batteryLatestValue
+               }
+       }
+
 }
index 5f07e4cf75a66baf7af150e2e4aa7c15b5d497a7..1aafbb4a11731007655f1639f032cb06fcbc1778 100644 (file)
@@ -20,8 +20,8 @@ public class BeaconSensor {
        }
 
        def setValue(String value) {
-               this.presenceLatestValue = presence
                println("the beacon sensor with id:$id is triggered to $value!")
+               this.presenceLatestValue = value
                this.presence = value
                this.currentPresence = value
        }
index b2b5e1a8379ab3d32ffdef4a29f219fe830f1a84..0e9996f89fde3e8e42b785deb42bc0ece00df485 100644 (file)
@@ -38,10 +38,10 @@ public class BeaconSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != beaconSensors[0].presence) {
+                       this.presenceLatestValue = eventDataMap["value"]
+                       this.presence = eventDataMap["value"]
+                       this.currentPresence = eventDataMap["value"]
                        beaconSensors[0].setValue(eventDataMap["value"])
-                       this.presenceLatestValue = beaconSensors[0].presenceLatestValue
-                       this.presence = beaconSensors[0].presence
-                       this.currentPresence = beaconSensors[0].presence
                        sendEvent(eventDataMap)
                }
        }
@@ -56,6 +56,9 @@ public class BeaconSensors {
        def each(Closure Input) {
                beaconSensors.each(Input)
        }
+       def sort(Closure Input) {
+               beaconSensors.sort(Input)
+       }
        def find(Closure Input) {
                beaconSensors.find(Input)
        }
index 29434795734306a93867b04df5706f07c8d395d5..213d1531d3ec79c7353f6d893d55f0c885dfe859 100644 (file)
@@ -20,8 +20,8 @@ public class CarbonMonoxideDetector {
        }
 
        def setValue(String value) {
-               this.carbonMonoxideLatestValue = carbonMonoxide
                println("the carbon monoxide detector with id:$id is triggered to $value!")
+               this.carbonMonoxideLatestValue = value
                this.carbonMonoxide = value
                this.currentCarbonMonoxideValue = value
        }
index 9a682610d0814b45b434d7ab332b4b56c8d519aa..21aa5921e70436446e84caf2b5dca80c093c5f57 100644 (file)
@@ -41,10 +41,10 @@ public class CarbonMonoxideDetectors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != carbonMonoxideDetectors[0].currentCarbonMonoxideValue) {
+                       this.carbonMonoxideLatestValue = eventDataMap["value"]
+                       this.carbonMonoxide = eventDataMap["value"]
+                       this.currentCarbonMonoxideValue = eventDataMap["value"]
                        carbonMonoxideDetectors[0].setValue(eventDataMap["value"])
-                       this.carbonMonoxideLatestValue = carbonMonoxideDetectors[0].carbonMonoxideLatestValue
-                       this.carbonMonoxide = carbonMonoxideDetectors[0].currentCarbonMonoxideValue
-                       this.currentCarbonMonoxideValue = carbonMonoxideDetectors[0].currentCarbonMonoxideValue
                        sendEvent(eventDataMap)
                }
        }
@@ -62,6 +62,9 @@ public class CarbonMonoxideDetectors {
        def find(Closure Input) {
                carbonMonoxideDetectors.find(Input)
        }
+       def sort(Closure Input) {
+               carbonMonoxideDetectors.sort(Input)
+       }
        def collect(Closure Input) {
                carbonMonoxideDetectors.collect(Input)
        }
index ac80290ee4c192311e17ee3fd1756b0ea3227eb8..53658dce6e3ddb542ee1f616f6a7fa4174fd195d 100644 (file)
@@ -8,16 +8,22 @@ public class ColorControl {
        private String label
        private String displayName
        private String color
+       private String currentSwitch
+       private int level
        private int hue
        private int saturation
+       private int colorTemperature
        
-       ColorControl(String id, String label, String displayName, String color, int hue, int saturation) {
+       ColorControl(String id, String label, String displayName, String color, int hue, int saturation, int level, String currentSwitch, int colorTemperature) {
                this.id = id
                this.label = label
                this.displayName = displayName
                this.color = color
                this.hue = hue
                this.saturation = saturation
+               this.level = level
+               this.currentSwitch = currentSwitch
+               this.colorTemperature = colorTemperature
        }
        
        //By model checker
@@ -28,9 +34,18 @@ public class ColorControl {
                } else if ((name == "hue") && (value != this.hue)) {
                        this.hue = value.toInteger()
                        println("The hue level of the light is changed to $value!")
-               } else if (value != this.saturation) {
+               } else if ((name == "saturation") && (value != this.saturation)) {
                        this.saturation = value.toInteger()
                        println("The saturation level of the light is changed to $value!")
+               } else if ((name == "level") && (value != this.level)) {
+                       this.level = value.toInteger()
+                       println("The level of the light is changed to $value!")
+               } else if ((name == "currentSwitch") && (value != this.currentSwitch)) {
+                       this.currentSwitch = value
+                       println("The light is changed to $value!")
+               } else if ((name == "colorTemperature") && (value != this.colorTemperature)) {
+                       this.colorTemperature = value.toInteger()
+                       println("The color temperature level of the light is changed to $value!")
                }
        }
 
@@ -62,6 +77,46 @@ public class ColorControl {
                }
        }
 
+       def setLevel(int level) {
+               if (level != this.level) {
+                       this.level = level
+                       println("The level of the light is changed to $level!")
+                       sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+
+       def setColorTemperature(int colorTemperature) {
+               if (colorTemperature != this.colorTemperature) {
+                       this.colorTemperature = colorTemperature
+                       println("The color temperature level of the light is changed to $colorTemperature!")
+                       sendEvent([name: "colorTemperature", value: "$colorTemperature", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+
+       def on(String currentSwitch) {
+               if (currentSwitch != this.currentSwitch) {
+                       this.currentSwitch = currentSwitch
+                       println("The light is changed to $currentSwitch!")
+                       sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.on", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+
+       def off(String currentSwitch) {
+               if (currentSwitch != this.currentSwitch) {
+                       this.currentSwitch = currentSwitch
+                       println("The light is changed to $currentSwitch!")
+                       sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.off", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+
        def currentValue(String deviceFeature) {
                if (deviceFeature == "color") {
                        return color
@@ -69,6 +124,28 @@ public class ColorControl {
                        return saturation
                } else if (deviceFeature == "hue") {
                        return hue
+               } else if (deviceFeature == "level") {
+                       return level
+               } else if (deviceFeature == "colorTemperature") {
+                       return colorTemperature
+               } else if (deviceFeature == "switch") {
+                       return currentSwitch
+               }
+       }
+
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "color") {
+                       return color
+               } else if (deviceFeature == "saturation") {
+                       return saturation
+               } else if (deviceFeature == "hue") {
+                       return hue
+               } else if (deviceFeature == "level") {
+                       return level
+               } else if (deviceFeature == "colorTemperature") {
+                       return colorTemperature
+               } else if (deviceFeature == "switch") {
+                       return currentSwitch
                }
        }
 }
index 39dfeaa8ab3c8d3a3fb84a4bc269c82a07f0e309..5b29f55e54eb51d83ebe1e13a7d8f0545eeff57b 100644 (file)
@@ -15,10 +15,13 @@ public class ColorControls {
        private String label = "colorControl0"
        private String displayName = "colorControl0"
        private String color = "red"
+       private String currentSwitch = "off"
+       private int level = 50
        private int hue = 50
        private int saturation = 50
+       private int colorTemperature = 15000
        
-               
+
        ColorControls(Closure sendEvent, int deviceNumbers) {
                this.sendEvent = sendEvent
                this.deviceNumbers = deviceNumbers
@@ -37,7 +40,7 @@ public class ColorControls {
                        this.color = "blue"
                }*/
 
-               colorControls.add(new ColorControl(id, label, displayName, this.color, this.hue, this.saturation))
+               colorControls.add(new ColorControl(id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
        }
 
        //Methods for closures
@@ -53,6 +56,9 @@ public class ColorControls {
        def find(Closure Input) {
                colorControls.find(Input)
        }
+       def sort(Closure Input) {
+               colorControls.sort(Input)
+       }
        def collect(Closure Input) {
                colorControls.collect(Input)
        }
@@ -61,20 +67,38 @@ public class ColorControls {
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["name"] == "color") {
                        if (eventDataMap["value"] != colorControls[0].color) {
+                               this.color = eventDataMap["value"]
                                colorControls[0].setValue(eventDataMap["value"], "color")
-                               this.color = colorControls[0].color
                                sendEvent(eventDataMap)
                        }       
                } else if (eventDataMap["name"] == "hue") {
-                       if (eventDataMap["value"] != colorControls[0].hue) {
+                       if (eventDataMap["value"].toInteger() != colorControls[0].hue) {
+                               this.hue = eventDataMap["value"].toInteger()
                                colorControls[0].setValue(eventDataMap["value"], "hue")
-                               this.hue = colorControls[0].hue
                                sendEvent(eventDataMap)
                        }
-               } else {
-                       if (eventDataMap["value"] != colorControls[0].saturation) {
+               } else if (eventDataMap["name"] == "saturation") {
+                       if (eventDataMap["value"].toInteger() != colorControls[0].saturation) {
+                               this.saturation = eventDataMap["value"].toInteger()
                                colorControls[0].setValue(eventDataMap["value"], "saturation")
-                               this.saturation = colorControls[0].saturation
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "switch") {
+                       if (eventDataMap["value"] != colorControls[0].currentSwitch) {
+                               this.currentSwitch = eventDataMap["value"]
+                               colorControls[0].setValue(eventDataMap["value"], "switch")
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "colorTemperature") {
+                       if (eventDataMap["value"].toInteger() != colorControls[0].colorTemperature) {
+                               this.colorTemperature = eventDataMap["value"].toInteger()
+                               colorControls[0].setValue(eventDataMap["value"], "colorTemperature")
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "level") {
+                       if (eventDataMap["value"].toInteger() != colorControls[0].level) {
+                               this.level = eventDataMap["value"].toInteger()
+                               colorControls[0].setValue(eventDataMap["value"], "level")
                                sendEvent(eventDataMap)
                        }
                }
@@ -84,29 +108,61 @@ public class ColorControls {
        //methods
        def setColor(String color) {
                if (color != this.color) {
-                       colorControls[0].setColor(color)
                        this.color = color
+                       colorControls[0].setColor(color)                        
                }
        }
 
        def setHue(int hue) {
-               if (hue != this.hue) {          
+               if (hue != this.hue) {
+                       this.hue = hue  
                        colorControls[0].setHue(hue)
-                       this.hue = hue
                }
        }
 
        def setSaturation(int saturation) {
                if (saturation != this.saturation) {
-                       colorControls[0].setSaturation(saturation)
                        this.saturation = saturation
+                       colorControls[0].setSaturation(saturation)                      
                }       
        }
 
+       def setLevel(int level) {
+               if (level != this.level) {
+                       this.level = level
+                       colorControls[0].setLevel(level)
+               }
+       }
+
+       def setColorTemperature(String colorTemperature) {
+               if (colorTemperature != this.colorTemperature) {
+                       this.colorTemperature = colorTemperature
+                       colorControls[0].setColorTemperature(colorTemperature)                  
+               }
+       }
+
+       def on(String currentSwitch) {
+               if (currentSwitch != this.currentSwitch) {
+                       this.currentSwitch = currentSwitch
+                       colorControls[0].on(currentSwitch)                      
+               }
+       }
+
+       def off(String currentSwitch) {
+               if (currentSwitch != this.currentSwitch) {
+                       this.currentSwitch = currentSwitch
+                       colorControls[0].off(currentSwitch)                     
+               }
+       }
+
        def currentValue(String deviceFeature) {
                colorControls[0].currentValue(deviceFeature)
        }
 
+       def latestValue(String deviceFeature) {
+               colorControls[0].latestValue(deviceFeature)
+       }       
+
        def getAt(int ix) {
                colorControls[ix]
        }
index d13993ae3231095369a8a0fdabe74bba220ae7eb..b4ed62906771be1655f70bcedfdffe17966a6687 100644 (file)
@@ -10,6 +10,8 @@ public class ContactSensor {
        private String currentContact   
        private String latestValue
        private String alarmState
+       private List events = []
+       private List timeOfEvents = []
        
 
        ContactSensor(String id, String label, String displayName, String contactState, String currentContact, String alarmState, String latestValue) {
@@ -23,10 +25,22 @@ public class ContactSensor {
        }
 
        def setValue(String value) {
-               this.latestValue = contactState
                println("the contact sensor with id:$id is triggered to $value!")
                this.contactState = value
                this.currentContact = value
+               this.latestValue = value
+               this.events.add(eventDataMap)
+               this.timeOfEvents.add(System.currentTimeMillis())
+       }
+
+       def eventsSince(Date dateObj) {
+               def List happenedEvents = []
+               def sinceThen = dateObj.time
+               for (int i = 0;i < timeOfEvents.size();i++) {
+                       if (timeOfEvents[i]>=sinceThen)
+                               happenedEvents.add(events[i])
+               }
+               return happenedEvents
        }
        
        def on() {
@@ -45,6 +59,12 @@ public class ContactSensor {
                }
        }
 
+       def currentState(String deviceFeature) {
+               if (deviceFeature == "contact") {
+                       return contactState
+               }
+       }
+
        def latestValue(String deviceFeature) {
                if (deviceFeature == "contact") {
                        return latestValue
index b8fba79c363f683418856d43f92300c962b0208c..c691853aad4c3ea157ff65cc8b90ac4ff290f3f0 100644 (file)
@@ -58,6 +58,9 @@ public class ContactSensors {
        def find(Closure Input) {
                contacts.find(Input)
        }
+       def sort(Closure Input) {
+               contacts.sort(Input)
+       }
        def collect(Closure Input) {
                contacts.collect(Input)
        }
@@ -65,28 +68,32 @@ public class ContactSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != contacts[0].contactState) {
+                       this.latestValue = eventDataMap["value"]
+                       this.contactState = eventDataMap["value"]
+                       this.currentContact = eventDataMap["value"]
                        contacts[0].setValue(eventDataMap["value"])
-                       this.latestValue = contacts[0].latestValue
-                       this.contactState = contacts[0].contactState
-                       this.currentContact = contacts[0].contactState
                        sendEvent(eventDataMap)
                }
        }
 
        def on() {
-               contacts[0].on()
                this.alarmState = "armed"
+               contacts[0].on()
        }
 
        def off() {
-               contacts[0].off()
                this.alarmState = "not armed"
+               contacts[0].off()
        }
 
        def currentValue(String deviceFeature) {
                contacts[0].currentValue(deviceFeature)//It is called if we have only one device
        }
 
+       def currentState(String deviceFeature) {
+               contacts[0].currentState(deviceFeature)//It is called if we have only one device
+       }
+
        def latestValue(String deviceFeature) {
                contacts[0].latestValue(deviceFeature)//It is called if we have only one device
        }
index 1830070772ab0260773d1cde53eb24cdc915166a..d0b04d2838ddadea53bba5e5c369c51d1c0224c5 100644 (file)
@@ -19,16 +19,19 @@ public class DoorControl {
                this.label = label
                this.displayName = displayName
                this.doorState = doorState
+               this.doorLatestValue = doorLatestValue
        }
 
        //By Apps
        def open() {
                if (doorState != "open") {
                        println("the door with id:$id is open!")
-                       this.doorLatestValue = this.doorState
+                       this.doorLatestValue = "open"
                        this.doorState = "open"
                        sendEvent([name: "doorControl", value: "open", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "doorControl.open", value: "open", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -36,10 +39,12 @@ public class DoorControl {
                if (doorState != "open") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the door with id:$id is open!")
-                               this.doorLatestValue = this.doorState
+                               this.doorLatestValue = "open"
                                this.doorState = "open"
                                sendEvent([name: "doorControl", value: "open", deviceId: this.id, descriptionText: "",
                                    displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "doorControl.open", value: "open", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -47,10 +52,12 @@ public class DoorControl {
        def close() {
                if (doorState != "closed") {
                        println("the door with id:$id is closed!")
-                       this.doorLatestValue = this.doorState
+                       this.doorLatestValue = "closed"
                        this.doorState = "closed"
                        sendEvent([name: "doorControl", value: "closed", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "doorControl.closed", value: "closed", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -58,10 +65,12 @@ public class DoorControl {
                if (doorState != "closed") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the door with id:$id is closed!")
-                               this.doorLatestValue = this.doorState
+                               this.doorLatestValue = "closed"
                                this.doorState = "closed"
                                sendEvent([name: "doorControl", value: "closed", deviceId: this.id, descriptionText: "",
                                    displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "doorControl.closed", value: "closed", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -69,7 +78,7 @@ public class DoorControl {
        //By Model Checker
        def setValue(String value) {
                println("the door with id:$id is $value!")
-               this.doorLatestValue = this.doorState
+               this.doorLatestValue = value
                this.doorState = value
        }
        
index 9cb85cd30da7c05682b249b7fb540b8c25e296a3..ac6decc59c64343620a1f696cca6c5322a53c8cc 100644 (file)
@@ -48,6 +48,9 @@ public class DoorControls {
        def find(Closure Input) {
                doorControls.find(Input)
        }
+       def sort(Closure Input) {
+               doorControls.sort(Input)
+       }
        def collect(Closure Input) {
                doorControls.collect(Input)
        }
@@ -82,8 +85,9 @@ public class DoorControls {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != doorControls[0].doorState) {
+                       this.doorState = eventDataMap["value"]
+                       this.doorLatestValue = eventDataMap["value"]
                        doorControls[0].setValue(eventDataMap["value"])
-                       this.doorState = doorControls[0].doorState
                        sendEvent(eventDataMap)
                }
        }
index a0ab13ea73c4363e6743b9347686f7fcb07ac9ff..c4eca238f66d6d13e23c209ea9688882523e243e 100644 (file)
@@ -29,4 +29,9 @@ public class EnergyMeter {
                }
        }
 
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "energy") {
+                       return energy
+               }
+       }
 }
index 553ed86da28e29c33fdd8479a1e1df28f3bb58d1..907ec6680065932c3f48f59e65cbc1e5e660b17f 100644 (file)
@@ -31,10 +31,10 @@ public class EnergyMeters {
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != energyMeters[0].energy) {
-                       energyMeters[0].setValue(eventDataMap["value"])
-                       this.energy = energyMeters[0].energy
-                       this.currentEnergy = energyMeters[0].currentEnergy              
+               if (eventDataMap["value"].toInteger() != energyMeters[0].energy) {
+                       this.energy = eventDataMap["value"].toInteger()
+                       this.currentEnergy = eventDataMap["value"].toInteger()
+                       energyMeters[0].setValue(eventDataMap["value"]) 
                        sendEvent(eventDataMap)
                }
        }
@@ -52,6 +52,9 @@ public class EnergyMeters {
        def find(Closure Input) {
                energyMeters.find(Input)
        }
+       def sort(Closure Input) {
+               energyMeters.sort(Input)
+       }
        def collect(Closure Input) {
                energyMeters.collect(Input)
        }
@@ -61,6 +64,10 @@ public class EnergyMeters {
                energyMeters[0].currentValue(deviceFeature)//It is called if we have only one device
        }
 
+       def latestValue(String deviceFeature) {
+               energyMeters[0].latestValue(deviceFeature)//It is called if we have only one device
+       }
+
        def getAt(int ix) {
                energyMeters[ix]
        }
index 309223d3547eaa7cb8ba1412763e7777a3301ae3..502fdc3bb8f3a8be7e47d8bd7e26eae8c96beebd 100644 (file)
@@ -82,6 +82,8 @@ import Timer.SimulatedTimer
 @Field def log = new Logger()
 //Create a global variable for optional property
 @Field def optional = false //by default for now
+//Global Object for class AtomicState!
+@Field def atomicState = [history: "15:00"]
 
 
 //Global variables for files
@@ -348,6 +350,7 @@ def timeToday(String time, Object timeZone) {
 @Field boolVariable5
 
 
+
 /////Input Methods/////
 //input "",""
 def input(String name, String type) {
@@ -395,7 +398,7 @@ def input(LinkedHashMap metaData) {
 
                        lockObjects=lockObjects+1
 
-                       settings.put(metaData['name'], metaData['name']
+                       settings.put(metaData['name'], new Locks({}, 1)
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class lock!\n")
@@ -421,7 +424,7 @@ def input(LinkedHashMap metaData) {
 
                        alarmObjects=alarmObjects+1
 
-                       settings.put(metaData['name'], metaData['name']
+                       settings.put(metaData['name'], new Alarms({}, 1)
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class alarm!\n")
@@ -447,7 +450,7 @@ def input(LinkedHashMap metaData) {
 
                        batteryObjects=batteryObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new Batteries({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class Battery!\n")
@@ -473,7 +476,7 @@ def input(LinkedHashMap metaData) {
 
                        beaconSensorObjects=beaconSensorObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new BeaconSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class beacon sensor!\n")
@@ -499,7 +502,7 @@ def input(LinkedHashMap metaData) {
 
                        carbonMonoxideDetectorObjects=carbonMonoxideDetectorObjects+1
                        
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new CarbonMonoxideDetectors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class carbon monoxide detector!\n")
@@ -525,7 +528,7 @@ def input(LinkedHashMap metaData) {
 
                        colorControlObjects=colorControlObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new ColorControls({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class color control!\n")
@@ -551,7 +554,7 @@ def input(LinkedHashMap metaData) {
 
                        contactObjects=contactObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new ContactSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class contactSensor!\n")
@@ -577,7 +580,7 @@ def input(LinkedHashMap metaData) {
 
                        doorControlObjects=doorControlObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new DoorControls({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class door control!\n")
@@ -603,7 +606,7 @@ def input(LinkedHashMap metaData) {
 
                        energyMeterObjects=energyMeterObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new EnergyMeters({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class energy meter!\n")
@@ -629,7 +632,7 @@ def input(LinkedHashMap metaData) {
 
                        illuminanceMeasurementObjects=illuminanceMeasurementObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new IlluminanceMeasurements({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class illuminance measurement!\n")
@@ -655,7 +658,7 @@ def input(LinkedHashMap metaData) {
 
                        accelerationSensorObjects=accelerationSensorObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new AccelerationSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class Acceleration Sensor!\n")
@@ -681,7 +684,7 @@ def input(LinkedHashMap metaData) {
 
                        motionSensorObjects=motionSensorObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new MotionSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class Motion Sensor!\n")
@@ -707,7 +710,7 @@ def input(LinkedHashMap metaData) {
 
                        musicPlayerObjects=musicPlayerObjects+1
 
-                       settings.put(metaData['name'], metaData['name']
+                       settings.put(metaData['name'], new MusicPlayers({}, 1)
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class music player!\n")
@@ -733,7 +736,7 @@ def input(LinkedHashMap metaData) {
 
                        powerMeterObjects=powerMeterObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new PowerMeters({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class power meter!\n")
@@ -759,7 +762,7 @@ def input(LinkedHashMap metaData) {
 
                        presenceSensorObjects=presenceSensorObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new PresenceSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class presence sensor!\n")
@@ -785,7 +788,7 @@ def input(LinkedHashMap metaData) {
 
                        humidityMeasurementObjects=humidityMeasurementObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new RelativeHumidityMeasurements({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class humidity measurement!\n")
@@ -811,7 +814,7 @@ def input(LinkedHashMap metaData) {
 
                        relaySwitchObjects=relaySwitchObjects+1
                        
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new RelaySwitches({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class relay switch!\n")
@@ -837,7 +840,7 @@ def input(LinkedHashMap metaData) {
 
                        sleepSensorObjects=sleepSensorObjects+1
                        
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new SleepSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class sleep sensor!\n")
@@ -863,7 +866,7 @@ def input(LinkedHashMap metaData) {
 
                        smokeDetectorObjects=smokeDetectorObjects+1
                        
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new SmokeDetectors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class smoke detector!\n")
@@ -889,7 +892,7 @@ def input(LinkedHashMap metaData) {
 
                        stepSensorObjects=stepSensorObjects+1
                        
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new StepSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class step sensor!\n")
@@ -915,7 +918,7 @@ def input(LinkedHashMap metaData) {
 
                        switchObjects=switchObjects+1
                        
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new Switches({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class switch!\n")
@@ -941,7 +944,7 @@ def input(LinkedHashMap metaData) {
 
                        switchLevelObjects=switchLevelObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new SwitchLevels({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class switch level!\n")
@@ -967,7 +970,7 @@ def input(LinkedHashMap metaData) {
 
                        temperatureMeasurementObjects=temperatureMeasurementObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new TemperatureMeasurements({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class temperature measurement!\n")
@@ -993,7 +996,7 @@ def input(LinkedHashMap metaData) {
 
                        thermostatObjects=thermostatObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new Thermostats({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class thermostat!\n")
@@ -1019,7 +1022,7 @@ def input(LinkedHashMap metaData) {
 
                        valveObjects=valveObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new Valves({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class valve!\n")
@@ -1045,7 +1048,7 @@ def input(LinkedHashMap metaData) {
 
                        speechSynthesisObjects=speechSynthesisObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new SpeechSynthesises({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class speech synthesis!\n")
@@ -1071,7 +1074,7 @@ def input(LinkedHashMap metaData) {
 
                        waterSensorObjects=waterSensorObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new WaterSensors({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class water sensor!\n")
@@ -1097,7 +1100,7 @@ def input(LinkedHashMap metaData) {
 
                        touchSensorObjects=touchSensorObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new NfcTouch({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class Touch Sensor!\n")
@@ -1123,7 +1126,7 @@ def input(LinkedHashMap metaData) {
 
                        imageCaptureObjects=imageCaptureObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new ImageCaptures({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class Image Capture!\n")
@@ -1149,7 +1152,7 @@ def input(LinkedHashMap metaData) {
 
                        mobilePresenceObjects=mobilePresenceObjects+1
 
-                       settings.put(metaData['name'], metaData['name'])
+                       settings.put(metaData['name'], new MobilePresences({}, 1))
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class mobile presence!\n")
@@ -1175,7 +1178,7 @@ def input(LinkedHashMap metaData) {
 
                        aeonKeyFobObjects=aeonKeyFobObjects+1
 
-                       settings.put(metaData['name'], metaData['name']
+                       settings.put(metaData['name'], new AeonKeyFobs({}, 1)
 
                        if (App == "App1") {
                                extractedObjectsApp1.append("//Object for class aeon key fob!\n")
@@ -1212,7 +1215,11 @@ def input(LinkedHashMap metaData) {
                                this[mode5] = userInput
                        }
 
-                       modeVariables=modeVariables+1
+                       if (modeVariables != 5)
+                               modeVariables=modeVariables+1
+                       else
+                               modeVariables=0
+
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1247,7 +1254,10 @@ def input(LinkedHashMap metaData) {
                                this[decimal5] = userInput
                        }
 
-                       decimalVariables=decimalVariables+1
+                       if (decimalVariables != 5)
+                               decimalVariables=decimalVariables+1
+                       else
+                               decimalVariables=0
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1282,7 +1292,11 @@ def input(LinkedHashMap metaData) {
                                this[text5] = userInput
                        }
 
-                       textVariables=textVariables+1
+                       if (textVariables != 5)
+                               textVariables=textVariables+1
+                       else
+                               textVariables=0
+
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1317,7 +1331,12 @@ def input(LinkedHashMap metaData) {
                                this[number5] = userInput
                        }
 
-                       numberVariables=numberVariables+1
+
+                       if (numberVariables != 5)
+                               numberVariables=numberVariables+1
+                       else
+                               numberVariables=0
+                       
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1352,7 +1371,10 @@ def input(LinkedHashMap metaData) {
                                this[time5] = userInput
                        }
 
-                       timeVariables=timeVariables+1
+                       if (timeVariables != 5)
+                               timeVariables=timeVariables+1
+                       else
+                               timeVariables=0
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1367,8 +1389,10 @@ def input(LinkedHashMap metaData) {
                case "enum":
                        if (metaData['options'] != null)
                                modes = metaData['options']
-                       else // If it is not named 'options' then it is captured as 'metadata'
+                       else if (metaData['metadata'] != null) { // If it is not named 'options' then it is captured as 'metadata'
                                modes = metaData['metadata']
+                               modes = modes['values']
+                       }
                        def userInput = modes[0]
        
                        if (enumVariables == 0) {
@@ -1391,7 +1415,11 @@ def input(LinkedHashMap metaData) {
                                this[enum5] = userInput
                        }
 
-                       enumVariables=enumVariables+1
+                       if (enumVariables != 5)
+                               enumVariables=enumVariables+1
+                       else
+                               enumVariables=0                 
+
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1426,7 +1454,11 @@ def input(LinkedHashMap metaData) {
                                this[bool5] = userInput
                        }
 
-                       boolVariables=boolVariables+1
+                       if (boolVariables != 5)
+                               boolVariables=boolVariables+1
+                       else
+                               boolVariables=0
+
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1461,7 +1493,10 @@ def input(LinkedHashMap metaData) {
                                this[phone5] = userInput
                        }
 
-                       phoneVariables=phoneVariables+1
+                       if (phoneVariables != 5)
+                               phoneVariables=phoneVariables+1
+                       else
+                               phoneVariables=0
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1496,7 +1531,10 @@ def input(LinkedHashMap metaData) {
                                this[contact5] = userInput
                        }
 
-                       contactVariables=contactVariables+1
+                       if (contactVariables != 5)
+                               contactVariables=contactVariables+1
+                       else
+                               contactVariables=0
 
                        settings.put(metaData['name'], metaData['name'])
 
@@ -1552,12 +1590,27 @@ def definition(LinkedHashMap metaData) {
 
 def preferences(Closure inputData) {
        find(inputData) //Run the closure to extract pages/sections/inputMethods
-       if (App == "App1") {                    
+       settings.put("END", "END")
+       if (App == "App1") {            
                extractedObjectsConstructorApp1.append("//Global variable for settings!\n")
-               extractedObjectsConstructorApp1.append("settings = $settings\n")
+               extractedObjectsConstructorApp1.append("settings = [")
+               settings.each{
+                       key, value ->
+                       if (value != "END")
+                               extractedObjectsConstructorApp1.append("$key: $key, ")
+                       else
+                               extractedObjectsConstructorApp1.append("END: \"END\"]\n")
+               }
        } else {
                extractedObjectsConstructorApp2.append("//Global variable for settings!\n")
-               extractedObjectsConstructorApp2.append("settings = $settings\n")
+               extractedObjectsConstructorApp2.append("settings = [")
+               settings.each{
+                       key, value ->
+                       if (value != "END")
+                               extractedObjectsConstructorApp2.append("$key: $key, ")
+                       else
+                               extractedObjectsConstructorApp2.append("END: \"END\"]\n")
+               }
        }
 }
 
@@ -1601,6 +1654,10 @@ def section(LinkedHashMap metaData, Closure inputData) {
        find(inputData) //Run the closure to extract inputMethods
 }
 
+def section(LinkedHashMap metaData, String data, Closure inputData) {
+       find(inputData)
+}
+
 def mappings(Closure inputData) {
        println("//IGNORE--some data//")
 }
index 998778b9380bb5611888df21ca3941a744de4056..2840bea5a3dd390eb318781b5c4d8db6077c1b26 100644 (file)
@@ -8,8 +8,6 @@
 @Field def appObject = new Touched(sendEvent, 0)
 //Create a global list for events
 //@Field def evt = []
-//Global Object for class AtomicState!
-@Field def atomicState = new AtomicState()
 //Global Object for class Touch Sensor!
 @Field def touchSensorObject = new NfcTouch(sendEvent, 1)
 //Global Object for class switch!
index 0e1de0bfbcb7cb00e98a1b18c854a1822bad5d57..8ae34ad07c32e71b31d3b40804f1769ad0b2d582 100644 (file)
@@ -16,3 +16,5 @@ def timersList = []
 def settings
 //Zip code
 def zipCode = 92617
+//atomicState variable
+def atomicState = [version: "1.01"]
diff --git a/GlobalVariables/test.groovy b/GlobalVariables/test.groovy
new file mode 100644 (file)
index 0000000..4b73ab8
--- /dev/null
@@ -0,0 +1,3 @@
+String s = "smoke.detected"
+if (s.contains("smoke"))
+       println(s)
index c73576b8f14a0d793e1661c21bf5bf5dadc49b8a..644db1b7c0bcbddd425f8d6e071a29f86ed94fac 100644 (file)
@@ -30,4 +30,10 @@ public class IlluminanceMeasurement {
                }
        }
 
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "illuminance") {
+                       return illuminance
+               }
+       }
+
 }
index 0da46af6a3689bf46213bd607b6a8caa838e1262..6f7637479a8d54a22796deb1536885d374abcbd0 100644 (file)
@@ -31,10 +31,10 @@ public class IlluminanceMeasurements {
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != illuminanceMeasurements[0].illuminance) {
+               if (eventDataMap["value"].toInteger() != illuminanceMeasurements[0].illuminance) {
+                       this.illuminance = eventDataMap["value"].toInteger()
+                       this.currentIlluminance = eventDataMap["value"].toInteger()
                        illuminanceMeasurements[0].setValue(eventDataMap["value"])
-                       this.illuminance = illuminanceMeasurements[0].illuminance
-                       this.currentIlluminance = illuminanceMeasurements[0].illuminance
                        sendEvent(eventDataMap)
                }
        }
@@ -52,6 +52,9 @@ public class IlluminanceMeasurements {
        def find(Closure Input) {
                illuminanceMeasurements.find(Input)
        }
+       def sort(Closure Input) {
+               illuminanceMeasurements.sort(Input)
+       }
        def collect(Closure Input) {
                illuminanceMeasurements.collect(Input)
        }
@@ -61,6 +64,10 @@ public class IlluminanceMeasurements {
                illuminanceMeasurements[0].currentValue(deviceFeature)//It is called if we have only one device
        }
 
+       def latestValue(String deviceFeature) {
+               illuminanceMeasurements[0].latestValue(deviceFeature)//It is called if we have only one device
+       }
+
        def getAt(int ix) {
                illuminanceMeasurements[ix]
        }
index e9034b151d03551d0cf981cc4cd7412ea38574ae..3b97a87b0e533f8a600969b1fd59e2e5993afb09 100644 (file)
@@ -46,21 +46,24 @@ public class ImageCaptures {
        def find(Closure Input) {
                imageCaptureSensors.find(Input)
        }
+       def sort(Closure Input) {
+               imageCaptureSensors.sort(Input)
+       }
        def collect(Closure Input) {
                imageCaptureSensors.collect(Input)
        }
 
        def alarmOn() {
                if (alarmState != "armed") {
-                       imageCaptureSensors[0].alarmOn()
                        this.alarmState = "armed"
+                       imageCaptureSensors[0].alarmOn()
                }
        }
 
        def alarmOff() {
                if (alarmState != "not armed") {
-                       imageCaptureSensors[0].alarmOff()
                        this.alarmState = "not armed"
+                       imageCaptureSensors[0].alarmOff()
                }
        }
 
index d10206ba1e1d99a7b0f2ee3aba7ab3d4f67d066c..a87abe9834197ab321f5b935e41416be893b72b9 100644 (file)
@@ -6,6 +6,7 @@ class LocationVar {
        private def modes
        private def timeZone
        private String mode
+       private String name
        private List contacts
        private List phoneNumbers
        def sendEvent
@@ -21,6 +22,7 @@ class LocationVar {
                this.phoneNumbers = [9495379373]
                this.sendEvent = sendEvent
                this.timeZone = TimeZone.getTimeZone("America/New_York")
+               this.name = "hub0"
        }
 
        //By Model Checker
index fd18e4384071a7de01191dcdaad67ad3fcc9331b..4b84497003b6696d86c74eacdcc6567f32766919 100644 (file)
@@ -28,12 +28,17 @@ public class Lock {
        def lock() {
                if (lockState != "locked") {
                        println("the door with id:$id is locked!")
+<<<<<<< HEAD
+=======
                        //this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                        this.lockLatestValue = "locked"
                        this.lockState = "locked"
                        this.currentLock = "locked"
                        sendEvent([name: "lock", value: "locked", deviceId: this.id, descriptionText: "",
                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "lock.locked", value: "locked", deviceId: this.id, descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -41,12 +46,17 @@ public class Lock {
                if (lockState != "locked") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the door with id:$id is locked!")
+<<<<<<< HEAD
+=======
                                //this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                                this.lockLatestValue = "locked"
                                this.lockState = "locked"
                                this.currentLock = "locked"
                                sendEvent([name: "lock", value: "locked", deviceId: this.id, descriptionText: "",
                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "lock.locked", value: "locked", deviceId: this.id, descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -54,7 +64,10 @@ public class Lock {
        def unlock() {
                if (lockState != "unlocked") {
                        println("the door with id:$id is unlocked!")
+<<<<<<< HEAD
+=======
                        //this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                        this.lockLatestValue = "unlocked"
                        this.lockState = "unlocked"
                        this.currentLock = "unlocked"
@@ -62,6 +75,11 @@ public class Lock {
                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+<<<<<<< HEAD
+                       sendEvent([name: "lock.unlocked", value: "unlocked", deviceId: this.id, descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+=======
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                }
        }
 
@@ -69,6 +87,17 @@ public class Lock {
                if (lockState != "unlocked") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the door with id:$id is locked!")
+<<<<<<< HEAD
+                               this.lockLatestValue = "unlocked"
+                               this.lockState = "unlocked"
+                               this.currentLock = "unlocked"
+                               sendEvent([name: "unlock", value: "unlocked", deviceId: this.id, descriptionText: "",
+                                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
+                                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "lock.unlocked", value: "unlocked", deviceId: this.id, descriptionText: "",
+                                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])                             
+=======
                                //this.lockLatestValue = this.lockState
                                this.lockLatestValue = "locked"
                                this.lockState = "locked"
@@ -77,6 +106,7 @@ public class Lock {
                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                                sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
                                                displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                        }
                }
        }
@@ -84,7 +114,7 @@ public class Lock {
        //By Model Checker
        def setValue(String value) {
                println("the door with id:$id is $value!")
-               this.lockLatestValue = this.lockState
+               this.lockLatestValue = value
                this.lockState = value
                this.currentLock = value
        }
index 63d93b41131aced268ce3d6e4fcb6247428d2b5d..8b73dc55ac20e393cd311655c2ddd4f03a2859c9 100644 (file)
@@ -95,6 +95,9 @@ public class Locks{
        def find(Closure Input) {
                locks.find(Input)
        }
+       def sort(Closure Input) {
+               locks.sort(Input)
+       }
        def collect(Closure Input) {
                locks.collect(Input)
        }
diff --git a/Methods/createAccessToken.groovy b/Methods/createAccessToken.groovy
new file mode 100644 (file)
index 0000000..1d639f6
--- /dev/null
@@ -0,0 +1,5 @@
+/////////////////////////////////////////////////////////////////////
+def createAccessToken() {
+       state.accessToken = "accessToken"
+       return state.accessToken
+}
index b838418bf64c12cbba30b99e4b4804d8fa919686..ca13fa3c5e3d13bf2390c920f0abeb95284f648c 100644 (file)
@@ -13,14 +13,24 @@ def eventHandler(LinkedHashMap eventDataMap) {
        for (int i = 0;i < app2.eventList.size();i++) {
                if (app2.eventList[i] == name) {
                        def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
-                       app2.functionList[i](event)
+                       if (app2.functionList[i] instanceof String) {
+                               String toCall = app2.functionList[i]
+                               app2."$toCall"(event)
+                       }
+                       else
+                               app2.functionList[i](event)
                }
        }
 
        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)
-                       app1.functionList[i](event)
+                       if (app1.functionList[i] instanceof String) {
+                               String toCall = app1.functionList[i]
+                               app1."$toCall"(event)
+                       }
+                       else
+                               app1.functionList[i](event)
                }
        }
 }
diff --git a/Methods/runOnce.groovy b/Methods/runOnce.groovy
new file mode 100644 (file)
index 0000000..335cc19
--- /dev/null
@@ -0,0 +1,4 @@
+/////////////////////////////////////////////////////////////////////
+def runOnce(Date date, Closure methodToCall) {
+       methodTocall()
+}
index 165d0a4320a977b8e0382d24b9aba7beeebd6dd4..06563c0878eb63d714a5dd88caffa1ea776a982b 100644 (file)
@@ -9,3 +9,13 @@ def sendNotificationToContacts(String text, String recipients) {
                }
        }
 }
+
+def sendNotificationToContacts(String text, String recipients, LinkedHashMap metaData) {
+       for (int i = 0;i < recipients.size();i++) {
+               for (int j = 0;j < location.contacts.size();j++) {
+                       if (recipients[i] == location.contacts[j]) {
+                               println("Sending \""+text+"\" to "+location.phoneNumbers[j].toString())
+                       }
+               }
+       }
+}
index d2dade11e2fb92cf74098d399781e266d23f6e90..aa7424bf19130ccb1c59b1b9502e85da011d27ab 100644 (file)
@@ -1,5 +1,8 @@
 /////////////////////////////////////////////////////////////////////
 def setLocationMode(String mode) {
-       location.mode = mode
+       location.setValue([name: "Location", value: "$mode", deviceId: "locationID0", descriptionText: "",
+                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+       location.setValue([name: "mode", value: "$mode", deviceId: "locationID0", descriptionText: "",
+                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 }
 
index 74f7047e0b64167f2267eb5bd40a82a04628aaf0..730b76ac60bdc542a28f290a0e5b6f96c2cfa6c6 100644 (file)
@@ -17,6 +17,12 @@ def subscribe(Object obj, String event, Closure FunctionToCall) {
        eventList.add(event)
        functionList.add(FunctionToCall)
 }
+////subscribe(obj, event, nameOfFunc)
+def subscribe(Object obj, String event, String nameOfFunction) {
+       objectList.add(obj)
+       eventList.add(event)
+       functionList.add(nameOfFunction)
+}
 ////subscribe(obj, event, func, data)
 def subscribe(Object obj, String event, Closure FunctionToCall, LinkedHashMap metaData) {
        objectList.add(obj)     
index 322d80583d785a5631c6b7245495d05f67f56c2e..7f6ca1fdf920128f08737d042126e2675a6c810a 100644 (file)
@@ -9,6 +9,17 @@ def unschedule(Closure functionToUnschedule) {
        }
 }
 
+def unschedule(String nameOfFunctionToUnschedule) {
+       for (int i = 0;i < timersFuncList.size();i++) {
+               if (timersFuncList[i] instanceof String) {
+                       if (timersFuncList[i] == nameOfFunctionToUnschedule) {
+                               if (timersList != null)
+                                       timersList[i].cancel()
+                       }
+               }
+       }
+}
+
 
 def unschedule() {
        for (int i = 0;i < timersFuncList.size();i++) {
index e264cae4dcc9c0825c2658e9d1f0d9b48213cd82..a462b9fbb737f5ec6ba04b815490133477c640d7 100644 (file)
@@ -36,6 +36,9 @@ public class MobilePresences {
        def find(Closure Input) {
                mobilePresences.find(Input)
        }
+       def sort(Closure Input) {
+               mobilePresences.sort(Input)
+       }
        def collect(Closure Input) {
                mobilePresences.collect(Input)
        }
index 825fe332a75b33c6d42b7be8e6bbf3fd77ebb938..79fbf9b5b018b71054fe72ac8de51005fd005b7d 100644 (file)
@@ -22,8 +22,8 @@ public class MotionSensor {
        }
 
        def setValue(String value) {
-               this.motionLatestValue = motion
                println("the motion sensor with id:$id is triggered to $value!")
+               this.motionLatestValue = value
                this.motion = value
                this.currentMotion = value
                this.states.add(value)
index 764aa3e9c505d0c405933f12b2b7489eb2d38abe..52034d9521b50b2823b4d40be65c9566cb06ea86 100644 (file)
@@ -38,10 +38,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,6 +59,9 @@ public class MotionSensors {
        def find(Closure Input) {
                motionSensors.find(Input)
        }
+       def sort(Closure Input) {
+               motionSensors.sort(Input)
+       }
        def collect(Closure Input) {
                motionSensors.collect(Input)
        }
index 80b5f49cc825edced9452c3445e15dd202eb88f6..236b52888a1470d1b00260bdd727aff63240a338 100644 (file)
@@ -4,6 +4,7 @@ import Timer.SimulatedTimer
 
 
 public class MusicPlayer {
+       def sendEvent
        private String id
        private String label
        private String displayName
@@ -53,7 +54,9 @@ public class MusicPlayer {
                if (mute != "muted") {
                        println("the music player with id:$id is muted!")
                        this.mute = "muted"
-                       sendEvent([name: "mute", value: "mute", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "mute", value: "muted", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "mute.muted", value: "muted", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -65,6 +68,8 @@ public class MusicPlayer {
                        this.status = "playing"
                        sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -77,6 +82,8 @@ public class MusicPlayer {
                        this.status = "paused"
                        sendEvent([name: "status", value: "paused", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.paused", value: "paused", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
        def play() {
@@ -85,6 +92,8 @@ public class MusicPlayer {
                        this.status = "playing"
                        sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
        def playTrack(String trackToPlay) {
@@ -94,6 +103,8 @@ public class MusicPlayer {
                        this.status = "playing"
                        sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -109,6 +120,8 @@ public class MusicPlayer {
                        this.status = "playing"
                        sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -125,6 +138,8 @@ public class MusicPlayer {
                        this.status = "playing"
                        sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
        def setLevel(int level) {
@@ -142,6 +157,8 @@ public class MusicPlayer {
                        this.status = "playing"
                        sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -154,6 +171,18 @@ public class MusicPlayer {
                        this.status = "stopped"
                        sendEvent([name: "status", value: "stopped", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.stopped", value: "stopped", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+       def playText(String text) {
+               println("the music player with id:$id is playing the text:$text!")
+               if (status != "playing") {
+                       this.status = "playing"
+                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "status.playing", value: "playing", deviceId: this.id, descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -162,4 +191,10 @@ public class MusicPlayer {
                        return status
                }
        }
+
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "musicPlayer") {
+                       return status
+               }
+       }
 }
index bce3fc7d40612d6139e29c67317e41163df47b3a..486feeac79a9f468c945db62ec22eb3081d44322 100644 (file)
@@ -44,6 +44,9 @@ public class MusicPlayers {
                } else {
                        this.status = "stopped"
                }
+<<<<<<< HEAD
+
+=======
                def initTrack = Verify.getIntFromList(1, 2, 3)
                this.trackNumber = initTrack 
                def initData = Verify.getBoolean()
@@ -58,6 +61,7 @@ public class MusicPlayers {
                } else {
                        this.trackDescription = "someOtherDescriptions"
                }*/
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                musicPlayers.add(new MusicPlayer(sendEvent, id, label, displayName, this.level, this.mute, this.status, this.trackNumber, this.trackData, this.trackDescription))
        }
 
@@ -65,32 +69,32 @@ public class MusicPlayers {
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["name"] == "status") {
                        if (eventDataMap["value"] != musicPlayers[0].status) {
+                               this.status = eventDataMap["value"]
                                musicPlayers[0].setValue(eventDataMap["value"], "status")
-                               this.status = musicPlayers[0].status
                                sendEvent(eventDataMap)
                        }       
                } else if (eventDataMap["name"] == "level") {
-                       if (eventDataMap["value"] != musicPlayers[0].level) {
+                       if (eventDataMap["value"].toInteger() != musicPlayers[0].level) {
+                               this.level = eventDataMap["value"].toInteger()
                                musicPlayers[0].setValue(eventDataMap["value"], "level")
-                               this.level = musicPlayers[0].level
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "trackDescription") {
                        if (eventDataMap["value"] != musicPlayers[0].trackDescription) {
+                               this.trackDescription = eventDataMap["value"]
                                musicPlayers[0].setValue(eventDataMap["value"], "trackDescription")
-                               this.trackDescription = musicPlayers[0].trackDescription
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "trackData") {
                        if (eventDataMap["value"] != musicPlayers[0].trackData) {
-                               musicPlayers[0].setValue(eventDataMap["value"], "trackData")
-                               this.trackData = musicPlayers[0].trackData
+                               this.trackData = eventDataMap["value"]
+                               musicPlayers[0].setValue(eventDataMap["value"], "trackData")                            
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "mute") {
                        if (eventDataMap["value"] != musicPlayers[0].mute) {
+                               this.mute = eventDataMap["value"]
                                musicPlayers[0].setValue(eventDataMap["value"], "mute")
-                               this.mute = musicPlayers[0].mute
                                sendEvent(eventDataMap)
                        }
                }
@@ -109,6 +113,9 @@ public class MusicPlayers {
        def find(Closure Input) {
                musicPlayers.find(Input)
        }
+       def sort(Closure Input) {
+               musicPlayers.sort(Input)
+       }
        def collect(Closure Input) {
                musicPlayers.collect(Input)
        }
@@ -116,76 +123,85 @@ public class MusicPlayers {
        //methods
        def mute() {
                if (mute != "muted") {
-                       musicPlayers[0].mute()
                        this.mute = "muted"
+                       musicPlayers[0].mute()
                }
        }
        def nextTrack() {
-               musicPlayers[0].nextTrack()
                if (status != "playing") {
                        this.status = "playing"
                }
-               this.trackNumber = musicPlayers[0].trackNumber
+               this.trackNumber = this.trackNumber+1
+               musicPlayers[0].nextTrack()
        }
        def pause() {
                if (status != "paused") {
-                       musicPlayers[0].pause()
                        this.status = "paused"
+                       musicPlayers[0].pause()                 
                }
        }
        def play() {
                if (status != "playing") {
-                       musicPlayers[0].play()
                        this.status = "playing"
+                       musicPlayers[0].play()
                }
        }
        def playTrack(String trackToPlay) {
-               musicPlayers[0].playTrack(trackToPlay)
                if (status != "playing") {
                        this.status = "playing"
                }
-               this.trackNumber = musicPlayers[0].trackNumber
+               musicPlayers[0].playTrack(trackToPlay)
        }
        def previousTrack() {
-               musicPlayers[0].previousTrack()
                if (status != "playing") {
                        this.status = "playing"
                }
-               this.trackNumber = musicPlayers[0].trackNumber
+               if (this.trackNumber != 1)
+                       this.trackNumber = this.trackNumber-1
+               musicPlayers[0].previousTrack()
        }
        def restoreTrack(String trackToRestore) {
                musicPlayers[0].restoreTrack(trackToRestore)
        }
        def resumeTrack(String trackToResume) {
-               musicPlayers[0].resumeTrack(trackToResume)
                if (status != "playing") {
                        this.status = "playing"
                }
+               musicPlayers[0].resumeTrack(trackToResume)
        }
        def setLevel(int level) {
-               if (level != this.level) {              
+               if (level != this.level) {
+                       this.level = level      
                        musicPlayers[0].setLevel(level)
-                       this.level = level
                }
        }
        def setTrack(String trackToSet) {
-               musicPlayers[0].setTrack(trackToSet)
                if (status != "playing") {
                        this.status = "playing"
                }
-               this.trackNumber = musicPlayers[0].trackNumber
+               musicPlayers[0].setTrack(trackToSet)
        }
        def stop() {
                if (status != "stopped") {
-                       musicPlayers[0].stop()
                        this.status = "stopped"
+                       musicPlayers[0].stop()
                }
        }
+       def playText(String text) {
+               if (status != "playing") {
+                       this.status = "playing"
+               }
+               musicPlayers[0].playText(text)
+       }
 
        def currentValue(String deviceFeature) {
                musicPlayers[0].currentValue(deviceFeature)
        }
 
+       def latestValue(String deviceFeature) {
+               musicPlayers[0].latestValue(deviceFeature)
+       }
+
        def getAt(int ix) {
                musicPlayers[ix]
        }
index 212d5fabb8401db65772ca3b977cca1aa6ad652d..a0915ea940e0f68a93dc67fac15ef5842c4f6410 100644 (file)
@@ -29,4 +29,10 @@ public class PowerMeter {
                }
        }
 
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "power") {
+                       return power
+               }
+       }
+
 }
index 4b4f1937a233243b71fe653e4142cc6102363151..836218299f018ae5026547b9e1f34629535c838f 100644 (file)
@@ -31,10 +31,10 @@ public class PowerMeters {
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != powerMeters[0].power) {
+               if (eventDataMap["value"].toInteger() != powerMeters[0].power) {
+                       this.power = eventDataMap["value"].toInteger()
+                       this.currentPower = eventDataMap["value"].toInteger()
                        powerMeters[0].setValue(eventDataMap["value"])
-                       this.power = powerMeters[0].power
-                       this.currentPower = powerMeters[0].currentPower
                        sendEvent(eventDataMap)
                }
        }
@@ -52,6 +52,9 @@ public class PowerMeters {
        def find(Closure Input) {
                powerMeters.find(Input)
        }
+       def sort(Closure Input) {
+               powerMeters.sort(Input)
+       }
        def collect(Closure Input) {
                powerMeters.collect(Input)
        }
@@ -61,6 +64,10 @@ public class PowerMeters {
                powerMeters[0].currentValue(deviceFeature)//It is called if we have only one device
        }
 
+       def latestValue(String deviceFeature) {
+               powerMeters[0].latestValue(deviceFeature)//It is called if we have only one device
+       }
+
        def getAt(int ix) {
                powerMeters[ix]
        }
index 5f15a6f60febaf7ba031d4eca8721707ad7ebf3b..c1553fb942d1ac05e3d71d7c02ea40ac306c39e9 100644 (file)
@@ -20,8 +20,8 @@ public class PresenceSensor {
        }
 
        def setValue(String value) {
-               this.presenceLatestValue = presence
                println("the presence sensor with id:$id is triggered to $value!")
+               this.presenceLatestValue = value
                this.presence = value
                this.currentPresence = value
        }
index 05721d5b1ec58da4a5d29fcda8e556d27def909f..ec24f3b0c675ebf8433a0a42b279701a5ae9c2ae 100644 (file)
@@ -38,10 +38,10 @@ public class PresenceSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != presenceSensors[0].presence) {
+                       this.presenceLatestValue = eventDataMap["value"]
+                       this.presence = eventDataMap["value"]
+                       this.currentPresence = eventDataMap["value"]
                        presenceSensors[0].setValue(eventDataMap["value"])
-                       this.presenceLatestValue = presenceSensors[0].presenceLatestValue
-                       this.presence = presenceSensors[0].presence
-                       this.currentPresence = presenceSensors[0].presence
                        sendEvent(eventDataMap)
                }
        }
@@ -59,6 +59,9 @@ public class PresenceSensors {
        def find(Closure Input) {
                presenceSensors.find(Input)
        }
+       def sort(Closure Input) {
+               presenceSensors.sort(Input)
+       }
        def collect(Closure Input) {
                presenceSensors.collect(Input)
        }
index 083bd8fb97f2af306a467236017d4df933a4c963..c9ad722cf3859012e012549a5a9f9aa47afc47ea 100644 (file)
@@ -29,4 +29,9 @@ public class RelativeHumidityMeasurement {
                }
        }
 
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "humidity") {
+                       return humidity
+               }
+       }
 }
index 17da9b5b6105db3062859a37614691378901bf8d..7bee67627e85557eb190e36908c7c0001747396d 100644 (file)
@@ -31,10 +31,10 @@ public class RelativeHumidityMeasurements {
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != humidityMeasurements[0].humidity) {
-                       humidityMeasurements[0].setValue(eventDataMap["value"])
-                       this.humidity = humidityMeasurements[0].humidity
-                       this.currentHumidity = humidityMeasurements[0].currentHumidity          
+               if (eventDataMap["value"].toInteger() != humidityMeasurements[0].humidity) {
+                       this.humidity = eventDataMap["value"].toInteger()
+                       this.currentHumidity = eventDataMap["value"].toInteger()
+                       humidityMeasurements[0].setValue(eventDataMap["value"]) 
                        sendEvent(eventDataMap)
                }
        }
@@ -52,6 +52,9 @@ public class RelativeHumidityMeasurements {
        def find(Closure Input) {
                humidityMeasurements.find(Input)
        }
+       def sort(Closure Input) {
+               humidityMeasurements.sort(Input)
+       }
        def collect(Closure Input) {
                humidityMeasurements.collect(Input)
        }
@@ -61,6 +64,10 @@ public class RelativeHumidityMeasurements {
                humidityMeasurements[0].currentValue(deviceFeature)//It is called if we have only one device
        }
 
+       def latestValue(String deviceFeature) {
+               humidityMeasurements[0].latestValue(deviceFeature)//It is called if we have only one device
+       }
+
        def getAt(int ix) {
                humidityMeasurements[ix]
        }
index b418477477944dc7c93dd4a68af616cde5ec5bbd..137d7ad837d24533fee2d6ae95f4be1bc3c2d4ff 100644 (file)
@@ -28,11 +28,13 @@ public class RelaySwitch {
        def on() {
                if (switchState != "on") {
                        println("the relay switch with id:$id is on!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "on"
                        this.switchState = "on"
                        this.currentSwitch = "on"
                        sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
-                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: [value: "on"]])
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -40,11 +42,13 @@ public class RelaySwitch {
                if (switchState != "on") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the relay switch with id:$id is on!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "on"
                                this.switchState = "on"
                                this.currentSwitch = "on"
                                sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+                                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -52,11 +56,13 @@ public class RelaySwitch {
        def off() {
                if (switchState != "off") {
                        println("the relay switch with id:$id is off!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "off"
                        this.switchState = "off"
                        this.currentSwitch = "off"
                        sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+                                 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -64,11 +70,13 @@ public class RelaySwitch {
                if (switchState != "off") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the relay switch with id:$id is off!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "off"
                                this.switchState = "off"
                                this.currentSwitch = "off"
                                sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+                                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -76,7 +84,7 @@ public class RelaySwitch {
        //By Model Checker
        def setValue(String value) {
                println("the relay switch with id:$id is $value!")
-               this.switchLatestValue = this.switchState
+               this.switchLatestValue = value
                this.switchState = value
                this.currentSwitch = value
        }
index d9615e2f8a64110f92506ee0b6999f2517e06a7d..e7b6e0080bd68b95e0d4a67f3cb214165e9076d0 100644 (file)
@@ -51,6 +51,9 @@ public class RelaySwitches {
        def find(Closure Input) {
                relaySwitches.find(Input)
        }
+       def sort(Closure Input) {
+               relaySwitches.sort(Input)
+       }
        def collect(Closure Input) {
                relaySwitches.collect(Input)
        }
@@ -58,40 +61,40 @@ public class RelaySwitches {
        //By Apps
        def on() {
                if (switchState != "on") {
-                       relaySwitches[0].on()
-                       switchLatestValue = switchState
+                       switchLatestValue = "on"
                        switchState = "on"
                        currentSwitch = "on"
+                       relaySwitches[0].on()
                }
        }
 
        def on(LinkedHashMap metaData) {
                if (switchState != "on") {
                        def task = timers.runAfter(metaData["delay"]) {
-                               relaySwitches[0].on()
-                               switchLatestValue = switchState
+                               switchLatestValue = "on"
                                switchState = "on"
                                currentSwitch = "on"
+                               relaySwitches[0].on()
                        }
                }
        }
 
        def off() {
                if (switchState != "off") {
-                       relaySwitches[0].off()
-                       switchLatestValue = switchState
+                       switchLatestValue = "off"
                        switchState = "off"
                        currentSwitch = "off"
+                       relaySwitches[0].off()
                }
        }
 
        def off(LinkedHashMap metaData) {
                if (switchState != "off") {
                        def task = timers.runAfter(metaData["delay"]) {
-                               relaySwitches[0].off()
-                               switchLatestValue = switchState
+                               switchLatestValue = "off"
                                switchState = "off"
                                currentSwitch = "off"
+                               relaySwitches[0].off()
                        }
                }
        }
@@ -99,9 +102,9 @@ public class RelaySwitches {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != relaySwitches[0].switchState) {
+                       this.switchState = eventDataMap["value"]
+                       this.switchLatestValue = eventDataMap["value"]
                        relaySwitches[0].setValue(eventDataMap["value"])
-                       this.switchState = relaySwitches[0].switchState
-                       this.switchLatestValue = relaySwitches[0].switchLatestValue
                        sendEvent(eventDataMap)
                }
        }
index d72844dbe2d2be08adace65a80fcfab232280238..6f8bd4def5599b5c28792704c7248d8e5fae598e 100644 (file)
--- a/Runner.py
+++ b/Runner.py
@@ -29,6 +29,8 @@ runEvery15Minutes = open("Methods/"+"runEvery15Minutes.groovy", "r")
 timeToday = open("Methods/"+"timeToday.groovy", "r")
 sendNotification = open("Methods/"+"sendNotification.groovy", "r")
 canSchedule = open("Methods/"+"canSchedule.groovy", "r")
+createAccessToken = open("Methods/"+"createAccessToken.groovy", "r")
+runOnce = open("Methods/"+"runOnce.groovy", "r")
 App1 = open("Extractor/"+"App1/App1.groovy", "r")
 extractedObjectsApp1 = open("Extractor/"+"App1/extractedObjectsApp1.groovy", "r")
 extractedObjectsConstructorApp1 = open("Extractor/"+"App1/extractedObjectsConstructorApp1.groovy", "r")
@@ -109,7 +111,6 @@ Out.write("import Valve.Valves\n")
 Out.write("import MobilePresence.MobilePresence\n")
 Out.write("import MobilePresence.MobilePresences\n")
 Out.write("import Event.Event\n")
-Out.write("import AtomicState.AtomicState\n")
 Out.write("import Timer.SimulatedTimer\n")
 Out.write("\n")
 Out.write("//JPF's Verify API\n")
@@ -128,7 +129,6 @@ Out.write("class App1 {\n")
 Out.write("\tdef reference\n")
 Out.write("\tdef location\n")
 Out.write("\tdef app\n")
-Out.write("\tdef atomicState\n")
 Out.write("\n")
 Out.write("\t//Extracted objects for App1\n")
 for line in extractedObjectsApp1:
@@ -142,7 +142,6 @@ Out.write("\tApp1(Object obj) {\n")
 Out.write("\t\treference = obj\n")
 Out.write("\t\tlocation = obj.locationObject\n")
 Out.write("\t\tapp = obj.appObject\n")
-Out.write("\t\tatomicState = obj.atomicState\n")
 for line in extractedObjectsConstructorApp1:
        Out.write("\t\t"+line)
 Out.write("\t}\n")
@@ -183,6 +182,10 @@ for line in sendNotification:
        Out.write("\t"+line)
 for line in canSchedule:
        Out.write("\t"+line)
+for line in createAccessToken:
+       Out.write("\t"+line)
+for line in runOnce:
+       Out.write("\t"+line)
 Out.write("\n")
 Start = 0
 for line in App1:
@@ -214,6 +217,8 @@ runEvery15Minutes = open("Methods/"+"runEvery15Minutes.groovy", "r")
 timeToday = open("Methods/"+"timeToday.groovy", "r")
 sendNotification = open("Methods/"+"sendNotification.groovy", "r")
 canSchedule = open("Methods/"+"canSchedule.groovy", "r")
+createAccessToken = open("Methods/"+"createAccessToken.groovy", "r")
+runOnce = open("Methods/"+"runOnce.groovy", "r")
 App2 = open("Extractor/"+"App2/App2.groovy", "r")
 extractedObjectsApp2 = open("Extractor/"+"App2/extractedObjectsApp2.groovy", "r")
 extractedObjectsConstructorApp2 = open("Extractor/"+"App2/extractedObjectsConstructorApp2.groovy", "r")
@@ -224,7 +229,6 @@ Out.write("class App2 {\n")
 Out.write("\tdef reference\n")
 Out.write("\tdef location\n")
 Out.write("\tdef app\n")
-Out.write("\tdef atomicState\n")
 Out.write("\n")
 Out.write("\t//Extracted objects for App2\n")
 for line in extractedObjectsApp2:
@@ -238,7 +242,6 @@ Out.write("\tApp2(Object obj) {\n")
 Out.write("\t\treference = obj\n")
 Out.write("\t\tlocation = obj.locationObject\n")
 Out.write("\t\tapp = obj.appObject\n")
-Out.write("\t\tatomicState = obj.atomicState\n")
 for line in extractedObjectsConstructorApp2:
        Out.write("\t\t"+line)
 Out.write("\t}\n")
@@ -279,6 +282,10 @@ for line in sendNotification:
        Out.write("\t"+line)
 for line in canSchedule:
        Out.write("\t"+line)
+for line in createAccessToken:
+       Out.write("\t"+line)
+for line in runOnce:
+       Out.write("\t"+line)
 Out.write("\n")
 Start = 0
 for line in App2:
index 32895c804919fcd27475f0d3539d24f227415268..fc26621c1f1d586a8d2632987ef05b75c7b849dc 100644 (file)
@@ -34,8 +34,8 @@ public class SleepSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != sleepSensors[0].sleeping) {
+                       this.sleeping = eventDataMap["value"]
                        sleepSensors[0].setValue(eventDataMap["value"])
-                       this.sleeping = sleepSensors[0].sleeping
                        sendEvent(eventDataMap)
                }
        }
@@ -53,6 +53,9 @@ public class SleepSensors {
        def find(Closure Input) {
                sleepSensors.find(Input)
        }
+       def sort(Closure Input) {
+               sleepSensors.sort(Input)
+       }
        def collect(Closure Input) {
                sleepSensors.collect(Input)
        }
index 3182cc3a62442c831e2e8fa7e8a8886cda90a078..07b6764d1e43e6859569900cde1fc955a41e6719 100644 (file)
@@ -9,33 +9,63 @@ public class SmokeDetector {
        private String smoke
        private String currentSmokeValue
        private String smokeLatestValue
+       private String carbonMonoxide
+       private String currentCarbonMonoxideValue
+       private String carbonMonoxideLatestValue
+       private int battery
+       private int batteryLatestValue
 
-       SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue) {
+       SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue, String carbonMonoxide, String carbonMonoxideLatestValue, int battery) {
                this.id = id
                this.label = label
                this.displayName = displayName
                this.smoke = smoke
                this.currentSmokeValue = smoke
                this.smokeLatestValue = smokeLatestValue
+               this.carbonMonoxide = carbonMonoxide
+               this.currentCarbonMonoxideValue = currentCarbonMonoxideValue
+               this.carbonMonoxideLatestValue = carbonMonoxideLatestValue
+               this.battery = battery
+               this.batteryLatestValue = battery
        }
 
-       def setValue(String value) {
-               this.smokeLatestValue = smoke
-               println("the smoke detector with id:$id is triggered to $value!")
-               this.smoke = value
-               this.currentSmokeValue = value
+       def setValue(String value, String name) {
+               if (name.contains("smoke")) {
+                       println("the smoke value of smoke detector with id:$id is triggered to $value!")
+                       this.smokeLatestValue = value
+                       this.smoke = value
+                       this.currentSmokeValue = value
+               } else if (name.contains("carbonMonoxide")) {
+                       println("the carbonMonoxide value of smoke detector with id:$id is triggered to $value!")
+                       this.carbonMonoxideLatestValue = value
+                       this.carbonMonoxide = value
+                       this.currentCarbonMonoxideValue = value
+               } else if (name.contains("battery")) {
+                       println("the battery value of smoke detector with id:$id is triggered to $value!")
+                       this.batteryLatestValue = value.toInteger()
+                       this.battery = value.toInteger()
+               }
+               
        }
 
        
        def currentValue(String deviceFeature) {
                if (deviceFeature == "smoke") {
                        return currentSmokeValue
+               } else if (deviceFeature == "carbonMonoxide") {
+                       return currentCarbonMonoxideValue
+               } else if (deviceFeature == "battery") {
+                       return battery
                }
        }
 
        def latestValue(String deviceFeature) {
                if (deviceFeature == "smoke") {
                        return smokeLatestValue
+               } else if (deviceFeature == "carbonMonoxide") {
+                       return carbonMonoxideLatestValue
+               } else if (deviceFeature == "battery") {
+                       return batteryLatestValue
                }
        }
 }
index 2bbc41d5706704716753b6c2ec91bd7b350050a3..94c6176d2e79272524931b0b7a8bee1ce1a45736 100644 (file)
@@ -17,6 +17,11 @@ public class SmokeDetectors {
        private String smoke = "clear"
        private String currentSmokeValue = "clear"
        private String smokeLatestValue = "clear"
+       private String carbonMonoxide = "clear"
+       private String currentCarbonMonoxideValue = "clear"
+       private String carbonMonoxideLatestValue = "clear"
+       private int battery = 50
+       private int batteryLatestValue = 50
 
                
        SmokeDetectors(Closure sendEvent, int deviceNumbers) {
@@ -24,28 +29,72 @@ public class SmokeDetectors {
                this.deviceNumbers = deviceNumbers
                this.smokeDetectors = []
 
+<<<<<<< HEAD
+               def initBattery = Verify.getIntFromList(30, 50, 70)
+               this.battery = initBattery
+               this.batteryLatestValue = initBattery
+
+               def initSmoke = Verify.getInt(0,2)
+               if (initSmoke == 0) {
+=======
                /*def init = Verify.getInt(0,2)
                if (init == 0) {
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                        this.currentSmokeValue = "clear"
                        this.smokeLatestValue = "clear"
-               } else if (init == 1) {
+               } else if (initSmoke == 1) {
                        this.currentSmokeValue = "detected"
                        this.smokeLatestValue = "detected"
                } else {
                        this.currentSmokeValue = "tested"
                        this.smokeLatestValue = "tested"                
+<<<<<<< HEAD
+               }
+
+               def initCarbonMonoxide = Verify.getInt(0,2)
+               if (initCarbonMonoxide == 0) {
+                       this.currentCarbonMonoxideValue = "clear"
+                       this.carbonMonoxideLatestValue = "clear"
+               } else if (initCarbonMonoxide == 1) {
+                       this.currentCarbonMonoxideValue = "detected"
+                       this.carbonMonoxideLatestValue = "detected"
+               } else {
+                       this.currentCarbonMonoxideValue = "tested"
+                       this.carbonMonoxideLatestValue = "tested"               
+               }
+               smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue, this.currentCarbonMonoxideValue,
+                                                     this.carbonMonoxideLatestValue, this.battery))
+=======
                }*/
                smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue))
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
        }
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != smokeDetectors[0].currentSmokeValue) {
-                       smokeDetectors[0].setValue(eventDataMap["value"])
-                       this.smokeLatestValue = smokeDetectors[0].smokeLatestValue
-                       this.smoke = smokeDetectors[0].currentSmokeValue
-                       this.currentSmokeValue = smokeDetectors[0].currentSmokeValue
-                       sendEvent(eventDataMap)
+               if (eventDataMap["name"].contains("smoke")) {
+                       if (eventDataMap["value"] != smokeDetectors[0].currentSmokeValue) {
+                               this.smokeLatestValue = eventDataMap["value"]
+                               this.smoke = eventDataMap["value"]
+                               this.currentSmokeValue = eventDataMap["value"]
+                               smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"].contains("carbonMonoxide")) {
+                       if (eventDataMap["value"] != smokeDetectors[0].currentCarbonMonoxideValue) {
+                               this.carbonMonoxideLatestValue = eventDataMap["value"]
+                               this.carbonMonoxide = eventDataMap["value"]
+                               this.currentCarbonMonoxideValue = eventDataMap["value"]
+                               smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"].contains("battery")) {
+                       if (eventDataMap["value"].toInteger() != smokeDetectors[0].battery) {
+                               this.battery = eventDataMap["value"].toInteger()
+                               this.batteryLatestValue = eventDataMap["value"].toInteger()
+                               smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+                               sendEvent(eventDataMap)
+                       }
                }
        }
 
@@ -62,6 +111,9 @@ public class SmokeDetectors {
        def find(Closure Input) {
                smokeDetectors.find(Input)
        }
+       def sort(Closure Input) {
+               smokeDetectors.sort(Input)
+       }
        def collect(Closure Input) {
                smokeDetectors.collect(Input)
        }
index 369a8ac1fd2b7f444377d73df8a5fbec2397b1db..2a125987d1806787f72821694a14bda378ab40fd 100644 (file)
@@ -41,14 +41,17 @@ public class SpeechSynthesises {
        def find(Closure Input) {
                speechSynthesises.find(Input)
        }
+       def sort(Closure Input) {
+               speechSynthesises.sort(Input)
+       }
        def collect(Closure Input) {
                speechSynthesises.collect(Input)
        }
 
        def setLevel(int level) {
                if (level != this.level) {
-                       speechSynthesises[0].setLevel(level)
                        this.level = level
+                       speechSynthesises[0].setLevel(level)
                }
        }
 
index cc709fe704b507f0cf161124947767c1aab26f90..021db256317e3006a4bf8b86ecbf2d3f8305604e 100644 (file)
@@ -34,15 +34,15 @@ public class StepSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["name"] == "steps") {
-                       if (eventDataMap["value"] != stepSensors[0].steps) {
+                       if (eventDataMap["value"].toInteger() != stepSensors[0].steps) {
+                               this.steps = eventDataMap["value"].toInteger()
                                stepSensors[0].setValue(eventDataMap["value"], "steps")
-                               this.steps = stepSensors[0].steps
                                sendEvent(eventDataMap)
                        }
-               } else if (eventDataMap["value"] == "goal") {
-                       if (eventDataMap["value"] != stepSensors[0].goal) {
+               } else if (eventDataMap["name"] == "goal") {
+                       if (eventDataMap["value"].toInteger() != stepSensors[0].goal) {
+                               this.goal = eventDataMap["value"].toInteger()
                                stepSensors[0].setValue(eventDataMap["value"], "goal")
-                               this.goal = stepSensors[0].goal
                                sendEvent(eventDataMap)
                        }
                }
@@ -61,6 +61,9 @@ public class StepSensors {
        def find(Closure Input) {
                stepSensors.find(Input)
        }
+       def sort(Closure Input) {
+               stepSensors.sort(Input)
+       }
        def collect(Closure Input) {
                stepSensors.collect(Input)
        }
index b924d21d3ec3af148d91211fc041ad8db1c57253..aa3b2c52f841001c55416f8c5845bc71c2e0297d 100644 (file)
@@ -31,7 +31,7 @@ public class Switch {
                if (this.currentLevel != level) {
                        println("the switch with id:$id is setted to level $level!")
                        this.currentLevel = level
-                       sendEvent([name: "level", value: "40", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -39,11 +39,13 @@ public class Switch {
        def on() {
                if (this.switchState != "on") {
                        println("the switch with id:$id is on!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "on"
                        this.switchState = "on"
                        this.currentSwitch = "on"
                        sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -51,11 +53,13 @@ public class Switch {
                if (this.switchState != "on") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the switch with id:$id is on!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "on"
                                this.switchState = "on"
                                this.currentSwitch = "on"
                                sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
                                    displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -63,11 +67,13 @@ public class Switch {
        def off() {
                if (this.switchState != "off") {
                        println("the switch with id:$id is off!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "off"
                        this.switchState = "off"
                        this.currentSwitch = "off"
                        sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -75,11 +81,13 @@ public class Switch {
                if (this.switchState != "off") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the switch with id:$id is off!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "off"
                                this.switchState = "off"
                                this.currentSwitch = "off"
                                sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
                                    displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -87,7 +95,7 @@ public class Switch {
        //By Model Checker
        def setValue(String value) {
                println("the switch with id:$id is $value!")
-               this.switchLatestValue = this.switchState
+               this.switchLatestValue = value
                this.switchState = value
                this.currentSwitch = value
        }
index 8c57869b54aadf78c3271ebc78409fc401f18cdf..5a2754042f05a585db006b4cf0326bcc38e457af 100644 (file)
@@ -55,54 +55,57 @@ public class Switches {
        def find(Closure Input) {
                switches.find(Input)
        }
+       def sort(Closure Input) {
+               switches.sort(Input)
+       }
        def collect(Closure Input) {
                switches.collect(Input)
        }
 
        //By Apps
        def setLevel(int level) {
-               switches[0].setLevel(level)
                currentLevel = level
+               switches[0].setLevel(level)
        }
 
        def on() {
-               switches[0].on()
-               switchLatestValue = switchState
+               switchLatestValue = "on"
                switchState = "on"
                currentSwitch = "on"
+               switches[0].on()
        }
 
        def on(LinkedHashMap metaData) {
                def task = timers.runAfter(metaData["delay"]) {
-                       switches[0].on()
-                       switchLatestValue = switchState
+                       switchLatestValue = "on"
                        switchState = "on"
                        currentSwitch = "on"
+                       switches[0].on()
                }
        }
 
        def off() {
-               switches[0].off()
-               switchLatestValue = switchState
+               switchLatestValue = "off"
                switchState = "off"
                currentSwitch = "off"
+               switches[0].off()
        }
 
        def off(LinkedHashMap metaData) {
                def task = timers.runAfter(metaData["delay"]) {
-                       switches[0].off()
-                       switchLatestValue = switchState
+                       switchLatestValue = "off"
                        switchState = "off"
                        currentSwitch = "off"
+                       switches[0].off()
                }
        }
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != switches[0].switchState) {
+                       this.switchState = eventDataMap["value"]
+                       this.switchLatestValue = eventDataMap["value"]
                        switches[0].setValue(eventDataMap["value"])
-                       this.switchState = switches[0].switchState
-                       this.switchLatestValue = switches[0].switchLatestValue
                        sendEvent(eventDataMap)
                }
        }
index 4b7acbf9d7ce495ffb2957c7f9e33a48179e0209..ff83a50e86a0c8c51b96499b252f2aa7b4c9943b 100644 (file)
@@ -34,7 +34,7 @@ public class SwitchLevel {
                        println("the switch with id:$id is setted to level $level!")
                        this.level = level
                        this.rate = level
-                       sendEvent([name: "level", value: "50", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -42,11 +42,13 @@ public class SwitchLevel {
        def on() {
                if (this.switchState != "on") {
                        println("the switch with id:$id is on!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "on"
                        this.switchState = "on"
                        this.currentSwitch = "on"
                        sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -54,11 +56,13 @@ public class SwitchLevel {
                if (this.switchState != "on") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the switch with id:$id is on!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "on"
                                this.switchState = "on"
                                this.currentSwitch = "on"
                                sendEvent([name: "switch", value: "on", deviceId: this.id, descriptionText: "",
                                    displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "switch.on", value: "on", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -66,11 +70,13 @@ public class SwitchLevel {
        def off() {
                if (this.switchState != "off") {
                        println("the switch with id:$id is off!")
-                       this.switchLatestValue = this.switchState
+                       this.switchLatestValue = "off"
                        this.switchState = "off"
                        this.currentSwitch = "off"
                        sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -78,11 +84,13 @@ public class SwitchLevel {
                if (this.switchState != "off") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the switch with id:$id is off!")
-                               this.switchLatestValue = this.switchState
+                               this.switchLatestValue = "off"
                                this.switchState = "off"
                                this.currentSwitch = "off"
                                sendEvent([name: "switch", value: "off", deviceId: this.id, descriptionText: "",
                                    displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "switch.off", value: "off", deviceId: this.id, descriptionText: "",
+                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
index 4ace3612708741914db1dd0d13f155c5b065836e..591611a6e8394be165e964960d50e86805dfd3ac 100644 (file)
@@ -55,6 +55,9 @@ public class SwitchLevels {
        def find(Closure Input) {
                switchLevels.find(Input)
        }
+       def sort(Closure Input) {
+               switchLevels.sort(Input)
+       }
        def collect(Closure Input) {
                switchLevels.collect(Input)
        }
@@ -69,43 +72,43 @@ public class SwitchLevels {
        }
 
        def on() {
-               switchLevels[0].on()
-               switchLatestValue = switchState
+               switchLatestValue = "on"
                switchState = "on"
                currentSwitch = "on"
+               switchLevels[0].on()
        }
 
        def on(LinkedHashMap metaData) {
                def task = timers.runAfter(metaData["delay"]) {
-                       switchLevels[0].on()
-                       switchLatestValue = switchState
+                       switchLatestValue = "on"
                        switchState = "on"
                        currentSwitch = "on"
+                       switchLevels[0].on()
                }
        }
 
        def off() {
-               switchLevels[0].off()
-               switchLatestValue = switchState
+               switchLatestValue = "off"
                switchState = "off"
                currentSwitch = "off"
+               switchLevels[0].off()
        }
 
        def off(LinkedHashMap metaData) {
                def task = timers.runAfter(metaData["delay"]) {
-                       switchLevels[0].off()
-                       switchLatestValue = switchState
+                       switchLatestValue = "off"
                        switchState = "off"
                        currentSwitch = "off"
+                       switchLevels[0].off()
                }
        }
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != switchLevels[0].level) {
+               if (eventDataMap["value"].toInteger() != switchLevels[0].level) {
+                       this.level = eventDataMap["value"].toInteger()
+                       this.rate = eventDataMap["value"].toInteger()
                        switchLevels[0].setValue(eventDataMap["value"])
-                       this.level = switchLevels[0].level
-                       this.rate = switchLevels[0].level
                        sendEvent(eventDataMap)
                }
        }
index fcee39a23f1ae395e78f1884c6f41462e26eb717..afcb768b9882ca7f4728396348f2ed19ee22c93c 100644 (file)
@@ -7,18 +7,21 @@ public class TemperatureMeasurement {
        private String label
        private String displayName
        private int temperature
+       private int currentTemperature
 
        TemperatureMeasurement(String id, String label, String displayName, int temperature) {
                this.id = id
                this.label = label
                this.displayName = displayName
                this.temperature = temperature
+               this.currentTemperature = temperature
        }
 
        //By Model Checker
        def setValue(String value) {
                println("the temperature is changed to $value!")
                this.temperature = value.toInteger()
+               this.currentTemperature = value.toInteger()
        }
 
 }
index 15119cc38c6bd9e4484c5f4a23eb3cc8f46298d2..20d1f5af01bd44c3dd2259eff76a0a8e044edd86 100644 (file)
@@ -15,6 +15,11 @@ public class TemperatureMeasurements {
        private String label = "temperatureMeasurement0"
        private String displayName = "temperatureMeasurement0"
        private int temperature = 50
+<<<<<<< HEAD
+       private int currentTemperature = 50
+
+=======
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
        
        TemperatureMeasurements(Closure sendEvent, int deviceNumbers) {
                this.sendEvent = sendEvent              
@@ -29,9 +34,10 @@ public class TemperatureMeasurements {
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != temperatureMeasurements[0].temperature) {
+               if (eventDataMap["value"].toInteger() != temperatureMeasurements[0].temperature) {
+                       this.temperature = eventDataMap["value"].toInteger()
+                       this.currentTemperature = eventDataMap["value"].toInteger()
                        temperatureMeasurements[0].setValue(eventDataMap["value"])
-                       this.temperature = temperatureMeasurements[0].temperature
                        sendEvent(eventDataMap)
                }
        }
@@ -49,6 +55,9 @@ public class TemperatureMeasurements {
        def find(Closure Input) {
                temperatureMeasurements.find(Input)
        }
+       def sort(Closure Input) {
+               temperatureMeasurements.sort(Input)
+       }
        def collect(Closure Input) {
                temperatureMeasurements.collect(Input)
        }
index bd9ede1f9c1f7bdedf2a2416c8cb662b7e8d4782..b3f68b41f9319a1d231934393d4214fb46c80e7a 100644 (file)
@@ -7,11 +7,15 @@ public class Thermostat {
        private String label
        private String displayName
        private int temperature
+       private int currentTemperature
        private int currentCoolingSetpoint
        private int currentHeatingSetpoint
        private int coolingSetpoint
+       private int latestCoolingSetPoint
        private int thermostatSetpoint
+       private int latestThermostatSetPoint
        private int heatingSetpoint
+       private int latestHeatingSetPoint
        private List coolingSetpointRange
        private List thermostatSetpointRange
        private List heatingSetpointRange
@@ -22,6 +26,9 @@ public class Thermostat {
        private String thermostatMode
        private String currentThermostatMode
        private String climateName
+       private String thermostatLatestMode
+       private String thermostatLatestOperatingState
+       private String thermostatLatestFanMode
        def sendEvent
        def timers
 
@@ -29,11 +36,13 @@ public class Thermostat {
        Thermostat(Closure sendEvent, String id, String label, String displayName, int temperature, int currentCoolingSetpoint, int currentHeatingSetpoint, int coolingSetpoint, 
                    int thermostatSetpoint, int heatingSetpoint, List coolingSetpointRange, List thermostatSetpointRange, List heatingSetpointRange, 
                    List supportedThermostatFanModes, List supportedThermostatModes, String thermostatOperatingState, String thermostatFanMode, String thermostatMode,
-                  String climateName) {
+                  String climateName, String thermostatLatestMode, String thermostatLatestOperatingState, String thermostatLatestFanMode, int latestCoolingSetPoint,
+                  int latestThermostatSetPoint, int latestHeatingSetPoint) {
                this.id = id
                this.label = label
                this.sendEvent = sendEvent
                this.temperature = temperature
+               this.currentTemperature = currentTemperature
                this.currentCoolingSetpoint = currentCoolingSetpoint
                this.currentHeatingSetpoint = currentHeatingSetpoint
                this.coolingSetpoint = coolingSetpoint
@@ -49,12 +58,19 @@ public class Thermostat {
                this.thermostatMode = thermostatMode
                this.currentThermostatMode = thermostatMode
                this.climateName = climateName
+               this.thermostatLatestMode = thermostatLatestMode
+               this.thermostatLatestOperatingState = thermostatLatestOperatingState
+               this.thermostatLatestFanMode = thermostatLatestFanMode
+               this.latestHeatingSetPoint = latestHeatingSetPoint
+               this.latestThermostatSetPoint = latestThermostatSetPoint
+               this.latestCoolingSetPoint = latestCoolingSetPoint
        }
 
 
        //By Apps
        def setCoolingSetpoint(int coolingSetpoint) {
                if (this.coolingSetpoint != coolingSetpoint) {
+                       this.latestCoolingSetPoint = coolingSetpoint
                        this.coolingSetpoint = coolingSetpoint
                        this.currentCoolingSetpoint = currentCoolingSetpoint
                        println("Cooling set point for the thermostat with id:$id is changed to $coolingSetpoint!")
@@ -63,8 +79,13 @@ public class Thermostat {
                }
        }
 
+       def setCoolingSetpoint(String coolingSetpoint) {
+               setCoolingSetpoint(coolingSetpoint.toInteger())
+       }
+
        def setHeatingSetpoint(int heatingSetpoint) {
                if (this.heatingSetpoint != heatingSetpoint) {
+                       this.latestHeatingSetPoint = heatingSetpoint
                        this.heatingSetpoint = heatingSetpoint
                        this.currentHeatingSetpoint = currentHeatingSetpoint
                        println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!")
@@ -73,12 +94,17 @@ public class Thermostat {
                }
        }
 
+       def setHeatingSetpoint(String heatingSetpoint) {
+               setHeatingSetpoint(heatingSetpoint.toInteger())
+       }
+
        def setSchedule() {
                //Not implemented yet
        }
 
        def setThermostatFanMode(String thermostatFanMode) {
                if (this.thermostatFanMode != thermostatFanMode) {
+                       this.thermostatLatestFanMode = thermostatFanMode
                        this.thermostatFanMode = thermostatFanMode
                        println("Fan mode of the thermostat with id:$id is changed to $thermostatFanMode!")
                        sendEvent([name: "thermostatFanMode", value: "$thermostatFanMode", deviceId: this.id, descriptionText: "",
@@ -88,6 +114,7 @@ public class Thermostat {
 
        def setThermostatMode(String thermostatMode) {
                if (this.thermostatMode != thermostatMode) {
+                       this.thermostatLatestMode =thermostatMode
                        this.thermostatMode = thermostatMode
                        this.currentThermostatMode = currentThermostatMode
                        println("Mode of the thermostat with id:$id is changed to $thermostatMode!")
@@ -98,6 +125,7 @@ public class Thermostat {
 
        def cool() {
                if (this.thermostatMode != "cool") {
+                       this.thermostatLatestMode = "cool"
                        this.thermostatMode = "cool"
                        this.currentThermostatMode = "cool"
                        println("Mode of the thermostat with id:$id is changed to cool!")
@@ -108,6 +136,7 @@ public class Thermostat {
 
        def heat() {
                if (this.thermostatMode != "heat") {
+                       this.thermostatLatestMode = "heat"
                        this.thermostatMode = "heat"
                        this.currentThermostatMode = "heat"
                        println("Mode of the thermostat with id:$id is changed to heat!")
@@ -118,6 +147,7 @@ public class Thermostat {
 
        def auto() {
                if (this.thermostatMode != "auto") {
+                       this.thermostatLatestMode = "auto"
                        this.thermostatMode = "auto"
                        this.currentThermostatMode = "auto"
                        println("Mode of the thermostat with id:$id is changed to auto!")
@@ -128,6 +158,7 @@ public class Thermostat {
 
        def off() {
                if (this.thermostatMode != "off") {
+                       this.thermostatLatestMode = "off"
                        this.thermostatMode = "off"
                        this.currentThermostatMode = "off"
                        println("Mode of the thermostat with id:$id is changed to off!")
@@ -151,33 +182,74 @@ public class Thermostat {
                        this.heatingSetpoint = heatingSetpoint
                        this.currentHeatingSetpoint = currentHeatingSetpoint
                        println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!")
+                       sendEvent([name: "heatingSetpoint", value: "$heatingSetpoint", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "coolingSetpoint", value: "$coolingSetpoint", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
        //By Model Checker
        def setValue(String value, String name) {
-               if ((name == "temperature") && (value != this.temperature)) {
+               if ((name == "temperature") && (value.toInteger() != this.temperature)) {
                        println("the temperature is $value!")
                        this.temperature = value.toInteger()
-               } else if ((name == "heatingSetpoint") && (value != this.heatingSetpoint)) {
+                       this.currentTemperature = value.toInteger()
+               } else if ((name == "heatingSetpoint") && (value.toInteger() != this.heatingSetpoint)) {
                        println("the heating set point of the thermostat with id:$id is $value!")
+                       this.latestHeatingSetPoint = value.toInteger()
                        this.heatingSetpoint = value.toInteger()
-               } else if ((name == "coolingSetpoint") && (value != this.coolingSetpoint)) {
+               } else if ((name == "coolingSetpoint") && (value.toInteger() != this.coolingSetpoint)) {
                        println("the cooling set point of the thermostat with id:$id is $value!")
+                       this.latestCoolingSetPoint = value.toInteger()
                        this.coolingSetpoint = value.toInteger()
-               } else if ((name == "thermostatSetpoint") && (value != this.thermostatSetpoint)) {
+               } else if ((name == "thermostatSetpoint") && (value.toInteger() != this.thermostatSetpoint)) {
                        println("the set point of the thermostat with id:$id is $value!")
+                       this.latestThermostatSetPoint = value.toInteger()
                        this.thermostatSetpoint = value.toInteger()
                } else if ((name == "thermostatMode") && (value != this.thermostatMode)) {
                        println("the mode of the thermostat with id:$id is $value!")
+                       this.thermostatLatestMode = value
                        this.thermostatMode = value
                } else if ((name == "thermostatFanMode") && (value != this.thermostatFanMode)) {
                        println("the fan mode of the thermostat with id:$id is $value!")
+                       this.thermostatLatestFanMode = value
                        this.thermostatFanMode = value
                } else if ((name == "thermostatOperatingState") && (value != this.thermostatOperatingState)) {
                        println("the operating state of the thermostat with id:$id is $value!")
+                       this.thermostatLatestOperatingState = value
                        this.thermostatOperatingState = value
                }
        }
 
+       def currentValue(String deviceFeature) {
+               if (deviceFeature == "thermostatMode")
+                       return thermostatMode
+               else if (deviceFeature == "thermostatOperatingState")
+                       return thermostatOperatingState
+               else if (deviceFeature == "thermostatFanMode")
+                       return thermostatFanMode
+               else if (deviceFeature == "heatingSetpoint")
+                       return heatingSetpoint
+               else if (deviceFeature == "coolingSetpoint")
+                       return coolingSetpoint
+               else if (deviceFeature == "thermostatSetpoint")
+                       return thermostatSetpoint
+       }
+
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "thermostatMode")
+                       return thermostatLatestMode
+               else if (deviceFeature == "thermostatOperatingState")
+                       return thermostatLatestOperatingState
+               else if (deviceFeature == "thermostatFanMode")
+                       return thermostatLatestFanMode
+               else if (deviceFeature == "heatingSetpoint")
+                       return latestHeatingSetPoint
+               else if (deviceFeature == "coolingSetpoint")
+                       return latestCoolingSetPoint
+               else if (deviceFeature == "thermostatSetpoint")
+                       return latestThermostatSetPoint
+       }
+
 }
index 24d7b16abaf76a9c85a86120ceefd14328541218..80a643b6a5ae0be8fbdaa4961f354e617254fab2 100644 (file)
@@ -16,6 +16,7 @@ public class Thermostats{
        private String label = "thermostat0"
        private String displayName = "thermostat0"
        private int temperature = 66
+       private int currentTemperature = 66
        private int currentCoolingSetpoint = 70
        private int currentHeatingSetpoint = 50
        private int coolingSetpoint = 70
@@ -31,6 +32,13 @@ public class Thermostats{
        private String thermostatMode = "auto"
        private String currentThermostatMode = "auto"
        private String climateName = ""
+       private String thermostatLatestMode = "auto"
+       private String thermostatLatestOperatingState = "cooling"
+       private String thermostatLatestFanMode = "auto"
+       private int latestCoolingSetPoint = 70
+       private int latestThermostatSetPoint = 60
+       private int latestHeatingSetPoint = 50
+
 
        Thermostats(Closure sendEvent, int deviceNumbers) {
                this.sendEvent = sendEvent
@@ -40,6 +48,7 @@ public class Thermostats{
 
                /*def initTemperature = Verify.getIntFromList(60, 66, 70)
                this.temperature = initTemperature
+               this.currentTemperature = initTemperature
                
                def initCoolingSetpoint = Verify.getIntFromList(70, 80, 90)
                this.currentCoolingSetpoint = initCoolingSetpoint
@@ -55,38 +64,54 @@ public class Thermostats{
                def initFanMode = Verify.getInt(0,4)
                if (initFanMode == 0) {
                        this.thermostatFanMode = "auto"
+                       this.thermostatLatestFanMode = "auto"
                } else if (initFanMode == 1) {
                        this.thermostatFanMode = "fanCirculate"
+                       this.thermostatLatestFanMode = "fanCirculate"
                } else if (initFanMode == 2) {
                        this.thermostatFanMode = "circulate"
+                       this.thermostatLatestFanMode = "circulate"
                } else if (initFanMode == 3) {
                        this.thermostatFanMode = "fanOn"
+                       this.thermostatLatestFanMode = "fanOn"
                } else {
                        this.thermostatFanMode = "on"
+                       this.thermostatLatestFanMode = "on"
                }
 
                def initMode = Verify.getInt(0,4)
                if (initMode == 0) {
                        this.thermostatMode = "auto"
                        this.currentThermostatMode = "auto"
+                       this.thermostatLatestMode = "auto"
                } else if (initMode == 1) {
                        this.thermostatMode = "cool"
                        this.currentThermostatMode = "cool"
+                       this.thermostatLatestMode = "cool"
                } else if (initMode == 2) {
                        this.thermostatMode = "emergencyHeat"
                        this.currentThermostatMode = "emergencyHeat"
+                       this.thermostatLatestMode = "emergencyHeat"
                } else if (initMode == 3) {
                        this.thermostatMode = "heat"
                        this.currentThermostatMode = "heat"
+                       this.thermostatLatestMode = "heat"
                } else {
                        this.thermostatMode = "off"
                        this.currentThermostatMode = "off"
+<<<<<<< HEAD
+                       this.thermostatLatestMode = "off"
+               }
+=======
                }*/
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
 
                thermostats.add(new Thermostat(sendEvent, id, label, displayName, this.temperature, this.currentCoolingSetpoint, 
                                                this.currentHeatingSetpoint, this.coolingSetpoint, this.thermostatSetpoint, this.heatingSetpoint, this.coolingSetpointRange,
                                                this.thermostatSetpointRange, this.heatingSetpointRange, this.supportedThermostatFanModes, this.supportedThermostatModes,
-                                               this.thermostatOperatingState, this.thermostatFanMode,  this.thermostatMode, this.climateName))
+                                               this.thermostatOperatingState, this.thermostatFanMode,  this.thermostatMode, this.climateName, 
+                                              this.thermostatLatestMode, this.thermostatLatestOperatingState, this.thermostatLatestFanMode, this.latestCoolingSetPoint,
+                                              this.latestThermostatSetPoint, this.latestHeatingSetPoint))
        }
 
        //Methods for closures
@@ -102,6 +127,9 @@ public class Thermostats{
        def find(Closure Input) {
                thermostats.find(Input)
        }
+       def sort(Closure Input) {
+               thermostats.sort(Input)
+       }
        def collect(Closure Input) {
                thermostats.collect(Input)
        }
@@ -109,136 +137,167 @@ public class Thermostats{
        //By Apps
        def setCoolingSetpoint(int coolingSetpoint) {
                if (coolingSetpoint != this.coolingSetpoint) {
-                       thermostats[0].setCoolingSetpoint(coolingSetpoint)
+                       this.latestCoolingSetPoint = coolingSetpoint
                        this.currentCoolingSetpoint = coolingSetpoint
                        this.coolingSetpoint = coolingSetpoint
+                       thermostats[0].setCoolingSetpoint(coolingSetpoint)
                }
        }
 
+       def setCoolingSetpoint(String coolingSetpoint) {
+               setCoolingSetpoint(coolingSetpoint.toInteger())
+       }
+
        def setHeatingSetpoint(int heatingSetpoint) {
                if (heatingSetpoint != this.heatingSetpoint) {
-                       thermostats[0].setHeatingSetpoint(heatingSetpoint)
+                       this.latestHeatingSetPoint = heatingSetpoint
                        this.currentHeatingSetpoint = heatingSetpoint
                        this.heatingSetpoint = heatingSetpoint
+                       thermostats[0].setHeatingSetpoint(heatingSetpoint)
                }
        }
 
+       def setHeatingSetpoint(String heatingSetpoint) {
+               setHeatingSetpoint(heatingSetpoint.toInteger())
+       }
+
        def setSchedule() {
                //Not implemented yet
        }
 
        def setThermostatFanMode(String thermostatFanMode) {
                if (thermostatFanMode != this.thermostatFanMode) {
-                       thermostats[0].setThermostatFanMode(thermostatFanMode)
+                       this.thermostatLatestFanMode = thermostatFanMode
                        this.thermostatFanMode = thermostatFanMode
+                       thermostats[0].setThermostatFanMode(thermostatFanMode)
                }
        }
 
        def setThermostatMode(String thermostatMode) {
                if (thermostatMode != this.thermostatMode) {
-                       thermostats[0].setThermostatMode(thermostatMode)
+                       this.thermostatLatestMode = thermostatMode
                        this.thermostatMode = thermostatMode
                        this.currentThermostatMode = currentThermostatMode
+                       thermostats[0].setThermostatMode(thermostatMode)
                }
        }
 
        def cool() {
                if (thermostatMode != "cool") {
-                       thermostats[0].cool()
+                       this.thermostatLatestMode = "cool"
                        this.thermostatMode = "cool"
                        this.currentThermostatMode = "cool"
+                       thermostats[0].cool()
                }
        }
 
        def heat() {
                if (thermostatMode != "heat") {
-                       thermostats[0].heat()
+                       this.thermostatLatestMode = "heat"
                        this.thermostatMode = "heat"
                        this.currentThermostatMode = "heat"
+                       thermostats[0].heat()
                }
        }
 
        def auto() {
                if (thermostatMode != "auto") {
-                       thermostats[0].auto()
+                       this.thermostatLatestMode = "auto"
                        this.thermostatMode = "auto"
                        this.currentThermostatMode = "auto"
+                       thermostats[0].auto()
                }
        }
 
        def off() {
                if (thermostatMode != "off") {
-                       thermostats[0].off()
+                       this.thermostatLatestMode = "off"
                        this.thermostatMode = "off"
                        this.currentThermostatMode = "off"
+                       thermostats[0].off()
                }
        }
 
        def setClimate(String info, String givenClimateName) {
                if (givenClimateName != climateName) {
-                       thermostats[0].setClimate(info, givenClimateName)
                        this.climateName = givenClimateName
+                       thermostats[0].setClimate(info, givenClimateName)
                }
        }
 
        def setHold(String info1, int coolingSetpoint, int heatingSetpoint, String info2, String info3) {
                if ((coolingSetpoint != this.coolingSetpoint) || (heatingSetpoint != this.heatingSetpoint)) {
-                       thermostats[0].setHold(info1, coolingSetpoint, heatingSetpoint, info2, info3)
                        this.currentCoolingSetpoint = coolingSetpoint
                        this.coolingSetpoint = coolingSetpoint
                        this.currentHeatingSetpoint = heatingSetpoint
                        this.heatingSetpoint = heatingSetpoint
+                       thermostats[0].setHold(info1, coolingSetpoint, heatingSetpoint, info2, info3)
                }
        }
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["name"] == "temperature") {
-                       if (eventDataMap["value"] != thermostats[0].temperature) {
+                       if (eventDataMap["value"].toInteger() != thermostats[0].temperature) {
+                               this.temperature = eventDataMap["value"].toInteger()
+                               this.currentTemperature = eventDataMap["value"].toInteger()
                                thermostats[0].setValue(eventDataMap["value"], "temperature")
-                               this.temperature = thermostats[0].temperature
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "heatingSetpoint") {
-                       if (eventDataMap["value"] != thermostats[0].heatingSetpoint) {
+                       if (eventDataMap["value"].toInteger() != thermostats[0].heatingSetpoint) {
+                               this.latestHeatingSetpoint = eventDataMap["value"].toInteger()
+                               this.heatingSetpoint = eventDataMap["value"].toInteger()
                                thermostats[0].setValue(eventDataMap["value"], "heatingSetpoint")
-                               this.heatingSetpoint = thermostats[0].heatingSetpoint
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "coolingSetpoint") {
-                       if (eventDataMap["value"] != thermostats[0].coolingSetpoint) {
+                       if (eventDataMap["value"].toInteger() != thermostats[0].coolingSetpoint) {
+                               this.latestCoolingSetPoint = eventDataMap["value"].toInteger()
+                               this.coolingSetpoint = eventDataMap["value"].toInteger()
                                thermostats[0].setValue(eventDataMap["value"], "coolingSetpoint")
-                               this.coolingSetpoint = thermostats[0].coolingSetpoint
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "thermostatSetpoint") {
-                       if (eventDataMap["value"] != thermostats[0].thermostatSetpoint) {
+                       if (eventDataMap["value"].toInteger() != thermostats[0].thermostatSetpoint) {
+                               this.latestThermostatSetpoint = eventDataMap["value"].toInteger()
+                               this.thermostatSetpoint = eventDataMap["value"].toInteger()
                                thermostats[0].setValue(eventDataMap["value"], "thermostatSetpoint")
-                               this.thermostatSetpoint = thermostats[0].thermostatSetpoint
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "thermostatMode") {
                        if (eventDataMap["value"] != thermostats[0].thermostatMode) {
+                               this.thermostatLatestMode = eventDataMap["value"]
+                               this.thermostatMode = eventDataMap["value"]
+                               this.currentThermostatMode = eventDataMap["value"]
                                thermostats[0].setValue(eventDataMap["value"], "thermostatMode")
-                               this.thermostatMode = thermostats[0].thermostatMode
-                               this.currentThermostatMode = thermostats[0].currentThermostatMode
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "thermostatFanMode") {
                        if (eventDataMap["value"] != thermostats[0].thermostatFanMode) {
+                               this.thermostatLatestFanMode = eventDataMap["value"]
+                               this.thermostatFanMode = eventDataMap["value"]
                                thermostats[0].setValue(eventDataMap["value"], "thermostatFanMode")
-                               this.thermostatFanMode = thermostats[0].thermostatFanMode
                                sendEvent(eventDataMap)
                        }
                } else if (eventDataMap["name"] == "thermostatOperatingState") {
                        if (eventDataMap["value"] != thermostats[0].thermostatOperatingState) {
+                               this.thermostatLatestOperatingState = eventDataMap["value"]
+                               this.thermostatOperatingState = eventDataMap["value"]
                                thermostats[0].setValue(eventDataMap["value"], "thermostatOperatingState")
-                               this.thermostatOperatingState = thermostats[0].thermostatOperatingState
                                sendEvent(eventDataMap)
                        }
                }
        }
 
+       def currentValue(String deviceFeature) {
+               thermostats[0].currentValue(deviceFeature)
+       }
+
+       def latestValue(String deviceFeature) {
+               thermostats[0].latestValue(deviceFeature)
+       }
+
        def getAt(int ix) {
                thermostats[ix]
        }
index cf123be7992dcebbbd6c72c398670ed20d608dbe..96b356e261e77d3ab088b1dd37335b4bb126b414 100644 (file)
@@ -22,6 +22,19 @@ public class SimulatedTimer {
                closure()\r
        }\r
 \r
+       def runAfter(long delay, Closure closure) {\r
+               /*thread = new Thread() {\r
+       \r
+                       @Override\r
+                       public void run() {\r
+                               Thread.sleep(delay)\r
+                               closure()\r
+                       }\r
+               }.start()\r
+               return thread*/\r
+               closure()\r
+       }\r
+\r
        def cancel() {\r
                //if (thread != null)\r
                //      thread.stop()\r
index 4aaf5b3067f465602595f112dbdf56b8a2921895..75efd8a4d2c58b6434ee76f9e5db6ac53e74a753 100644 (file)
@@ -26,10 +26,12 @@ public class Valve {
        def open() {
                if (valve != "open") {
                        println("the valve with id:$id is open!")
-                       this.valveLatestValue = this.valve
+                       this.valveLatestValue = "open"
                        this.valve = "open"
                        sendEvent([name: "contact", value: "open", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "contact.open", value: "open", deviceId: this.id, descriptionText: "",
+                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -37,10 +39,12 @@ public class Valve {
                if (valve != "open") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the valve with id:$id is open!")
-                               this.valveLatestValue = this.valve
+                               this.valveLatestValue = "open"
                                this.valve = "open"
                                sendEvent([name: "contact", value: "open", deviceId: this.id, descriptionText: "",
                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "contact.open", value: "open", deviceId: this.id, descriptionText: "",
+                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -48,10 +52,12 @@ public class Valve {
        def close() {
                if (valve != "closed") {
                        println("the valve with id:$id is closed!")
-                       this.valveLatestValue = this.valve
+                       this.valveLatestValue = "closed"
                        this.valve = "closed"
                        sendEvent([name: "contact", value: "closed", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "contact.closed", value: "closed", deviceId: this.id, descriptionText: "",
+                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
@@ -59,10 +65,12 @@ public class Valve {
                if (valve != "closed") {
                        def task = timers.runAfter(metaData["delay"]) {
                                println("the valve with id:$id is closed!")
-                               this.valveLatestValue = this.valve
+                               this.valveLatestValue = "closed"
                                this.valve = "closed"
                                sendEvent([name: "contact", value: "closed", deviceId: this.id, descriptionText: "",
                                            displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                               sendEvent([name: "contact.closed", value: "closed", deviceId: this.id, descriptionText: "",
+                                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                }
        }
@@ -70,7 +78,7 @@ public class Valve {
        //By Model Checker
        def setValue(String value) {
                println("the valve with id:$id is $value!")
-               this.valveLatestValue = this.valve
+               this.valveLatestValue = value
                this.valve = value
        }
        
index b4c1e7b479db74a88d92b745589af409d0d0801b..0bf0bbce18669e7b7f7489028ff0fe949417bb04 100644 (file)
@@ -48,32 +48,45 @@ public class Valves {
        def find(Closure Input) {
                valves.find(Input)
        }
+       def sort(Closure Input) {
+               valves.sort(Input)
+       }
        def collect(Closure Input) {
                valves.collect(Input)
        }
 
        //By Apps
        def open() {
-               if (valve != "open")
+               if (valve != "open") {
+                       this.valve = "open"
+                       this.valveLatestValue = "open"
                        valves[0].open()
+               }
        }
 
        def open(LinkedHashMap metaData) {
                if (valve != "open") {
                        def task = timers.runAfter(metaData["delay"]) {
+                               this.valve = "open"
+                               this.valveLatestValue = "open"
                                valves[0].open()
                        }
                }
        }
 
        def close() {
-               if (valve != "closed")
+               if (valve != "closed") {
+                       this.valve = "closed"
+                       this.valveLatestValue = "closed"                        
                        valves[0].close()
+               }
        }
 
        def close(LinkedHashMap metaData) {
                if (valve != "closed") {
                        def task = timers.runAfter(metaData["delay"]) {
+                               this.valve = "closed"
+                               this.valveLatestValue = "closed"
                                valves[0].close()
                        }
                }
@@ -82,8 +95,8 @@ public class Valves {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != valves[0].valve) {
+                       this.valve = eventDataMap["value"]
                        valves[0].setValue(eventDataMap["value"])
-                       this.valve = valves[0].valve
                }
        }
 
index 793398309e89e352100a11149aa6b8ca26398101..66e3f51d8ec0e4d8fa6699e9ad4092408aab5fdd 100644 (file)
@@ -27,6 +27,10 @@ contactObject.setValue([name: "contact", value: "open", deviceId: "contactSensor
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 contactObject.setValue([name: "contact", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+contactObject.setValue([name: "tamper.tampered", value: "open", deviceId: "contactSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+contactObject.setValue([name: "tamper.tampered", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 /////
 /*events*/
 //
@@ -88,6 +92,10 @@ motionSensorObject.setValue([name: "motion", value: "active", deviceId: "motionS
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 motionSensorObject.setValue([name: "motion", value: "inactive", deviceId: "motionSensorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+motionSensorObject.setValue([name: "motion.active", value: "active", deviceId: "motionSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+motionSensorObject.setValue([name: "motion.inactive", value: "inactive", deviceId: "motionSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 /////
 /*events*/
 //
@@ -146,11 +154,17 @@ smokeDetectorObject.setValue([name: "smoke", value: "detected", deviceId: "smoke
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 smokeDetectorObject.setValue([name: "smoke", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-smokeDetectorObject.setValue([name: "carbonMonoxide", value: "clear", deviceId: "smokeDetectorID0", descriptionText: "",
+smokeDetectorObject.setValue([name: "smoke.clear", value: "clear", deviceId: "smokeDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+smokeDetectorObject.setValue([name: "smoke.detected", value: "detected", deviceId: "smokeDetectorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-smokeDetectorObject.setValue([name: "carbonMonoxide", value: "detected", deviceId: "smokeDetectorID0", descriptionText: "",
+smokeDetectorObject.setValue([name: "smoke.tested", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-smokeDetectorObject.setValue([name: "carbonMonoxide", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
+smokeDetectorObject.setValue([name: "carbonMonoxide.clear", value: "clear", deviceId: "smokeDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+smokeDetectorObject.setValue([name: "carbonMonoxide.detected", value: "detected", deviceId: "smokeDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+smokeDetectorObject.setValue([name: "carbonMonoxide.tested", value: "tested", deviceId: "smokeDetectorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 smokeDetectorObject.setValue([name: "battery", value: "5"/*A number between 0 to 100 as a charge*/, deviceId: "smokeDetectorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -241,7 +255,7 @@ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "
 
 //For appTouch:
 /*events*/
-appObject.setValue([name: "Touched", value: "touched", deviceId: "touchedSensorID0", descriptionText: "",
+appObject.setValue([name: "Touched", value: "touched", deviceId: "appID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 /////
 /*events*/
@@ -279,6 +293,10 @@ accelerationSensorObject.setValue([name: "acceleration", value: "active", device
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 accelerationSensorObject.setValue([name: "acceleration", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+accelerationSensorObject.setValue([name: "acceleration.active", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+accelerationSensorObject.setValue([name: "acceleration.inactive", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 /////
 /*events*/
 //
@@ -317,6 +335,12 @@ carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide", value: "detected"
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide", value: "tested", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide.clear", value: "clear", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide.detected", value: "detected", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+carbonMonoxideDetectorObject.setValue([name: "carbonMonoxide.tested", value: "tested", deviceId: "carbonMonoxideDetectorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 /*events*/
 //
 -------------------------------------------------------------------------------
@@ -333,6 +357,14 @@ colorControlObject.setValue([name: "hue", value: "50", deviceId: "colorControlID
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "level", value: "50", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "switch", value: "on", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "switch", value: "off", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "colorTemperature", value: "50", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 /*events*/
 //
 -------------------------------------------------------------------------------
@@ -464,6 +496,10 @@ waterSensorObject.setValue([name: "water", value: "dry", deviceId: "waterSensorI
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 waterSensorObject.setValue([name: "water", value: "wet", deviceId: "waterSensorID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+waterSensorObject.setValue([name: "water.dry", value: "dry", deviceId: "waterSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+waterSensorObject.setValue([name: "water.wet", value: "wet", deviceId: "waterSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 /////
 /*events*/
 //
index 236d746faca82d88f1240e06872d48a302b1640b..bb8aac0ce22c906faf3cfc593c01765ee6d54a50 100644 (file)
@@ -34,8 +34,8 @@ public class WaterSensors {
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
                if (eventDataMap["value"] != waterSensors[0].water) {
+                       this.water = eventDataMap["value"]
                        waterSensors[0].setValue(eventDataMap["value"])
-                       this.water = waterSensors[0].water
                        sendEvent(eventDataMap)
                }
        }
@@ -53,6 +53,9 @@ public class WaterSensors {
        def find(Closure Input) {
                waterSensors.find(Input)
        }
+       def sort(Closure Input) {
+               waterSensors.sort(Input)
+       }
        def collect(Closure Input) {
                waterSensors.collect(Input)
        }
index e4310fecf57664cd1b3c1e892b9355c3470ed9fd..1d9e57fd18ff17c1cb95bc3e91ea931674aca6e4 100644 (file)
@@ -3,13 +3,15 @@ package appTouch
 
 public class Touched{
        def sendEvent
+       private String id
        private int isTouched
        private String label
 
        Touched(Closure sendEvent, int isTouched) {
                this.sendEvent = sendEvent
                this.isTouched = isTouched
-               this.label = "App"
+               this.label = "app0"
+               this.id = "appID0"
        }
 
        //By Model Checker
diff --git a/eventSimulator/colorChangeEvent.groovy b/eventSimulator/colorChangeEvent.groovy
new file mode 100644 (file)
index 0000000..5ed3b4f
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorControlObject.setValue([name: "color", value: "red", deviceId: "colorControlID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/colorChangedEvent.groovy b/eventSimulator/colorChangedEvent.groovy
deleted file mode 100644 (file)
index 5ed3b4f..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-                       colorControlObject.setValue([name: "color", value: "red", deviceId: "colorControlID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index ad7c1db3c5f96f59bda952b881413a5984e08bee..393f9bd1fbbbc769d776ad69c819b1b2aff36409 100644 (file)
@@ -1,30 +1,40 @@
 while(true) {
-       def eventNumber = Verify.getInt(0,4)
+       def eventNumber = Verify.getInt(0,5)
        switch(eventNumber) {
                case 0:
                        def event = Verify.getInt(0,1)
                        if (event == 0) {
+<<<<<<< HEAD
+                                       switchObject.setValue([name: "switch", value: "on", deviceId: "switchID0", descriptionText: "",
+                                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       } else {
+                                       switchObject.setValue([name: "switch", value: "off", deviceId: "switchID0", descriptionText: "",
+=======
                                        lockObject.setValue([name: "lock", value: "locked", deviceId: "lockID0", descriptionText: "",
                                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])                       } else {
                                        lockObject.setValue([name: "lock", value: "unlocked", deviceId: "lockID0", descriptionText: "",
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        }
                        break
                case 1:
-                       lockObject.setValue([name: "unlock", value: "unlocked ", deviceId: "lockID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        break
                case 2:
-                       contactObject.setValue([name: "contact.open", value: "open", deviceId: "contactSensorID0", descriptionText: "",
+                       colorControlObject.setValue([name: "hue", value: "50", deviceId: "colorControlID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        break
                case 3:
-                       contactObject.setValue([name: "contact.closed", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
+                       colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                        break
                case 4:
+<<<<<<< HEAD
+                       break
+               case 5:
+=======
                        appObject.setValue([name: "Touched", value: "touched", deviceId: "touchedSensorID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
                        break
        }
 }
diff --git a/eventSimulator/hueChangeEvent.groovy b/eventSimulator/hueChangeEvent.groovy
new file mode 100644 (file)
index 0000000..b5d20d2
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorControlObject.setValue([name: "hue", value: "50", deviceId: "colorControlID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/hueChangedEvent.groovy b/eventSimulator/hueChangedEvent.groovy
deleted file mode 100644 (file)
index b5d20d2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-                       colorControlObject.setValue([name: "hue", value: "50", deviceId: "colorControlID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/saturationChangeEvent.groovy b/eventSimulator/saturationChangeEvent.groovy
new file mode 100644 (file)
index 0000000..5327de2
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/saturationChangedEvent.groovy b/eventSimulator/saturationChangedEvent.groovy
deleted file mode 100644 (file)
index 5327de2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-                       colorControlObject.setValue([name: "saturation", value: "50", deviceId: "colorControlID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])