wid, added implements keyword for Boolean/RangeTriggerable in all the devices

This commit is contained in:
omenem 2020-04-22 16:48:49 +02:00
parent db21aa0a26
commit 5c2f828834
4 changed files with 24 additions and 5 deletions

View file

@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull;
@Entity @Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Dimmable extends Switchable { public class Dimmable extends Switchable implements RangeTriggerable {
public static final Connector<KnobDimmer, Dimmable> KNOB_DIMMER_DIMMABLE_CONNECTOR = public static final Connector<KnobDimmer, Dimmable> KNOB_DIMMER_DIMMABLE_CONNECTOR =
Connector.basic(KnobDimmer::getOutputs, Dimmable::getDimmers); Connector.basic(KnobDimmer::getOutputs, Dimmable::getDimmers);
@ -85,4 +85,9 @@ public class Dimmable extends Switchable {
newState.setIntensity(getIntensity()); newState.setIntensity(getIntensity());
return newState; return newState;
} }
@Override
public double readTriggerState() {
return intensity;
}
} }

View file

@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull;
/** Represents a standard non-dimmable light */ /** Represents a standard non-dimmable light */
@Entity @Entity
public class RegularLight extends Switchable { public class RegularLight extends Switchable implements BooleanTriggerable {
/** Whether the light is on or not */ /** Whether the light is on or not */
@Column(name = "light_on", nullable = false) @Column(name = "light_on", nullable = false)
@ -27,4 +27,9 @@ public class RegularLight extends Switchable {
public void setOn(boolean on) { public void setOn(boolean on) {
this.on = on; this.on = on;
} }
@Override
public boolean readTriggerState() {
return on;
}
} }

View file

@ -5,7 +5,7 @@ import javax.persistence.Entity;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Entity @Entity
public class SecurityCamera extends Switchable { public class SecurityCamera extends Switchable implements BooleanTriggerable {
public SecurityCamera() { public SecurityCamera() {
super("securityCamera"); super("securityCamera");
@ -33,4 +33,9 @@ public class SecurityCamera extends Switchable {
public void setOn(boolean on) { public void setOn(boolean on) {
this.on = on; this.on = on;
} }
@Override
public boolean readTriggerState() {
return on;
}
} }

View file

@ -1,6 +1,5 @@
package ch.usi.inf.sa4.sanmarinoes.smarthut.models; package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import com.google.common.base.Objects;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.persistence.Column; import javax.persistence.Column;
@ -9,7 +8,7 @@ import javax.validation.constraints.NotNull;
/** A smart plug that can be turned either on or off */ /** A smart plug that can be turned either on or off */
@Entity @Entity
public class SmartPlug extends Switchable { public class SmartPlug extends Switchable implements BooleanTriggerable {
/** The average consumption of an active plug when on in Watt */ /** The average consumption of an active plug when on in Watt */
public static final Double AVERAGE_CONSUMPTION_KW = 200.0; public static final Double AVERAGE_CONSUMPTION_KW = 200.0;
@ -46,4 +45,9 @@ public class SmartPlug extends Switchable {
public SmartPlug() { public SmartPlug() {
super("smartPlug"); super("smartPlug");
} }
@Override
public boolean readTriggerState() {
return on;
}
} }