@typecad/typecad
Version:
🤖programmatically 💥create 🛰️hardware
124 lines (123 loc) • 3.5 kB
TypeScript
import { Pin } from "./pin";
import { IVia } from "./pcb";
export interface IComponent {
symbol?: string;
reference?: string | undefined;
value?: string;
footprint?: string;
prefix?: string;
datasheet?: string;
description?: string;
voltage?: string;
wattage?: string;
uuid?: string;
mpn?: string;
dnp?: boolean;
pcb?: {
x: number;
y: number;
rotation?: number;
side?: 'front' | 'back';
};
pins?: Pin[];
via?: boolean;
simulation?: {
include: boolean;
model?: string;
};
sch?: {
x: number;
y: number;
rotation: number;
};
viaData?: IVia;
}
/**
* Represents a component in an electronic circuit.
* @property reference - Reference designator (e.g., R1).
* @property value - Component value (e.g., 1 kOhm).
* @property footprint - Component footprint (e.g., Resistor_SMD:R_0603_1608Metric).
* @property datasheet - Link to component datasheet.
* @property description - Description of the component.
* @property mpn - Manufacturer Part Number.
* @property pcb - PCB placement details (x, y, rotation).
* @property dnp - True if Do Not Place.
* @property uuid - Unique identifier.
* @property pins - Array of component pins.
* @property via - True if the component is a via.
* @property simulation - Simulation details.
*/
export declare class Component {
#private;
reference: string;
value: string;
footprint: string;
datasheet: string;
description: string;
voltage: string;
wattage: string;
mpn: string;
pcb: {
x: number;
y: number;
rotation?: number;
side?: 'front' | 'back';
};
dnp: boolean;
pins: Pin[];
via: boolean;
viaData?: IVia;
simulation: {
include: boolean;
model: string;
};
symbol?: string;
sch: {
x: number;
y: number;
rotation?: number;
};
groups: string[];
private _uuid;
private _gettingUuid;
/**
* Creates an instance of Component.
* @param {IComponent} [options={}] - The component options.
*/
constructor({ reference, value, footprint, prefix, datasheet, description, voltage, wattage, mpn, via, uuid, simulation, symbol, sch, pcb, viaData }?: IComponent);
/**
* Get the UUID for this component. If not explicitly set, it will be generated
* consistently based on component properties.
*/
get uuid(): string;
/**
* Set the UUID for this component
*/
set uuid(value: string);
/**
* Returns a {@link Pin} object from the component.
* @param number - The pin number or identifier.
* @returns The pin object.
*/
pin(number: number | string): Pin;
/**
* Check if this component belongs to a specific group.
* @param groupName - The name of the group to check.
* @returns True if the component is in the specified group.
*/
isInGroup(groupName: string): boolean;
/**
* Get all groups this component belongs to.
* @returns Array of group names this component is a member of.
*/
getGroups(): string[];
/**
* Retrieves the footprint library for the component.
* Used internally to manage footprint files.
*
* @param {string} footprint - The footprint identifier
* @returns {string} - The serialized footprint data
* @ignore
*/
footprint_lib(footprint: string): string;
}