Skip to content
Snippets Groups Projects
Commit be79d84a authored by Rasmus Karlsson's avatar Rasmus Karlsson
Browse files

Moved functionality from split to new func: replace_self(). Split reverted to...

Moved functionality from split to new func: replace_self(). Split reverted to original, but with exclusion of Input and Output.
parent 5c0bf4ab
No related branches found
No related tags found
1 merge request!34Resolve "Operation Splitting"
Pipeline #14082 passed
......@@ -232,12 +232,25 @@ class SFG(AbstractOperation):
return value
def split(self) -> Iterable[Operation]:
""" Iterates over the SFG's Input- and OutputSignals to reconnect them to each necessary operation inside the SFG,
""" Returns every operation in the SFG except for Input and Output types. """
ops = []
for op in self.operations:
if not isinstance(op, Input) and not isinstance(op, Output):
ops.append(op)
return ops # Need any checking before returning?
def replace_self(self):
""" Iterates over the SFG's (self) Input- and OutputSignals to reconnect them to each necessary operation inside the SFG,
so that the inner operations of the SFG can function on their own, effectively replacing the SFG. """
assert len(self.inputs) == len(self.input_operations), "Number of inputs does not match the number of input_operations in SFG."
assert len(self.outputs) == len(self.output_operations), "Number of outputs does not match the number of output_operations SFG."
# Add check so it does not Split the SFG if not a component of a larger SFG
# For each input_signal, connect it to the corresponding operation
for port, input_operation in zip(self.inputs, self.input_operations):
# Disconnect the previous signal to the destination
......@@ -253,8 +266,6 @@ class SFG(AbstractOperation):
src.clear()
# Connect the signal to the new source
port.signals[0].set_source(src)
@property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment