Mercurial > hg > Database > Alice
view src/alice/test/topology/fishmodel/alpha/AutoIncrement.java @ 126:669dba7cbb69 working
Use singleton
author | sugi |
---|---|
date | Fri, 03 Aug 2012 19:14:46 +0900 (2012-08-03) |
parents | f84e1684c6be |
children | 1044a79ce4ef |
line wrap: on
line source
package alice.test.topology.fishmodel.alpha; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class AutoIncrement extends CodeSegment { public Receiver position = ids.create(CommandType.PEEK); String key; float max = 3.3f; float min = -1.3f; public AutoIncrement(String key,int index){ this.key = key; this.position.setKey("local", key); } public void Init(){ this.ods = null; this.position = null; } @Override public synchronized void run() { FishPoint FP = this.position.asClass(FishPoint.class); if (FP.getX()+0.01>max){ FP.setXY(min, FP.getY()); } else if (FP.getX()+0.01< min){ FP.setXY(max, FP.getY()); } else { FP.setXY(FP.getX()+0.01f, FP.getY()); } ods.update("local", key, FP); /* try { wait(100); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } */ new AutoIncrement(this.key,this.position.index); } }