Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions src/fastcs/transport/epics/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pvi.device import (
LED,
ButtonPanel,
CheckBox,
ComboBox,
ComponentUnion,
Device,
Expand All @@ -14,8 +13,6 @@
SignalW,
SignalX,
SubScreen,
TableRead,
TableWrite,
TextFormat,
TextRead,
TextWrite,
Expand All @@ -35,12 +32,11 @@
Float,
Int,
String,
Table,
Waveform,
)
from fastcs.exceptions import FastCSError
from fastcs.logging import bind_logger
from fastcs.util import numpy_to_fastcs_datatype, snake_to_pascal
from fastcs.util import snake_to_pascal

from .options import EpicsGUIFormat, EpicsGUIOptions

Expand Down Expand Up @@ -216,39 +212,3 @@ def extract_api_components(self, controller_api: ControllerAPI) -> Tree:
components.append(Group(name=name, layout=Grid(), children=children))

return components


class PvaEpicsGUI(EpicsGUI):
"""For creating gui in the PVA EPICS transport."""

def _get_pv(self, attr_path: list[str], name: str):
return f"pva://{super()._get_pv(attr_path, name)}"

def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None:
if isinstance(fastcs_datatype, Table):
fastcs_datatypes = [
numpy_to_fastcs_datatype(datatype)
for _, datatype in fastcs_datatype.structured_dtype
]

base_get_read_widget = super()._get_read_widget
widgets = [base_get_read_widget(datatype) for datatype in fastcs_datatypes]

return TableRead(widgets=widgets) # type: ignore
else:
return super()._get_read_widget(fastcs_datatype)

def _get_write_widget(self, fastcs_datatype: DataType) -> WriteWidgetUnion | None:
if isinstance(fastcs_datatype, Table):
widgets = []
for _, datatype in fastcs_datatype.structured_dtype:
fastcs_datatype = numpy_to_fastcs_datatype(datatype)
if isinstance(fastcs_datatype, Bool):
# Replace with compact version for Table row
widget = CheckBox()
else:
widget = super()._get_write_widget(fastcs_datatype)
widgets.append(widget)
return TableWrite(widgets=widgets)
else:
return super()._get_write_widget(fastcs_datatype)
47 changes: 47 additions & 0 deletions src/fastcs/transport/epics/pva/gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from pvi.device import (
CheckBox,
ReadWidgetUnion,
TableRead,
TableWrite,
WriteWidgetUnion,
)

from fastcs.datatypes import Bool, DataType, Table
from fastcs.transport.epics.gui import EpicsGUI
from fastcs.util import numpy_to_fastcs_datatype


class PvaEpicsGUI(EpicsGUI):
"""For creating gui in the PVA EPICS transport."""

def _get_pv(self, attr_path: list[str], name: str):
return f"pva://{super()._get_pv(attr_path, name)}"

def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None: # noqa: F821
if isinstance(fastcs_datatype, Table):
fastcs_datatypes = [
numpy_to_fastcs_datatype(datatype)
for _, datatype in fastcs_datatype.structured_dtype
]

base_get_read_widget = super()._get_read_widget
widgets = [base_get_read_widget(datatype) for datatype in fastcs_datatypes]

return TableRead(widgets=widgets) # type: ignore
else:
return super()._get_read_widget(fastcs_datatype)

def _get_write_widget(self, fastcs_datatype: DataType) -> WriteWidgetUnion | None:
if isinstance(fastcs_datatype, Table):
widgets = []
for _, datatype in fastcs_datatype.structured_dtype:
fastcs_datatype = numpy_to_fastcs_datatype(datatype)
if isinstance(fastcs_datatype, Bool):
# Replace with compact version for Table row
widget = CheckBox()
else:
widget = super()._get_write_widget(fastcs_datatype)
widgets.append(widget)
return TableWrite(widgets=widgets)
else:
return super()._get_write_widget(fastcs_datatype)
2 changes: 1 addition & 1 deletion src/fastcs/transport/epics/pva/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from fastcs.controller_api import ControllerAPI
from fastcs.logging import logger as _fastcs_logger
from fastcs.transport.epics.docs import EpicsDocs
from fastcs.transport.epics.gui import PvaEpicsGUI
from fastcs.transport.epics.options import (
EpicsDocsOptions,
EpicsGUIOptions,
EpicsIOCOptions,
)
from fastcs.transport.epics.pva.gui import PvaEpicsGUI
from fastcs.transport.transport import Transport

from .ioc import P4PIOC
Expand Down
2 changes: 1 addition & 1 deletion tests/transport/epics/pva/test_pva_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from fastcs.attributes import AttrR, AttrW
from fastcs.datatypes import Table
from fastcs.transport.epics.gui import PvaEpicsGUI
from fastcs.transport.epics.pva.gui import PvaEpicsGUI


def test_get_pv_in_pva(controller_api):
Expand Down