Commit 7d9dd411 authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

csv ausgabe implementiert

parent 48e585b1
......@@ -97,7 +97,7 @@ public class Nloc {
// calculate and set pump offsets
List<Channel> payloadPathToCurrentBifurcation =
payloadPath.subList(0,payloadPath.indexOf(currentBifurcation));
payloadPath.subList(0,payloadPath.indexOf(currentBifurcation) + 1);
int pathLenPayloadDroplet = this.getPayloadPathlength(
payloadPathToCurrentBifurcation);
......@@ -112,6 +112,10 @@ public class Nloc {
tmpTuple.setMaxPos(newTupleMaxPos);
}
}
//for (SequenceTuple stup: headersWithDefaultPaths) {
// System.out.println("stup to add to list: " + stup.getDroplet().getName() + " : " + stup.getMinPos() + ":" + stup.getMaxPos());
//}
if (headersWithDefaultPaths.isEmpty()) {
// if no header with default path is found empty sequencetuple list
// and stop the search
......@@ -122,18 +126,23 @@ public class Nloc {
for (SequenceTuple hstup: headersWithDefaultPaths) {
if (!SequenceTuple.conflictingOffsets(hstup, s1)) {
s1.add(hstup);
break;
}
}
if (oldSeqTupListLen < s1.size()) {
//for (SequenceTuple stup: s1) {
// System.out.println("SequenceTuple: " + stup.getDroplet().getName() + " : " + stup.getMinPos() + ":" + stup.getMaxPos());
//}
if ( !(payldTuple.getCurrentBifurcation() instanceof Pump) &&
oldSeqTupListLen >= s1.size()) {
s1.clear();
suitableHeaderFound = false;
}
}
payldTuple.setCurrentBifurcation(payldTuple.getPreviousBifurcation());
} else {
// no header needed just ascend to next bifurcation
payldTuple.setCurrentBifurcation(payldTuple.getPreviousBifurcation());
}
} while (suitableHeaderFound &&
!(payldTuple.getCurrentBifurcation() instanceof Pump));
......
......@@ -10,7 +10,7 @@ public class TestNloc {
public static void main(String[] args) {
List<Channel> chList = getNlocSXX(); //getNlocSXX();
List<Channel> chList = getNlocS3(); //getNlocSXX();
Nloc nl = new Nloc(chList);
......@@ -50,31 +50,74 @@ public class TestNloc {
////printDropletSequence(drlist);
////printPumpcontents(p);
long overallStart = System.nanoTime();
for (List<Channel> path: allPaths) {
String[] modulesToVisit = extractModuleStringArrayFromPath(path);
System.out.println("Pathnum: " + count++);
System.out.println("Modules to visit: ");
for (String str: modulesToVisit) {
System.out.print(str + " " );
}
System.out.println("");
//System.out.println("Pathnum: " + count++);
//System.out.println("Modules to visit: ");
//for (String str: modulesToVisit) {
// System.out.print(str + " " );
//}
//System.out.println("");
//try {
// List<List<SequenceTuple>> stll = nl.getPossibleSequencesExhaustive(modulesToVisit);
// //printSequences(stll);
//} catch (Exception e) {
// e.printStackTrace();
//}
//List<Droplet> drlist = nl.getShortestSequenceExhaustive(modulesToVisit);
List<Droplet> drlist = nl.getShortestSequenceOnlyDefaultPathHeader(modulesToVisit);
printDropletSequence(drlist);
long timeStart = System.nanoTime();
List<Droplet> drlist = nl.getShortestSequenceExhaustive(modulesToVisit);
//List<Droplet> drlist = nl.getShortestSequenceOnlyDefaultPathHeader(modulesToVisit);
long timeEnd = System.nanoTime();
long duration = (timeEnd - timeStart);
printCSV(modulesToVisit, drlist, duration);
//printDropletSequence(drlist);
//printDuration(duration);
}
long overallEnd = System.nanoTime();
long overallDuration = (overallEnd - overallStart);
printDuration(overallDuration);
}
public static void printCSV(String[] modulesToVisit, List<Droplet> drlist,
long duration) {
String csv = "";
for (String str: modulesToVisit) {
csv = csv.concat(str + " ");
}
csv = csv.concat(";");
if (drlist == null || drlist.isEmpty()) {
csv = csv.concat("No");
} else {
csv = csv.concat("Yes");
}
csv = csv.concat(";");
duration /= 1000000;
csv = csv.concat(duration + " ms");
System.out.println( csv);
}
public static void printDuration(long duration) {
System.out.print("Duration: ");
if (duration < 1000) {
System.out.println(duration + " ns");
} else if (duration < 1000000) {
duration /= 1000;
System.out.println(duration + " micro sec");
} else if (duration < 1000000000) {
duration /= 1000000;
System.out.println(duration + " ms");
} else {
duration /= 1000000000;
System.out.println(duration + " s");
}
}
public static void printDropletSequence(List<Droplet> drList) {
if (drList == null || drList.isEmpty()) {
System.out.println("No Sequence Found");
System.out.println("No Sequence Found\n");
} else {
for (Droplet dr: drList) {
System.out.print("Droplet: " + dr.getName() + " Pos: " + dr.getPosition().getSteps() + " Outlet: " + dr.getPumpOutlet().getName());
......
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