Infrastruction modification
[smartthings-infrastructure.git] / MobilePresence / MobilePresences.groovy
index a462b9fbb737f5ec6ba04b815490133477c640d7..2cea98823ab97b67113d7103299e29069fdcd819 100644 (file)
@@ -1,50 +1,27 @@
 //Create a class for mobile presence
 package MobilePresence
-import Timer.SimulatedTimer
+import SmartThing.SmartThings
 
-public class MobilePresences {
-       private int deviceNumbers
-       private List mobilePresences
-       private String deviceNetworkId
-       def sendEvent
-
-       //For one device(We cannot have obj.id)-> We should have obj[0].id
-       private String id = "mobilePresenceID0"
-       private String label = "mobilePresence0"
-       private String displayName = "mobilePresence0"
+public class MobilePresences extends SmartThings {
+       List mobilePresences = new ArrayList()
        
-               
-       MobilePresences(Closure sendEvent, int deviceNumbers) {
-               this.sendEvent = sendEvent              
-               this.deviceNumbers = deviceNumbers
-               this.mobilePresences = []
-               this.deviceNetworkId = "mobile0"
+       MobilePresences(Closure sendEvent) {
+               // Only initialize one time since we only have one device for each capability
+               mobilePresences = smartThings
 
-               mobilePresences.add(new MobilePresence(id, label, displayName, deviceNetworkId))
-       }
+               // Initialization
+               StringBuilder id = new StringBuilder("mobileDeviceID0")
+               StringBuilder label = new StringBuilder("mobileDevice")
+               StringBuilder displayName = new StringBuilder("mobileDevice0")
+               StringBuilder deviceNetworkId = new StringBuilder("mobile0")
 
-       //Methods for closures
-       def count(Closure Input) {
-               mobilePresences.count(Input)
-       }
-       def size() {
-               mobilePresences.size()
-       }
-       def each(Closure Input) {
-               mobilePresences.each(Input)
+               mobilePresences.add(new MobilePresence(sendEvent, id, label, displayName, deviceNetworkId))
        }
-       def find(Closure Input) {
-               mobilePresences.find(Input)
-       }
-       def sort(Closure Input) {
-               mobilePresences.sort(Input)
-       }
-       def collect(Closure Input) {
-               mobilePresences.collect(Input)
-       }
-
 
-       def getAt(int ix) {
-               mobilePresences[ix]
+       // Methods to return values
+       def getDeviceNetworkId() {
+               List tmpValues = new ArrayList()
+               tmpValues.add(mobilePresences[0].getDeviceNetworkId())
+               return tmpValues
        }
 }