vtivrt.packet
Classes related to the parsing of VRT packets.
Members
- class vtivrt.packet.BitField(word: bytes)
Bases:
objectA superclass representing a 32-bit integer broken into specific bit fields. Subclasses should override _fields_ with a tuple such as:
class MyBitField(BitField): _fields_ = ( ('foo', 24), ('bar', 8), )
This defines a MyBitField class with a “foo” field in the lower 24 bits, and a “bar” field in the upper 8 bits.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VrtContextEvents(word: bytes)
Bases:
BitFieldThe events word of a VRT context packet
- Variables:
user_defined – (8 bits) The user defined event flags. Use
constants.VrtMeasInfoUserEventto decode this value.indicators – (12 bits) The event flag indicators. Use
constants.VrtLogicalEventsto decode this value.enables – (12 bits) The event flag enables. Use
constants.VrtLogicalEventsto decode this value. When a bit is 1, the corresponding bit in indicators is valid and should be read.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VrtHeader(word: bytes)
Bases:
BitFieldThe header word of a VRT packet
- Variables:
size – (16 bits) The total number of 32-bit words in the packet, including this header word.
count – (4 bits) The 4-bit sequence number. This should increment separately for each combination of packet_type and stream_id.
tsf – (2 bits) The meaning of the fractional portion of the timestamp. Decode with
constants.VrtTimestampFractional.tsi – (2 bits) The meaning of the integer portion of the timestamp. Decode with
constants.VrtTimestampInteger.tsm – (1 bit) For context packets, indicates whether the timestamp is an exact match for the timestamp in the associated data packet’s header (True) or instead represents the precise time of the events specified by the contents of the context packet (False).
has_trailer – (1 bit) 1 when a trailer word is included in the packet.
has_class – (1 bit) 1 when a 2-word class specifier is included in the packet.
packet_type – (4 bits) The packet type. Decode with
constants.VrtPacketClass.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VrtMeasInfoEvents(user_defined: VrtMeasInfoUserEvent, enables: VrtLogicalEvents, indicators: VrtLogicalEvents)
Bases:
objectRepresents the
eventsfield of aVtiVrtMeasInfoDatainstance.- Variables:
user_defined – A mask of user-defined event flags.
enables – If a flag is set in this mask, the corresponding bit in
indicatorsis enabled and should be checked.indicators – A mask representing various status conditions. Each flag is only valid if the corresponding bit in
enablesis set.
- static decode(word: int) VrtMeasInfoEvents
Create a new
VrtMeasInfoEventsfrom an unsigned 32-bit integer value.- Parameters:
word – The raw packet data, as an unsigned 32-bit integer.
- encode() int
Convert the trailer back into the raw unsigned integer format.
- class vtivrt.packet.VrtTrailer(context_count: int, enables: VrtTrailerEvents, indicators: VrtTrailerEvents)
Bases:
objectRepresents a VRT Packet Trailer word.
- Variables:
context_count – The number of context packets associated with this packet.
enables – If a flag is set in this mask, the corresponding bit in indicators is enabled and should be checked.
indicators – A mask representing various status conditions. Each flag is only valid if the corresponding bit in enables is set.
- static decode(word: int) VrtTrailer
Create a new
VrtTrailerfrom an unsigned 32-bit integer value.- Parameters:
word – The raw packet data, as an unsigned 32-bit integer.
- encode() int
Convert the trailer back into the raw unsigned integer format.
- class vtivrt.packet.VrtTrailerFields(word: bytes)
Bases:
BitFieldThe trailer word of a VRT packet
- Variables:
context_count – (7 bits) The number of context packets associated with this data packet.
context_en – (1 bit) 1 when context data is enabled for this information stream.
indicators – (12 bits) The trailer flag indicators. Use
constants.VrtTrailerEventsto decode this value.enables – (12 bits) The trailer flag enables. Use
constants.VrtTrailerEventsto decode this value. When a bit is 1, the corresponding bit in indicators is valid and should be read.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VtiVrtExMeasInfoCommentInfo(word: bytes)
Bases:
BitFieldThe comment word of an EXMeasInfo VRT context packet
- Variables:
comment_id – (24 bits) The user-supplied comment-id.
comment_type – (8 bits) The comment type. Decode using
constants.VtiVrtCommentType.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VtiVrtExMeasInfoData(indicators: VtiVrtExMeasInfoContextIndicator, span: int = None, prescaler: int = None, filter_: int = None, range_: float = None, weighting: VtiVrtWeighting = None, eu_type: VtiVrtEuType = None, eu_params: List[int] = None, comment_type: VtiVrtCommentType = None, comment_id: int = None, comment: str = None, trigger_timestamp: Decimal = None, reference_junction: float = None)
Bases:
objectThe VtiVrtExMeasInfoData class represents the payload of the VtiVrtPacketClass.EX_MEAS_INFO packet class.
- Variables:
indicators – This field contains flags to indicate whether any of the other attributes were included in the packet. Attributes whose associated indicator flag is not set will be None.
span – Which stage of a series of divide-by-2 digital decimation filters the data was taken from.
prescaler – The divisor of the selected first stage digital decimation filter.
filter – The filter type.
range – The channel’s nominal maximum input range.
weighting – The channel weighing.
eu_type – The type of EU conversion
eu_params – The list of EU conversion parameters. Interpretation depends on eu_type.
comment_type – The comment type.
comment_id – The user-supplied comment ID.
comment – The comment text.
trigger_timestamp – The timestamp of the trigger event that caused the associated data packet to be acquired.
reference_junction – A reference junction measurement value.
- static decode(words)
Create a new instance of the VtiVrtExMeasInfoData class from a sequence unparsed payload data.
- Parameters:
words – The payload data to be parsed. This should be formatted as a list of 32-bit unsigned integers.
- encode()
Encode the context data as a list of 32-bit unsigned integers.
- class vtivrt.packet.VtiVrtExMeasInfoEu(word: bytes)
Bases:
BitFieldThe EU conversion word of an EXMeasInfo VRT context packet
- Variables:
param_count – (8 bits) The number of EU Conversion parameter fields included.
eu_type – (8 bits) The tyep of EU conversion. Decode using
constants.VtiVrtEuType.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VtiVrtExMeasInfoRange(word: bytes)
Bases:
BitFieldThe range word of an EXMeasInfo VRT context packet. range = mantissa * 10^(exponent)
- Variables:
mantissa – (16 bits) The mantissa portion of the range value
exponent – (8 bits) The exponent portion of the range value, consisting of 1 bit of sign (1=negative) and 7 bits of magnitude.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VtiVrtExMeasInfoSpanInfo(word: bytes)
Bases:
BitFieldThe span info word of an EXMeasInfo VRT context packet
- Variables:
filter – (4 bits) The selected filter type.
prescaler – (4 bits) The selected prescaler divisor.
span – (4 bits) The selected decimation span index.
- decode(word: bytes)
Fill all fields from a
bytesrepresentation of the bitfield
- encode() bytes
Returns a
bytesrepresentation of the bitfield
- class vtivrt.packet.VtiVrtMeasInfoData(indicators: VrtMeasInfoContextIndicator, bandwidth: float = None, reference_level: float = None, over_range_count: int = None, sample_rate: float = None, temperature: float = None, events: VrtMeasInfoEvents = None)
Bases:
objectThe VtiVrtMeasInfoData class represents the payload of the VtiVrtPacketClass.MEAS_INFO packet class.
- Variables:
indicators – This field contains flags to indicate whether any of the other attributes were included in the packet. Attributes whose associated indicator flag is not set will be None.
bandwidth – The input bandwidth of the channel.
reference_level – The reference level of the channel.
over_range_count – The number of samples in the associated packet that are over range.
sample_rate – The sample rate the data was measured at.
temperature – The current temperature of the measurement hardware.
events – The parsed value of the events word.
- static decode(words: List[int])
Create a new instance of the
VtiVrtMeasInfoDataclass from a sequence unparsed payload data.- Parameters:
words – The payload data to be parsed. This should be formatted as a list of 32-bit unsigned integers.
- encode()
Encode the context data as a list of 32-bit unsigned integers.
- class vtivrt.packet.VtiVrtPacket(stream_id: int, count: int, packet_type: VrtPacketType, tsi: VrtTimestampInteger, tsf: VrtTimestampFractional, tsm: bool, timestamp: Decimal = None, oui: int = None, info_class: VtiVrtInfoClass = None, packet_class: VtiVrtPacketClass = None, data: List[float] | List[int] | VtiVrtMeasInfoData | VtiVrtExMeasInfoData = None, trailer: VrtTrailer = None, context: List[VtiVrtPacket] = None)
Bases:
objectRepresents one VRT packet.
- Variables:
stream_id – The unique numerical identifier of this data stream.
count – The 4-bit sequence number. This should increment separately for each combination of packet_type and stream_id.
packet_type – The packet type.
tsi – The meaning of the integer portion of the timestamp.
tsf – The meaning of the fractional portion of the timestamp.
tsm – For context packets, indicates whether the timestamp is an exact match for the timestamp in the associated data packet’s header (True) or instead represents the precise time of the events specified by the contents of the context packet (False).
timestamp – The value of the timestamp fields.
oui – The IANI OUI of the vendor of the product that created this packet. Should always be equal to VTI_OUI for VTI products.
info_class – The class of the information stream that this packet belongs to.
packet_class – The class of the packet.
data – The payload of the packet.
trailer – The parsed information from the packet trailer.
context – The context packets associated with this packet.
- encode(binary_point: int = None) bytearray
Encode the packet as a bytearray suitable for writing to a socket.
- Parameters:
binary_point – If specified, and if the packet is a data packet with an integer data type, the data samples will be interpretted as fixed-point, with a fractional portion the size of this value, in bits.
- static from_socket(sock: socket, binary_point: int = None) VtiVrtPacket
Read data from the supplied socket, and constrct a new VtiVrtPacket from it.
- Parameters:
sock – The socket to read the packet from.
binary_point – If specified, and if the packet is a data packet with an integer data type, the data samples will be interpretted as fixed-point, with a fractional portion the size of this value, in bits.
- static parse_data(sock: socket, samples: int, packet_type: VrtPacketType, packet_class: VtiVrtPacketClass, binary_point: int = None)
Parse the data portion of a VRT packet from the supplied socket.
- Parameters:
sock – The socket to read the packet from.
samples – The size of the data portion, in samples.
packet_type – The packet type field from the header
packet_class – The packet class field
binary_point – If specified, and if the packet is a data packet with an integer data type, the data samples will be interpretted as fixed-point, with a fractional portion the size of this value, in bits.
- to_socket(sock, binary_point=None) None
Write the packet to the supplied socket
- Parameters:
sock – The socket to read the packet from.
binary_point – If specified, and if the packet is a data packet with an integer data type, the data samples will be interpretted as fixed-point, with a fractional portion the size of this value, in bits.