def native_to_builtin(value, native_type, data_count):
'''Convert from a native EPICS DBR type to a builtin Python type
Notes:
- A waveform of characters is just a bytestring.
- A waveform of strings is an array whose elements are fixed-length (40-
character) strings.
- Enums are just integers that happen to have special significance.
- Everything else is, straightforwardly, an array of numbers.
'''
if USE_NUMPY:
# Return an ndarray
dt = _numpy_map[native_type]
if native_type == ChannelType.STRING and len(value) < MAX_STRING_SIZE:
# caput behaves this way
return numpy.frombuffer(
bytes(value).ljust(MAX_STRING_SIZE, b'\x00'), dtype=dt)
return numpy.frombuffer(value, dtype=dt)
else:
# TODO
raise NotImplementedError("the non-numpy version has not been "
"written yet")
评论列表
文章目录