Skip to content
Snippets Groups Projects
Commit f8ceeae7 authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

Beginn des coalesce Checks

parent 06235e2a
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -44,6 +44,12 @@ public class Channel extends NlocEntity implements Comparable<Channel> {
return minDist;
}
public List<Droplet> getNormalizedSortedDropletList() {
dropletList.sort((d1,d2) ->
d1.getNormalizedSteps() - d2.getNormalizedSteps());
return dropletList;
}
public List<Droplet> getDropletList() {
return dropletList;
}
......
package nloc;
import java.util.List;
import java.util.ArrayList;
public class Droplet {
private Position position;
private DropletType type;
......@@ -18,12 +21,58 @@ public class Droplet {
return type;
}
/*
* Unify the position using the faster channel
*/
public int getNormalizedSteps() {
Channel chan = this.position.getChannel();
int pSteps = chan.getPSteps();
int hSteps = chan.getHSteps();
float factor = 1;
if (pSteps < hSteps && this.type == DropletType.HEADER) {
factor = (float)pSteps / hSteps;
} else if (pSteps > hSteps && this.type == DropletType.PAYLOAD) {
factor = (float)hSteps / pSteps;
}
return (int)(this.position.getSteps() * factor);
}
public Position getPosition() {
return position;
}
public boolean coalesce() {
return false;
boolean coalesce = false;
if (this.position.getChannel() instanceof Module ||
this.position.getChannel() instanceof Sink ||
this.position.getChannel() instanceof Pump) {
coalesce = false;
} else {
List<Droplet> drlist =
this.position.getChannel().getNormalizedSortedDropletList();
// Check if we are the last droplet in the channel
if (drlist.indexOf(this) + 1 == drlist.size()) {
List<Channel> childChanList =
this.position.getChannel().getChildrenList();
// Check if the following channel is a sink
if (childChanList.size() == 1 &&
childChanList.get(0) instanceof Sink) {
coalesce = false;
} else {
// Next is no sink
for (Channel chan : childChanList) {
List<Droplet> childDrList = chan.getNormalizedSortedDropletList();
//if (!childDrList.isEmpty() && childDrList.get(0).
}
}
}
}
return coalesce;
}
public void setPosition(Position position) {
......
......@@ -53,7 +53,7 @@ public class Position {
}
private Channel getFollowingChannel(List<Channel> possibleChannels) {
/**
/*
* If possibleChannels.size() > 1 we are at a bifurcation.
* The droplet takes the first Channel that doesn't contain a droplet.
* The list of channels is already ordered by length and thus the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment