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 Nov 1, 2023
1 parent fa735a0 commit f804e8a
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)
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 TextWrite(format=TextFormat.string)
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)
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(
pv_name, always_update=True, on_update=on_update
)
case _:
raise FastCSException(f"Unsupported type {type(datatype)}: {datatype}")

Expand Down

0 comments on commit f804e8a

Please sign in to comment.