Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
614 changes: 556 additions & 58 deletions examples/demo02.gv

Large diffs are not rendered by default.

713 changes: 359 additions & 354 deletions examples/demo02.html

Large diffs are not rendered by default.

Binary file modified examples/demo02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
713 changes: 359 additions & 354 deletions examples/demo02.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/demo02.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ connectors:
X1:
<<: *molex_f # copying items from the template
pinlabels: [GND, +5V, SCL, SDA, MISO, MOSI, SCK, N/C]
strip:
sleeve: 10 mm
insulation: 2 mm
X2:
<<: *molex_f
<<: *con_i2c # it is possible to copy from more than one template
strip:
sleeve: 5 mm
X3:
<<: *molex_f
<<: *con_i2c
Expand Down
44 changes: 44 additions & 0 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ class Tweak:
append: Union[str, List[str], None] = None


def parse_length(l: str):
length: float = 0
length_unit: str = 'm'
try:
length, length_unit = l.split(' ')
length = float(length)
except Exception:
raise Exception(f'length={l} - Length must be a number, or number and unit separated by a space')
return {'length': length, 'length_unit': length_unit}


@dataclass
class Image:
# Attributes of the image object <img>:
Expand Down Expand Up @@ -136,6 +147,32 @@ def description(self) -> str:
return t


@dataclass
class StripSleeve:
name: Designator
length: float = 0
length_unit: Optional[str] = None


@dataclass
class StripInsulation:
name: Designator
length: float = 0
length_unit: Optional[str] = None


@dataclass
class Strip:
sleeve: Optional[StripSleeve] = None
insulation: Optional[StripInsulation] = None

def __post_init__(self) -> None:
if self.sleeve:
self.sleeve = StripSleeve('TODO', **parse_length(self.sleeve))
if self.insulation:
self.insulation = StripInsulation('TODO', **parse_length(self.insulation))


@dataclass
class Connector:
name: Designator
Expand All @@ -151,6 +188,8 @@ class Connector:
type: Optional[MultilineHypertext] = None
subtype: Optional[MultilineHypertext] = None
pincount: Optional[int] = None
# additional_parameters: Optional[Dict] = None
strip: Optional[Strip] = None
image: Optional[Image] = None
notes: Optional[MultilineHypertext] = None
pins: List[Pin] = field(default_factory=list)
Expand Down Expand Up @@ -220,6 +259,11 @@ def __post_init__(self) -> None:
if isinstance(item, dict):
self.additional_components[i] = AdditionalComponent(**item)

if self.strip:
self.strip = Strip(sleeve=self.strip.get('sleeve'), insulation=self.strip.get('insulation'))
else:
self.strip = Strip()

def activate_pin(self, pin: Pin, side: Side) -> None:
self.visible_pins[pin] = True
if side == Side.LEFT:
Expand Down
5 changes: 5 additions & 0 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
html_caption,
html_colorbar,
html_image,
html_length,
html_line_breaks,
nested_html_table,
remove_links,
Expand Down Expand Up @@ -207,6 +208,10 @@ def create_graph(self) -> Graph:
[html_caption(connector.image)]]
# fmt: on

if connector.strip.sleeve or connector.strip.insulation:
rows.append([
f'Strip Sleeve: {html_length(connector.strip.sleeve)} Insulation: {html_length(connector.strip.insulation)}'
])
rows.extend(get_additional_component_table(self, connector))
rows.append([html_line_breaks(connector.notes)])
html.extend(nested_html_table(rows, html_bgcolor_attr(connector.bgcolor)))
Expand Down
7 changes: 7 additions & 0 deletions src/wireviz/wv_gv_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,10 @@ def html_size_attr(image):

def html_line_breaks(inp):
return remove_links(inp).replace("\n", "<br />") if isinstance(inp, str) else inp


def html_length(o) -> str:
if o: # Can be None
return f'{o.length} {o.length_unit}' if o.length > 0 else None
else:
return '-'