Skip to content

Commit 93e1275

Browse files
committed
added EGU options to Attributes in Int and Float
1 parent 82593a0 commit 93e1275

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/fastcs/backends/epics/ioc.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,11 @@ def _get_input_record(pv: str, attribute: AttrR) -> RecordWrapper:
331331
case Bool(znam, onam):
332332
return builder.boolIn(pv, ZNAM=znam, ONAM=onam, **attribute_fields)
333333
case Int():
334-
return builder.longIn(pv, **attribute_fields)
334+
return builder.longIn(pv, EGU=attribute.datatype.units, **attribute_fields)
335335
case Float(prec):
336-
return builder.aIn(pv, PREC=prec, **attribute_fields)
336+
return builder.aIn(
337+
pv, EGU=attribute.datatype.units, PREC=prec, **attribute_fields
338+
)
337339
case String():
338340
return builder.longStringIn(pv, **attribute_fields)
339341
case _:
@@ -368,15 +370,20 @@ def _get_output_record(pv: str, attribute: AttrW, on_update: Callable) -> Any:
368370
always_update=True,
369371
on_update=on_update,
370372
)
371-
case Int():
373+
case Int(units=units):
372374
return builder.longOut(
373-
pv, always_update=True, on_update=on_update, **attribute_fields
375+
pv,
376+
always_update=True,
377+
on_update=on_update,
378+
EGU=units,
379+
**attribute_fields,
374380
)
375-
case Float(prec):
381+
case Float(prec=prec, units=units):
376382
return builder.aOut(
377383
pv,
378384
always_update=True,
379385
on_update=on_update,
386+
EGU=units,
380387
PREC=prec,
381388
**attribute_fields,
382389
)

src/fastcs/datatypes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def dtype(self) -> type[T]: # Using property due to lack of Generic ClassVars
2525
class Int(DataType[int]):
2626
"""`DataType` mapping to builtin ``int``."""
2727

28+
units: str | None = None
29+
2830
@property
2931
def dtype(self) -> type[int]:
3032
return int
@@ -35,6 +37,7 @@ class Float(DataType[float]):
3537
"""`DataType` mapping to builtin ``float``."""
3638

3739
prec: int = 2
40+
units: str | None = None
3841

3942
@property
4043
def dtype(self) -> type[float]:

0 commit comments

Comments
 (0)