Skip to content

Latest commit

 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

assets2036py

PyPI License Python

Python library for the assets2036 standard — a lightweight communication protocol for interconnecting devices and services on the factory floor, developed at Arena2036 research campus.

Features

  • Properties — Publish and subscribe to typed values with JSON Schema validation
  • Operations — RPC-style remote procedure calls with request/response pattern
  • Events — Fire-and-forget notifications with timestamp and payload
  • Auto-Discovery — Query available assets and submodels on the network
  • Proxy Pattern — Transparent access to remote assets

Prerequisites

You need an MQTT broker (e.g., Eclipse Mosquitto):

docker run -it -p 1883:1883 eclipse-mosquitto

Installation

pip install assets2036py

For development:

pip install -e ".[dev]"

Quick Start

Asset Owner (Provider)

import time
from assets2036py import AssetManager

def turn_on_handler(context):
    print("Turn on operation invoked!")
    return True

with AssetManager("localhost", 1883, "my_namespace", "my_endpoint") as mgr:
    # Create an asset and bind it to a submodel schema
    my_lamp = mgr.create_asset("my_lamp", "https://raw.githubusercontent.com/boschresearch/assets2036-submodels/master/light.json")
    
    # Set a property value
    my_lamp.light.status.value = "on"
    
    # Bind an operation to a handler function
    my_lamp.light.turn_on.on_invoke(turn_on_handler)
    
    # Keep running to listen for incoming requests
    print("Asset Owner running...")
    time.sleep(60)

Asset Consumer

from assets2036py import AssetManager

with AssetManager("localhost", 1883, "my_namespace", "my_client_endpoint") as mgr:
    # Create a proxy to interact with a remote asset
    lamp_proxy = mgr.create_proxy("my_lamp")
    
    # Read a property value
    status = lamp_proxy.light.status.value
    print(f"Lamp status: {status}")
    
    # Invoke an operation remotely
    result = lamp_proxy.light.turn_on.invoke()
    print(f"Operation result: {result}")

Architecture

  • AssetManager: The main entry point. Manages the MQTT connection and handles the context for all assets and proxies.
  • Asset: Represents a device or service being provided. It contains SubModels based on JSON schemas.
  • SubModel: A collection of Properties, Operations, and Events defined by a specific schema.
  • ProxyAsset: A client-side proxy to interact transparently with remote Assets on the network.

Context

Operations and event callbacks can accept a context object, which provides metadata about the incoming request or event, such as timestamps, source topics, and correlation IDs. This helps in tracing and handling requests correctly.

Contributing

See CONTRIBUTING.md

License

Apache 2.0 — see LICENSE

About

Python support library for assets2036

Topics

Resources

Contributing

Stars

3 stars

Watchers

4 watching

Forks

Releases

Contributors

Languages