annotate src/alice/test/topology/movement/CheckFishLocation.java @ 105:993a9f194615 working

success share TEST
author sugi
date Tue, 03 Jul 2012 15:58:08 +0900
parents df786bf8f036
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
1 package alice.test.topology.movement;
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
2
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
3 import java.util.regex.Matcher;
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
4 import java.util.regex.Pattern;
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
5
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
6 import alice.codesegment.CodeSegment;
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
7 import alice.datasegment.CommandType;
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
8 import alice.datasegment.Receiver;
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
9
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
10
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
11 public class CheckFishLocation extends CodeSegment{
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
12
97
df786bf8f036 add FishPoint.java and Test
sugi
parents: 94
diff changeset
13 private Receiver position = ids.create(CommandType.PEEK);
94
38f4021353c5 "setKey" is in the instance
sugi
parents: 93
diff changeset
14 private Receiver host = ids.create(CommandType.PEEK);
91
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
15 MakeObject obj;
105
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
16 String key;
91
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
17 Pattern pattern = Pattern.compile("^(cli)([0-9]+)$");
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
18
105
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
19 public CheckFishLocation(MakeObject MO ,String key,int index){
91
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
20 this.obj = MO;
105
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
21 this.key = key;
94
38f4021353c5 "setKey" is in the instance
sugi
parents: 93
diff changeset
22 this.host.setKey("local","host");
105
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
23 this.position.setKey("local",key,index);
91
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
24 }
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
25
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
26 @Override
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
27 public void run(){
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
28 String name = host.asString();
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
29 Matcher matcher = pattern.matcher(name);
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
30 matcher.find();
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
31 int num = new Integer(matcher.group(2));
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
32
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
33 float startX = 2*num - 3.0f;
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
34 float endX = 2*num -0.9f;
97
df786bf8f036 add FishPoint.java and Test
sugi
parents: 94
diff changeset
35 FishPoint FP = this.position.asClass(FishPoint.class);
105
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
36 obj.setLocation(FP.getX(), FP.getY());
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
37 /*
97
df786bf8f036 add FishPoint.java and Test
sugi
parents: 94
diff changeset
38 if (startX <= FP.getX() && FP.getX() < endX){
df786bf8f036 add FishPoint.java and Test
sugi
parents: 94
diff changeset
39 obj.setLocation(FP.getX() - 2*(num-1), FP.getY());
105
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
40 if(this.position.key!="fish3X")
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
41 ods.update("parent", this.position.key, this.position.asInteger()+1);
91
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
42 }
105
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
43 */
993a9f194615 success share TEST
sugi
parents: 97
diff changeset
44 new CheckFishLocation(this.obj,this.key,this.position.index);
94
38f4021353c5 "setKey" is in the instance
sugi
parents: 93
diff changeset
45
38f4021353c5 "setKey" is in the instance
sugi
parents: 93
diff changeset
46
91
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
47
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
48 }
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
49
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
50
19f3bd33277d add KeyInput
sugi
parents:
diff changeset
51 }