Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/aquarium/fx/CheckAllFishInfoExist.java @ 547:e91a574b69de dispose
remove index
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 18 Aug 2015 16:15:17 +0900 |
parents | 15eeb439830c |
children |
line wrap: on
line source
package alice.test.topology.aquarium.fx; import java.io.IOException; import javafx.scene.Group; import javafx.scene.Node; import org.msgpack.MessagePack; import org.msgpack.type.ArrayValue; import org.msgpack.type.Value; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class CheckAllFishInfoExist extends CodeSegment { // this CS check all fish object exist in scene private Receiver info = ids.create(CommandType.TAKE); // fishInfoList private Receiver info1 = ids.create(CommandType.PEEK); public CheckAllFishInfoExist(){ info.setKey("receiveRegisteredList", this); info1.setKey("root", this); } @Override public void run() { try { new SendDataOthers(info, info.key); ods.put("registeredList", info.getVal()); ArrayValue fishInfoList = info.asClass(Value.class).asArrayValue(); MessagePack packer = aliceDaemon.packer; Group root = info1.asClass(Group.class); for (Value v : fishInfoList){ boolean exist = false; FishInfo info = packer.convert(v, FishInfo.class); if (info.name != null) { for (Node n : root.getChildren()) { if (info.name.equals(n.getId())) { exist = true; break; } } if (!exist) { info.fromCheckExist = true; ods.put("fishData", info); } } } } catch (IOException e) { e.printStackTrace(); } this.recycle(); } }