From be79d84a91f5cfdb01767d9b0f4e02a622708313 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson <rasmus@rasmus.local> Date: Fri, 24 Apr 2020 21:25:02 +0200 Subject: [PATCH] Moved functionality from split to new func: replace_self(). Split reverted to original, but with exclusion of Input and Output. --- b_asic/signal_flow_graph.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py index 08fe7366..50045763 100644 --- a/b_asic/signal_flow_graph.py +++ b/b_asic/signal_flow_graph.py @@ -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 -- GitLab