11from pvi .device import (
22 CheckBox ,
3+ ImageRead ,
34 ReadWidgetUnion ,
45 TableRead ,
56 TableWrite ,
67 WriteWidgetUnion ,
78)
89
9- from fastcs .datatypes import Bool , DataType , Table , numpy_to_fastcs_datatype
10+ from fastcs .datatypes import Bool , DataType , Table , Waveform , numpy_to_fastcs_datatype
1011from fastcs .transports .epics .gui import EpicsGUI
1112
1213
@@ -18,31 +19,37 @@ class PvaEpicsGUI(EpicsGUI):
1819 def _get_pv (self , attr_path : list [str ], name : str ):
1920 return f"pva://{ super ()._get_pv (attr_path , name )} "
2021
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 )
22+ def _get_read_widget (self , fastcs_datatype : DataType ) -> ReadWidgetUnion | None :
23+ match fastcs_datatype :
24+ case Table ():
25+ fastcs_datatypes = [
26+ numpy_to_fastcs_datatype (datatype )
27+ for _ , datatype in fastcs_datatype .structured_dtype
28+ ]
29+
30+ base_get_read_widget = super ()._get_read_widget
31+ widgets = [
32+ base_get_read_widget (datatype ) for datatype in fastcs_datatypes
33+ ]
34+
35+ return TableRead (widgets = widgets ) # type: ignore
36+ case Waveform (shape = (height , width )):
37+ return ImageRead (height = height , width = width , grayscale = True )
38+ case _:
39+ return super ()._get_read_widget (fastcs_datatype )
3440
3541 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 )
42+ match fastcs_datatype :
43+ case Table ():
44+ widgets = []
45+ for _ , datatype in fastcs_datatype .structured_dtype :
46+ fastcs_datatype = numpy_to_fastcs_datatype (datatype )
47+ if isinstance (fastcs_datatype , Bool ):
48+ # Replace with compact version for Table row
49+ widget = CheckBox ()
50+ else :
51+ widget = super ()._get_write_widget (fastcs_datatype )
52+ widgets .append (widget )
53+ return TableWrite (widgets = widgets )
54+ case _:
55+ return super ()._get_write_widget (fastcs_datatype )
0 commit comments