Remove debugging print() lines
This commit is contained in:
parent
29b38364b3
commit
19d44c32f9
@ -374,7 +374,6 @@ class Harness:
|
|||||||
code_from = f'{mate.from_name}{from_port}:e'
|
code_from = f'{mate.from_name}{from_port}:e'
|
||||||
to_port = f':p{mate.to_port}l' if isinstance(mate, MatePin) and self.connectors[mate.to_name].style != 'simple' else ''
|
to_port = f':p{mate.to_port}l' if isinstance(mate, MatePin) and self.connectors[mate.to_name].style != 'simple' else ''
|
||||||
code_to = f'{mate.to_name}{to_port}:w'
|
code_to = f'{mate.to_name}{to_port}:w'
|
||||||
print(mate, '---', code_from, '---', code_to)
|
|
||||||
dot.edge(code_from, code_to)
|
dot.edge(code_from, code_to)
|
||||||
|
|
||||||
return dot
|
return dot
|
||||||
|
|||||||
@ -73,9 +73,6 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
|
|
||||||
connection_sets = yaml_data['connections']
|
connection_sets = yaml_data['connections']
|
||||||
|
|
||||||
print('Conector templates:', list(template_connectors.keys()))
|
|
||||||
print('Cable templates: ', list(template_cables.keys()))
|
|
||||||
|
|
||||||
# go through connection sets, generate and connect components ==============
|
# go through connection sets, generate and connect components ==============
|
||||||
|
|
||||||
def resolve_designator(inp):
|
def resolve_designator(inp):
|
||||||
@ -100,8 +97,6 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
return (template, designator)
|
return (template, designator)
|
||||||
|
|
||||||
for connection_set in connection_sets:
|
for connection_set in connection_sets:
|
||||||
print('')
|
|
||||||
print('connection set @0:', connection_set)
|
|
||||||
|
|
||||||
# figure out number of parallel connections within this set
|
# figure out number of parallel connections within this set
|
||||||
connectioncount = []
|
connectioncount = []
|
||||||
@ -114,7 +109,6 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
connectioncount.append(None) # strings do not reveal connectioncount
|
connectioncount.append(None) # strings do not reveal connectioncount
|
||||||
if not any(connectioncount):
|
if not any(connectioncount):
|
||||||
raise Exception('No item in connection set revealed number of connections')
|
raise Exception('No item in connection set revealed number of connections')
|
||||||
print(f'Connection count: {connectioncount}')
|
|
||||||
|
|
||||||
# check that all entries are the same length
|
# check that all entries are the same length
|
||||||
if len(set(filter(None, connectioncount))) > 1:
|
if len(set(filter(None, connectioncount))) > 1:
|
||||||
@ -124,33 +118,23 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
|
|
||||||
# expand string entries to list entries of correct length
|
# expand string entries to list entries of correct length
|
||||||
for index, entry in enumerate(connection_set):
|
for index, entry in enumerate(connection_set):
|
||||||
print(index, entry, connectioncount)
|
|
||||||
if isinstance(entry, str):
|
if isinstance(entry, str):
|
||||||
connection_set[index] = [entry] * connectioncount
|
connection_set[index] = [entry] * connectioncount
|
||||||
|
|
||||||
print('connection set @1:', connection_set)
|
|
||||||
print('des_temp @1:', designators_and_templates)
|
|
||||||
|
|
||||||
# resolve all designators
|
# resolve all designators
|
||||||
for index, entry in enumerate(connection_set):
|
for index, entry in enumerate(connection_set):
|
||||||
# print(index, ':')
|
|
||||||
if isinstance(entry, list):
|
if isinstance(entry, list):
|
||||||
for subindex, item in enumerate(entry):
|
for subindex, item in enumerate(entry):
|
||||||
template, designator = resolve_designator(item)
|
template, designator = resolve_designator(item)
|
||||||
# print('list', index, subindex, item, template, designator)
|
|
||||||
connection_set[index][subindex] = designator
|
connection_set[index][subindex] = designator
|
||||||
elif isinstance(entry, dict):
|
elif isinstance(entry, dict):
|
||||||
key = list(entry.keys())[0]
|
key = list(entry.keys())[0]
|
||||||
template, designator = resolve_designator(key)
|
template, designator = resolve_designator(key)
|
||||||
value = entry[key]
|
value = entry[key]
|
||||||
# print('dict', key, template, designator, value)
|
|
||||||
connection_set[index] = {designator: value}
|
connection_set[index] = {designator: value}
|
||||||
else:
|
else:
|
||||||
pass # string entries have been expanded in previous step
|
pass # string entries have been expanded in previous step
|
||||||
|
|
||||||
print('connection set @2:', connection_set)
|
|
||||||
print('des_temp @2:', designators_and_templates)
|
|
||||||
|
|
||||||
# expand all pin lists
|
# expand all pin lists
|
||||||
for index, entry in enumerate(connection_set):
|
for index, entry in enumerate(connection_set):
|
||||||
if isinstance(entry, list):
|
if isinstance(entry, list):
|
||||||
@ -162,8 +146,6 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
else:
|
else:
|
||||||
pass # string entries have been expanded in previous step
|
pass # string entries have been expanded in previous step
|
||||||
|
|
||||||
print('connection set @3:', connection_set)
|
|
||||||
|
|
||||||
# TODO: check alternating cable/connector
|
# TODO: check alternating cable/connector
|
||||||
alternating_sections = ['connectors','cables']
|
alternating_sections = ['connectors','cables']
|
||||||
|
|
||||||
@ -174,39 +156,32 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
for item in entry:
|
for item in entry:
|
||||||
designator = list(item.keys())[0]
|
designator = list(item.keys())[0]
|
||||||
template = designators_and_templates[designator]
|
template = designators_and_templates[designator]
|
||||||
if designator in harness.connectors:
|
if designator in harness.connectors: # existing connector instance
|
||||||
print(' ', designator, 'is an existing connector instance')
|
pass
|
||||||
elif template in template_connectors.keys():
|
elif template in template_connectors.keys(): # generate new connector instance from template
|
||||||
print(' ', designator, 'is a new connector instance of type', template)
|
|
||||||
harness.add_connector(name = designator, **template_connectors[template])
|
harness.add_connector(name = designator, **template_connectors[template])
|
||||||
|
|
||||||
elif designator in harness.cables:
|
elif designator in harness.cables: # existing cable instance
|
||||||
print(' ', designator, 'is an existing cable instance')
|
pass
|
||||||
elif template in template_cables.keys():
|
elif template in template_cables.keys(): # generate new cable instance from template
|
||||||
print(' ', designator, 'is a new cable instance of type', template)
|
|
||||||
harness.add_cable(name = designator, **template_cables[template])
|
harness.add_cable(name = designator, **template_cables[template])
|
||||||
|
|
||||||
elif isarrow(designator):
|
elif isarrow(designator):
|
||||||
print(f' {template} is an arrow')
|
pass # arrows do not need to be generated here
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f' Template {template} not found, neither in connectors nor in cables')
|
raise Exception(f'{template} is an unknown template/designator/arrow.')
|
||||||
|
|
||||||
# transpose connection set list
|
# transpose connection set list
|
||||||
# before: one row per component, one column per connection in set
|
# before: one row per component, one column per connection in set
|
||||||
# after: one row per connection in set, one column per component
|
# after: one row per connection in set, one column per component
|
||||||
print('TRANSPOSE!!')
|
|
||||||
connection_set = list(map(list, zip(*connection_set))) # transpose list
|
connection_set = list(map(list, zip(*connection_set))) # transpose list
|
||||||
print(connection_set)
|
|
||||||
|
|
||||||
# connect components
|
# connect components
|
||||||
for index_entry, entry in enumerate(connection_set):
|
for index_entry, entry in enumerate(connection_set):
|
||||||
print(f' entry ie {index_entry}', entry)
|
|
||||||
for index_item, item in enumerate(entry):
|
for index_item, item in enumerate(entry):
|
||||||
print(f' item ii {index_item}', item)
|
|
||||||
designator = list(item.keys())[0]
|
designator = list(item.keys())[0]
|
||||||
|
|
||||||
if designator in harness.cables:
|
if designator in harness.cables:
|
||||||
print(f' - {designator} is a known cable')
|
|
||||||
if index_item == 0: # list started with a cable, no connector to join on left side
|
if index_item == 0: # list started with a cable, no connector to join on left side
|
||||||
from_name = None
|
from_name = None
|
||||||
from_pin = None
|
from_pin = None
|
||||||
@ -221,10 +196,9 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
else:
|
else:
|
||||||
to_name = list(connection_set[index_entry][index_item+1].keys())[0]
|
to_name = list(connection_set[index_entry][index_item+1].keys())[0]
|
||||||
to_pin = connection_set[index_entry][index_item+1][to_name]
|
to_pin = connection_set[index_entry][index_item+1][to_name]
|
||||||
print(' > connect ', from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
|
||||||
harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)
|
||||||
|
|
||||||
elif isarrow(designator):
|
elif isarrow(designator):
|
||||||
print(f' - {designator} is an arrow')
|
|
||||||
if index_item == 0: # list startess with an arrow
|
if index_item == 0: # list startess with an arrow
|
||||||
raise Exception('An arrow cannot be at the start of a connection set')
|
raise Exception('An arrow cannot be at the start of a connection set')
|
||||||
elif index_item == len(entry) - 1: # list ends with an arrow
|
elif index_item == len(entry) - 1: # list ends with an arrow
|
||||||
@ -237,10 +211,8 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
to_name = list(connection_set[index_entry][index_item+1].keys())[0]
|
to_name = list(connection_set[index_entry][index_item+1].keys())[0]
|
||||||
to_pin = connection_set[index_entry][index_item+1][to_name]
|
to_pin = connection_set[index_entry][index_item+1][to_name]
|
||||||
if '-' in designator: # mate pin by pin
|
if '-' in designator: # mate pin by pin
|
||||||
print(f' Mate {from_name}:{from_pin} {designator} {to_name}:{to_pin}')
|
|
||||||
harness.add_mate_pin(from_name, from_pin, to_name, to_pin, designator)
|
harness.add_mate_pin(from_name, from_pin, to_name, to_pin, designator)
|
||||||
elif '=' in designator and index_entry == 0: # mate two connectors as a whole
|
elif '=' in designator and index_entry == 0: # mate two connectors as a whole
|
||||||
print(f' Mate {from_name} {designator} {to_name} ({index_entry})')
|
|
||||||
harness.add_mate_component(from_name, to_name, designator)
|
harness.add_mate_component(from_name, to_name, designator)
|
||||||
|
|
||||||
# harness population completed ==============================================
|
# harness population completed ==============================================
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user