Source code for trsfile.common

from enum import Enum

from trsfile.parametermap import TraceSetParameterMap, TraceParameterDefinitionMap
from trsfile.standardparameters import StandardTraceSetParameters


[docs]class TracePadding(Enum): """Defines the padding mode of the samples in each trace. This can be helpful when not all traces will be the same length. This can be set in :py:func:`trsfile.open()`, :py:func:`trsfile.trs_open()` +----------+---------------------------------------------------------------+ | Mode | Description | +==========+===============================================================+ | NONE | No padding will be used and an exception will be thrown when | | | traces are not of the same length. | +----------+---------------------------------------------------------------+ | PAD | All traces will be padded with zeroes to the maximum trace | | | length. | +----------+---------------------------------------------------------------+ | TRUNCATE | All traces will be truncated to the minimum trace length. | +----------+---------------------------------------------------------------+ | AUTO | Traces will be clipped or padded in the best possible way the | | | storage engine supports. This could mean data is lost which | | | because retroactive padding is not supported. | +----------+---------------------------------------------------------------+ """ NONE = 0 PAD = 1 TRUNCATE = 2 AUTO = 3
[docs]class SampleCoding(Enum): """Defines the encoding of all the samples in the trace. Bit 4 specifies if it is a float (1) or an integer (0), bits 0 to 3 specifies the length of the value. Finally, bits 5-7 are currently reserved and set to 000. This class is just a simple lookup table. """ BYTE = (0x01, 1, 'int8') SHORT = (0x02, 2, 'int16') INT = (0x04, 4, 'int32') FLOAT = (0x14, 4, 'float32') def __new__(cls, coding, size, format): obj = object.__new__(cls) obj._value_ = coding obj.size = size obj.format = format return obj @property def is_float(self): return (self._value_ & 0x10) != 0