Infrastructure compatible for all groups instead of switches.
[smartthings-infrastructure.git] / Extractor / Extractor.groovy
index 19e5016b1d078a1f853420fdabfb62ee80847ed5..c8c7019118e6b22e62a929ef5b22c78a7eb6de07 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