annotate src/alice/test/topology/fishmodel/alpha/AutoIncrement.java @ 115:9845b74063ec working

share max number
author sugi
date Sat, 21 Jul 2012 10:02:41 +0900
parents 7dbaaa0de144
children 248064474909
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
1 package alice.test.topology.fishmodel.alpha;
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
2
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
3 import alice.codesegment.CodeSegment;
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
4 import alice.datasegment.CommandType;
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
5 import alice.datasegment.Receiver;
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
6
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
7 public class AutoIncrement extends CodeSegment {
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
8
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
9 public Receiver position = ids.create(CommandType.PEEK);
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
10 String key;
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
11
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
12 public AutoIncrement(String key,int index){
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
13
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
14 this.key = key;
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
15 this.position.setKey("local", key);
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
16
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
17 }
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
18
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
19 @Override
115
9845b74063ec share max number
sugi
parents: 114
diff changeset
20 public synchronized void run() {
111
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
21 FishPoint FP = this.position.asClass(FishPoint.class);
115
9845b74063ec share max number
sugi
parents: 114
diff changeset
22
9845b74063ec share max number
sugi
parents: 114
diff changeset
23 if (FP.getX()+0.01>9.0f){
9845b74063ec share max number
sugi
parents: 114
diff changeset
24 FP.setXY(-1.0f, FP.getY());
9845b74063ec share max number
sugi
parents: 114
diff changeset
25 } else if (FP.getX()+0.01< -1.0f){
9845b74063ec share max number
sugi
parents: 114
diff changeset
26 FP.setXY(9.0f, FP.getY());
9845b74063ec share max number
sugi
parents: 114
diff changeset
27 }
9845b74063ec share max number
sugi
parents: 114
diff changeset
28 else {
9845b74063ec share max number
sugi
parents: 114
diff changeset
29 FP.setXY(FP.getX()+0.01f, FP.getY());
9845b74063ec share max number
sugi
parents: 114
diff changeset
30 }
9845b74063ec share max number
sugi
parents: 114
diff changeset
31
9845b74063ec share max number
sugi
parents: 114
diff changeset
32
111
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
33 ods.update("local", key, FP);
114
7dbaaa0de144 remove vector3f and add Matrix4d
sugi
parents: 112
diff changeset
34
115
9845b74063ec share max number
sugi
parents: 114
diff changeset
35 try {
9845b74063ec share max number
sugi
parents: 114
diff changeset
36 wait(150);
9845b74063ec share max number
sugi
parents: 114
diff changeset
37 } catch (InterruptedException e) {
9845b74063ec share max number
sugi
parents: 114
diff changeset
38 // TODO Auto-generated catch block
9845b74063ec share max number
sugi
parents: 114
diff changeset
39 e.printStackTrace();
9845b74063ec share max number
sugi
parents: 114
diff changeset
40 }
9845b74063ec share max number
sugi
parents: 114
diff changeset
41
111
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
42 new AutoIncrement(this.key,this.position.index);
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
43
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
44 }
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
45
ba64a9d76e70 Add AutoIncrement
sugi
parents:
diff changeset
46 }