Skip to content

Commit

Permalink
Merge pull request #968 from slaclab/list_var
Browse files Browse the repository at this point in the history
Override bitsize for list variables, make offset mandatory
  • Loading branch information
slacrherbst authored Aug 22, 2023
2 parents 354d6f6 + 2f2f724 commit 19948c9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python/pyrogue/_Variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ def __init__(self, *,
highWarning=None,
highAlarm=None,
base=pr.UInt,
offset=None,
offset,
numValues=0,
valueBits=0,
valueStride=0,
Expand Down Expand Up @@ -1017,7 +1017,8 @@ def __init__(self, *,
pollInterval=pollInterval,updateNotify=updateNotify,
guiGroup=guiGroup, **kwargs)

# If numValues > 0 the bit size array must only have one entry and the total number of bits must be a multiple of the number of values
# If numValues > 0 the bit size array must only have one entry
# Auto calculate the total number of bits
if numValues != 0:
self._nativeType = np.ndarray
self._ndType = self._base.ndType
Expand All @@ -1029,8 +1030,8 @@ def __init__(self, *,
if valueBits > valueStride:
raise VariableError(f'ValueBits {valueBits} is greater than valueStrude {valueStride}')

if (numValues * valueStride) != sum(bitSize):
raise VariableError(f'Total bitSize {sum(bitSize)} is not equal to multile of numValues {numValues} and valueStride {valueStride}')
# Override the bitSize
bitSize[0] = numValues * valueStride

if self._ndType is None:
raise VariableError(f'Invalid base type {self._base} with numValues = {numValues}')
Expand Down

0 comments on commit 19948c9

Please sign in to comment.