From 327f179b820ab60fedb776897e490b52330b48c9 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Mon, 5 Aug 2019 12:21:34 -0700 Subject: [PATCH] Adding sunset and sunrise events. --- ColorControl/ColorControls.groovy | 2 +- Extractor/ExtractorScript.py | 42 +++++++++++++++++-- eventSimulator/locationSunriseEvent.groovy | 2 + .../locationSunriseTimeEvent.groovy | 2 + eventSimulator/locationSunsetEvent.groovy | 2 + eventSimulator/locationSunsetTimeEvent.groovy | 2 + 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 eventSimulator/locationSunriseEvent.groovy create mode 100644 eventSimulator/locationSunriseTimeEvent.groovy create mode 100644 eventSimulator/locationSunsetEvent.groovy create mode 100644 eventSimulator/locationSunsetTimeEvent.groovy diff --git a/ColorControl/ColorControls.groovy b/ColorControl/ColorControls.groovy index 43c71e9..4919ebe 100644 --- a/ColorControl/ColorControls.groovy +++ b/ColorControl/ColorControls.groovy @@ -185,7 +185,7 @@ public class ColorControls { } } - def setColorTemperature(String colorTemperature) { + def setColorTemperature(int colorTemperature) { if (colorTemperature != this.colorTemperature) { this.colorTemperature = colorTemperature colorControls[0].setColorTemperature(colorTemperature) diff --git a/Extractor/ExtractorScript.py b/Extractor/ExtractorScript.py index 2281ade..bd7a320 100644 --- a/Extractor/ExtractorScript.py +++ b/Extractor/ExtractorScript.py @@ -48,6 +48,10 @@ eventTypeCounterMap = {'lock': 2, 'switch.off' : 1, 'location' : 3, 'mode' : 3, + 'sunset' : 1, + 'sunsetTime' : 1, + 'sunrise' : 1, + 'sunriseTime' : 1, 'acceleration' : 2, 'acceleration.active' : 1, 'acceleration.inactive' : 1, @@ -150,12 +154,22 @@ def ExtractFunctions(F, appName): variable = Temp while (Temp != "\"" and Temp != "app" and Temp != "location"): Temp = GetToken(F) + if Temp == "location": + # See if we have another case for location + Temp = GetToken(F) # Get ',' + Temp = GetToken(F) # Get '"' + if Temp == "\"": + Temp = GetToken(F) + else: + # This is the special case where we will see, e.g., sunset, sunrise, etc. + Temp = "location" if Temp == "\"": - Temp = GetToken(F) + Temp = GetToken(F) #print "DEBUG: %s - %s" % (variable, Temp) #print capabilityMap - if Temp == "app" or Temp == "location": + #print "DEBUG: location variable: %s" % Temp + if Temp == "app" or Temp == "location" or Temp == "mode" or Temp == "sunset" or Temp == "sunrise" or Temp == "sunsetTime" or Temp == "sunriseTime": if Temp not in eventList: eventList.append(Temp) if (appName == "App1"): @@ -241,7 +255,9 @@ def AnalyzePhysicalInteraction(app1Capab, app2Capab): def CountEvents(): global eventList numOfActualEvents = 0 + #print "DEBUG: eventlist: %d" % len(eventList) for event in eventList: + #print "DEBUG: Event: %s %d" % (event, eventTypeCounterMap[event]) numOfActualEvents = numOfActualEvents + eventTypeCounterMap[event] return numOfActualEvents @@ -264,7 +280,7 @@ def ExtractEvents(extractedEvents): #print "DEBUG: App2: %d" % indexApp2 #print "DEBUG: eventList: %d" % len(eventList) isApp1 = True - while counter < len(eventList): + while counter < numOfActualEvents: # Interleave events from App1 and App2 if isApp1 is True: i = indexApp1 @@ -818,6 +834,26 @@ def ExtractEvents(extractedEvents): for line in event: extractedEvents.write(line) event.close() + elif eventList[i] == "sunrise": + event = open("eventSimulator/locationSunriseEvent.groovy", "r") + for line in event: + extractedEvents.write(line) + event.close() + elif eventList[i] == "sunset": + event = open("eventSimulator/locationSunsetEvent.groovy", "r") + for line in event: + extractedEvents.write(line) + event.close() + elif eventList[i] == "sunsetTime": + event = open("eventSimulator/locationSunsetTimeEvent.groovy", "r") + for line in event: + extractedEvents.write(line) + event.close() + elif eventList[i] == "sunriseTime": + event = open("eventSimulator/locationSunriseTimeEvent.groovy", "r") + for line in event: + extractedEvents.write(line) + event.close() elif eventList[i] == "acceleration": #Write two events subsequently event = open("eventSimulator/accelerationActiveEvent.groovy", "r") diff --git a/eventSimulator/locationSunriseEvent.groovy b/eventSimulator/locationSunriseEvent.groovy new file mode 100644 index 0000000..df4a7cd --- /dev/null +++ b/eventSimulator/locationSunriseEvent.groovy @@ -0,0 +1,2 @@ + locationObject.setValue([name: "sunrise", value: "sunrise", deviceId: "locationID0", descriptionText: "", + displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) diff --git a/eventSimulator/locationSunriseTimeEvent.groovy b/eventSimulator/locationSunriseTimeEvent.groovy new file mode 100644 index 0000000..e70070c --- /dev/null +++ b/eventSimulator/locationSunriseTimeEvent.groovy @@ -0,0 +1,2 @@ + locationObject.setValue([name: "sunriseTime", value: "sunriseTime", deviceId: "locationID0", descriptionText: "", + displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) diff --git a/eventSimulator/locationSunsetEvent.groovy b/eventSimulator/locationSunsetEvent.groovy new file mode 100644 index 0000000..1852b78 --- /dev/null +++ b/eventSimulator/locationSunsetEvent.groovy @@ -0,0 +1,2 @@ + locationObject.setValue([name: "sunset", value: "sunset", deviceId: "locationID0", descriptionText: "", + displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) diff --git a/eventSimulator/locationSunsetTimeEvent.groovy b/eventSimulator/locationSunsetTimeEvent.groovy new file mode 100644 index 0000000..b3f3596 --- /dev/null +++ b/eventSimulator/locationSunsetTimeEvent.groovy @@ -0,0 +1,2 @@ + locationObject.setValue([name: "sunsetTime", value: "sunsetTime", deviceId: "locationID0", descriptionText: "", + displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) -- 2.34.1