94 lines
2.2 KiB
Java
94 lines
2.2 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;
|
|
private String picture;
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* Get the relative URL to the picture of this device
|
|
* @return the relative URL to the picture
|
|
*/
|
|
public final String getPicture() {
|
|
return picture;
|
|
}
|
|
|
|
/**
|
|
* Get the relative URL to the picture of this device
|
|
* @param picture The relative URL to the picture
|
|
*/
|
|
public final void setPicture(String picture) {
|
|
this.picture = picture;
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
|
|
|
|
}
|