diff --git a/src/_config/procon-navigation.ts b/src/_config/procon-navigation.ts index abc40de..c90df03 100644 --- a/src/_config/procon-navigation.ts +++ b/src/_config/procon-navigation.ts @@ -5,7 +5,10 @@ export const proconNavigation: { label: string; href?: string }[] = [ { label: 'Elemente' }, { label: 'Anzeigen', href: '/anzeigewerte' }, { label: 'Parameter', href: '/parameter' }, + { label: 'Parameterbeschriftungen', href: '/parameter-beschriftungen' }, { label: 'Buttons', href: '/steuerbuttons' }, { label: 'Texte', href: '/texte' }, + { label: 'Fehlerliste', href: '/fehlerliste' }, + { label: 'Aggregatmeldungen', href: '/aggregat-meldungen' }, { label: 'Verbindungen', href: '/verbindungen' }, ]; diff --git a/src/actions/backup/api-backup.ts b/src/actions/backup/api-backup.ts new file mode 100644 index 0000000..5861b4a --- /dev/null +++ b/src/actions/backup/api-backup.ts @@ -0,0 +1,6 @@ +'use server'; +import type {BackupData,BackupManifest} from '@/types/backup'; +const url='http://localhost:3000/rk2/backups'; +async function request(init?:RequestInit):Promise{const response=await fetch(url,{cache:'no-store',...init});const data=await response.json();if(!response.ok)throw new Error(data.message??'Datensicherung fehlgeschlagen');return data;} +export async function api_backups(){return request();} +export async function api_createBackup(native:boolean){return request({method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({native})});} diff --git a/src/actions/fehlerliste/api-aggregat-meldungen.ts b/src/actions/fehlerliste/api-aggregat-meldungen.ts new file mode 100644 index 0000000..aca08de --- /dev/null +++ b/src/actions/fehlerliste/api-aggregat-meldungen.ts @@ -0,0 +1,10 @@ +'use server'; +import {revalidatePath} from 'next/cache'; +import type {AggregatMeldungen,AggregatMeldungComparison} from '@/types/aggregat-meldungen'; +const url='http://localhost:3000/rk2/aggregat-meldungen'; +async function request(path='',method='GET',body?:unknown):Promise{const r=await fetch(url+path,{method,cache:'no-store',...(body?{headers:{'Content-Type':'application/json'},body:JSON.stringify(body)}:{})});const data=await r.json();if(!r.ok)throw new Error(Array.isArray(data.message)?data.message.join(', '):data.message??'Anfrage fehlgeschlagen');return data;} +export async function api_aggregatMeldungen(){return request();} +export async function api_saveAggregatMeldungen(table:AggregatMeldungen){const result=await request('','PUT',table);revalidatePath('/aggregat-meldungen');return result;} +export async function api_importAggregatMeldungen(input:Pick){const result=await request('/import','POST',input);revalidatePath('/aggregat-meldungen');return result;} +export async function api_compareAggregatMeldung(id:string){return request('/'+encodeURIComponent(id)+'/sync');} +export async function api_syncAggregatMeldung(id:string,input:{anlageId:string;verbindungId:string;version:string;direction:'toLocal'|'toProcon'}){const result=await request('/'+encodeURIComponent(id)+'/sync','POST',input);revalidatePath('/aggregat-meldungen');return result;} diff --git a/src/actions/fehlerliste/api-fehlerliste.ts b/src/actions/fehlerliste/api-fehlerliste.ts new file mode 100644 index 0000000..9f60966 --- /dev/null +++ b/src/actions/fehlerliste/api-fehlerliste.ts @@ -0,0 +1,25 @@ +'use server'; +import { revalidatePath } from 'next/cache'; +import type { FehlerTable } from '@/types/fehlerliste'; +const url = 'http://localhost:3000/rk2/fehlerliste'; +async function request(init?: RequestInit): Promise { + const response = await fetch(url, { cache: 'no-store', ...init }); + const data = await response.json(); + if (!response.ok) throw new Error(Array.isArray(data.message) ? data.message.join(', ') : data.message ?? 'Fehlerliste konnte nicht geladen werden.'); + return data; +} +export async function api_fehlerliste() { return request(); } +export async function api_compareFehler(id:string):Promise{ + const response=await fetch(url+'/'+encodeURIComponent(id)+'/sync',{cache:'no-store'}); + const data=await response.json();if(!response.ok)throw new Error(data.message??'Vergleich fehlgeschlagen');return data; +} +export async function api_syncFehler(id:string,dto:{anlageId:string;verbindungId:string;version:string;direction:'toLocal'|'toProcon'}):Promise{ + const response=await fetch(url+'/'+encodeURIComponent(id)+'/sync',{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json'},body:JSON.stringify(dto)}); + const data=await response.json();if(!response.ok)throw new Error(data.message??'Synchronisierung fehlgeschlagen');revalidatePath('/fehlerliste');return data; +} +export async function api_saveFehlerliste(table: FehlerTable) { + const body = JSON.stringify(table); + if (new TextEncoder().encode(body).length > 9 * 1024 * 1024) throw new Error('Die Tabelle ist zu groß (maximal 9 MB).'); + const saved = await request({ method: 'PUT', headers: { 'Content-Type': 'application/json' }, body }); + revalidatePath('/fehlerliste'); return saved; +} diff --git a/src/actions/opcua/api-io-diagnostics.ts b/src/actions/opcua/api-io-diagnostics.ts new file mode 100644 index 0000000..7d3d55f --- /dev/null +++ b/src/actions/opcua/api-io-diagnostics.ts @@ -0,0 +1,6 @@ +'use server'; +import type {IoDiagnosticConfig,DiagnosticReport} from '@/types/io-diagnostics'; +const url='http://localhost:3000/rk2/io-diagnostics'; +async function request(path='',init?:RequestInit):Promise{const r=await fetch(url+path,{cache:'no-store',...init});const data=await r.json();if(!r.ok)throw new Error(data.message??'E/A-Prüfung fehlgeschlagen');return data;} +export async function api_ioDiagnosticConfig(){return request();} +export async function api_checkIos(anlageId:string,connectionId:string){return request('/check',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({anlageId,connectionId})});} diff --git a/src/actions/opcua/api-io-simulation.ts b/src/actions/opcua/api-io-simulation.ts new file mode 100644 index 0000000..3784b26 --- /dev/null +++ b/src/actions/opcua/api-io-simulation.ts @@ -0,0 +1,12 @@ +'use server'; +import type {SimulationData,SimulationPlan,SimulationProposal,SimulationRuntime,SimulationSelection} from '@/types/io-simulation'; +const url='http://localhost:3000/rk2/io-simulation'; +async function request(path='',method='GET',body?:unknown):Promise{const r=await fetch(url+path,{method,cache:'no-store',...(body?{headers:{'Content-Type':'application/json'},body:JSON.stringify(body)}:{})});const data=await r.json();if(!r.ok)throw new Error(Array.isArray(data.message)?data.message.join(', '):data.message??'Simulationsanfrage fehlgeschlagen');return data;} +export async function api_simulation(id?:string){return request(id?'?connectionId='+encodeURIComponent(id):'');} +export async function api_saveSimulation(plan:SimulationPlan){return request('','PUT',plan);} +export async function api_previewSimulation(input:SimulationSelection){return request<{rows:SimulationProposal[];token:string}>('/preview','POST',input);} +export async function api_applySimulation(input:SimulationSelection&{token:string;targetIds:string[]}){return request('/apply','POST',input);} +export async function api_startSimulation(input:SimulationSelection){return request('/start','POST',input);} +export async function api_stopSimulation(input:{anlageId:string;connectionId:string}){return request('/stop','POST',input);} +export async function api_simulationState(anlageId:string,connectionId:string){return request('/runtime?'+new URLSearchParams({anlageId,connectionId}));} +export async function api_manualSimulation(input:{anlageId:string;connectionId:string;targetId:string;value:boolean}){return request('/manual','POST',input);} diff --git a/src/actions/opcua/api-opcua.ts b/src/actions/opcua/api-opcua.ts new file mode 100644 index 0000000..7cda3e3 --- /dev/null +++ b/src/actions/opcua/api-opcua.ts @@ -0,0 +1,22 @@ +'use server'; +import { revalidatePath } from 'next/cache'; +import type { OpcConfiguration, OpcEndpoint, OpcNode, OpcValue } from '@/types/opcua'; +const url = 'http://localhost:3000/rk2/opcua'; +async function request(path = '', init?: RequestInit): Promise { + const response = await fetch(url + path, { cache: 'no-store', ...init }); + const data = await response.json(); + if (!response.ok) throw new Error(Array.isArray(data.message) ? data.message.join(', ') : data.message ?? 'OPC-Anfrage fehlgeschlagen'); + return data; +} +export async function api_opcConfiguration() { return request(); } +export async function api_saveOpcConfiguration(data: OpcConfiguration) { + const saved = await request('', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); + revalidatePath('/sps/opcua'); return saved; +} +async function operation(id: string, action: string, data: object) { + return request('/' + encodeURIComponent(id) + '/' + action, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); +} +export async function api_opcEndpoints(anlageId: string, id: string) { return operation(id, 'endpoints', { anlageId }); } +export async function api_opcTest(anlageId: string, id: string) { return operation<{ connected: boolean; testedAt: string; status: string; serverTime: unknown }>(id, 'test', { anlageId }); } +export async function api_opcBrowse(anlageId: string, id: string, nodeId: string) { return operation<{ nodes: OpcNode[]; truncated: boolean }>(id, 'browse', { anlageId, nodeId }); } +export async function api_opcRead(anlageId: string, id: string, nodeIds: string[]) { return operation(id, 'read', { anlageId, nodeIds }); } diff --git a/src/actions/opcua/api-structures.ts b/src/actions/opcua/api-structures.ts new file mode 100644 index 0000000..8c783e6 --- /dev/null +++ b/src/actions/opcua/api-structures.ts @@ -0,0 +1,27 @@ +'use server'; +import { revalidatePath } from 'next/cache'; +import type { OpcStructure, StructuresData, StructureWriteResult } from '@/types/opcua-structures'; +const url = 'http://localhost:3000/rk2/opcua-structures'; +async function request(path = '', method = 'GET', body?: unknown): Promise { + const response = await fetch(url + path, { method, cache: 'no-store', ...(body ? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}) }); + const result = await response.json(); + if (!response.ok) throw new Error(Array.isArray(result.message) ? result.message.join(', ') : result.message ?? 'Strukturanfrage fehlgeschlagen'); + return result; +} +export async function api_structures() { return request(); } +export async function api_createStructure(input: Pick) { + const result = await request('', 'POST', input); revalidatePath('/sps/opcua-strukturen'); return result; +} +export async function api_removeStructure(row: OpcStructure) { await request('/' + encodeURIComponent(row.name), 'DELETE', { anlageId: row.anlageId, id: row.id, version: row.version }); revalidatePath('/sps/opcua-strukturen'); } +export async function api_writeStructure(row: OpcStructure, values: Record) { + try { return await request('/' + encodeURIComponent(row.name) + '/write', 'POST', { anlageId: row.anlageId, id: row.id, version: row.version, values }); } + catch (error) { throw new Error((error instanceof Error ? error.message : 'Schreiben fehlgeschlagen') + ' Keine automatische Wiederholung. Bei Verbindungsfehlern ist das Schreibergebnis eventuell unbekannt.'); } +} + +export async function api_previewStructureArray(input: import('@/types/opcua-structures').ArrayImportInput) { + return request('/array/preview', 'POST', input); +} +export async function api_importStructureArray(input: import('@/types/opcua-structures').ArrayImportInput & { token: string }) { + const result = await request<{ created: number; skipped: number; invalid: number; failures: { name: string; message: string }[]; notProcessed: number }>('/array/import', 'POST', input); + revalidatePath('/sps/opcua-strukturen'); return result; +} diff --git a/src/actions/parameter/api-element-parameter.ts b/src/actions/parameter/api-element-parameter.ts new file mode 100644 index 0000000..c553f01 --- /dev/null +++ b/src/actions/parameter/api-element-parameter.ts @@ -0,0 +1,11 @@ +'use server'; +import {revalidatePath} from 'next/cache'; +import type {ElementParameterTable,ElementParameterComparison,ParameterKind} from '@/types/element-parameter'; +const url='http://localhost:3000/rk2/element-parameter/'; +async function request(kind:ParameterKind,path='',method='GET',body?:unknown):Promise{const r=await fetch(url+kind+path,{method,cache:'no-store',...(body?{headers:{'Content-Type':'application/json'},body:JSON.stringify(body)}:{})});const data=await r.json();if(!r.ok)throw new Error(Array.isArray(data.message)?data.message.join(', '):data.message??'Parameteranfrage fehlgeschlagen');return data;} +function revalidate(kind:ParameterKind){revalidatePath(kind==='beschriftungen'?'/parameter-beschriftungen':'/parameter/'+kind);} +export async function api_elementParameters(kind:ParameterKind){return request(kind);} +export async function api_saveElementParameters(table:ElementParameterTable){const body=JSON.stringify(table);if(new TextEncoder().encode(body).length>9*1024*1024)throw new Error('Tabelle zu groß (maximal 9 MB)');const result=await request(table.kind,'','PUT',table);revalidate(table.kind);return result;} +export async function api_importElementParameters(table:ElementParameterTable){const result=await request(table.kind,'/import','POST',{anlageId:table.anlageId,verbindungId:table.verbindungId,version:table.version});revalidate(table.kind);return result;} +export async function api_compareElementParameter(kind:ParameterKind,id:string){return request(kind,'/'+encodeURIComponent(id)+'/sync');} +export async function api_syncElementParameter(kind:ParameterKind,id:string,input:{anlageId:string;verbindungId:string;version:string;direction:'toLocal'|'toProcon'}){const result=await request(kind,'/'+encodeURIComponent(id)+'/sync','POST',input);revalidate(kind);return result;} diff --git a/src/actions/parameter/api-parameter.ts b/src/actions/parameter/api-parameter.ts index 1ce7b00..fa044a0 100644 --- a/src/actions/parameter/api-parameter.ts +++ b/src/actions/parameter/api-parameter.ts @@ -9,6 +9,12 @@ async function request(init?: RequestInit): Promise { return data; } export async function api_parameters() { return request(); } +export async function api_deleteProconParameters(anlageId: string, version: number): Promise<{ deleted: number }> { + const response = await fetch(url + '/delete-procon', { method: 'POST', cache: 'no-store', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ anlageId, version }) }); + const result = await response.json(); + if (!response.ok) throw new Error(Array.isArray(result.message) ? result.message.join(', ') : result.message ?? 'Löschen fehlgeschlagen'); + revalidatePath('/parameter'); return result; +} export async function api_saveParameters(table: ParameterTable) { const body = JSON.stringify(table); if (new TextEncoder().encode(body).length > 9 * 1024 * 1024) throw new Error('Die Tabelle ist zu groß (maximal 9 MB).'); diff --git a/src/actions/rk2/api-compTypes.ts b/src/actions/rk2/api-compTypes.ts index 50a67ba..d9c699c 100644 --- a/src/actions/rk2/api-compTypes.ts +++ b/src/actions/rk2/api-compTypes.ts @@ -2,6 +2,7 @@ import { ComponentDefaults, ComponentTypeDefinition } from "@/types/anlagen/comp import { SignalType } from "@/types/anlagen/signals"; export const componentTypeDefinitions: ComponentTypeDefinition[] = [ + { type: "Allgemein", label: "Allgemein / freie Signale", properties: [] }, { type: "Antrieb", label: "Antrieb", @@ -259,6 +260,7 @@ export const componentTypeDefinitions: ComponentTypeDefinition[] = [ ] export const componentDefaults: ComponentDefaults[] = [ + { type: "Allgemein", name: "Allgemein", signals: [] }, { type: "Antrieb", name: "M", diff --git a/src/actions/sensoren/api-digital-opc.ts b/src/actions/sensoren/api-digital-opc.ts new file mode 100644 index 0000000..661c5c5 --- /dev/null +++ b/src/actions/sensoren/api-digital-opc.ts @@ -0,0 +1,24 @@ +'use server'; +import { revalidatePath } from 'next/cache'; +import type { DigitalOpcData, DigitalOpcBinding, DigitalSensorLive, StructureReference } from '@/types/digital-opc'; +const url = 'http://localhost:3000/rk2/digital-opc'; +async function request(path = '', init?: RequestInit): Promise { + const response = await fetch(url + path, { cache: 'no-store', ...init }); const data = await response.json(); + if (!response.ok) throw new Error(Array.isArray(data.message) ? data.message.join(', ') : data.message ?? 'OPC-Zuordnung fehlgeschlagen'); return data; +} +export async function api_digitalOpc() { return request(); } +export async function api_saveDigitalOpc(sensorId: string, input: { anlageId: string; sensorVersion: number; version: number; ist: StructureReference | null; soll: StructureReference | null }) { + const result = await request('/' + encodeURIComponent(sensorId), { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(input) }); + revalidatePath('/sensoren-digital/live'); return result; +} +export async function api_digitalSensorLive(sensorId: string, anlageId: string) { return request('/' + encodeURIComponent(sensorId) + '/live?anlageId=' + encodeURIComponent(anlageId)); } + +export async function api_digitalSensorControl(sensorId: string, anlageId: string) { + return request<{ bindingRevision: number; structure: import('@/types/opcua-structures').OpcStructure }>('/' + encodeURIComponent(sensorId) + '/control?anlageId=' + encodeURIComponent(anlageId)); +} +export async function api_writeDigitalSensor(sensorId: string, input: { anlageId: string; bindingRevision: number; structureId: string; structureVersion: number; values: Record }) { + try { return await request('/' + encodeURIComponent(sensorId) + '/write', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(input) }); } + catch (cause) { throw new Error((cause instanceof Error ? cause.message : 'Schreiben fehlgeschlagen') + ' Keine automatische Wiederholung; bei Verbindungsabbruch kann das Ergebnis unbekannt sein.'); } +} + +export async function api_digitalLiveScene() { return request('/scene'); } diff --git a/src/actions/sensoren/api-motor-opc.ts b/src/actions/sensoren/api-motor-opc.ts new file mode 100644 index 0000000..3db06ea --- /dev/null +++ b/src/actions/sensoren/api-motor-opc.ts @@ -0,0 +1,7 @@ +'use server'; +import type {MotorOpcData,MotorBinding} from '@/types/motor-opc'; +const url='http://localhost:3000/rk2/motor-opc'; +async function request(path='',init?:RequestInit):Promise{const r=await fetch(url+path,{cache:'no-store',...init});const d=await r.json();if(!r.ok)throw new Error(d.message??'Motorzuordnung fehlgeschlagen');return d;} +export async function api_motorOpc(){return request();} +export async function api_motorCommand(componentId:string,input:{anlageId:string;revision:number;controlId:string;command:string}){return request<{results:{field:string;good:boolean;status:string}[]}>('/'+encodeURIComponent(componentId)+'/command',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(input)});} +export async function api_saveMotorOpc(componentId:string,input:{anlageId:string;version:number;structure:{id:string;name:string}|null;field:'M1'|'M2';operatingMode?:{id:string;name:string}|null;parameters?:{id:string;name:string}|null;control?:{id:string;name:string}|null}){return request('/'+encodeURIComponent(componentId),{method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify(input)});} diff --git a/src/app/aggregat-meldungen/page.tsx b/src/app/aggregat-meldungen/page.tsx new file mode 100644 index 0000000..606b764 --- /dev/null +++ b/src/app/aggregat-meldungen/page.tsx @@ -0,0 +1,3 @@ +import {api_aggregatMeldungen} from '@/actions/fehlerliste/api-aggregat-meldungen'; +import AggregatMeldungenTable from '@/components/fehlerliste/aggregatMeldungenTable'; +export default async function Page(){try{return ;}catch(cause){return

{cause instanceof Error?cause.message:'Aggregatmeldungen konnten nicht geladen werden.'}

;}} diff --git a/src/app/datensicherung/[id]/datei/route.ts b/src/app/datensicherung/[id]/datei/route.ts new file mode 100644 index 0000000..157b842 --- /dev/null +++ b/src/app/datensicherung/[id]/datei/route.ts @@ -0,0 +1,8 @@ +export async function GET(request:Request,{params}:{params:Promise<{id:string}>}){ + const {id}=await params,file=new URL(request.url).searchParams.get('file')??'manifest.json'; + try{const response=await fetch('http://localhost:3000/rk2/backups/'+encodeURIComponent(id)+'/file?file='+encodeURIComponent(file),{cache:'no-store'}); + if(!response.ok)return new Response('Sicherungsdatei nicht verfügbar',{status:response.status}); + const filename=file.split('/').pop()?.replace(/[^A-Za-z0-9_.-]/g,'_')??'backup.json'; + return new Response(response.body,{headers:{'Content-Type':response.headers.get('Content-Type')??'application/json','Content-Disposition':'attachment; filename="'+filename+'"','Cache-Control':'no-store'}}); + }catch{return new Response('Keine Verbindung zum Backend',{status:502});} +} diff --git a/src/app/datensicherung/page.tsx b/src/app/datensicherung/page.tsx new file mode 100644 index 0000000..fb8d636 --- /dev/null +++ b/src/app/datensicherung/page.tsx @@ -0,0 +1,3 @@ +import {api_backups} from '@/actions/backup/api-backup'; +import BackupPanel from '@/components/backup/backupPanel'; +export default async function Page(){try{return ;}catch(cause){return

{cause instanceof Error?cause.message:'Datensicherungen konnten nicht geladen werden.'}

;}} diff --git a/src/app/fehlerliste/bearbeiten/page.tsx b/src/app/fehlerliste/bearbeiten/page.tsx new file mode 100644 index 0000000..7388946 --- /dev/null +++ b/src/app/fehlerliste/bearbeiten/page.tsx @@ -0,0 +1,6 @@ +import { api_fehlerliste } from '@/actions/fehlerliste/api-fehlerliste'; +import FehlerTable from '@/components/fehlerliste/fehlerTable'; +export default async function Page() { + try { return ; } + catch (cause) { return

{cause instanceof Error ? cause.message : 'Fehlerliste konnte nicht geladen werden.'}

; } +} diff --git a/src/app/fehlerliste/export/route.ts b/src/app/fehlerliste/export/route.ts new file mode 100644 index 0000000..cf6d1f8 --- /dev/null +++ b/src/app/fehlerliste/export/route.ts @@ -0,0 +1,8 @@ +export async function GET() { + try { + const response = await fetch('http://localhost:3000/rk2/fehlerliste/export', { cache: 'no-store' }); + if (!response.ok) return new Response('Fehlerlisten-Export fehlgeschlagen', { status: 502 }); + return new Response(response.body, { headers: { 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'Content-Disposition': 'attachment; filename="Fehlerliste.xlsx"', 'Cache-Control': 'no-store' } }); + } catch { return new Response('Keine Verbindung zum Backend', { status: 502 }); } +} diff --git a/src/app/fehlerliste/page.tsx b/src/app/fehlerliste/page.tsx new file mode 100644 index 0000000..9cd65e5 --- /dev/null +++ b/src/app/fehlerliste/page.tsx @@ -0,0 +1,6 @@ +import { api_fehlerliste } from '@/actions/fehlerliste/api-fehlerliste'; +import FehlerTable from '@/components/fehlerliste/fehlerTable'; +export default async function Page() { + try { return ; } + catch (cause) { return

{cause instanceof Error ? cause.message : 'Fehlerliste konnte nicht geladen werden.'}

; } +} diff --git a/src/app/live-anlage/events/route.ts b/src/app/live-anlage/events/route.ts new file mode 100644 index 0000000..9196dff --- /dev/null +++ b/src/app/live-anlage/events/route.ts @@ -0,0 +1,11 @@ +export const dynamic = 'force-dynamic'; +export const runtime = 'nodejs'; +export async function GET(request: Request) { + const params = new URL(request.url).searchParams, anlageId = params.get('anlageId'), token = params.get('token'); + if (!anlageId || !token || !/^[a-f0-9]{64}$/.test(token)) return new Response('Anlagenbild fehlt', { status: 400 }); + try { + const response = await fetch('http://localhost:3000/rk2/digital-opc/scene/events?anlageId=' + encodeURIComponent(anlageId) + '&token=' + encodeURIComponent(token), { cache: 'no-store', signal: request.signal }); + if (!response.ok) return new Response('Live-Verbindung nicht erreichbar', { status: response.status }); + return new Response(response.body, { headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache, no-transform', 'X-Accel-Buffering': 'no' } }); + } catch { return new Response('Backend nicht erreichbar', { status: 502 }); } +} diff --git a/src/app/live-anlage/page.tsx b/src/app/live-anlage/page.tsx new file mode 100644 index 0000000..b0359f2 --- /dev/null +++ b/src/app/live-anlage/page.tsx @@ -0,0 +1,6 @@ +import { api_digitalLiveScene } from '@/actions/sensoren/api-digital-opc'; +import LiveAnlage from '@/components/live-anlage/liveAnlage'; +export default async function Page() { + try { return ; } + catch (cause) { return

{cause instanceof Error ? cause.message : 'Anlagenbild nicht erreichbar'}

; } +} diff --git a/src/app/motor-opc/page.tsx b/src/app/motor-opc/page.tsx new file mode 100644 index 0000000..7e8a0c7 --- /dev/null +++ b/src/app/motor-opc/page.tsx @@ -0,0 +1,3 @@ +import {api_motorOpc} from '@/actions/sensoren/api-motor-opc'; +import MotorOpcConfig from '@/components/opcua/motorOpcConfig'; +export default async function Page({searchParams}:{searchParams:Promise<{componentId?:string}>}){try{const [data,params]=await Promise.all([api_motorOpc(),searchParams]);return ;}catch(cause){return

{cause instanceof Error?cause.message:'Motorzuordnung nicht erreichbar'}

;}} diff --git a/src/app/parameter-beschriftungen/page.tsx b/src/app/parameter-beschriftungen/page.tsx new file mode 100644 index 0000000..f7f08c5 --- /dev/null +++ b/src/app/parameter-beschriftungen/page.tsx @@ -0,0 +1,3 @@ +import {api_elementParameters} from '@/actions/parameter/api-element-parameter'; +import ElementParameterTable from '@/components/parameter/elementParameterTable'; +export default async function Page(){try{return ;}catch(cause){return

{cause instanceof Error?cause.message:'Beschriftungen konnten nicht geladen werden.'}

;}} diff --git a/src/app/parameter/[kind]/page.tsx b/src/app/parameter/[kind]/page.tsx new file mode 100644 index 0000000..17d53ec --- /dev/null +++ b/src/app/parameter/[kind]/page.tsx @@ -0,0 +1,4 @@ +import {notFound} from 'next/navigation'; +import {api_elementParameters} from '@/actions/parameter/api-element-parameter'; +import ElementParameterTable from '@/components/parameter/elementParameterTable'; +export default async function Page({params}:{params:Promise<{kind:string}>}){const {kind}=await params;if(kind!=='aggregate'&&kind!=='analog'&&kind!=='digital')notFound();try{return ;}catch(cause){return

{cause instanceof Error?cause.message:'Parameter konnten nicht geladen werden.'}

;}} diff --git a/src/app/sensoren-digital/live/page.tsx b/src/app/sensoren-digital/live/page.tsx new file mode 100644 index 0000000..3247203 --- /dev/null +++ b/src/app/sensoren-digital/live/page.tsx @@ -0,0 +1,6 @@ +import { api_digitalOpc } from '@/actions/sensoren/api-digital-opc'; +import DigitalLiveStatus from '@/components/sensoren/digitalLiveStatus'; +export default async function Page({ searchParams }: { searchParams: Promise<{ sensorId?: string }> }) { + try { const [initial, params] = await Promise.all([api_digitalOpc(), searchParams]); return ; } + catch (cause) { return

{cause instanceof Error ? cause.message : 'Live-Status konnte nicht geladen werden'}

; } +} diff --git a/src/app/sps/io-diagnose/events/route.ts b/src/app/sps/io-diagnose/events/route.ts new file mode 100644 index 0000000..93c6d35 --- /dev/null +++ b/src/app/sps/io-diagnose/events/route.ts @@ -0,0 +1,8 @@ +export const dynamic='force-dynamic'; +export const runtime='nodejs'; +export async function GET(request:Request){ + const params=new URL(request.url).searchParams; + if(!['anlageId','connectionId','unitId','token'].every(k=>params.get(k))||!/^[a-f0-9]{64}$/.test(params.get('token')??''))return new Response('Prüfung und Unit fehlen',{status:400}); + const query=new URLSearchParams();for(const key of ['anlageId','connectionId','unitId','token'])query.set(key,params.get(key)!); + try{const r=await fetch('http://localhost:3000/rk2/io-diagnostics/events?'+query,{cache:'no-store',signal:request.signal});if(!r.ok)return new Response('Live-Verbindung nicht verfügbar',{status:r.status});return new Response(r.body,{headers:{'Content-Type':'text/event-stream','Cache-Control':'no-cache, no-transform','X-Accel-Buffering':'no'}});}catch{return new Response('Backend nicht erreichbar',{status:502});} +} diff --git a/src/app/sps/io-diagnose/page.tsx b/src/app/sps/io-diagnose/page.tsx new file mode 100644 index 0000000..16c3123 --- /dev/null +++ b/src/app/sps/io-diagnose/page.tsx @@ -0,0 +1,3 @@ +import {api_ioDiagnosticConfig} from '@/actions/opcua/api-io-diagnostics'; +import IoDiagnostics from '@/components/opcua/ioDiagnostics'; +export default async function Page(){try{return ;}catch(cause){return

{cause instanceof Error?cause.message:'E/A-Diagnose konnte nicht geladen werden.'}

;}} diff --git a/src/app/sps/opcua-strukturen/live/route.ts b/src/app/sps/opcua-strukturen/live/route.ts new file mode 100644 index 0000000..8ae2a19 --- /dev/null +++ b/src/app/sps/opcua-strukturen/live/route.ts @@ -0,0 +1,15 @@ +export const dynamic = 'force-dynamic'; +export const runtime = 'nodejs'; +export async function GET(request: Request) { + const params = new URL(request.url).searchParams; + const name = params.get('name'), anlageId = params.get('anlageId'); + if (!name || !anlageId || !/^[A-Za-z_][A-Za-z0-9_]{0,79}$/.test(name)) return new Response('Struktur fehlt', { status: 400 }); + const sensorId = params.get('sensorId'), expectedId = params.get('expectedId'); + if (sensorId && !/^[\w-]{1,80}$/.test(sensorId)) return new Response('Ungültiger Sensor', { status: 400 }); + try { + const target = sensorId ? 'http://localhost:3000/rk2/digital-opc/' + encodeURIComponent(sensorId) + '/events?anlageId=' + encodeURIComponent(anlageId) + '&expectedId=' + encodeURIComponent(expectedId ?? '') : 'http://localhost:3000/rk2/opcua-structures/' + encodeURIComponent(name) + '/live?anlageId=' + encodeURIComponent(anlageId) + '&expectedId=' + encodeURIComponent(expectedId ?? ''); + const response = await fetch(target, { cache: 'no-store', signal: request.signal }); + if (!response.ok) return new Response('Live-Verbindung fehlgeschlagen', { status: response.status }); + return new Response(response.body, { headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache, no-transform', 'X-Accel-Buffering': 'no' } }); + } catch { return new Response('Backend nicht erreichbar', { status: 502 }); } +} diff --git a/src/app/sps/opcua-strukturen/page.tsx b/src/app/sps/opcua-strukturen/page.tsx new file mode 100644 index 0000000..8ce5e07 --- /dev/null +++ b/src/app/sps/opcua-strukturen/page.tsx @@ -0,0 +1,10 @@ +import { api_opcConfiguration } from '@/actions/opcua/api-opcua'; +import { api_structures } from '@/actions/opcua/api-structures'; +import StructuresPanel from '@/components/opcua/structuresPanel'; +export default async function Page() { + try { + const [initial, connections] = await Promise.all([api_structures(), api_opcConfiguration()]); + if (initial.anlageId !== connections.anlageId) return

Anlage gewechselt. Bitte neu laden.

; + return ; + } catch (cause) { return

{cause instanceof Error ? cause.message : 'Strukturen nicht erreichbar'}

; } +} diff --git a/src/app/sps/opcua/certificate/route.ts b/src/app/sps/opcua/certificate/route.ts new file mode 100644 index 0000000..c9bf2e1 --- /dev/null +++ b/src/app/sps/opcua/certificate/route.ts @@ -0,0 +1,10 @@ +export async function GET(request: Request) { + const params = new URL(request.url).searchParams; + const id = params.get('id'), anlageId = params.get('anlageId'); + if (!id || !anlageId) return new Response('Verbindung fehlt', { status: 400 }); + try { + const response = await fetch('http://localhost:3000/rk2/opcua/' + encodeURIComponent(id) + '/certificate?anlageId=' + encodeURIComponent(anlageId), { cache: 'no-store' }); + if (!response.ok) return new Response('Zertifikat konnte nicht geladen werden. Anlage und Verbindung pruefen.', { status: response.status }); + return new Response(response.body, { headers: { 'Content-Type': 'application/x-pem-file', 'Content-Disposition': 'attachment; filename="RK-OpcUaClient.pem"', 'Cache-Control': 'no-store' } }); + } catch { return new Response('Backend nicht erreichbar', { status: 502 }); } +} diff --git a/src/app/sps/opcua/page.tsx b/src/app/sps/opcua/page.tsx new file mode 100644 index 0000000..3972f45 --- /dev/null +++ b/src/app/sps/opcua/page.tsx @@ -0,0 +1,6 @@ +import { api_opcConfiguration } from '@/actions/opcua/api-opcua'; +import OpcPanel from '@/components/opcua/opcPanel'; +export default async function Page() { + try { return ; } + catch (cause) { return

{cause instanceof Error ? cause.message : 'OPC-Konfiguration nicht erreichbar'}

; } +} diff --git a/src/app/sps/page.tsx b/src/app/sps/page.tsx index e8721ce..0fc7e21 100644 --- a/src/app/sps/page.tsx +++ b/src/app/sps/page.tsx @@ -1,6 +1,6 @@ import Link from 'next/link'; export default function Page() { return

SPS-Exporte

Tabgetrennte Listen aus den gespeicherten Excel-Zuordnungen zum Kopieren.

-
    {[['aggregate', 'Aggregate'], ['sensoren-digital', 'Sensoren Digital'], ['sensoren-analog', 'Sensoren Analog']].map(([path, label]) =>
  • {label}
  • )}
+
    {[['opcua', 'OPC-UA-Verbindungen'], ['aggregate', 'Aggregate'], ['sensoren-digital', 'Sensoren Digital'], ['sensoren-analog', 'Sensoren Analog']].map(([path, label]) =>
  • {label}
  • )}
; } diff --git a/src/app/sps/simulation/page.tsx b/src/app/sps/simulation/page.tsx new file mode 100644 index 0000000..5ae5de0 --- /dev/null +++ b/src/app/sps/simulation/page.tsx @@ -0,0 +1,3 @@ +import {api_simulation} from '@/actions/opcua/api-io-simulation'; +import IoSimulation from '@/components/opcua/ioSimulation'; +export default async function Page(){try{return ;}catch(cause){return

{cause instanceof Error?cause.message:'Simulation konnte nicht geladen werden.'}

;}} diff --git a/src/components/backup/backupPanel.tsx b/src/components/backup/backupPanel.tsx new file mode 100644 index 0000000..baafbc6 --- /dev/null +++ b/src/components/backup/backupPanel.tsx @@ -0,0 +1,26 @@ +'use client'; +import {useEffect,useState} from 'react'; +import {Button} from '@/components/ui/button'; +import {api_backups,api_createBackup} from '@/actions/backup/api-backup'; +import type {BackupData} from '@/types/backup'; +const statuses={running:'Läuft',complete:'Abgeschlossen',failed:'Fehlgeschlagen'}; +function download(id:string,file:string){return '/datensicherung/'+encodeURIComponent(id)+'/datei?file='+encodeURIComponent(file);} +export default function BackupPanel({initial}:{initial:BackupData}){ + const [data,setData]=useState(initial),[native,setNative]=useState(initial.nativeAvailable),[busy,setBusy]=useState(false),[error,setError]=useState(''); + useEffect(()=>{ + if(!data.active)return;let active=true;let timer:ReturnType; + const poll=async()=>{try{const next=await api_backups();if(active){setData(next);setError('');}}catch(cause){if(active)setError(cause instanceof Error?cause.message:'Status konnte nicht geladen werden');}finally{if(active)timer=setTimeout(()=>void poll(),2000);}}; + timer=setTimeout(()=>void poll(),2000);return()=>{active=false;clearTimeout(timer);}; + },[data.active?.id]); + async function refresh(){setBusy(true);setError('');try{setData(await api_backups());}catch(cause){setError(cause instanceof Error?cause.message:'Laden fehlgeschlagen');}finally{setBusy(false);}} + async function start(){if(busy||data.active)return;setBusy(true);setError('');try{const backup=await api_createBackup(native&&data.nativeAvailable);setData(old=>({...old,active:backup,backups:[backup,...old.backups]}));}catch(cause){setError(cause instanceof Error?cause.message:'Sicherung fehlgeschlagen');}finally{setBusy(false);}} + return

MongoDB-Datensicherung

Sichert alle Collections der Datenbanken rk und rk2 als MongoDB Extended JSON, einschließlich ObjectIds, Datumswerten, Einstellungen und Zugangsdaten. Pro Sicherung wird ein neuer Ordner angelegt.

+

Ablage auf dem Backend-Rechner: {data.directory}

+
+ {!data.nativeAvailable&&

mongodump ist nicht installiert oder nicht im Suchpfad. Die vollständige JSON-Sicherung ist verfügbar. Für die zusätzliche native Sicherung MongoDB Database Tools bereitstellen und das Backend neu starten.

} +

Während der Sicherung möglichst keine Daten bearbeiten oder importieren: Die laufende MongoDB wird ohne gemeinsamen Zeitpunkt über beide Datenbanken gelesen. Grafikdateien, OPC-Zertifikate und die ProCon-SQL-Datenbank sind separate Dateien bzw. Systeme. Kopiere den Sicherungsordner für Notfälle auf ein weiteres Laufwerk.

+ {data.active&&

Sicherung läuft: {data.active.files.length} Collections, {data.active.totalDocuments} Dokumente geschrieben.

} + {error&&

{error}

} +
{['Beginn (UTC)','Status','Collections','Dokumente','Native Sicherung','Dateien'].map(label=>)}{data.backups.map(backup=>)}
{label}
{backup.startedAt.replace('T',' ').replace('Z','')}{statuses[backup.status]}{backup.error&&

{backup.error}

}
{backup.files.length}{backup.totalDocuments}{backup.native.status==='complete'?'Abgeschlossen':backup.native.status==='skipped'?'Nicht angefordert':backup.native.status==='running'?'Läuft':'Fehlgeschlagen'}
Dateien und Ordner

{backup.directory}

Übersicht herunterladen
{backup.files.map(file=>
{file.database} / {file.collection} ({file.documents} Dokumente) · Metadaten
)}{backup.native.files.map(file=>{file})}
{!data.backups.length&&

Noch keine Sicherung vorhanden.

}
+
; +} diff --git a/src/components/fehlerliste/aggregatMeldungenTable.tsx b/src/components/fehlerliste/aggregatMeldungenTable.tsx new file mode 100644 index 0000000..7ea25a3 --- /dev/null +++ b/src/components/fehlerliste/aggregatMeldungenTable.tsx @@ -0,0 +1,38 @@ +'use client'; +import {useEffect,useState} from 'react'; +import {Button} from '@/components/ui/button'; +import {Input} from '@/components/ui/input'; +import Modal from '@/components/ui/Modal'; +import {api_aggregatMeldungen,api_saveAggregatMeldungen,api_importAggregatMeldungen,api_compareAggregatMeldung,api_syncAggregatMeldung} from '@/actions/fehlerliste/api-aggregat-meldungen'; +import type {AggregatMeldungen,AggregatMeldung,AggregatMeldungComparison} from '@/types/aggregat-meldungen'; +export default function AggregatMeldungenTable({initial}:{initial:AggregatMeldungen}){ + const [data,setData]=useState(initial),[filter,setFilter]=useState(''),[marked,setMarked]=useState([]),[dirty,setDirty]=useState(false),[busy,setBusy]=useState(false),[error,setError]=useState(''),[message,setMessage]=useState(''); + const [preview,setPreview]=useState<{row:AggregatMeldung;comparison?:AggregatMeldungComparison;error?:string;result?:string}[]|null>(null),[completed,setCompleted]=useState(false); + const visible=data.rows.filter(r=>`${r.antriebId} ${r.aggregatName} ${r.bit} ${r.meldung}`.toLowerCase().includes(filter.toLowerCase())).sort((a,b)=>a.antriebId-b.antriebId||a.bit-b.bit); + useEffect(()=>{if(!dirty)return;const warn=(e:BeforeUnloadEvent)=>{e.preventDefault();e.returnValue='';};window.addEventListener('beforeunload',warn);return()=>window.removeEventListener('beforeunload',warn);},[dirty]); + function edit(id:string,patch:Partial){setData({...data,rows:data.rows.map(r=>r.id===id?{...r,...patch}:r)});setDirty(true);setMessage('');} + async function run(action:'save'|'load'|'import'){ + if(busy||dirty&&action!=='save')return;setBusy(true);setError('');setMessage(''); + try{const next=action==='save'?await api_saveAggregatMeldungen(data):action==='import'?await api_importAggregatMeldungen({anlageId:data.anlageId,verbindungId:data.verbindungId,version:data.version}):await api_aggregatMeldungen();setData(next);setDirty(false);setMessage(action==='import'?`${next.rows.length-data.rows.length} neue Meldungen übernommen. Vorhandene Texte beibehalten.`:action==='save'?'Gespeichert.':'Neu geladen.');}catch(cause){setError(cause instanceof Error?cause.message:'Aktion fehlgeschlagen');}finally{setBusy(false);} + } + async function compare(rows:AggregatMeldung[]){if(busy||dirty)return;setBusy(true);setError('');setCompleted(false);setPreview([]);const next:NonNullable=[]; + try{for(const row of rows){try{next.push({row,comparison:await api_compareAggregatMeldung(row.id)});}catch(cause){next.push({row,error:cause instanceof Error?cause.message:'Vergleich fehlgeschlagen'});}setPreview([...next]);}}finally{setBusy(false);} + } + async function apply(direction:'toLocal'|'toProcon'){ + if(busy||!preview||completed)return;setBusy(true);let ok=0; + try{for(const item of preview){if(!item.comparison)continue; + try{const expected=item.comparison,current=await api_compareAggregatMeldung(item.row.id); + if(current.anlageId!==expected.anlageId||current.verbindungId!==expected.verbindungId||JSON.stringify(current.local)!==JSON.stringify(expected.local)||JSON.stringify(current.remote)!==JSON.stringify(expected.remote))throw new Error('Daten seit der Vorschau geändert. Neu vergleichen.'); + setData(await api_syncAggregatMeldung(item.row.id,{anlageId:current.anlageId,verbindungId:current.verbindungId,version:current.version,direction}));item.result='Übernommen';ok++; + }catch(cause){item.result=cause instanceof Error?cause.message:'Übernahme fehlgeschlagen';}setPreview([...preview]); + }setCompleted(true);setMessage(`${ok} Meldungen übernommen.`);}finally{setBusy(false);} + } + return

Aggregatmeldungen

Von ProCon beim Aggregatimport erzeugte Meldungen. Zuordnung über SPS-Antrieb-ID und Typ = Meldebit (0–31). Texte und SelbstQuittierend werden lokal bearbeitet und bei Bedarf synchronisiert.

+
+ setFilter(e.target.value)}/> +
Auswahl bleibt beim Filtern bestehen.
+
{['Auswahl','Antrieb-ID','Aggregat','Typ / Bit','Meldung','SelbstQuittierend','Aktion'].map(t=>)}{visible.map(r=>)}
{t}
setMarked(old=>e.target.checked?[...old,r.id]:old.filter(id=>id!==r.id))}/>{r.antriebId}{r.aggregatName}{r.bit}edit(r.id,{meldung:e.target.value})}/>edit(r.id,{selbstQuittierend:e.target.checked})}/>
{!visible.length&&

Keine Meldungen vorhanden. Bei der ersten Nutzung Meldungen aus ProCon übernehmen.

}
+ {preview&&{if(!busy)setPreview(null);}}>

Aggregatmeldungen mit ProCon vergleichen

{['Aggregat / Bit','Lokal','ProCon','SelbstQuittierend lokal / ProCon','Ergebnis'].map(t=>)}{preview.map(item=>{const r=item.comparison?.remote;return ;})}
{t}
{item.row.aggregatName} / {item.row.bit}{item.row.meldung||'(leer)'}{r?.Bezeichnung??'–'}{item.row.selbstQuittierend?'x':'–'} / {r?(r.SelbstQuittierend?'x':'–'):'?'}{item.result??item.error??'Bereit'}

Übernahmen erfolgen einzeln. Erfolgreiche Zeilen bleiben bei Fehlern anderer Zeilen übernommen. Keine automatische Wiederholung.

{busy&&

Wird verarbeitet …

}
} + {dirty&&

Ungespeicherte Änderungen

}{message&&

{message}

}{error&&

{error}

} +
; +} diff --git a/src/components/fehlerliste/fehlerBulkSyncDialog.tsx b/src/components/fehlerliste/fehlerBulkSyncDialog.tsx new file mode 100644 index 0000000..ba6d734 --- /dev/null +++ b/src/components/fehlerliste/fehlerBulkSyncDialog.tsx @@ -0,0 +1,33 @@ +'use client'; +import {useEffect,useRef,useState} from 'react'; +import Modal from '@/components/ui/Modal'; +import {Button} from '@/components/ui/button'; +import {api_compareFehler,api_syncFehler} from '@/actions/fehlerliste/api-fehlerliste'; +import {syncFehlerSelection,type FehlerBulkItem,type FehlerBulkResult} from '@/lib/fehlerliste/bulk-sync'; +import type {FehlerRow,FehlerTable} from '@/types/fehlerliste'; +export default function FehlerBulkSyncDialog({rows,onSaved,onClose}:{rows:FehlerRow[];onSaved:(table:FehlerTable)=>void;onClose:()=>void}){ + const [items,setItems]=useState([]),[results,setResults]=useState([]),[busy,setBusy]=useState(true),[processed,setProcessed]=useState(0); + const running=useRef(false); + async function load(){if(running.current)return;running.current=true;setBusy(true);setItems([]);setResults([]);setProcessed(0); + const next:FehlerBulkItem[]=[]; + try{for(const row of rows){try{next.push({id:row.id,comparison:await api_compareFehler(row.id)});}catch(cause){next.push({id:row.id,error:cause instanceof Error?cause.message:'Vergleich fehlgeschlagen'});}setProcessed(next.length);}setItems(next);} + finally{running.current=false;setBusy(false);} + } + useEffect(()=>{void load();},[]); // eslint-disable-line react-hooks/exhaustive-deps + async function apply(direction:'toLocal'|'toProcon'){ + if(running.current||!items.length||results.length)return;running.current=true;setBusy(true);setProcessed(0); + try{await syncFehlerSelection(items,direction,api_compareFehler,api_syncFehler,onSaved,result=>{setResults(old=>[...old,result]);setProcessed(n=>n+1);});} + finally{running.current=false;setBusy(false);} + } + const ready=items.filter(i=>i.comparison?.remote).length; + return {if(!busy)onClose();}}>

Ausgewählte Fehler mit ProCon synchronisieren ({rows.length})

+

Meldung und SelbstQuittierend werden übertragen. AggregateId ist leer, Typ = 33 + Fehlernummer. Deaktivierbar bleibt unverändert. Die Übernahme erfolgt einzeln; Fehler werden je Meldung angezeigt.

+
{['FehlerNr.','Lokal','ProCon','SelbstQuittierend lokal / ProCon','Ergebnis'].map(label=>)}{rows.map(row=>{ + const item=items.find(i=>i.id===row.id),remote=item?.comparison?.remote,result=results.find(r=>r.id===row.id); + const differs=remote&&(row.meldung!==(remote.Bezeichnung??'')||row.selbstQuittierend!==!!remote.SelbstQuittierend); + return ; + })}
{label}
{row.fehlerNr}{row.meldung||'(leer)'}{remote?remote.Bezeichnung||'(leer)':'–'}{row.selbstQuittierend?'x':'–'} / {remote?(remote.SelbstQuittierend?'x':'–'):'?'}{result?.message??item?.error??(remote?'Bereit':'Wird verglichen …')}
+ {busy?

Wird verarbeitet: {processed} / {rows.length}

:

{results.length?`${results.filter(r=>r.ok).length} übernommen, ${results.filter(r=>!r.ok).length} fehlgeschlagen.`:`${ready} bereit, ${items.length-ready} ohne gültigen Vergleich.`}

} +
+
; +} diff --git a/src/components/fehlerliste/fehlerSyncDialog.tsx b/src/components/fehlerliste/fehlerSyncDialog.tsx new file mode 100644 index 0000000..a362e11 --- /dev/null +++ b/src/components/fehlerliste/fehlerSyncDialog.tsx @@ -0,0 +1,23 @@ +'use client'; +import {useEffect,useState} from 'react'; +import Modal from '@/components/ui/Modal'; +import {Button} from '@/components/ui/button'; +import {api_compareFehler,api_syncFehler} from '@/actions/fehlerliste/api-fehlerliste'; +import type {FehlerComparison,FehlerTable} from '@/types/fehlerliste'; +export default function FehlerSyncDialog({id,onDone,onClose}:{id:string;onDone:(data:FehlerTable)=>void;onClose:()=>void}){ + const [data,setData]=useState(null),[busy,setBusy]=useState(true),[error,setError]=useState(''); + async function load(){setBusy(true);setError('');try{setData(await api_compareFehler(id));}catch(cause){setData(null);setError(cause instanceof Error?cause.message:'Vergleich fehlgeschlagen');}finally{setBusy(false);}} + useEffect(()=>{void load();},[id]); // eslint-disable-line react-hooks/exhaustive-deps + async function apply(direction:'toLocal'|'toProcon'){ + if(!data?.remote||busy)return;setBusy(true);setError(''); + try{onDone(await api_syncFehler(id,{anlageId:data.anlageId,verbindungId:data.verbindungId,version:data.version,direction}));onClose();} + catch(cause){setError(cause instanceof Error?cause.message:'Synchronisierung fehlgeschlagen');}finally{setBusy(false);} + } + const values=data?.remote?[['Meldung',data.local.meldung,data.remote.Bezeichnung??''],['SelbstQuittierend',data.local.selbstQuittierend?'x':'',data.remote.SelbstQuittierend?'x':'']]:[]; + return {if(!busy)onClose();}}>

Fehler mit ProCon vergleichen

+ {data&&<>

Fehler-Nr. {data.local.fehlerNr} · {data.local.meldung}

Automatische Zuordnung: AggregateId leer ? Typ {33+data.local.fehlerNr} ? ProCon-ID {data.remote?.Id}

+ {data.remote&&<>{values.map(([label,local,remote])=>)}
FeldLokalProCon
{label}{local||'(leer)'}{remote||'(leer)'}
} +

Deaktivierbar bleibt lokal und im Excel-Export. ProCon-Deaktiviert ist ein anderer Zustand und wird nicht verändert. Fehlernummer, Doppelwort und Bit bleiben unverändert.

} + {busy&&

Wird verarbeitet …

}{error&&

{error}

} +
; +} diff --git a/src/components/fehlerliste/fehlerTable.tsx b/src/components/fehlerliste/fehlerTable.tsx new file mode 100644 index 0000000..eae178e --- /dev/null +++ b/src/components/fehlerliste/fehlerTable.tsx @@ -0,0 +1,88 @@ +'use client'; +import { useEffect, useState, type MouseEvent } from 'react'; +import Link from 'next/link'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { api_fehlerliste, api_saveFehlerliste } from '@/actions/fehlerliste/api-fehlerliste'; +import type { FehlerRow, FehlerTable as TableData } from '@/types/fehlerliste'; +import FehlerSyncDialog from './fehlerSyncDialog'; +import FehlerBulkSyncDialog from './fehlerBulkSyncDialog'; +import { mitMeldeKennung } from '@/lib/fehlerliste/kennung'; +export default function FehlerTable({ initial, editable = false }: { initial: TableData; editable?: boolean }) { + const [data, setData] = useState(initial), [filter, setFilter] = useState(''); + const [dirty, setDirty] = useState(false), [busy, setBusy] = useState(false); + const [syncId,setSyncId]=useState(null); + const [marked,setMarked]=useState([]),[bulkRows,setBulkRows]=useState(null); + const syncOpen=!!syncId||!!bulkRows; + const [autoKennung,setAutoKennung]=useState(true); + const [auchLeere,setAuchLeere]=useState(false); + const [error, setError] = useState(''), [message, setMessage] = useState(''); + const visible = data.rows.filter(row => `${row.fehlerNr} Meldung[${Math.floor(row.fehlerNr / 32) + 1}] ${row.meldung}`.toLowerCase().includes(filter.toLowerCase())).sort((a,b) => a.fehlerNr - b.fehlerNr); + useEffect(() => { + if (!dirty) return; + const warn = (event: BeforeUnloadEvent) => { event.preventDefault(); event.returnValue = ''; }; + window.addEventListener('beforeunload', warn); return () => window.removeEventListener('beforeunload', warn); + }, [dirty]); + function update(next: TableData) { setData(next); setDirty(true); setError(''); setMessage(''); } + function edit(id: string, patch: Partial) { update({ ...data, rows: data.rows.map(row => row.id === id ? { ...row, ...patch } : row) }); } + function kennungenErgaenzen() { + let count = 0; + const rows = data.rows.map(row => { + const meldung = mitMeldeKennung(row.meldung, row.fehlerNr, auchLeere); + if (meldung !== row.meldung) count++; + return { ...row, meldung }; + }); + if (count) update({ ...data, rows }); + setMessage(`${count} fehlende Kennungen ergänzt. Gilt für alle Einträge, unabhängig vom Suchfilter. Bitte speichern.`); + } + function add(all = false) { + if (!Number.isSafeInteger(data.doppelWords) || data.doppelWords < 1 || data.doppelWords > 100) { setError('Bitte 1–100 Doppelwörter angeben.'); return; } + const used = new Set(data.rows.map(row => row.fehlerNr)), rows: FehlerRow[] = []; + for (let nr = 0; nr < data.doppelWords * 32; nr++) if (!used.has(nr)) { + rows.push({ id: crypto.randomUUID(), fehlerNr: nr, meldung: '', selbstQuittierend: false, deaktivierbar: false }); + if (!all) break; + } + if (!rows.length) { setError('Alle Meldungsplätze sind belegt.'); return; } + update({ ...data, rows: [...data.rows, ...rows] }); + } + async function run(save: boolean) { + if (busy || !save && dirty) return; + setBusy(true); setError(''); setMessage(''); + try { const next = save && autoKennung ? { ...data, rows: data.rows.map(row => ({ ...row, meldung: mitMeldeKennung(row.meldung, row.fehlerNr, auchLeere) })) } : data; + setData(save ? await api_saveFehlerliste(next) : await api_fehlerliste()); setDirty(false); setMessage(save ? 'Fehlerliste gespeichert.' : 'Neu geladen.'); } + catch (cause) { setError(cause instanceof Error ? cause.message : 'Aktion fehlgeschlagen'); } finally { setBusy(false); } + } + function navigate(event: MouseEvent) { if (dirty || busy) { event.preventDefault(); setError('Bitte zuerst Änderungen speichern.'); } } + return

Fehlerliste{editable ? ' bearbeiten' : ''}

+

Fehlerliste.xlsx · {data.doppelWords} Melde-Doppelwörter mit je 32 Bit. Fehler 0–31 liegen in Meldung[1], Fehler 32–63 in Meldung[2]. Freie Plätze werden leer exportiert.

+
+ {editable ? <> + + Zur Übersicht + : <>{data.rows.length} Einträge / {data.doppelWords * 32} Plätze} + + +
+ {editable &&
Aus der Fehlernummer. Vorhandene Kennungen bleiben erhalten. Die Option f?r leere Texte gilt f?r vorhandene Zeilen; weitere Zeilen ?ber ?Freie Pl?tze anlegen? erg?nzen.
} + setFilter(e.target.value)} /> +
+ + + + Auswahl bleibt beim Filtern bestehen. Vor dem Synchronisieren Änderungen speichern. +
+
{['Auswahl', 'FehlerNr.', 'DoppelWord', 'Melde Bit', 'Meldung', 'SelbstQuittierend', 'Deaktivierbar', 'Aktion'].map(label => )} + {visible.map(row => + + + + + + {(['selbstQuittierend', 'deaktivierbar'] as const).map(key => )} + + )}
{label}
setMarked(old=>e.target.checked?[...old,row.id]:old.filter(id=>id!==row.id))}/>{editable ? edit(row.id, { fehlerNr: e.target.valueAsNumber })} /> : row.fehlerNr}{Number.isSafeInteger(row.fehlerNr) && row.fehlerNr >= 0 ? `Meldung[${Math.floor(row.fehlerNr / 32) + 1}]` : '–'}{Number.isSafeInteger(row.fehlerNr) && row.fehlerNr >= 0 ? row.fehlerNr % 32 : '–'}{editable ? edit(row.id, { meldung: e.target.value })} onBlur={() => { if(autoKennung) { const meldung=mitMeldeKennung(row.meldung,row.fehlerNr,auchLeere); if(meldung!==row.meldung)edit(row.id,{meldung}); } }} /> : row.meldung || '(leer)'}{editable ? edit(row.id, { [key]: e.target.checked })} /> : row[key] ? 'x' : ''}{editable&&}
{!visible.length &&

Keine passenden Meldungen vorhanden.

}
+ {syncId&&setSyncId(null)} onDone={next=>{setData(next);setDirty(false);setMessage('Synchronisierung abgeschlossen.');}}/>} + {bulkRows&&setBulkRows(null)} onSaved={next=>{setData(next);setDirty(false);}}/>} + {dirty &&

Ungespeicherte Änderungen

}{message &&

{message}

}{error &&

{error}

} +
; +} diff --git a/src/components/live-anlage/liveAnlage.tsx b/src/components/live-anlage/liveAnlage.tsx new file mode 100644 index 0000000..fc4a50c --- /dev/null +++ b/src/components/live-anlage/liveAnlage.tsx @@ -0,0 +1,70 @@ +'use client'; +import { useEffect, useRef, useState } from 'react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import Modal from '@/components/ui/Modal'; +import MotorControl from './motorControl'; +import { SensorStatus } from '@/components/sensoren/digitalLiveStatus'; +import { api_digitalLiveScene, api_digitalSensorLive } from '@/actions/sensoren/api-digital-opc'; +import { liveSceneBounds, liveSceneDraws } from '@/lib/sensoren/live-scene'; +import { motorStatus, operatingMode } from '@/lib/sensoren/motor-status'; +import type { DigitalLiveScene, DigitalSensorLive } from '@/types/digital-opc'; +import type { StructureSnapshot } from '@/types/opcua-structures'; +function SensorDialog({ id, anlageId, onClose }: { id: string; anlageId: string; onClose: () => void }) { + const [data,setData] = useState(null), [error,setError] = useState(''); + useEffect(() => { let active = true; api_digitalSensorLive(id,anlageId).then(row => { if(active) setData(row); }).catch(cause => { if(active) setError(cause instanceof Error ? cause.message : 'Sensor nicht erreichbar'); }); return () => { active = false; }; },[id,anlageId]); + return

Sensorstatus und Bedienung

{data ? :

{error || 'Sensor wird geladen …'}

}
; +} +export default function LiveAnlage({ initial }: { initial: DigitalLiveScene }) { + const [scene,setScene] = useState(initial), [snapshots,setSnapshots] = useState>({}); + const [viewport,setViewport] = useState(() => liveSceneBounds(initial)), [hand,setHand] = useState(false), [selected,setSelected] = useState(''); + const [filter,setFilter] = useState(''), [error,setError] = useState(''), [busy,setBusy] = useState(false); + const svg = useRef(null), drag = useRef<{ x:number; y:number; box:typeof viewport } | null>(null); + useEffect(() => { + setSnapshots({}); setError(''); if(!scene.sensors.some(s => s.ist)&&!(scene.motors??[]).some(m=>m.structure||m.operatingMode||m.parameters)) return; + let active = true; + const source = new EventSource('/live-anlage/events?anlageId=' + encodeURIComponent(scene.anlageId) + '&token=' + encodeURIComponent(scene.token)); + source.onmessage = event => { + if(!active) return; + try { const data = JSON.parse(event.data); + if(data.type === 'reload') { setSnapshots({}); setError(data.error); source.close(); } + else if(['sensor','motor','motorMode','motorParameters'].includes(data.type)) setSnapshots(old => ({ ...old, [(data.type==='sensor'?'':data.type+':')+data.sensorId]:data.snapshot })); + else if(data.type === 'empty') source.close(); + } catch { setSnapshots({}); setError('Ungültige Live-Antwort'); } + }; + source.onerror = () => { if(active) { setSnapshots({}); setError('Live-Verbindung unterbrochen. Wiederverbindung läuft.'); } }; + source.onopen = () => { if(active) setError(''); }; + return () => { active = false; source.close(); }; + },[scene]); + async function reload() { if(busy) return; setBusy(true); setSelected(''); setSnapshots({}); try { const next = await api_digitalLiveScene(); setScene(next); setViewport(liveSceneBounds(next)); setError(''); } catch(cause) { setError(cause instanceof Error ? cause.message : 'Laden fehlgeschlagen'); } finally { setBusy(false); } } + function zoom(factor:number) { setViewport(v => ({x:v.x+v.width*(1-factor)/2,y:v.y+v.height*(1-factor)/2,width:v.width*factor,height:v.height*factor})); } + const selectedMotor = (scene.motors??[]).find(m=>'motor:'+m.componentId===selected); + const motorSnapshot = selectedMotor ? snapshots[selected] : undefined; + const selectedMotorValue = motorSnapshot?.status==='online'||motorSnapshot?.status==='partial' ? motorSnapshot.values[selectedMotor!.field] : null; + const selectedMotorStatus = motorStatus(selectedMotorValue); + const parameterSnapshot=selectedMotor?snapshots['motorParameters:'+selectedMotor.componentId]:undefined; + const parameterValues=parameterSnapshot?.status==='online'||parameterSnapshot?.status==='partial'?parameterSnapshot.values:{}; + const modeSnapshot=selectedMotor?snapshots['motorMode:'+selectedMotor.componentId]:undefined; + const modeValue=modeSnapshot?.status==='online'||modeSnapshot?.status==='partial'?modeSnapshot.values.Value:null; + const draws = liveSceneDraws(scene, snapshots); + const visible = scene.sensors.filter(s => (s.sensor.datenNr+' '+s.sensor.beschreibung).toLowerCase().includes(filter.toLowerCase())); + const online = scene.sensors.filter(s => snapshots[s.sensor.id]?.status === 'online').length; + return

Live-Anlagenansicht

Digitale Sensoren und Motorkomponenten mit projektierten Positionen und echten CPU-Zuständen. Anklicken öffnet die Bedienung.

+
{online} / {scene.sensors.length} Sensoren online · {(scene.motors??[]).filter(m=>snapshots['motor:'+m.componentId]?.status==='online').length} / {(scene.motors??[]).length} Motoren online
+ {error &&

{error}

} +
+ { if(hand || e.button===1 || e.target===e.currentTarget) { e.preventDefault(); e.stopPropagation(); drag.current={x:e.clientX,y:e.clientY,box:viewport}; e.currentTarget.setPointerCapture(e.pointerId); } }} + onPointerMove={e => { const d=drag.current, node=svg.current; if(!d || !node) return; const rect=node.getBoundingClientRect(), scale=Math.min(rect.width/d.box.width,rect.height/d.box.height); setViewport({...d.box,x:d.box.x-(e.clientX-d.x)/scale,y:d.box.y-(e.clientY-d.y)/scale}); }} + onPointerUp={e => { drag.current=null; if(e.currentTarget.hasPointerCapture(e.pointerId))e.currentTarget.releasePointerCapture(e.pointerId); }} onPointerCancel={() => { drag.current=null; }}> + Live-Anlagenbild – Sensoren und Motorkomponenten + {draws.map((g,index) => { if(!hand)setSelected(g.id); }} onKeyDown={e => { if(!hand && (e.key==='Enter'||e.key===' ')){e.preventDefault();setSelected(g.id);} }}> + {g.name + (g.unknown ? ' – unbekannt' : '')}{g.unknown ? <>? : g.text ? <>{g.text} : } + )} + {!scene.sensors.length && !(scene.motors??[]).length &&

Noch keine digitalen Sensoren oder Motorkomponenten projektiert.

} +
+

? bedeutet unbekannter Zustand oder fehlende Zustandsgrafik. Editor-Ebenen und temporäre Sichtbarkeit werden hier nicht angewendet. Diese Anlagenansicht zeigt digitale Sensoren und Motorkomponenten. Anzeigen und analoge Sensoren folgen separat.

+ {selectedMotor && setSelected('')}>

{selectedMotor.name}

Feld: {selectedMotor.field} · Struktur: {selectedMotor.structure?.name??'Keine Zuordnung'}

Statuscode: {selectedMotorValue===null||selectedMotorValue===undefined?'Unbekannt':String(selectedMotorValue)}

{selectedMotorStatus?.label??'Unbekannter oder ungültiger Status'}

Verbindung: {motorSnapshot?.status??'offline'} · Qualität: {motorSnapshot?.fields[selectedMotor.field]?.status??'Unbekannt'}

Betriebsart: {operatingMode(modeValue)??'Unbekannt'}

Restzeit: {typeof parameterValues.Restzeit==='number'?parameterValues.Restzeit+' s':'Unbekannt'}

Ist-Drehzahl: {parameterValues.IstDrehzahl??'Unbekannt'}

Ist-Strom: {parameterValues.IstStrom??'Unbekannt'}

Parameterqualität: {parameterSnapshot?.fields.Restzeit?.status??'Unbekannt'}

} + {selected && !selectedMotor && setSelected('')} />} +
; +} diff --git a/src/components/live-anlage/motorControl.tsx b/src/components/live-anlage/motorControl.tsx new file mode 100644 index 0000000..246347f --- /dev/null +++ b/src/components/live-anlage/motorControl.tsx @@ -0,0 +1,20 @@ +'use client'; +import {useRef,useState} from 'react'; +import {Button} from '@/components/ui/button'; +import {api_motorCommand} from '@/actions/sensoren/api-motor-opc'; +import type {MotorLiveRow} from '@/types/motor-opc'; +const commands=[['Taster_1','Start rechts'],['Taster_2','Stopp'],['Taster_3','Start links'],['UmschaltungAutomatik','Automatik'],['UmschaltungHand','Handbetrieb'],['UmschaltungRevision','Revision']] as const; +export default function MotorControl({motor,anlageId,online}:{motor:MotorLiveRow;anlageId:string;online:boolean}){ + const pending=useRef(false),[busy,setBusy]=useState(false),[message,setMessage]=useState(''),[error,setError]=useState(''); + async function send(command:string){ + if(pending.current||!online||!motor.control)return; + pending.current=true;setBusy(true);setMessage('');setError(''); + try{const result=await api_motorCommand(motor.componentId,{anlageId,revision:motor.revision??0,controlId:motor.control.id,command}); + const answer=result.results.find(r=>r.field===command);if(!answer?.good)throw new Error('Befehl nicht bestätigt: '+(answer?.status??'Ergebnis unbekannt')); + setMessage('Schreibzugriff bestätigt. Die CPU setzt das Befehlsbit zurück; die Ausführung zeigt die Statusrückmeldung.'); + }catch(cause){setError(cause instanceof Error?cause.message:'Schreibergebnis unbekannt. CPU-Rückmeldung prüfen.');} + finally{pending.current=false;setBusy(false);} + } + if(!motor.control)return

Keine Steuerstruktur zugeordnet.

; + return

Motorbedienung · {motor.control.name}

Steuert beide Motoren gemeinsam, falls vorhanden. Jeder Klick schreibt einmal true; die CPU setzt das Bit zurück.

{commands.map(([field,label])=>)}
{!online&&

Bedienung bei fehlender Live-Verbindung gesperrt.

}{message&&

{message}

}{error&&

{error}

}
; +} diff --git a/src/components/navigation/appBreadcrumbs.tsx b/src/components/navigation/appBreadcrumbs.tsx index c9ac3c6..fbe3d54 100644 --- a/src/components/navigation/appBreadcrumbs.tsx +++ b/src/components/navigation/appBreadcrumbs.tsx @@ -9,9 +9,21 @@ const ownBreadcrumbs = [ /^\/signals(?:\/[^/]+)?$/, /^\/ios$/, /^\/visu-aggregate$/, ]; const labels: Record = { + datensicherung: 'Datensicherung', + 'io-diagnose': 'E/A-Diagnose', + simulation: 'E/A-Simulation', + fehlerliste: 'Fehlerliste', + 'aggregat-meldungen': 'Aggregatmeldungen', parameter: 'Anlagenparameter', + 'parameter-beschriftungen': 'Parameterbeschriftungen', + analog: 'Sensoren Analog', digital: 'Sensoren Digital', texte: 'Texte', steuerbuttons: 'Allgemeine Steuertaster', + 'opcua-strukturen': 'OPC-Strukturen', + 'motor-opc': 'Motor-OPC-Zuordnung', + 'live-anlage': 'Live-Anlagenansicht', + live: 'Live-Status', + opcua: 'OPC UA', sps: 'SPS', alt: 'Alt', rk: 'Anlage (alt)', visu: 'Visualisierung (alt)', anlagen: 'Anlagen', groups: 'Gruppen', units: 'Units', signals: 'Signale', ios: 'IO-Übersicht', @@ -30,6 +42,7 @@ const labels: Record = { // Only link parents that have a real page, rather than route containers such as /alt/rk. const parentPages = new Set([ + '/fehlerliste', '/parameter', '/texte', '/steuerbuttons', diff --git a/src/components/navigation/appSidebar.tsx b/src/components/navigation/appSidebar.tsx index fe04002..1e6fdd7 100644 --- a/src/components/navigation/appSidebar.tsx +++ b/src/components/navigation/appSidebar.tsx @@ -17,12 +17,19 @@ const groups: NavigationGroup[] = [ { label: 'Units', href: '/units' }, { label: 'EA’s', href: '/signals' }, { label: 'IO-Übersicht', href: '/ios' }, + { label: 'Datensicherung', href: '/datensicherung' }, ] }, { id: 'import', label: 'Import', items: [ { label: 'IO Import', href: '/signals/import' }, ] }, { id: 'sps', label: 'SPS', items: [ { label: 'SPS-Exporte', href: '/sps' }, + { label: 'OPC UA', href: '/sps/opcua' }, + { label: 'E/A-Diagnose', href: '/sps/io-diagnose' }, + { label: 'E/A-Simulation', href: '/sps/simulation' }, + { label: 'OPC-Strukturen', href: '/sps/opcua-strukturen' }, + { label: 'Motor-OPC-Zuordnung', href: '/motor-opc' }, + { label: 'Digitalsensoren Live', href: '/sensoren-digital/live' }, { label: 'Aggregate', href: '/sps/aggregate' }, { label: 'Sensoren Digital', href: '/sps/sensoren-digital' }, { label: 'Sensoren Analog', href: '/sps/sensoren-analog' }, @@ -33,6 +40,7 @@ const groups: NavigationGroup[] = [ ] }, { id: 'visualisierung', label: 'Visualisierung', items: [ { label: 'Web-Visu', href: '/visualisierung' }, + { label: 'Live-Anlagenansicht', href: '/live-anlage' }, { label: 'Grafikbibliothek', href: '/visualisierung/bibliothek' }, { label: 'VisuAggregate', href: '/visu-aggregate' }, { label: 'Grafikübersicht', href: '/visu-aggregate/grafiken' }, diff --git a/src/components/opcua/digitalStructureTest.tsx b/src/components/opcua/digitalStructureTest.tsx new file mode 100644 index 0000000..73ec6d8 --- /dev/null +++ b/src/components/opcua/digitalStructureTest.tsx @@ -0,0 +1,59 @@ +'use client'; +import { useState } from 'react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { api_opcBrowse, api_opcRead } from '@/actions/opcua/api-opcua'; +import { digitalFields, digitalSnapshot, suggestDigitalMapping, type DigitalMapping } from '@/lib/opcua/digitalStructure'; +import type { OpcNode } from '@/types/opcua'; + +const labels = { signal: 'Signal', grenzwertErreicht: 'Grenzwert erreicht', ersatzwertAktiv: 'Ersatzwert aktiv' }; +export default function DigitalStructureTest({ anlageId, connectionId, browserNodeId, disabled, run }: { + anlageId: string; connectionId: string; browserNodeId: string; disabled: boolean; + run: (action: () => Promise) => Promise; +}) { + const [root, setRoot] = useState(''), [loadedRoot, setLoadedRoot] = useState(''); + const [nodes, setNodes] = useState([]), [notice, setNotice] = useState(''); + const [mapping, setMapping] = useState({ signal: '', grenzwertErreicht: '', ersatzwertAktiv: '' }); + const [result, setResult] = useState | null>(null); + function changeRoot(value: string) { setRoot(value); setLoadedRoot(''); setNodes([]); setResult(null); setNotice(''); } + async function load() { + await run(async () => { + setResult(null); setLoadedRoot(''); setNodes([]); setNotice(''); + const data = await api_opcBrowse(anlageId, connectionId, root.trim()); + const fields = data.nodes.filter(node => node.nodeClass === 'Variable'); + setNodes(fields); setMapping(suggestDigitalMapping(fields)); setLoadedRoot(root.trim()); + if (!fields.length) setNotice('Keine aufklappbaren Variablenfelder gefunden. Wähle einen einzelnen Struktureintrag, z. B. GrenzwertIst[3], statt des gesamten Arrays. Ein ausschließlich als ExtensionObject angebotener Wert wird in diesem Beispiel noch nicht aufgelöst.'); + else if (data.truncated) setNotice('Die Feldliste wurde begrenzt. Bitte einen einzelnen Struktureintrag auswählen.'); + }); + } + return
+

Struktur-Test: Sensor Digital Ist

+

Einen Eintrag wie GrenzwertIst[3] im Browser öffnen und dessen tatsächliche NodeId übernehmen. Die Felder werden gemeinsam gelesen und hier als Struktur angezeigt.

+
+ + + +
+ {loadedRoot && nodes.length > 0 && <> +
{digitalFields.map(field => )}
+

Gleichnamige Felder werden vorgeschlagen. Abweichende SPS-Feldnamen kannst du selbst zuordnen; die Bedeutung des zweiten Feldes bitte prüfen.

+ + } + {notice &&

{notice}

} + {result &&
+

{result.good ? 'Alle drei Felder gültig gelesen.' : 'Struktur unvollständig oder mindestens ein Feld ungültig. Unbekannte Werte stehen auf null.'}

+
{JSON.stringify({ struktur: loadedRoot, ist: result.ist }, null, 2)}
+
{result.fields.map(field => )}
FeldQualitätQuellzeitGelesen um
{labels[field.field]}{field.status}{field.sourceTimestamp ?? '–'}{field.readAt ?? '–'}
+
} +

Manueller Lesetest ohne Speicherung und ohne SPS-Schreibzugriff. Eine gemeinsame Leseanfrage garantiert keine zeitgleiche Momentaufnahme aller Felder.

+
; +} diff --git a/src/components/opcua/grenzwertLiveExample.tsx b/src/components/opcua/grenzwertLiveExample.tsx new file mode 100644 index 0000000..52ac3fc --- /dev/null +++ b/src/components/opcua/grenzwertLiveExample.tsx @@ -0,0 +1,14 @@ +'use client'; +import { useOpcStructure } from './useOpcStructure'; +interface GrenzwertIst { Signal: boolean | null; GrenzwertErreicht: boolean | null; ErsatzwertAktiv: boolean | null } +export default function GrenzwertLiveExample({ name, anlageId }: { name: string; anlageId: string }) { + const { ist, status, fields, updatedAt, error } = useOpcStructure(name, anlageId); + return

Live: {name}

+

Verbindung: {status}

Signal: {ist?.Signal === true ? 'Ein' : ist?.Signal === false ? 'Aus' : 'Unbekannt'}

+
{JSON.stringify(ist, null, 2)}
+

Letzte Datenmeldung: {updatedAt ?? '–'}

+
{Object.entries(fields).map(([field, data]) => )}
FeldQualitätQuellzeit
{field}{data.status}{data.sourceTimestamp}
+ {error &&

{error}

} +

Die Felder werden abonniert, nicht zyklisch aus der SPS gelesen. Bei Ausfall wird ist auf null gesetzt.

+
; +} diff --git a/src/components/opcua/ioDiagnostics.tsx b/src/components/opcua/ioDiagnostics.tsx new file mode 100644 index 0000000..094636f --- /dev/null +++ b/src/components/opcua/ioDiagnostics.tsx @@ -0,0 +1,40 @@ +'use client'; +import {useEffect,useState} from 'react'; +import {Button} from '@/components/ui/button'; +import {Input} from '@/components/ui/input'; +import {api_checkIos} from '@/actions/opcua/api-io-diagnostics'; +import type {IoDiagnosticConfig,DiagnosticReport,DiagnosticIo,IoLiveValue} from '@/types/io-diagnostics'; +const address=(io:DiagnosticIo|null)=>io?({DigitalInput:'I',DigitalOutput:'Q',AnalogInput:'IW',AnalogOutput:'QW'}[io.adrType]??io.adrType)+io.adrByte+(io.adrType.startsWith('Digital')?'.'+io.adrBit:''):'–'; +export default function IoDiagnostics({initial}:{initial:IoDiagnosticConfig}){ + const [connectionId,setConnectionId]=useState(initial.connections[0]?.id??''),[report,setReport]=useState(null),[busy,setBusy]=useState(false),[error,setError]=useState(''); + const [tab,setTab]=useState<'project'|'unmatched'|'opc'|'free'>('project'),[unitId,setUnitId]=useState(''),[filter,setFilter]=useState(''),[state,setState]=useState('all'),[watching,setWatching]=useState(false); + const [values,setValues]=useState>({}),[status,setStatus]=useState('Nicht verbunden'); + useEffect(()=>{ + setValues({});if(!watching||!report||!unitId){setStatus('Nicht verbunden');return;} + let active=true;const source=new EventSource('/sps/io-diagnose/events?'+new URLSearchParams({anlageId:report.anlageId,connectionId:report.connectionId,unitId,token:report.token})); + setStatus('Verbindungsaufbau'); + source.onmessage=event=>{if(!active)return;try{const data=JSON.parse(event.data); + if(data.type==='value'){setValues(old=>({...old,[data.signalId]:data}));setStatus('Verbunden');} + else if(data.type==='status'){setStatus(data.status==='online'?'Verbunden':data.status==='offline'?'Verbindung unterbrochen':'Verbindungsaufbau');if(data.status!=='online')setValues({});} + else if(data.type==='reload'){setValues({});setError(data.error);setWatching(false);source.close();} + else if(data.type==='empty'){setStatus('Keine eindeutig zugeordneten Signale in dieser Unit');source.close();} + }catch{setValues({});setError('Ungültige Live-Antwort');}}; + source.onerror=()=>{if(active){setValues({});setStatus('Live-Verbindung unterbrochen. Wiederverbindung läuft.');}}; + return()=>{active=false;source.close();}; + },[watching,report,unitId]); + async function check(){if(busy)return;setWatching(false);setReport(null);setValues({});setBusy(true);setError('');try{setReport(await api_checkIos(initial.anlageId,connectionId));setTab('project');}catch(cause){setError(cause instanceof Error?cause.message:'Prüfung fehlgeschlagen');}finally{setBusy(false);}} + const matches=(text:string)=>text.toLowerCase().includes(filter.toLowerCase()); + const rows=(report?.rows??[]).filter(r=>(tab!=='unmatched'||r.status!=='matched')&&(!unitId||r.unitId===unitId)&&matches(`${r.name} ${r.unitName} ${address(r.io)} ${r.io?.functionText??''} ${r.issues.join(' ')}`)).filter(r=>{const v=values[r.signalId];return state==='all'||state==='on'&&v?.good&&v.value===true||state==='off'&&v?.good&&v.value===false||state==='unknown'&&(!v?.good||v.value===null);}); + return

E/A-Konsistenz und Unit-Beobachtung

Zuerst projektierte E/As mit ns=3;s=Inputs und ns=3;s=Outputs vergleichen, danach eine Unit lesend beobachten. Eindeutige Namen allein bestätigen keine physikalische Verdrahtung oder SPS-Adresse.

+
+ {busy&&

OPC-Knoten und lokale Zuordnungen werden geprüft …

}{error&&

{error}

} + {report&&<>

{report.summary.matched} / {report.summary.signals} eindeutig · {report.summary.missing} ohne OPC-Treffer · {report.summary.conflicts} Konflikte

+
{([['project','Projektierte E/As',report.rows.length],['unmatched','Nicht zuordenbar',report.summary.missing+report.summary.conflicts],['opc','Nur in OPC',report.opcOnly.length],['free','IOs ohne Signal',report.freeIos.length]] as const).map(([key,label,count])=>)}
+
{status}
+
setFilter(e.target.value)}/>{(tab==='project'||tab==='unmatched')&&}
+ {(tab==='project'||tab==='unmatched')&&
{['Unit','Signal / IO-Text','Adresse','Prüfung','Live-Wert','Qualität','Empfangen (UTC)'].map(t=>)}{rows.map(r=>{const v=values[r.signalId],known=v?.good&&v.value!==null;return ;})}
{t}
{r.unitName}{r.name}{r.io?.functionText}{address(r.io)}{r.status==='matched'?'Eindeutig':r.issues.join('; ')}{r.node?.dataType}{!known?'Unbekannt':v.value===true?'● Gesetzt':v.value===false?'○ Nicht gesetzt':String(v.value)}{v?.quality??'–'}{v?.receivedAt?.replace('T',' ').replace('Z','')??'–'}
{!rows.length&&

Keine passenden Signale.

}
} + {tab==='opc'&&
{['Bereich','OPC-Signal','Typ','NodeId'].map(t=>)}{report.opcOnly.filter(n=>matches(`${n.name} ${n.nodeId} ${n.direction}`)).map(n=>)}
{t}
{n.direction}{n.name}{n.dataType}{n.nodeId}

Diese Knoten haben keinen gleichnamigen projektierten Gegenpart. Der Unit-Filter gilt hier nicht.

} + {tab==='free'&&
{report.freeIos.filter(io=>matches(`${address(io)} ${io.functionText??''}`)).map(io=>)}
AdresseIO-Text
{address(io)}{io.functionText||'(leer)'}

Ohne Signalzuordnung ist keine Unit bekannt; der Unit-Filter gilt hier nicht.

} +

Nur eindeutig zugeordnete E/As der gewählten Unit werden abonniert. Analoge Wörter erscheinen als Zahl. Bei Verbindungsverlust sind Werte unbekannt. Ausgänge zeigen den CPU-Wert, keine physikalische Rückmeldung. Änderungen an der Projektierung erfordern eine neue Prüfung.

} +
; +} diff --git a/src/components/opcua/ioSimulation.tsx b/src/components/opcua/ioSimulation.tsx new file mode 100644 index 0000000..f48f084 --- /dev/null +++ b/src/components/opcua/ioSimulation.tsx @@ -0,0 +1,50 @@ +'use client'; +import {useEffect,useState} from 'react'; +import Link from 'next/link'; +import {Button} from '@/components/ui/button'; +import {Input} from '@/components/ui/input'; +import SimulationSettingsFields,{settingsHeaders,simulationModes} from './simulationSettings'; +import {api_checkIos} from '@/actions/opcua/api-io-diagnostics'; +import {api_simulation,api_saveSimulation,api_previewSimulation,api_applySimulation,api_startSimulation,api_stopSimulation,api_simulationState,api_manualSimulation} from '@/actions/opcua/api-io-simulation'; +import type {SimulationData,SimulationPlan,SimulationProposal,SimulationRule,SimulationSettings} from '@/types/io-simulation'; +import type {DiagnosticReport} from '@/types/io-diagnostics'; +export default function IoSimulation({initial}:{initial:SimulationData}){ + const [data,setData]=useState(initial),[report,setReport]=useState(null),[unitIds,setUnitIds]=useState([]),[busy,setBusy]=useState(false),[dirty,setDirty]=useState(false),[error,setError]=useState(''),[message,setMessage]=useState(''); + const [preview,setPreview]=useState<{rows:SimulationProposal[];token:string}|null>(null),[targets,setTargets]=useState([]),[filter,setFilter]=useState(''),[target,setTarget]=useState(''); + const plan=data.plan,running=data.runtime.running; + useEffect(()=>{if(!running)return;let active=true;let timer:ReturnType; + const poll=async()=>{try{const runtime=await api_simulationState(plan.anlageId,plan.connectionId);if(active)setData(old=>({...old,runtime}));}catch(cause){if(active)setError(cause instanceof Error?cause.message:'Status nicht verfügbar');}finally{if(active)timer=setTimeout(()=>void poll(),200);}}; + timer=setTimeout(()=>void poll(),200);return()=>{active=false;clearTimeout(timer);}; + },[running,plan.anlageId,plan.connectionId]); + useEffect(()=>{if(!dirty)return;const warn=(e:BeforeUnloadEvent)=>{e.preventDefault();e.returnValue='';};window.addEventListener('beforeunload',warn);return()=>window.removeEventListener('beforeunload',warn);},[dirty]); + function update(next:SimulationPlan){setData({...data,plan:next});setDirty(true);setPreview(null);setError('');setMessage('');} + function editRule(id:string,patch:Partial){update({...plan,rules:plan.rules.map(r=>r.targetId===id?{...r,...patch,origin:'individual'}:r)});} + async function action(work:()=>Promise){if(busy)return;setBusy(true);setError('');setMessage('');try{await work();}catch(cause){setError(cause instanceof Error?cause.message:'Aktion fehlgeschlagen');}finally{setBusy(false);}} + function selection(){if(!report)throw new Error('Zuerst Konsistenz prüfen');return{anlageId:plan.anlageId,connectionId:plan.connectionId,version:plan.version,reportToken:report.token,unitIds};} + const visibleRules=plan.rules.filter(r=>(!unitIds.length||unitIds.includes(r.unitId))&&r.targetName.toLowerCase().includes(filter.toLowerCase())); + const open=preview?.rows.filter(r=>r.status!=='ready')??[]; + function addRule(){const row=report?.rows.find(r=>r.signalId===target&&r.status==='matched'&&r.type==='DigitalInput');if(!row||!row.unitId)return; + update({...plan,rules:[...plan.rules,{targetId:row.signalId,unitId:row.unitId,targetName:row.name,sourceIds:[],origin:'individual',enabled:true,mode:'manual',value:false,invert:false,onDelayMs:500,offDelayMs:0,pulseOnMs:100,pulseOffMs:400,edge:'rising'}]});setTarget(''); + } + return

E/A-Simulation

Interne Vorschau: echte OPC-Ausgänge lesen und daraus simulierte Eingangswerte berechnen. Diese Werte werden weder zur CPU geschrieben noch in der Live-Visu als echte Eingangswerte verwendet.

+
+ + +
+
{data.runtime.status}

Die Simulation läuft im Backend auch bei geschlossenem Browser weiter. Nach Backend-Neustart ist sie gestoppt. Bei geänderter Projektierung wird sie beendet; unbekannte Ausgangswerte erzeugen keine erfundenen Rückmeldungen.

+ {report&&

Units auswählen

{report.units.map(u=>)}
} +
Vorlagen einmal festlegen ({plan.presets.length})

Festwerte und Polarität je Vorlage prüfen. Zeiten in Millisekunden. Mehrere zugehörige Startausgänge werden ODER-verknüpft. Veränderte Vorlagen zuerst speichern, danach Vorschläge neu erzeugen.

{['Aktiv','Vorlage',...settingsHeaders].map(t=>)}{plan.presets.map(p=>update({...plan,presets:plan.presets.map(old=>old.id===p.id?{...old,...patch}:old)})}/>)}
{t}
update({...plan,presets:plan.presets.map(old=>old.id===p.id?{...old,enabled:e.target.checked}:old)})}/>{p.name}
+
{preview&&}
+ {preview&&

Vorschau: {preview.rows.filter(r=>r.status==='ready').length} eindeutig, {open.length} offen / individuell

{preview.rows.map(row=>)}
AuswahlZielsignalVorschlag
setTargets(old=>e.target.checked?[...old,row.targetId]:old.filter(id=>id!==row.targetId))}/>{row.name}{row.message}
Offene Fälle separat ({open.length}){open.map(row=>

{row.name}: {row.message}

)}
} +

Regeln und berechnete Eingangswerte ({visibleRules.length})

setFilter(e.target.value)}/> + {report&&
} +
{['Aktiv','Ziel / Herkunft','Ausgangsquellen (ODER)',...settingsHeaders,'Simuliert / Ausgang','Aktion'].map(t=>)}{visibleRules.map(rule=>{const live=data.runtime.values[rule.targetId];return editRule(rule.targetId,patch)}/>;})}
{t}
editRule(rule.targetId,{enabled:e.target.checked})}/>{rule.targetName}{rule.origin==='individual'?'Individuell':'Vorlage'}{live?.value===true?'true':live?.value===false?'false':'Unbekannt'} / {live?.source===true?'true':live?.source===false?'false':'–'}{running&&rule.mode==='manual'&&}
{!visibleRules.length&&

Noch keine Regeln für die Auswahl vorhanden.

}
+ {dirty&&

Ungespeicherte Änderungen

}{message&&

{message}

}{error&&

{error}

} + Zur E/A-Diagnose +
; +} +function RuleSettings({disabled,rule,onChange}:{disabled:boolean;rule:SimulationRule;onChange:(patch:Partial)=>void}){ + // Form controls inherit the row lock without introducing invalid table nesting. + if(disabled)return <>{[simulationModes.find(m=>m.value===rule.mode)?.label,String(rule.value),rule.invert?'Ja':'Nein',rule.onDelayMs,rule.offDelayMs,rule.pulseOnMs,rule.pulseOffMs,rule.edge==='rising'?'Steigend':'Fallend'].map((value,i)=>{value})}; + return ; +} diff --git a/src/components/opcua/motorOpcConfig.tsx b/src/components/opcua/motorOpcConfig.tsx new file mode 100644 index 0000000..7aab1e9 --- /dev/null +++ b/src/components/opcua/motorOpcConfig.tsx @@ -0,0 +1,25 @@ +'use client'; +import {useState} from 'react'; +import Link from 'next/link'; +import {Button} from '@/components/ui/button'; +import {Input} from '@/components/ui/input'; +import {api_motorOpc,api_saveMotorOpc} from '@/actions/sensoren/api-motor-opc'; +import type {MotorOpcData} from '@/types/motor-opc'; +export default function MotorOpcConfig({initial,initialId}:{initial:MotorOpcData;initialId:string}){ + const [data,setData]=useState(initial),[id,setId]=useState(initialId),[structureId,setStructureId]=useState(initial.bindings.find(b=>b.componentId===initialId)?.structure?.id??''),[field,setField]=useState<'M1'|'M2'>(initial.bindings.find(b=>b.componentId===initialId)?.field??'M1'); + const [modeId,setModeId]=useState(initial.bindings.find(b=>b.componentId===initialId)?.operatingMode?.id??''),[parametersId,setParametersId]=useState(initial.bindings.find(b=>b.componentId===initialId)?.parameters?.id??''); + const [controlId,setControlId]=useState(initial.bindings.find(b=>b.componentId===initialId)?.control?.id??''); + const [filter,setFilter]=useState(''),[busy,setBusy]=useState(false),[error,setError]=useState(''),[message,setMessage]=useState(''); + const binding=data.bindings.find(b=>b.componentId===id); + function select(next:string){setId(next);const b=data.bindings.find(b=>b.componentId===next);setStructureId(b?.structure?.id??'');setField(b?.field??'M1');setModeId(b?.operatingMode?.id??'');setParametersId(b?.parameters?.id??'');setControlId(b?.control?.id??'');setMessage('');setError('');} + async function save(clear=false){if(busy)return;setBusy(true);setError('');try{const ref=clear?null:data.structures.find(s=>s.id===structureId);if(!clear&&structureId&&!ref)throw new Error('Struktur fehlt. Neu laden.');const control=clear?null:data.controlStructures?.find(s=>s.id===controlId);if(!clear&&controlId&&!control)throw new Error('Steuerstruktur fehlt. Neu laden.');const mode=clear?null:data.operatingModes?.find(s=>s.id===modeId);const parameters=clear?null:data.parameterStructures?.find(s=>s.id===parametersId);if(!clear&&(modeId&&!mode||parametersId&&!parameters))throw new Error('Zusatzstruktur fehlt. Neu laden.');const b=await api_saveMotorOpc(id,{anlageId:data.anlageId,version:binding?.revision??0,structure:ref?{id:ref.id,name:ref.name}:null,field,control:control?{id:control.id,name:control.name}:null,operatingMode:mode?{id:mode.id,name:mode.name}:null,parameters:parameters?{id:parameters.id,name:parameters.name}:null});setData({...data,bindings:[...data.bindings.filter(old=>old.componentId!==id),b]});if(clear){setStructureId('');setModeId('');setParametersId('');setControlId('');}setMessage('Motorzuordnung gespeichert. Live-Anlagenbild bitte neu laden.');}catch(cause){setError(cause instanceof Error?cause.message:'Speichern fehlgeschlagen');}finally{setBusy(false);}} + return

OPC-Zuordnung der Motorkomponenten

Je Komponente eine Struktur und ein Statusfeld auswählen. Zwei Komponenten können dieselbe Struktur mit M1 bzw. M2 verwenden. Beide Komponenten k?nnen dieselbe Steuerstruktur verwenden. Befehle werden ausschlie?lich im Live-Motordialog ausgel?st.

Strukturen/Array zuerst übernehmen (Int16 wird unterstützt) + setFilter(e.target.value)} aria-label="Motorkomponente suchen"/> +
+ {id&&<> + +

Restzeit wird ohne Umrechnung in Sekunden angezeigt. Die drei Zuordnungen dürfen unterschiedliche Array-Indizes verwenden.

+} +
{message&&

{message}

}{error&&

{error}

} + Zur separaten Live-Anlagenansicht
; +} diff --git a/src/components/opcua/opcPanel.tsx b/src/components/opcua/opcPanel.tsx new file mode 100644 index 0000000..118674a --- /dev/null +++ b/src/components/opcua/opcPanel.tsx @@ -0,0 +1,66 @@ +'use client'; +import { useEffect, useState } from 'react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { api_opcConfiguration, api_saveOpcConfiguration, api_opcEndpoints, api_opcTest, api_opcBrowse, api_opcRead } from '@/actions/opcua/api-opcua'; +import type { OpcConfiguration, OpcConnection, OpcEndpoint, OpcNode, OpcValue } from '@/types/opcua'; +import DigitalStructureTest from './digitalStructureTest'; +export default function OpcPanel({ initial }: { initial: OpcConfiguration }) { + const [data, setData] = useState(initial), [id, setId] = useState(initial.connections[0]?.id ?? ''); + const [dirty, setDirty] = useState(false), [busy, setBusy] = useState(false), [error, setError] = useState(''), [message, setMessage] = useState(''); + const [endpoints, setEndpoints] = useState([]), [nodes, setNodes] = useState([]), [values, setValues] = useState([]); + const [nodeId, setNodeId] = useState('ObjectsFolder'), [history, setHistory] = useState([]), [readIds, setReadIds] = useState(''); + const selected = data.connections.find(c => c.id === id); + useEffect(() => { + if (!dirty) return; + const warn = (event: BeforeUnloadEvent) => { event.preventDefault(); event.returnValue = ''; }; + window.addEventListener('beforeunload', warn); return () => window.removeEventListener('beforeunload', warn); + }, [dirty]); + function reset() { setEndpoints([]); setNodes([]); setValues([]); setHistory([]); setNodeId('ObjectsFolder'); setReadIds(''); setMessage(''); setError(''); } + function update(next: OpcConfiguration) { setData(next); setDirty(true); setError(''); setMessage(''); setNodes([]); setValues([]); } + function edit(patch: Partial) { if (selected) update({ ...data, connections: data.connections.map(c => c.id === id ? { ...c, ...patch } : c) }); } + async function run(action: () => Promise) { + if (busy) return; setBusy(true); setError(''); setMessage(''); + try { await action(); } catch (cause) { setError(cause instanceof Error ? cause.message : 'Aktion fehlgeschlagen'); } finally { setBusy(false); } + } + async function browse(target: string, back = false) { + if (!selected || dirty) return; + await run(async () => { const result = await api_opcBrowse(data.anlageId, id, target); setNodes(result.nodes); if (!back && target !== nodeId) setHistory([...history, nodeId]); setNodeId(target); if (result.truncated) setMessage('Anzeige auf 2000 Einträge begrenzt. Unterordner gezielt durchsuchen.'); }); + } + return

OPC UA

+

CPU-Verbindung testen, Variablen durchsuchen und Werte manuell lesen. Jede Anfrage öffnet eine Sitzung und schließt sie anschließend.

+
+
+ + + +
+ {selected && <>
+ + + + + + {selected.authentication === 'username' && <>} +
+
+ + +
+

Das RK-Client-Zertifikat muss bei gesicherter Verbindung in TIA/CPU vertraut sein. Das CPU-Zertifikat unten nach Abgleich mit UaExpert übernehmen und speichern. {selected.serverCertificate ? 'CPU-Zertifikat gespeichert bzw. ausgewählt.' : 'Noch kein CPU-Zertifikat ausgewählt.'}

+ {endpoints.length > 0 &&
{endpoints.map((e, i) =>

{e.endpoint} · {e.securityMode} · {e.securityPolicy.split('#').pop()} · {e.authentication.join(', ')}

SHA-256: {e.fingerprint ?? '(kein Zertifikat)'}

{e.subject} · Gültig bis: {e.validTo}

{e.certificate && }
)}
} +

Variablen durchsuchen

+
setNodeId(e.target.value)} />
+
{nodes.map((n, i) => )}
NameNodeIdTypAktion
{n.name || n.browseName}{n.nodeId}{n.nodeClass}{n.nodeClass === 'Variable' && }
+
+

Werte lesen