Skip to content

Commit

Permalink
Add widget and PV creation for String datatype in EPICS backend
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed Oct 13, 2023
1 parent fa735a0 commit 3d6f1d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/fastcs/backends/epics/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
SignalRW,
SignalW,
SignalX,
TextFormat,
TextRead,
TextWrite,
Tree,
WriteWidget,
)

from fastcs.attributes import Attribute, AttrR, AttrRW, AttrW
from fastcs.datatypes import Bool, DataType, Float, Int
from fastcs.datatypes import Bool, DataType, Float, Int, String
from fastcs.exceptions import FastCSException
from fastcs.mapping import Mapping

Expand Down Expand Up @@ -62,6 +63,8 @@ def _get_read_widget(datatype: DataType) -> ReadWidget:
return LED()
case Int() | Float():
return TextRead()
case String():
return TextRead(format=TextFormat.string)

Check warning on line 67 in src/fastcs/backends/epics/gui.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/backends/epics/gui.py#L66-L67

Added lines #L66 - L67 were not covered by tests
case _:
raise FastCSException(f"Unsupported type {type(datatype)}: {datatype}")

Expand All @@ -72,6 +75,8 @@ def _get_write_widget(datatype: DataType) -> WriteWidget:
return CheckBox()
case Int() | Float():
return TextWrite()
case String():
return TextRead(format=TextFormat.string)

Check warning on line 79 in src/fastcs/backends/epics/gui.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/backends/epics/gui.py#L78-L79

Added lines #L78 - L79 were not covered by tests
case _:
raise FastCSException(f"Unsupported type {type(datatype)}: {datatype}")

Expand Down
8 changes: 7 additions & 1 deletion src/fastcs/backends/epics/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from fastcs.attributes import AttrR, AttrRW, AttrW
from fastcs.backend import Backend
from fastcs.datatypes import Bool, DataType, Float, Int
from fastcs.datatypes import Bool, DataType, Float, Int, String
from fastcs.exceptions import FastCSException
from fastcs.mapping import Mapping

Expand All @@ -25,6 +25,8 @@ def _get_input_record(pv_name: str, datatype: DataType) -> RecordWrapper:
return builder.longIn(pv_name)
case Float(prec):
return builder.aIn(pv_name, PREC=prec)
case String():
return builder.longStringIn(pv_name)

Check warning on line 29 in src/fastcs/backends/epics/ioc.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/backends/epics/ioc.py#L28-L29

Added lines #L28 - L29 were not covered by tests
case _:
raise FastCSException(f"Unsupported type {type(datatype)}: {datatype}")

Expand Down Expand Up @@ -54,6 +56,10 @@ def _get_output_record(pv_name: str, datatype: DataType, on_update: Callable) ->
return builder.aOut(
pv_name, always_update=True, on_update=on_update, PREC=prec
)
case String():
return builder.longStringOut(

Check warning on line 60 in src/fastcs/backends/epics/ioc.py

View check run for this annotation

Codecov / codecov/patch

src/fastcs/backends/epics/ioc.py#L59-L60

Added lines #L59 - L60 were not covered by tests
pv_name, always_update=True, on_update=on_update
)
case _:
raise FastCSException(f"Unsupported type {type(datatype)}: {datatype}")

Expand Down

0 comments on commit 3d6f1d8

Please sign in to comment.