UNPKG

major-ai-skills

Version:

Installable agentic skills / AI agent skills (SKILL.md) for Claude Code, Cursor, Codex CLI, Gemini CLI & Antigravity - 402+ professional app, token-efficiency, and common-sense skills. SEO/GEO ready.

145 lines (110 loc) 7.97 kB
--- title: "Siemens TIA Portal Industrial Automation AI Skill Guide (GPT & Codex)" description: "Comprehensive operational skill specification for OpenAI GPT and Codex to automate, script, troubleshoot, and optimize Siemens TIA Portal, TIA Openness .NET API (Siemens.Engineering), pythonnet, and PLCSIM Advanced." category: "Integrated PLC & HMI Engineering" tags: ["siemens-tia-portal", "tia-openness-net", "pythonnet", "plcsim-advanced", "scl-generation", "gpt-codex", "automation-engineering"] --- # Siemens TIA Portal Industrial Automation AI Skill Guide (GPT & Codex) ## Overview & Engine Architecture Siemens TIA Portal exposes complete programmatic project lifecycle control via the **TIA Portal Openness .NET API (`Siemens.Engineering.dll`)**, supporting automated compilation, hardware generation, and software deployment from C# or Python (`pythonnet`). Additionally, the **PLCSIM Advanced API (`Siemens.Simatic.Simulation.Runtime.Api.x64.dll`)** provides virtual PLC instance orchestration for Software-in-the-Loop (SiL) simulation. GPT/Codex acts as a Principal Automation DevOps Engineer and Siemens Extensibility Developer, delivering **TIA Openness automation scripts**, **PLCSIM Advanced virtual commissioning harnesses**, **programmatic SCL block synthesizers**, and **automated continuous integration pipelines**. ### Developer Architecture & Openness Platform Stack ``` ┌─────────────────────────────────────────────────────────────┐ TIA Portal Developer Platform TIA Openness .NET Architecture (`Siemens.Engineering`) ├── `TiaPortal` Root Object (`TiaPortalMode.WithUserInterface`)│ ├── `ProjectComposition` & `DeviceComposition` (Rack/Slot) └── `PlcSoftware` (Block Import/Export, SCL Generation) Virtual Commissioning & Simulation Engine ├── PLCSIM Advanced API (Headless Virtual S7-1500 Runtime) ├── S7comm Socket Communication Pipelines (`python-snap7`) └── Automated Hardware & Tag Database Exporters (XML/CSV) └─────────────────────────────────────────────────────────────┘ ``` --- ## Operational Capabilities & Agent Directives 1. **TIA Openness .NET Automation**: Author C# and Python (`pythonnet`) scripts communicating with `Siemens.Engineering.dll` to open projects, import SCL sources, execute block compilation, and export project archives. 2. **PLCSIM Advanced API Scripting**: Construct Python scripts orchestrating headless virtual S7-1500 PLC instances, powering virtual hardware on/off and injecting simulated sensor inputs. 3. **Structured Control Language (SCL) Development**: Write type-safe SCL algorithms implementing finite state machines, FIFO buffers, and moving average filters. 4. **Automated XML Block Import/Export**: Parse and generate SIMATIC XML schemas for Data Blocks (`DB`), Function Blocks (`FB`), and PLC Tag Tables. --- ## Production Python Automation: TIA Portal Openness Project Builder (`pythonnet`) Save this script as `tia_openness_builder.py` (requires `pip install pythonnet` and TIA Portal V18/V19 installed): ```python """ Siemens TIA Portal Openness Automation (pythonnet) Connects to Siemens.Engineering.dll, opens an existing .ap19 project, and compiles the PLC software. """ import sys import os import clr # pythonnet OPENNESS_DLL = r"C:\Program Files\Siemens\Automation\Portal V19\PublicAPI\V19\Siemens.Engineering.dll" PROJECT_PATH = r"C:\AutomationProjects\MainPlant.ap19" def automate_tia_portal(): print("--- [INITIALIZING TIA PORTAL OPENNESS AUTOMATION] ---") if not os.path.exists(OPENNESS_DLL): print(f"🚨 Error: TIA Openness DLL not found at: {OPENNESS_DLL}") return # 1. Load Siemens.Engineering .NET Assembly clr.AddReference(OPENNESS_DLL) import Siemens.Engineering as Tia import Siemens.Engineering.Compiler as Compiler # 2. Launch TIA Portal Instance print("Launching TIA Portal instance (Without UI)...") portal = Tia.TiaPortal(Tia.TiaPortalMode.WithoutUserInterface) try: # 3. Open Project print(f"Opening project: {PROJECT_PATH}...") project = portal.Projects.Open(Tia.FileInfo(PROJECT_PATH)) print(f"Project '{project.Name}' opened successfully.") # 4. Locate First PLC Device plc_device = None for device in project.Devices: for item in device.DeviceItems: if item.Classification == Tia.HW.DeviceItemClassifications.CPU: plc_device = item break if plc_device: print(f"Found CPU Target: {plc_device.Name}") software_container = plc_device.GetService[Tia.HW.Features.SoftwareContainer]() if software_container: plc_software = software_container.Software print("Compiling PLC Software Blocks...") # Execute Compilation compile_service = plc_software.GetService[Compiler.ICompilable]() result = compile_service.Compile() print(f"✅ Compilation Complete! Errors: {result.ErrorCount}, Warnings: {result.WarningCount}") # Save and Close project.Save() project.Close() print("Project saved and closed.") finally: portal.Dispose() print("TIA Portal instance disposed cleanly.") if __name__ == "__main__": automate_tia_portal() ``` --- ## Technical Troubleshooting Matrix | Issue & Failure Signature | Root Cause Analysis | Diagnostic & Resolution Pathway | | :--- | :--- | :--- | | **`System.IO.FileNotFoundException: Siemens.Engineering.dll`** | Target .NET assembly missing or path does not match installed TIA Portal version. | Verify exact TIA Portal version directory: `C:\Program Files\Siemens\Automation\Portal V18\PublicAPI\V18\` vs `V19`. | | **Openness Throws `TiaPortalException: Project is write-protected`** | Another TIA Portal GUI process has the project `.ap19` locked in exclusive mode. | Terminate running TIA instances: `taskkill /F /IM Siemens.Automation.Portal.exe`. | | **PLCSIM Advanced Returns `Error: RuntimeManager not initialized`** | `Siemens.Simatic.Simulation.Runtime.Manager.exe` background service is stopped. | In Windows Services, start **Siemens PLCSIM Advanced Service** and verify virtual network adapter status. | | **SCL Import Throws `Tag already defined in block`** | SCL text file contains duplicate variable names across `VAR_INPUT` and `VAR_TEMP`. | Ensure variable identifiers are unique within the Function Block scope. | --- ## Command Line Syntax & Batch Processing ```bash # Validate Openness DLL Presence powershell -Command "Test-Path 'C:\Program Files\Siemens\Automation\Portal V19\PublicAPI\V19\Siemens.Engineering.dll'" # Run Python Openness Automation Script python tia_openness_builder.py ``` ### Essential File Locations - **Openness Assembly**: `C:\Program Files\Siemens\Automation\Portal V19\PublicAPI\V19\Siemens.Engineering.dll` - **PLCSIM Advanced API**: `C:\Program Files\Siemens\Automation\PLCSIMADV\bin\Siemens.Simatic.Simulation.Runtime.Api.x64.dll` --- ## Agent Operational Directive > **MANDATORY**: Always call `portal.Dispose()` within a `finally:` block when automating TIA Portal via Openness to prevent orphaned background processes from holding file locks on `.ap19` project databases.