Skip to content

Commit 37cb58c

Browse files
committed
Truncate values when setting into an EPICS CA waveform
Remove duplicate value validation
1 parent ed2964e commit 37cb58c

File tree

1 file changed

+4
-1
lines changed
  • src/fastcs/transport/epics/ca

1 file changed

+4
-1
lines changed

src/fastcs/transport/epics/ca/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232

3333
EPICS_ALLOWED_DATATYPES = (Bool, DataType, Enum, Float, Int, String, Waveform)
34+
EPICS_WAVEFORM_LENGTH = 256
3435

3536
DATATYPE_FIELD_TO_RECORD_FIELD = {
3637
"prec": "PREC",
@@ -124,8 +125,10 @@ def cast_to_epics_type(datatype: DataType[T], value: T) -> object:
124125
return datatype.index_of(datatype.validate(value))
125126
else: # enum backed by string record
126127
return datatype.validate(value).name
128+
case String():
129+
return value[: EPICS_WAVEFORM_LENGTH - 1]
127130
case datatype if issubclass(type(datatype), EPICS_ALLOWED_DATATYPES):
128-
return datatype.validate(value)
131+
return value
129132
case _:
130133
raise ValueError(f"Unsupported datatype {datatype}")
131134

0 commit comments

Comments
 (0)