inital commit
This commit is contained in:
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
7
.idea/encodings.xml
generated
Normal file
7
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/misc.xml
generated
Normal file
14
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
24
pom.xml
Normal file
24
pom.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>ArtDMX</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.0.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
120
src/main/java/de/srsoftware/artdmx/ArtNetLib.java
Normal file
120
src/main/java/de/srsoftware/artdmx/ArtNetLib.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package de.srsoftware.artdmx;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
|
||||
/**
|
||||
* ArtNet Class
|
||||
* @author: Mirco Borella
|
||||
*/
|
||||
public class ArtNetLib {
|
||||
|
||||
private DatagramSocket socket;
|
||||
private String socketIp;
|
||||
|
||||
/**
|
||||
* Constructor with ip
|
||||
* @param socketIp Ip address of the socket
|
||||
*/
|
||||
public ArtNetLib(String socketIp){
|
||||
this.socketIp = socketIp;
|
||||
try {
|
||||
socket = new DatagramSocket();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception in constructor: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a ArtDmx packet in a universe, subnet and net given.
|
||||
* @param dmxChannelData Dmx data array. ArraySize=512, ArrayType=byte, ArrayValue=(0-255)
|
||||
* @param universe Universe in which send the packets. (Values from 0 to 15)
|
||||
* @param subnet Subnet in which send the packets. (Values from 0 to 15)
|
||||
* @param net Net in which send the packets. (Values from 0 to 15)
|
||||
*/
|
||||
public void sendArtDmxPacket(byte[] dmxChannelData, byte universe, byte subnet, byte net){
|
||||
//Name: Size: Bytes: Bits:
|
||||
//Id[8] Int8 8 64
|
||||
char[] idChars = {'A', 'r', 't', '-', 'N', 'e', 't', 0x00};
|
||||
byte[] id = new byte[8];
|
||||
for (int i = 0; i < id.length; i++) {
|
||||
id[i] = (byte)idChars[i];
|
||||
}
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//OpCode Int16 2 16
|
||||
//Choosen OpCode: OpDmx=0x5000;
|
||||
//Notation: Little-endian
|
||||
byte[] opCode = {(byte)0, (byte)80};
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//ProtVerHi Int8 1 8
|
||||
byte protVerHi = 0;
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//ProtVerLow Int8 1 8
|
||||
byte protVerLow = 14;
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//Sequence Int8 1 8
|
||||
byte sequence = 0;
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//Physical Int8 1 8
|
||||
byte physical = 0;
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//SubUni Int8 1 8
|
||||
//Most significant 4 bit- > Subnet
|
||||
//Least significant 4 bit -> Universe
|
||||
//Values accepted: 0-15
|
||||
subnet = (byte) (subnet << 4);
|
||||
byte subUni = (byte) (subnet + universe);
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//Net Int8 1 8
|
||||
//Values accepted: 0-127
|
||||
byte pNet = net;
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//LengthHi Int8 1 8
|
||||
byte lengthHi = 2;
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//Lenght Int8 1 8
|
||||
byte length = 0;
|
||||
|
||||
//Name: Size: Bytes: Bits:
|
||||
//Data Int8 512 4096
|
||||
byte[] data = dmxChannelData;
|
||||
|
||||
//Preparing the byte array
|
||||
byte[] byteToSend = new byte[530];
|
||||
for (int i = 0; i < id.length; i++) {
|
||||
byteToSend[i] = id[i];
|
||||
}
|
||||
byteToSend[8] = opCode[0];
|
||||
byteToSend[9] = opCode[1];
|
||||
byteToSend[10] = protVerHi;
|
||||
byteToSend[11] = protVerLow;
|
||||
byteToSend[12] = sequence;
|
||||
byteToSend[13] = physical;
|
||||
byteToSend[14] = subUni;
|
||||
byteToSend[15] = pNet;
|
||||
byteToSend[16] = lengthHi;
|
||||
byteToSend[17] = length;
|
||||
for (int i = 18; i < byteToSend.length; i++) {
|
||||
byteToSend[i] = data[i-18];
|
||||
}
|
||||
|
||||
//Sending the packet
|
||||
try {
|
||||
DatagramPacket dgram = new DatagramPacket(byteToSend, byteToSend.length, InetAddress.getByName(socketIp), 6454);
|
||||
socket.send(dgram);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception at packet sending: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
53
src/main/java/de/srsoftware/artdmx/Light.java
Normal file
53
src/main/java/de/srsoftware/artdmx/Light.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package de.srsoftware.artdmx;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Light implements Runnable{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Light.class);
|
||||
private final byte chn;
|
||||
private static final int min = 4;
|
||||
private static final int max = 128;
|
||||
private static final Random RAND = new Random();
|
||||
private final Universe uni;
|
||||
|
||||
public Light(Universe universe, byte channel) {
|
||||
LOG.info("creating Light {}",channel);
|
||||
chn = channel;
|
||||
uni = universe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.info("started light {}",chn);
|
||||
while (true){
|
||||
try {
|
||||
long time = 1000+RAND.nextInt(30000);
|
||||
LOG.info("light {} sleeping for {}s",chn,time/1000d);
|
||||
Thread.sleep(time);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
for (int bright = min; bright < max; bright++) {
|
||||
uni.send(chn,(byte)bright);
|
||||
sleep();
|
||||
}
|
||||
for (int bright = max; bright > min; bright--) {
|
||||
uni.send(chn,(byte)bright);
|
||||
sleep();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void sleep(){
|
||||
try {
|
||||
Thread.sleep(33);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
25
src/main/java/de/srsoftware/artdmx/Main.java
Normal file
25
src/main/java/de/srsoftware/artdmx/Main.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package de.srsoftware.artdmx;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Main {
|
||||
private static final Logger LOG = LoggerFactory.getLogger("ArtDmx");
|
||||
public static void main(String[] args) {
|
||||
byte lights = 8;
|
||||
var universe = new Universe("192.168.1.255",(byte)1);
|
||||
startLights(lights,universe);
|
||||
}
|
||||
|
||||
private static void startLights(byte lights, Universe universe) {
|
||||
LOG.info("Setting up {} lights…",lights);
|
||||
for (byte i = 0; i<lights; i++){
|
||||
startLight(i,universe);
|
||||
}
|
||||
}
|
||||
|
||||
private static void startLight(byte channel, Universe universe) {
|
||||
var light = new Light(universe,channel);
|
||||
new Thread(light).start();
|
||||
}
|
||||
}
|
||||
23
src/main/java/de/srsoftware/artdmx/Universe.java
Normal file
23
src/main/java/de/srsoftware/artdmx/Universe.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package de.srsoftware.artdmx;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Universe extends ArtNetLib{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Universe.class);
|
||||
private final byte[] data;
|
||||
private final byte univ;
|
||||
|
||||
public Universe(String socketIp, byte universe) {
|
||||
super(socketIp);
|
||||
LOG.info("created universe {}",universe);
|
||||
data = new byte[512];
|
||||
univ = universe;
|
||||
}
|
||||
|
||||
public synchronized void send(byte channel, byte val){
|
||||
LOG.info("sending {} on channel {}",val,channel);
|
||||
data[channel] = val;
|
||||
sendArtDmxPacket(data,univ,(byte)0,(byte)0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user