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 eventSimulator = open("eventSimulator/"+"eventSimulator.groovy", "r")
14 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
15 setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
16 subscribe = open("Methods/"+"subscribe.groovy", "r")
17 runIn = open("Methods/"+"runIn.groovy", "r")
18 unschedule = open("Methods/"+"unschedule.groovy", "r")
19 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
20 sendSms = open("Methods/"+"sendSms.groovy", "r")
21 sendPush = open("Methods/"+"sendPush.groovy", "r")
22 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
23 schedule = open("Methods/"+"schedule.groovy", "r")
24 now = open("Methods/"+"now.groovy", "r")
25 getTemperatureScale = open("Methods/"+"getTemperatureScale.groovy", "r")
26 getSunriseAndSunset = open("Methods/"+"getSunriseAndSunset.groovy", "r")
27 App1 = open("Extractor/"+"App1/App1.groovy", "r")
28 extractedObjectsApp1 = open("Extractor/"+"App1/extractedObjectsApp1.groovy", "r")
29 extractedObjectsConstructorApp1 = open("Extractor/"+"App1/extractedObjectsConstructorApp1.groovy", "r")
30 extractedFunctionsApp1 = open("Extractor/"+"App1/extractedFunctionsApp1.groovy", "r")
35 Out.write("//Infrastructure for SmartThings Application\n")
36 Out.write("//Importing Libraries\n")
37 Out.write("import groovy.transform.Field\n")
39 Out.write("//Importing Classes\n")
40 Out.write("import ContactSensor.ContactSensor\n")
41 Out.write("import ContactSensor.ContactSensors\n")
42 Out.write("import DoorControl.DoorControl\n")
43 Out.write("import DoorControl.DoorControls\n")
44 Out.write("import Lock.Lock\n")
45 Out.write("import Lock.Locks\n")
46 Out.write("import Thermostat.Thermostat\n")
47 Out.write("import Thermostat.Thermostats\n")
48 Out.write("import Switch.Switch\n")
49 Out.write("import Switch.Switches\n")
50 Out.write("import PresenceSensor.PresenceSensor\n")
51 Out.write("import PresenceSensor.PresenceSensors\n")
52 Out.write("import Logger.Logger\n")
53 Out.write("import Location.LocationVar\n")
54 Out.write("import Location.Phrase\n")
55 Out.write("import appTouch.Touched\n")
56 Out.write("import NfcTouch.NfcTouch\n")
57 Out.write("import AeonKeyFob.AeonKeyFob\n")
58 Out.write("import AeonKeyFob.AeonKeyFobs\n")
59 Out.write("import MusicPlayer.MusicPlayer\n")
60 Out.write("import MusicPlayer.MusicPlayers\n")
61 Out.write("import MotionSensor.MotionSensor\n")
62 Out.write("import MotionSensor.MotionSensors\n")
63 Out.write("import ImageCapture.ImageCapture\n")
64 Out.write("import ImageCapture.ImageCaptures\n")
65 Out.write("import SmokeDetector.SmokeDetector\n")
66 Out.write("import SmokeDetector.SmokeDetectors\n")
67 Out.write("import Alarm.Alarm\n")
68 Out.write("import Alarm.Alarms\n")
69 Out.write("import SpeechSynthesis.SpeechSynthesis\n")
70 Out.write("import SpeechSynthesis.SpeechSynthesises\n")
71 Out.write("import Event.Event\n")
72 Out.write("import Timer.SimulatedTimer\n")
74 Out.write("//JPF's Verify API\n")
75 Out.write("import gov.nasa.jpf.vm.Verify\n")
77 Out.write("//Global eventHandler\n")
78 for line in eventHandler:
81 Out.write("//GlobalVariables for both Apps\n")
82 for line in GlobalVariablesBothApps:
85 Out.write("//Application #1\n")
86 Out.write("class App1 {\n")
87 Out.write("\tdef reference\n")
88 Out.write("\tdef location\n")
89 Out.write("\tdef app\n")
91 Out.write("\t//Extracted objects for App1\n")
92 for line in extractedObjectsApp1:
95 Out.write("\t//Extracted objects for functions for App1\n")
96 for line in extractedFunctionsApp1:
99 Out.write("\tApp1(Object obj) {\n")
100 Out.write("\t\treference = obj\n")
101 Out.write("\t\tlocation = obj.locationObject\n")
102 Out.write("\t\tapp = obj.appObject\n")
103 for line in extractedObjectsConstructorApp1:
104 Out.write("\t\t"+line)
106 Out.write("\t//Global variables for each app\n")
107 for line in GlobalVariablesEachApp:
110 Out.write("\t//Methods\n")
111 for line in setLocationMode:
113 for line in subscribe:
117 for line in unschedule:
119 for line in sendNotificationToContacts:
123 for line in sendPush:
125 for line in schedule:
129 for line in getTemperatureScale:
131 for line in getSunriseAndSunset:
143 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
146 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
147 setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
148 subscribe = open("Methods/"+"subscribe.groovy", "r")
149 runIn = open("Methods/"+"runIn.groovy", "r")
150 unschedule = open("Methods/"+"unschedule.groovy", "r")
151 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
152 sendSms = open("Methods/"+"sendSms.groovy", "r")
153 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
154 schedule = open("Methods/"+"schedule.groovy", "r")
155 now = open("Methods/"+"now.groovy", "r")
156 getTemperatureScale = open("Methods/"+"getTemperatureScale.groovy", "r")
157 getSunriseAndSunset = open("Methods/"+"getSunriseAndSunset.groovy", "r")
158 App2 = open("Extractor/"+"App2/App2.groovy", "r")
159 extractedObjectsApp2 = open("Extractor/"+"App2/extractedObjectsApp2.groovy", "r")
160 extractedObjectsConstructorApp2 = open("Extractor/"+"App2/extractedObjectsConstructorApp2.groovy", "r")
161 extractedFunctionsApp2 = open("Extractor/"+"App2/extractedFunctionsApp2.groovy", "r")
163 Out.write("//Application #2\n")
164 Out.write("class App2 {\n")
165 Out.write("\tdef reference\n")
166 Out.write("\tdef location\n")
167 Out.write("\tdef app\n")
169 Out.write("\t//Extracted objects for App2\n")
170 for line in extractedObjectsApp2:
173 Out.write("\t//Extracted objects for functions for App2\n")
174 for line in extractedFunctionsApp2:
177 Out.write("\tApp2(Object obj) {\n")
178 Out.write("\t\treference = obj\n")
179 Out.write("\t\tlocation = obj.locationObject\n")
180 Out.write("\t\tapp = obj.appObject\n")
181 for line in extractedObjectsConstructorApp2:
182 Out.write("\t\t"+line)
184 Out.write("\t//Global variables for each app\n")
185 for line in GlobalVariablesEachApp:
188 Out.write("\t//Methods\n")
189 for line in setLocationMode:
191 for line in subscribe:
195 for line in unschedule:
197 for line in sendNotificationToContacts:
201 for line in sendPush:
203 for line in schedule:
207 for line in getTemperatureScale:
209 for line in getSunriseAndSunset:
220 Out.write("@Field def app1 = new App1(this)\n")
221 Out.write("@Field def app2 = new App2(this)\n")
222 Out.write("app1.installed()\n")
223 Out.write("app2.installed()\n")
225 for line in eventSimulator: