Mercurial > hg > Database > Alice
annotate src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java @ 544:90019fe596c4 dispose
add AliceDaemon on paramater, add static ods in Aquarium.java
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 03 Aug 2015 20:13:57 +0900 |
parents | 6e304a7a60e7 |
children | 15eeb439830c |
rev | line source |
---|---|
375 | 1 package alice.test.topology.aquarium.fx; |
2 | |
384 | 3 import java.util.ArrayList; |
375 | 4 import java.util.regex.Matcher; |
5 import java.util.regex.Pattern; | |
6 | |
7 import alice.codesegment.CodeSegment; | |
8 import alice.datasegment.CommandType; | |
9 import alice.datasegment.Receiver; | |
10 | |
11 public class CheckMyName extends CodeSegment { | |
419 | 12 private Receiver host = ids.create(CommandType.PEEK); |
13 private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$"); | |
14 private int INNER_WIDTH = 10; | |
15 | |
16 public CheckMyName(){ | |
17 host.setKey("host"); | |
18 } | |
375 | 19 |
419 | 20 @Override |
21 public void run() { | |
22 String name = host.asString(); | |
23 Matcher matcher = pattern.matcher(name); | |
24 matcher.find(); | |
25 | |
26 // use view scope | |
27 int num = new Integer(matcher.group(2)); | |
28 // scope: A_n = 5 + 10(n - 1); | |
29 int median = INNER_WIDTH * num; | |
30 ods.put("median", median); // node0 median : 0 | |
31 // node1 median : 10 | |
32 // node2 median : 20 | |
384 | 33 |
467 | 34 if (num == 0){ |
419 | 35 // only root node create fishInfoList registered all fishInfo |
36 // fishInfoList send children for checking all Fish object in own scene | |
37 new RegisterList(); | |
38 ods.put("registeredList", new ArrayList<FishInfo>()); | |
467 | 39 } |
419 | 40 |
41 new CheckAllFishInfoExist(); | |
384 | 42 |
419 | 43 FishInfo fishInfo = new FishInfo(median,0,0); |
44 fishInfo.setName(name); | |
45 | |
46 ods.put("OwnFishP", fishInfo.clone()); | |
47 ods.put("fishData", fishInfo); | |
384 | 48 |
419 | 49 new CreateObject(); |
50 new AddObject(); | |
51 | |
52 String[] args = {name}; | |
544
90019fe596c4
add AliceDaemon on paramater, add static ods in Aquarium.java
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
53 Aquarium.ods = ods; |
419 | 54 Aquarium.main(args); |
55 } | |
375 | 56 } |