feat(tia): read-only C# Openness connector, V20 and V21 #1094

Open
opened 2026-12-01 12:36:11 +00:00 by sharang · 1 comment
Owner

Part of the TIA epic #1095. Separate repo (C#, .NET Framework 4.8, Windows).

Read-only console tool, later a Windows service:

  • opens a project file without UI (TiaPortalMode.WithoutUserInterface) or attaches to the user's running TIA; never compiles, downloads or saves;
  • exports devices, CPU security settings, blocks (SimaticML; SD on V21) and writes the bundle (#1090);
  • uploads with a workspace API key (bp_…) over HTTPS; nothing inbound;
  • builds against PublicAPI\V20 and \V21 (apps built for < V21 do not run on V21);
  • handles LicenseNotFoundException and the Openness firewall (EngineeringSecurityException, group "Siemens TIA Openness", permanent allow for unattended runs) with clear messages;
  • never disposes handles from TiaPortal.GetProcesses().

Test bed: TIA Portal on Sharang's Windows machine with our own demo project.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9

Order (2026-12-01): after #1097 (AML upload), #1098 (component states) and #1099 (fleet view), per Sharang.

Part of the TIA epic #1095. Separate repo (C#, .NET Framework 4.8, Windows). Read-only console tool, later a Windows service: - opens a project file without UI (`TiaPortalMode.WithoutUserInterface`) or attaches to the user's running TIA; never compiles, downloads or saves; - exports devices, CPU security settings, blocks (SimaticML; SD on V21) and writes the bundle (#1090); - uploads with a workspace API key (`bp_…`) over HTTPS; nothing inbound; - builds against PublicAPI\V20 and \V21 (apps built for < V21 do not run on V21); - handles `LicenseNotFoundException` and the Openness firewall (`EngineeringSecurityException`, group "Siemens TIA Openness", permanent allow for unattended runs) with clear messages; - never disposes handles from `TiaPortal.GetProcesses()`. Test bed: TIA Portal on Sharang's Windows machine with our own demo project. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9 **Order (2026-12-01):** after #1097 (AML upload), #1098 (component states) and #1099 (fleet view), per Sharang.
Author
Owner

Notes from Siemens' Openness skills (github.com/siemens/tia-portal-ai-extensions, V21-based), for the connector:

Reading devices

  • Walk Project.Devices, DeviceGroups (recursively) and UngroupedDevicesGroup, then Device.DeviceItems recursively.
  • No OrderNumber or FirmwareVersion attribute is documented. Order number and firmware come from TypeIdentifier (OrderNumber:<MLFB>/V<fw>).
  • Watch out for catalog wildcards (-0Axx), variants (//10002), family suffixes (/V5.2.3/S120) and System: items without an order number. Prüfwerk now parses these (PR #1096, 1f3beb5).
  • CatalogEntry.ArticleNumber and .Version are a cross-check.
  • Discover anything else with GetAttributeInfos(), then GetAttributes(names).

Network: NetworkInterface (nodes, Address, SubnetMask, PnDeviceName, IO systems), NetworkPort.ConnectedPorts.

CPU protection

  • PlcAccessLevelProvider.PlcProtectionAccessLevel throws when no password is set, so it is written to the manifest as unreadable.
  • PlcAccessControlConfigurationProvider gives the access-control mechanism.
  • UMAC: EngineeringFunctionRights non-empty means the project is protected.
  • PUT/GET, the web server, OPC UA, secure PG/HMI and "confidential data" are not documented. Probe them with GetAttributeInfos() on the CPU DeviceItem and its HW.Features services, and write unreadable when not found.

Read-only discipline

  • No read-only project open mode exists. Work on a copy, or retrieve a .zap into a temp directory. Never Save, never OpenWithUpgrade on the customer's file.

  • Never call Compile, GoOnline, Download, Archive, any Create*, Set*, Delete* or Import*, or Protect.

  • Never Dispose() handles from TiaPortal.GetProcesses(); on V21 this kills the user's TIA session.

  • Calls known to crash TIA:

    • GetAttributes(AttributeAccessOptions) on a G120C;
    • GetAttribute("IsBuiltIn") on drive services;
    • the mrpdomain and sivarc services;
    • CommunicationManagement on a PM G120C.

    Call GetServiceInfos() before GetService.

  • MissingProductsException on open means an option package is not installed. Report it, don't attach.

Versions and licences

  • V21 ships one assembly per package under PublicAPI\V21\net48. Before V21 there is one Siemens.Engineering.dll. Build twice.
  • There is no Openness licence, but product licences are needed (LicenseNotFoundException).
  • Windows group "Siemens TIA Openness"; the same Windows user as TIA; an admin "permanent allow" for headless runs (otherwise EngineeringSecurityException).
  • Proxies are bound to the thread that created them (MTA).
Notes from Siemens' Openness skills (github.com/siemens/tia-portal-ai-extensions, V21-based), for the connector: **Reading devices** - Walk `Project.Devices`, `DeviceGroups` (recursively) and `UngroupedDevicesGroup`, then `Device.DeviceItems` recursively. - No `OrderNumber` or `FirmwareVersion` attribute is documented. Order number and firmware come from `TypeIdentifier` (`OrderNumber:<MLFB>/V<fw>`). - Watch out for catalog wildcards (`-0Axx`), variants (`//10002`), family suffixes (`/V5.2.3/S120`) and `System:` items without an order number. Prüfwerk now parses these (PR #1096, 1f3beb5). - `CatalogEntry.ArticleNumber` and `.Version` are a cross-check. - Discover anything else with `GetAttributeInfos()`, then `GetAttributes(names)`. **Network:** `NetworkInterface` (nodes, `Address`, `SubnetMask`, `PnDeviceName`, IO systems), `NetworkPort.ConnectedPorts`. **CPU protection** - `PlcAccessLevelProvider.PlcProtectionAccessLevel` throws when no password is set, so it is written to the manifest as `unreadable`. - `PlcAccessControlConfigurationProvider` gives the access-control mechanism. - UMAC: `EngineeringFunctionRights` non-empty means the project is protected. - PUT/GET, the web server, OPC UA, secure PG/HMI and "confidential data" are not documented. Probe them with `GetAttributeInfos()` on the CPU `DeviceItem` and its `HW.Features` services, and write `unreadable` when not found. **Read-only discipline** - No read-only project open mode exists. Work on a copy, or retrieve a `.zap` into a temp directory. Never `Save`, never `OpenWithUpgrade` on the customer's file. - Never call `Compile`, `GoOnline`, `Download`, `Archive`, any `Create*`, `Set*`, `Delete*` or `Import*`, or `Protect`. - Never `Dispose()` handles from `TiaPortal.GetProcesses()`; on V21 this kills the user's TIA session. - Calls known to crash TIA: - `GetAttributes(AttributeAccessOptions)` on a G120C; - `GetAttribute("IsBuiltIn")` on drive services; - the `mrpdomain` and `sivarc` services; - `CommunicationManagement` on a PM G120C. Call `GetServiceInfos()` before `GetService`. - `MissingProductsException` on open means an option package is not installed. Report it, don't attach. **Versions and licences** - V21 ships one assembly per package under `PublicAPI\V21\net48`. Before V21 there is one `Siemens.Engineering.dll`. Build twice. - There is no Openness licence, but product licences are needed (`LicenseNotFoundException`). - Windows group "Siemens TIA Openness"; the same Windows user as TIA; an admin "permanent allow" for headless runs (otherwise `EngineeringSecurityException`). - Proxies are bound to the thread that created them (MTA).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: platform/pruefwerk#1094