Skip to content

Commit

Permalink
NetTie again
Browse files Browse the repository at this point in the history
  • Loading branch information
mawildoer committed Sep 5, 2024
1 parent 755aca5 commit 9b27698
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions src/faebryk/library/NetTie.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,45 @@
import faebryk.library._F as F
from faebryk.core.module import Module
from faebryk.core.moduleinterface import ModuleInterface
from faebryk.library import _F as F
from faebryk.library.Constant import Constant
from faebryk.library.Electrical import Electrical
from faebryk.library.KicadFootprint import KicadFootprint
from faebryk.libs.library import L
from faebryk.libs.picker.picker import has_part_picked_remove
from faebryk.libs.util import once

logger = logging.getLogger(__name__)


class Size(float, Enum):
_2_0MM = 2.0
_0_5MM = 0.5
class NetTie[T: ModuleInterface](Module):
class Size(float, Enum):
_2_0MM = 2.0
_0_5MM = 0.5

unnamed: list[T]

@once
def net_tie(
width: Size | Constant[float],
interface_type: type[ModuleInterface] = Electrical,
):
class NetTie(Module):
unnamed = L.list_field(2, interface_type)
def __init__(
self,
width: Size,
interface_type: type[T] = Electrical,
) -> None:
super().__init__()

def __preinit__(
self,
) -> None:
self.add_trait(F.can_bridge_defined(*self.unnamed))
# dynamically construct the interfaces
self.unnamed = self.add([interface_type(), interface_type()], "unnamed")

width_mm = Size(width).value
# add dem trairs
self.add(F.can_bridge_defined(*self.unnamed))

self.add_trait(F.can_attach_to_footprint_symmetrically())
self.add_trait(F.has_designator_prefix_defined("H"))
# TODO: "removed" isn't really true, but seems to work
self.add_trait(has_part_picked_remove())
width_mm = NetTie.Size(width).value

# TODO: generate the kicad footprint instead of loading it
self.add_trait(
F.has_footprint_defined(
KicadFootprint(
f"NetTie:NetTie-2_SMD_Pad{width_mm:.1f}mm", pin_names=["1", "2"]
)
self.add(F.can_attach_to_footprint_symmetrically())
self.add(F.has_designator_prefix_defined("H"))
# TODO: "removed" isn't really true, but seems to work
self.add(has_part_picked_remove())

# TODO: generate the kicad footprint instead of loading it
self.add(
F.has_footprint_defined(
KicadFootprint(
f"NetTie:NetTie-2_SMD_Pad{width_mm:.1f}mm", pin_names=["1", "2"]
)
)

return NetTie
)

0 comments on commit 9b27698

Please sign in to comment.