diff --git a/src/Nloc.java b/src/Nloc.java index a112798e1e6884e03715ffefc4e0475ecae3e3d8..cdb8ae89d04d29c8b3e30c9c617c7c83292fedf8 100644 --- a/src/Nloc.java +++ b/src/Nloc.java @@ -52,7 +52,7 @@ public class Nloc { currentSeq = resetPayloadDropletPosition(currentSeq); } while (!possibleSequences.isEmpty() && dropletSequence.size() != currentSeq.size() && - !sequenceFunctinal()); + !this.sequenceFunctinal()); if (dropletSequence.size() != currentSeq.size()) { pump = null; @@ -239,9 +239,9 @@ public class Nloc { for (Droplet dr : drArr) { //System.out.println("Droplet: " + dr.getName() + " Position: " + dr.getPosition().getChannel().getName() + ":" + dr.getPosition().getSteps()); dr.move(); - System.out.println("Droplet: " + dr.getName() + " Position: " + dr.getPosition().getChannel().getName() + ":" + dr.getPosition().getSteps()); + //System.out.println("Droplet: " + dr.getName() + " Position: " + dr.getPosition().getChannel().getName() + ":" + dr.getPosition().getSteps()); } - System.out.println(""); + //System.out.println(""); for (Droplet dr: drArr) { //System.out.println("Droplet: " + dr.getName() + " Position: " + dr.getPosition().getChannel().getName() + ":" + dr.getPosition().getSteps()); if (dr.coalesce()) { diff --git a/src/TestNloc.java b/src/TestNloc.java index af3e9330760ce93d83241fe3a91f2c2a22b125c4..4861e4e69868bf9f9538ab32f244f683cf155c04 100644 --- a/src/TestNloc.java +++ b/src/TestNloc.java @@ -11,7 +11,7 @@ public class TestNloc { public static void main(String[] args) { //Nloc nl = new Nloc(getNlocS5()); - List<Channel> chList = getNlocS5(); + List<Channel> chList = getNlocSXX(); Nloc nl = new Nloc(chList); //Pump pump = nl.getPump(); //pump.setSteps(2); @@ -39,7 +39,8 @@ public class TestNloc { //} List<List<Channel>> allPaths = nl.getAllPaths(); - allPaths.remove(4); + //printPaths(allPaths); + //allPaths.remove(4); //try { // String[] mtv = {"f2", "m3", "h0", "m5"}; @@ -54,34 +55,46 @@ public class TestNloc { //} //printPaths(allPaths); - int count = 0; - 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("Pathnum: " + count++); - Pump p = nl.getShortestSequence(modulesToVisit); - printPumpcontents(p); + String[] mtv = {"h0", "m2", "m3"}; + try { + List<List<SequenceTuple>> stll = nl.getPossibleSequences(mtv); + printSequences(stll); + } catch (NoSuchModuleException e) { + System.out.println(e.getMessage()); } + //int count = 0; + //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("Pathnum: " + count++); + // 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() + " Outlet: " + dr.getPumpOutlet().getName()); - if (drlist.indexOf(dr) == drlist.size() - 1) { + if (pump == null) { + System.out.println("No Sequence Found"); + } else { + List<Droplet> drlist = pump.getDropletList(); + if (!drlist.isEmpty()) { + for (Droplet dr: drlist) { + System.out.print("Droplet: " + dr.getName() + " Pos: " + dr.getPosition().getSteps() + " Outlet: " + dr.getPumpOutlet().getName()); + if (drlist.indexOf(dr) == drlist.size() - 1) { + System.out.println(""); + } else { + System.out.print(" | "); + } + } System.out.println(""); - } else { - System.out.print(" | "); } } - System.out.println(""); - } public static String[] extractModuleStringArrayFromPath(List<Channel> path) { List<String> strlist = new ArrayList<String>(); @@ -1042,6 +1055,83 @@ public class TestNloc { return chlist; } + public static List<Channel> getNlocSXX() { + + // channel(name, psteps, hsteps) + Channel ch1 = new Channel("ch1",1,1); + Channel ch2 = new Channel("ch2",1,1); + Channel ch3 = new Channel("ch3",3,3); + Channel ch4 = new Channel("ch4",1,1); + Channel ch5 = new Channel("ch5",1,1); + Channel ch6 = new Channel("ch6",1,1); + Channel ch7 = new Channel("ch7",1,1); + Channel ch8 = new Channel("ch8",3,3); + Channel ch9 = new Channel("ch9",1,1); + Channel ch10 = new Channel("ch10",1,1); + Channel ch11 = new Channel("ch11",1,1); + Channel ch12 = new Channel("ch12",3,3); + Channel ch13 = new Channel("ch13",1,1); + Channel ch14 = new Channel("ch14",1,1); + Channel ch15 = new Channel("ch15",1,1); + Channel ch16 = new Channel("ch16",1,1); + Channel ch17 = new Channel("ch17",1,1); + + Module m0 = new Module("m0", 5,1); + Module m1 = new Module("m1", 5,1); + Module m2 = new Module("m2", 5,1); + Module m3 = new Module("m3", 5,1); + Module h0 = new Module("h0", 5,1); + + Pump p0 = new Pump(); + Sink s0 = new Sink(); + + List<Channel> chlist = Arrays.asList(ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, + ch9, ch10, ch11, ch12, ch13, ch14, ch15, ch16, ch17, m0, m1, m2, m3, + h0, p0, s0); + + p0.addChild(ch1); + p0.addChild(ch2); + p0.addChild(ch17); + + ch1.addChild(ch3); + ch1.addChild(ch4); + + ch3.addChild(m0); + m0.addChild(ch6); + + ch2.addChild(h0); + h0.addChild(ch5); + + + ch17.addChild(ch7); + ch5.addChild(ch7); + + ch7.addChild(ch8); + ch7.addChild(ch9); + + ch8.addChild(m1); + m1.addChild(ch10); + + ch10.addChild(ch11); + ch9.addChild(ch11); + ch6.addChild(ch11); + ch4.addChild(ch11); + + ch11.addChild(ch12); + ch11.addChild(ch13); + + ch12.addChild(m2); + m2.addChild(ch14); + ch14.addChild(ch15); + ch13.addChild(ch15); + + ch15.addChild(m3); + m3.addChild(ch16); + + ch16.addChild(s0); + return chlist; + } + public static List<Channel> getNlocSC() { // channel(name, psteps, hsteps)