Added support for `bus_alias` [KiCad 6]
- Not documented in the file format Closes #133
This commit is contained in:
parent
e2147f40ee
commit
dadcd8a543
|
|
@ -1063,6 +1063,20 @@ class Junction(object):
|
|||
return _symbol('junction', data)
|
||||
|
||||
|
||||
class BusAlias(object):
|
||||
@staticmethod
|
||||
def parse(items):
|
||||
_check_len_total(items, 3, 'bus_alias')
|
||||
alias = BusAlias()
|
||||
alias.name = _check_str(items, 1, 'bus_alias')
|
||||
elems = _check_symbol_value(items, 2, 'bus_alias', 'members')
|
||||
alias.members = elems[1:]
|
||||
return alias
|
||||
|
||||
def write(self):
|
||||
return _symbol('bus_alias', [self.name, _symbol('members', self.members)])
|
||||
|
||||
|
||||
class NoConnect(object):
|
||||
@staticmethod
|
||||
def parse(items):
|
||||
|
|
@ -1376,8 +1390,9 @@ def _symbol(name, content):
|
|||
return [Symbol(name)] + content
|
||||
|
||||
|
||||
def _add_items(items, sch, sep=False, cross=False):
|
||||
def _add_items(items, sch, sep=False, cross=False, pre_sep=True):
|
||||
if len(items):
|
||||
if pre_sep:
|
||||
sch.append(Sep())
|
||||
for i in items:
|
||||
if cross:
|
||||
|
|
@ -1501,8 +1516,10 @@ class SchematicV6(Schematic):
|
|||
if self.title_ori is not None:
|
||||
sch.extend(self.write_title_block())
|
||||
sch.extend(self.write_lib_symbols(cross))
|
||||
# Bus aliases
|
||||
_add_items(self.bus_alias, sch)
|
||||
# Connections (aka Junctions)
|
||||
_add_items(self.junctions, sch)
|
||||
_add_items(self.junctions, sch, pre_sep=(len(self.bus_alias) == 0))
|
||||
# No connect
|
||||
_add_items(self.no_conn, sch)
|
||||
# Bus entry
|
||||
|
|
@ -1595,6 +1612,7 @@ class SchematicV6(Schematic):
|
|||
self.sheets = []
|
||||
self.sheet_instances = []
|
||||
self.symbol_instances = []
|
||||
self.bus_alias = []
|
||||
self.libs = {} # Just for compatibility with v5 class
|
||||
# TODO: this assumes we are expanding the schematic to allow variant.
|
||||
# This is needed to overcome KiCad 6 limitations (symbol instances only differ in Reference)
|
||||
|
|
@ -1635,6 +1653,8 @@ class SchematicV6(Schematic):
|
|||
self._get_title_block(e[1:])
|
||||
elif e_type == 'lib_symbols':
|
||||
self._get_lib_symbols(e)
|
||||
elif e_type == 'bus_alias':
|
||||
self.bus_alias.append(BusAlias.parse(e))
|
||||
elif e_type == 'junction':
|
||||
self.junctions.append(Junction.parse(e))
|
||||
elif e_type == 'no_connect':
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@
|
|||
)
|
||||
)
|
||||
|
||||
(bus_alias "AELEM" (members "A1" "A0"))
|
||||
(junction (at 63.5 25.4) (diameter 0) (color 0 0 0 0)
|
||||
(uuid 01eb9bdd-a337-4673-a2b0-d209aebe8932)
|
||||
)
|
||||
|
|
@ -316,6 +317,14 @@
|
|||
|
||||
(no_connect (at 27.94 66.04) (uuid 2d6718e7-f18d-444d-9792-ddf1a113460c))
|
||||
|
||||
(bus_entry (at 177.8 101.6) (size 2.54 2.54)
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid 2fb9964c-4cd4-4e81-b5e8-f78759d3adb5)
|
||||
)
|
||||
(bus_entry (at 177.8 97.79) (size 2.54 2.54)
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid 2fb9964c-4cd4-4e81-b5e8-f78759d3adb6)
|
||||
)
|
||||
(bus_entry (at 25.4 25.4) (size -2.54 -2.54)
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid 46cfd089-6873-4d8b-89af-02ff30e49472)
|
||||
|
|
@ -371,6 +380,12 @@
|
|||
(stroke (width 0.508) (type default) (color 0 0 0 0))
|
||||
(uuid 1a2f72d1-0b36-4610-afc4-4ad1660d5d3b)
|
||||
)
|
||||
|
||||
(bus (pts (xy 177.8 88.9) (xy 177.8 97.79))
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid 272c2a78-b5f5-4b61-aed3-ec69e0e92729)
|
||||
)
|
||||
|
||||
(polyline (pts (xy 76.2 127) (xy 88.9 127))
|
||||
(stroke (width 0) (type solid) (color 0 0 0 0))
|
||||
(uuid 2732632c-4768-42b6-bf7f-14643424019e)
|
||||
|
|
@ -445,6 +460,11 @@
|
|||
(stroke (width 0) (type solid) (color 0 0 0 0))
|
||||
(uuid 854dd5d4-5fd2-4730-bd49-a9cd8299a065)
|
||||
)
|
||||
|
||||
(wire (pts (xy 180.34 104.14) (xy 190.5 104.14))
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid 87f44303-a6e8-48e5-bb6d-f89abb09a999)
|
||||
)
|
||||
(polyline (pts (xy 76.2 139.7) (xy 76.2 127))
|
||||
(stroke (width 0) (type solid) (color 0 0 0 0))
|
||||
(uuid 8d55e186-3e11-40e8-a65e-b36a8a00069e)
|
||||
|
|
@ -463,11 +483,19 @@
|
|||
(uuid a501555e-bbc7-4b58-ad89-28a0cd3dd6d0)
|
||||
)
|
||||
|
||||
(bus (pts (xy 177.8 97.79) (xy 177.8 101.6))
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid a819bf9a-0c8b-443a-b488-e5f1395d77ad)
|
||||
)
|
||||
(bus (pts (xy 63.5 25.4) (xy 66.04 22.86))
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid ac264c30-3e9a-4be2-b97a-9949b68bd497)
|
||||
)
|
||||
|
||||
(wire (pts (xy 180.34 100.33) (xy 190.5 100.33))
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid af7ed34f-31b5-4744-97e9-29e5f4d85343)
|
||||
)
|
||||
(wire (pts (xy 22.86 66.04) (xy 27.94 66.04))
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid b603d26a-e034-42fb-8327-b60c5bf9cdd2)
|
||||
|
|
@ -498,6 +526,11 @@
|
|||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid c801d42e-dd94-493e-bd2f-6c3ddad43f55)
|
||||
)
|
||||
(bus (pts (xy 165.1 88.9) (xy 177.8 88.9))
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(uuid ceb12634-32ca-4cbf-9ff5-5e8b53ab18ad)
|
||||
)
|
||||
|
||||
(polyline (pts (xy 63.754 157.48) (xy 51.054 157.48))
|
||||
(stroke (width 0) (type solid) (color 255 0 255 1))
|
||||
(uuid cef6f603-8a0b-4dd0-af99-ebfbef7d1b4b)
|
||||
|
|
@ -1578,10 +1611,22 @@
|
|||
(uuid 786b6072-5772-4bc1-8eeb-6c4e19f2a91b)
|
||||
)
|
||||
|
||||
(label "B.A0" (at 181.61 104.14 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left bottom))
|
||||
(uuid 56bbedad-6259-4443-b321-0ffa1f89c336)
|
||||
)
|
||||
(label "B.A1" (at 181.61 100.33 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left bottom))
|
||||
(uuid 82941cb3-7e8d-4836-8b43-647cd4390ab6)
|
||||
)
|
||||
(label "L1" (at 22.86 66.04 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left bottom))
|
||||
(uuid f144a97d-c3f0-423f-b0a9-3f7dbc42478b)
|
||||
)
|
||||
(label "B{AELEM}" (at 165.1 88.9 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left bottom))
|
||||
(uuid fc80fa5b-8c07-4dda-8002-331dcafd556b)
|
||||
)
|
||||
|
||||
(global_label "L2B" (shape output) (at 39.37 55.88 90) (fields_autoplaced)
|
||||
(effects (font (size 1.27 1.27) italic) (justify left))
|
||||
|
|
|
|||
Loading…
Reference in New Issue