mirror of
https://github.com/ivan-usov-org/bec.git
synced 2025-04-21 10:10:02 +02:00
feat(client): custom summary for devices including docs
This commit is contained in:
parent
99173c02fd
commit
2c530bfbb7
@ -10,9 +10,11 @@ import inspect
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from collections import namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.table import Table
|
||||||
from typeguard import typechecked
|
from typeguard import typechecked
|
||||||
|
|
||||||
from bec_lib.endpoints import MessageEndpoints
|
from bec_lib.endpoints import MessageEndpoints
|
||||||
@ -832,11 +834,42 @@ class Device(OphydInterfaceBase):
|
|||||||
via the scan server.
|
via the scan server.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@rpc
|
# @rpc
|
||||||
def summary(self):
|
def summary(self):
|
||||||
"""
|
"""
|
||||||
Provides a summary of the device, all associated signals and their type.
|
Provides a summary of the device, all associated signals and their type.
|
||||||
"""
|
"""
|
||||||
|
table = Table(title=f"{self.name} - Summary of Available Signals")
|
||||||
|
table.add_column("Name")
|
||||||
|
table.add_column("Data Name")
|
||||||
|
table.add_column("Kind")
|
||||||
|
table.add_column("Source")
|
||||||
|
table.add_column("Type")
|
||||||
|
table.add_column("Doc")
|
||||||
|
signals = self._info.get("signals", {})
|
||||||
|
signals_grouped = defaultdict(dict)
|
||||||
|
for kind in ["hinted", "normal", "config", "omitted"]:
|
||||||
|
signals_grouped[kind] = {
|
||||||
|
signal_name: signal_info
|
||||||
|
for signal_name, signal_info in signals.items()
|
||||||
|
if kind in signal_info.get("kind_str")
|
||||||
|
}
|
||||||
|
kind_added = False
|
||||||
|
for kind in ["hinted", "normal", "config", "omitted"]:
|
||||||
|
if kind_added:
|
||||||
|
table.add_row()
|
||||||
|
for signal_name, signal_info in signals_grouped[kind].items():
|
||||||
|
table.add_row(
|
||||||
|
signal_name,
|
||||||
|
signal_info.get("obj_name"),
|
||||||
|
signal_info.get("kind_str"),
|
||||||
|
signal_info.get("describe", {}).get("source"),
|
||||||
|
signal_info.get("describe", {}).get("dtype"),
|
||||||
|
signal_info.get("doc"),
|
||||||
|
)
|
||||||
|
kind_added = True
|
||||||
|
console = Console()
|
||||||
|
console.print(table)
|
||||||
|
|
||||||
|
|
||||||
class AdjustableMixin:
|
class AdjustableMixin:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user