Skip to main content

TwinCAT PLC file parser using xsdata

Project description

pytwincatparser

A Python package for parsing TwinCAT PLC files (TcPOU, TcDUT, TcIO).

Description

This package provides tools to parse and work with TwinCAT PLC files. It uses xsdata to handle XML parsing. Be aware, that this is a python lib written by a beginner with help of AI assisted programming. My main work task is to design and program industrial machines, not develop python programms!

Features

  • Parse TwinCAT PLC files (.TcPOU, .TcDUT, .TcIO)
  • Access POU (Program Organization Units), DUT (Data Unit Types), and ITF (Interfaces)
  • Extract declarations, implementations, methods, and properties
  • Extract VAR Blocks
  • Extract Return Values
  • Extract Comments

Installation

This project uses uv as its package manager. To set up the development environment:

Windows

# Install uv if you don't have it
pip install uv

# Run the setup script
.\setup_uv.ps1

Usage

from pytwincatparser_xsdata.TwincatParser import TwinCatLoader

# Initialize the loader with the path to TwinCAT files
loader = TwinCatLoader(search_path="path/to/twincat/files")

# Load all TwinCAT files
loader.load()

# Get a specific object by name
pou = loader.getItemByName("FB_Base.TcPOU")

# Get all loaded objects
all_objects = loader.getAllItems()

Look in the example folder!

Requirements

  • Python 3.11
  • lxml >= 5.3.0
  • xsdata[lxml] >= 24.12

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytwincatparser-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytwincatparser-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pytwincatparser-0.1.0.tar.gz.

File metadata

  • Download URL: pytwincatparser-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for pytwincatparser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fc9ba0c8c60848c107902b7b2c224fb3e1eec27336ddd6424af67d37fc62617
MD5 16021cfcc7061a55c08067fbc39b3a91
BLAKE2b-256 9d204e2edfef07a1fd4dcfc07160d5ff3b163a0f575ccc29b539a7b8fd4483fd

See more details on using hashes here.

File details

Details for the file pytwincatparser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytwincatparser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d81cb28dc46c13125ed94b814b583bcd773264058afcb6940252a6851db7e3eb
MD5 6907cecd9a17b4e6254de3edd476c7f9
BLAKE2b-256 07b9526a16e132d92095def36d1f924245d8d67579eb659328326809d0744347

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page