32 lines
1,010 B
TypeScript
32 lines
1,010 B
TypeScript
import type { CircuitGroupCategory } from "../../shared/constants/circuit-group.js";
|
|
|
|
export interface ProjectDevicePlacementSource {
|
|
category: CircuitGroupCategory;
|
|
}
|
|
|
|
export interface ProjectDevicePlacementSection {
|
|
key: string;
|
|
}
|
|
|
|
export type DefaultCircuitSectionKey = "lighting" | "single_phase" | "three_phase";
|
|
|
|
// Lighting classification takes precedence over the electrical phase because
|
|
// lighting devices use their dedicated numbering section by default.
|
|
export function inferProjectDeviceSectionKey(
|
|
device: ProjectDevicePlacementSource
|
|
): DefaultCircuitSectionKey {
|
|
return device.category;
|
|
}
|
|
|
|
export function resolveProjectDevicePhaseType(
|
|
category: CircuitGroupCategory
|
|
): "single_phase" | "three_phase" {
|
|
return category === "three_phase" ? "three_phase" : "single_phase";
|
|
}
|
|
|
|
export function isProjectDevicePlacementValid(
|
|
device: ProjectDevicePlacementSource,
|
|
section: ProjectDevicePlacementSection
|
|
): boolean {
|
|
return section.key === inferProjectDeviceSectionKey(device);
|
|
}
|