ich hasse git
This commit is contained in:
commit
466eee7222
|
@ -0,0 +1 @@
|
||||||
|
/SimpleArtNetSenderImpl.java
|
|
@ -1,41 +0,0 @@
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package de.ctdo.bunti.artnet.packets;
|
package de.ctdo.bunti.artnet.packets;
|
||||||
|
|
||||||
|
|
||||||
public class ArtDmxPacket extends ArtNetPacket {
|
public class ArtDmxPacket extends ArtNetPacket {
|
||||||
|
|
||||||
private int numChannels;
|
private int numChannels;
|
||||||
|
|
|
@ -2,9 +2,9 @@ package de.ctdo.bunti.dmx;
|
||||||
|
|
||||||
public class DMX {
|
public class DMX {
|
||||||
|
|
||||||
public static int DMX_CHANNELS_MAX = 511;
|
public static int DMX_CHANNELS_MAX = (byte) 511;
|
||||||
public static int DMX_CHANNELS_MIN = 0;
|
public static int DMX_CHANNELS_MIN = 0;
|
||||||
public static int DMX_CHANNEL_VALUE_MAX = 255;
|
public static int DMX_CHANNEL_VALUE_MAX = (byte) 255;
|
||||||
public static int DMX_CHANNEL_VALUE_MIN = 0;
|
public static int DMX_CHANNEL_VALUE_MIN = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,8 +6,10 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -16,6 +18,7 @@ import de.ctdo.bunti.artnet.SimpleArtNetSender;
|
||||||
import de.ctdo.bunti.model.*;
|
import de.ctdo.bunti.model.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
|
||||||
public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChangedEvent> {
|
public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChangedEvent> {
|
||||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
private final String ARTNET_DEVICE_ADDRESS = "192.168.0.90";
|
private final String ARTNET_DEVICE_ADDRESS = "192.168.0.90";
|
||||||
|
@ -29,12 +32,14 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChanged
|
||||||
this.artNetSender = artNetSender;
|
this.artNetSender = artNetSender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void initDMXData() {
|
public void initDMXData() {
|
||||||
for (int i = 0; i <= DMX.DMX_CHANNELS_MAX; i++) {
|
for (int i = 0; i <= DMX.DMX_CHANNELS_MAX; i++) {
|
||||||
dmxMap.put(i, 0);
|
dmxMap.put(i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(fixedDelay=100) //TODO aendern auf 10ms
|
@Scheduled(fixedDelay=100) //TODO aendern auf 10ms
|
||||||
public void sendOutDMXBuffer() {
|
public void sendOutDMXBuffer() {
|
||||||
if( dmxMap.size() == 0) initDMXData();
|
if( dmxMap.size() == 0) initDMXData();
|
||||||
|
@ -54,7 +59,6 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChanged
|
||||||
|
|
||||||
dmxMap.putAll(dmxDev.getChannelData());
|
dmxMap.putAll(dmxDev.getChannelData());
|
||||||
|
|
||||||
|
|
||||||
logger.info("setValuesFromOptions on " + device);
|
logger.info("setValuesFromOptions on " + device);
|
||||||
} else {
|
} else {
|
||||||
logger.info("setValuesFromOptions on " + device + " failed");
|
logger.info("setValuesFromOptions on " + device + " failed");
|
||||||
|
|
|
@ -130,7 +130,7 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
||||||
|
|
||||||
if(channel != null) {
|
if(channel != null) {
|
||||||
try {
|
try {
|
||||||
int value = Integer.parseInt(opt.getValue().toString());
|
byte value = Byte.parseByte(opt.getValue().toString());
|
||||||
|
|
||||||
setChannelValueByName(channel.getName(), value);
|
setChannelValueByName(channel.getName(), value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue