You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been looking at implementing NTEnum PVs using p4p and I've run into an issue with setting the alarm and descriptor parts of the struct failing when using a put operation from a client. It looks like this has not been implemented yet in the wrap method and only setting the index or choices is supported. The following change to the wrap method fixes this:
def wrap(self, value, choices=None, **kws):
"""Pack python value into Value
"""
V = self.type()
if choices is not None:
V['value.choices'] = choices
if isinstance(value, dict):
for key in value:
V[key] = value[key]
elif isinstance(value, Value):
for key in value.changedSet():
V[key] = value[key]
else:
# index or string
self.assign(V, value)
if V.changed('value.choices'):
self._choices = V['value.choices']
return self._annotate(V, **kws)
It'd be good to include this in master if you're happy with this fix.
The text was updated successfully, but these errors were encountered:
I recently had a similar issue when initialising an NTEnum struct (see this PR: #154). I think the ideal fix is to make it as similar to the NRScalar wrap() code as possible, something like this:
if isinstance(value, Value):
V = value
elif isinstance(value, ntwrappercommon):
kws.setdefault('timestamp', value.timestamp)
V = value.raw
elif isinstance(value, dict):
V = self.Value(self.type, value)
else:
# index or string (use NTEnum.assign() here, different from NTScalar)
self.assign(V, value)
self._annotate(V, **kws)
However, the code above would break the existing functionality of setting index/choices like this initial={'index': N, 'choices': [...]}.
I've been looking at implementing NTEnum PVs using p4p and I've run into an issue with setting the
alarm
anddescriptor
parts of the struct failing when using a put operation from a client. It looks like this has not been implemented yet in the wrap method and only setting the index or choices is supported. The following change to the wrap method fixes this:It'd be good to include this in master if you're happy with this fix.
The text was updated successfully, but these errors were encountered: