Skip to content

Commit 6748ca5

Browse files
committed
cleaned config, fixed requires error (missing reference), fixed implements error (name mismatch between config and main.cpp proxy)
1 parent 433e938 commit 6748ca5

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

cli/robocompdsl/robocompdsl/templates/templateCPP/files/etc/config

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
${storm_topic_manager}
2-
32
${config_publishes_proxies}
4-
53
${config_requires_proxies}
6-
74
${config_subscribes_endpoints}
8-
95
${config_implements_endpoints}
106

11-
127
${dsr_config}
13-
148
${dsr_viewer_config}
159

1610
Period.Compute = 100

cli/robocompdsl/robocompdsl/templates/templateCPP/plugins/base/functions/etc/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
STORM_TOPIC_MANAGER_STR = """\
77
# This property is used by the clients to connect to IceStorm.
88
Proxies.TopicManager = "IceStorm/TopicManager:default -p 9999"
9+
910
"""
1011

1112
class etc_config(TemplateDict):
@@ -24,7 +25,7 @@ def config_implements_endpoints(self):
2425
if communication_is_ice(interface):
2526
result += f'Endpoints.{interface.name}{num} = "tcp -p 0"\n'
2627
if result != "":
27-
result = '# Endpoints for implements interfaces\n' + result
28+
result = '# Endpoints for implements interfaces\n' + result + '\n'
2829
return result
2930

3031
def config_subscribes_endpoints(self):
@@ -34,7 +35,7 @@ def config_subscribes_endpoints(self):
3435
result += f'Endpoints.{interface.name}Topic{num} = "tcp -p 0"\n'
3536
result += f'Endpoints.{interface.name}Prefix{num} = ""\n'
3637
if result != "":
37-
result = '# Endpoints for subscriptions interfaces\n' + result
38+
result = '# Endpoints for subscriptions interfaces\n' + result + '\n'
3839
return result
3940

4041
def config_publishes_proxies(self):
@@ -43,7 +44,7 @@ def config_publishes_proxies(self):
4344
if communication_is_ice(interface):
4445
result += f'Proxies.{interface.name}Prefix{num} = ""\n'
4546
if result != "":
46-
result = '# Proxies for publishes interfaces\n' + result
47+
result = '# Proxies for publishes interfaces\n' + result + '\n'
4748
return result
4849

4950
def config_requires_proxies(self):
@@ -54,7 +55,7 @@ def config_requires_proxies(self):
5455
result += f'Proxies.{interface.name}{num} = "{interface.name.lower()}:tcp -h localhost -p {port}"\n'
5556

5657
if result != "":
57-
result = '# Proxies for required interfaces\n' + result
58+
result = '# Proxies for required interfaces\n' + result + '\n'
5859
return result
5960

6061
def storm_topic_manager(self):

cli/robocompdsl/robocompdsl/templates/templateCPP/plugins/base/functions/generated/main_cpp.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
void require(const Ice::CommunicatorPtr& communicator,
1717
const std::string& proxyConfig,
1818
const std::string& proxyName,
19-
ProxyPointer proxy)
19+
ProxyPointer& proxy)
2020
{
2121
try
2222
{
@@ -257,7 +257,7 @@ def proxy_ptr(self, interfaces, prefix=''):
257257
return result
258258

259259
def topic_manager_creation(self):
260-
result = "\n//Topic Manager code\n"
260+
result = ""
261261
need_topic = False
262262
for pub in self.component.publishes:
263263
if communication_is_ice(pub):
@@ -269,6 +269,8 @@ def topic_manager_creation(self):
269269
ptr = "Ptr"
270270
manager_type = "Ice::checkedCast<IceStorm::TopicManagerPrx>"
271271
result += Template(TOPIC_MANAGER_STR).substitute(ptr=ptr, type=manager_type)
272+
if len(result)!=0:
273+
result = "\n//Topic Manager code\n" + result
272274
return result
273275

274276

@@ -287,7 +289,7 @@ def add_templates(self):
287289

288290

289291
def publish(self):
290-
result = "\n//Publish code\n"
292+
result = ""
291293
for pba, num in get_name_number(self.component.publishes):
292294
if type(pba) == str:
293295
name = pba
@@ -299,22 +301,25 @@ def publish(self):
299301
result += f'''publish<{proxy_type}Prx, {proxy_type}PrxPtr>(topicManager,
300302
configLoader.get<std::string>("Proxies.{name}Prefix{num}"),
301303
"{name}", {name.lower()}_proxy{num}, PROGRAM_NAME);\n'''
302-
304+
if len(result)!=0:
305+
result = "\n//Publish code\n" + result
303306
return result
304307

305308
def subscribes_to(self):
306-
result = "\n//Subscribe code\n"
309+
result = ""
307310
for interface, num in get_name_number(self.component.subscribesTo):
308311
name = interface.name
309312
if communication_is_ice(interface):
310313
result += f'''subscribe<{name}I>(communicator(),
311314
topicManager, configLoader.get<std::string>("Endpoints.{name}Topic{num}"),
312315
configLoader.get<std::string>("Endpoints.{name}Prefix{num}"), "{name}", worker, {num if num!="" else "0"},
313316
{name.lower()}_topic, {name.lower()}, PROGRAM_NAME);\n'''
317+
if len(result)!=0:
318+
result = "\n//Subscribe code\n" + result
314319
return result
315320

316321
def implements(self):
317-
result = "\n//Implement code\n"
322+
result = ""
318323
for ima, num in get_name_number(self.component.implements):
319324
if type(ima) == str:
320325
name = ima
@@ -323,19 +328,22 @@ def implements(self):
323328
if communication_is_ice(ima):
324329
result += f'''implement<{name}I>(communicator(),
325330
configLoader.get<std::string>("Endpoints.{name}{num}"),
326-
"{name}{num}", worker, {num if num!="" else "0"});\n'''
327-
331+
"{name.lower()}{num}", worker, {num if num!="" else "0"});\n'''
332+
if len(result)!=0:
333+
result = "\n//Implement code\n" + result
328334
return result
329335

330336
def requires(self):
331-
result = "\n//Require code\n"
337+
result = ""
332338
for interface, num in get_name_number(self.component.requires):
333339
name = interface.name
334340
if communication_is_ice(interface):
335341
module = self.component.idsl_pool.module_providing_interface(name)
336342
proxy_type = utils.get_type_string(name, module['name'])
337343
result += f'''require<{proxy_type}Prx, {proxy_type}PrxPtr>(communicator(),
338344
configLoader.get<std::string>("Proxies.{name}{num}"), "{name}Proxy{num}", {name.lower()}_proxy{num});\n'''
345+
if len(result)!=0:
346+
result = "\n//Require code\n" + result
339347
return result
340348

341349
def specificworker_creation(self):

0 commit comments

Comments
 (0)