From 3bad0fd48f04db8baf488a973d394e50fe49742b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Wed, 7 Mar 2012 22:12:18 +0100 Subject: [PATCH] cleanup and removed unnecessary code --- .../java/de/ctdo/bunti/dmx/DMXChannel.java | 12 +---- .../java/de/ctdo/bunti/dmx/DMXChannels.java | 49 +------------------ src/main/java/de/ctdo/bunti/dmx/DMXMixer.java | 4 +- .../java/de/ctdo/bunti/dmx/DMXMixerImpl.java | 17 +++---- .../de/ctdo/bunti/model/Strobe1500Test.java | 3 +- 5 files changed, 14 insertions(+), 71 deletions(-) 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