1
2
3
4
5
6
7
8
9
10 import re
11 import concert_msgs.msg as concert_msgs
12
13
14
15
16
17
19 '''
20 This represents an implementation rule node currently derived from
21 a ros parameterisation.
22 '''
23 __slots__ = ['id', 'tuple', 'min', 'max', 'force_name_matching']
24
26
27 self.id = param['id']
28 self.tuple = param['tuple']
29
30 if not 'min' in param and not 'max' in param:
31 self.min = 1
32 self.max = 1
33 elif not 'min' in param:
34 self.min = 1
35 self.max = param['max']
36 elif not 'max' in param:
37 self.min = param['min']
38 self.max = concert_msgs.LinkNode.UNLIMITED_RESOURCE
39 else:
40 self.min = param['min']
41 self.max = param['max']
42 self.force_name_matching = True if 'force_name_matching' in param else False
43
46
48 return self.min == self.max
49
51 '''
52 Checks to see if a client is compatible for the implementation's node rule.
53 '''
54
55
56
57 parts = self.tuple.split('.')
58 platform = parts[0]
59 system = parts[1]
60 robot = parts[2]
61 app_name = parts[3]
62 if platform != '*' and platform != concert_client.platform:
63 return False
64 if system != '*' and system != concert_client.system:
65 return False
66 if robot != '*' and robot != concert_client.robot:
67 return False
68
69 if self.force_name_matching and not re.match(self.id, re.sub('[0-9]*$', '', concert_client.name)):
70 return False
71 for client_app in concert_client.apps:
72 if app_name == client_app.name:
73 return True
74 return False
75