81
|
1 package alice.test.topology.movement;
|
|
2
|
|
3 import java.util.regex.Matcher;
|
|
4 import java.util.regex.Pattern;
|
|
5
|
|
6 import alice.codesegment.CodeSegment;
|
|
7 import alice.datasegment.CommandType;
|
|
8 import alice.datasegment.Receiver;
|
|
9
|
|
10 public class CheckMyName extends CodeSegment {
|
|
11 Receiver host = ids.create(CommandType.PEEK);
|
87
|
12 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
|
|
13
|
81
|
14 @Override
|
|
15 public void run(){
|
|
16
|
|
17 String name = host.asString();
|
|
18 Matcher matcher = pattern.matcher(name);
|
|
19
|
|
20 matcher.find();
|
|
21 String type = matcher.group(1);
|
|
22 int cliNum = new Integer(matcher.group(2));
|
|
23
|
|
24 if (type.equals("cli")){
|
|
25 System.out.println("cli"+cliNum);
|
93
|
26
|
88
|
27 MakeFrame frame = new MakeFrame();
|
93
|
28
|
89
|
29 MakeObject obj = new MakeObject(frame);
|
|
30 frame.register(obj);
|
91
|
31 CheckFishLocation cs = new CheckFishLocation(obj,"fish1X");
|
83
|
32 cs.host.setKey("local","host");
|
88
|
33 cs.nowX.setKey("parent","fish1X");
|
|
34
|
89
|
35 MakeObject obj2 = new MakeObject(frame);
|
|
36 frame.register(obj2);
|
91
|
37 CheckFishLocation cs2 = new CheckFishLocation(obj2,"fish2X");
|
89
|
38 cs2.host.setKey("local","host");
|
|
39 cs2.nowX.setKey("parent","fish2X");
|
|
40
|
92
|
41 MakeObject obj3 = new MakeObject(frame);
|
93
|
42 frame.register(obj3);
|
|
43 CheckFishLocation cs3 = new CheckFishLocation(obj3,"fish3X");
|
|
44 cs3.host.setKey("local","host");
|
|
45 cs3.nowX.setKey("parent","fish3X");
|
|
46
|
|
47
|
81
|
48 }else if(type.equals("node")){
|
|
49 System.out.println("node0");
|
88
|
50 ods.update("local", "fish1X", -1000);
|
89
|
51 ods.update("local", "fish2X", -1000);
|
93
|
52 ods.update("local", "fish3X", 0);
|
81
|
53
|
|
54 }
|
|
55 }
|
|
56 }
|