Metadata-Version: 2.4
Name: pymtconnect
Version: 1.0.1
Summary: Python model classes generated from the MTConnect SysML specification
License: Apache-2.0
Project-URL: Homepage, https://github.com/mnoomnoo/MtconnectTranspiler.Sinks.Python
Project-URL: Issues, https://github.com/mnoomnoo/MtconnectTranspiler.Sinks.Python/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.33
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"

<!-- Generated by MtconnectTranspiler.Sinks.Python 2.6.0.0 -->
# pymtconnect

Python model classes generated from the [MTConnect](https://www.mtconnect.org/) 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

```bash
pip install pymtconnect
```

## Quick start

Import generated classes directly from the package root:

```python
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:

```python
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:

```python
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:

```bash
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`:

```bash
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](https://github.com/mnoomnoo/MtconnectTranspiler.Sinks.Python)
from the [MTConnect SysML model](https://github.com/mtconnect/mtconnect_sysml_model).
Issues with the generated package should be filed against
[MtconnectTranspiler.Sinks.Python](https://github.com/mnoomnoo/MtconnectTranspiler.Sinks.Python/issues).
