package AccelerationSensor
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class AccelerationSensor {
private String id
private String label
private String acceleration
private String currentAcceleration
private String accelerationLatestValue
- private List states = []
- private List timeOfStates = []
AccelerationSensor(String id, String label, String displayName, String acceleration, String accelerationLatestValue) {
this.id = id
this.accelerationLatestValue = value
this.acceleration = value
this.currentAcceleration = value
- this.states.add(value)
- this.timeOfStates.add(System.currentTimeMillis())
}
- def statesSince(String info, Date dateObj) {
- def List happenedStates = []
- def sinceThen = dateObj.time
- for (int i = 0;i < timeOfStates.size();i++) {
- if (timeOfStates[i]>=sinceThen)
- happenedStates.add(states[i])
+ def statesSince() {
+ def evtActive = [[name: "acceleration", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
+ [name: "acceleration.active", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+ def evtInactive = [[name: "acceleration", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
+ [name: "acceleration.inactive", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+ def init = Verify.getInt(0,4)
+ def evtToSend = []
+ if (init == 0) {//return empty set
+ return evtToSend
+ } else if (init == 1) {//send one active event
+ evtActive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 2) {//send two active events
+ evtActive.each{
+ evtToSend.add(it)
+ }
+ evtActive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 3) {//send one inactive event
+ evtInactive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 4) {//send two inactive events
+ evtInactive.each{
+ evtToSend.add(it)
+ }
+ evtInactive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ }
+ }
+
+ def eventsSince() {
+ def evtActive = [[name: "acceleration", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
+ [name: "acceleration.active", value: "active", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+ def evtInactive = [[name: "acceleration", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'],
+ [name: "acceleration.inactive", value: "inactive", deviceId: "accelerationSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+ def init = Verify.getInt(0,4)
+ def evtToSend = []
+ if (init == 0) {//return empty set
+ return evtToSend
+ } else if (init == 1) {//send one active event
+ evtActive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 2) {//send two active events
+ evtActive.each{
+ evtToSend.add(it)
+ }
+ evtActive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 3) {//send one inactive event
+ evtInactive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 4) {//send two inactive events
+ evtInactive.each{
+ evtToSend.add(it)
+ }
+ evtInactive.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
}
- return happenedStates
}
}
}
+ //methods
+ def eventsSince(Date dateObj) {
+ return accelerationSensors[0].eventsSince()
+ }
+
+ def statesSince(String info, Date dateObj) {
+ return accelerationSensors[0].statesSince()
+ }
+
//Methods for closures
def count(Closure Input) {
accelerationSensors.count(Input)
accelerationSensors[0].latestValue(deviceFeature)//It is called if we have only one device
}
- def statesSince(String info, Date dateObj) {
- return accelerationSensors[0].statesSince(info, dateObj)
- }
-
def getAt(int ix) {
accelerationSensors[ix]
}
--- /dev/null
+//Create a class for button
+package Button
+import Timer.SimulatedTimer
+
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
+public class Button {
+ private String id
+ private String label
+ private String displayName
+ private String button
+ private int numberOfButtons
+
+ Button(String id, String label, String displayName, String button, int numberOfButtons) {
+ this.id = id
+ this.label = label
+ this.displayName = displayName
+ this.button = button
+ this.numberOfButtons = numberOfButtons
+ }
+
+ def setValue(LinkedHashMap eventDataMap) {
+ button = eventDataMap["value"]
+ println("the button is $button!")
+ }
+
+ def eventsSince() {
+ def evtHeld = [[name: "button", value: "held", deviceId: "buttonID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+ def evtPushed = [[name: "button", value: "pushed", deviceId: "buttonID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+ def init = Verify.getInt(0,4)
+ def evtToSend = []
+ if (init == 0) {//return empty set
+ return evtToSend
+ } else if (init == 1) {//send one held event
+ evtHeld.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 2) {//send two held events
+ evtHeld.each{
+ evtToSend.add(it)
+ }
+ evtHeld.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 3) {//send one pushed event
+ evtPushed.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ } else if (init == 4) {//send two pushed events
+ evtPushed.each{
+ evtToSend.add(it)
+ }
+ evtPushed.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ }
+ }
+}
--- /dev/null
+//Create a class for button
+package Button
+import Timer.SimulatedTimer
+
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
+public class Buttons {
+ private int deviceNumbers
+ private List buttons
+ def sendEvent
+
+ //For one device(We cannot have obj.id)-> We should have obj[0].id
+ private String id = "buttonID0"
+ private String label = "button0"
+ private String displayName = "button0"
+ private String button = "pushed"
+ private int numberOfButtons = 4
+
+
+ Buttons(Closure sendEvent, int deviceNumbers) {
+ this.sendEvent = sendEvent
+ this.deviceNumbers = deviceNumbers
+ this.buttons = []
+
+ buttons.add(new Button(id, label, displayName, button, numberOfButtons))
+ }
+
+ //By Model Checker
+ def setValue(LinkedHashMap eventDataMap) {
+ buttons[0].setValue(eventDataMap)
+ sendEvent(eventDataMap)
+ }
+
+ //Methods for closures
+ def count(Closure Input) {
+ buttons.count(Input)
+ }
+ def size() {
+ buttons.size()
+ }
+ def each(Closure Input) {
+ buttons.each(Input)
+ }
+ def sort(Closure Input) {
+ buttons.sort(Input)
+ }
+ def find(Closure Input) {
+ buttons.find(Input)
+ }
+ def collect(Closure Input) {
+ buttons.collect(Input)
+ }
+
+
+ //methods
+ def eventsSince(Date dateObj) {
+ return buttons[0].eventsSince()
+ }
+
+
+ def getAt(int ix) {
+ buttons[ix]
+ }
+}
private String label
private String displayName
private String color
+ private String currentColor
private String currentSwitch
private int level
+ private int currentLevel
private int hue
+ private int currentHue
private int saturation
+ private int currentSaturation
private int colorTemperature
ColorControl(Closure sendEvent, String id, String label, String displayName, String color, int hue, int saturation, int level, String currentSwitch, int colorTemperature) {
this.label = label
this.displayName = displayName
this.color = color
+ this.currentColor = color
this.hue = hue
+ this.currentHue = hue
this.saturation = saturation
+ this.currentSaturation = saturation
this.level = level
+ this.currentLevel = level
this.currentSwitch = currentSwitch
this.colorTemperature = colorTemperature
this.sendEvent = sendEvent
def setValue(String value, String name) {
if ((name == "color") && (value != this.color)) {
this.color = value
+ this.currentColor = value
println("the color of the light is changed to $value!")
} else if ((name == "hue") && (value != this.hue)) {
this.hue = value.toInteger()
+ this.currentHue = value.toInteger()
println("The hue level of the light is changed to $value!")
} else if ((name == "saturation") && (value != this.saturation)) {
this.saturation = value.toInteger()
+ this.currentSaturation = value.toInteger()
println("The saturation level of the light is changed to $value!")
} else if ((name == "level") && (value != this.level)) {
+ this.currentLevel = value.toInteger()
this.level = value.toInteger()
println("The level of the light is changed to $value!")
} else if ((name == "currentSwitch") && (value != this.currentSwitch)) {
//methods
def setColor(String color) {
if (color != this.color) {
+ this.currentColor = color
this.color = color
println("The color of the light is changed to $color!")
sendEvent([name: "color", value: "$color", deviceId: this.id, descriptionText: "",
def setHue(int hue) {
if (hue != this.hue) {
this.hue = hue
+ this.currentHue = hue
println("The hue level of the light is changed to $hue!")
sendEvent([name: "hue", value: "$hue", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
def setSaturation(int saturation) {
if (saturation != this.saturation) {
+ this.currentSaturation = saturation
this.saturation = saturation
println("The saturation level of the light is changed to $saturation!")
sendEvent([name: "saturation", value: "$saturation", deviceId: this.id, descriptionText: "",
def setLevel(int level) {
if (level != this.level) {
+ this.currentLevel = level
this.level = level
println("The level of the light is changed to $level!")
sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
private String label = "colorControl0"
private String displayName = "colorControl0"
private String color = "red"
+ private String currentColor = "red"
private String currentSwitch = "off"
private int level = 50
+ private int currentLevel = 50
private int hue = 50
+ private int currentHue = 50
private int saturation = 50
+ private int currentSaturation = 50
private int colorTemperature = 15000
this.deviceNumbers = deviceNumbers
this.colorControls = []
- /*def initHue = Verify.getIntFromList(30, 50, 70)
+ def initHue = Verify.getIntFromList(30, 50)
this.hue = initHue
- def initSat = Verify.getIntFromList(40, 50, 60)
+ def initSat = Verify.getIntFromList(40, 50)
this.saturation = initSat
def init = Verify.getInt(0,2)
if (init == 0) {
this.color = "red"
- } else if (init == 1) {
- this.color = "green"
} else {
this.color = "blue"
- }*/
+ }
colorControls.add(new ColorControl(sendEvent, id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
}
def setValue(LinkedHashMap eventDataMap) {
if (eventDataMap["name"] == "color") {
if (eventDataMap["value"] != colorControls[0].color) {
+ this.currentColor = eventDataMap["value"]
this.color = eventDataMap["value"]
colorControls[0].setValue(eventDataMap["value"], "color")
sendEvent(eventDataMap)
} else if (eventDataMap["name"] == "hue") {
if (eventDataMap["value"].toInteger() != colorControls[0].hue) {
this.hue = eventDataMap["value"].toInteger()
+ this.currentHue = eventDataMap["value"].toInteger()
colorControls[0].setValue(eventDataMap["value"], "hue")
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "saturation") {
if (eventDataMap["value"].toInteger() != colorControls[0].saturation) {
this.saturation = eventDataMap["value"].toInteger()
+ this.currentSaturation = eventDataMap["value"].toInteger()
colorControls[0].setValue(eventDataMap["value"], "saturation")
sendEvent(eventDataMap)
}
}
} else if (eventDataMap["name"] == "level") {
if (eventDataMap["value"].toInteger() != colorControls[0].level) {
+ this.currentLevel = eventDataMap["value"].toInteger()
this.level = eventDataMap["value"].toInteger()
colorControls[0].setValue(eventDataMap["value"], "level")
sendEvent(eventDataMap)
//methods
def setColor(String color) {
if (color != this.color) {
+ this.currentColor = color
this.color = color
colorControls[0].setColor(color)
}
def setHue(int hue) {
if (hue != this.hue) {
- this.hue = hue
+ this.hue = hue
+ this.currentHue = hue
colorControls[0].setHue(hue)
}
}
def setSaturation(int saturation) {
if (saturation != this.saturation) {
+ this.currentSaturation = saturation
this.saturation = saturation
colorControls[0].setSaturation(saturation)
}
def setLevel(int level) {
if (level != this.level) {
+ this.currentLevel = level
this.level = level
colorControls[0].setLevel(level)
}
--- /dev/null
+//Create a class for color temperature
+package ColorTemperature
+import Timer.SimulatedTimer
+
+
+public class ColorTemperature {
+ def sendEvent
+ private String id
+ private String label
+ private String displayName
+ private String currentSwitch
+ private int level
+ private int currentLevel
+ private int colorTemperature
+
+ ColorTemperature(Closure sendEvent, String id, String label, String displayName, int level, String currentSwitch, int colorTemperature) {
+ this.id = id
+ this.label = label
+ this.displayName = displayName
+ this.level = level
+ this.currentLevel = level
+ this.currentSwitch = currentSwitch
+ this.colorTemperature = colorTemperature
+ this.sendEvent = sendEvent
+ }
+
+ //By model checker
+ def setValue(String value, String name) {
+ if ((name == "level") && (value != this.level)) {
+ this.currentLevel = value.toInteger()
+ this.level = value.toInteger()
+ println("The level of the light is changed to $value!")
+ } else if ((name == "currentSwitch") && (value != this.currentSwitch)) {
+ this.currentSwitch = value
+ println("The light is changed to $value!")
+ } else if ((name == "colorTemperature") && (value != this.colorTemperature)) {
+ this.colorTemperature = value.toInteger()
+ println("The color temperature level of the light is changed to $value!")
+ }
+ }
+
+ //methods
+ def setLevel(int level) {
+ if (level != this.level) {
+ this.currentLevel = level
+ this.level = level
+ println("The level of the light is changed to $level!")
+ sendEvent([name: "level", value: "$level", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
+ def setColorTemperature(int colorTemperature) {
+ if (colorTemperature != this.colorTemperature) {
+ this.colorTemperature = colorTemperature
+ println("The color temperature level of the light is changed to $colorTemperature!")
+ sendEvent([name: "colorTemperature", value: "$colorTemperature", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
+ def on(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ println("The light is changed to $currentSwitch!")
+ sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.on", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
+ def off(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ println("The light is changed to $currentSwitch!")
+ sendEvent([name: "switch", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "switch.off", value: "$currentSwitch", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ }
+ }
+
+ def currentValue(String deviceFeature) {
+ if (deviceFeature == "level") {
+ return level
+ } else if (deviceFeature == "colorTemperature") {
+ return colorTemperature
+ } else if (deviceFeature == "switch") {
+ return currentSwitch
+ }
+ }
+
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "level") {
+ return level
+ } else if (deviceFeature == "colorTemperature") {
+ return colorTemperature
+ } else if (deviceFeature == "switch") {
+ return currentSwitch
+ }
+ }
+}
--- /dev/null
+//Create a class for color temperature
+package ColorTemperature
+import Timer.SimulatedTimer
+
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
+public class ColorTemperatures {
+ private int deviceNumbers
+ private List colorTemperatues
+ def sendEvent
+
+ //For one device(We cannot have obj.id)-> We should have obj[0].id
+ private String id = "colorTemperatureID0"
+ private String label = "colorTemperature0"
+ private String displayName = "colorTemperature0"
+ private String currentSwitch = "off"
+ private int level = 50
+ private int currentLevel = 50
+ private int colorTemperature = 15000
+
+
+ ColorTemperatures(Closure sendEvent, int deviceNumbers) {
+ this.sendEvent = sendEvent
+ this.deviceNumbers = deviceNumbers
+ this.colorTemperatues = []
+
+ def initLevel = Verify.getIntFromList(50, 70)
+ this.level = initLevel
+ def initTemp = Verify.getIntFromList(10000, 15000)
+ this.colorTemperature = initTemp
+ def init = Verify.getBoolean
+ if (init) {
+ this.currentSwitch = "off"
+ } else {
+ this.currentSwitch = "on"
+ }
+
+ colorTemperatues.add(new ColorTemperature(sendEvent, id, label, displayName, this.level, this.currentSwitch, this.colorTemperature))
+ }
+
+ //Methods for closures
+ def count(Closure Input) {
+ colorTemperatues.count(Input)
+ }
+ def size() {
+ colorTemperatues.size()
+ }
+ def each(Closure Input) {
+ colorTemperatues.each(Input)
+ }
+ def find(Closure Input) {
+ colorTemperatues.find(Input)
+ }
+ def sort(Closure Input) {
+ colorTemperatues.sort(Input)
+ }
+ def collect(Closure Input) {
+ colorTemperatues.collect(Input)
+ }
+
+ //By model checker
+ def setValue(LinkedHashMap eventDataMap) {
+ if (eventDataMap["name"] == "switch") {
+ if (eventDataMap["value"] != colorTemperatues[0].currentSwitch) {
+ this.currentSwitch = eventDataMap["value"]
+ colorTemperatues[0].setValue(eventDataMap["value"], "switch")
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"] == "colorTemperature") {
+ if (eventDataMap["value"].toInteger() != colorTemperatues[0].colorTemperature) {
+ this.colorTemperature = eventDataMap["value"].toInteger()
+ colorTemperatues[0].setValue(eventDataMap["value"], "colorTemperature")
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"] == "level") {
+ if (eventDataMap["value"].toInteger() != colorTemperatues[0].level) {
+ this.currentLevel = eventDataMap["value"].toInteger()
+ this.level = eventDataMap["value"].toInteger()
+ colorTemperatues[0].setValue(eventDataMap["value"], "level")
+ sendEvent(eventDataMap)
+ }
+ }
+ }
+
+
+ //methods
+ def setLevel(int level) {
+ if (level != this.level) {
+ this.currentLevel = level
+ this.level = level
+ colorTemperatues[0].setLevel(level)
+ }
+ }
+
+ def setColorTemperature(String colorTemperature) {
+ if (colorTemperature != this.colorTemperature) {
+ this.colorTemperature = colorTemperature
+ colorTemperatues[0].setColorTemperature(colorTemperature)
+ }
+ }
+
+ def on(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ colorTemperatues[0].on(currentSwitch)
+ }
+ }
+
+ def off(String currentSwitch) {
+ if (currentSwitch != this.currentSwitch) {
+ this.currentSwitch = currentSwitch
+ colorTemperatues[0].off(currentSwitch)
+ }
+ }
+
+ def currentValue(String deviceFeature) {
+ colorTemperatues[0].currentValue(deviceFeature)
+ }
+
+ def latestValue(String deviceFeature) {
+ colorTemperatues[0].latestValue(deviceFeature)
+ }
+
+ def getAt(int ix) {
+ colorTemperatues[ix]
+ }
+}
private String unit
private String data
private int integerValue
+ private double doubleValue
private List integerValues = ["battery", "hue", "saturation", "energy", "level", "temperature",
"heatingSetpoint", "coolingSetpoint", "thermostatSetpoint", "illuminance"]
this.unit = unit
this.data = data
this.displayed = displayed
- if (integerValues.contains(name))
+ if (integerValues.contains(name)) {
this.integerValue = value.toInteger()
+ this.doubleValue = Double.parseDouble(value);
+ }
}
}
import Valve.Valves
import MobilePresence.MobilePresence
import MobilePresence.MobilePresences
+import ColorTemperature.ColorTemperature
+import ColorTemperature.ColorTemperatures
+import Button.Button
+import Button.Buttons
import Timer.SimulatedTimer
//GlobalVariables
@Field def sleepSensorObject0
@Field def sleepSensorObject1
@Field def sleepSensorObject2
-//Global Object for class sleep sensor!
+//Global Object for class step sensor!
@Field stepSensorObjects = 0
@Field def stepSensorObject0
@Field def stepSensorObject1
@Field def temperatureMeasurementObject0
@Field def temperatureMeasurementObject1
@Field def temperatureMeasurementObject2
-//Global Object for class temperature measurement!
+//Global Object for class water sensor!
@Field waterSensorObjects = 0
@Field def waterSensorObject0
@Field def waterSensorObject1
@Field def valveObject0
@Field def valveObject1
@Field def valveObject2
-//Global Object for class valve!
+//Global Object for class mobile presence!
@Field mobilePresenceObjects = 0
@Field def mobilePresenceObject0
@Field def mobilePresenceObject1
@Field def mobilePresenceObject2
-
+//Global Object for class color temperature!
+@Field colorTemperatureObjects = 0
+@Field def colorTemperatureObject0
+@Field def colorTemperatureObject1
+@Field def colorTemperatureObject2
+//Global Object for class button!
+@Field buttonObjects = 0
+@Field def buttonObject0
+@Field def buttonObject1
+@Field def buttonObject2
//Global variables
extractedObjectsConstructorApp2.append(metaData['name']+" = obj.alarmObject\n")
}
break
+ case "capability.button":
+ globalObjects.eachLine { line ->
+ if(line.contains("buttonObject")){
+ contains = 1
+ }
+ }
+
+ if (contains == 0)
+ globalObjects.append("@Field def buttonObject = new Buttons(sendEvent, 1)\n")
+
+ if (buttonObjects == 0) {
+ buttonObject0 = metaData['name']
+ this[buttonObject0] = new Buttons({}, 1)
+ } else if (buttonObjects == 1) {
+ buttonObject1 = metaData['name']
+ this[buttonObject1] = new Buttons({}, 1)
+ } else if (buttonObjects == 2) {
+ buttonObject2 = metaData['name']
+ this[buttonObject2] = new Buttons({}, 1)
+ }
+
+ buttonObjects=buttonObjects+1
+
+ settings.put(metaData['name'], new Buttons({}, 1))
+
+ if (App == "App1") {
+ extractedObjectsApp1.append("//Object for class Button!\n")
+ extractedObjectsApp1.append("def "+metaData['name']+"\n")
+ extractedObjectsConstructorApp1.append(metaData['name']+" = obj.buttonObject\n")
+ } else {
+ extractedObjectsApp2.append("//Object for class Button!\n")
+ extractedObjectsApp2.append("def "+metaData['name']+"\n")
+ extractedObjectsConstructorApp2.append(metaData['name']+" = obj.buttonObject\n")
+ }
+ break
case "capability.battery":
globalObjects.eachLine { line ->
if(line.contains("batteryObject")){
extractedObjectsConstructorApp2.append(metaData['name']+" = obj.carbonMonoxideDetectorObject\n")
}
break
+ case "capability.colorTemperature":
+ globalObjects.eachLine { line ->
+ if(line.contains("colorTemperatureObject")){
+ contains = 1
+ }
+ }
+
+ if (contains == 0)
+ globalObjects.append("@Field def colorTemperatureObject = new ColorTemperatures(sendEvent, 1)\n")
+
+ if (colorTemperatureObjects == 0) {
+ colorTemperatureObject0 = metaData['name']
+ this[colorTemperatureObject0] = new ColorTemperatures({}, 1)
+ } else if (colorTemperatureObjects == 1) {
+ colorTemperatureObject1 = metaData['name']
+ this[colorTemperatureObject1] = new ColorTemperatures({}, 1)
+ } else if (colorTemperatureObjects == 2) {
+ colorTemperatureObject2 = metaData['name']
+ this[colorTemperatureObject2] = new ColorTemperatures({}, 1)
+ }
+
+ colorTemperatureObjects=colorTemperatureObjects+1
+
+ settings.put(metaData['name'], new ColorTemperatures({}, 1))
+
+ if (App == "App1") {
+ extractedObjectsApp1.append("//Object for class color temperature!\n")
+ extractedObjectsApp1.append("def "+metaData['name']+"\n")
+ extractedObjectsConstructorApp1.append(metaData['name']+" = obj.colorTemperatureObject\n")
+ } else {
+ extractedObjectsApp2.append("//Object for class color control!\n")
+ extractedObjectsApp2.append("def "+metaData['name']+"\n")
+ extractedObjectsConstructorApp2.append(metaData['name']+" = obj.colorTemperatureObject\n")
+ }
+ break
case "capability.colorControl":
globalObjects.eachLine { line ->
if(line.contains("colorControlObject")){
extractedObjectsConstructorApp2.append(metaData['name']+" = obj.mobilePresenceObject\n")
}
break
- case "capability.button":
case "device.aeonKeyFob":
globalObjects.eachLine { line ->
if(line.contains("aeonKeyFobObject")){
extractedEvents.write(line)
event.close()
elif eventList[i] == "unlock":
- event = open("eventSimulator/unlockEvent.groovy", "r")
- for line in event:
- extractedEvents.write(line)
- event.close()
+ #Don't do anything for this case
+ counter = counter - 1
elif eventList[i] == "contact.open":
event = open("eventSimulator/contactOpenEvent.groovy", "r")
for line in event:
event.close()
elif eventList[i] == "doorState":
#Write two events subsequently
- extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
- extractedEvents.write("\t\t\tif (event == 0) {\n")
event = open("eventSimulator/doorOpenEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event = open("eventSimulator/musicPlayerLevelEvent.groovy", "r")
elif capability == "capability.switchLevel":
event = open("eventSimulator/switchLevelEvent.groovy", "r")
+ elif capability == "capability.colorControl":
+ event = open("eventSimulator/colorLevelChangeEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event.close()
--- /dev/null
+/////////////////////////////////////////////////////////////////////
+def parseJson(String data) {
+ return new groovy.json.JsonSlurper().parseText(data)
+}
\ No newline at end of file
--- /dev/null
+/////////////////////////////////////////////////////////////////////
+def unsubscribe() {
+ objectList.clear()
+ eventList.clear()
+ functionList.clear()
+}
\ No newline at end of file
canSchedule = open("Methods/"+"canSchedule.groovy", "r")
createAccessToken = open("Methods/"+"createAccessToken.groovy", "r")
runOnce = open("Methods/"+"runOnce.groovy", "r")
+parseJson = open("Methods/"+"parseJson.groovy", "r")
+unsubscribe = open("Methods/"+"unsubscribe.groovy", "r")
App1 = open("Extractor/"+"App1/App1.groovy", "r")
extractedObjectsApp1 = open("Extractor/"+"App1/extractedObjectsApp1.groovy", "r")
extractedObjectsConstructorApp1 = open("Extractor/"+"App1/extractedObjectsConstructorApp1.groovy", "r")
Out.write("import Valve.Valves\n")
Out.write("import MobilePresence.MobilePresence\n")
Out.write("import MobilePresence.MobilePresences\n")
+Out.write("import ColorTemperature.ColorTemperature\n")
+Out.write("import ColorTemperature.ColorTemperatures\n")
+Out.write("import Button.Button\n")
+Out.write("import Button.Buttons\n")
Out.write("import Event.Event\n")
Out.write("import Timer.SimulatedTimer\n")
Out.write("\n")
Out.write("\t"+line)
for line in runOnce:
Out.write("\t"+line)
+for line in parseJson:
+ Out.write("\t"+line)
+for line in unsubscribe:
+ Out.write("\t"+line)
Out.write("\n")
Start = 0
for line in App1:
canSchedule = open("Methods/"+"canSchedule.groovy", "r")
createAccessToken = open("Methods/"+"createAccessToken.groovy", "r")
runOnce = open("Methods/"+"runOnce.groovy", "r")
+parseJson = open("Methods/"+"parseJson.groovy", "r")
+unsubscribe = open("Methods/"+"unsubscribe.groovy", "r")
App2 = open("Extractor/"+"App2/App2.groovy", "r")
extractedObjectsApp2 = open("Extractor/"+"App2/extractedObjectsApp2.groovy", "r")
extractedObjectsConstructorApp2 = open("Extractor/"+"App2/extractedObjectsConstructorApp2.groovy", "r")
Out.write("\t"+line)
for line in runOnce:
Out.write("\t"+line)
+for line in parseJson:
+ Out.write("\t"+line)
+for line in unsubscribe:
+ Out.write("\t"+line)
Out.write("\n")
Start = 0
for line in App2:
this.rate = value.toInteger()
}
}
+
+
+ def currentValue(String deviceFeature) {
+ if (deviceFeature == "level") {
+ return level
+ } else if (deviceFeature == "switch") {
+ return switchState
+ }
+ }
+
+ def latestValue(String deviceFeature) {
+ if (deviceFeature == "level") {
+ return level
+ } else if (deviceFeature == "switch") {
+ return switchState
+ }
+ }
}
}
}
+ def currentValue(String deviceFeature) {
+ switchLevels[0].currentValue(deviceFeature)
+ }
+
+ def latestValue(String deviceFeature) {
+ switchLevels[0].latestValue(deviceFeature)
+ }
+
+
def getAt(int ix) {
switchLevels[ix]
}
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
switchObject.setValue([name: "switch", value: "on", deviceId: "switchID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+switchObject.setValue([name: "switch.off", value: "off", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+switchObject.setValue([name: "switch.on", value: "on", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
//
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
colorControlObject.setValue([name: "switch", value: "off", deviceId: "colorControlID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "switch.on", value: "on", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorControlObject.setValue([name: "switch.off", value: "off", deviceId: "colorControlID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
colorControlObject.setValue([name: "colorTemperature", value: "50", deviceId: "colorControlID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/*events*/
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
relaySwitchObject.setValue([name: "switch", value: "on", deviceId: "relaySwitchID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+relaySwitchObject.setValue([name: "switch.off", value: "off", deviceId: "relaySwitchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+relaySwitchObject.setValue([name: "switch.on", value: "on", deviceId: "relaySwitchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
//
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
switchLevelObject.setValue([name: "switch", value: "off", deviceId: "switchLevelID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+switchLevelObject.setValue([name: "switch.on", value: "on", deviceId: "switchLevelID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+switchLevelObject.setValue([name: "switch.off", value: "off", deviceId: "switchLevelID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
/////
/*events*/
//
/////
/*events*/
//
+-------------------------------------------------------------------------------
+
+
+//For color temperature:
+int colorTemperature
+String switchState
+/*events*/
+colorTemperatureObject.setValue([name: "switch", value: "off", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorTemperatureObject.setValue([name: "switch", value: "on", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorTemperatureObject.setValue([name: "switch.off", value: "off", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorTemperatureObject.setValue([name: "switch.on", value: "on", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+colorTemperatureObject.setValue([name: "colorTemperature", value: "13000", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+/////
+/*events*/
+//
+-------------------------------------------------------------------------------
+
+
+//For button:
+String button
+/*events*/
+buttonObject.setValue([name: "button", value: "held", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])
+buttonObject.setValue([name: "button", value: "push", deviceId: "switchID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"buttonNumber": 1}'])
+/////
+/*events*/
+//
+
#!/bin/bash
# Device conflict
-python ModelCheck.py ../jpf-core/ ../logs/thermostats/ ../smartapps/ appLists/device-interaction/thermostatsAppList appLists/device-interaction/thermostatsAppList2
+python ModelCheck.py ../jpf-core/ ../logs/nonHueLights/ ../smartapps/ appLists/device-interaction/nonHueLightsAppList appLists/device-interaction/nonHueLightsAppList2
+#python ModelCheck.py ../jpf-core/ ../logs/hueLights/ ../smartapps/ appLists/device-interaction/hueLightsAppList
+#python ModelCheck.py ../jpf-core/ ../logs/thermostats/ ../smartapps/ appLists/device-interaction/thermostatsAppList appLists/device-interaction/thermostatsAppList2
#python ModelCheck.py ../jpf-core/ ../logs/alarms/ ../smartapps/ appLists/device-interaction/alarmsAppList appLists/device-interaction/alarmsAppList2
#python ModelCheck.py ../jpf-core/ ../logs/locks/ ../smartapps/ appLists/device-interaction/locksAppList appLists/device-interaction/locksAppList2
#python ModelCheck.py ../jpf-core/ ../logs/musicPlayers/ ../smartapps/ appLists/device-interaction/musicPlayersAppList