tscircuit/autorouting-dataset-01

This code manages the hardware and electronic components for circuit design and PCB layout, defining components like resistors, capacitors, transistors, connectors, and footprints, and providing tools for component placement, PCB topology, and electrical connections.

Version
1.0.102
License
unset
Stars
4

scripts/random-circuits/get-pin-counts.ts

import { filterPinNamesForComponent } from "scripts/random-circuits/filterPinNamesForComponent"
import { getFootprinterPinNames } from "scripts/random-circuits/getFootprinterPinNames"
import { normalizeFootprintForFootprinter } from "scripts/random-circuits/normalizeFootprintForFootprinter"
import type { ComponentType } from "types/ComponentType"
import type { PinInfo } from "types/PinInfo"

/**
 * Returns the pin count and pin names based on component type and footprint.
 */
export const getPinInfo = (
  componentType: ComponentType,
  footprint: string,
): PinInfo => {
  const normalized = normalizeFootprintForFootprinter(footprint)
  const pinNames = filterPinNamesForComponent(
    componentType,
    getFootprinterPinNames(normalized),
  )
  return {
    pinCount: pinNames.length,
    pinNames,
  }
}