111
|
1 package alice.test.topology.fishmodel.alpha;
|
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
|
6
|
|
7 public class AutoIncrement extends CodeSegment {
|
|
8
|
|
9 public Receiver position = ids.create(CommandType.PEEK);
|
|
10 String key;
|
|
11
|
|
12 public AutoIncrement(String key,int index){
|
|
13
|
|
14 this.key = key;
|
|
15 this.position.setKey("local", key);
|
|
16
|
|
17 }
|
|
18
|
|
19 @Override
|
115
|
20 public synchronized void run() {
|
111
|
21 FishPoint FP = this.position.asClass(FishPoint.class);
|
115
|
22
|
|
23 if (FP.getX()+0.01>9.0f){
|
|
24 FP.setXY(-1.0f, FP.getY());
|
|
25 } else if (FP.getX()+0.01< -1.0f){
|
|
26 FP.setXY(9.0f, FP.getY());
|
|
27 }
|
|
28 else {
|
|
29 FP.setXY(FP.getX()+0.01f, FP.getY());
|
|
30 }
|
|
31
|
|
32
|
111
|
33 ods.update("local", key, FP);
|
114
|
34
|
115
|
35 try {
|
|
36 wait(150);
|
|
37 } catch (InterruptedException e) {
|
|
38 // TODO Auto-generated catch block
|
|
39 e.printStackTrace();
|
|
40 }
|
|
41
|
111
|
42 new AutoIncrement(this.key,this.position.index);
|
|
43
|
|
44 }
|
|
45
|
|
46 }
|