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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lab_device_sdk-0.1.9.tar.gz
  • Upload date:
  • Size: 8.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.9.tar.gz
Algorithm Hash digest
SHA256 b59aca766ed9dfe5c127efcb9d4fa1e56abec68fc63695590a4bed0801c62255
MD5 5920fce7d7cd3b839f2ae39e622750d5
BLAKE2b-256 20589db2f290ee77eb5b6d27858b896a146335437710c4994b00ff89d0163e90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lab_device_sdk-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f66739a77e04324b99576a72da0a1d8abb95ad2c07c30f2bb5d2d9ba3ff8d39e
MD5 d58832609ed83820aa9e2e3520b39de3
BLAKE2b-256 43f4cec930ed4c0e39852ab82bc4f3b42fbb9c2045091dac9e5a0889a48eb798

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