Configure circuit protection
This commit is contained in:
@@ -5,6 +5,10 @@ import {
|
||||
type CircuitDeviceRowSnapshot,
|
||||
} from "./circuit-device-row-structure-project-command.model.js";
|
||||
import type { SerializedProjectCommand } from "./project-command.model.js";
|
||||
import {
|
||||
assertCircuitProtectionSnapshot,
|
||||
type CircuitProtectionSnapshot,
|
||||
} from "./circuit-protection-project-command.model.js";
|
||||
|
||||
export const circuitInsertCommandType = "circuit.insert" as const;
|
||||
export const circuitDeleteCommandType = "circuit.delete" as const;
|
||||
@@ -31,6 +35,7 @@ export interface CircuitSnapshot {
|
||||
isReserve: boolean;
|
||||
remark: string | null;
|
||||
deviceRows: CircuitDeviceRowSnapshot[];
|
||||
protectionDevice?: CircuitProtectionSnapshot | null;
|
||||
}
|
||||
|
||||
export interface CircuitInsertCommandPayload {
|
||||
@@ -142,6 +147,15 @@ export function assertCircuitInsertProjectCommand(
|
||||
if (!Array.isArray(circuit.deviceRows)) {
|
||||
throw new Error("circuit.deviceRows must be an array.");
|
||||
}
|
||||
if (
|
||||
circuit.protectionDevice !== undefined &&
|
||||
circuit.protectionDevice !== null
|
||||
) {
|
||||
assertCircuitProtectionSnapshot(
|
||||
circuit.protectionDevice,
|
||||
circuit.id as string
|
||||
);
|
||||
}
|
||||
if (circuit.isReserve !== (circuit.deviceRows.length === 0)) {
|
||||
throw new Error(
|
||||
"Circuit reserve state must match whether device rows exist."
|
||||
|
||||
Reference in New Issue
Block a user