This commit is contained in:
Lucas Pleß 2012-03-03 18:40:50 +01:00
parent 466eee7222
commit 98c4b74a2c
2 changed files with 43 additions and 1 deletions

View File

@ -1 +0,0 @@
/SimpleArtNetSenderImpl.java

View File

@ -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<Integer,Integer> 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);
}
}