forked from jappel/leistungsbilanz-ts
Configure circuit protection
This commit is contained in:
parent
18ca5eb3d4
commit
8898117ed4
18 changed files with 642 additions and 14 deletions
36
src/frontend/utils/circuit-protection-editing.ts
Normal file
36
src/frontend/utils/circuit-protection-editing.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import type {
|
||||
CircuitProtectionSnapshot,
|
||||
} from "../../domain/models/circuit-protection-project-command.model";
|
||||
import { createDefaultCircuitProtection } from "../../domain/services/protection-device-defaults";
|
||||
import type { CircuitGroupCategory } from "../../shared/constants/circuit-group";
|
||||
import type {
|
||||
CircuitTreeProtectionDeviceDto,
|
||||
} from "../types";
|
||||
|
||||
export function toCircuitProtectionSnapshot(
|
||||
circuitId: string,
|
||||
protection: CircuitTreeProtectionDeviceDto
|
||||
): CircuitProtectionSnapshot {
|
||||
return {
|
||||
circuitId,
|
||||
type: protection.type,
|
||||
ratedCurrentA: protection.ratedCurrentA,
|
||||
fuseUtilizationCategory:
|
||||
protection.fuseUtilizationCategory ?? null,
|
||||
tripCharacteristic: protection.tripCharacteristic ?? null,
|
||||
rcdType: protection.rcdType ?? null,
|
||||
ratedResidualCurrentMa:
|
||||
protection.ratedResidualCurrentMa ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export function getCircuitProtectionEditorInitialValue(
|
||||
category: CircuitGroupCategory | undefined,
|
||||
protection: CircuitTreeProtectionDeviceDto | undefined
|
||||
): CircuitTreeProtectionDeviceDto {
|
||||
if (protection) {
|
||||
return protection;
|
||||
}
|
||||
const fallback = createDefaultCircuitProtection(category ?? "lighting");
|
||||
return { ...fallback };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue