view src/alice/test/topology/fishmodel/alpha/CheckMyName.java @ 107:a8f77957a477 working

create new model to share fish point
author sugi
date Tue, 10 Jul 2012 02:30:25 +0900
parents src/alice/test/topology/movement/CheckMyName.java@993a9f194615
children aa9fc077c286
line wrap: on
line source

package alice.test.topology.fishmodel.alpha;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;
import alice.test.topology.share.CheckLocalIndex;
import alice.test.topology.share.CheckParentIndex;

public class CheckMyName extends CodeSegment {
	Receiver host = ids.create(CommandType.PEEK);
	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
	String key = "fish";
	
	@Override
	public void run(){
		
		String name = host.asString();
		Matcher matcher = pattern.matcher(name);
		
		matcher.find();
		String type = matcher.group(1);
		int cliNum = new Integer(matcher.group(2));
		
		if (type.equals("cli")){
			System.out.println("cli"+cliNum);
			ods.update("local", key, new FishPoint(0.0f,0.0f));
			MakeFrame frame =  new MakeFrame();
			
			MakeObject obj3 = new MakeObject(frame);
			frame.register(obj3);
			new CheckFishLocation(obj3,key,0);
			new CheckLocalIndex(key,0);
			new CheckParentIndex(key,0);
			/*
			MakeObject obj = new MakeObject(frame);
			frame.register(obj);
			new CheckFishLocation(obj,"fish1X");
			*/					
		}else if(type.equals("node")){
			System.out.println("node0");
			
			ods.update("local", key, new FishPoint(0.0f,0.0f));
			//ods.update("local", "fish1X", new FishPoint(-1.0f,0.0f));
			if(cliNum == 0){
				new LookData(key,0);
			} else {
				new CheckLocalIndex(key,0);
				new CheckParentIndex(key,0);
				
			}
			
			
			
		}
	}
}