view src/alice/test/topology/fish/AsignStartX.java @ 37:ebd44d3e8578

add fish scripts
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Fri, 20 Jan 2012 19:13:31 +0900
parents 0b25b48116b6
children b5daccf36104
line wrap: on
line source

package alice.test.topology.fish;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;

public class AsignStartX extends CodeSegment {

	public Receiver routing = ids.create(CommandType.PEEK);
	public int startX;
	public int index;

	public AsignStartX(int startX, int index) {
		this.startX = startX;
		this.index = index;
	}
	
	@Override
	public void run() {
		System.out.println("AsignStartX: " + startX);
		
		RoutingTable routing = this.routing.asClass(RoutingTable.class);
		int x = startX;
		System.out.println("RoutingTable: " + this.routing.val);
		if (this.index >= this.routing.index) {
			AsignStartX cs = new AsignStartX(startX, index);
			cs.routing.setKey("local", "routing", this.routing.index);
			return;
		}
		for (Routing r : routing.table) {
			System.out.println(r.name);
			ods.update(r.name, "startX", x);
			System.out.println("Assign: " + r.name + ".startX = " + x);
			x += r.width;
		}
		PeekStartX cs = new PeekStartX(this.routing.index);
		cs.startX.setKey("local", "startX", this.index);
	}

}