Configure circuit protection
This commit is contained in:
parent
18ca5eb3d4
commit
8898117ed4
18 changed files with 642 additions and 14 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import type { CircuitTreeCircuitDto, CircuitTreeDeviceRowDto } from "../types.js";
|
||||
import type { CircuitUpdatePatch } from "../../domain/models/circuit-project-command.model.js";
|
||||
import type { CircuitDeviceRowUpdatePatch } from "../../domain/models/circuit-device-row-project-command.model.js";
|
||||
import { protectionDeviceTypeLabels } from "../../shared/constants/protection-device";
|
||||
|
||||
export type CellKey =
|
||||
| "equipmentIdentifier"
|
||||
|
|
@ -472,18 +473,54 @@ export function getDeviceValue(device: CircuitTreeDeviceRowDto, key: CellKey): G
|
|||
}
|
||||
|
||||
export function getCircuitValue(circuit: CircuitTreeCircuitDto, key: CellKey): GridValue {
|
||||
const protection = circuit.protectionDevice;
|
||||
const protectionCharacteristic = protection
|
||||
? [
|
||||
protection.fuseUtilizationCategory,
|
||||
protection.tripCharacteristic,
|
||||
protection.rcdType ? `Typ ${protection.rcdType}` : undefined,
|
||||
protection.ratedResidualCurrentMa !== undefined
|
||||
? `${protection.ratedResidualCurrentMa} mA`
|
||||
: undefined,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")
|
||||
: undefined;
|
||||
switch (key) {
|
||||
case "equipmentIdentifier": return circuit.equipmentIdentifier;
|
||||
case "displayName": return circuit.displayName;
|
||||
case "circuitTotalPower": return circuit.circuitTotalPower;
|
||||
case "protectionType": return circuit.protectionType;
|
||||
case "protectionRatedCurrent": return circuit.protectionRatedCurrent;
|
||||
case "protectionCharacteristic": return circuit.protectionCharacteristic;
|
||||
case "protectionType":
|
||||
return protection
|
||||
? protectionDeviceTypeLabels[protection.type]
|
||||
: circuit.protectionType;
|
||||
case "protectionRatedCurrent":
|
||||
return protection?.ratedCurrentA ?? circuit.protectionRatedCurrent;
|
||||
case "protectionCharacteristic":
|
||||
return protectionCharacteristic || circuit.protectionCharacteristic;
|
||||
case "protectionSummary": {
|
||||
const current = circuit.protectionRatedCurrent !== undefined && circuit.protectionRatedCurrent !== null
|
||||
? `${circuit.protectionRatedCurrent}A`
|
||||
if (!protection) {
|
||||
const legacyCurrent =
|
||||
circuit.protectionRatedCurrent !== undefined &&
|
||||
circuit.protectionRatedCurrent !== null
|
||||
? `${circuit.protectionRatedCurrent}A`
|
||||
: "";
|
||||
return [
|
||||
circuit.protectionType,
|
||||
legacyCurrent,
|
||||
circuit.protectionCharacteristic,
|
||||
].filter(Boolean).join(" ").trim() || undefined;
|
||||
}
|
||||
const currentValue =
|
||||
protection.ratedCurrentA;
|
||||
const current = currentValue !== undefined && currentValue !== null
|
||||
? `${currentValue} A`
|
||||
: "";
|
||||
return [circuit.protectionType, current, circuit.protectionCharacteristic].filter(Boolean).join(" ").trim() || undefined;
|
||||
return [
|
||||
protectionDeviceTypeLabels[protection.type],
|
||||
current,
|
||||
protectionCharacteristic,
|
||||
].filter(Boolean).join(" · ").trim() || undefined;
|
||||
}
|
||||
case "cableSummary": {
|
||||
const length = circuit.cableLength !== undefined && circuit.cableLength !== null ? `${circuit.cableLength} m` : "";
|
||||
|
|
@ -539,7 +576,14 @@ export function compareSortValues(left: GridValue, right: GridValue): number {
|
|||
}
|
||||
|
||||
export function getCellKind(rowType: RowType, key: CellKey): CellKind {
|
||||
if (key === "rowTotalPower" || key === "circuitTotalPower") return "computed";
|
||||
if (
|
||||
key === "rowTotalPower" ||
|
||||
key === "circuitTotalPower" ||
|
||||
key === "protectionType" ||
|
||||
key === "protectionRatedCurrent" ||
|
||||
key === "protectionCharacteristic" ||
|
||||
key === "protectionSummary"
|
||||
) return "computed";
|
||||
if (key === "voltage") return "readonly";
|
||||
if (rowType === "section") return "readonly";
|
||||
if (rowType === "placeholder") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue