diff --git a/src/main/java/de/ctdo/bunti/dmx/DMXChannel.java b/src/main/java/de/ctdo/bunti/dmx/DMXChannel.java index 3a59b8f..528cc76 100644 --- a/src/main/java/de/ctdo/bunti/dmx/DMXChannel.java +++ b/src/main/java/de/ctdo/bunti/dmx/DMXChannel.java @@ -4,8 +4,7 @@ public class DMXChannel { private int offset; private String name; private int value; - private long lastChangedTimestamp = 0; - + public DMXChannel(int offset, String name) { this.name = name; this.offset = offset; @@ -18,11 +17,6 @@ public class DMXChannel { public final void setValue(int value) { this.value = value; - lastChangedTimestamp = System.currentTimeMillis(); - } - - public final long getLastChangedTimestamp() { - return lastChangedTimestamp; } public final int getOffset() { @@ -41,10 +35,6 @@ public class DMXChannel { this.name = name; } - public final void hasbeenSendOut() { - this.lastChangedTimestamp = System.currentTimeMillis(); - } - @Override public final String toString() { return "DMXChannel " + getName() + "," + getOffset() + "," + getValue(); diff --git a/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java b/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java index c6e83ac..43374f8 100644 --- a/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java +++ b/src/main/java/de/ctdo/bunti/dmx/DMXChannels.java @@ -11,8 +11,6 @@ import java.util.Map; * */ public class DMXChannels { - - private Map channelByNumber = new HashMap(); private Map channelByName = new HashMap(); /** @@ -20,7 +18,7 @@ public class DMXChannels { * @return number of channels */ public final int getCount() { - return this.channelByNumber.size(); + return this.channelByName.size(); } /** @@ -35,15 +33,6 @@ public class DMXChannels { return this.channelByName.get(name); } - /** - * Returns a channel by offset - * @param number number - * @return channel or null if not found - */ - public final DMXChannel getChannelByNumber(int number) { - return this.channelByNumber.get(number); - } - /** * Adds a channel * @param channel channel to add @@ -58,55 +47,21 @@ public class DMXChannels { if (channel.getName() == null) { return false; } - // entry must not exist by offset - if (this.channelByNumber.containsKey(channel.getOffset())) { - return false; - } // entry must not exist by name if (this.channelByName.containsKey(channel.getName())) { return false; } - this.channelByNumber.put(channel.getOffset(), channel); this.channelByName.put(channel.getName(), channel); return true; } - /** - * Removes a channel by offset - * @param offset offset - * @return removed channel or null if it does not exist - */ - public final DMXChannel removeChannel(int offset) { - DMXChannel tmpChannel = this.channelByNumber.remove(offset); - if (tmpChannel != null) { - this.channelByName.remove(tmpChannel.getName()); - } - return tmpChannel; - } - /** - * Removes a channel by name - * @param name channel name - * @return removed channel or null if it does not exist - */ - public final DMXChannel removeChannel(String name) { - if (name == null) { - return null; - } - DMXChannel tmpChannel = this.channelByName.remove(name); - if (tmpChannel != null) { - this.channelByNumber.remove(tmpChannel.getOffset()); - } - return tmpChannel; - } - - /** * Returns an (unmodifiable) collection of all channels * @return unmodifiable collection of all channels */ public final Collection getAllChannels() { - return Collections.unmodifiableCollection(this.channelByNumber.values()); + return Collections.unmodifiableCollection(this.channelByName.values()); } } diff --git a/src/main/java/de/ctdo/bunti/dmx/DMXMixer.java b/src/main/java/de/ctdo/bunti/dmx/DMXMixer.java index 1f5ea80..786fdc6 100644 --- a/src/main/java/de/ctdo/bunti/dmx/DMXMixer.java +++ b/src/main/java/de/ctdo/bunti/dmx/DMXMixer.java @@ -6,7 +6,7 @@ import de.ctdo.bunti.model.BuntiDevice; public interface DMXMixer { - void setDMX512Channel(int channel, int value); - void updateDevice(BuntiDevice device, Map options); + boolean setDMX512Channel(int channel, int value); + boolean updateDevice(BuntiDevice device, Map options); } diff --git a/src/main/java/de/ctdo/bunti/dmx/DMXMixerImpl.java b/src/main/java/de/ctdo/bunti/dmx/DMXMixerImpl.java index 8526a2a..4a83382 100644 --- a/src/main/java/de/ctdo/bunti/dmx/DMXMixerImpl.java +++ b/src/main/java/de/ctdo/bunti/dmx/DMXMixerImpl.java @@ -41,7 +41,7 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener options) { + public final boolean updateDevice(BuntiDevice device, Map options) { BuntiDMXDevice dmxDev = (BuntiDMXDevice) device; if (dmxDev.setValuesFromOptions(options)) { @@ -63,21 +61,22 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener