Derive device voltages from project settings

This commit is contained in:
Julian Appel 2026-07-29 09:53:58 +02:00
parent b1a11397b3
commit 084103bf54
39 changed files with 2696 additions and 76 deletions

View file

@ -5,6 +5,10 @@ import {
inferProjectDeviceSectionKey,
isProjectDevicePlacementValid,
} from "../../domain/services/project-device-placement.service";
import {
resolveCircuitPhaseType,
resolveProjectVoltage,
} from "../../domain/services/project-voltage.service";
import {
getInsertionSortOrder,
resolveGridInsertionIntent,
@ -819,6 +823,19 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
values: CreateCircuitInputDto,
deviceRowValues: CreateCircuitDeviceRowInputDto[] = []
) {
const section = data?.sections.find(
(entry) => entry.id === values.sectionId
);
if (!section || !data) {
throw new Error("Bereich wurde nicht gefunden.");
}
const voltage = resolveProjectVoltage(
resolveCircuitPhaseType(
section.key,
deviceRowValues.map((row) => row.phaseType)
),
data
);
const circuitId = crypto.randomUUID();
const deviceRows = deviceRowValues.map((row, index) =>
createDeviceRowSnapshot(circuitId, row, (index + 1) * 10)
@ -826,7 +843,7 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
return buildCircuitInsertSnapshot({
id: circuitId,
circuitListId,
values,
values: { ...values, voltage },
deviceRows,
});
}

View file

@ -47,7 +47,6 @@ export function ProjectDeviceModal({
simultaneityFactor: Number(values.simultaneityFactor),
cosPhi: optionalNumber(values.cosPhi),
remark: optionalString(values.remark),
voltageV: optionalNumber(values.voltageV),
});
}
@ -182,13 +181,6 @@ export function ProjectDeviceModal({
step="0.01"
value={values.cosPhi}
/>
<NumberField
id="device-voltage"
label="Spannung [V]"
min="1"
onChange={(value) => update("voltageV", value)}
value={values.voltageV}
/>
<div className="col-12">
<label className="form-label" htmlFor="device-remark">
Bemerkung
@ -272,7 +264,6 @@ function toFormValues(device?: ProjectDeviceDto) {
simultaneityFactor: String(device?.simultaneityFactor ?? 1),
cosPhi: String(device?.cosPhi ?? 1),
remark: device?.remark ?? "",
voltageV: String(device?.voltageV ?? ""),
};
}

View file

@ -187,7 +187,6 @@ export interface CreateGlobalDeviceInput {
quantity: number;
installedPowerPerUnitKw: number;
demandFactor: number;
voltageV?: number;
phaseCount?: 1 | 3;
powerFactor?: number;
note?: string;
@ -205,7 +204,6 @@ export interface CreateProjectDeviceInput {
simultaneityFactor: number;
cosPhi?: number;
remark?: string;
voltageV?: number;
}
export interface ProjectDeviceSyncDifferenceDto {
@ -314,6 +312,8 @@ export interface CircuitTreeMigrationReportDto {
export interface CircuitTreeResponseDto {
circuitListId: string;
currentRevision: number;
singlePhaseVoltageV: number;
threePhaseVoltageV: number;
sections: CircuitTreeSectionDto[];
migrationReport?: CircuitTreeMigrationReportDto;
}

View file

@ -161,7 +161,6 @@ const circuitFieldKeys = new Set<CellKey>([
"cableSummary",
"rcdAssignment",
"terminalDesignation",
"voltage",
"controlRequirement",
"status",
"isReserve",
@ -393,6 +392,7 @@ 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 === "voltage") return "readonly";
if (rowType === "section") return "readonly";
if (rowType === "placeholder") {
if (deviceFieldKeys.has(key)) return "deviceField";

View file

@ -149,6 +149,8 @@ function makeVisibleGridRow(
value = circuit.circuitTotalPower;
} else if (column.key === "circuitTotalPower" && circuit) {
value = circuit.circuitTotalPower;
} else if (column.key === "voltage" && circuit) {
value = circuit.voltage;
}
return { cellKey: column.key, editable, kind, value };