annotate src/alice/test/topology/movement/CheckMyName.java @ 93:6601f8854126 working

can KeyInputCodeSegment
author sugi
date Tue, 05 Jun 2012 16:33:28 +0900
parents 8e3c1217aad4
children 38f4021353c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
1 package alice.test.topology.movement;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
2
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
3 import java.util.regex.Matcher;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
4 import java.util.regex.Pattern;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
5
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
6 import alice.codesegment.CodeSegment;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
7 import alice.datasegment.CommandType;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
8 import alice.datasegment.Receiver;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
9
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
10 public class CheckMyName extends CodeSegment {
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
11 Receiver host = ids.create(CommandType.PEEK);
87
899b2b78ac75 minor change
sugi
parents: 83
diff changeset
12 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
899b2b78ac75 minor change
sugi
parents: 83
diff changeset
13
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
14 @Override
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
15 public void run(){
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
16
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
17 String name = host.asString();
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
18 Matcher matcher = pattern.matcher(name);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
19
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
20 matcher.find();
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
21 String type = matcher.group(1);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
22 int cliNum = new Integer(matcher.group(2));
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
23
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
24 if (type.equals("cli")){
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
25 System.out.println("cli"+cliNum);
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
26
88
33a19ca88e43 Singleton is removed .
sugi
parents: 87
diff changeset
27 MakeFrame frame = new MakeFrame();
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
28
89
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
29 MakeObject obj = new MakeObject(frame);
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
30 frame.register(obj);
91
19f3bd33277d add KeyInput
sugi
parents: 89
diff changeset
31 CheckFishLocation cs = new CheckFishLocation(obj,"fish1X");
83
909e1c9bc6fc set range
sugi
parents: 81
diff changeset
32 cs.host.setKey("local","host");
88
33a19ca88e43 Singleton is removed .
sugi
parents: 87
diff changeset
33 cs.nowX.setKey("parent","fish1X");
33a19ca88e43 Singleton is removed .
sugi
parents: 87
diff changeset
34
89
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
35 MakeObject obj2 = new MakeObject(frame);
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
36 frame.register(obj2);
91
19f3bd33277d add KeyInput
sugi
parents: 89
diff changeset
37 CheckFishLocation cs2 = new CheckFishLocation(obj2,"fish2X");
89
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
38 cs2.host.setKey("local","host");
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
39 cs2.nowX.setKey("parent","fish2X");
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
40
92
8e3c1217aad4 add KeyInput
sugi
parents: 91
diff changeset
41 MakeObject obj3 = new MakeObject(frame);
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
42 frame.register(obj3);
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
43 CheckFishLocation cs3 = new CheckFishLocation(obj3,"fish3X");
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
44 cs3.host.setKey("local","host");
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
45 cs3.nowX.setKey("parent","fish3X");
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
46
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
47
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
48 }else if(type.equals("node")){
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
49 System.out.println("node0");
88
33a19ca88e43 Singleton is removed .
sugi
parents: 87
diff changeset
50 ods.update("local", "fish1X", -1000);
89
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
51 ods.update("local", "fish2X", -1000);
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
52 ods.update("local", "fish3X", 0);
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
53
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
54 }
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
55 }
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
56 }