annotate src/main/java/alice/test/topology/aquarium/fx/CalculatePosition.java @ 520:c9175c310987 dispose

add reconnect event on aquariumFX
author sugi
date Fri, 23 Jan 2015 14:51:58 +0900
parents 6e304a7a60e7
children 15eeb439830c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
391
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
1 package alice.test.topology.aquarium.fx;
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
2
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
3 import alice.codesegment.CodeSegment;
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
4 import alice.datasegment.CommandType;
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
5 import alice.datasegment.Receiver;
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
6
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
7 public class CalculatePosition extends CodeSegment {
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
8
467
6e304a7a60e7 remove white space
sugi
parents: 419
diff changeset
9 private Receiver info = ids.create(CommandType.TAKE); // diff fish position value
6e304a7a60e7 remove white space
sugi
parents: 419
diff changeset
10 private Receiver info1 = ids.create(CommandType.TAKE); // absolute fish position value
419
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
11 private Receiver info2 = ids.create(CommandType.PEEK);
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
12
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
13 public CalculatePosition(String key){
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
14 info.setKey(key);
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
15 info1.setKey("OwnFishP");
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
16 info2.setKey("host");
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
17
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
18 }
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
19
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
20 @Override
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
21 public void run() {
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
22 FishInfo dfp = info.asClass(FishInfo.class);
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
23 FishInfo afp = info1.asClass(FishInfo.class);
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
24 String myName = info2.asString();
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
25
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
26 afp.setX(afp.getX() + dfp.getX());
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
27 afp.setY(afp.getY() + dfp.getY());
467
6e304a7a60e7 remove white space
sugi
parents: 419
diff changeset
28 afp.setZ(afp.getZ() + dfp.getZ());
419
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
29 ods.update(info1.key, afp);
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
30
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
31 FishInfo fishInfo = new FishInfo(afp.getX(),afp.getY(),afp.getZ());
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
32 fishInfo.rolX = dfp.rolX;
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
33 fishInfo.rolY = dfp.rolY;
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
34 fishInfo.rolZ = dfp.rolZ;
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
35 fishInfo.rotate = dfp.rotate;
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
36 ods.update(myName+"FishabsoluteP", fishInfo);
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
37
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
38 this.recycle();
aefbe41fcf12 change tab to space
sugi
parents: 396
diff changeset
39 }
391
a049f025583b add CalculatePosition CodeSegment
sugi
parents:
diff changeset
40 }