import os
#Create directory for files to append in the main file
+
+#Extract information from preferences and subscribe method to create required objects
+os.system("python Extractor/ExtractorScript.py")
+
+#Files for both Apps
Out = open("main.groovy", "w+")
-GlobalVariables = open("GlobalVariables/"+"GlobalVariables.groovy", "r")
-definition = open("Methods/"+"definition.groovy", "r")
-preferences = open("Methods/"+"preferences.groovy", "r")
+GlobalVariablesBothApps = open("GlobalVariables/"+"GlobalVariablesBothApps.groovy", "r")
+eventSimulator = open("eventSimulator/"+"eventSimulator.groovy", "r")
+
+#For App1
+GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
subscribe = open("Methods/"+"subscribe.groovy", "r")
runIn = open("Methods/"+"runIn.groovy", "r")
unschedule = open("Methods/"+"unschedule.groovy", "r")
sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
sendSms = open("Methods/"+"sendSms.groovy", "r")
+sendPush = open("Methods/"+"sendPush.groovy", "r")
eventHandler = open("Methods/"+"eventHandler.groovy", "r")
-App = open("Extractor/"+"App.groovy", "r")
-extractedObjects = open("Extractor/"+"extractedObjects.groovy", "r")
+schedule = open("Methods/"+"schedule.groovy", "r")
+now = open("Methods/"+"now.groovy", "r")
+App1 = open("Extractor/"+"App1/App1.groovy", "r")
+extractedObjectsApp1 = open("Extractor/"+"App1/extractedObjectsApp1.groovy", "r")
+extractedObjectsConstructorApp1 = open("Extractor/"+"App1/extractedObjectsConstructorApp1.groovy", "r")
+extractedFunctionsApp1 = open("Extractor/"+"App1/extractedFunctionsApp1.groovy", "r")
+
-#Extract information from preferences and subscribe method to create required objects
-os.system("python Extractor/ExtractorScript.py")
Out.write("//Infrastructure for SmartThings Application\n")
Out.write("//Importing Libraries\n")
Out.write("import groovy.transform.Field\n")
Out.write("\n")
Out.write("//Importing Classes\n")
-Out.write("import ContactSensor.Contacting\n")
-Out.write("import ContactSensor.Contacts\n")
-Out.write("import Lock.Locking\n")
+Out.write("import ContactSensor.ContactSensor\n")
+Out.write("import ContactSensor.ContactSensors\n")
+Out.write("import DoorControl.DoorControl\n")
+Out.write("import DoorControl.DoorControls\n")
+Out.write("import Lock.Lock\n")
Out.write("import Lock.Locks\n")
-Out.write("import Switch.Switching\n")
+Out.write("import Thermostat.Thermostat\n")
+Out.write("import Thermostat.Thermostats\n")
+Out.write("import Switch.Switch\n")
Out.write("import Switch.Switches\n")
+Out.write("import PresenceSensor.PresenceSensor\n")
+Out.write("import PresenceSensor.PresenceSensors\n")
Out.write("import Logger.Logger\n")
Out.write("import Location.LocationVar\n")
Out.write("import Location.Phrase\n")
Out.write("import appTouch.Touched\n")
+Out.write("import NfcTouch.NfcTouch\n")
+Out.write("import AeonKeyFob.AeonKeyFob\n")
+Out.write("import AeonKeyFob.AeonKeyFobs\n")
+Out.write("import MusicPlayer.MusicPlayer\n")
+Out.write("import MusicPlayer.MusicPlayers\n")
Out.write("import Event.Event\n")
+Out.write("import Timer.SimulatedTimer\n")
Out.write("\n")
-Out.write("//GlobalVariables\n")
-for line in GlobalVariables:
+Out.write("//Global eventHandler\n")
+for line in eventHandler:
Out.write(line)
Out.write("\n")
-Out.write("//extractedObjects\n")
-for line in extractedObjects:
+Out.write("//GlobalVariables for both Apps\n")
+for line in GlobalVariablesBothApps:
Out.write(line)
Out.write("\n")
-Out.write("//Methods\n")
-for line in definition:
- Out.write(line)
-for line in preferences:
- Out.write(line)
+Out.write("//Application #1\n")
+Out.write("class App1 {\n")
+Out.write("\tdef reference\n")
+Out.write("\tdef location\n")
+Out.write("\tdef app\n")
+Out.write("\n")
+Out.write("\t//Extracted objects for App1\n")
+for line in extractedObjectsApp1:
+ Out.write("\t"+line)
+Out.write("\n")
+Out.write("\t//Extracted objects for functions for App1\n")
+for line in extractedFunctionsApp1:
+ Out.write("\t"+line)
+Out.write("\n")
+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")
+for line in extractedObjectsConstructorApp1:
+ Out.write("\t\t"+line)
+Out.write("\t}\n")
+Out.write("\t//Global variables for each app\n")
+for line in GlobalVariablesEachApp:
+ Out.write("\t"+line)
+Out.write("\n")
+Out.write("\t//Methods\n")
for line in setLocationMode:
- Out.write(line)
+ Out.write("\t"+line)
for line in subscribe:
- Out.write(line)
+ Out.write("\t"+line)
for line in runIn:
- Out.write(line)
+ Out.write("\t"+line)
for line in unschedule:
- Out.write(line)
+ Out.write("\t"+line)
for line in sendNotificationToContacts:
- Out.write(line)
+ Out.write("\t"+line)
for line in sendSms:
- Out.write(line)
-for line in eventHandler:
- Out.write(line)
+ Out.write("\t"+line)
+for line in sendPush:
+ Out.write("\t"+line)
+for line in schedule:
+ Out.write("\t"+line)
+for line in now:
+ Out.write("\t"+line)
Out.write("\n")
-for line in App:
- Out.write(line)
+Start = 0
+for line in App1:
+ if ("def " in line):
+ Start = 1
+ if (Start):
+ Out.write("\t"+line)
+Out.write("}\n")
Out.write("\n")
-Out.write("installed()\n")
+Out.write("\n")
+GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
+
+#For App2
+GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
+setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
+subscribe = open("Methods/"+"subscribe.groovy", "r")
+runIn = open("Methods/"+"runIn.groovy", "r")
+unschedule = open("Methods/"+"unschedule.groovy", "r")
+sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
+sendSms = open("Methods/"+"sendSms.groovy", "r")
+eventHandler = open("Methods/"+"eventHandler.groovy", "r")
+schedule = open("Methods/"+"schedule.groovy", "r")
+App2 = open("Extractor/"+"App2/App2.groovy", "r")
+extractedObjectsApp2 = open("Extractor/"+"App2/extractedObjectsApp2.groovy", "r")
+extractedObjectsConstructorApp2 = open("Extractor/"+"App2/extractedObjectsConstructorApp2.groovy", "r")
+extractedFunctionsApp2 = open("Extractor/"+"App2/extractedFunctionsApp2.groovy", "r")
+
+Out.write("//Application #2\n")
+Out.write("class App2 {\n")
+Out.write("\tdef reference\n")
+Out.write("\tdef location\n")
+Out.write("\tdef app\n")
+Out.write("\n")
+Out.write("\t//Extracted objects for App2\n")
+for line in extractedObjectsApp2:
+ Out.write("\t"+line)
+Out.write("\n")
+Out.write("\t//Extracted objects for functions for App2\n")
+for line in extractedFunctionsApp2:
+ Out.write("\t"+line)
+Out.write("\n")
+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")
+for line in extractedObjectsConstructorApp2:
+ Out.write("\t\t"+line)
+Out.write("\t}\n")
+Out.write("\t//Global variables for each app\n")
+for line in GlobalVariablesEachApp:
+ Out.write("\t"+line)
+Out.write("\n")
+Out.write("\t//Methods\n")
+for line in setLocationMode:
+ Out.write("\t"+line)
+for line in subscribe:
+ Out.write("\t"+line)
+for line in runIn:
+ Out.write("\t"+line)
+for line in unschedule:
+ Out.write("\t"+line)
+for line in sendNotificationToContacts:
+ Out.write("\t"+line)
+for line in sendSms:
+ Out.write("\t"+line)
+for line in sendPush:
+ Out.write("\t"+line)
+for line in schedule:
+ Out.write("\t"+line)
+for line in now:
+ Out.write("\t"+line)
+Out.write("\n")
+Start = 0
+for line in App2:
+ if ("def " in line):
+ Start = 1
+ if (Start):
+ Out.write("\t"+line)
+Out.write("}\n")
+Out.write("\n")
+Out.write("@Field def app1 = new App1(this)\n")
+Out.write("@Field def app2 = new App2(this)\n")
+Out.write("app1.installed()\n")
+Out.write("app2.installed()\n")
+Out.write("\n")
+for line in eventSimulator:
+ Out.write(line)
Out.close()