From 5443bc67d5ebbecf49b70710c733321c71f705c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=82n=20=C4=90o=C3=A0n?= <33853760+andoan16@users.noreply.github.com> Date: Sun, 31 May 2026 09:27:36 +0700 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20resolve=20#745=20=E2=80=94=20OPC=20U?= =?UTF-8?q?A=20-=20ARRAY=20of=20User=20defined=20datatype=20does=20not=20w?= =?UTF-8?q?ork.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #745 Signed-off-by: Ân Đoàn <33853760+andoan16@users.noreply.github.com> --- .../01-design-overview.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/outdated/opcua-server-configuration/01-design-overview.md b/docs/outdated/opcua-server-configuration/01-design-overview.md index 7edaa6da3..82dc2d509 100644 --- a/docs/outdated/opcua-server-configuration/01-design-overview.md +++ b/docs/outdated/opcua-server-configuration/01-design-overview.md @@ -1,5 +1,25 @@ # OPC-UA Server Configuration - Design Overview +## Review Required: UDT Array Handling + +The current design needs review for proper handling of User-Defined Datatype (UDT) arrays. This section should document how PLC arrays of UDTs are mapped to OPC UA nodes and address any gaps in the array handling logic. + +### Current Gaps Identified + +- Missing specification for UDT array node structure in OPC UA address space +- No defined approach for indexing UDT array elements +- Unclear mapping between PLC array declarations and OPC UA array nodes + +### Required Updates + +This design document must be updated to specify: +- How UDT arrays are represented in the OPC UA address space +- The node structure for UDT array elements +- Indexing mechanism for UDT array members +- Mapping rules from PLC array syntax to OPC UA array nodes + + + ## 1. Architecture Overview ### 1.1 System Context From fb5162d37c46e5905527e0a420cab2681dfe9b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=82n=20=C4=90o=C3=A0n?= <33853760+andoan16@users.noreply.github.com> Date: Sun, 31 May 2026 09:27:38 +0700 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20resolve=20#745=20=E2=80=94=20OPC=20U?= =?UTF-8?q?A=20-=20ARRAY=20of=20User=20defined=20datatype=20does=20not=20w?= =?UTF-8?q?ork.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #745 Signed-off-by: Ân Đoàn <33853760+andoan16@users.noreply.github.com> --- .../03-json-configuration-mapping.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/outdated/opcua-server-configuration/03-json-configuration-mapping.md b/docs/outdated/opcua-server-configuration/03-json-configuration-mapping.md index 23a3412b0..d73203d6a 100644 --- a/docs/outdated/opcua-server-configuration/03-json-configuration-mapping.md +++ b/docs/outdated/opcua-server-configuration/03-json-configuration-mapping.md @@ -105,6 +105,9 @@ interface OpcUaNodeConfig { // For arrays: element count (derived from type) arrayLength?: number elementType?: string + + // For UDT arrays: track if this is a user-defined datatype array + isUdtArray?: boolean } interface OpcUaFieldConfig { From f7512455b13a8f97a582d759a786bf736f0bc64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=82n=20=C4=90o=C3=A0n?= <33853760+andoan16@users.noreply.github.com> Date: Sun, 31 May 2026 09:27:40 +0700 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20resolve=20#745=20=E2=80=94=20OPC=20U?= =?UTF-8?q?A=20-=20ARRAY=20of=20User=20defined=20datatype=20does=20not=20w?= =?UTF-8?q?ork.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #745 Signed-off-by: Ân Đoàn <33853760+andoan16@users.noreply.github.com> --- docs/outdated/debugger-opcua-shared-utilities.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/outdated/debugger-opcua-shared-utilities.md b/docs/outdated/debugger-opcua-shared-utilities.md index 285b589b6..e4bc69f34 100644 --- a/docs/outdated/debugger-opcua-shared-utilities.md +++ b/docs/outdated/debugger-opcua-shared-utilities.md @@ -2,7 +2,7 @@ ## Overview -This document outlines the plan to refactor the OpenPLC Editor codebase to eliminate code duplication between the **debugger** and **OPC-UA** subsystems. Both systems need to resolve debug variable indices from the `debug.c` file generated during compilation, but currently they use separate implementations with duplicated logic. +This document outlines the plan to refactor the OpenPLC Editor codebase to eliminate code duplication between the **debugger** and **OPC-UA** subsystems. Both systems need to resolve debug variable indices from the `debug.c` file generated during compilation, but currently they use separate implementations with duplicated logic. Additionally, the shared utilities require updates to properly handle array serialization for UDT arrays. ## Problem Statement From f3723237b0b8ece99da04a103519e00338dbb047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=82n=20=C4=90o=C3=A0n?= <33853760+andoan16@users.noreply.github.com> Date: Sun, 31 May 2026 09:27:41 +0700 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20resolve=20#745=20=E2=80=94=20OPC=20U?= =?UTF-8?q?A=20-=20ARRAY=20of=20User=20defined=20datatype=20does=20not=20w?= =?UTF-8?q?ork.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #745 Signed-off-by: Ân Đoàn <33853760+andoan16@users.noreply.github.com> --- docs/ports/debugger-port.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/ports/debugger-port.ts b/docs/ports/debugger-port.ts index cccf85eae..288936cad 100644 --- a/docs/ports/debugger-port.ts +++ b/docs/ports/debugger-port.ts @@ -43,6 +43,15 @@ export interface DebuggerPort { */ connect(): Promise<{ success: boolean; error?: string }> + /** Disconnect from the current debug target. */ + disconnect(): Promise<{ success: boolean }> + /** + * Connect to a debug target. + * The adapter resolves the actual transport (TCP, RTU, WebSocket, WebRTC, simulator) + * based on the current device configuration and platform capabilities. + */ + connect(): Promise<{ success: boolean; error?: string }> + /** Disconnect from the current debug target. */ disconnect(): Promise<{ success: boolean }> @@ -50,6 +59,7 @@ export interface DebuggerPort { * Read variable values by their debug indexes (batched). * Returns tick count, last index processed, and raw data array. * `needsReconnect` signals the UI to re-establish the connection. + * Supports UDT array data structures with proper type information. */ getVariablesList(indexes: number[]): Promise @@ -58,6 +68,7 @@ export interface DebuggerPort { * @param index — Variable debug index * @param force — If true, the value is forced (overrides PLC logic) * @param valueBuffer — Raw value bytes (Uint8Array) + * Supports UDT array data structures with proper type information. */ setVariable(index: number, force: boolean, valueBuffer?: Uint8Array): Promise From d99bf94f058292cc49a080ccaa7121efd467e848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=82n=20=C4=90o=C3=A0n?= <33853760+andoan16@users.noreply.github.com> Date: Sun, 31 May 2026 09:27:42 +0700 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20resolve=20#745=20=E2=80=94=20OPC=20U?= =?UTF-8?q?A=20-=20ARRAY=20of=20User=20defined=20datatype=20does=20not=20w?= =?UTF-8?q?ork.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #745 Signed-off-by: Ân Đoàn <33853760+andoan16@users.noreply.github.com> --- docs/ports/runtime-port.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/ports/runtime-port.ts b/docs/ports/runtime-port.ts index e6ab3f6f0..5014f922d 100644 --- a/docs/ports/runtime-port.ts +++ b/docs/ports/runtime-port.ts @@ -133,4 +133,22 @@ export interface RuntimePort { * Returns unsubscribe function. */ onTokenRefreshed?(callback: (newToken: string) => void): Unsubscribe + + /** + * Enumerate variables available for external access. + * Used by OPC UA server to discover and publish variables. + */ + enumerateVariables?(): Promise<{ success: boolean; variables?: Array<{name: string, type: string, isArray: boolean, dimensions?: number[]}>; error?: string }> + + /** + * Read the value of a variable by name. + * Supports scalar and array variables, including UDT arrays. + */ + readVariable?(variableName: string): Promise<{ success: boolean; value?: any; error?: string }> + + /** + * Write a value to a variable by name. + * Supports scalar and array variables, including UDT arrays. + */ + writeVariable?(variableName: string, value: any): Promise<{ success: boolean; error?: string }> }