Mercurial > hg > Database > Alice
changeset 391:a049f025583b multicast
add CalculatePosition CodeSegment
author | sugi |
---|---|
date | Mon, 16 Jun 2014 21:51:36 +0900 |
parents | e29cf08ad1f3 |
children | 60eb80232eaa |
files | src/main/java/alice/test/topology/aquarium/fx/CalculatePosition.java |
diffstat | 1 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/aquarium/fx/CalculatePosition.java Mon Jun 16 21:51:36 2014 +0900 @@ -0,0 +1,38 @@ +package alice.test.topology.aquarium.fx; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class CalculatePosition extends CodeSegment { + + private Receiver info = ids.create(CommandType.TAKE); // diff fish position value + private Receiver info1 = ids.create(CommandType.TAKE); // absolute fish position value + private Receiver info2 = ids.create(CommandType.PEEK); + + + public CalculatePosition(String key){ + info.setKey(key+"FishdiffP"); + info1.setKey("OwnFishP"); + info2.setKey("host"); + + } + + @Override + public void run() { + FishInfo dfp = info.asClass(FishInfo.class); + FishInfo afp = info1.asClass(FishInfo.class); + String myName = info2.asString(); + + afp.setX(afp.getX() + dfp.getX()); + afp.setY(afp.getY() + dfp.getY()); + afp.setZ(afp.getZ() + dfp.getZ()); + + ods.update(info1.key, afp); + ods.update(myName+"FishabsoluteP", new FishInfo(afp.getX(),afp.getY(),afp.getZ())); + + this.recycle(); + } + + +}