import ThreeAxis.ThreeAxises
import Momentary.Momentary
import Momentary.Momentaries
+import RemainingDevices.RemainingDevices
import Timer.SimulatedTimer
//GlobalVariables
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 ->
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
}
'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',
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")
--- /dev/null
+//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)
+ }
+}
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")
--- /dev/null
+ carbonDioxideMeasurementObject.setValue([name: "carbonDioxide", value: "45", deviceId: "carbonDioxideID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ consumableObject.setValue([name: "consumableStatus", value: "status", deviceId: "consumableID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ signalStrengthObject.setValue([name: "lqi", value: "70", deviceId: "signalStrengthID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ pHMeasurementObject.setValue([name: "pH", value: "40", deviceId: "pHMeasurementID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ sensorObject.setValue([name: "pressure", value: "40", deviceId: "sensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ signalStrengthObject.setValue([name: "rssi", value: "70", deviceId: "signalStrengthID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ shockSensorObject.setValue([name: "shock", value: "shocked", deviceId: "shockSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ soundSensorObject.setValue([name: "sound", value: "54", deviceId: "soundSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ soundPressureLevelObject.setValue([name: "soundPressureLevel", value: "70", deviceId: "soundPressureLevelID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ tamperAlertObject.setValue([name: "tamper", value: "tampered", deviceId: "tamperAlertID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ ultravioletIndexObject.setValue([name: "ultravioletIndex", value: "someValue", deviceId: "ultravioletIndexID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ voltageMeasurementObject.setValue([name: "voltage", value: "22", deviceId: "voltageMeasurementID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ windowShadeObject.setValue([name: "windowShade", value: "someValue", deviceId: "windowShadeID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])