Commit 77286a54 authored by Flavio TARSETTI's avatar Flavio TARSETTI

[widgets][toolchaineditor] fix loop Cancel button

parent 4bb7fc38
......@@ -1492,93 +1492,96 @@ class Toolchain(QWidget):
self.autonomous_loop_evaluator_list,
)
sequential_loop_processor = loops["sequential_loop_processor"]
autonomous_loop_processor = loops["autonomous_loop_processor"]
sequential_loop_evaluator = loops["sequential_loop_evaluator"]
autonomous_loop_evaluator = loops["autonomous_loop_evaluator"]
if sequential_loop_processor is None and autonomous_loop_processor is None:
raise ValueError("No processor selected!")
elif sequential_loop_evaluator is None and autonomous_loop_evaluator is None:
raise ValueError("No evaluator selected!")
elif (
sequential_loop_processor is not None
and autonomous_loop_processor is not None
):
raise ValueError("Two processors selected!")
elif (
sequential_loop_evaluator is not None
and autonomous_loop_evaluator is not None
):
raise ValueError("Two evaluators selected!")
else:
processor_asset = None
evaluator_asset = None
processor_inputs = []
processor_outputs = []
evaluator_inputs = []
evaluator_outputs = []
if sequential_loop_processor is not None:
processor_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, sequential_loop_processor
)
else:
processor_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, autonomous_loop_processor
)
if sequential_loop_evaluator is not None:
evaluator_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, sequential_loop_evaluator
)
if ok:
sequential_loop_processor = loops["sequential_loop_processor"]
autonomous_loop_processor = loops["autonomous_loop_processor"]
sequential_loop_evaluator = loops["sequential_loop_evaluator"]
autonomous_loop_evaluator = loops["autonomous_loop_evaluator"]
if sequential_loop_processor is None and autonomous_loop_processor is None:
raise ValueError("No processor selected!")
elif (
sequential_loop_evaluator is None and autonomous_loop_evaluator is None
):
raise ValueError("No evaluator selected!")
elif (
sequential_loop_processor is not None
and autonomous_loop_processor is not None
):
raise ValueError("Two processors selected!")
elif (
sequential_loop_evaluator is not None
and autonomous_loop_evaluator is not None
):
raise ValueError("Two evaluators selected!")
else:
evaluator_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, autonomous_loop_evaluator
)
processor_asset = None
evaluator_asset = None
processor_declaration = processor_asset.declaration
evaluator_declaration = evaluator_asset.declaration
processor_inputs = []
processor_outputs = []
evaluator_inputs = []
evaluator_outputs = []
block_item = {}
for group in processor_declaration["groups"]:
if "inputs" in group:
for key in group["inputs"].keys():
processor_inputs.append(key)
block_item["processor_inputs"] = processor_inputs
if "outputs" in group:
for key in group["outputs"].keys():
processor_outputs.append(key)
block_item["processor_outputs"] = processor_outputs
if sequential_loop_processor is not None:
processor_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, sequential_loop_processor
)
else:
processor_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, autonomous_loop_processor
)
for group in evaluator_declaration["groups"]:
if "inputs" in group:
for key in group["inputs"].keys():
evaluator_inputs.append(key)
block_item["evaluator_inputs"] = evaluator_inputs
if "outputs" in group:
for key in group["outputs"].keys():
evaluator_outputs.append(key)
block_item["evaluator_outputs"] = evaluator_outputs
if sequential_loop_evaluator is not None:
evaluator_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, sequential_loop_evaluator
)
else:
evaluator_asset = Asset(
self.prefix_path, AssetType.ALGORITHM, autonomous_loop_evaluator
)
init_name_count = 0
init_name = self.tr("CHANGE_ME")
for block in self.blocks:
if block.name.find(init_name) > -1:
init_name_count += 1
new_block_name = init_name + "_" + str(init_name_count)
block_item["name"] = new_block_name
processor_declaration = processor_asset.declaration
evaluator_declaration = evaluator_asset.declaration
block_item = {}
for group in processor_declaration["groups"]:
if "inputs" in group:
for key in group["inputs"].keys():
processor_inputs.append(key)
block_item["processor_inputs"] = processor_inputs
if "outputs" in group:
for key in group["outputs"].keys():
processor_outputs.append(key)
block_item["processor_outputs"] = processor_outputs
for group in evaluator_declaration["groups"]:
if "inputs" in group:
for key in group["inputs"].keys():
evaluator_inputs.append(key)
block_item["evaluator_inputs"] = evaluator_inputs
if "outputs" in group:
for key in group["outputs"].keys():
evaluator_outputs.append(key)
block_item["evaluator_outputs"] = evaluator_outputs
init_name_count = 0
init_name = self.tr("CHANGE_ME")
for block in self.blocks:
if block.name.find(init_name) > -1:
init_name_count += 1
new_block_name = init_name + "_" + str(init_name_count)
block_item["name"] = new_block_name
block = Block(
BlockType.LOOPS.name, self.block_config, self.connection_config
)
block.load(self, block_item)
block = Block(
BlockType.LOOPS.name, self.block_config, self.connection_config
)
block.load(self, block_item)
block.dataChanged.connect(self.dataChanged)
block.dataChanged.emit()
self.blocks.append(block)
self.scene.addItem(block)
block.dataChanged.connect(self.dataChanged)
block.dataChanged.emit()
self.blocks.append(block)
self.scene.addItem(block)
def update_channel_path(self, block, old_channel, new_channel):
# check if current block is synchronized on old_channel
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment