# Cable Length Calculation

## Goal

Estimate practical cable lengths from the physical arrangement of devices in a rack so users can preselect realistic patch and power cable variants.

The result should support planning, not exact installation certification.

## Use cases

- patch cable length between patch panel and switch
- DAC or fiber estimate between devices in the same rack
- power cable estimate from PDU to active device
- BOM generation for preconfigured cable sets

## V1 approach

Cable length should be estimated from:

- rack unit position of both components
- side of connection: front or rear
- optional port offsets
- route style
- slack factor

## Suggested routing model

For V1, use a rule-based path estimate instead of full geometric routing.

### Inputs

- source component `U` position
- target component `U` position
- source and target side
- rack depth
- routing preference
- slack percentage or fixed reserve

### Routing preferences

- `front_vertical`
- `rear_vertical`
- `front_to_rear`
- `shortest_practical`

## Example calculation logic

Estimate length as:

1. vertical distance between source and target mounting positions
2. plus horizontal or side transition allowance
3. plus front/rear traversal allowance
4. plus slack reserve

Illustrative formula:

```text
estimated_length =
  vertical_distance_mm
  + side_transition_mm
  + front_rear_allowance_mm
  + service_loop_mm
```

Then round up to the next marketable cable length, for example:

- `0.25 m`
- `0.5 m`
- `1.0 m`
- `1.5 m`
- `2.0 m`
- `3.0 m`

## Accuracy strategy

The tool should display:

- raw estimated length
- recommended order length
- confidence note such as `estimate only`

## Data requirements

Better cable estimation becomes possible if components expose ports with offsets.

Minimum V1:

- component `U` position only

Better V1:

- per-port offsets in the component metadata

## BOM integration

Cable entries can be generated as:

- one line per connection
- or aggregated by cable type and recommended order length

Example:

- `12 x RJ45 patch cable Cat6A, 0.5 m`
- `4 x C13 to C14 power cable, 1.5 m`

## Future improvements

- front and rear cable manager objects
- reserved routing channels
- left/right side path selection
- bend radius constraints
- color-coded cable groups
- cross-rack cable planning
