Initialize Component from Component
Problem
Currently, a component can't use information from another component for initialization. This is caused by the fact that all components need to connect()
(i.e. push initial outputs) in the same initialization phase.
Possible solution
Iterative connect: The connect()
method should be able to fail (return use false
ComponentStatus
) in the case that some required input can't be pulled. The algorithm could look like this:
while True:
any_connect = False
any_unconnected = False
for mod in modules:
if mod.state != CONNECTED:
if mod.connect():
any_connect = True
else:
any_unconnected = True
if not any_connect:
raise FinamConnectError("Circular dependency in component initialization. Unconnected components... [list here]")
if not any_unconnected:
break // Done!
Edited by Martin Lange