|
@@ -5,34 +5,57 @@ import org.iotivity.OCEndpoint;
|
|
|
public class Light {
|
|
|
|
|
|
// Device : oic.d.light
|
|
|
- static public final String DT_LIGHT = "oic.d.light";
|
|
|
- // Resources : oic.r.switch.binary, oic.r.light.dimming
|
|
|
- static public final String RT_BINARYSWITCH = "oic.r.switch.binary"; // required
|
|
|
- static public final String RT_DIMMING = "oic.r.light.dimming"; // optional
|
|
|
- // Properties of BinarySwitch Resource(oic.r.switch.binary)
|
|
|
- static public final String SWITCH_KEY = "value"; // required
|
|
|
- // Properties of Dimming Resource(oic.r.light.dimming)
|
|
|
- static public final String DIMMING_SETTING_KEY = "dimmingSetting"; // required
|
|
|
- static public final String DIMMING_STEP_KEY = "step" ; // optional, default 5
|
|
|
- static public final String DIMMING_RANGE_KEY = "range" ; // optional, default [0, 100]
|
|
|
- // Properties of light resource name
|
|
|
- static public final String RESOURCE_NAME_KEY = "n" ; // optional
|
|
|
+ public static final String DT_LIGHT = "oic.d.light";
|
|
|
+ // Resources of Device : oic.r.switch.binary, oic.r.light.dimming, oic.r.colour.colourtemperature, oic.r.energy.consumption
|
|
|
+ public static final String RT_BINARYSWITCH = "oic.r.switch.binary"; // required
|
|
|
+ public static final String RT_DIMMING = "oic.r.light.dimming"; // optional
|
|
|
+ public static final String RT_COLORTEMP = "oic.r.colour.colourtemperature"; // optional
|
|
|
+ public static final String RT_ENERGY = "oic.r.energy.consumption"; // optional
|
|
|
|
|
|
public static final String URI_LIGHT = "/light" ;
|
|
|
public static final String URI_DIMMING = "/dimming" ;
|
|
|
+ public static final String URI_COLORTMEP = "/ColourTemperatureResURI" ;
|
|
|
+ public static final String URI_ENERGY = "/EnergyConsumptionResURI" ;
|
|
|
|
|
|
- private String device_name;
|
|
|
+ // Properties of resource name
|
|
|
+ static public final String RESOURCE_NAME_KEY = "n" ; // optional
|
|
|
+
|
|
|
+ public static final String RESOURCE_NAME_SWITCH = "Light Switch"; // Switch Binary resource Name
|
|
|
+ public static final String RESOURCE_NAME_DIMMING = "Dimming Control"; // Dimming resource Name
|
|
|
+ public static final String RESOURCE_NAME_COLORTMEP = "Color Temperature"; // Color Temperature resource Name
|
|
|
+ public static final String RESOURCE_NAME_ENERGY = "Energy Consumption"; // Energy Consumption resource Name
|
|
|
+
|
|
|
+ // Properties of BinarySwitch Resource(oic.r.switch.binary)
|
|
|
+ public static final String SWITCH_KEY = "value"; // required
|
|
|
+ // Properties of Dimming Resource(oic.r.light.dimming)
|
|
|
+ public static final String DIMMING_SETTING_KEY = "dimmingSetting"; // required
|
|
|
+ public static final String DIMMING_STEP_KEY = "step" ; // optional, default 5
|
|
|
+ public static final String DIMMING_RANGE_KEY = "range" ; // optional, default [0, 100]
|
|
|
+
|
|
|
+ // Properties of Color Temperature Resource(oic.r.colour.colourtemperature)
|
|
|
+ public static final String CT_KEY = "ct"; // required
|
|
|
+ public static final String CT_STEP_KEY = "step" ; // optional, default 5
|
|
|
+ public static final String CT_RANGE_KEY = "range" ; // optional, default [0, 1000] (?)
|
|
|
|
|
|
- private String resource_name_light = "Light Switch"; // Dimming resource Name
|
|
|
- private String resource_name_dimming = "Dimming Control"; // Dimming resource Name
|
|
|
+ // Properties of Color Temperature Resource(oic.r.colour.colourtemperature)
|
|
|
+ public static final String ENERGY_KEY = "energy"; // required
|
|
|
+ public static final String POWER_KEY = "power" ; // required
|
|
|
+
|
|
|
+ private String device_name;
|
|
|
|
|
|
+ // Light Switch
|
|
|
private boolean switch_value = false; // default switch value : false
|
|
|
+ // Dimming Control
|
|
|
private int dimming_level = 30 ; // default dimming level : 30
|
|
|
private int dimming_range = 100; // dimming range : 0 ~ 99
|
|
|
private int dimming_step = 10; // dimming step : 10
|
|
|
-
|
|
|
- //private OCEndpoint serverEndpoint;
|
|
|
- //private String serverUri;
|
|
|
+ // Color Temperature
|
|
|
+ private int ct_value = 457 ;
|
|
|
+ private int ct_range = 1000 ;
|
|
|
+ private int ct_step = 1 ;
|
|
|
+ // Energy Consumption
|
|
|
+ private double power = 20.0 ;
|
|
|
+ private double energy = 350.4 ;
|
|
|
|
|
|
public Light() {
|
|
|
|
|
@@ -49,15 +72,6 @@ public class Light {
|
|
|
device_name = name ;
|
|
|
}
|
|
|
|
|
|
- public String getLightResourceName() { return resource_name_light; }
|
|
|
- public void setLightResourceName(String resource_name) {
|
|
|
- this.resource_name_light = resource_name ;
|
|
|
- }
|
|
|
-
|
|
|
- public String getDimmingResourceName() { return resource_name_dimming; }
|
|
|
- public void setDimmingResourceName(String resource_name) {
|
|
|
- this.resource_name_dimming = resource_name ;
|
|
|
- }
|
|
|
|
|
|
public boolean isSwitchOn() {
|
|
|
return switch_value;
|
|
@@ -87,4 +101,39 @@ public class Light {
|
|
|
this.dimming_range = range;
|
|
|
}
|
|
|
|
|
|
+ public int getColorTemperature() {
|
|
|
+ return ct_value;
|
|
|
+ }
|
|
|
+ public void setColorTemperature(int ct) {
|
|
|
+ this.ct_value = ct;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getCTStep() {
|
|
|
+ return ct_step;
|
|
|
+ }
|
|
|
+ public void setCTStep(int ct_step) {
|
|
|
+ this.ct_step = ct_step;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getCTRange() {
|
|
|
+ return ct_range;
|
|
|
+ }
|
|
|
+ public void setCTRange(int ct_range) {
|
|
|
+ this.ct_range = ct_range;
|
|
|
+ }
|
|
|
+
|
|
|
+ public double getPower() {
|
|
|
+ return power;
|
|
|
+ }
|
|
|
+ public void setPower(double current_power) {
|
|
|
+ this.power = current_power;
|
|
|
+ }
|
|
|
+
|
|
|
+ public double getEnergy() {
|
|
|
+ return energy;
|
|
|
+ }
|
|
|
+ public void setEnergy(double calulated_energy) {
|
|
|
+ this.energy = calulated_energy;
|
|
|
+ }
|
|
|
+
|
|
|
}
|