private String displayName
private int energy
private int currentEnergy
+ private String status
- EnergyMeter(String id, String label, String displayName, int energy) {
+ EnergyMeter(String id, String label, String displayName, int energy, String status) {
this.id = id
this.label = label
this.displayName = displayName
this.energy = energy
+ this.status = status
}
//By Model Checker
this.currentEnergy = value.toInteger()
}
+ def reset() {
+ if (status != "on") {
+ status = "on"
+ println("the energy meter is on!")
+ }
+ }
+
+ def off() {
+ if (status != "off") {
+ status = "off"
+ println("the energy meter is off!")
+ }
+ }
+
def currentValue(String deviceFeature) {
if (deviceFeature == "energy") {
return energy
private String displayName = "energyMeter0"
private int energy = 50
private int currentEnergy = 50
+ private String status = "off"
EnergyMeters(Closure sendEvent, int deviceNumbers, boolean init) {
this.energy = 60
this.currentEnergy = 60
}
- energyMeters.add(new EnergyMeter(id, label, displayName, this.energy))
+ energyMeters.add(new EnergyMeter(id, label, displayName, this.energy, this.status))
}
//By Model Checker
energyMeters.collect(Input)
}
+ def reset() {
+ if (status != "on") {
+ status = "on"
+ energyMeters[0].reset()
+ }
+ }
+
+ def off() {
+ if (status != "off") {
+ status = "off"
+ energyMeters[0].off()
+ }
+ }
def currentValue(String deviceFeature) {
energyMeters[0].currentValue(deviceFeature)//It is called if we have only one device
private String name
private List contacts
private List phoneNumbers
+ private String temperatureScale
def sendEvent
-
+
private Phrase helloHome
LocationVar(Closure sendEvent) {
this.sendEvent = sendEvent
this.timeZone = TimeZone.getTimeZone("America/New_York")
this.name = "hub0"
+ this.temperatureScale = "F"
}
//By Model Checker
package MotionSensor
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class MotionSensor {
private String id
private String label
}
def statesSince() {
+ eventsSince()
+ }
+
+ def eventsSince() {
def evtActive = [[name: "motion", value: "active", deviceId: "motionSensorID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
def evtInactive = [[name: "motion", value: "inactive", deviceId: "motionSensorID0", descriptionText: "",
package MotionSensor
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class MotionSensors {
private int deviceNumbers
private List motionSensors
return motionSensors[0].statesSince()
}
+ def eventsSince(Date dateObj) {
+ return motionSensors[0].statesSince()
+ }
+
def getAt(int ix) {
motionSensors[ix]
}
package TemperatureMeasurement
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class TemperatureMeasurement {
private String id
private String label
this.currentTemperature = temperature
}
+ def eventsSince() {
+ def evtTemp = [[name: "temperature", value: this.temperature.toString(), deviceId: "temperatureMeasurementID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
+ def init = Verify.getInt(0,1)
+ def evtToSend = []
+ if (init == 0) {//return empty set
+ return evtToSend
+ } else if (init == 1) {//send one open event
+ evtTemp.each{
+ evtToSend.add(it)
+ }
+ return evtToSend
+ }
+ }
+
//By Model Checker
def setValue(String value) {
println("the temperature is changed to $value!")
package TemperatureMeasurement
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class TemperatureMeasurements {
private int deviceNumbers
private List temperatureMeasurements
}
}
+ def eventsSince(Date dateObj) {
+ return temperatureMeasurements[0].eventsSince()
+ }
+
//Methods for closures
def count(Closure Input) {
temperatureMeasurements.count(Input)