Skip to content

Commit

Permalink
Use Analog records, with PREC=0, for uint records
Browse files Browse the repository at this point in the history
This removes the need to clamp the values to the max of a 32-bit integer
Instead we have the full value of a float64 to represent the value,
which allows us to represent the full range of PandA values
  • Loading branch information
AlexanderWells-diamond committed Sep 23, 2022
1 parent bc0e865 commit 3e88374
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pandablocks/ioc/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ def _make_uint(
# Ensure VAL is clamped to valid range of values.
# The DRVH field is a signed LONG value, but PandA uses unsigned 32-bit
# which can overflow it.
if field_info.max_val > np.iinfo(np.int32).max:
if field_info.max_val > np.finfo(np.float64).max:
logging.warning(
f"Configured maximum value for {record_name} was too large."
f"Restricting to int32 maximum value."
Expand All @@ -1144,8 +1144,9 @@ def _make_uint_param(
return self._make_uint(
record_name,
field_info,
builder.longOut,
builder.aOut,
initial_value=values[record_name],
PREC=0,
)

def _make_uint_read(
Expand All @@ -1158,8 +1159,9 @@ def _make_uint_read(
return self._make_uint(
record_name,
field_info,
builder.longIn,
builder.aIn,
initial_value=values[record_name],
PREC=0,
)

def _make_uint_write(
Expand All @@ -1170,7 +1172,11 @@ def _make_uint_write(
) -> Dict[EpicsName, RecordInfo]:
self._check_num_values(values, 0)
return self._make_uint(
record_name, field_info, builder.longOut, always_update=True
record_name,
field_info,
builder.aOut,
always_update=True,
PREC=0,
)

def _make_int_param(
Expand Down

0 comments on commit 3e88374

Please sign in to comment.