@Override
public void processCommand(DmxService service, Command command) {
// process HSB command
if (command instanceof HSBType) {
HSBType hsbValue = (HSBType) command;
setHSBValue(service, hsbValue);
return;
}
// process increase/decrease
if (command instanceof IncreaseDecreaseType
&& !isRedefinedByCustomCommand(command)
&& !service.hasChannelActions(channels[0])) {
// rather than doing a linear fade on all channels, we fade only the
// V part of HSV to maintain the color during the fade
HSBType hsb = hsbState;
int brightness = 0;
IncreaseDecreaseType t = (IncreaseDecreaseType) command;
if (IncreaseDecreaseType.INCREASE.equals(t)) {
if (hsb == null) {
hsb = new HSBType(Color.WHITE);
}
for (int ch : channels) {
service.enableChannel(ch);
}
brightness = hsb.getBrightness().intValue();
brightness += BRIGHTNESS_STEP_SIZE;
if (brightness > 100) {
brightness = 100;
}
} else {
if (hsb == null) {
hsb = new HSBType(Color.BLACK);
}
brightness = hsb.getBrightness().intValue();
brightness -= BRIGHTNESS_STEP_SIZE;
if (brightness <= 0) {
brightness = 0;
}
}
HSBType newHsb = new HSBType(hsb.getHue(), hsb.getSaturation(),
new PercentType(brightness));
setHSBValue(service, newHsb);
return;
}
// process percent command
if (command instanceof PercentType
&& !isRedefinedByCustomCommand(command)
&& !service.hasChannelActions(channels[0])) {
PercentType t = (PercentType) command;
HSBType hsb = hsbState;
if (hsb == null) {
hsb = new HSBType(Color.WHITE);
}
HSBType newHsb = new HSBType(hsb.getHue(), hsb.getSaturation(), t);
setHSBValue(service, newHsb);
return;
}
// process on/off, increase/decrease, percent type