Mercurial > hg > Database > Alice
comparison 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 |
comparison
equal
deleted
inserted
replaced
133:26b4b18c51fa | 134:53aff28cde6b |
---|---|
1 package alice.test.topology.aquarium; | |
2 | |
3 import java.util.regex.Matcher; | |
4 import java.util.regex.Pattern; | |
5 | |
6 import alice.codesegment.CodeSegment; | |
7 import alice.datasegment.CommandType; | |
8 import alice.datasegment.Receiver; | |
9 | |
10 | |
11 public class CheckMyName extends CodeSegment { | |
12 Receiver host = ids.create(CommandType.PEEK); | |
13 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); | |
14 String key = "fish"; | |
15 | |
16 @Override | |
17 public void run(){ | |
18 | |
19 String name = host.asString(); | |
20 Matcher matcher = pattern.matcher(name); | |
21 | |
22 matcher.find(); | |
23 String type = matcher.group(1); | |
24 int num = new Integer(matcher.group(2)); | |
25 /* | |
26 ods.put("local", "myMax", num); | |
27 if (type.equals("cli")){ | |
28 ods.put("parent", "check", num); | |
29 }else if (type.equals("node")){ | |
30 if (num !=0){ | |
31 ods.put("parent", "check", num); | |
32 } else { | |
33 | |
34 } | |
35 } | |
36 */ | |
37 | |
38 MakeFrame frame = new MakeFrame(name); | |
39 RoutingTable routing = new RoutingTable(); | |
40 /* | |
41 ods.put("local", "max", num); | |
42 new CheckLocalIndex(key,1); | |
43 */ | |
44 if (type.equals("cli")){ | |
45 System.out.println("cli"+num); | |
46 routing.table.add(new Routing("parent")); | |
47 ods.put("local", "list", routing); | |
48 | |
49 new AddRoutingTable(routing,0); | |
50 ods.put("parent", "member", name); | |
51 | |
52 }else if (type.equals("node")){ | |
53 System.out.println("node"+num); | |
54 if (num != 0){ | |
55 routing.table.add(new Routing("parent")); | |
56 ods.put("parent", "member", name); | |
57 | |
58 } | |
59 ods.put("local", "list", routing); | |
60 new AddRoutingTable(routing,0); | |
61 | |
62 } | |
63 | |
64 ods.update("local", key, new FishPoint(-0.1f,-0.1f)); | |
65 new SetLocation(new MakeObject(frame),key,0,num); | |
66 new CheckLocalIndex(key,1); | |
67 | |
68 for (int i = 0;i < 3 ; i++){ | |
69 key = "fish"+i; | |
70 if (num == 0) new AutoIncrement(key,0); | |
71 ods.update("local", key, new FishPoint(0.2f*i,0.2f*i)); | |
72 new SetLocation(new MakeObject(frame),key,0,num); | |
73 new CheckLocalIndex(key,1); | |
74 } | |
75 | |
76 | |
77 } | |
78 } |