Infrastructure compatible for all groups instead of switches.
authoramiraj <amiraj.95@uci.edu>
Tue, 6 Aug 2019 03:16:29 +0000 (20:16 -0700)
committeramiraj <amiraj.95@uci.edu>
Tue, 6 Aug 2019 03:16:29 +0000 (20:16 -0700)
13 files changed:
Extractor/Extractor.groovy
ImageCapture/ImageCapture.groovy
ImageCapture/ImageCaptures.groovy
Location/LocationVar.groovy
Methods/timeToday.groovy
MusicPlayer/MusicPlayer.groovy
MusicPlayer/MusicPlayers.groovy
Runner.py
SwitchLevel/SwitchLevel.groovy
SwitchLevel/SwitchLevels.groovy
ThreeAxis/ThreeAxis.groovy [new file with mode: 0644]
ThreeAxis/ThreeAxises.groovy [new file with mode: 0644]
Variables and events for each device

index 19e5016..c8c7019 100644 (file)
@@ -74,6 +74,8 @@ import ColorTemperature.ColorTemperature
 import ColorTemperature.ColorTemperatures
 import Button.Button
 import Button.Buttons
+import ThreeAxis.ThreeAxis
+import ThreeAxis.ThreeAxises
 import Timer.SimulatedTimer
 
 //GlobalVariables
@@ -288,6 +290,11 @@ def timeToday(String time, Object timeZone) {
 @Field def buttonObject0
 @Field def buttonObject1
 @Field def buttonObject2
+//Global Object for class three axis!
+@Field threeAxisObjects = 0
+@Field def threeAxisObject0
+@Field def threeAxisObject1
+@Field def threeAxisObject2
 
 
 //Global variables
@@ -713,6 +720,41 @@ def input(LinkedHashMap metaData) {
                                extractedObjectsConstructorApp2.append(metaData['name']+" = obj.contactObject\n")
                        }
                        break
+               case "capability.threeAxis":
+                       globalObjects.eachLine { line ->
+                               if(line.contains("threeAxisObject")){
+                                       contains = 1
+                               }
+                       }
+
+                       if (contains == 0)
+                               globalObjects.append("@Field def threeAxisObject = new ThreeAxises(sendEvent, 1)\n")
+
+                       if (threeAxisObjects == 0) {
+                               threeAxisObject0 = metaData['name']
+                               this[threeAxisObject0] = new ThreeAxises({}, 1)
+                       } else if (threeAxisObjects == 1) {
+                               threeAxisObject1 = metaData['name']
+                               this[threeAxisObject1] = new ThreeAxises({}, 1)
+                       } else if (threeAxisObjects == 2) {
+                               threeAxisObject2 = metaData['name']
+                               this[threeAxisObject2] = new ThreeAxises({}, 1)
+                       }
+
+                       threeAxisObjects=threeAxisObjects+1
+
+                       settings.put(metaData['name'], new ThreeAxises({}, 1))
+
+                       if (App == "App1") {
+                               extractedObjectsApp1.append("//Object for class three axis!\n")
+                               extractedObjectsApp1.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp1.append(metaData['name']+" = obj.threeAxisObject\n")             
+                       } else {
+                               extractedObjectsApp2.append("//Object for class three axis!\n")
+                               extractedObjectsApp2.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp2.append(metaData['name']+" = obj.threeAxisObject\n")
+                       }
+                       break
                case "capability.doorControl":
                        globalObjects.eachLine { line ->
                                if(line.contains("doorControlObject")){
@@ -1795,6 +1837,46 @@ def input(LinkedHashMap metaData) {
                                extractedObjectsApp2.append("def "+metaData['name']+" = \""+userInput+"\"\n")
                        }
                        break
+               case "boolean":
+                       //def userInput = Math.abs(new Random().nextInt() % 2)
+                       def userInput = true
+
+                       if (boolVariables == 0) {
+                               bool0 = metaData['name']
+                               this[bool0] = userInput
+                       } else if (boolVariables == 1) {
+                               bool1 = metaData['name']
+                               this[bool1] = userInput
+                       } else if (boolVariables == 2) {
+                               bool2 = metaData['name']
+                               this[bool2] = userInput
+                       } else if (boolVariables == 3) {
+                               bool3 = metaData['name']
+                               this[bool3] = userInput
+                       } else if (boolVariables == 4) {
+                               bool4 = metaData['name']
+                               this[bool4] = userInput
+                       } else if (boolVariables == 5) {
+                               bool5 = metaData['name']
+                               this[bool5] = userInput
+                       }
+
+                       if (boolVariables != 5)
+                               boolVariables=boolVariables+1
+                       else
+                               boolVariables=0
+
+
+                       settings.put(metaData['name'], metaData['name'])
+
+                       if (App == "App1") {                    
+                               extractedObjectsApp1.append("//Global variable for boolean!\n")
+                               extractedObjectsApp1.append("def "+metaData['name']+" = \""+userInput+"\"\n")
+                       } else {
+                               extractedObjectsApp2.append("//Global variable for boolean!\n")
+                               extractedObjectsApp2.append("def "+metaData['name']+" = \""+userInput+"\"\n")
+                       }
+                       break
                case "bool":
                        //def userInput = Math.abs(new Random().nextInt() % 2)
                        def userInput = true
@@ -1993,6 +2075,10 @@ def preferences(Closure inputData) {
        }
 }
 
+def image(String data) {
+       println("//IGNORE--some image//")
+}
+
 def page(LinkedHashMap metaData, Closure inputData) {
        if (metaData.containsKey('name'))
                println(metaData['name'])
@@ -2020,6 +2106,10 @@ def paragraph(String paragraphText) {
        println(paragraphText)
 }
 
+def paragraph(LinkedHashMap metaData, String paragraphText) {
+       println(paragraphText)
+}
+
 def section(String title, Closure inputData) {
        println(title)
        find(inputData) //Run the closure to extract inputMethods
index 5e8748b..0672e60 100644 (file)
@@ -8,6 +8,7 @@ public class ImageCapture {
        private String displayName
        private String image
        private String alarmState
+       def timers
 
        ImageCapture(String id, String label, String displayName, String image, String alarmState) {
                this.id = id
@@ -15,6 +16,7 @@ public class ImageCapture {
                this.displayName = displayName
                this.image = image
                this.alarmState = alarmState
+               this.timers = new SimulatedTimer()
        }
        
        def alarmOn() {
@@ -34,4 +36,10 @@ public class ImageCapture {
        def take() {
                println("The camera with id:$id is taken a picture!")
        }
+
+       def take(LinkedHashMap metaData) {
+               def task = timers.runAfter(metaData["delay"]) {
+                       println("The camera with id:$id is taken a picture!")
+               }
+       }
 }
index 3b97a87..95d0812 100644 (file)
@@ -70,6 +70,11 @@ public class ImageCaptures {
        def take() {
                imageCaptureSensors[0].take()
        }
+
+       def take(LinkedHashMap metaData) {
+               imageCaptureSensors[0].take(metaData)
+       }
+
        def getAt(int ix) {
                imageCaptureSensors[ix]
        }
index a87abe9..ca20cff 100644 (file)
@@ -5,6 +5,7 @@ class LocationVar {
        private int contactBookEnabled
        private def modes
        private def timeZone
+       private def hubs
        private String mode
        private String name
        private List contacts
@@ -14,6 +15,7 @@ class LocationVar {
        private Phrase helloHome
 
        LocationVar(Closure sendEvent) {
+               this.hubs = [[id:0, localIP:"128.195.204.105"]]
                this.modes = [[name: "home"],[name: "away"],[name: "night"]]
                this.mode = "home"
                this.helloHome = new Phrase()
index 0b975ce..0d905b5 100644 (file)
@@ -6,3 +6,11 @@ def timeToday(String time, Object timeZone) {
        timeOfDay.time = inputTime
        return timeOfDay
 }
+
+def timeToday(String time) {
+       def timeOfDay = new Date()
+       def _inputTime = time.split(':')
+       def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60+1564191100415
+       timeOfDay.time = inputTime
+       return timeOfDay
+}
index 659476a..b21dbf9 100644 (file)
@@ -49,6 +49,31 @@ public class MusicPlayer {
        }
 
        //methods
+       def on(LinkedHashMap metaData) {
+               on()
+       }
+       def on() {
+               if (status != "on") {
+                       println("the music player with id:$id is on!")
+                       this.status = "on"
+                       sendEvent([name: "status", value: "on", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+       def off(LinkedHashMap metaData) {
+               off()
+       }
+       def off() {
+               if (status != "off") {
+                       println("the music player with id:$id is off!")
+                       this.status = "off"
+                       sendEvent([name: "status", value: "off", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+       def mute(LinkedHashMap metaData) {
+               mute()
+       }
        def mute() {
                if (mute != "muted") {
                        println("the music player with id:$id is muted!")
@@ -57,13 +82,16 @@ public class MusicPlayer {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def nextTrack(LinkedHashMap metaData) {
+               nextTrack()
+       }
        def nextTrack() {
                trackNumber = trackNumber+1
                def trackPlaying = trackData
                println("the $trackPlaying is selected!")
-               if (status != "playing") {
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
@@ -71,28 +99,37 @@ public class MusicPlayer {
                sendEvent([name: "trackData", value: "someTrack", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }
+       def pause(LinkedHashMap metaData) {
+               pause()
+       }
        def pause() {
-               if (status != "paused") {
+               if (status != "pause") {
                        println("the music player with id:$id is paused!")
-                       this.status = "paused"
-                       sendEvent([name: "status", value: "paused", deviceId: this.id, descriptionText: "",
+                       this.status = "pause"
+                       sendEvent([name: "status", value: "pause", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def play(LinkedHashMap metaData) {
+               play()
+       }
        def play() {
-               if (status != "playing") {
+               if (status != "play") {
                        println("the music player with id:$id is starting to play!")
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def playTrack(LinkedHashMap metaData) {
+               playTrack()
+       }
        def playTrack(String trackToPlay) {
                def trackPlaying = trackData
                println("the $trackPlaying is selected to play!")
-               if (status != "playing") {              
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {         
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
@@ -100,6 +137,9 @@ public class MusicPlayer {
                sendEvent([name: "trackData", value: "someTrack", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }
+       def previousTrack(LinkedHashMap metaData) {
+               previousTrack()
+       }
        def previousTrack() {
                if (trackNumber != 1)
                        trackNumber = trackNumber-1
@@ -118,15 +158,21 @@ public class MusicPlayer {
        /*def restoreTrack(String trackToRestore) {
                musicPlayers*.restoreTrack(trackToRestore)
        }*/
+       def resumeTrack(LinkedHashMap metaData) {
+               resumeTrack()
+       }
        def resumeTrack(String trackToResume) {
                def trackPlaying = trackData
                println("the $trackPlaying is resumed!")
-               if (status != "playing") {
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def setLevel(LinkedHashMap metaData) {
+               setLevel()
+       }
        def setLevel(int level) {
                if (level != this.level) {
                        this.level = level
@@ -135,12 +181,15 @@ public class MusicPlayer {
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def setTrack(LinkedHashMap metaData) {
+               setTrack()
+       }
        def setTrack(String trackToSet) {
                def trackPlaying = trackData
                println("the $trackPlaying is set!")
-               if (status != "playing") {
-                       this.status = "playing"
-                       sendEvent([name: "status", value: "playing", deviceId: this.id, descriptionText: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
                sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: this.id, descriptionText: "",
@@ -148,31 +197,37 @@ public class MusicPlayer {
                sendEvent([name: "trackData", value: "someTrack", deviceId: this.id, descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }
+       def stop(LinkedHashMap metaData) {
+               stop()
+       }
        def stop() {
-               if (status != "stopped") {
-                       println("the music player with id:$id is stopped!")
-                       this.status = "stopped"
-                       sendEvent([name: "status", value: "stopped", deviceId: this.id, descriptionText: "",
+               if (status != "stop") {
+                       println("the music player with id:$id is stop!")
+                       this.status = "stop"
+                       sendEvent([name: "status", value: "stop", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
+       def playText(LinkedHashMap metaData) {
+               playText()
+       }
        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: "",
+               if (status != "play") {
+                       this.status = "play"
+                       sendEvent([name: "status", value: "play", deviceId: this.id, descriptionText: "",
                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
 
        def currentValue(String deviceFeature) {
-               if (deviceFeature == "musicPlayer") {
+               if (deviceFeature == "playpause") {
                        return status
                }
        }
 
        def latestValue(String deviceFeature) {
-               if (deviceFeature == "musicPlayer") {
+               if (deviceFeature == "playpause") {
                        return status
                }
        }
index c2d8b75..e476a8d 100644 (file)
@@ -16,7 +16,7 @@ public class MusicPlayers {
        private String displayName = "musicPlayer0"
        private int level = 20
        private String mute = "unmuted"
-       private String status = "paused"
+       private String status = "pause"
        private int trackNumber = 1
        private String trackData = "someTrack"
        private String trackDescription = "someDescriptions"
@@ -117,75 +117,129 @@ public class MusicPlayers {
        }
 
        //methods
+       def on(LinkedHashMap metaData) {
+               on()
+       }
+       def on() {
+               if (status != "on") {
+                       this.status = "on"
+                       musicPlayers[0].on()
+               }
+       }
+       def off(LinkedHashMap metaData) {
+               off()
+       }
+       def off() {
+               if (status != "off") {
+                       this.status = "off"
+                       musicPlayers[0].off()
+               }
+       }
+       def mute(LinkedHashMap metaData) {
+               mute()
+       }
        def mute() {
                if (mute != "muted") {
                        this.mute = "muted"
                        musicPlayers[0].mute()
                }
        }
+       def nextTrack(LinkedHashMap metaData) {
+               nextTrack()
+       }
        def nextTrack() {
-               if (status != "playing") {
-                       this.status = "playing"
+               if (status != "play") {
+                       this.status = "play"
                }
                this.trackNumber = this.trackNumber+1
                musicPlayers[0].nextTrack()
        }
+       def pause(LinkedHashMap metaData) {
+               pause()
+       }
        def pause() {
-               if (status != "paused") {
-                       this.status = "paused"
+               if (status != "pause") {
+                       this.status = "pause"
                        musicPlayers[0].pause()                 
                }
        }
+       def play(LinkedHashMap metaData) {
+               play()
+       }
        def play() {
-               if (status != "playing") {
-                       this.status = "playing"
+               if (status != "play") {
+                       this.status = "play"
                        musicPlayers[0].play()
                }
        }
+       def playTrack(LinkedHashMap metaData) {
+               playTrack()
+       }
        def playTrack(String trackToPlay) {
-               if (status != "playing") {
-                       this.status = "playing"
+               if (status != "play") {
+                       this.status = "play"
                }
                musicPlayers[0].playTrack(trackToPlay)
        }
+       def previousTrack(LinkedHashMap metaData) {
+               previousTrack()
+       }
        def previousTrack() {
-               if (status != "playing") {
-                       this.status = "playing"
+               if (status != "play") {
+                       this.status = "play"
                }
                if (this.trackNumber != 1)
                        this.trackNumber = this.trackNumber-1
                musicPlayers[0].previousTrack()
        }
+       def restoreTrack(LinkedHashMap metaData) {
+               restoreTrack()
+       }
        def restoreTrack(String trackToRestore) {
                musicPlayers[0].restoreTrack(trackToRestore)
        }
+       def resumeTrack(LinkedHashMap metaData) {
+               resumeTrack()
+       }
        def resumeTrack(String trackToResume) {
-               if (status != "playing") {
-                       this.status = "playing"
+               if (status != "play") {
+                       this.status = "play"
                }
                musicPlayers[0].resumeTrack(trackToResume)
        }
+       def setLevel(LinkedHashMap metaData) {
+               setLevel()
+       }
        def setLevel(int level) {
                if (level != this.level) {
                        this.level = level      
                        musicPlayers[0].setLevel(level)
                }
        }
+       def setTrack(LinkedHashMap metaData) {
+               setTrack()
+       }
        def setTrack(String trackToSet) {
-               if (status != "playing") {
-                       this.status = "playing"
+               if (status != "play") {
+                       this.status = "play"
                }
                musicPlayers[0].setTrack(trackToSet)
        }
+       def stop(LinkedHashMap metaData) {
+               stop()
+       }
        def stop() {
-               if (status != "stopped") {
-                       this.status = "stopped"
+               if (status != "stop") {
+                       this.status = "stop"
                        musicPlayers[0].stop()
                }
        }
+       def playText(LinkedHashMap metaData) {
+               playText()
+       }
        def playText(String text) {
-               if (status != "playing") {
-                       this.status = "playing"
+               if (status != "play") {
+                       this.status = "play"
                }
                musicPlayers[0].playText(text)
        }
index 4c02586..087dd3e 100644 (file)
--- a/Runner.py
+++ b/Runner.py
@@ -116,6 +116,8 @@ Out.write("import ColorTemperature.ColorTemperature\n")
 Out.write("import ColorTemperature.ColorTemperatures\n")
 Out.write("import Button.Button\n")
 Out.write("import Button.Buttons\n")
+Out.write("import ThreeAxis.ThreeAxis\n")
+Out.write("import ThreeAxis.ThreeAxises\n")
 Out.write("import Event.Event\n")
 Out.write("import Timer.SimulatedTimer\n")
 Out.write("\n")
index f9337f9..32ae591 100644 (file)
@@ -10,12 +10,14 @@ public class SwitchLevel {
        private String currentSwitch
        private int level
        private int rate
+       private int hue
+       private int saturation
        private String switchLatestValue
        def sendEvent   
        def timers
        
 
-       SwitchLevel(Closure sendEvent, String id, String label, String displayName, int level, String switchState, String switchLatestValue) {
+       SwitchLevel(Closure sendEvent, String id, String label, String displayName, int level, int hue, int saturation, String switchState, String switchLatestValue) {
                this.sendEvent = sendEvent
                this.timers = new SimulatedTimer()
                this.id = id
@@ -23,12 +25,30 @@ public class SwitchLevel {
                this.displayName = displayName
                this.level = level
                this.rate = level
+               this.hue = hue
+               this.saturation = saturation
                this.switchState = switchState
                this.currentSwitch = switchState
                this.switchLatestValue = switchLatestValue
        }
 
        //By Apps
+       def setColor(LinkedHashMap metaData) {
+               if ((this.level != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) {
+                       this.level = metaData["level"]
+                       this.rate = metaData["level"]
+                       this.hue = metaData["hue"]
+                       this.saturation = metaData["saturation"]
+                       println("the switch with id:$id is setted to level $level and hue to $hue and saturation to $saturation!")
+                       sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "hue", value: "$hue", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                       sendEvent([name: "saturation", value: "$saturation", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }       
+
        def setLevel(int level) {
                if (this.level != level) {
                        println("the switch with id:$id is setted to level $level!")
index 6ceaf8f..09bf7a6 100644 (file)
@@ -17,6 +17,8 @@ public class SwitchLevels {
        private String displayName = "switchLevel0"
        private int level = 50
        private int rate = 50
+       private int hue = 30
+       private int saturation = 70
        private String switchState = "on"
        private String currentSwitch = "on"
        private String switchLatestValue = "on"
@@ -39,7 +41,7 @@ public class SwitchLevels {
                        this.currentSwitch = "on"
                        this.switchLatestValue = "on"
                }*/
-               switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level, this.switchState, this.switchLatestValue))
+               switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level, this.hue, this.saturation, this.switchState, this.switchLatestValue))
        }
 
        //Methods for closures
@@ -63,6 +65,16 @@ public class SwitchLevels {
        }
 
        //By Apps
+       def setColor(LinkedHashMap metaData) {
+               if ((this.level != metaData["level"]) || (this.hue != metaData["hue"]) || (this.saturation != metaData["saturation"])) {
+                       this.level = metaData["level"]
+                       this.rate = metaData["level"]
+                       this.hue = metaData["hue"]
+                       this.saturation = metaData["saturation"]
+                       switchLevels[0].setColor(metaData)
+               }
+       }
+
        def setLevel(int level) {
                if (this.level != level) {
                        switchLevels[0].setLevel(level)
diff --git a/ThreeAxis/ThreeAxis.groovy b/ThreeAxis/ThreeAxis.groovy
new file mode 100644 (file)
index 0000000..83c1a59
--- /dev/null
@@ -0,0 +1,36 @@
+//Create a class for three axis
+package ThreeAxis
+import Timer.SimulatedTimer
+import groovy.json.JsonSlurper
+
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
+public class ThreeAxis {
+       private String id
+       private String label
+       private String displayName
+       private LinkedHashMap threeAxis
+
+       ThreeAxis(String id, String label, String displayName, LinkedHashMap threeAxis) {
+               this.id = id
+               this.label = label
+               this.displayName = displayName
+               this.threeAxis = threeAxis
+       }
+
+       def setValue(LinkedHashMap eventDataMap) {
+               threeAxis = new groovy.json.JsonSlurper().parseText(eventDataMap["value"])
+               println("the three axis of cube is chagned to $threeAxis!")
+       }
+
+       def currentValue(String deviceFeature) {
+               if (deviceFeature == "threeAxis")
+                       return threeAxis
+       }
+
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "threeAxis")
+                       return threeAxis
+       }
+}
diff --git a/ThreeAxis/ThreeAxises.groovy b/ThreeAxis/ThreeAxises.groovy
new file mode 100644 (file)
index 0000000..6dd02b2
--- /dev/null
@@ -0,0 +1,66 @@
+//Create a class for three axis
+package ThreeAxis
+import Timer.SimulatedTimer
+
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
+public class ThreeAxises {
+       private int deviceNumbers
+       private List threeAxises
+       def sendEvent
+
+       //For one device(We cannot have obj.id)-> We should have obj[0].id
+       private String id = "threeAxisID0"
+       private String label = "threeAxis0"
+       private String displayName = "threeAxis0"
+       private LinkedHashMap threeAxis = [x:0, y:0, z:0]
+       
+               
+       ThreeAxises(Closure sendEvent, int deviceNumbers) {
+               this.sendEvent = sendEvent              
+               this.deviceNumbers = deviceNumbers
+               this.threeAxises = []
+
+               threeAxises.add(new ThreeAxis(id, label, displayName, threeAxis))
+       }
+
+       //By Model Checker
+       def setValue(LinkedHashMap eventDataMap) {
+               threeAxises[0].setValue(eventDataMap)
+               sendEvent(eventDataMap)
+       }
+
+       //Methods for closures
+       def count(Closure Input) {
+               threeAxises.count(Input)
+       }
+       def size() {
+               threeAxises.size()
+       }
+       def each(Closure Input) {
+               threeAxises.each(Input)
+       }
+       def sort(Closure Input) {
+               threeAxises.sort(Input)
+       }
+       def find(Closure Input) {
+               threeAxises.find(Input)
+       }
+       def collect(Closure Input) {
+               threeAxises.collect(Input)
+       }
+
+
+       def currentValue(String deviceFeature) {
+               threeAxises[0].currentValue(deviceFeature)
+       }
+
+       def latestValue(String deviceFeature) {
+               threeAxises[0].latestValue(deviceFeature)
+       }
+
+       def getAt(int ix) {
+               threeAxises[ix]
+       }
+}
index 8643131..6f6d6e3 100644 (file)
@@ -93,11 +93,15 @@ String trackDescription
 String trackData
 String mute
 /*events*/
-musicPlayerObject.setValue([name: "status", value: "playing", deviceId: "musicPlayerID0", descriptionText: "",
+musicPlayerObject.setValue([name: "status", value: "play", deviceId: "musicPlayerID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-musicPlayerObject.setValue([name: "status", value: "stopped", deviceId: "musicPlayerID0", descriptionText: "",
+musicPlayerObject.setValue([name: "status", value: "stop", deviceId: "musicPlayerID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-musicPlayerObject.setValue([name: "status", value: "paused", deviceId: "musicPlayerID0", descriptionText: "",
+musicPlayerObject.setValue([name: "status", value: "pause", deviceId: "musicPlayerID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+musicPlayerObject.setValue([name: "status", value: "on", deviceId: "musicPlayerID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+musicPlayerObject.setValue([name: "status", value: "off", deviceId: "musicPlayerID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
 musicPlayerObject.setValue([name: "level", value: "36"/*A number between 0 to 100 as a charge*/, deviceId: "musicPlayerID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -471,11 +475,22 @@ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "
 //For button:
 String button
 /*events*/
-buttonObject.setValue([name: "button", value: "held", deviceId: "switchID0", descriptionText: "",
+buttonObject.setValue([name: "button", value: "held", deviceId: "buttonID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])
-buttonObject.setValue([name: "button", value: "push", deviceId: "switchID0", descriptionText: "",
+buttonObject.setValue([name: "button", value: "push", deviceId: "buttonID0", descriptionText: "",
 displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])
 /////
 /*events*/
 //
+-------------------------------------------------------------------------------
+
+
+//For threeAxis:
+LinkedHashMap threeAxis
+/*events*/
+threeAxisObject.setValue([name: "threeAxis", value: '{"x": 1, "y": 2, "z": 3}', deviceId: "threeAxisID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+/////
+/*events*/
+//