diff --git a/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_active.xaml b/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_active.xaml
new file mode 100644
index 0000000..1dd1710
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_active.xaml
@@ -0,0 +1,16 @@
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_error.xaml b/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_error.xaml
new file mode 100644
index 0000000..a34b880
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_error.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_inactive.xaml
new file mode 100644
index 0000000..5338fe9
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_26_Zufuhrband_M_main_inactive.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_active.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_active.xaml
new file mode 100644
index 0000000..d624b5a
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_active.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_error.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_error.xaml
new file mode 100644
index 0000000..31a4690
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_error.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_inactive.xaml
new file mode 100644
index 0000000..462c5cc
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M1_main_inactive.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_active.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_active.xaml
new file mode 100644
index 0000000..d624b5a
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_active.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_error.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_error.xaml
new file mode 100644
index 0000000..31a4690
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_error.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_inactive.xaml
new file mode 100644
index 0000000..462c5cc
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M2_slave_inactive.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_active.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_active.xaml
new file mode 100644
index 0000000..d624b5a
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_active.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_error.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_error.xaml
new file mode 100644
index 0000000..31a4690
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_error.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_inactive.xaml
new file mode 100644
index 0000000..462c5cc
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M3_slave_inactive.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_active.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_active.xaml
new file mode 100644
index 0000000..d624b5a
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_active.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_error.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_error.xaml
new file mode 100644
index 0000000..31a4690
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_error.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_inactive.xaml
new file mode 100644
index 0000000..462c5cc
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Fahrantrieb_M4_slave_inactive.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_active.xaml b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_active.xaml
new file mode 100644
index 0000000..a6963db
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_active.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_error.xaml b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_error.xaml
new file mode 100644
index 0000000..266dc3e
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_error.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_inactive.xaml
new file mode 100644
index 0000000..a68871a
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M1_main_inactive.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_active.xaml b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_active.xaml
new file mode 100644
index 0000000..d624b5a
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_active.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_error.xaml b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_error.xaml
new file mode 100644
index 0000000..31a4690
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_error.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_inactive.xaml
new file mode 100644
index 0000000..462c5cc
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_28_Verteilband_M2_slave_inactive.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_active.xaml b/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_active.xaml
new file mode 100644
index 0000000..b271198
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_active.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_error.xaml b/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_error.xaml
new file mode 100644
index 0000000..799e543
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_error.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_inactive.xaml
new file mode 100644
index 0000000..f1c7fc9
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_29_Kopfband_hinten_M_main_inactive.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_active.xaml b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_active.xaml
new file mode 100644
index 0000000..b271198
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_active.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_error.xaml b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_error.xaml
new file mode 100644
index 0000000..799e543
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_error.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_inactive.xaml
new file mode 100644
index 0000000..f1c7fc9
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_main_inactive.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ 0.5,0.5
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_warnung_inactive.xaml b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_warnung_inactive.xaml
new file mode 100644
index 0000000..2c024f0
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA1_30_Kopfband_vorne_M_warnung_inactive.xaml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_active.xaml b/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_active.xaml
new file mode 100644
index 0000000..d624b5a
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_active.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_error.xaml b/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_error.xaml
new file mode 100644
index 0000000..31a4690
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_error.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_inactive.xaml b/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_inactive.xaml
new file mode 100644
index 0000000..462c5cc
--- /dev/null
+++ b/data/1667_Durmin 2/xaml/BA2_33_Fahrantrieb_M2_main_inactive.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/_dto/band-oben.dto.ts b/src/_dto/band-oben.dto.ts
index f3df839..84439e1 100644
--- a/src/_dto/band-oben.dto.ts
+++ b/src/_dto/band-oben.dto.ts
@@ -7,21 +7,27 @@ export class BandObenRenderDto {
}
export function parseBandObenRequest(input: unknown): BandObenRenderDto {
- const object = (value: unknown): value is Record =>
- typeof value === 'object' && value !== null && !Array.isArray(value);
+ const object = (value: unknown): value is Record => typeof value === 'object' && value !== null && !Array.isArray(value);
+
if (!object(input) || Object.keys(input).some(key => !['config', 'options'].includes(key)) || !object(input.config))
throw new BadRequestException('Erwartet werden config und optional options');
+
const config = input.config;
+
if (Object.keys(config).some(key => !['width', 'length'].includes(key)) ||
- typeof config.width !== 'number' || !Number.isFinite(config.width) || config.width <= 10 ||
- typeof config.length !== 'number' || !Number.isFinite(config.length) || config.length <= 0)
+ typeof config.width !== 'number' || !Number.isFinite(config.width) || config.width <= 10 ||
+ typeof config.length !== 'number' || !Number.isFinite(config.length) || config.length <= 0)
throw new BadRequestException('config.width muss größer als 10 und config.length positiv sein; beide Werte müssen endliche Zahlen sein');
+
const options = input.options === undefined ? {} : input.options;
+
if (!object(options) || Object.entries(options).some(([key, value]) =>
!['fromNorthToSouth', 'trichterStart', 'trichterEnd'].includes(key) || typeof value !== 'boolean'))
throw new BadRequestException('options erlaubt nur fromNorthToSouth, trichterStart und trichterEnd als Boolean');
+
if ((options.trichterStart || options.trichterEnd) && config.length < 20)
throw new BadRequestException('Mit Trichter muss die Bandlänge mindestens 20 sein');
+
return {
config: { width: config.width, length: config.length },
options: {
diff --git a/src/_dto/draw.dto.ts b/src/_dto/draw.dto.ts
index 0b05971..789dff1 100644
--- a/src/_dto/draw.dto.ts
+++ b/src/_dto/draw.dto.ts
@@ -27,8 +27,7 @@ export class DrawDataDto {
name!:string;
height!: number;
width!:number;
- svg!:{state:string,data:string}[]
- xaml!:{state:"inactive" | "active" | "error",data:string,base64?:string}[]
+ varianten!: { state: 'inactive' | 'active' | 'error'; svg: string; xaml: string; xamlBase64: string }[];
}
export class DrawShapeOptionenDto{
@@ -54,4 +53,4 @@ export class DrawParameterDto{
colorActive?:string;
colorError?:string;
-}
\ No newline at end of file
+}
diff --git a/src/_dto/motor.dto.ts b/src/_dto/motor.dto.ts
new file mode 100644
index 0000000..8fb40e3
--- /dev/null
+++ b/src/_dto/motor.dto.ts
@@ -0,0 +1,42 @@
+import { BadRequestException } from '@nestjs/common';
+import type { MotorConfig, MotorOptions } from '../graphics/elements/types';
+
+export class MotorRenderDto {
+ config!: MotorConfig;
+ options?: Partial;
+}
+
+export function parseMotorRequest(input: unknown): MotorRenderDto {
+ const object = (value: unknown): value is Record =>
+ typeof value === 'object' && value !== null && !Array.isArray(value);
+
+ if (!object(input) || Object.keys(input).some(key => !['config', 'options'].includes(key)) || !object(input.config))
+ throw new BadRequestException('Erwartet werden config und optional options');
+
+ const config = input.config;
+
+ if (Object.keys(config).some(key => !['scale', 'raster'].includes(key)))
+ throw new BadRequestException('Motor-config erlaubt nur scale und raster');
+
+ const scale = config.scale ?? 2, raster = config.raster ?? 4;
+
+ if (typeof scale !== 'number' ||
+ !Number.isFinite(scale) ||
+ scale <= 0 ||
+ typeof raster !== 'number' ||
+ !Number.isFinite(raster) ||
+ raster <= 0 ||
+ !Number.isFinite(3 * scale * raster)
+ )
+ throw new BadRequestException('scale und raster müssen positive endliche Zahlen sein');
+
+ const options = input.options === undefined ? {} : input.options;
+
+ if (!object(options) ||
+ Object.entries(options).some(([key, value]) => !['colorInactive', 'colorActive', 'colorError'].includes(key) ||
+ typeof value !== 'string' || !/^#[0-9a-fA-F]{6}$/.test(value))
+ )
+ throw new BadRequestException('Motor-options erlaubt colorInactive, colorActive und colorError als Hexfarbe #RRGGBB');
+
+ return { config: { scale, raster }, options: options as Partial };
+}
diff --git a/src/_dto/procon-verbindungen.dto.ts b/src/_dto/procon-verbindungen.dto.ts
new file mode 100644
index 0000000..2cdc5e4
--- /dev/null
+++ b/src/_dto/procon-verbindungen.dto.ts
@@ -0,0 +1,39 @@
+import { BadRequestException } from '@nestjs/common';
+import { Types } from 'mongoose';
+import type { ProConVerbindung } from '../_schemas/procon-verbindung';
+
+export class ProConVerbindungenDto {
+ verbindungen!: (Omit & { id?: string })[];
+ aktiveVerbindungId!: string | null;
+}
+
+export function parseVerbindungen(input: ProConVerbindungenDto) {
+ if (!input || !Array.isArray(input.verbindungen)) throw new BadRequestException('Verbindungsliste fehlt');
+ const ids = new Set();
+ const verbindungen = input.verbindungen.map(item => {
+ if (!item || ['name', 'server', 'datenbank', 'benutzer'].some(key => typeof item[key] !== 'string' || !item[key].trim()) ||
+ typeof item.passwort !== 'string' || typeof item.instanz !== 'string' ||
+ !['test', 'produktion'].includes(item.umgebung) ||
+ typeof item.encrypt !== 'boolean' || typeof item.trustServerCertificate !== 'boolean')
+ throw new BadRequestException('Verbindungsdaten sind unvollständig');
+ if (item.server.includes('\\') || item.server.includes('/') || (item.instanz && item.port !== null))
+ throw new BadRequestException('Server und Instanz getrennt eingeben; entweder Instanz oder Port verwenden');
+ if ((item.port !== null && (!Number.isInteger(item.port) || item.port < 1 || item.port > 65535)) ||
+ !Number.isInteger(item.connectionTimeoutMs) || item.connectionTimeoutMs < 1000 || item.connectionTimeoutMs > 60000)
+ throw new BadRequestException('Port muss 1–65535 und Timeout 1000–60000 ms betragen');
+ if (item.id && !Types.ObjectId.isValid(item.id)) throw new BadRequestException('Ungültige Verbindungs-ID');
+ const _id = item.id ? new Types.ObjectId(item.id) : new Types.ObjectId();
+ if (ids.has(_id.toString())) throw new BadRequestException('Doppelte Verbindungs-ID');
+ ids.add(_id.toString());
+ return {
+ _id, name: item.name.trim(), server: item.server.trim(), instanz: item.instanz.trim(),
+ port: item.port, datenbank: item.datenbank.trim(), benutzer: item.benutzer.trim(),
+ passwort: item.passwort, umgebung: item.umgebung, encrypt: item.encrypt,
+ trustServerCertificate: item.trustServerCertificate, connectionTimeoutMs: item.connectionTimeoutMs,
+ };
+ });
+ if (input.aktiveVerbindungId !== null && !ids.has(input.aktiveVerbindungId))
+ throw new BadRequestException('Aktive Verbindung ist nicht in der Liste enthalten');
+ return { verbindungen, aktiveVerbindungId: input.aktiveVerbindungId };
+}
+
diff --git a/src/_schemas/anlage.schema.ts b/src/_schemas/anlage.schema.ts
index 41270ea..dafd283 100644
--- a/src/_schemas/anlage.schema.ts
+++ b/src/_schemas/anlage.schema.ts
@@ -1,5 +1,7 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
+import { ProConVerbindungSchema } from './procon-verbindung';
+import type { ProConVerbindung } from './procon-verbindung';
interface AnlageJSON {
id: string;
@@ -9,6 +11,11 @@ interface AnlageJSON {
@Schema()
export class Anlage extends Document {
+ @Prop({ type: [ProConVerbindungSchema], default: [] })
+ proConVerbindungen!: ProConVerbindung[];
+
+ @Prop({ type: String, default: null })
+ aktiveProConVerbindungId!: string | null;
@Prop()
@@ -45,4 +52,4 @@ AnlageSchema.set('toJSON', {
return ret;
}
});
-*/
\ No newline at end of file
+*/
diff --git a/src/_schemas/anlagen/procon-view-aggregate.spec.ts b/src/_schemas/anlagen/procon-view-aggregate.spec.ts
index 62c0b7d..89aa917 100644
--- a/src/_schemas/anlagen/procon-view-aggregate.spec.ts
+++ b/src/_schemas/anlagen/procon-view-aggregate.spec.ts
@@ -27,7 +27,7 @@ describe('ProConViewAggregate', () => {
{ ...basis, darstellung: 'xaml', typ: 'main', varianten: [
{ zustand: 'active', xamlBase64: '' }, { zustand: 'inactive' },
] },
- { ...basis, key: 'motor', darstellung: 'xaml', typ: 'motor' },
+ { ...basis, key: 'motor', darstellung: 'xaml', typ: 'main' },
]);
await document.validate();
expect(document.toObject().elemente[0]).toEqual(expect.objectContaining({
@@ -36,7 +36,7 @@ describe('ProConViewAggregate', () => {
expect(document.toObject().elemente[1]).toEqual(expect.objectContaining({ varianten: [] }));
});
- it.each(['anfahrzeit', 'betriebsart', 'text'])('speichert %s ohne XAML-Felder', async typ => {
+ it.each(['anfahrzeit', 'betriebsart', 'text', 'motor'])('speichert %s ohne XAML-Felder', async typ => {
const document = create([{ ...basis, darstellung: 'standard', typ }]);
await document.validate();
expect(document.toObject().elemente[0]).not.toHaveProperty('varianten');
diff --git a/src/_schemas/anlagen/procon-view-aggregate.ts b/src/_schemas/anlagen/procon-view-aggregate.ts
index 46abeb2..dfce9a0 100644
--- a/src/_schemas/anlagen/procon-view-aggregate.ts
+++ b/src/_schemas/anlagen/procon-view-aggregate.ts
@@ -1,9 +1,19 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
import { VisuAggregate } from './visu-aggregate';
+import type { DrawDataDto } from '../../_dto/draw.dto';
+
+export interface GrafikGeneratorDaten {
+ grafikTyp: 'motor' | 'bandOben' | 'warnung';
+ config: Record;
+ options: Record;
+ ergebnis?: DrawDataDto;
+}
export interface XamlVariante {
zustand: string;
+ svg?: string;
+ xaml?: string;
xamlBase64: string;
}
@@ -17,20 +27,23 @@ export interface ViewElementBasis {
posY: number;
zIndex: number;
show: boolean;
+ manuell?: boolean;
}
export type ProConViewElement =
- | (ViewElementBasis & { darstellung: 'xaml'; typ: string; varianten: XamlVariante[] })
- | (ViewElementBasis & { darstellung: 'standard'; typ: 'anfahrzeit' | 'betriebsart' | 'text' });
+ | (ViewElementBasis & { darstellung: 'xaml'; typ: string; varianten: XamlVariante[]; generator?: GrafikGeneratorDaten })
+ | (ViewElementBasis & { darstellung: 'standard'; typ: 'anfahrzeit' | 'betriebsart' | 'text' | 'motor' });
-const standardTypen = ['anfahrzeit', 'betriebsart', 'text'];
+const standardTypen = ['anfahrzeit', 'betriebsart', 'text', 'motor'];
const dateiTeil = /^[a-zA-Z0-9_-]+$/;
const endlich = { validator: Number.isFinite, message: 'Wert muss eine endliche Zahl sein' };
const VarianteSchema = new MongooseSchema({
+ svg: { type: String },
+ xaml: { type: String },
zustand: { type: String, required: true, match: dateiTeil },
xamlBase64: { type: String, default: '' },
-}, { _id: false, strict: 'throw' });
+}, { _id: false, strict: 'throw', minimize: false });
const ElementSchema = new MongooseSchema({
key: { type: String, required: true, match: dateiTeil },
@@ -41,12 +54,16 @@ const ElementSchema = new MongooseSchema({
posY: { type: Number, required: true, validate: endlich },
zIndex: { type: Number, required: true, validate: { validator: Number.isSafeInteger, message: 'zIndex muss ganzzahlig sein' } },
show: { type: Boolean, default: true },
-}, { discriminatorKey: 'darstellung', strict: 'throw' });
+ manuell: { type: Boolean, default: false },
+}, { discriminatorKey: 'darstellung', strict: 'throw', minimize: false });
-@Schema({ collection: 'proConViewAggregate', timestamps: true, strict: 'throw' })
+@Schema({ collection: 'proConViewAggregate', timestamps: true, strict: 'throw', minimize: false })
export class ProConViewAggregate {
_id!: Types.ObjectId;
+ @Prop({ type: String, default: null })
+ positionsMasterId!: string | null;
+
@Prop({ type: MongooseSchema.Types.ObjectId, ref: VisuAggregate.name, required: true, immutable: true })
visuAggregateId!: Types.ObjectId;
@@ -69,6 +86,15 @@ ProConViewAggregateSchema.index({ visuAggregateId: 1 }, { unique: true });
const elemente = ProConViewAggregateSchema.path('elemente');
elemente.discriminator('xaml', new MongooseSchema({
+ generator: {
+ type: new MongooseSchema({
+ grafikTyp: { type: String, enum: ['motor', 'bandOben', 'warnung'], required: true },
+ config: { type: MongooseSchema.Types.Mixed, required: true },
+ options: { type: MongooseSchema.Types.Mixed, default: () => ({}) },
+ ergebnis: { type: MongooseSchema.Types.Mixed },
+ }, { _id: false, strict: 'throw', minimize: false }),
+ default: undefined,
+ },
typ: {
type: String, required: true,
validate: { validator: (typ: string) => !standardTypen.includes(typ), message: 'Dieser Elementtyp verwendet keine XAML-Grafiken' },
@@ -80,8 +106,8 @@ elemente.discriminator('xaml', new MongooseSchema({
message: 'Zustände müssen pro Element eindeutig sein',
},
},
-}, { _id: false, strict: 'throw' }));
+}, { _id: false, strict: 'throw', minimize: false }));
elemente.discriminator('standard', new MongooseSchema({
typ: { type: String, enum: standardTypen, required: true },
-}, { _id: false, strict: 'throw' }));
+}, { _id: false, strict: 'throw', minimize: false }));
diff --git a/src/_schemas/anlagen/procon-zuordnung.ts b/src/_schemas/anlagen/procon-zuordnung.ts
new file mode 100644
index 0000000..0952cee
--- /dev/null
+++ b/src/_schemas/anlagen/procon-zuordnung.ts
@@ -0,0 +1,19 @@
+import { Schema, Types } from 'mongoose';
+export interface ProConZuordnung {
+ anlageId: string;
+ verbindungId: string;
+ proConAggregateId: number;
+ spsAntriebId: number;
+ visuAggregateId: Types.ObjectId;
+ elemente: { visualizationId: number; elementId: string; key: string }[];
+}
+export const ProConZuordnungSchema = new Schema({
+ anlageId: { type: String, required: true },
+ verbindungId: { type: String, required: true },
+ proConAggregateId: { type: Number, required: true },
+ spsAntriebId: { type: Number, required: true },
+ visuAggregateId: { type: Schema.Types.ObjectId, required: true, ref: 'VisuAggregate' },
+ elemente: { type: [new Schema({ visualizationId: Number, elementId: String, key: String }, { _id: false })], default: [] },
+}, { collection: 'procon_zuordnungen', timestamps: true });
+ProConZuordnungSchema.index({ anlageId: 1, verbindungId: 1, proConAggregateId: 1 }, { unique: true });
+ProConZuordnungSchema.index({ anlageId: 1, verbindungId: 1, visuAggregateId: 1 }, { unique: true });
diff --git a/src/_schemas/anlagen/visualisierung-settings.ts b/src/_schemas/anlagen/visualisierung-settings.ts
new file mode 100644
index 0000000..7e91828
--- /dev/null
+++ b/src/_schemas/anlagen/visualisierung-settings.ts
@@ -0,0 +1,12 @@
+import { Schema } from 'mongoose';
+import type { VisualisierungSettingsDto } from '../../visualisierung/visualisierung.dto';
+
+export interface VisualisierungSettings extends VisualisierungSettingsDto { anlageId: string }
+export const VisualisierungSettingsSchema = new Schema({
+ anlageId: { type: String, required: true, unique: true },
+ workspaceWidth: { type: Number, required: true }, workspaceHeight: { type: Number, required: true },
+ grid: { type: Boolean, required: true }, gridStep: { type: Number, required: true },
+ snapToGrid: { type: Boolean, required: true }, showHidden: { type: Boolean, required: true },
+ selectedSpsAntriebId: { type: Number, default: null },
+ viewport: { type: new Schema({ x: Number, y: Number, width: Number, height: Number }, { _id: false }), required: true },
+}, { collection: 'visualisierung_settings', timestamps: true, strict: 'throw' });
diff --git a/src/_schemas/procon-verbindung.ts b/src/_schemas/procon-verbindung.ts
new file mode 100644
index 0000000..5ad567e
--- /dev/null
+++ b/src/_schemas/procon-verbindung.ts
@@ -0,0 +1,31 @@
+import { Schema, Types } from 'mongoose';
+
+export interface ProConVerbindung {
+ _id: Types.ObjectId;
+ name: string;
+ umgebung: 'test' | 'produktion';
+ server: string;
+ instanz: string;
+ port: number | null;
+ datenbank: string;
+ benutzer: string;
+ passwort: string;
+ encrypt: boolean;
+ trustServerCertificate: boolean;
+ connectionTimeoutMs: number;
+}
+
+export const ProConVerbindungSchema = new Schema({
+ name: { type: String, required: true },
+ umgebung: { type: String, enum: ['test', 'produktion'], required: true },
+ server: { type: String, required: true },
+ instanz: { type: String, default: '' },
+ port: { type: Number, default: null },
+ datenbank: { type: String, required: true },
+ benutzer: { type: String, required: true },
+ passwort: { type: String, default: '' },
+ encrypt: { type: Boolean, default: true },
+ trustServerCertificate: { type: Boolean, default: false },
+ connectionTimeoutMs: { type: Number, default: 3000 },
+});
+
diff --git a/src/anlagen/visu-aggregate/procon-view-aggregate.controller.ts b/src/anlagen/visu-aggregate/procon-view-aggregate.controller.ts
index b2c78d4..9fbd40a 100644
--- a/src/anlagen/visu-aggregate/procon-view-aggregate.controller.ts
+++ b/src/anlagen/visu-aggregate/procon-view-aggregate.controller.ts
@@ -1,4 +1,5 @@
-import { Body, Controller, Get, Param, Put } from '@nestjs/common';
+import { Body, Controller, Get, Param, Post, Put, HttpCode } from '@nestjs/common';
+import { XamlExportDto } from './procon-xaml-export';
import { ProConViewAggregateUpdateDto } from '../../_dto/anlagen/procon-view-aggregate';
import { ProConViewAggregateService } from './procon-view-aggregate.service';
@@ -7,6 +8,9 @@ export class ProConViewAggregateController {
constructor(private readonly service: ProConViewAggregateService) {}
@Get()
findAll() { return this.service.findAll(); }
+ @Post('xaml')
+ @HttpCode(200)
+ exportXaml(@Body() dto: XamlExportDto) { return this.service.exportXaml(dto); }
@Get(':componentId')
findOne(@Param('componentId') id: string) { return this.service.findOne(id); }
@Put(':componentId')
diff --git a/src/anlagen/visu-aggregate/procon-view-aggregate.service.spec.ts b/src/anlagen/visu-aggregate/procon-view-aggregate.service.spec.ts
index 6c93a04..1db077d 100644
--- a/src/anlagen/visu-aggregate/procon-view-aggregate.service.spec.ts
+++ b/src/anlagen/visu-aggregate/procon-view-aggregate.service.spec.ts
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
jest.mock('../../rk-anlagen/anlage/anlage.service', () => ({ AnlageService: class AnlageService {} }));
+jest.mock('../../draw/draw.service', () => ({ DrawService: class DrawService {} }));
import { model, Types } from 'mongoose';
import { ProConViewAggregateSchema } from '../../_schemas/anlagen/procon-view-aggregate';
import { ProConViewAggregateService } from './procon-view-aggregate.service';
@@ -22,7 +23,7 @@ describe('ProConViewAggregateService', () => {
lean: () => ({ exec: async () => null }),
}));
aggregates = { findOne: jest.fn(() => ({ exec: async () => aggregate })) };
- service = new ProConViewAggregateService(views, aggregates, { getSelected: async () => ({ id: anlageId }) } as any);
+ service = new ProConViewAggregateService(views, aggregates, { getSelected: async () => ({ id: anlageId }) } as any, {} as any);
});
it('liefert für noch nicht angelegte Grafiken eine leere Elementliste', async () => {
@@ -72,6 +73,27 @@ describe('ProConViewAggregateService', () => {
expect(views).not.toHaveBeenCalled();
});
+ it('erzeugt und speichert das vollständige Generatorergebnis anstelle veralteter Daten', async () => {
+ const ergebnis = {
+ name: 'motor', width: 24, height: 24,
+ varianten: [{ state: 'active', svg: '', xaml: '', xamlBase64: Buffer.from('').toString('base64') }],
+ };
+ const renderGraphic = jest.fn(() => ergebnis);
+ service = new ProConViewAggregateService(views, aggregates, { getSelected: async () => ({ id: anlageId }) } as any, { renderGraphic } as any);
+ await service.save(componentId, { anlageId, elemente: [{
+ key: 'motor', name: '', darstellung: 'xaml', typ: 'main',
+ width: 1, height: 1, posX: 100, posY: 200, zIndex: 3, show: true, varianten: [],
+ generator: { grafikTyp: 'motor', config: { scale: 2, raster: 4 }, options: {} },
+ }] });
+ expect(renderGraphic).toHaveBeenCalledWith('motor', { config: { scale: 2, raster: 4 }, options: {} });
+ const document = views.mock.results[0].value;
+ expect(document.toObject().elemente[0]).toEqual(expect.objectContaining({
+ width: 24, height: 24, posX: 100, posY: 200,
+ generator: { grafikTyp: 'motor', config: { scale: 2, raster: 4 }, options: {}, ergebnis },
+ varianten: [{ zustand: 'active', svg: '', xaml: '', xamlBase64: Buffer.from('').toString('base64') }],
+ }));
+ });
+
it('meldet ungültige Elemente als Eingabefehler', async () => {
await expect(service.save(componentId, { anlageId, elemente: [{ key: 'leer' } as any] })).rejects.toMatchObject({ status: 400 });
});
diff --git a/src/anlagen/visu-aggregate/procon-view-aggregate.service.ts b/src/anlagen/visu-aggregate/procon-view-aggregate.service.ts
index ccbf9aa..a5e646a 100644
--- a/src/anlagen/visu-aggregate/procon-view-aggregate.service.ts
+++ b/src/anlagen/visu-aggregate/procon-view-aggregate.service.ts
@@ -5,6 +5,21 @@ import { ProConViewAggregate } from '../../_schemas/anlagen/procon-view-aggregat
import { VisuAggregate } from '../../_schemas/anlagen/visu-aggregate';
import { AnlageService } from '../../rk-anlagen/anlage/anlage.service';
import { ProConViewAggregateUpdateDto } from '../../_dto/anlagen/procon-view-aggregate';
+import { DrawService } from '../../draw/draw.service';
+import type { ProConViewElement } from '../../_schemas/anlagen/procon-view-aggregate';
+import { mkdir, writeFile } from 'node:fs/promises';
+import { resolve, join } from 'node:path';
+import { createXamlFiles, XamlExportDto } from './procon-xaml-export';
+
+function normalizeMotor(element: ProConViewElement): ProConViewElement {
+ if (element.typ !== 'motor') return element;
+ return {
+ _id: element._id, key: element.key, name: element.name, typ: 'motor', darstellung: 'standard',
+ width: element.width, height: element.height, posX: element.posX, posY: element.posY,
+ zIndex: element.zIndex, show: element.show,
+ manuell: element.manuell,
+ };
+}
@Injectable()
export class ProConViewAggregateService {
@@ -12,8 +27,33 @@ export class ProConViewAggregateService {
@InjectModel(ProConViewAggregate.name, 'anlagen') private readonly views: Model,
@InjectModel(VisuAggregate.name, 'anlagen') private readonly aggregates: Model,
private readonly anlagen: AnlageService,
+ private readonly draw: DrawService,
) {}
+ async exportXaml(dto: XamlExportDto) {
+ const anlage = await this.anlagen.getSelected();
+ const anlageId = anlage.id;
+ if (!dto || dto.anlageId !== anlageId) throw new BadRequestException('Anlage hat sich geändert. Bitte neu laden.');
+ if (!Array.isArray(dto.auswahl) || dto.auswahl.length === 0 || dto.auswahl.some(item =>
+ !item || typeof item.componentId !== 'string' || !Array.isArray(item.elementKeys) || item.elementKeys.some(key => typeof key !== 'string')))
+ throw new BadRequestException('Keine gültige Grafikauswahl');
+ const aggregates = await this.findAll();
+ if ((await this.anlagen.getSelected()).id !== anlageId) throw new BadRequestException('Anlage hat sich geändert. Bitte neu laden.');
+ const { files, skipped } = createXamlFiles(aggregates, dto);
+ const safeName = anlage.name.trim()
+ .replace(/[<>:"/\\|?*\u0000-\u001f]/g, '_')
+ .replace(/[ .]+$/g, '');
+ if (!safeName || !Number.isSafeInteger(anlage.anlageNr))
+ throw new BadRequestException('Anlagennummer oder Anlagenname ist ungültig');
+ const folder = anlage.anlageNr + '_' + safeName;
+ const target = resolve(process.cwd(), 'data', folder, 'xaml');
+ if (files.length) {
+ await mkdir(target, { recursive: true });
+ for (const file of files) await writeFile(join(target, file.name), file.data, 'utf8');
+ }
+ return { count: files.length, skipped, directory: 'data/' + folder + '/xaml' };
+ }
+
async findAll() {
const anlageId = (await this.anlagen.getSelected()).id;
const aggregates = await this.aggregates.find({
@@ -25,7 +65,7 @@ export class ProConViewAggregateService {
antriebId: aggregate.antriebId,
name: aggregate.antriebName,
viewName: aggregate.view ?? '',
- elemente: views.find(view => view.visuAggregateId.toString() === aggregate._id.toString())?.elemente ?? [],
+ elemente: (views.find(view => view.visuAggregateId.toString() === aggregate._id.toString())?.elemente ?? []).map(normalizeMotor),
})).sort((a, b) => a.antriebId - b.antriebId);
}
@@ -49,7 +89,7 @@ export class ProConViewAggregateService {
anlageId, visuAggregateId: aggregate._id.toString(),
viewName: aggregate.view ?? '', name: aggregate.antriebName,
anzahlMotoren: aggregate.anzahlMotoren ?? 1,
- persisted: !!view, elemente: view?.elemente ?? [],
+ persisted: !!view, elemente: (view?.elemente ?? []).map(normalizeMotor),
};
}
@@ -57,10 +97,24 @@ export class ProConViewAggregateService {
const { aggregate, anlageId } = await this.parent(componentId);
if (!dto || dto.anlageId !== anlageId) throw new BadRequestException('Die Anlage hat sich geändert. Bitte neu laden.');
if (!Array.isArray(dto.elemente)) throw new BadRequestException('Elementliste fehlt');
+ const elemente = dto.elemente.map(normalizeMotor).map(element => {
+ if (element?.darstellung !== 'xaml' || !element.generator || element.manuell) return element;
+ const { grafikTyp, config, options } = element.generator;
+ // Vor jedem Speichern serverseitig neu erzeugen: Parameter und Ergebnis bleiben konsistent.
+ const ergebnis = this.draw.renderGraphic(grafikTyp, { config, options });
+ return {
+ ...element, width: ergebnis.width, height: ergebnis.height,
+ generator: { grafikTyp, config, options: options ?? {}, ergebnis },
+ varianten: ergebnis.varianten.map(variant => ({
+ zustand: variant.state,
+ svg: variant.svg, xaml: variant.xaml, xamlBase64: variant.xamlBase64,
+ })),
+ };
+ });
try {
const document = await this.views.findOne({ visuAggregateId: aggregate._id }).exec()
?? new this.views({ visuAggregateId: aggregate._id });
- document.set('elemente', dto.elemente);
+ document.set('elemente', elemente);
await document.save();
return { success: true };
} catch (error) {
diff --git a/src/anlagen/visu-aggregate/procon-xaml-export.spec.ts b/src/anlagen/visu-aggregate/procon-xaml-export.spec.ts
new file mode 100644
index 0000000..2b71930
--- /dev/null
+++ b/src/anlagen/visu-aggregate/procon-xaml-export.spec.ts
@@ -0,0 +1,38 @@
+import { describe, expect, it } from '@jest/globals';
+import { createXamlFiles } from './procon-xaml-export';
+import type { ProConViewElement } from '../../_schemas/anlagen/procon-view-aggregate';
+
+describe('XAML-Dateiexport', () => {
+ const element: ProConViewElement = {
+ key: 'main', name: '', darstellung: 'xaml', typ: 'main',
+ width: 40, height: 40, posX: 0, posY: 0, zIndex: 0, show: true,
+ varianten: [
+ { zustand: 'active', xaml: 'ä', xamlBase64: '' },
+ { zustand: 'inactive', xamlBase64: Buffer.from('').toString('base64') },
+ { zustand: 'error', xamlBase64: '' },
+ ],
+ };
+ const aggregates = [{ componentId: 'c1', viewName: 'SF1_Band', elemente: [element] }];
+ const dto = { anlageId: 'a1', auswahl: [{ componentId: 'c1', elementKeys: ['main'] }] };
+
+ it('erstellt Dateien für die Auswahl und dekodiert ältere Base64-Daten', () => {
+ expect(createXamlFiles(aggregates, dto)).toEqual({
+ files: [
+ { name: 'SF1_Band_main_active.xaml', data: 'ä' },
+ { name: 'SF1_Band_main_inactive.xaml', data: '' },
+ ], skipped: 1,
+ });
+ expect(createXamlFiles(aggregates, { ...dto, auswahl: [{ componentId: 'c1', elementKeys: [] }] }).files).toEqual([]);
+ });
+
+ it('verhindert Pfade außerhalb des Exportordners und leere View-Namen', () => {
+ for (const viewName of ['../fremd', 'C:\\fremd', '', 'Datei.']) {
+ expect(() => createXamlFiles([{ ...aggregates[0], viewName }], dto)).toThrow('Dateinamenbestandteile');
+ }
+ });
+
+ it('verhindert doppelte Dateinamen und unbekannte Auswahlen', () => {
+ expect(() => createXamlFiles(aggregates, { ...dto, auswahl: [...dto.auswahl, ...dto.auswahl] })).toThrow('Doppelter');
+ expect(() => createXamlFiles(aggregates, { ...dto, auswahl: [{ componentId: 'fremd', elementKeys: ['main'] }] })).toThrow('dieser Anlage');
+ });
+});
diff --git a/src/anlagen/visu-aggregate/procon-xaml-export.ts b/src/anlagen/visu-aggregate/procon-xaml-export.ts
new file mode 100644
index 0000000..32d5f3c
--- /dev/null
+++ b/src/anlagen/visu-aggregate/procon-xaml-export.ts
@@ -0,0 +1,32 @@
+import { BadRequestException } from '@nestjs/common';
+import type { ProConViewElement } from '../../_schemas/anlagen/procon-view-aggregate';
+
+export class XamlExportDto {
+ anlageId!: string;
+ auswahl!: { componentId: string; elementKeys: string[] }[];
+}
+
+export function createXamlFiles(aggregates: { componentId: string; viewName: string; elemente: ProConViewElement[] }[], dto: XamlExportDto) {
+ const files = new Map();
+ let skipped = 0;
+ const safe = (value: string) => !!value && /^[\p{L}\p{N}_ .-]+$/u.test(value) && !value.includes('..') && !/[ .]$/.test(value);
+ for (const selection of dto.auswahl) {
+ const aggregate = aggregates.find(item => item.componentId === selection.componentId);
+ if (!aggregate) throw new BadRequestException('Ausgewähltes Aggregat ist in dieser Anlage nicht vorhanden');
+ for (const key of selection.elementKeys) {
+ const element = aggregate.elemente.find(item => item.key === key);
+ if (!element) throw new BadRequestException('Ausgewähltes Element ist nicht mehr vorhanden: ' + key);
+ if (element.darstellung !== 'xaml') continue;
+ for (const variant of element.varianten) {
+ const data = variant.xaml || (variant.xamlBase64 ? Buffer.from(variant.xamlBase64, 'base64').toString('utf8') : '');
+ if (!data.trim()) { skipped++; continue; }
+ if (![aggregate.viewName, element.key, variant.zustand].every(safe))
+ throw new BadRequestException('View, Element und Zustand müssen gültige Dateinamenbestandteile sein');
+ const name = aggregate.viewName + '_' + element.key + '_' + variant.zustand + '.xaml';
+ if (files.has(name.toLowerCase())) throw new BadRequestException('Doppelter Dateiname: ' + name);
+ files.set(name.toLowerCase(), { name, data });
+ }
+ }
+ }
+ return { files: [...files.values()], skipped };
+}
diff --git a/src/anlagen/visu-aggregate/visu-aggregate.module.ts b/src/anlagen/visu-aggregate/visu-aggregate.module.ts
index cbd5403..0672860 100644
--- a/src/anlagen/visu-aggregate/visu-aggregate.module.ts
+++ b/src/anlagen/visu-aggregate/visu-aggregate.module.ts
@@ -8,9 +8,10 @@ import { VisuAggregateController } from './visu-aggregate.controller';
import { ProConViewAggregate, ProConViewAggregateSchema } from '../../_schemas/anlagen/procon-view-aggregate';
import { ProConViewAggregateService } from './procon-view-aggregate.service';
import { ProConViewAggregateController } from './procon-view-aggregate.controller';
+import { DrawModule } from '../../draw/draw.module';
@Module({
- imports: [AnlageModule, MongooseModule.forFeature([
+ imports: [AnlageModule, DrawModule, MongooseModule.forFeature([
{ name: VisuAggregate.name, schema: VisuAggregateSchema },
{ name: ProConViewAggregate.name, schema: ProConViewAggregateSchema },
{ name: Unit.name, schema: UnitSchema },
diff --git a/src/app.module.ts b/src/app.module.ts
index c949116..8492411 100644
--- a/src/app.module.ts
+++ b/src/app.module.ts
@@ -9,10 +9,12 @@ import { ProconModule } from './procon/procon.module';
import { SqlModule } from './infrastructure/sql/sql.module';
import { FileWatcherModule } from './moon/file-watcher/file-watcher.module';
import { AnlagenModule } from './anlagen/anlagen.module';
+import { VisualisierungModule } from './visualisierung/visualisierung.module';
@Module({
imports: [
+ VisualisierungModule,
MongooseModule.forRoot('mongodb://localhost/rk'),
MongooseModule.forRoot('mongodb://localhost/rk2', { connectionName: 'anlagen' }),
UserModule,
diff --git a/src/draw/draw.controller.ts b/src/draw/draw.controller.ts
index 9b6e0f2..5c88648 100644
--- a/src/draw/draw.controller.ts
+++ b/src/draw/draw.controller.ts
@@ -17,10 +17,10 @@ const graphicMethods = {
export class DrawController {
constructor(private readonly service: DrawService) {}
- @Post('bandOben/render')
+ @Post(':grafikTyp/render')
@HttpCode(200)
- renderBandOben(@Body() body: unknown): DrawDataDto {
- return this.service.renderBandOben(body);
+ renderGraphic(@Param('grafikTyp') grafikTyp: string, @Body() body: unknown): DrawDataDto {
+ return this.service.renderGraphic(grafikTyp, body);
}
// Die Anlagenzeichnung ist kein einzelnes Grafiksymbol.
diff --git a/src/draw/draw.module.ts b/src/draw/draw.module.ts
index f683e45..7eadbe8 100644
--- a/src/draw/draw.module.ts
+++ b/src/draw/draw.module.ts
@@ -22,11 +22,13 @@ import { DrawBehaelterMulti } from 'src/graphics/elements/drawBehaelterMulti';
import { DrawMotor } from 'src/graphics/elements/drawMotor';
import { DrawAnlageDurmin } from 'src/graphics/elements/drawAnlageDurmin2';
import { DrawBandOben } from 'src/graphics/elements/drawBandOben';
+import { DrawWarnung } from '../graphics/elements/drawWarnung';
@Module({
imports: [],
controllers: [DrawController],
providers: [
+ DrawWarnung,
DrawService,
Sieb,
DrawGurtfoerderer,
diff --git a/src/draw/draw.service.ts b/src/draw/draw.service.ts
index 00af620..0e5b17e 100644
--- a/src/draw/draw.service.ts
+++ b/src/draw/draw.service.ts
@@ -1,4 +1,6 @@
-import { Injectable } from '@nestjs/common';
+import { Injectable, NotFoundException } from '@nestjs/common';
+import { parseMotorRequest } from '../_dto/motor.dto';
+import { DrawWarnung, parseWarnungRequest } from '../graphics/elements/drawWarnung';
import { DrawShapeOptionenDto } from 'src/_dto/draw.dto';
import { DrawBand } from 'src/graphics/elements/drawBand';
import { DrawBehaelter } from 'src/graphics/elements/drawBehaelter';
@@ -28,6 +30,7 @@ import { parseBandObenRequest } from '../_dto/band-oben.dto';
@Injectable()
export class DrawService {
constructor(
+ private readonly buildWarnung: DrawWarnung,
private readonly buildBandOben: DrawBandOben,
private readonly buildSieb: Sieb,
private readonly buildGurtfoerderer: DrawGurtfoerderer,
@@ -63,6 +66,21 @@ export class DrawService {
return this.buildBandOben.getObject(config, options);
}
+ renderGraphic(type: string, input: unknown) {
+ switch (type) {
+ case 'warnung': {
+ const { config, options } = parseWarnungRequest(input);
+ return this.buildWarnung.getObject(config, options);
+ }
+ case 'bandOben': return this.renderBandOben(input);
+ case 'motor': {
+ const { config, options } = parseMotorRequest(input);
+ return this.buildMotor.getObject(config, options);
+ }
+ default: throw new NotFoundException('Unbekannter POST-Grafiktyp: ' + type);
+ }
+ }
+
sieb(options?: DrawShapeOptionenDto, rawSvg?: boolean) {
if (rawSvg) return this.buildSieb.getSvg(options);
return this.buildSieb.getDrawObject(options);
diff --git a/src/graphics/elements/drawAnlageDurmin2.ts b/src/graphics/elements/drawAnlageDurmin2.ts
index 262ed8e..7bafe12 100644
--- a/src/graphics/elements/drawAnlageDurmin2.ts
+++ b/src/graphics/elements/drawAnlageDurmin2.ts
@@ -341,21 +341,45 @@ export class DrawAnlageDurmin {
let ba3_pos_hf_x = 750
let ba3_pos_hf_y = 770 //anfanf(B1) 130 B2 310; B3 ende 520
- group1.add(this.createBand({ posX: 100, posY: 20, width: zufuefband_l, height: zufuefband_b, nordSued: true, boxEnde: true })) // BA1 Zufuehrband
- group1.add(this.createBand({ posX: ba1_pos_hf_x, posY: ba1_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA1 Verteilband
- group1.add(this.createBand({ posX: ba1_pos_hf_x - (kopfband_l / 2 - verteilband_b / 2), posY: ba1_pos_hf_y - (kopfband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten
- group1.add(this.createBand({ posX: ba1_pos_hf_x - (kopfband_l / 2 - verteilband_b / 2), posY: ba1_pos_hf_y + verteilband_l - (kopfband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne
+ /* group1.add(new DrawLine({x1:0,y1:100,x2:1500,y2:100}));
+ group1.add(new DrawLine({x1:0,y1:110,x2:1500,y2:110}));
+ group1.add(new DrawLine({x1:0,y1:120,x2:1500,y2:120}));
+ group1.add(new DrawLine({x1:0,y1:130,x2:1500,y2:130}));
+ group1.add(new DrawLine({x1:0,y1:140,x2:1500,y2:140}));
+ group1.add(new DrawLine({x1:0,y1:150,x2:1500,y2:150}));
+ group1.add(new DrawLine({x1:0,y1:160,x2:1500,y2:160}));
+ group1.add(new DrawLine({x1:0,y1:170,x2:1500,y2:170}));
+ group1.add(new DrawLine({x1:0,y1:180,x2:1500,y2:180}));
+ group1.add(new DrawLine({x1:0,y1:190,x2:1500,y2:190}));
+ group1.add(new DrawLine({x1:0,y1:200,x2:1500,y2:200}));
+
+ group1.add(new DrawLine({x1:10,y1:0,x2:10,y2:1100}));
+ group1.add(new DrawLine({x1:20,y1:0,x2:20,y2:1100}));
+ group1.add(new DrawLine({x1:30,y1:0,x2:30,y2:1100}));
+ group1.add(new DrawLine({x1:40,y1:0,x2:40,y2:1100}));
+ group1.add(new DrawLine({x1:50,y1:0,x2:50,y2:1100}));
+ group1.add(new DrawLine({x1:60,y1:0,x2:60,y2:1100}));
+ group1.add(new DrawLine({x1:70,y1:0,x2:70,y2:1100}));
+
+ group1.add(new DrawLine({x1:80,y1:0,x2:80,y2:1100}));
+ group1.add(new DrawLine({x1:90,y1:0,x2:90,y2:1100}));
+ group1.add(new DrawLine({x1:100,y1:0,x2:100,y2:1100}));
+*/
+ //group1.add(this.createBand({ posX: 100, posY: 20, width: zufuefband_l, height: zufuefband_b, nordSued: true, boxEnde: true })) // BA1 Zufuehrband
+ //group1.add(this.createBand({ posX: ba1_pos_hf_x, posY: ba1_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA1 Verteilband
+ //group1.add(this.createBand({ posX: ba1_pos_hf_x - (kopfband_l / 2 - verteilband_b / 2), posY: ba1_pos_hf_y - (kopfband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten
+ //group1.add(this.createBand({ posX: ba1_pos_hf_x - (kopfband_l / 2 - verteilband_b / 2), posY: ba1_pos_hf_y + verteilband_l - (kopfband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne
- group1.add(this.createBand({ posX: 340, posY: 240, width: zufuefband_l + 400, height: zufuefband_b, nordSued: false, boxStart: true, boxEnde: true }))// BA2 Zufuehrband
- group1.add(this.createBand({ posX: ba2_pos_hf_x, posY: ba2_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA1 Verteilband
- group1.add(this.createBand({ posX: ba2_pos_hf_x - (kopfband_b / 2), posY: ba2_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten
- group1.add(this.createBand({ posX: ba2_pos_hf_x + verteilband_l - (kopfband_b / 2), posY: ba2_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne
+ //group1.add(this.createBand({ posX: 340, posY: 240, width: zufuefband_l + 400, height: zufuefband_b, nordSued: false, boxStart: true, boxEnde: true }))// BA2 Zufuehrband
+ //group1.add(this.createBand({ posX: ba2_pos_hf_x, posY: ba2_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA1 Verteilband
+ //group1.add(this.createBand({ posX: ba2_pos_hf_x - (kopfband_b / 2), posY: ba2_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten
+ //group1.add(this.createBand({ posX: ba2_pos_hf_x + verteilband_l - (kopfband_b / 2), posY: ba2_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne
- group1.add(this.createBand({ posX: 360, posY: 900, width: zufuefband_l + 400, height: zufuefband_b, nordSued: false, boxStart: true, boxEnde: true }))// BA2 Zufuehrband
- group1.add(this.createBand({ posX: ba3_pos_hf_x, posY: ba3_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA1 Verteilband
- group1.add(this.createBand({ posX: ba3_pos_hf_x - (kopfband_b / 2), posY: ba3_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten
- group1.add(this.createBand({ posX: ba3_pos_hf_x + verteilband_l - (kopfband_b / 2), posY: ba3_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne
+ //group1.add(this.createBand({ posX: 360, posY: 900, width: zufuefband_l + 400, height: zufuefband_b, nordSued: false, boxStart: true, boxEnde: true }))// BA2 Zufuehrband
+ //group1.add(this.createBand({ posX: ba3_pos_hf_x, posY: ba3_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA1 Verteilband
+ //group1.add(this.createBand({ posX: ba3_pos_hf_x - (kopfband_b / 2), posY: ba3_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten
+ //group1.add(this.createBand({ posX: ba3_pos_hf_x + verteilband_l - (kopfband_b / 2), posY: ba3_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne
group1.add(zBa1Schine1);
group1.add(zBa1Schine2);
diff --git a/src/graphics/elements/drawBandOben.spec.ts b/src/graphics/elements/drawBandOben.spec.ts
index 7dd4534..263222b 100644
--- a/src/graphics/elements/drawBandOben.spec.ts
+++ b/src/graphics/elements/drawBandOben.spec.ts
@@ -12,10 +12,57 @@ describe('BandOben render', () => {
const result = new DrawBandOben().getObject({ width: 40, length: 200 }, { fromNorthToSouth, trichterStart });
expect(result.width).toBe(width);
expect(result.height).toBe(height);
- expect(result.svg[0].data).toContain('