view src/alice/test/topology/aquarium/fx/CalculateMaxSize.java @ 18:4e5507afb41f

"MAXSIZE" change automatically
author e095732
date Mon, 04 Feb 2013 01:23:24 +0900
parents
children
line wrap: on
line source

package alice.test.topology.aquarium.fx;

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

public class CalculateMaxSize extends CodeSegment{
	
	private Receiver data1 = ids.create(CommandType.PEEK);
	private Receiver data2 = ids.create(CommandType.PEEK);

	public CalculateMaxSize(){
		data1.setKey("CHILDNUM");
		data2.setKey("width");
	}
	
	public CalculateMaxSize(int index){
		data1.setKey("CHILDNUM", index);
		data2.setKey("width");
	}
	
	@Override
	public void run() {
		int childnum = data1.asInteger();
		int width = data2.asInteger();
		int maxsize = childnum * width + width;
		ods.update("local", "MAXSIZE", maxsize);
		System.out.println(maxsize);
		new CalculateMaxSize(data1.index);
	}
}