Commit b885c7ec authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

droplet grund sequenz mal soweit fertig. jetzt kommt noch der check ob die...

droplet grund sequenz mal soweit fertig. jetzt kommt noch der check ob die droplets sich auch nicht gegenseitig auffressen
parent 65feff0e
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -7,7 +7,7 @@ import java.util.Arrays;
public class Nloc {
public static final int MIN_TIMEDIFF = 3;
public static final int MIN_TIMEDIFF = 2;
private List<Channel> chanlist;
private List<Droplet> dropletList;
......@@ -69,28 +69,24 @@ public class Nloc {
pump = createDropletsequenceInPump(pump, startConfiguration);
//cumulatedDropletTimeDiffList = calcCumTDiffList(timediffList);
//dropletList = generateDropletList(noOfDroplets);
//pump = generateSequenceAsPump(dropletList, cumulatedDropletTimeDiffList);
//for (int i = 0; i < noOfDroplets; i++){
// if (!pump.containsDroplets()) {
// dropletList.add(new Droplet(DropletType.PAYLOAD,
// new Position(pump,1)));
// } else {
// dropletList.add(new Droplet(DropletType.HEADER,
// new Position(pump,i + i * timediff + 1)));
// }
//}
return pump;
}
private Pump createDropletsequenceInPump(Pump pump, BFTableEntry startConfiguration) {
private Pump createDropletsequenceInPump(Pump pump,
BFTableEntry startConfiguration) {
int noOfDroplets = startConfiguration.getNoOfDroplets();
int minTimediff = startConfiguration.getMinTimediff();
for (int i = 0; i < noOfDroplets; i++){
if (!pump.containsDroplets()) {
dropletList.add(new Droplet(DropletType.PAYLOAD,
new Position(pump,1)));
} else {
dropletList.add(new Droplet(DropletType.HEADER,
new Position(pump,i + i * minTimediff + 1)));
}
}
return pump;
}
private List<BFTableEntry> calcBFTable(List<Channel> path)
......@@ -114,14 +110,11 @@ public class Nloc {
* "end" to "start"
*/
for (int listPos = bftable.size(); listPos > 0; listPos--) {
System.out.println("listpos: " + listPos + " Size: " + bftable.size());
BFTableEntry cur = bftable.get(listPos - 1);
System.out.println("Entry num: " + bftable.indexOf(cur));
BFTableEntry prev = null;
if (listPos != bftable.size()) {
prev = bftable.get(listPos);
}
System.out.println(prev);
if (cur.getBfPathPriority() == 2) {
if (prev != null) {
......@@ -139,7 +132,7 @@ public class Nloc {
int curMinSteps = cur.getBfMinSteps();
if (curMinSteps <= prevMaxTimediff) {
if (curMinSteps <= (prevMaxTimediff - 1)) {
if (curMinSteps > prevMinTimediff) {
cur.setMinTimediff(curMinSteps);
} else {
......@@ -147,7 +140,7 @@ public class Nloc {
}
cur.setMaxTimediff(prevMaxTimediff);
cur.setNoOfDroplets(prevNoOfDroplets);
} else if (prevMinTimediff <= prevMaxTimediff / 2) {
} else if (prevMinTimediff <= (prevMaxTimediff - 1) / 2) {
cur.setMinTimediff(prevMinTimediff);
cur.setMaxTimediff(prevMaxTimediff / 2);
cur.setNoOfDroplets(prevNoOfDroplets * 2 - 1);
......
......@@ -17,15 +17,26 @@ public class TestNloc {
Nloc nloc4 = new Nloc(getNloc4());
try {
List<BFTableEntry> bftable = nloc4.generateDropletSequence(Arrays.asList("m0","m2","m5"));
for (BFTableEntry bftentry: bftable) {
System.out.print("EntruNr: " + bftable.indexOf(bftentry));
System.out.print(" Prio: " + bftentry.getBfPathPriority());
System.out.print(" MinSteps: " + bftentry.getBfMinSteps());
System.out.print(" NoOfDroplets: " + bftentry.getNoOfDroplets());
System.out.print(" MinTimediff: " + bftentry.getMinTimediff());
System.out.println(" MaxTimediff: " + bftentry.getMaxTimediff());
Pump pump = nloc4.generateDropletSequence(Arrays.asList("m0","m2","m5"));
List<Droplet> startList = pump.getNormalizedSortedDropletList();
String[] printsequence = new String[startList.get(startList.size()-1).getPosition().getSteps()];
for (Droplet dr: startList) {
switch (dr.getType()) {
case PAYLOAD: printsequence[dr.getPosition().getSteps() - 1] = "P";
break;
case HEADER: printsequence[dr.getPosition().getSteps() - 1] = "H";
break;
}
}
System.out.println("Droplet Sequence:");
for (int i = 0; i < printsequence.length; i++) {
if (printsequence[i] == null) {
printsequence[i] = "-";
}
System.out.print(printsequence[i]);
}
System.out.println("");
} catch (NlocStructureException exc) {
System.out.println(exc.getMessage());
}
......
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