Skip to content

Commit

Permalink
reorg related to #1
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteUEM committed Sep 15, 2017
1 parent 7154f37 commit 7b5ab92
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
44 changes: 36 additions & 8 deletions src/main/java/team.stein.qlc/App.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package team.stein.qlc;

import com.sun.org.apache.xerces.internal.dom.DeferredElementImpl;
import org.apache.log4j.Logger;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import team.stein.qlc.controller.Pattern;
import team.stein.qlc.controller.QXWread;
import team.stein.qlc.model.*;
import team.stein.qlc.view.QLCFunction;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -12,17 +18,29 @@
*/
class App {
private static final Logger log = Logger.getLogger(App.class);
public static QXWread qxwRead;
private static int highestFunctionID;

public static void main(String[] args) {

// read the base file
qxwRead = new QXWread(new File(QXWread.class.getResource("sample.qxw").getFile()));
Element rootNode = qxwRead.document.getDocumentElement();
NodeList engineNodes = rootNode.getElementsByTagName("Engine").item(0).getChildNodes();
NodeList functionNodes = ((DeferredElementImpl) engineNodes).getElementsByTagName("Function");
highestFunctionID = qxwRead.getHighestFunctionID(functionNodes);

List<LEDLightDRGB> allLights = new ArrayList<>();
// generate the TourLED group as used in regular EFG setup with 8 spots

for (Integer i = 130; i <= 200; i += 10) {
allLights.add(new LEDLightDRGB(i, -1));
}

//Generate Pattern and printout debug
firstCase(allLights);
anotherCase(allLights);
}

public static void firstCase(List allLights){
Pattern pat1 = new Pattern(allLights.subList(0, 3));
pat1.movement = Movement.LEFTtoRIGHT;
log.debug("Generated: " + pat1);
Expand All @@ -42,24 +60,34 @@ public static void main(String[] args) {
Chaser chaser = new Chaser(-1, ">||>", scenesLeft);
chaser.merge(scenesMiddle);
chaser.merge(scenesRight);

log.debug("Chaser: " + chaser);

for (Scene scene : scenesLeft){
QLCFunction function = new QLCFunction(scene,highestFunctionID+1);
highestFunctionID++;
}
//TODO continue here to prepare IDs for export? #1
}

//Another example non in order
public static void anotherCase(List allLights){
FixtureValue val1 = new FixtureValue();
FixtureValue val2 = new FixtureValue(0, 255, 255, 255);

pat1 = new Pattern(allLights.subList(3, 5));
//Another example non in order
Pattern pat1 = new Pattern(allLights.subList(3, 5));
pat1.movement = Movement.ALL;
List<Scene> scenes_inner = pat2.iteratePattern(val1, val2);
List<Scene> scenes_inner = pat1.iteratePattern(val1, val2);

List<LEDLightDRGB> lights2 = new ArrayList();
lights2.addAll(allLights.subList(0, 3));
lights2.addAll(allLights.subList(5, 8));
pat2 = new Pattern(lights2);
Pattern pat2 = new Pattern(lights2);
pat2.movement = Movement.LEFTtoRIGHT;
List<Scene> scenes_outer = pat2.iteratePattern(val1, val2);

chaser = new Chaser(-1, ">||(>)", scenes_outer);
Chaser chaser = new Chaser(-1, ">||(>)", scenes_outer);
chaser.merge(scenes_inner);
log.debug("Chaser: " + chaser);

}
}
6 changes: 3 additions & 3 deletions src/main/java/team.stein.qlc/controller/QXWread.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class QXWread {

private static final Logger log = Logger.getLogger(QXWread.class);
Document document;
public Document document;
private HashMap<Integer, Integer> dmxToQlc;

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ public HashMap<Integer, Integer> parseDMXtoQLCId(NodeList listOfFixtures) {
*
* @return an ID number which can be used for a new function
*/
public int generateNewFunctionId(NodeList listOfFunction) {
public int getHighestFunctionID(NodeList listOfFunction) {
int highest = -1;
for (int x = 0, size = listOfFunction.getLength(); x < size; x++) {
Node nNode = listOfFunction.item(x);
Expand All @@ -78,6 +78,6 @@ public int generateNewFunctionId(NodeList listOfFunction) {
highest = (id > highest) ? id : highest;
}
}
return highest + 1;
return highest;
}
}
11 changes: 6 additions & 5 deletions src/main/java/team.stein.qlc/view/QLCFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
/**
* A QLC Function is an element for export which can contain e.g. Chaser or Scene
*/
class QLCFunction {
public class QLCFunction {
private static final Logger log = Logger.getLogger(QLCFunction.class);
int id;

/**
* DIM VALUE
Expand Down Expand Up @@ -41,7 +42,8 @@ class QLCFunction {
* <FixtureVal ID="36">1,255,2,255,3,255</FixtureVal>
* </Function>
*/
public QLCFunction(Scene scene) {
public QLCFunction(Scene scene, int id) {
this.id = id;
log.warn("not yet implemented export");
}

Expand All @@ -63,9 +65,8 @@ public QLCFunction(Scene scene) {
* <Step Number="7" FadeIn="0" Hold="0" FadeOut="0">235</Step>
* </Function>
*/
public QLCFunction(Chaser chaser) {
public QLCFunction(Chaser chaser, int id) {
this.id = id;
log.warn("not yet implemented chaser export");
}


}
2 changes: 1 addition & 1 deletion src/test/java/team/stein/qlc/controller/TestQXWread.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public void testHighestFunctionID() {
Element rootNode = qxWread.document.getDocumentElement();
NodeList engineNodes = rootNode.getElementsByTagName("Engine").item(0).getChildNodes();
NodeList nodeList = ((DeferredElementImpl) engineNodes).getElementsByTagName("Function");
assertEquals(239, qxWread.generateNewFunctionId(nodeList) - 1);
assertEquals(239, qxWread.getHighestFunctionID(nodeList) );
}
}

0 comments on commit 7b5ab92

Please sign in to comment.