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 ?? ""),
};
}