diff --git a/bunti_server/src/main/java/de/ctdo/Log4jInit.java b/bunti_server/src/main/java/de/ctdo/Log4jInit.java deleted file mode 100644 index 059c874..0000000 --- a/bunti_server/src/main/java/de/ctdo/Log4jInit.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.ctdo; - -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.log4j.PropertyConfigurator; - -@WebServlet("/Log4jInit") -public class Log4jInit extends HttpServlet { - private static final long serialVersionUID = 1L; - - public void init() { - String prefix = getServletContext().getRealPath("/"); - String file = "log4j.properties"; - PropertyConfigurator.configure(prefix + file); - } - - public void doGet(HttpServletRequest req, HttpServletResponse res) { - } - -} diff --git a/bunti_server/src/main/java/de/ctdo/dmx/DMXDevice.java b/bunti_server/src/main/java/de/ctdo/dmx/DMXDevice.java deleted file mode 100644 index c70f245..0000000 --- a/bunti_server/src/main/java/de/ctdo/dmx/DMXDevice.java +++ /dev/null @@ -1,30 +0,0 @@ -package de.ctdo.dmx; - -public abstract class DMXDevice { - private int startaddress = 0; - private String name = "New Device"; - - public DMXDevice() { - - } - - public DMXDevice(int startaddress, String name) { - setStartaddress(startaddress); - setName(name); - } - - public int getStartaddress() { - return startaddress; - } - - public void setStartaddress(int startaddress) { - this.startaddress = startaddress; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - -} diff --git a/bunti_server/src/main/java/de/ctdo/dmx/DeviceManager.java b/bunti_server/src/main/java/de/ctdo/dmx/DeviceManager.java deleted file mode 100644 index 52093cf..0000000 --- a/bunti_server/src/main/java/de/ctdo/dmx/DeviceManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.ctdo.dmx; - -import java.util.ArrayList; -import java.util.List; - -public class DeviceManager { - - private List devices = new ArrayList(); - - public DeviceManager() { - - // fill device list - devices.add(new Par56Spot(1, "Par1")); - devices.add(new Par56Spot(6, "Par2")); - devices.add(new Par56Spot(11, "Par3")); - devices.add(new Par56Spot(16, "Par4")); - - - - } - - - public List getDevices() { - return new ArrayList(devices); - } - -} diff --git a/bunti_server/src/main/java/de/ctdo/dmx/Mixer.java b/bunti_server/src/main/java/de/ctdo/dmx/Mixer.java index 8c484ce..2196ef3 100644 --- a/bunti_server/src/main/java/de/ctdo/dmx/Mixer.java +++ b/bunti_server/src/main/java/de/ctdo/dmx/Mixer.java @@ -17,20 +17,22 @@ public class Mixer { final int TICKS_BETWEEN_DMX_SEND = 20; final int DMX_MIN_CHANNEL = 0; final int DMX_MAX_CHANNEL = 512; + final String ARTNET_DEVICE_ADDRESS = "192.168.0.90"; Logger logger = LoggerFactory.getLogger(Mixer.class); int[] dmx512databuffer = new int[512]; static int sequenceID = 0; ArtNet artnet = new ArtNet(); ArtNetNode firstNodeFound = null; + ArtDmxPacket artnetDmxPacket = null; long ticksLastBufferFlush = 0; + protected final List listeners = new ArrayList(); public static Mixer getInstance() { return instance; } - public void addListener(DMXDataChangedListener l) { synchronized (listeners) { listeners.add(l); @@ -45,6 +47,9 @@ public class Mixer { private Mixer() { + artnetDmxPacket = new ArtDmxPacket(); + artnetDmxPacket.setUniverse(0, 0); + try { artnet.start(); } @@ -59,28 +64,18 @@ public class Mixer { } private void sendOutDMXBuffer() { -// if(firstNodeFound == null) { -// logger.info("No ArtNetNode to send data to"); -// return; -// } - ArtDmxPacket dmx = new ArtDmxPacket(); -// dmx.setUniverse(firstNodeFound.getSubNet(), firstNodeFound.getDmxOuts()[0]); -// dmx.setSequenceID(sequenceID % 255); -// dmx.setDMX(dmx512databuffer, dmx512databuffer.length); -// artnet.unicastPacket(dmx, firstNodeFound.getIPAddress()); - dmx.setUniverse(0, 0); - dmx.setSequenceID(sequenceID % 255); + byte[] arr = new byte[dmx512databuffer.length]; for (int i = 0; i < dmx512databuffer.length; i++) { arr[i] = (byte)dmx512databuffer[i]; } - dmx.setDMX(arr, arr.length); - artnet.unicastPacket(dmx, "192.168.0.90"); + artnetDmxPacket.setSequenceID(sequenceID % 255); + artnetDmxPacket.setDMX(arr, arr.length); + artnet.unicastPacket(artnetDmxPacket, ARTNET_DEVICE_ADDRESS); sequenceID++; ticksLastBufferFlush = System.currentTimeMillis(); -// logger.debug("Send out DMX Data"); } public void sendOutDMXBufferIfNeeded() { diff --git a/bunti_server/src/main/java/de/ctdo/dmx/Par56Spot.java b/bunti_server/src/main/java/de/ctdo/dmx/Par56Spot.java deleted file mode 100644 index 44dc8a5..0000000 --- a/bunti_server/src/main/java/de/ctdo/dmx/Par56Spot.java +++ /dev/null @@ -1,81 +0,0 @@ -package de.ctdo.dmx; - -import java.awt.Color; - -public class Par56Spot extends DMXDevice { - private final int NUM_CHANNELS = 5; - private byte red = 0; - private byte green = 0; - private byte blue = 0; - - public Par56Spot() { - - } - - public Par56Spot(int startaddress, String name) { - setStartaddress(startaddress); - setName(name); - } - - public boolean getDMXValues(byte[] dmx512data) { - int dmxStartAddressInDataArray = getStartaddress()-1; - - if( dmx512data == null || dmx512data.length < NUM_CHANNELS+dmxStartAddressInDataArray ) { - return false; - } - - dmx512data[dmxStartAddressInDataArray+0] = 0; - dmx512data[dmxStartAddressInDataArray+1] = red; - dmx512data[dmxStartAddressInDataArray+2] = green; - dmx512data[dmxStartAddressInDataArray+3] = blue; - dmx512data[dmxStartAddressInDataArray+4] = 0; - - return true; - } - - public boolean setDMXValues(byte[] dmx512data) { - int dmxStartAddressInDataArray = getStartaddress()-1; - - if( dmx512data == null || dmx512data.length < NUM_CHANNELS+dmxStartAddressInDataArray ) { - return false; - } - - red = dmx512data[dmxStartAddressInDataArray+1]; - green = dmx512data[dmxStartAddressInDataArray+2]; - blue = dmx512data[dmxStartAddressInDataArray+3]; - return true; - } - - public void setColor(Color c) { - red = (byte) c.getRed(); - green = (byte) c.getGreen(); - blue = (byte) c.getBlue(); - } - - public Color getColor() { - return new Color(red, green, blue, 255); - } - - - public byte getRed() { - return red; - } - public void setRed(byte red) { - this.red = red; - } - public byte getGreen() { - return green; - } - public void setGreen(byte green) { - this.green = green; - } - public byte getBlue() { - return blue; - } - public void setBlue(byte blue) { - this.blue = blue; - } - - - -} diff --git a/bunti_server/src/main/java/de/ctdo/websocket/DMXControllerApplication.java b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerApplication.java similarity index 80% rename from bunti_server/src/main/java/de/ctdo/websocket/DMXControllerApplication.java rename to bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerApplication.java index 891443f..a08e055 100644 --- a/bunti_server/src/main/java/de/ctdo/websocket/DMXControllerApplication.java +++ b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerApplication.java @@ -11,13 +11,13 @@ import com.sun.grizzly.websockets.WebSocketListener; import de.ctdo.dmx.Mixer; -public class DMXControllerApplication extends WebSocketApplication { - Logger logger = LoggerFactory.getLogger(DMXControllerApplication.class); +public class BuntiControllerApplication extends WebSocketApplication { + Logger logger = LoggerFactory.getLogger(BuntiControllerApplication.class); @Override public WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) { logger.debug("createSocket "); - DMXControllerWebSocket socket = new DMXControllerWebSocket(protocolHandler, listeners); + BuntiControllerWebSocket socket = new BuntiControllerWebSocket(protocolHandler, listeners); Mixer.getInstance().addListener(socket); return socket; } @@ -25,12 +25,12 @@ public class DMXControllerApplication extends WebSocketApplication { @Override public boolean isApplicationRequest(Request request) { final String uri = request.requestURI().toString(); - return uri.endsWith("/dmx"); + return uri.endsWith("/bunti"); } @Override public void onClose(WebSocket socket, com.sun.grizzly.websockets.DataFrame frame) { - DMXControllerWebSocket ws = (DMXControllerWebSocket) socket; + BuntiControllerWebSocket ws = (BuntiControllerWebSocket) socket; Mixer.getInstance().removeListener(ws); logger.debug("removed websocket"); } diff --git a/bunti_server/src/main/java/de/ctdo/websocket/DMXControllerServlet.java b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerServlet.java similarity index 66% rename from bunti_server/src/main/java/de/ctdo/websocket/DMXControllerServlet.java rename to bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerServlet.java index fb2ae14..e6d382f 100644 --- a/bunti_server/src/main/java/de/ctdo/websocket/DMXControllerServlet.java +++ b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerServlet.java @@ -2,7 +2,7 @@ package de.ctdo.websocket; import javax.servlet.ServletConfig; import javax.servlet.ServletException; -//import javax.servlet.annotation.WebServlet; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import org.slf4j.Logger; @@ -10,11 +10,12 @@ import org.slf4j.LoggerFactory; import com.sun.grizzly.websockets.WebSocketEngine; -public class DMXControllerServlet extends HttpServlet { +@WebServlet(urlPatterns = "/bunti") +public class BuntiControllerServlet extends HttpServlet { private static final long serialVersionUID = 1L; - Logger logger = LoggerFactory.getLogger(DMXControllerServlet.class); + Logger logger = LoggerFactory.getLogger(BuntiControllerServlet.class); - private final DMXControllerApplication app = new DMXControllerApplication(); + private final BuntiControllerApplication app = new BuntiControllerApplication(); @Override public void init(ServletConfig config) throws ServletException { diff --git a/bunti_server/src/main/java/de/ctdo/websocket/DMXControllerWebSocket.java b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerWebSocket.java similarity index 72% rename from bunti_server/src/main/java/de/ctdo/websocket/DMXControllerWebSocket.java rename to bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerWebSocket.java index 678cacd..d5bb9fd 100644 --- a/bunti_server/src/main/java/de/ctdo/websocket/DMXControllerWebSocket.java +++ b/bunti_server/src/main/java/de/ctdo/websocket/BuntiControllerWebSocket.java @@ -17,11 +17,11 @@ import de.ctdo.dmx.DMXDataChangedListener; * @author lucas * */ -public class DMXControllerWebSocket extends DefaultWebSocket implements DMXDataChangedListener { +public class BuntiControllerWebSocket extends DefaultWebSocket implements DMXDataChangedListener { - Logger logger = LoggerFactory.getLogger(DMXControllerWebSocket.class); + Logger logger = LoggerFactory.getLogger(BuntiControllerWebSocket.class); - public DMXControllerWebSocket(ProtocolHandler protocolHandler, WebSocketListener[] listeners) { + public BuntiControllerWebSocket(ProtocolHandler protocolHandler, WebSocketListener[] listeners) { super(protocolHandler, listeners); } diff --git a/bunti_server/src/main/webapp/WEB-INF/web.xml b/bunti_server/src/main/webapp/WEB-INF/web.xml index 3c09c7d..58eb681 100644 --- a/bunti_server/src/main/webapp/WEB-INF/web.xml +++ b/bunti_server/src/main/webapp/WEB-INF/web.xml @@ -10,20 +10,20 @@ default.jsp - CTDO DMX control Server - + CTDO bunti control Server + 25 diff --git a/bunti_server/src/main/webapp/index.jsp b/bunti_server/src/main/webapp/index.jsp index e46f434..4ab3dd7 100644 --- a/bunti_server/src/main/webapp/index.jsp +++ b/bunti_server/src/main/webapp/index.jsp @@ -20,8 +20,8 @@ $(document).ready( function() { - - ws = new MozWebSocket("ws://localhost:8080/bunti_server/dmx"); + var Socket = "MozWebSocket" in window ? MozWebSocket : WebSocket; + ws = new MozWebSocket("ws://localhost:8080/bunti_server/bunti"); //ws = new MozWebSocket("ws://localhost:8080/grizzly-websockets-chat/chat"); ws.onmessage = function (message) {