view src/alice/test/topology/movement/CheckMyName.java @ 91:19f3bd33277d working

add KeyInput
author sugi
date Tue, 05 Jun 2012 00:35:58 +0900
parents e269cedd8bae
children 8e3c1217aad4
line wrap: on
line source

package alice.test.topology.movement;

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

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

public class CheckMyName extends CodeSegment {
	Receiver host = ids.create(CommandType.PEEK);
	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
	
	@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);
			MakeFrame frame =  new MakeFrame();
			MakeObject obj = new MakeObject(frame);
			frame.register(obj);
			CheckFishLocation cs = new CheckFishLocation(obj,"fish1X");
			cs.host.setKey("local","host");
			cs.nowX.setKey("parent","fish1X");
						
			MakeObject obj2 = new MakeObject(frame);
			frame.register(obj2);
			CheckFishLocation cs2 = new CheckFishLocation(obj2,"fish2X");
			cs2.host.setKey("local","host");
			cs2.nowX.setKey("parent","fish2X");
			
					
		}else if(type.equals("node")){
			System.out.println("node0");
			ods.update("local", "fish1X", -1000);
			ods.update("local", "fish2X", -1000);
			
		}
	}
}