Skip to main content

Library for classes and functions that are used for the development of drivers integrated into Device Hub.

Project description

pre-commit Ruff uv Checked with pyright Actions status Open in Dev Containers PyPI Version Downloads Python Versions Codecov

Usage

Create a device driver by inheriting from the Device class and using decorators:

from lab_device_sdk import Device, command, settings, float_in, int_in, string_in, string_out, StringType

class MyDevice(Device):
    device_type_id = "f423f4b7-d389-42c5-bc44-eb3acee3154d"  # Use a UUID for your device type
    manufacturer = "My Company"
    model = "Model X"

    def __init__(self, device_id: str, configuration: str | None = None):
        super().__init__(device_id, configuration)

    @settings()
    @string_in("Host", "localhost", "Device host address")
    @string_in("Port", "8080", "Device port")
    @int_in("Timeout (sec)", 30, "Connection timeout")
    async def connect(self, host: str, port: str):
        # Connection logic here
        pass

    @command("Get Status", "Get device status")
    @string_out("Status")
    async def get_status(self) -> str:
        return "OK"

    @command("Set Temperature", "Set device temperature")
    @float_in("Temperature (C)", 25.0, "Device temperature")
    async def set_temperature(self, temperature: float):
        pass

    @command("Reset", "Reset the device")
    async def reset(self):
        pass

    @command("Set Mode", "Set device mode")
    @string_in("Mode", "Normal", "Device mode", options=["Normal", "Safe", "Test"], string_type=StringType.CONSTRAINED_TO_OPTIONS)
    async def set_mode(self, mode: str):
        pass

Development

This project has a dev container. If you already have VS Code and Docker installed, you can click the badge above or here to get started. Clicking these links will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.

To publish a new version of the repository, you can run the Publish workflow manually and publish to the staging registry from any branch, and you can check the 'Publish to Primary' option when on main to publish to the primary registry and create a git tag.

Updating from the template

This repository uses a copier template. To pull in the latest updates from the template, use the command: copier update --trust --conflict rej --defaults

Project details


Download files

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

Source Distribution

lab_device_sdk-0.1.7.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

lab_device_sdk-0.1.7-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file lab_device_sdk-0.1.7.tar.gz.

File metadata

  • Download URL: lab_device_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for lab_device_sdk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 1ea3abe585eb3b2b277c215cde5341481d24df4ff8498e2954973209c7d906c5
MD5 e19a2670d0539402366e98d8bcdbe570
BLAKE2b-256 b7c198cc7c2360bc291e6054a07bc0366b8ebbc2403ff93029c08a73b8204824

See more details on using hashes here.

File details

Details for the file lab_device_sdk-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: lab_device_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for lab_device_sdk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 00b00deaa15ee1d2a43d371c63fd91b1408b94ee4aa34678a26db9c995b0ac93
MD5 784c412f015fe5ad61212e015919ab01
BLAKE2b-256 86b5ee55216deced16ac8ac98887b923dc598ca6d1a7cceed3e5a04dcb04a86b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page