+#For both apps
+outGlobal = open("Extractor/outGlobal.groovy", "w+")
+lockIsSet = 0
+ContactIsSet = 0
+SwitchIsSet = 0
+
+
+def ExtractorFunc(F, outApp, outConstructorApp, Temp):
+ global outGlobal
+ global lockIsSet
+ global ContactIsSet
+ global SwitchIsSet
+
+ while (Temp != "EOF"):
+ #Extract the global objects for input
+ if (Temp == "input"):
+ Object = ""
+ Type = ""
+ Temp = GetToken(F) #name or "name"
+ #input name: "name", type: "type",...
+ if (Temp == "name"):
+ Temp = GetToken(F) #"name"
+ Object = Temp
+ GetToken(F) #type
+ Temp = GetToken(F) #"type"
+ Type = Temp
+ #input "name", "type",...
+ else:
+ Object = Temp
+ Temp = GetToken(F) #"type"
+ Type = Temp
+ Temp = GetToken(F)
+ Title = ""
+ Required = ""
+ Multiple = ""
+ while (Temp != "input" and Temp != "}"):
+ if (Temp == "title"):
+ Temp = GetToken(F)
+ Title = Temp
+ elif (Temp == "required"):
+ Temp = GetToken(F)
+ Required = Temp
+ elif (Temp == "multiple"):
+ Temp = GetToken(F)
+ Multiple = Temp
+ Temp = GetToken(F)
+ if (Type == "capability.lock"):
+ if (Title != ""):
+ print(Object+", "+Title)
+ if (Multiple != "" and Multiple == "true" and lockIsSet != 1):
+ lockIsSet = 1
+ g = raw_input("Enter the number of locks to control: (1, 2, or 3)\n")
+ outGlobal.write("//Global Object for class lock!\n")
+ outGlobal.write("@Field def lockObject = new Locking(sendEvent, ")
+ outGlobal.write("%s)\n" % g)
+ elif ((Multiple == "" or Multiple == "false") and lockIsSet != 1):
+ lockIsSet = 1
+ outGlobal.write("//Global Object for class lock!\n")
+ outGlobal.write("@Field def lockObject = new Locking(sendEvent, 1)\n")
+ outApp.write("//Object for class lock!\n")
+ outApp.write("def %s\n" % Object)
+ outConstructorApp.write("%s = obj.lockObject\n" % Object)
+ #elif (Type == "capability.alarm"):
+
+ #elif (Type == "capability.battery"):
+
+ #elif (Type == "capability.beacon"):
+
+ #elif (Type == "capability.carbonMonoxideDetector"):
+
+ #elif (Type == "capability.colorControl"):
+
+ elif (Type == "capability.contactSensor"):
+ if (Title != ""):
+ print(Object+", "+Title)
+ if (Multiple != "" and Multiple == "true" and ContactIsSet != 1):
+ ContactIsSet = 1
+ g = raw_input("Enter the number of contact sensors to control: (1, 2, or 3)\n")
+ outGlobal.write("//Global Object for class contactSensor!\n")
+ outGlobal.write("@Field def contactObject = new Contacting(sendEvent, ")
+ outGlobal.write("%s)\n" % g)
+ elif ((Multiple == "" or Multiple == "false") and ContactIsSet != 1):
+ ContactIsSet = 1
+ outGlobal.write("//Global Object for class contactSensor!\n")
+ outGlobal.write("@Field def contactObject = new Contacting(sendEvent, 1)\n")
+ outApp.write("//Object for class contactSensor!\n")
+ outApp.write("def %s\n" % Object)
+ outConstructorApp.write("%s = obj.contactObject\n" % Object)
+ #elif (Type == "capability.doorControl"):
+
+ #elif (Type == "capability.energyMeter"):
+
+ #elif (Type == "capability.illuminanceMeasurement"):
+
+ #elif (Type == "capability.accelerationSensor"):
+
+ #elif (Type == "capability.motionSensor"):
+
+ #elif (Type == "capability.musicPlayer"):
+
+ #elif (Type == "capability.powerMeter"):
+
+ #elif (Type == "capability.presenceSensor"):
+
+ #elif (Type == "capability.relativeHumidityMeasurement"):
+
+ #elif (Type == "capability.relaySwitch"):
+
+ #elif (Type == "capability.sleepSensor"):
+
+ #elif (Type == "capability.smokeDetector"):
+
+ #elif (Type == "capability.stepSensor"):
+
+ elif (Type == "capability.switch"):
+ if (Title != ""):
+ print(Object+", "+Title)
+ if (Multiple != "" and Multiple == "true" and SwitchIsSet != 1):
+ SwitchIsSet = 1
+ g = raw_input("Enter the number of switches to control: (1, 2, or 3)\n")
+ outGlobal.write("//Global Object for class Switch!\n")
+ outGlobal.write("@Field def switchObject = new Switching(sendEvent, ")
+ outGlobal.write("%s)\n" % g)
+ elif ((Multiple == "" or Multiple == "false") and SwitchIsSet != 1):
+ SwitchIsSet = 1
+ outGlobal.write("//Global Object for class Switch!\n")
+ outGlobal.write("@Field def switchObject = new Switching(sendEvent, 1)\n")
+ outApp.write("//Object for class Switch!\n")
+ outApp.write("def %s\n" % Object)
+ outConstructorApp.write("%s = obj.switchObject\n" % Object)
+ #elif (Type == "capability.switchLevel"):
+
+ #elif (Type == "capability.temperatureMeasurement"):