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;
|
119
|
11 float max = 3.3f;
|
|
12 float min = -1.3f;
|
|
13
|
111
|
14
|
|
15 public AutoIncrement(String key,int index){
|
|
16
|
|
17 this.key = key;
|
|
18 this.position.setKey("local", key);
|
|
19
|
|
20 }
|
119
|
21
|
|
22 public void Init(){
|
|
23 this.ods = null;
|
|
24 this.position = null;
|
|
25
|
|
26 }
|
111
|
27
|
|
28 @Override
|
115
|
29 public synchronized void run() {
|
111
|
30 FishPoint FP = this.position.asClass(FishPoint.class);
|
115
|
31
|
119
|
32 if (FP.getX()+0.01>max){
|
|
33 FP.setXY(min, FP.getY());
|
|
34 } else if (FP.getX()+0.01< min){
|
|
35 FP.setXY(max, FP.getY());
|
115
|
36 }
|
|
37 else {
|
|
38 FP.setXY(FP.getX()+0.01f, FP.getY());
|
|
39 }
|
|
40
|
|
41
|
111
|
42 ods.update("local", key, FP);
|
119
|
43 /*
|
115
|
44 try {
|
126
|
45 wait(100);
|
115
|
46 } catch (InterruptedException e) {
|
|
47 // TODO Auto-generated catch block
|
|
48 e.printStackTrace();
|
|
49 }
|
119
|
50 */
|
111
|
51 new AutoIncrement(this.key,this.position.index);
|
|
52 }
|
|
53
|
|
54 }
|