diff --git a/app/src/main/java/com/example/greenwatch/mvc/Device.java b/app/src/main/java/com/example/greenwatch/mvc/Device.java new file mode 100644 index 0000000..60bd3d0 --- /dev/null +++ b/app/src/main/java/com/example/greenwatch/mvc/Device.java @@ -0,0 +1,29 @@ +package com.example.greenwatch.mvc; + + +public class Device { + + private String sensor; + private Boolean isActive; + + public Device(String Sensor, Boolean Status) { + this.sensor = Sensor; + this.isActive = Status; + } + + public void setSensor(String Sensor) { + this.sensor = Sensor; + } + + public String getSensor() { + return sensor; + } + + public void setIsActive(Boolean Status) { + this.isActive = Status; + } + + public Boolean getIsActive() { + return isActive; + } +} diff --git a/app/src/main/java/com/example/greenwatch/mvc/DeviceController.java b/app/src/main/java/com/example/greenwatch/mvc/DeviceController.java new file mode 100644 index 0000000..aa7a9ea --- /dev/null +++ b/app/src/main/java/com/example/greenwatch/mvc/DeviceController.java @@ -0,0 +1,33 @@ +package com.example.greenwatch.mvc; + +public class DeviceController { + + private DeviceModel deviceModel; + private DeviceView deviceView; + + public DeviceController(DeviceView view) { + this.deviceModel = DeviceModel.getInstance(); + this.deviceView = view; + } + + public void createDevice(String Sensor, Boolean Status) { + Device device = new Device(Sensor, Status); + deviceModel.addDevice(device); + // todo: Inform view and sender about changes + } + public void setDeviceSensor(String UUID, String Sensor) { + deviceModel.setDeviceSensor(UUID, Sensor); + } + + public String getDeviceSensor(String UUID) { + return deviceModel.getDeviceSensor(UUID); + } + + public void setDeviceStatus(String UUID, Boolean Status) { + deviceModel.setDeviceStatus(UUID, Status); + } + + public Boolean getDeviceStatus(String UUID) { + return deviceModel.getDeviceStatus(UUID); + } +} diff --git a/app/src/main/java/com/example/greenwatch/mvc/DeviceModel.java b/app/src/main/java/com/example/greenwatch/mvc/DeviceModel.java new file mode 100644 index 0000000..be40f7f --- /dev/null +++ b/app/src/main/java/com/example/greenwatch/mvc/DeviceModel.java @@ -0,0 +1,47 @@ +package com.example.greenwatch.mvc; + +import java.util.Vector; + +public class DeviceModel { + private static DeviceModel itemModelInstance; + // todo: should be a hashmap with UUID Keys + private Vector connectetDevicesList; + + private DeviceModel() { + connectetDevicesList = new Vector(); + } + + public static synchronized DeviceModel getInstance() { + if (itemModelInstance == null){ + itemModelInstance = new DeviceModel(); + } + return itemModelInstance; + } + + public void addDevice(Device device) { + // todo: Check if divece already exist + connectetDevicesList.add(device); + } + + public Vector getConnectetDevicesList() { + return connectetDevicesList; + } + + public void setDeviceSensor(String UUID, String Sensor) { + // todo: iterate through HashMap and find Divece for UUID + } + + public String getDeviceSensor(String UUID) { + // todo: iterate through HashMap and find Divece for UUID + return "hasToBeDone"; + } + + public void setDeviceStatus(String UUID, Boolean Status) { + // todo: iterate through HashMap and find Divece for UUID + } + + public Boolean getDeviceStatus(String UUID) { + // todo: iterate through HashMap and find Divece for UUID + return false; + } +} diff --git a/app/src/main/java/com/example/greenwatch/mvc/DeviceView.java b/app/src/main/java/com/example/greenwatch/mvc/DeviceView.java new file mode 100644 index 0000000..55e62a9 --- /dev/null +++ b/app/src/main/java/com/example/greenwatch/mvc/DeviceView.java @@ -0,0 +1,10 @@ +package com.example.greenwatch.mvc; + +import java.util.Vector; + +public class DeviceView { + + public void updateView(Vector deviceVector) { + // todo: what should be displayed + } +}