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.1.tar.gz (396.9 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.1-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pymtconnect-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3b8b1a9f9797082ca2585bcb55d9b420f9f855070442557d77975138cbd7a72d
MD5 afc89e0c8d37374a9914adc6873eae0c
BLAKE2b-256 a8dfca2a3cc710535282d4a1751db9dccf383d0ac9b9ad8cf7dedc33f2d6ec66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymtconnect-1.0.1-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.7

File hashes

Hashes for pymtconnect-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 301dac446005b8afc09421b2ed1376935251c93b7c20e120f825282611a056c0
MD5 ca07c645dacc5cadaa2eafeaed91641c
BLAKE2b-256 075b43dde7b7c6011493d5f9e260b7121351de232e22a92717ee67218edc75f2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

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