Skip to content
Back to search

tia-portal-openness-ai

AI-ready skill and C# scaffold for Siemens TIA Portal Openness V15-V21 / 支持 V15-V21 的博途 Openness AI 自动化工具

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/huahaizo--tia-portal-openness-ai/badge.svg)](/listings/huahaizo--tia-portal-openness-ai)

HTML

<a href="/listings/huahaizo--tia-portal-openness-ai"><img src="/api/listings/huahaizo--tia-portal-openness-ai/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

把整个 `tia-openness-control` 文件夹复制到你的 AI 工具或 Agent 支持的 skills 目录中。这个文件夹必须包含 `SKILL.md`。

不同 AI 工具的 skills 目录位置不同,请以你正在使用的工具文档为准。只要最终能让 AI 读取到 `SKILL.md`、`references/` 和 `scripts/`,就可以使用。

最终结构应类似:

tia-openness-control/
├─ SKILL.md
├─ README.md
├─ agents/openai.yaml
├─ references/openness-patterns.md
└─ scripts/new-openness-controller.ps1

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 115 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: tia-openness-control
  3. description: Build, review, and run Siemens TIA Portal Openness automations that let any AI-assisted workflow control TIA Portal projects through the official Siemens.Engineering .NET API. Supports TIA Portal V15 through V21, including automatic installed-version detection. Use when the user asks to automate BoTu/TIA Portal operations, generate C# or PowerShell wrappers for Openness, open/create/modify/compile/export/import/archive TIA projects, inspect PLC/HMI/hardware objects, or design a safe AI-to-TIA command layer.
  4. ---
  5. # TIA Openness Control
  6. ## Mission
  7. Use TIA Portal Openness as the execution boundary: any AI proposes structured actions, generated .NET code performs them through `Siemens.Engineering`, and every destructive or plant-impacting operation is explicit, logged, and reviewable.
  8. ## Workflow
  9. 1. Identify the project path and exact operation. Detect the installed TIA Portal version automatically when the user does not specify one.
  10. 2. Confirm prerequisites: Windows host, TIA Portal V15 through V21 installed, user in the `Siemens TIA Openness` Windows group, Openness enabled, project backed up, and matching `PublicAPI` path. For first-time setup, instruct the user to add the Windows account to that group with administrator rights, then sign out and back in.
  11. 3. Choose execution mode: `WithUserInterface` for exploratory/debug work, `WithoutUserInterface` for repeatable batch work.
  12. 4. Generate or modify a C# .NET controller. Use `scripts/new-openness-controller.ps1` to scaffold a starter controller when useful.
  13. 5. Keep AI commands declarative, such as JSON/YAML action plans, and map them through a whitelist. Do not execute arbitrary prompt text as code.
  14. 6. Run read-only or dry-run behavior first; then write only the requested target objects.
  15. 7. Capture stdout, stderr, exit code, active project path, and log file path for every run.
  16. 8. Verify results by reading the project back through Openness. Do not claim success from exit code, file timestamp, or "no exception" alone.
  17. 9. Save or archive the project and report changed objects, warnings, and compile diagnostics.
  18. ## Universal AI Interface
  19. Keep this skill usable by any AI agent or automation runner:
  20. - Describe actions as plain JSON/YAML command documents.
  21. - Generate ordinary PowerShell, C#, `.csproj`, and CLI commands.
  22. - Avoid product-specific hidden state, proprietary prompt features, or assumptions about a single AI runtime.
  23. - Make every generated controller runnable by a human from a terminal.
  24. - Return machine-readable results when possible so another AI can continue from logs.
  25. Example command document:
  26. ```json
  27. {
  28. "tiaVersion": "auto",
  29. "projectPath": "D:/Projects/Line1.ap20",
  30. "mode": "WithUserInterface",
  31. "dryRun": true,
  32. "actions": [
  33. { "type": "ListDevices" }
  34. ]
  35. }
  36. ```
  37. ## Version Support
  38. Support TIA Portal V15, V15.1, V16, V17, V18, V19, V20, and V21.
  39. When scaffolding a controller, prefer automatic detection:
  40. ```powershell
  41. powershell -ExecutionPolicy Bypass -File .\scripts\new-openness-controller.ps1 -OutputPath . -ProjectName TiaOpennessController
  42. ```
  43. The script scans `C:\Program Files\Siemens\Automation\Portal V*\PublicAPI\V*` and selects the highest supported installed version. Use `-TiaVersion V17` or `-TiaVersion V15_1` only when the user explicitly wants a specific version.
  44. ## Safety Rules
  45. - Never connect to a PLC, download to a device, change online state, or alter production hardware without explicit user approval.
  46. - Prefer offline project edits and generated source import/export.
  47. - Before writes, create a `.zap` archive or duplicate project folder when TIA Portal supports the workflow.
  48. - Pin `Siemens.Engineering.dll` to the detected or selected TIA Portal version; do not mix assemblies and runtime versions.
  49. - Set Siemens Engineering assembly references to `Copy Local = false`, or load them from `PublicAPI` at runtime.
  50. - Treat block names, device names, file paths, credentials, project libraries, and know-how protected content as user data.
  51. ## First-Time Windows Group Setup
  52. If the current Windows account is not in the `Siemens TIA Openness` group, tell the user to run an elevated PowerShell session and execute:
  53. ```powershell
  54. net localgroup "Siemens TIA Openness" "$env:USERNAME" /add
  55. ```
  56. After adding the account, the user should sign out and sign in again, or restart Windows, before running Openness automation.
  57. ## Common Tasks
  58. - Open, create, save, close, or archive a project.
  59. - Enumerate devices, PLC software, blocks, external sources, tag tables, HMI objects, and libraries.
  60. - Import/export PLC blocks, tag tables, libraries, and hardware descriptions as source/XML files.
  61. - Generate SCL/LAD/FBD source files, then import them through Openness.
  62. - Compile software or hardware and summarize diagnostics.
  63. - Start TIA Portal, use a visible UI session, or attach to an existing Openness process when the local version supports it.
  64. ## Implementation Patterns
  65. Read `references/openness-patterns.md` when generating C# code, planning an AI command schema, or troubleshooting assembly loading/version problems.
  66. Critical assembly-loading rule: keep `Main` as a clean bootstrap that does not reference any `Siemens.Engineering` types. Register `AssemblyResolve`, preload `Siemens.Engineering.dll`, then call the real Openness logic in a separate `[MethodImpl(MethodImplOptions.NoInlining)]` method or class. If `Main` directly uses `TiaPortal`, `TiaPortalMode`, `Project`, or an `Options` property typed as `TiaPortalMode`, .NET Framework can throw `FileNotFoundException` before the resolver is registered.
  67. When another AI or user reports `FileNotFoundException` at `Program.Main`, replace the generated controller with the current scaffold from `scripts/new-openness-controller.ps1` before attempting feature work. Do not keep patching a controller whose `Main` directly references Siemens types.
  68. For device creation tasks, require a read-back verification step such as `ListDevices` after saving and reopening the project. If the target order number, device type identifier, or catalog version is unknown for the installed TIA version, inspect/export an existing matching device or ask the user for the exact catalog item instead of guessing.
  69. For Chinese users, read `README.md` when user-facing guidance is needed.
  70. Use official Siemens documentation for exact version-specific APIs. Useful starting points:
  71. - TIA Portal Openness V21 example program: https://docs.tia.siemens.cloud/r/en-us/v21/tia-portal-openness-api-for-automation-of-engineering-workflows/tia-portal-openness-api/general-functions/example-program
  72. - TIA Portal Openness V20 connecting guide: https://docs.tia.siemens.cloud/r/en-us/v20/tia-portal-openness-api-for-automation-of-engineering-workflows/tia-portal-openness-api/general-functions/connecting-to-the-tia-portal
  73. ## Output Expectations
  74. When helping a user, provide:
  75. - the exact command or C# project to run,
  76. - detected TIA Portal version, PublicAPI path, and project path,
  77. - the list of operations the automation will perform,
  78. - stdout, stderr, and exit code from the last automation run,
  79. - validation steps and expected diagnostics,
  80. - read-back evidence for created or modified objects,
  81. - any operation that still needs manual confirmation inside TIA Portal.
README.md · README · 208 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # 🚀 TIA Openness Control
  2. ![TIA Portal](https://img.shields.io/badge/TIA%20Portal-V15--V21-0f766e)
  3. ![Openness](https://img.shields.io/badge/Siemens-Openness-2563eb)
  4. ![AI Ready](https://img.shields.io/badge/AI-Ready-7c3aed)
  5. ![Windows](https://img.shields.io/badge/Platform-Windows-475569)
  6. 通过 Siemens **TIA Portal Openness**,让 AI 帮你自动化操作博途项目。
  7. 你可以用中文描述需求,例如“打开项目并列出所有设备”“导出 PLC 块”“把这段 SCL 导入项目并编译”。AI 会先生成可审查的动作计划,再通过 C# 控制器调用 `Siemens.Engineering` 官方 API 执行。
  8. ```text
  9. 你的需求 -> AI 动作计划 -> JSON/YAML 指令 -> C# Openness 控制器 -> TIA Portal 项目
  10. ```
  11. ## 📌 目录
  12. - [✅ 当前状态](#-当前状态)
  13. - [✨ 可以做什么](#-可以做什么)
  14. - [🧰 使用前准备](#-使用前准备)
  15. - [📦 安装 skill](#-安装-skill)
  16. - [🔐 首次使用配置](#-首次使用配置)
  17. - [🧭 支持版本](#-支持版本)
  18. - [🚀 快速开始](#-快速开始)
  19. - [🧪 建议的使用方式](#-建议的使用方式)
  20. - [🛠 常见报错](#-常见报错)
  21. - [⚠️ 安全提醒](#️-安全提醒)
  22. - [📖 常见术语](#-常见术语)
  23. ## ✅ 当前状态
  24. 当前版本已经过实际 Openness 调用验证,可以用于生成控制器并执行 TIA Portal 自动化任务。
  25. 脚手架已处理常见的 `Siemens.Engineering.dll` 加载问题:程序会先注册程序集解析器,再加载 `Siemens.Engineering.dll`,最后才进入真正的 Openness 逻辑。
  26. ## ✨ 可以做什么
  27. | 你想做的事 | 对应自动化动作 |
  28. | --- | --- |
  29. | 打开博途项目并列出设备 | `OpenProject` + `ListDevices` |
  30. | 导出 PLC 块 | `ExportBlocks` |
  31. | 导入 AI 生成的 SCL 源文件 | `ImportSources` |
  32. | 编译 PLC 并返回诊断信息 | `CompilePlc` |
  33. | 归档项目 | `ArchiveProject` |
  34. | 生成 Openness 控制器骨架 | `new-openness-controller.ps1` |
  35. ## 🧰 使用前准备
  36. 请确认本机满足这些条件:
  37. - Windows 系统
  38. - 已安装 TIA Portal V15 到 V21 中的任一版本
  39. - 当前 Windows 用户已加入 `Siemens TIA Openness` 用户组
  40. - 已启用 TIA Portal Openness
  41. - 要操作的项目已经备份
  42. - 本机可以访问对应版本的 `Siemens.Engineering.dll`
  43. ## 📦 安装 skill
  44. 把整个 `tia-openness-control` 文件夹复制到你的 AI 工具或 Agent 支持的 skills 目录中。这个文件夹必须包含 `SKILL.md`。
  45. 不同 AI 工具的 skills 目录位置不同,请以你正在使用的工具文档为准。只要最终能让 AI 读取到 `SKILL.md`、`references/` 和 `scripts/`,就可以使用。
  46. 最终结构应类似:
  47. ```text
  48. tia-openness-control/
  49. ├─ SKILL.md
  50. ├─ README.md
  51. ├─ agents/openai.yaml
  52. ├─ references/openness-patterns.md
  53. └─ scripts/new-openness-controller.ps1
  54. ```
  55. ## 🔐 首次使用配置
  56. 第一次使用 Openness 前,需要把当前 Windows 用户加入 `Siemens TIA Openness` 用户组。这个操作需要管理员权限。
  57. 用管理员身份打开 PowerShell,然后执行:
  58. ```powershell
  59. net localgroup "Siemens TIA Openness" "$env:USERNAME" /add
  60. ```
  61. 如果要添加指定用户:
  62. ```powershell
  63. net localgroup "Siemens TIA Openness" "用户名" /add
  64. ```
  65. 添加后请注销并重新登录 Windows,必要时重启电脑。否则 TIA Portal 可能仍然识别不到新的 Openness 权限。
  66. 也可以通过图形界面操作:
  67. ```text
  68. 计算机管理 -> 本地用户和组 -> 组 -> Siemens TIA Openness -> 添加用户
  69. ```
  70. ## 🧭 支持版本
  71. 支持这些 TIA Portal 版本:
  72. ```text
  73. V15, V15_1 / V15.1, V16, V17, V18, V19, V20, V21
  74. ```
  75. 脚本会自动扫描本机安装的 Openness API,并默认选择最高可用版本:
  76. ```text
  77. C:\Program Files\Siemens\Automation\Portal V*\PublicAPI\V*\Siemens.Engineering.dll
  78. ```
  79. ## 🚀 快速开始
  80. 如果当前目录就是 `tia-openness-control`,运行下面的命令,自动检测当前安装的 TIA Portal 版本,并生成 C# 控制器:
  81. ```powershell
  82. powershell -ExecutionPolicy Bypass -File .\scripts\new-openness-controller.ps1 -OutputPath . -ProjectName TiaOpennessController
  83. ```
  84. 如果你在它的上一级目录运行,使用:
  85. ```powershell
  86. powershell -ExecutionPolicy Bypass -File .\tia-openness-control\scripts\new-openness-controller.ps1 -OutputPath . -ProjectName TiaOpennessController
  87. ```
  88. 如果要指定 TIA Portal 版本:
  89. ```powershell
  90. powershell -ExecutionPolicy Bypass -File .\scripts\new-openness-controller.ps1 -OutputPath . -ProjectName TiaOpennessController -TiaVersion V17
  91. ```
  92. 生成后构建控制器:
  93. ```powershell
  94. dotnet build .\TiaOpennessController
  95. ```
  96. ## 🧪 建议的使用方式
  97. 先让 AI 做只读或 dry-run 操作,例如:
  98. ```text
  99. 请使用 tia-openness-control,自动检测本机 TIA Portal 版本,打开 D:\Projects\Line1.ap20,并列出所有设备。先不要写入项目。
  100. ```
  101. 确认结果正确后,再让 AI 生成写入动作,例如导入源文件、编译、保存或归档。
  102. ## 🛠 常见报错
  103. 如果运行控制器时看到类似错误:
  104. ```text
  105. System.IO.FileNotFoundException: 未能加载文件或程序集“Siemens.Engineering, Version=16.0.0.0...”
  106. 在 TiaOpennessController.Program.Main(String[] args)
  107. ```
  108. 通常不是 DLL 不存在,而是程序在 `Main` 里太早引用了 `Siemens.Engineering` 类型,导致程序集解析器还没注册就开始加载 DLL。
  109. 处理方式:
  110. - 优先使用本 skill 的 `new-openness-controller.ps1` 重新生成控制器骨架
  111. - 不要让 AI 在 `Main` 里直接写 `TiaPortal`、`TiaPortalMode`、`Project`、`Device`
  112. - `Main` 只负责注册 `AssemblyResolve` 和加载 `Siemens.Engineering.dll`
  113. - 真正的 Openness 代码放到单独的 runner 方法或类里,并延迟调用
  114. 如果 AI 说“运行成功”,但你没有看到项目变化,请让它提供:
  115. - 实际执行的命令
  116. - stdout / stderr
  117. - 退出码
  118. - 项目完整路径
  119. - 保存后重新打开项目并读取到的设备或块列表
  120. 不要只相信“退出码为 0”或“文件时间变了”。添加 PLC、块、变量表之后,必须通过 Openness 再读回项目内容确认。
  121. ## ⚠️ 安全提醒
  122. 以下操作必须人工确认后再执行:
  123. - 下载到 PLC 或 HMI
  124. - 进入在线模式
  125. - 删除设备、块、变量表或库
  126. - 修改安全相关对象或受保护对象
  127. - 修改生产项目的硬件地址、网络参数或通信设置
  128. - 未备份项目时执行写入
  129. 推荐优先操作离线项目。AI 生成的 PLC 内容最好先保存为源文件,再由 Openness 导入并编译。
  130. ## 📄 免责声明
  131. 本项目是独立的 AI skill 和 Openness 自动化脚手架,不包含 Siemens TIA Portal、`Siemens.Engineering.dll`、Siemens 专有库、官方文档或任何 Siemens 授权软件。
  132. 使用者需要自行安装并授权 Siemens TIA Portal,并遵守 Siemens 的许可条款、安全要求和官方文档。本项目与 Siemens 无隶属关系,未获得 Siemens 认可、赞助、背书或支持。
  133. 完整说明见 [DISCLAIMER.md](./DISCLAIMER.md)。
  134. ## 📖 常见术语
  135. | 中文 | 英文 / API |
  136. | --- | --- |
  137. | 博途 | TIA Portal |
  138. | 官方自动化接口 | Openness |
  139. | 公共 API 路径 | `PublicAPI` |
  140. | 核心 DLL | `Siemens.Engineering.dll` |
  141. | 带界面启动 | `TiaPortalMode.WithUserInterface` |
  142. | 无界面启动 | `TiaPortalMode.WithoutUserInterface` |
  143. | 只读 / 试运行 | dry-run |

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.