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.6.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.6-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lab_device_sdk-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 f7fcd07033a565f0e4df4e21100c80d3eeb35b7b5e08afa5934febc6c632ea2a
MD5 6969227b5b68b30f6bcd79a3d5c0ff66
BLAKE2b-256 6e7260e35813b741c104f2a49a1ac3f2cb98b2c9486890cc9d30f2c90bfc5071

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lab_device_sdk-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 78ac7ae86bf0ad634223cbea4342b0f9d183f63b551626c297629e2b7a1d510b
MD5 6426d9c03eaa8d4b2fc0838577645e8c
BLAKE2b-256 595cb9b7fb1a1511716edb65113b21d08eb126647e9615ac812d4ca1cc0c7f9f

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