11from pvi .device import (
22 CheckBox ,
3+ ImageColorMap ,
4+ ImageRead ,
35 ReadWidgetUnion ,
46 TableRead ,
57 TableWrite ,
68 WriteWidgetUnion ,
79)
810
9- from fastcs .datatypes import Bool , DataType , Table , numpy_to_fastcs_datatype
11+ from fastcs .datatypes import Bool , DataType , Table , Waveform , numpy_to_fastcs_datatype
1012from fastcs .transports .epics .gui import EpicsGUI
1113
1214
@@ -18,31 +20,39 @@ class PvaEpicsGUI(EpicsGUI):
1820 def _get_pv (self , attr_path : list [str ], name : str ):
1921 return f"pva://{ super ()._get_pv (attr_path , name )} "
2022
21- def _get_read_widget (self , fastcs_datatype : DataType ) -> ReadWidgetUnion | None : # noqa: F821
22- if isinstance (fastcs_datatype , Table ):
23- fastcs_datatypes = [
24- numpy_to_fastcs_datatype (datatype )
25- for _ , datatype in fastcs_datatype .structured_dtype
26- ]
27-
28- base_get_read_widget = super ()._get_read_widget
29- widgets = [base_get_read_widget (datatype ) for datatype in fastcs_datatypes ]
30-
31- return TableRead (widgets = widgets ) # type: ignore
32- else :
33- return super ()._get_read_widget (fastcs_datatype )
23+ def _get_read_widget (self , fastcs_datatype : DataType ) -> ReadWidgetUnion | None :
24+ match fastcs_datatype :
25+ case Table ():
26+ fastcs_datatypes = [
27+ numpy_to_fastcs_datatype (datatype )
28+ for _ , datatype in fastcs_datatype .structured_dtype
29+ ]
30+
31+ base_get_read_widget = super ()._get_read_widget
32+ widgets = [
33+ base_get_read_widget (datatype ) for datatype in fastcs_datatypes
34+ ]
35+
36+ return TableRead (widgets = widgets ) # type: ignore
37+ case Waveform (shape = (height , width )):
38+ return ImageRead (
39+ height = height , width = width , color_map = ImageColorMap .GRAY
40+ )
41+ case _:
42+ return super ()._get_read_widget (fastcs_datatype )
3443
3544 def _get_write_widget (self , fastcs_datatype : DataType ) -> WriteWidgetUnion | None :
36- if isinstance (fastcs_datatype , Table ):
37- widgets = []
38- for _ , datatype in fastcs_datatype .structured_dtype :
39- fastcs_datatype = numpy_to_fastcs_datatype (datatype )
40- if isinstance (fastcs_datatype , Bool ):
41- # Replace with compact version for Table row
42- widget = CheckBox ()
43- else :
44- widget = super ()._get_write_widget (fastcs_datatype )
45- widgets .append (widget )
46- return TableWrite (widgets = widgets )
47- else :
48- return super ()._get_write_widget (fastcs_datatype )
45+ match fastcs_datatype :
46+ case Table ():
47+ widgets = []
48+ for _ , datatype in fastcs_datatype .structured_dtype :
49+ fastcs_datatype = numpy_to_fastcs_datatype (datatype )
50+ if isinstance (fastcs_datatype , Bool ):
51+ # Replace with compact version for Table row
52+ widget = CheckBox ()
53+ else :
54+ widget = super ()._get_write_widget (fastcs_datatype )
55+ widgets .append (widget )
56+ return TableWrite (widgets = widgets )
57+ case _:
58+ return super ()._get_write_widget (fastcs_datatype )
0 commit comments