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.8.tar.gz (7.8 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.8-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lab_device_sdk-0.1.8.tar.gz
  • Upload date:
  • Size: 7.8 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.8.tar.gz
Algorithm Hash digest
SHA256 c018dfbd3cd11b5dce6275a4b484b2b96877612bb2b481abe0fe064fe9a06eb6
MD5 8877a8e193ce1eb69db999a2c197e816
BLAKE2b-256 3a718dd3a81c46397961b85da99e0d9d2d8c40a3ab1eb0f83efaf898cb512247

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lab_device_sdk-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6c119f869df6595ea50349683569d5dc94ba2b1d16196a3cea4658d5ab57ae62
MD5 04aa0c8a7f3c2fd9dda2cb6dc1cb5957
BLAKE2b-256 446f13cdfc43ae7e81410c761d424619ff3660134e89d75835103f8dedaeff61

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