bunti/src/main/java/de/ctdo/bunti/model/BuntiDevice.java

76 lines
1.8 KiB
Java

package de.ctdo.bunti.model;
import java.util.Map;
/**
* A physical device type in the bunti system.
* Maybe this is a lamp, or a switchable power source, or a strobe, ...
* @author lucas
*/
public abstract class BuntiDevice {
private int deviceId;
private String deviceName;
public BuntiDevice(int deviceId, String deviceName) {
this.deviceId = deviceId;
this.deviceName = deviceName;
}
/**
* Get the type of this device
* @return a string with the class name (=the Type)
*/
@SuppressWarnings("UnusedDeclaration")
public final String getType() {
String fqClassName = this.getClass().getName();
int firstChar = fqClassName.lastIndexOf ('.') + 1;
if ( firstChar > 0 ) {
fqClassName = fqClassName.substring ( firstChar );
}
return fqClassName;
}
/**
* Gets the device Id
* @return the device Id
*/
public final int getDeviceId() {
return deviceId;
}
/**
* Gets the device name
* @return The name of the device
*/
public final String getDeviceName() {
return deviceName;
}
/**
* Sets the device Name
* @param deviceName a String with the device name
*/
public final void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
/**
* Switch this device off.
*/
public abstract void switchOff();
/**
* Switch this device on.
*/
public abstract void switchOn();
/**
* The the internal options corresponding to the given Key Value Map
*
* @param options The options Map.
* @return True on success. False otherwise.
*/
public abstract boolean setValuesFromOptions(Map<String, Object> options);
}