Skip to content

Commit 2d9fe86

Browse files
committed
fix bugs and add documentation of multiple DSRs
1 parent 1432e9d commit 2d9fe86

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

cli/src/robocompdsl/templates/templateCPP/plugins/dsr/functions/etc/config_toml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
3d = true
2121
2222
# --- Multiple Instance Template ---
23-
# If you define sub-instances, the single instance config above will be ignored.
23+
# If you define multiple instances, the single instance config above will be ignored.
2424
# [Agent.instance_name]
2525
# configFile = ""
2626
# domain = 1

cli/src/robocompdsl/templates/templateCPP/plugins/dsr/functions/src/specificworker_cpp.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@
66
from robocompdsl.templates.common.templatedict import TemplateDict
77

88
DSR_SAVE = """\
9-
//G->write_to_json_file("./"+agent_name+".json");
9+
/*
10+
for (auto const& [name, g] : Graphs) {
11+
g->write_to_json_file("./"+agent_name+"_"+name+".json");
12+
}
13+
*/
1014
"""
1115

1216
DSR_CONNECTIONS= """\
13-
//dsr update signals
14-
//connect(G.get(), &DSR::DSRGraph::update_node_signal, this, &SpecificWorker::modify_node_slot);
15-
//connect(G.get(), &DSR::DSRGraph::update_edge_signal, this, &SpecificWorker::modify_edge_slot);
16-
//connect(G.get(), &DSR::DSRGraph::update_node_attr_signal, this, &SpecificWorker::modify_node_attrs_slot);
17-
//connect(G.get(), &DSR::DSRGraph::update_edge_attr_signal, this, &SpecificWorker::modify_edge_attrs_slot);
18-
//connect(G.get(), &DSR::DSRGraph::del_edge_signal, this, &SpecificWorker::del_edge_slot);
19-
//connect(G.get(), &DSR::DSRGraph::del_node_signal, this, &SpecificWorker::del_node_slot);
17+
//Subscription to DSR graph update signals.
18+
// If multiple graphs exist, it is necessary to specify the graph name
19+
// using 'Graphs.at("name")' to connect its signals to the Worker's slots.
20+
//connect(Graphs.at("").get(), &DSR::DSRGraph::update_node_signal, this, &SpecificWorker::modify_node_slot);
21+
//connect(Graphs.at("").get(), &DSR::DSRGraph::update_edge_signal, this, &SpecificWorker::modify_edge_slot);
22+
//connect(Graphs.at("").get(), &DSR::DSRGraph::update_node_attr_signal, this, &SpecificWorker::modify_node_attrs_slot);
23+
//connect(Graphs.at("").get(), &DSR::DSRGraph::update_edge_attr_signal, this, &SpecificWorker::modify_edge_attrs_slot);
24+
//connect(Graphs.at("").get(), &DSR::DSRGraph::del_edge_signal, this, &SpecificWorker::del_edge_slot);
25+
//connect(Graphs.at("").get(), &DSR::DSRGraph::del_node_signal, this, &SpecificWorker::del_node_slot);
2026
"""
2127

2228

@@ -28,7 +34,7 @@
2834
either with a QtDesigner or directly from scratch in a class of its own.
2935
The add_custom_widget_to_dock method receives a name for the widget and a reference to the class instance.
3036
***/
31-
37+
//If you have more than one graph, you need to connect to the specific graph with the name
3238
//graph_viewers.at("")->add_custom_widget_to_dock("CustomWidget", &custom_widget);
3339
"""
3440

cli/src/robocompdsl/templates/templatePython/plugins/dsr/functions/generated/genericworker_py.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66

77
DSR_INIT_STR = """\
8-
agent_name = configData.get("Agent", {}).get("name")
9-
agent_id = configData.get("Agent", {}).get("id")
8+
self.agent_name = configData.get("Agent", {}).get("name")
9+
self.agent_id = configData.get("Agent", {}).get("id")
1010
1111
# Initialize DSR
1212
sur_names = ConfigLoader.get_sur_names(configData, "Agent")
@@ -17,7 +17,7 @@
1717
domain = configData.get("Agent", {}).get("domain", 0)
1818
config_file = configData.get("Agent", {}).get("configFile")
1919
20-
new_graph = DSRGraph(0, agent_name, agent_id, config_file, True, domain)
20+
new_graph = DSRGraph(0, self.agent_name, self.agent_id, config_file, True, domain)
2121
self.g = new_graph
2222
2323
print("Graph loaded")
@@ -31,7 +31,7 @@
3131
config_file = prefix_data.get("configFile")
3232
domain = prefix_data.get("domain", 0)
3333
34-
self.graphs[name] = DSRGraph(0, agent_name, agent_id, config_file, True, domain)
34+
self.graphs[name] = DSRGraph(0, self.agent_name, self.agent_id, config_file, True, domain)
3535
print(f"Graph {name} loaded")
3636
3737
self.g = self.graphs[sur_names[0]]

cli/src/robocompdsl/templates/templatePython/plugins/gui/functions/etc/__init__.py

Whitespace-only changes.

cli/src/robocompdsl/templates/templatePython/plugins/gui/functions/etc/config.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)