Funnel merges its left and right inputs on its output.
public class Funnel extends ReactiveProcess { private Channel in, left, right, out; private boolean fromLeft = true; public Funnel(Channel left,Channel right,Channel out) { this.left = left; this.right = right; this.out = out; } public Funnel(NrpMachine machine,String left, String right,String out) { this.left = machine.getChannel(left); this.right = machine.getChannel(right); this.out = machine.getChannel(out); machine.add(this); } final public String toString(){ return "funnel(" + out + "," + left + "," + right + ")"; } protected byte activation(Machine machine) { Channel in = fromLeft ? left : right; byte b = fix(in,machine); if (b == TERM){ put(out,in.get(),machine); b = STOP; } if (b != SUSP) fromLeft = !fromLeft; return b; } }
Two points are important to note: