Adding sunset and sunrise events.
authorrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 19:21:34 +0000 (12:21 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 19:21:34 +0000 (12:21 -0700)
ColorControl/ColorControls.groovy
Extractor/ExtractorScript.py
eventSimulator/locationSunriseEvent.groovy [new file with mode: 0644]
eventSimulator/locationSunriseTimeEvent.groovy [new file with mode: 0644]
eventSimulator/locationSunsetEvent.groovy [new file with mode: 0644]
eventSimulator/locationSunsetTimeEvent.groovy [new file with mode: 0644]

index 43c71e99d058b1d8e94a4685403517c5e66f95d4..4919ebe463070dc97715f5b96e18678b6aab086f 100644 (file)
@@ -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)                  
                if (colorTemperature != this.colorTemperature) {
                        this.colorTemperature = colorTemperature
                        colorControls[0].setColorTemperature(colorTemperature)                  
index 2281ade3cdd86ac53cc313fcd05ebe8844c8f2f9..bd7a320e6726a38726a7d6d864a66dc0b6c281b1 100644 (file)
@@ -48,6 +48,10 @@ eventTypeCounterMap =  {'lock': 2,
                                                'switch.off' : 1,
                                                'location' : 3,
                                                'mode' : 3,
                                                'switch.off' : 1,
                                                'location' : 3,
                                                'mode' : 3,
+                                               'sunset' : 1,
+                                               'sunsetTime' : 1,
+                                               'sunrise' : 1,
+                                               'sunriseTime' : 1,
                                                'acceleration' : 2,
                                                'acceleration.active' : 1,
                                                'acceleration.inactive' : 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)
                        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 == "\"":
                        if Temp == "\"":
-                               Temp = GetToken(F)              
+                               Temp = GetToken(F)
 
                        #print "DEBUG: %s - %s" % (variable, Temp)
                        #print capabilityMap
 
                        #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"):
                                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
 def CountEvents():
        global eventList
        numOfActualEvents = 0
+       #print "DEBUG: eventlist: %d" % len(eventList)
        for event in eventList:
        for event in eventList:
+               #print "DEBUG: Event: %s %d" % (event, eventTypeCounterMap[event])
                numOfActualEvents = numOfActualEvents + eventTypeCounterMap[event]
        return numOfActualEvents
 
                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
        #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
                # 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()
                        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")                      
                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 (file)
index 0000000..df4a7cd
--- /dev/null
@@ -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 (file)
index 0000000..e70070c
--- /dev/null
@@ -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 (file)
index 0000000..1852b78
--- /dev/null
@@ -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 (file)
index 0000000..b3f3596
--- /dev/null
@@ -0,0 +1,2 @@
+                       locationObject.setValue([name: "sunsetTime", value: "sunsetTime", deviceId: "locationID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])