Skip to content

Commit 9d894ef

Browse files
authored
Move PvaEpicsGUI to pva/gui.py (#274)
1 parent 2895e1f commit 9d894ef

File tree

4 files changed

+50
-43
lines changed

4 files changed

+50
-43
lines changed

src/fastcs/transport/epics/gui.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from pvi.device import (
33
LED,
44
ButtonPanel,
5-
CheckBox,
65
ComboBox,
76
ComponentUnion,
87
Device,
@@ -14,8 +13,6 @@
1413
SignalW,
1514
SignalX,
1615
SubScreen,
17-
TableRead,
18-
TableWrite,
1916
TextFormat,
2017
TextRead,
2118
TextWrite,
@@ -35,12 +32,11 @@
3532
Float,
3633
Int,
3734
String,
38-
Table,
3935
Waveform,
4036
)
4137
from fastcs.exceptions import FastCSError
4238
from fastcs.logging import bind_logger
43-
from fastcs.util import numpy_to_fastcs_datatype, snake_to_pascal
39+
from fastcs.util import snake_to_pascal
4440

4541
from .options import EpicsGUIFormat, EpicsGUIOptions
4642

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

218214
return components
219-
220-
221-
class PvaEpicsGUI(EpicsGUI):
222-
"""For creating gui in the PVA EPICS transport."""
223-
224-
def _get_pv(self, attr_path: list[str], name: str):
225-
return f"pva://{super()._get_pv(attr_path, name)}"
226-
227-
def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None:
228-
if isinstance(fastcs_datatype, Table):
229-
fastcs_datatypes = [
230-
numpy_to_fastcs_datatype(datatype)
231-
for _, datatype in fastcs_datatype.structured_dtype
232-
]
233-
234-
base_get_read_widget = super()._get_read_widget
235-
widgets = [base_get_read_widget(datatype) for datatype in fastcs_datatypes]
236-
237-
return TableRead(widgets=widgets) # type: ignore
238-
else:
239-
return super()._get_read_widget(fastcs_datatype)
240-
241-
def _get_write_widget(self, fastcs_datatype: DataType) -> WriteWidgetUnion | None:
242-
if isinstance(fastcs_datatype, Table):
243-
widgets = []
244-
for _, datatype in fastcs_datatype.structured_dtype:
245-
fastcs_datatype = numpy_to_fastcs_datatype(datatype)
246-
if isinstance(fastcs_datatype, Bool):
247-
# Replace with compact version for Table row
248-
widget = CheckBox()
249-
else:
250-
widget = super()._get_write_widget(fastcs_datatype)
251-
widgets.append(widget)
252-
return TableWrite(widgets=widgets)
253-
else:
254-
return super()._get_write_widget(fastcs_datatype)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from pvi.device import (
2+
CheckBox,
3+
ReadWidgetUnion,
4+
TableRead,
5+
TableWrite,
6+
WriteWidgetUnion,
7+
)
8+
9+
from fastcs.datatypes import Bool, DataType, Table
10+
from fastcs.transport.epics.gui import EpicsGUI
11+
from fastcs.util import numpy_to_fastcs_datatype
12+
13+
14+
class PvaEpicsGUI(EpicsGUI):
15+
"""For creating gui in the PVA EPICS transport."""
16+
17+
def _get_pv(self, attr_path: list[str], name: str):
18+
return f"pva://{super()._get_pv(attr_path, name)}"
19+
20+
def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None: # noqa: F821
21+
if isinstance(fastcs_datatype, Table):
22+
fastcs_datatypes = [
23+
numpy_to_fastcs_datatype(datatype)
24+
for _, datatype in fastcs_datatype.structured_dtype
25+
]
26+
27+
base_get_read_widget = super()._get_read_widget
28+
widgets = [base_get_read_widget(datatype) for datatype in fastcs_datatypes]
29+
30+
return TableRead(widgets=widgets) # type: ignore
31+
else:
32+
return super()._get_read_widget(fastcs_datatype)
33+
34+
def _get_write_widget(self, fastcs_datatype: DataType) -> WriteWidgetUnion | None:
35+
if isinstance(fastcs_datatype, Table):
36+
widgets = []
37+
for _, datatype in fastcs_datatype.structured_dtype:
38+
fastcs_datatype = numpy_to_fastcs_datatype(datatype)
39+
if isinstance(fastcs_datatype, Bool):
40+
# Replace with compact version for Table row
41+
widget = CheckBox()
42+
else:
43+
widget = super()._get_write_widget(fastcs_datatype)
44+
widgets.append(widget)
45+
return TableWrite(widgets=widgets)
46+
else:
47+
return super()._get_write_widget(fastcs_datatype)

src/fastcs/transport/epics/pva/transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from fastcs.controller_api import ControllerAPI
55
from fastcs.logging import logger as _fastcs_logger
66
from fastcs.transport.epics.docs import EpicsDocs
7-
from fastcs.transport.epics.gui import PvaEpicsGUI
87
from fastcs.transport.epics.options import (
98
EpicsDocsOptions,
109
EpicsGUIOptions,
1110
EpicsIOCOptions,
1211
)
12+
from fastcs.transport.epics.pva.gui import PvaEpicsGUI
1313
from fastcs.transport.transport import Transport
1414

1515
from .ioc import P4PIOC

tests/transport/epics/pva/test_pva_gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from fastcs.attributes import AttrR, AttrW
1515
from fastcs.datatypes import Table
16-
from fastcs.transport.epics.gui import PvaEpicsGUI
16+
from fastcs.transport.epics.pva.gui import PvaEpicsGUI
1717

1818

1919
def test_get_pv_in_pva(controller_api):

0 commit comments

Comments
 (0)