diff --git a/process_bigraph/tests.py b/process_bigraph/tests.py index 3463184..90a2414 100644 --- a/process_bigraph/tests.py +++ b/process_bigraph/tests.py @@ -27,6 +27,12 @@ def schema(self): 'level': 'float'}} + def initial_state(self): + return { + 'inputs': { + 'level': 11.0}} + + def update(self, state, interval): return { 'level': state['level'] * self.config['rate']} diff --git a/process_bigraph/type_system.py b/process_bigraph/type_system.py index 25900ed..b5717ee 100644 --- a/process_bigraph/type_system.py +++ b/process_bigraph/type_system.py @@ -4,7 +4,7 @@ ============= """ -from bigraph_schema import Edge, TypeSystem, get_path, establish_path, set_path +from bigraph_schema import Edge, TypeSystem, get_path, establish_path, set_path, deep_merge from process_bigraph.registry import protocol_registry @@ -290,12 +290,24 @@ def initialize_edge_state(self, schema, path, edge): output_ports = get_path(schema, path + ('_outputs',)) ports = {'inputs': input_ports, 'outputs': output_ports} - projected_state = self.project_edge( + input_state = self.project_edge( ports, edge, path[:-1], - initial_state) - return projected_state + initial_state, + ports_key='input') + + output_state = self.project_edge( + ports, + edge, + path[:-1], + initial_state, + ports_key='output') + + state = deep_merge(input_state, output_state) + + return state + def dehydrate(self, schema): return {}