From 98c4b74a2cde58ad00057a23565b34c35170ac2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Sat, 3 Mar 2012 18:40:50 +0100 Subject: [PATCH] bla --- .../main/java/de/ctdo/bunti/artnet/.gitignore | 1 - .../bunti/artnet/SimpleArtNetSenderImpl.java | 43 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) delete mode 100644 bunti_server/src/main/java/de/ctdo/bunti/artnet/.gitignore create mode 100644 bunti_server/src/main/java/de/ctdo/bunti/artnet/SimpleArtNetSenderImpl.java diff --git a/bunti_server/src/main/java/de/ctdo/bunti/artnet/.gitignore b/bunti_server/src/main/java/de/ctdo/bunti/artnet/.gitignore deleted file mode 100644 index 4144361..0000000 --- a/bunti_server/src/main/java/de/ctdo/bunti/artnet/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/SimpleArtNetSenderImpl.java diff --git a/bunti_server/src/main/java/de/ctdo/bunti/artnet/SimpleArtNetSenderImpl.java b/bunti_server/src/main/java/de/ctdo/bunti/artnet/SimpleArtNetSenderImpl.java new file mode 100644 index 0000000..d0dcf1b --- /dev/null +++ b/bunti_server/src/main/java/de/ctdo/bunti/artnet/SimpleArtNetSenderImpl.java @@ -0,0 +1,43 @@ +package de.ctdo.bunti.artnet; + +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +import de.ctdo.bunti.artnet.packets.ArtDmxPacket; + +@Component +public class SimpleArtNetSenderImpl implements SimpleArtNetSender { + + private ArtNetSocket socket; + private int sequence = 0; + + @Autowired + public void setSocket(ArtNetSocket socket) { + this.socket = socket; + } + + + @Override + public void sendDMXData(Map dmxdata, String adr) { + + ArtDmxPacket packet = new ArtDmxPacket(); + + int size = dmxdata.size(); + + byte[] arr = new byte[size]; + + for (int i = 0; i < dmxdata.size(); i++) { + arr[i] = (byte)(dmxdata.get(i) & 0xff); + } + + packet.setSequenceID(sequence++); + packet.setDMX(arr, arr.length); + packet.setUniverse(0, 0); + + socket.unicastPacket(packet, adr); + + } +}