Commit 18c0e534 authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

die dropletsequenzen sind jetzt fast richtig aber die positionen in den pumps stimmen noch nicht

parent cb313b3f
......@@ -72,6 +72,10 @@ public class Channel extends NlocEntity implements Comparable<Channel> {
dropletList.add(droplet);
}
public void removeAllDroplets() {
this.dropletList.clear();
}
public void setDropletList(List<Droplet> dropletList) {
this.dropletList = dropletList;
}
......
......@@ -20,6 +20,7 @@ public class Nloc {
public Pump getShortestSequence(String[] modulesToVisit) {
Pump pump = this.getPump();
pump.removeAllDroplets();
try {
List<List<SequenceTuple>> possibleSequences =
getPossibleSequences(modulesToVisit);
......@@ -360,8 +361,6 @@ public class Nloc {
// and add the list of sequence tuples to the possible sequences list
if (dropletPath.contains(currentBifurcation) && prio > 0) {
System.out.println("At last sequence tuple and adding header droplet(s) to: " + currentSeqTup.getDroplet().getName() + ": " + currentSeqTup.getMinPos());
System.out.println("");
// we need header droplet
// cirst check all possible paths of header droplets
......@@ -406,15 +405,10 @@ public class Nloc {
possibleSequences.add(tmp);
}
} else {
System.out.println("At last sequence tuple and NOT adding header droplet(s) to: " + currentSeqTup.getDroplet().getName() + ": " + currentSeqTup.getMinPos());
System.out.println("");
possibleSequences.add(seqTupList);
}
} else {
if (dropletPath.contains(currentBifurcation) && prio > 0) {
System.out.println("NOT at last sequence tuple and ");
System.out.println("Adding header droplet(s) to: " + currentSeqTup.getDroplet().getName() + ": " + currentSeqTup.getMinPos());
System.out.println("");
// we need header droplet
// cirst check all possible paths of header droplets
......@@ -461,8 +455,6 @@ public class Nloc {
possibleSequences, currentBifurcation);
}
} else {
System.out.println("NOT at last sequence tuple and NOT adding header droplets to: " + currentSeqTup.getDroplet().getName() + ": " + currentSeqTup.getMinPos());
System.out.println("");
getSequencesAtBifurcationRecursive(seqTupList,
seqTupList.get(seqTupList.indexOf(currentSeqTup) + 1),
possibleSequences, currentBifurcation);
......
......@@ -10,68 +10,39 @@ public class TestNloc {
public static void main(String[] args) {
Nloc nl = new Nloc(getNlocS1());
Nloc nl = new Nloc(getNlocS2());
List<List<Channel>> allPaths = nl.getAllPaths();
//Nloc nlSX = new Nloc(getNlocS1());
//Nloc nlSX = new Nloc(getNlocS2());
//Nloc nlSX = new Nloc(getNlocS6());
//Nloc nlSX = new Nloc(getNlocS7());
//Nloc nlSX = new Nloc(getNlocS8());
//try {
// List<Channel> chlist = nlSX.getModulesByName(Arrays.asList("ch1","ch3"));
// List<Channel> chlist = nlSX.getModulesByName(Arrays.asList("ch1"));
// System.out.println(nlSX.getHeaderPathlength(chlist));
//} catch(Exception e) {
// System.out.println( e.getMessage());
//}
//String[] mtv = {"m4","d1","m1","m3","h0","m5"};
//try {
// List<List<SequenceTuple>> sequences = nlSX.getPossibleSequences(mtv);
// printSequences(sequences);
//} catch(Exception e) {
// System.out.println( e.getMessage());
//}
//
//Droplet p = new Droplet(DropletType.PAYLOAD,"p");
//Droplet h1 = new Droplet(DropletType.HEADER,"h1");
//Droplet h2 = new Droplet(DropletType.HEADER,"h2");
//Droplet h3 = new Droplet(DropletType.HEADER,"h3");
//Droplet h4 = new Droplet(DropletType.HEADER,"h4");
//Pump pump = new Pump();
//Channel outlet = new Channel("ch1",1,1);
//Sink sink = new Sink();
//List<Channel> path = Arrays.asList(pump, outlet, sink);
//Nloc nloc = new Nloc(path);
//SequenceTuple st0 = new SequenceTuple(p,path,0,0);
//SequenceTuple st1 = new SequenceTuple(h1,path,1,2);
//SequenceTuple st2 = new SequenceTuple(h2,path,1,1);
//SequenceTuple st3 = new SequenceTuple(h3,path,2,2);
//
//List<SequenceTuple> stl = new ArrayList<SequenceTuple>();
//stl.add(st0);
//stl.add(st1);
//stl.add(st2);
//stl.add(st3);
//List<List<SequenceTuple>> stll = new ArrayList<List<SequenceTuple>>();
//stll.add(stl);
//
//List<Droplet> dropletList = nloc.generateDropletListRecursive(new ArrayList<Droplet>(), stl, 1);
//for (Droplet dr: dropletList) {
// System.out.println("dr: " + dr.getName() + " Pos: " + dr.getPosition().getSteps() );
//}
//printPaths(allPaths);
for (List<Channel> path: allPaths) {
String[] modulesToVisit = extractModuleStringArrayFromPath(path);
System.out.println("Modules to visit: ");
for (String str: modulesToVisit) {
System.out.print(str + " " );
}
System.out.println("");
Pump p = nl.getShortestSequence(modulesToVisit);
printPumpcontents(p);
}
}
public static void printPumpcontents(Pump pump) {
List<Droplet> drlist = pump.getDropletList();
for (Droplet dr: drlist) {
System.out.print("Droplet: " + dr.getName() + " Pos: " + dr.getPosition().getSteps());
if (drlist.indexOf(dr) == drlist.size() - 1) {
System.out.println("");
} else {
System.out.print(" | ");
}
System.out.println("");
}
}
public static String[] extractModuleStringArrayFromPath(List<Channel> path) {
List<String> strlist = new ArrayList<String>();
for (Channel ch: path) {
......@@ -79,7 +50,7 @@ public class TestNloc {
strlist.add(ch.getName());
}
}
return strlist.toArray();
return strlist.toArray(new String[strlist.size()]);
}
public static void printSequence(List<SequenceTuple> seq) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment