Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@tds_data_type(8, np.uint64)
class Uint64(StructType):
size = 8
struct_declaration = "Q"
@tds_data_type(9, np.single)
class SingleFloat(StructType):
size = 4
struct_declaration = "f"
@tds_data_type(10, np.double)
class DoubleFloat(StructType):
size = 8
struct_declaration = "d"
@tds_data_type(11, None)
class ExtendedFloat(TdmsType):
pass
@tds_data_type(0x19, np.single, set_np_type=False)
class SingleFloatWithUnit(StructType):
size = 4
struct_declaration = "f"
@tds_data_type(0x1A, np.double, set_np_type=False)
self.value = value
self.bytes = _struct_pack('<' + self.struct_declaration, value)
@classmethod
def read(cls, file, endianness="<"):
read_bytes = file.read(cls.size)
return _struct_unpack(endianness + cls.struct_declaration, read_bytes)[0]
@tds_data_type(0, None)
class Void(TdmsType):
pass
@tds_data_type(1, np.int8)
class Int8(StructType):
size = 1
struct_declaration = "b"
@tds_data_type(2, np.int16)
class Int16(StructType):
size = 2
struct_declaration = "h"
@tds_data_type(3, np.int32)
class Int32(StructType):
size = 4
struct_declaration = "l"
@tds_data_type(7, np.uint32)
class Uint32(StructType):
size = 4
struct_declaration = "L"
@tds_data_type(8, np.uint64)
class Uint64(StructType):
size = 8
struct_declaration = "Q"
@tds_data_type(9, np.single)
class SingleFloat(StructType):
size = 4
struct_declaration = "f"
@tds_data_type(10, np.double)
class DoubleFloat(StructType):
size = 8
struct_declaration = "d"
@tds_data_type(11, None)
class ExtendedFloat(TdmsType):
pass
@tds_data_type(0x19, np.single, set_np_type=False)
This is stored as an array of offsets
followed by the contiguous string data.
"""
offsets = [0]
for i in range(number_values):
offsets.append(Uint32.read(file, endianness))
strings = []
for i in range(number_values):
s = file.read(offsets[i + 1] - offsets[i])
strings.append(s.decode('utf-8'))
return strings
@tds_data_type(0x21, np.bool8)
class Boolean(StructType):
size = 1
struct_declaration = "b"
@classmethod
def read(cls, file, endianness="<"):
return bool(super(Boolean, cls).read(file, endianness))
@tds_data_type(0x44, None)
class TimeStamp(TdmsType):
# Time stamps are stored as number of seconds since
# 01/01/1904 00:00:00.00 UTC, ignoring leap seconds,
# and number of 2^-64 fractions of a second.
# Note that the TDMS epoch is not the Unix epoch.
_tdms_epoch = np.datetime64('1904-01-01 00:00:00', 'us')
_fractions_per_microsecond = float(10**-6) / 2**-64
@tds_data_type(4, np.int64)
class Int64(StructType):
size = 8
struct_declaration = "q"
@tds_data_type(5, np.uint8)
class Uint8(StructType):
size = 1
struct_declaration = "B"
@tds_data_type(6, np.uint16)
class Uint16(StructType):
size = 2
struct_declaration = "H"
@tds_data_type(7, np.uint32)
class Uint32(StructType):
size = 4
struct_declaration = "L"
@tds_data_type(8, np.uint64)
class Uint64(StructType):
size = 8
struct_declaration = "Q"
@tds_data_type(6, np.uint16)
class Uint16(StructType):
size = 2
struct_declaration = "H"
@tds_data_type(7, np.uint32)
class Uint32(StructType):
size = 4
struct_declaration = "L"
@tds_data_type(8, np.uint64)
class Uint64(StructType):
size = 8
struct_declaration = "Q"
@tds_data_type(9, np.single)
class SingleFloat(StructType):
size = 4
struct_declaration = "f"
@tds_data_type(10, np.double)
class DoubleFloat(StructType):
size = 8
struct_declaration = "d"
@tds_data_type(5, np.uint8)
class Uint8(StructType):
size = 1
struct_declaration = "B"
@tds_data_type(6, np.uint16)
class Uint16(StructType):
size = 2
struct_declaration = "H"
@tds_data_type(7, np.uint32)
class Uint32(StructType):
size = 4
struct_declaration = "L"
@tds_data_type(8, np.uint64)
class Uint64(StructType):
size = 8
struct_declaration = "Q"
@tds_data_type(9, np.single)
class SingleFloat(StructType):
size = 4
struct_declaration = "f"
@tds_data_type(2, np.int16)
class Int16(StructType):
size = 2
struct_declaration = "h"
@tds_data_type(3, np.int32)
class Int32(StructType):
size = 4
struct_declaration = "l"
@tds_data_type(4, np.int64)
class Int64(StructType):
size = 8
struct_declaration = "q"
@tds_data_type(5, np.uint8)
class Uint8(StructType):
size = 1
struct_declaration = "B"
@tds_data_type(6, np.uint16)
class Uint16(StructType):
size = 2
struct_declaration = "H"
@tds_data_type(3, np.int32)
class Int32(StructType):
size = 4
struct_declaration = "l"
@tds_data_type(4, np.int64)
class Int64(StructType):
size = 8
struct_declaration = "q"
@tds_data_type(5, np.uint8)
class Uint8(StructType):
size = 1
struct_declaration = "B"
@tds_data_type(6, np.uint16)
class Uint16(StructType):
size = 2
struct_declaration = "H"
@tds_data_type(7, np.uint32)
class Uint32(StructType):
size = 4
struct_declaration = "L"
@tds_data_type(1, np.int8)
class Int8(StructType):
size = 1
struct_declaration = "b"
@tds_data_type(2, np.int16)
class Int16(StructType):
size = 2
struct_declaration = "h"
@tds_data_type(3, np.int32)
class Int32(StructType):
size = 4
struct_declaration = "l"
@tds_data_type(4, np.int64)
class Int64(StructType):
size = 8
struct_declaration = "q"
@tds_data_type(5, np.uint8)
class Uint8(StructType):
size = 1
struct_declaration = "B"