Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/outdated/debugger-opcua-shared-utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions docs/outdated/opcua-server-configuration/01-design-overview.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions docs/ports/debugger-port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,23 @@ 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 }>

/**
* 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<DebugVariableResult>

Expand All @@ -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<DebugSetResult>

Expand Down
18 changes: 18 additions & 0 deletions docs/ports/runtime-port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>
}