Skip to content
Edit this page

ictdesigntools.cabling.cables

Cables for the fill and pulling calculations: types, lines (a type and a count) and the spaces they are checked in.

Values are metric: outside diameters in mm, weights in kg per metre of one cable, pulling limits in newtons. The typical cable types are published in inches, lb/ft and lbf, and are converted exactly when this module loads.

FillError

Bases: ValueError

Raised when a pathway, its size or its cables are not valid.

CableLine dataclass

CableLine(
    label: str,
    od_mm: float,
    count: int,
    weight_kg_per_m: float | None = None,
    max_tension_n: float | None = None,
    cable_type: str | None = None,
    min_bend_radius_mm: float | None = None,
    max_swbp_n_per_m: float | None = None,
)

count cables of one kind. Make one with CableLine.of (a typical type) or CableLine.custom; label is free text for reports.

of classmethod

of(
    cable_type: str,
    count: int,
    *,
    weight_kg_per_m: float | None = None,
    max_tension_n: float | None = None,
    label: str | None = None,
    min_bend_radius_mm: float | None = None,
    max_swbp_n_per_m: float | None = None,
) -> CableLine

Cables of a typical type; a value given replaces the typical one.

Source code in src/ictdesigntools/cabling/cables.py
@classmethod
def of(cls, cable_type: str, count: int, *, weight_kg_per_m: float | None = None,
       max_tension_n: float | None = None, label: str | None = None,
       min_bend_radius_mm: float | None = None,
       max_swbp_n_per_m: float | None = None) -> CableLine:  # fmt: skip
    """Cables of a typical type; a value given replaces the typical one."""
    cable = CABLE_TYPES.get(cable_type)
    if cable is None:
        raise FillError(f"“{cable_type}” is not a known cable type.")
    return cls(
        cable.label if label is None else label,
        cable.od_mm,
        count,
        cable.weight_kg_per_m if weight_kg_per_m is None else weight_kg_per_m,
        cable.max_tension_n if max_tension_n is None else max_tension_n,
        cable_type,
        cable.min_bend_radius_mm if min_bend_radius_mm is None else min_bend_radius_mm,
        cable.max_swbp_n_per_m if max_swbp_n_per_m is None else max_swbp_n_per_m,
    )

Compartment dataclass

Compartment(
    label: str,
    lines: list[CableLine],
    container_area_mm2: float,
    limit_pct: float,
    target_pct: float | None = None,
    kind: str = "",
    inner_mm: float = 0.0,
    outer_mm: float = 0.0,
    remaining_width: bool = False,
)

One separately checked space: a tray lane or a subduct.

merge_lines

merge_lines(
    groups: Sequence[Sequence[CableLine]],
) -> tuple[list[CableLine], list[list[int]]]

Combine the cable lines of several groups into one list (for colours and the legend).

Lines that differ only in their count are merged and their counts added. Returns the merged lines and, for each group, the merged index of each of its lines.

Source code in src/ictdesigntools/cabling/cables.py
def merge_lines(groups: Sequence[Sequence[CableLine]]) -> tuple[list[CableLine], list[list[int]]]:
    """Combine the cable lines of several groups into one list (for colours and the legend).

    Lines that differ only in their count are merged and their counts added. Returns the merged
    lines and, for each group, the merged index of each of its lines.
    """
    merged: list[CableLine] = []
    positions: dict[CableLine, int] = {}
    maps: list[list[int]] = []
    for lines in groups:
        mapping = []
        for line in lines:
            key = replace(line, count=1)
            if key in positions:
                i = positions[key]
                merged[i] = replace(merged[i], count=merged[i].count + line.count)
            else:
                i = positions[key] = len(merged)
                merged.append(line)
            mapping.append(i)
        maps.append(mapping)
    return merged, maps