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
|
94
|
14
|
81
|
15 @Override
|
|
16 public void run(){
|
|
17
|
|
18 String name = host.asString();
|
|
19 Matcher matcher = pattern.matcher(name);
|
|
20
|
|
21 matcher.find();
|
|
22 String type = matcher.group(1);
|
|
23 int cliNum = new Integer(matcher.group(2));
|
|
24
|
|
25 if (type.equals("cli")){
|
|
26 System.out.println("cli"+cliNum);
|
93
|
27
|
88
|
28 MakeFrame frame = new MakeFrame();
|
93
|
29
|
94
|
30 MakeObject obj3 = new MakeObject(frame);
|
|
31 frame.register(obj3);
|
|
32 new CheckFishLocation(obj3,"fish3X");
|
|
33
|
89
|
34 MakeObject obj = new MakeObject(frame);
|
|
35 frame.register(obj);
|
94
|
36 new CheckFishLocation(obj,"fish1X");
|
|
37
|
81
|
38 }else if(type.equals("node")){
|
|
39 System.out.println("node0");
|
94
|
40 ods.update("local", "fish3X", 0);
|
88
|
41 ods.update("local", "fish1X", -1000);
|
94
|
42
|
81
|
43
|
|
44 }
|
|
45 }
|
|
46 }
|