TwinCAT PLC file parser using xsdata
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytwincatparser-0.5.6.tar.gz.
File metadata
- Download URL: pytwincatparser-0.5.6.tar.gz
- Upload date:
- Size: 41.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8c2a837f66913a4754ee9054d874b77404a4e382d7cbc65ddca1deab90a7cbe
|
|
| MD5 |
240d39077bc8075a54dee50c788fb7c6
|
|
| BLAKE2b-256 |
49953a5f21144180189b16eb387261e90ed9a0e0f33111f18c5d67cc4a232663
|
File details
Details for the file pytwincatparser-0.5.6-py3-none-any.whl.
File metadata
- Download URL: pytwincatparser-0.5.6-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a18b86e61b920146dea85bc7c2deb4a613de971f55b325901846d13a8f41a21d
|
|
| MD5 |
c9612ee53bd948f48f4d3d1b84a255eb
|
|
| BLAKE2b-256 |
ee8af9d7f3a9b43b80ad3fc99cc046868a1d57c281eb242f177f5a9a586f23eb
|