Skip to main content

pymtconnect

Python model classes generated from the MTConnect SysML specification, plus a small set of helpers for querying a live MTConnect agent.

Every class in this package is generated directly from the MTConnect SysML model, so its structure — names, properties, inheritance — mirrors the specification itself.

Installation

pip install pymtconnect

Quick start

Import generated classes directly from the package root:

from pymtconnect import Device, DataItem, CategoryEnum

Every generated class inherits a from_dict / to_dict / to_json protocol for JSON (de)serialization, so building an instance from an MTConnect agent's JSON response — or serializing one back out — needs no extra glue code:

device = Device.from_dict(json_data)
print(device.name, device.uuid)

data = device.to_dict()       # plain dict, ready for json.dumps
text = device.to_json(indent=2)  # or straight to a JSON string

Querying a live agent

mtconnect_client wraps the MTConnect REST endpoints and returns populated instances of the generated classes — no raw dicts:

from pymtconnect.mtconnect_client import probe, current, sample, stream_sample

header, devices = probe("http://demo.mtconnect.org")
header, events, conditions = current("http://demo.mtconnect.org")
header, events, conditions = sample("http://demo.mtconnect.org", count=100)

for header, events, conditions in stream_sample("http://demo.mtconnect.org", interval=1000):
    ...  # runs until the connection closes or `timeout` elapses

It can also be run directly as a smoke test against any agent:

python -m pymtconnect.mtconnect_client [agent_url]

For a fuller walk of an agent's device tree — including nested Components and DataItems, resolved to their most specific generated class — see probe_example.py:

python -m pymtconnect.probe_example [agent_url]

Both commands default to http://demo.mtconnect.org when agent_url is omitted.

Package layout

Path Contents
Classes/ One module per SysML class (Device, DataItem, Component, …)
Enums/ Generated enumerations (CategoryEnum, UnitEnum, …)
Packages/ Package-level groupings mirroring the SysML model's namespaces
base.py MtconnectBase — the from_dict/to_dict/to_json root class
MtconnectModel.py Root entry point into the generated package hierarchy
mtconnect_client.py probe/current/sample/stream_sample helpers for a live agent
probe_example.py Full device-tree probe example with typed component resolution

License

Apache-2.0

Source

Generated by MtconnectTranspiler.Sinks.Python from the MTConnect SysML model. Issues with the generated package should be filed against MtconnectTranspiler.Sinks.Python.

Download files

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

Source Distribution

pymtconnect-1.0.0.tar.gz (385.1 kB view details)

Uploaded Source

Built Distribution

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

pymtconnect-1.0.0-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file pymtconnect-1.0.0.tar.gz.

File metadata

  • Download URL: pymtconnect-1.0.0.tar.gz
  • Upload date:
  • Size: 385.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pymtconnect-1.0.0.tar.gz
Algorithm Hash digest
SHA256 472bb71727fc92e3158f4bdbc7228cb3fe8638ecaf3d3b7a551632d48c11f1ac
MD5 22ace05c769e9d8d3c1ce489db6adc2a
BLAKE2b-256 6d46789a11e84d50f69376d5990cfbd06fe77dfa5dbbb0fa3a25d154e0480f9e

See more details on using hashes here.

File details

Details for the file pymtconnect-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pymtconnect-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pymtconnect-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bca68f8f948e39b60c44331b1b9e01dbc552bd69873601858ae3cfc003db4a83
MD5 e001f4950447efdac96025a800545ede
BLAKE2b-256 908f4cc9d782c68eefde651c556944d114714d135d8f2787418d1a326417e506

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 files

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