Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
bugfix Scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Minus345 committed Oct 8, 2022
1 parent 440631e commit c0250a6
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added scenes.lito
Binary file not shown.
7 changes: 4 additions & 3 deletions src/main/java/com/console/LampActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Objects;

public class LampActions {

Expand All @@ -16,6 +17,9 @@ public static void selectLamp() throws IOException, InterruptedException, ClassN
System.out.println("Lampen Id eigeben");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String selectionString = reader.readLine();
if (Objects.equals(selectionString, "scene")) {
sceneSettings();
}
int selection = 0;
try {
selection = Integer.parseInt(selectionString);
Expand Down Expand Up @@ -97,9 +101,6 @@ public static void modifyLampe(Lampe lampe) throws IOException, InterruptedExcep
/**
* Set individual parameters per lamp
*
* @param lampe
* @throws IOException
* @throws InterruptedException
*/
private static void channelData(Lampe lampe) throws IOException, InterruptedException, ClassNotFoundException {
System.out.println("Channel auswählen");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/console/Lampe.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Lampe {
private byte strobo;
private final byte[] dmx;

//TODO matrix lampen (mit mehreren farben); gobos; shutter

public Lampe(int id, String name, int channel, String[] channelData,String[] channelName ) {
this.id = id;
this.name = name;
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/console/scene/Scene.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.console.scene;

import com.console.SendArtNet;

import java.io.Serializable;
import java.util.*;

Expand All @@ -10,7 +8,7 @@ public class Scene implements Serializable {
private final int loopCount;
private final boolean loop;
private final ArrayList<Step> stepList = new ArrayList<>();
private byte[] finishDmxData = new byte[512];
private final byte[] finishDmxData = new byte[512];

public Scene(String name, boolean loop, int loopCount) {
this.name = name;
Expand Down Expand Up @@ -78,9 +76,18 @@ public void read() throws InterruptedException {
dmxResult[i] = (int) Math.round(y);
}
ListToByteArray(dmxResult);
Thread.sleep(25);
try {
Thread.sleep(25);
}catch (InterruptedException interruptedException){
System.out.println("Interupted");
}

}
try {
Thread.sleep(stepList.get(step).getStayTime() * 1000L);
}catch (InterruptedException interruptedException){
System.out.println("Interupted");
}
Thread.sleep(stepList.get(step).getStayTime() * 1000L);
step++;

}
Expand Down
25 changes: 10 additions & 15 deletions src/main/java/com/console/scene/Scenes.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void startScene(Scene scene) {

public static void stopScene(Scene scene) {
runningScenesArray.remove(scene);
Objects.requireNonNull(getThreadByName(scene.getName())).stop();
Objects.requireNonNull(getThreadByName(scene.getName())).interrupt();
}

public static Thread getThreadByName(String threadName) {
Expand All @@ -55,21 +55,18 @@ public static Thread getThreadByName(String threadName) {
}

public static void writeSceneToFile() {

// TODO fix directory for saving the scenes

System.out.println("File wird erstellt");
try {
for (int i = 0; i < scenes.size(); i++) {
FileOutputStream f = new FileOutputStream(scenes.get(i).getName() + ".lito");
ObjectOutputStream o = new ObjectOutputStream(f);
//for (int i = 0; i < scenes.size(); i++) {
FileOutputStream f = new FileOutputStream("scenes.lito");
ObjectOutputStream o = new ObjectOutputStream(f);

// Write objects to file
o.writeObject(scenes);
// Write objects to file
o.writeObject(scenes);

o.close();
f.close();
}
o.close();
f.close();
//}
} catch (FileNotFoundException e) {
System.out.println("File not found");
} catch (IOException e) {
Expand All @@ -78,14 +75,12 @@ public static void writeSceneToFile() {
}

public static void readSceneFromFile() {
// TODO fix read from file
try {
FileInputStream fi = new FileInputStream("C:\\Users\\max\\Documents\\ArtNetConsole\\src\\main\\resources\\scenes\\1.lito");
FileInputStream fi = new FileInputStream("scenes.lito");
ObjectInputStream oi = new ObjectInputStream(fi);
// Read objects
ArrayList<Scene> deserializeScene = (ArrayList<Scene>) oi.readObject();
for (int i = 0; i < deserializeScene.size(); i++) {
System.out.println(deserializeScene.get(i).getName());
scenes.add(deserializeScene.get(i));
System.out.println("Scene: " + deserializeScene.get(i).getName() + " wurde hinzugefügt");
}
Expand Down
Binary file removed src/main/resources/scenes/1.lito
Binary file not shown.
Binary file removed src/main/resources/scenes/2.lito
Binary file not shown.
Binary file removed target/libs/artnet4j-0.6.2.jar
Binary file not shown.

0 comments on commit c0250a6

Please sign in to comment.