Skip to content

Commit

Permalink
Merge pull request #413 from ImperialCollegeLondon/manual_device_conf…
Browse files Browse the repository at this point in the history
…ig_dialog

Manual device management dialog
  • Loading branch information
alexdewar authored Nov 21, 2023
2 parents 34a4a78 + 8387c0d commit cc9f81c
Show file tree
Hide file tree
Showing 17 changed files with 911 additions and 335 deletions.
22 changes: 18 additions & 4 deletions finesse/device_info.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Provides common dataclasses about devices for using in backend and frontend."""
from __future__ import annotations

from collections.abc import Sequence
from collections.abc import Iterable, Sequence
from dataclasses import dataclass
from typing import Any

Expand Down Expand Up @@ -36,12 +36,12 @@ def __post_init__(self) -> None:
class DeviceTypeInfo:
"""Description of a device."""

class_name: str
"""The name of the device's class including the module name."""
description: str
"""A human-readable name for the device."""
parameters: list[DeviceParameter]
parameters: Sequence[DeviceParameter]
"""The device parameters."""
class_name: str
"""The name of the device's class including the module name."""


@dataclass(frozen=True)
Expand All @@ -57,6 +57,20 @@ class DeviceBaseTypeInfo:
names_long: Sequence[str]
"""A list of names for this type of device (human readable)."""

def get_instances_and_descriptions(self) -> Iterable[tuple[DeviceInstanceRef, str]]:
"""Get instances and descriptions.
If there are no possible names for the type, then there will only be one
instance, otherwise there will be one per name.
"""
if not self.names_long:
yield DeviceInstanceRef(self.name), self.description
return

for short, long in zip(self.names_short, self.names_long):
instance = DeviceInstanceRef(self.name, short)
yield instance, f"{self.description} ({long})"


@dataclass(frozen=True)
class DeviceInstanceRef:
Expand Down
301 changes: 0 additions & 301 deletions finesse/gui/device_view.py

This file was deleted.

File renamed without changes.
Loading

0 comments on commit cc9f81c

Please sign in to comment.