Mercurial > hg > Database > Alice
annotate src/alice/test/topology/share/CheckMyName.java @ 103:37f3483a869b working
remove bug from "CheckParentIndex" and "CheckLocalIndex"
author | sugi |
---|---|
date | Mon, 02 Jul 2012 11:16:01 +0900 |
parents | df786bf8f036 |
children | a8f77957a477 |
rev | line source |
---|---|
96 | 1 package alice.test.topology.share; |
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; | |
103
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
9 import alice.test.topology.movement.FishPoint; |
96 | 10 |
11 public class CheckMyName extends CodeSegment { | |
12 Receiver host = ids.create(CommandType.PEEK); | |
13 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); | |
14 | |
103
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
15 String key = "fish"; |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
16 |
96 | 17 public CheckMyName(){ |
18 host.setKey("local","host"); | |
19 } | |
20 | |
21 | |
22 @Override | |
23 public synchronized void run(){ | |
24 | |
25 String name = host.asString(); | |
26 Matcher matcher = pattern.matcher(name); | |
27 | |
28 matcher.find(); | |
29 String type = matcher.group(1); | |
30 int cliNum = new Integer(matcher.group(2)); | |
31 | |
32 if (type.equals("cli")){ | |
33 System.out.println("cli"+cliNum); | |
103
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
34 ods.update("local", this.key, new FishPoint(0.0f,0.0f)); |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
35 new CheckLocalIndex(this.key,0); |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
36 new CheckParentIndex(this.key,0); |
96 | 37 |
38 | |
39 | |
40 }else if(type.equals("node")){ | |
41 | |
42 System.out.println("node"+cliNum); | |
43 if (cliNum == 0){ | |
103
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
44 try { |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
45 for (float i = 0.0f; i < 2.0f; i +=0.1f) { |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
46 System.out.println("i = " + i); |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
47 ods.update("local", "fish", new FishPoint(i,i)); |
97 | 48 wait(500); |
103
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
49 } |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
50 }catch (InterruptedException e) { |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
51 |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
52 e.printStackTrace(); |
97 | 53 } |
96 | 54 }else{ |
103
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
55 ods.update("local", this.key, new FishPoint(0.0f,0.0f)); |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
56 new CheckLocalIndex(this.key,0); |
37f3483a869b
remove bug from "CheckParentIndex" and "CheckLocalIndex"
sugi
parents:
97
diff
changeset
|
57 new CheckParentIndex(this.key,0); |
96 | 58 |
59 } | |
60 | |
61 } | |
62 } | |
63 } |