Adding remaining devices!
authoramiraj <amiraj.95@uci.edu>
Mon, 12 Aug 2019 23:03:19 +0000 (16:03 -0700)
committeramiraj <amiraj.95@uci.edu>
Mon, 12 Aug 2019 23:03:19 +0000 (16:03 -0700)
17 files changed:
Extractor/Extractor.groovy
Extractor/ExtractorScript.py
RemainingDevices/RemainingDevices.groovy [new file with mode: 0644]
Runner.py
eventSimulator/carbonDioxideEvent.groovy [new file with mode: 0644]
eventSimulator/consumableStatusEvent.groovy [new file with mode: 0644]
eventSimulator/lqiEvent.groovy [new file with mode: 0644]
eventSimulator/pHEvent.groovy [new file with mode: 0644]
eventSimulator/pressureEvent.groovy [new file with mode: 0644]
eventSimulator/rssiEvent.groovy [new file with mode: 0644]
eventSimulator/shockEvent.groovy [new file with mode: 0644]
eventSimulator/soundEvent.groovy [new file with mode: 0644]
eventSimulator/soundPressureLevelEvent.groovy [new file with mode: 0644]
eventSimulator/tamperEvent.groovy [new file with mode: 0644]
eventSimulator/ultravioletIndexEvent.groovy [new file with mode: 0644]
eventSimulator/voltageEvent.groovy [new file with mode: 0644]
eventSimulator/windowShadeEvent.groovy [new file with mode: 0644]

index 2e82fb3..cf19c45 100644 (file)
@@ -78,6 +78,7 @@ import ThreeAxis.ThreeAxis
 import ThreeAxis.ThreeAxises
 import Momentary.Momentary
 import Momentary.Momentaries
+import RemainingDevices.RemainingDevices
 import Timer.SimulatedTimer
 
 //GlobalVariables
@@ -417,6 +418,15 @@ def input(LinkedHashMap metaData) {
                println "Options: "+metaData['options']
        }
        def contains = 0
+       def List = ["capability.carbonDioxideMeasurement", "capability.consumable", "capability.pHMeasurement", "capability.shockSensor", 
+                   "capability.signalStrength", "capability.soundSensor", "capability.soundPressureLevel", "capability.tamperAlert",
+                   "capability.ultravioletIndex", "capability.voltageMeasurement", "capability.windowShade", "capability.sensor"]
+       String thisCapability = ""      
+       if (metaData['type'] in List) {
+               int dot = metaData['type'].indexOf('.')
+               thisCapability = metaData['type'].substring(dot + 1)
+               metaData['type'] = "capability.remainingDevices"
+       }
        switch(metaData['type']) {
                case "capability.lock":
                        globalObjects.eachLine { line ->
@@ -2051,6 +2061,29 @@ def input(LinkedHashMap metaData) {
                                extractedObjectsApp2.append("def "+metaData['name']+" = \""+userInput+"\"\n")
                        }
                        break
+               case "capability.remainingDevices":
+                       String nameOfObject = thisCapability+"Object"
+                       globalObjects.eachLine { line ->
+                               if(line.contains(nameOfObject)){
+                                       contains = 1
+                               }
+                       }
+
+                       if (contains == 0)
+                               globalObjects.append("@Field def $nameOfObject = new RemainingDevices(sendEvent, 1)\n")
+
+                       settings.put(metaData['name'], new RemainingDevices({}, 1))
+
+                       if (App == "App1") {
+                               extractedObjectsApp1.append("//Object for class remaining devices!\n")
+                               extractedObjectsApp1.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp1.append(metaData['name']+" = obj.$nameOfObject\n")               
+                       } else {
+                               extractedObjectsApp2.append("//Object for class remaining devices!\n")
+                               extractedObjectsApp2.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp2.append(metaData['name']+" = obj.$nameOfObject\n")
+                       }
+                       break
                default:
                        break
        }
index 8a888fc..1f01568 100644 (file)
@@ -60,7 +60,21 @@ eventTypeCounterMap =  {'lock': 2,
                                                'heatingSetpoint' : 1,
                                                'coolingSetpoint' : 1,
                                                'thermostatSetpoint' : 1,
-                                               'threeAxis' : 1}
+                                               'threeAxis' : 1,
+                                               'carbonDioxide' : 1,
+                                               'consumableStatus' : 1,
+                                               'pH' : 1,
+                                               'pressure': 1,
+                                               'shock': 1,
+                                               'lqi': 1,
+                                               'rssi': 1,
+                                               'sound': 1,
+                                               'soundPressureLevel' : 1,
+                                               'tamper' : 1,
+                                               'ultravioletIndex': 1,
+                                               'voltage': 1,
+                                               'windowShade': 1,
+                                               'touched': 1}
 
 # Mapping for specific event types
 eventTypesMap =           {'alarm.both': 'alarm',
@@ -1015,6 +1029,71 @@ def ExtractEvents(extractedEvents):
                         for line in event:
                                 extractedEvents.write(line)
                         event.close()
+               elif eventList[i] == "carbonDioxide":
+                       event = open("eventSimulator/carbonDioxideEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "consumableStatus":
+                       event = open("eventSimulator/consumableStatusEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "pH":
+                       event = open("eventSimulator/pHEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "pressure":
+                       event = open("eventSimulator/pressureEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "shock":
+                       event = open("eventSimulator/shockEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "lqi":
+                       event = open("eventSimulator/lqiEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "rssi":
+                       event = open("eventSimulator/rssiEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "sound":
+                       event = open("eventSimulator/soundEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "soundPressureLevel":
+                       event = open("eventSimulator/soundPressureLevelEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "tamper":
+                       event = open("eventSimulator/tamperEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "voltage":
+                       event = open("eventSimulator/voltageEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "ultravioletIndex":
+                       event = open("eventSimulator/ultravioletIndexEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "windowShade":
+                       event = open("eventSimulator/windowShadeEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
                        
                ###TODO: Add more events later
                extractedEvents.write("\n\t\t\tbreak\n")
diff --git a/RemainingDevices/RemainingDevices.groovy b/RemainingDevices/RemainingDevices.groovy
new file mode 100644 (file)
index 0000000..4381fdf
--- /dev/null
@@ -0,0 +1,17 @@
+//Create a class for remaining devices
+package RemainingDevices
+import Timer.SimulatedTimer
+
+public class RemainingDevices {
+       private int deviceNumbers
+       def sendEvent
+               
+       RemainingDevices(Closure sendEvent, int deviceNumbers) {
+               this.sendEvent = sendEvent              
+               this.deviceNumbers = deviceNumbers
+       }
+
+       def setValue(LinkedHashMap eventDataMap) {
+               sendEvent(eventDataMap)
+       }
+}
index 81efa7a..ed4e62c 100644 (file)
--- a/Runner.py
+++ b/Runner.py
@@ -121,6 +121,7 @@ Out.write("import ThreeAxis.ThreeAxis\n")
 Out.write("import ThreeAxis.ThreeAxises\n")
 Out.write("import Momentary.Momentary\n")
 Out.write("import Momentary.Momentaries\n")
+Out.write("import RemainingDevices.RemainingDevices\n")
 Out.write("import Event.Event\n")
 Out.write("import Timer.SimulatedTimer\n")
 Out.write("\n")
diff --git a/eventSimulator/carbonDioxideEvent.groovy b/eventSimulator/carbonDioxideEvent.groovy
new file mode 100644 (file)
index 0000000..83c88b9
--- /dev/null
@@ -0,0 +1,2 @@
+                       carbonDioxideMeasurementObject.setValue([name: "carbonDioxide", value: "45", deviceId: "carbonDioxideID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/consumableStatusEvent.groovy b/eventSimulator/consumableStatusEvent.groovy
new file mode 100644 (file)
index 0000000..8d57d89
--- /dev/null
@@ -0,0 +1,2 @@
+                       consumableObject.setValue([name: "consumableStatus", value: "status", deviceId: "consumableID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/lqiEvent.groovy b/eventSimulator/lqiEvent.groovy
new file mode 100644 (file)
index 0000000..b0cd918
--- /dev/null
@@ -0,0 +1,2 @@
+                       signalStrengthObject.setValue([name: "lqi", value: "70", deviceId: "signalStrengthID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/pHEvent.groovy b/eventSimulator/pHEvent.groovy
new file mode 100644 (file)
index 0000000..cf52512
--- /dev/null
@@ -0,0 +1,2 @@
+                       pHMeasurementObject.setValue([name: "pH", value: "40", deviceId: "pHMeasurementID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/pressureEvent.groovy b/eventSimulator/pressureEvent.groovy
new file mode 100644 (file)
index 0000000..68e0f75
--- /dev/null
@@ -0,0 +1,2 @@
+                       sensorObject.setValue([name: "pressure", value: "40", deviceId: "sensorID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/rssiEvent.groovy b/eventSimulator/rssiEvent.groovy
new file mode 100644 (file)
index 0000000..47e33e5
--- /dev/null
@@ -0,0 +1,2 @@
+                       signalStrengthObject.setValue([name: "rssi", value: "70", deviceId: "signalStrengthID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/shockEvent.groovy b/eventSimulator/shockEvent.groovy
new file mode 100644 (file)
index 0000000..4c5e8fc
--- /dev/null
@@ -0,0 +1,2 @@
+                       shockSensorObject.setValue([name: "shock", value: "shocked", deviceId: "shockSensorID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/soundEvent.groovy b/eventSimulator/soundEvent.groovy
new file mode 100644 (file)
index 0000000..8e9bd1e
--- /dev/null
@@ -0,0 +1,2 @@
+                       soundSensorObject.setValue([name: "sound", value: "54", deviceId: "soundSensorID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/soundPressureLevelEvent.groovy b/eventSimulator/soundPressureLevelEvent.groovy
new file mode 100644 (file)
index 0000000..e5dc02b
--- /dev/null
@@ -0,0 +1,2 @@
+                       soundPressureLevelObject.setValue([name: "soundPressureLevel", value: "70", deviceId: "soundPressureLevelID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/tamperEvent.groovy b/eventSimulator/tamperEvent.groovy
new file mode 100644 (file)
index 0000000..b69daee
--- /dev/null
@@ -0,0 +1,2 @@
+                       tamperAlertObject.setValue([name: "tamper", value: "tampered", deviceId: "tamperAlertID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/ultravioletIndexEvent.groovy b/eventSimulator/ultravioletIndexEvent.groovy
new file mode 100644 (file)
index 0000000..29994fd
--- /dev/null
@@ -0,0 +1,2 @@
+                       ultravioletIndexObject.setValue([name: "ultravioletIndex", value: "someValue", deviceId: "ultravioletIndexID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/voltageEvent.groovy b/eventSimulator/voltageEvent.groovy
new file mode 100644 (file)
index 0000000..4ab6d7e
--- /dev/null
@@ -0,0 +1,2 @@
+                       voltageMeasurementObject.setValue([name: "voltage", value: "22", deviceId: "voltageMeasurementID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
diff --git a/eventSimulator/windowShadeEvent.groovy b/eventSimulator/windowShadeEvent.groovy
new file mode 100644 (file)
index 0000000..6f9d92d
--- /dev/null
@@ -0,0 +1,2 @@
+                       windowShadeObject.setValue([name: "windowShade", value: "someValue", deviceId: "windowShadeID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])