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.10.tar.gz (9.4 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.10-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lab_device_sdk-0.1.10.tar.gz
  • Upload date:
  • Size: 9.4 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.10.tar.gz
Algorithm Hash digest
SHA256 aff11dcc47924a6794adde89b8b56bea6e32915713f9a6f29a21cda3fd59d272
MD5 f3fab15b9cb735ef701c56ccd49e7dc7
BLAKE2b-256 668207ccd182c930a1d4a07b124af31d9c275285126b1c3eb2e2681364d26877

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lab_device_sdk-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 6a094835017f4b6245f085cde27f70a19cdd0fc68d6de5e9e2c0d3a81748deab
MD5 0ccc4e5b006fc3c13163a763d1624a9b
BLAKE2b-256 7f7b55efa93fc72cd242c7268afa781b80119d55b6935a155e70ebfb5e29424c

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