package de.ctdo.bunti.model;

import de.ctdo.bunti.dmx.DMX;
import de.ctdo.bunti.dmx.DMXChannel;

public class Strobe1500 extends BuntiDMXDevice {

    private static final String CHANNEL_SPEED = "speed";
    private static final String CHANNEL_INTENSITY = "intensity";
    private static final String CHANNEL_MODE = "mode";

    public Strobe1500(int deviceId, int startAddress, String deviceName) {
        super(deviceId, startAddress, deviceName);

        addChannel(new DMXChannel(0, CHANNEL_SPEED));
        addChannel(new DMXChannel(1, CHANNEL_INTENSITY));
        addChannel(new DMXChannel(2, CHANNEL_MODE));
    }

    public final boolean setSpeed(int value) {
        return setChannelValueByName(CHANNEL_SPEED, value);
    }

    public final boolean setIntensity(int value) {
        return setChannelValueByName(CHANNEL_INTENSITY, value);
    }

    public final boolean setMode(int value) {
        return setChannelValueByName(CHANNEL_MODE, value);
    }

    public final int getSpeed() {
        return getChannelValueByName(CHANNEL_SPEED);
    }

    public final int getIntensity() {
        return getChannelValueByName(CHANNEL_INTENSITY);
    }

    public final int getMode() {
        return getChannelValueByName(CHANNEL_MODE);
    }

    @Override
    public final void switchOff() {
        setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
        setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MIN);
        setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MIN);
    }

    @Override
    public final void switchOn() {
        setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
        setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MAX);
        setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MAX);
    }

    @Override
    public final String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Strobe1500 ");
        sb.append(getDeviceId());
        sb.append(", ");
        sb.append(getDeviceName());
        sb.append(" [");
        sb.append(getSpeed());
        sb.append(",");
        sb.append(getIntensity());
        sb.append(",");
        sb.append(getMode());
        sb.append("]");
        return sb.toString();
    }

}
