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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
375
e58f5f74748e create foundation
sugi
parents:
diff changeset
1 package alice.test.topology.aquarium.fx;
e58f5f74748e create foundation
sugi
parents:
diff changeset
2
384
56d4f93a3921 add RegisterList
sugi
parents: 383
diff changeset
3 import java.util.ArrayList;
375
e58f5f74748e create foundation
sugi
parents:
diff changeset
4 import java.util.regex.Matcher;
e58f5f74748e create foundation
sugi
parents:
diff changeset
5 import java.util.regex.Pattern;
e58f5f74748e create foundation
sugi
parents:
diff changeset
6
e58f5f74748e create foundation
sugi
parents:
diff changeset
7 import alice.codesegment.CodeSegment;
e58f5f74748e create foundation
sugi
parents:
diff changeset
8 import alice.datasegment.CommandType;
e58f5f74748e create foundation
sugi
parents:
diff changeset
9 import alice.datasegment.Receiver;
e58f5f74748e create foundation
sugi
parents:
diff changeset
10
e58f5f74748e create foundation
sugi
parents:
diff changeset
11 public class CheckMyName extends CodeSegment {
419
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
12 private Receiver host = ids.create(CommandType.PEEK);
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
13 private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$");
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
14 private int INNER_WIDTH = 10;
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
15
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
16 public CheckMyName(){
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
17 host.setKey("host");
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
18 }
375
e58f5f74748e create foundation
sugi
parents:
diff changeset
19
419
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
20 @Override
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
21 public void run() {
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
22 String name = host.asString();
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
23 Matcher matcher = pattern.matcher(name);
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
24 matcher.find();
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
25
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
26 // use view scope
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
27 int num = new Integer(matcher.group(2));
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
28 // scope: A_n = 5 + 10(n - 1);
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
29 int median = INNER_WIDTH * num;
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
30 ods.put("median", median); // node0 median : 0
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
31 // node1 median : 10
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
32 // node2 median : 20
384
56d4f93a3921 add RegisterList
sugi
parents: 383
diff changeset
33
467
6e304a7a60e7 remove white space
sugi
parents: 419
diff changeset
34 if (num == 0){
419
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
35 // only root node create fishInfoList registered all fishInfo
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
36 // fishInfoList send children for checking all Fish object in own scene
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
37 new RegisterList();
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
38 ods.put("registeredList", new ArrayList<FishInfo>());
467
6e304a7a60e7 remove white space
sugi
parents: 419
diff changeset
39 }
419
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
40
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
41 new CheckAllFishInfoExist();
384
56d4f93a3921 add RegisterList
sugi
parents: 383
diff changeset
42
419
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
43 FishInfo fishInfo = new FishInfo(median,0,0);
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
44 fishInfo.setName(name);
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
45
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
46 ods.put("OwnFishP", fishInfo.clone());
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
47 ods.put("fishData", fishInfo);
384
56d4f93a3921 add RegisterList
sugi
parents: 383
diff changeset
48
419
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
49 new CreateObject();
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
50 new AddObject();
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
51
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
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
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
54 Aquarium.main(args);
aefbe41fcf12 change tab to space
sugi
parents: 406
diff changeset
55 }
375
e58f5f74748e create foundation
sugi
parents:
diff changeset
56 }