Skip to main content

pytwincatparser

A Python package for parsing TwinCAT PLC files (TcPOU, TcDUT, TcIO, TcPlcProj, TcGvl, 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, .TcGvl, .TcPlcProj)
  • Load the twincatfile in python dataclasses
  • parse variable blocks
  • parse documentation
  • parse dependencies

Installation

pip install pytwincatparser

Usage

_strategy: BaseStrategy = None
_collected: dict[str, Objects] = {}

# for now only "twincat4024" strategy is allowed
if config.default_strategy is not None:
    strategy = get_strategy(config.default_strategy)
else:
    strategy = get_default_strategy()

# set the loader with the right strategy
_strategy = strategy()
_loader: Loader = Loader(loader_strategy=_strategy)

# load every file
for path in paths:
    tcobjects = _loader.load_objects(path=path)
    # for every found object
    for tcobject in tcobjects:
        # get identifier (fb_main.Do_This) and check if such a object is not loaded already
        if not tcobject.get_identifier() in _collected:
            _collected[tcobject.get_identifier()] = tcobject

Requirements

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

License

MIT

Todo

  • Add support for return values of methods and functions
  • Add support for specifier like CONSTANT and PERSISTEN in Variable blocks

Metadata

Release files for pytwincatparser 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytwincatparser 0.5.6
File Size Uploaded Provenance Actions
pytwincatparser-0.5.6.tar.gz 41.5 kB Without provenance Details for pytwincatparser-0.5.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytwincatparser 0.5.6
File Interpreter ABI Platform Actions
pytwincatparser-0.5.6-py3-none-any.whl Python 3 none any Details for pytwincatparser-0.5.6-py3-none-any.whl

Total release size: 63.2 kB

Release files / pytwincatparser-0.5.6.tar.gz

Download URL pytwincatparser-0.5.6.tar.gz
Size 41.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c8c2a837f66913a4754ee9054d874b77404a4e382d7cbc65ddca1deab90a7cbe
BLAKE2b-256 checksum
How to use checksums
49953a5f21144180189b16eb387261e90ed9a0e0f33111f18c5d67cc4a232663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.2

Release files / pytwincatparser-0.5.6-py3-none-any.whl

Download URL pytwincatparser-0.5.6-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a18b86e61b920146dea85bc7c2deb4a613de971f55b325901846d13a8f41a21d
BLAKE2b-256 checksum
How to use checksums
ee8af9d7f3a9b43b80ad3fc99cc046868a1d57c281eb242f177f5a9a586f23eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.2

Security for pytwincatparser 0.5.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page