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);
|
|
12 @Override
|
|
13 public void run(){
|
|
14
|
|
15 String name = host.asString();
|
|
16 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
|
|
17 Matcher matcher = pattern.matcher(name);
|
|
18
|
|
19 matcher.find();
|
|
20 String type = matcher.group(1);
|
|
21 int cliNum = new Integer(matcher.group(2));
|
|
22
|
|
23 if (type.equals("cli")){
|
|
24 System.out.println("cli"+cliNum);
|
|
25
|
|
26 FishMovement.getInstance();
|
|
27
|
|
28 SendLocation cs = new SendLocation();
|
|
29 cs.nowX.setKey("parent","fishX");
|
|
30 cs.nowY.setKey("parent","fishY");
|
|
31
|
|
32 }else if(type.equals("node")){
|
|
33 System.out.println("node0");
|
|
34 ods.update("local", "fishX", 10);
|
|
35 ods.update("local", "fishY", 10);
|
|
36
|
|
37 }
|
|
38 }
|
|
39 }
|