bla
This commit is contained in:
parent
466eee7222
commit
98c4b74a2c
|
@ -1 +0,0 @@
|
|||
/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<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);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue