3 #Create directory for files to append in the main file
5 #Extract information from preferences and subscribe method to create required objects
6 os.system("python Extractor/ExtractorScript.py")
9 Out = open("main.groovy", "w+")
10 GlobalVariablesBothApps = open("GlobalVariables/"+"GlobalVariablesBothApps.groovy", "r")
11 outGlobal = open("Extractor/"+"outGlobal.groovy", "r")
12 eventSimulator = open("eventSimulator/"+"eventSimulator.groovy", "r")
15 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
16 setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
17 subscribe = open("Methods/"+"subscribe.groovy", "r")
18 runIn = open("Methods/"+"runIn.groovy", "r")
19 unschedule = open("Methods/"+"unschedule.groovy", "r")
20 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
21 sendSms = open("Methods/"+"sendSms.groovy", "r")
22 sendPush = open("Methods/"+"sendPush.groovy", "r")
23 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
24 schedule = open("Methods/"+"schedule.groovy", "r")
25 App1 = open("Extractor/"+"App1/App1.groovy", "r")
26 extractedObjectsApp1 = open("Extractor/"+"App1/extractedObjectsApp1.groovy", "r")
27 extractedObjectsConstructorApp1 = open("Extractor/"+"App1/extractedObjectsConstructorApp1.groovy", "r")
28 extractedFunctionsApp1 = open("Extractor/"+"App1/extractedFunctionsApp1.groovy", "r")
33 Out.write("//Infrastructure for SmartThings Application\n")
34 Out.write("//Importing Libraries\n")
35 Out.write("import groovy.transform.Field\n")
37 Out.write("//Importing Classes\n")
38 Out.write("import ContactSensor.Contacting\n")
39 Out.write("import ContactSensor.Contacts\n")
40 Out.write("import Lock.Locking\n")
41 Out.write("import Lock.Locks\n")
42 Out.write("import Switch.Switching\n")
43 Out.write("import Switch.Switches\n")
44 Out.write("import Logger.Logger\n")
45 Out.write("import Location.LocationVar\n")
46 Out.write("import Location.Phrase\n")
47 Out.write("import appTouch.Touched\n")
48 Out.write("import Event.Event\n")
49 Out.write("import Timer.SimulatedTimer\n")
51 Out.write("//Global eventHandler\n")
52 for line in eventHandler:
55 Out.write("//GlobalVariables for both Apps\n")
56 for line in GlobalVariablesBothApps:
59 Out.write("//Extracted global objects for both Apps\n")
60 for line in outGlobal:
63 Out.write("//Application #1\n")
64 Out.write("class App1 {\n")
65 Out.write("\tdef reference\n")
66 Out.write("\tdef location\n")
67 Out.write("\tdef app\n")
69 Out.write("\t//Extracted objects for App1\n")
70 for line in extractedObjectsApp1:
73 Out.write("\t//Extracted objects for functions for App1\n")
74 for line in extractedFunctionsApp1:
77 Out.write("\tApp1(Object obj) {\n")
78 Out.write("\t\treference = obj\n")
79 Out.write("\t\tlocation = obj.locationObject\n")
80 Out.write("\t\tapp = obj.appObject\n")
81 for line in extractedObjectsConstructorApp1:
82 Out.write("\t\t"+line)
84 Out.write("\t//Global variables for each app\n")
85 for line in GlobalVariablesEachApp:
88 Out.write("\t//Methods\n")
89 for line in setLocationMode:
91 for line in subscribe:
95 for line in unschedule:
97 for line in sendNotificationToContacts:
101 for line in sendPush:
103 for line in schedule:
115 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
118 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
119 setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
120 subscribe = open("Methods/"+"subscribe.groovy", "r")
121 runIn = open("Methods/"+"runIn.groovy", "r")
122 unschedule = open("Methods/"+"unschedule.groovy", "r")
123 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
124 sendSms = open("Methods/"+"sendSms.groovy", "r")
125 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
126 schedule = open("Methods/"+"schedule.groovy", "r")
127 App2 = open("Extractor/"+"App2/App2.groovy", "r")
128 extractedObjectsApp2 = open("Extractor/"+"App2/extractedObjectsApp2.groovy", "r")
129 extractedObjectsConstructorApp2 = open("Extractor/"+"App2/extractedObjectsConstructorApp2.groovy", "r")
130 extractedFunctionsApp2 = open("Extractor/"+"App2/extractedFunctionsApp2.groovy", "r")
132 Out.write("//Application #2\n")
133 Out.write("class App2 {\n")
134 Out.write("\tdef reference\n")
135 Out.write("\tdef location\n")
136 Out.write("\tdef app\n")
138 Out.write("\t//Extracted objects for App2\n")
139 for line in extractedObjectsApp2:
142 Out.write("\t//Extracted objects for functions for App2\n")
143 for line in extractedFunctionsApp2:
146 Out.write("\tApp2(Object obj) {\n")
147 Out.write("\t\treference = obj\n")
148 Out.write("\t\tlocation = obj.locationObject\n")
149 Out.write("\t\tapp = obj.appObject\n")
150 for line in extractedObjectsConstructorApp2:
151 Out.write("\t\t"+line)
153 Out.write("\t//Global variables for each app\n")
154 for line in GlobalVariablesEachApp:
157 Out.write("\t//Methods\n")
158 for line in setLocationMode:
160 for line in subscribe:
164 for line in unschedule:
166 for line in sendNotificationToContacts:
170 for line in sendPush:
172 for line in schedule:
183 Out.write("@Field def app1 = new App1(this)\n")
184 Out.write("@Field def app2 = new App2(this)\n")
185 Out.write("app1.installed()\n")
186 Out.write("app2.installed()\n")
188 for line in eventSimulator: