Mercurial > hg > Database > Alice
view src/alice/test/topology/aquarium/CheckMyName.java @ 134:53aff28cde6b working
change package
author | sugi |
---|---|
date | Wed, 15 Aug 2012 17:11:57 +0900 |
parents | src/alice/test/topology/fishmodel/beta/CheckMyName.java@26b4b18c51fa |
children | 2f401fd70311 |
line wrap: on
line source
package alice.test.topology.aquarium; 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]+)$"); String key = "fish"; @Override public void run(){ String name = host.asString(); Matcher matcher = pattern.matcher(name); matcher.find(); String type = matcher.group(1); int num = new Integer(matcher.group(2)); /* ods.put("local", "myMax", num); if (type.equals("cli")){ ods.put("parent", "check", num); }else if (type.equals("node")){ if (num !=0){ ods.put("parent", "check", num); } else { } } */ MakeFrame frame = new MakeFrame(name); RoutingTable routing = new RoutingTable(); /* ods.put("local", "max", num); new CheckLocalIndex(key,1); */ if (type.equals("cli")){ System.out.println("cli"+num); routing.table.add(new Routing("parent")); ods.put("local", "list", routing); new AddRoutingTable(routing,0); ods.put("parent", "member", name); }else if (type.equals("node")){ System.out.println("node"+num); if (num != 0){ routing.table.add(new Routing("parent")); ods.put("parent", "member", name); } ods.put("local", "list", routing); new AddRoutingTable(routing,0); } ods.update("local", key, new FishPoint(-0.1f,-0.1f)); new SetLocation(new MakeObject(frame),key,0,num); new CheckLocalIndex(key,1); for (int i = 0;i < 3 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); ods.update("local", key, new FishPoint(0.2f*i,0.2f*i)); new SetLocation(new MakeObject(frame),key,0,num); new CheckLocalIndex(key,1); } } }