All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.bidib.wizard.model.status.LightPortStatus Maven / Gradle / Ivy
package org.bidib.wizard.model.status;
import org.bidib.jbidibc.messages.enums.LightPortEnum;
import org.bidib.jbidibc.messages.utils.ByteUtils;
public enum LightPortStatus implements BidibStatus {
// @formatter:off
ON(LightPortEnum.ON, "on"), OFF(LightPortEnum.OFF, "off"), UP(LightPortEnum.UP, "up"), DOWN(LightPortEnum.DOWN,
"down"), NEON(LightPortEnum.NEON, "neon"), BLINKA(LightPortEnum.BLINKA, "blinka"), BLINKB(LightPortEnum.BLINKB,
"blinkb"), FLASHA(LightPortEnum.FLASHA, "flasha"), FLASHB(LightPortEnum.FLASHB, "flashb"), DOUBLEFLASH(
LightPortEnum.DOUBLEFLASH, "doubleflash"), UNKNOWN(LightPortEnum.UNKNOWN, "unknown"), TEST(LightPortEnum.TEST,
"test");
// @formatter:on
private final LightPortEnum type;
private final String key;
LightPortStatus(LightPortEnum type, String key) {
this.type = type;
this.key = key;
}
@Override
public LightPortEnum getType() {
return type;
}
@Override
public String getKey() {
return key;
}
public static LightPortStatus valueOf(LightPortEnum type) {
LightPortStatus result = null;
for (LightPortStatus e : values()) {
if (e.type == type) {
result = e;
break;
}
}
if (result == null) {
throw new IllegalArgumentException("cannot map " + type + " to a light port status");
}
return result;
}
/**
* Create the {@code LightPortStatus} from the bidib value.
*
* @param value
* the value
* @return the status
*/
public static LightPortStatus fromBidibValue(int value) {
LightPortEnum type = LightPortEnum.valueOf(ByteUtils.getLowByte(value));
return valueOf(type);
}
@Override
public LightPortStatus[] getValues() {
return new LightPortStatus[] { ON, OFF, UP, DOWN, NEON, BLINKA, BLINKB, FLASHA, FLASHB, DOUBLEFLASH, TEST };
}
@Override
public LightPortStatus[] getMacroValues() {
return new LightPortStatus[] { ON, OFF, UP, DOWN, NEON, BLINKA, BLINKB, FLASHA, FLASHB, DOUBLEFLASH };
}
}