gsf package
Submodules
gsf.binarystream module
- class gsf.binarystream.BinaryStream(stream: StreamEncoder)[source]
Bases:
object
Establishes buffered I/O around a base stream, e.g., a socket.
- IO_BUFFERSIZE = 1420
- VALUE_BUFFERSIZE = 16
gsf.encoding7bit module
- class gsf.encoding7bit.Encoding7Bit[source]
Bases:
object
Defines 7-bit encoding/decoding functions.
- static read_int16(stream_reader: Callable[[], uint8]) int16 [source]
Reads 16-bit signed integer value using 7-bit encoding from the provided stream reader.
- Parameters:
stream_reader (function to read a byte value from a stream)
Notes
Call expects one to two bytes to be available in base stream.
- static read_int32(stream_reader: Callable[[], uint8]) int32 [source]
Reads 32-bit signed integer value using 7-bit encoding from the provided stream reader.
- Parameters:
stream_reader (function to read a byte value from a stream)
Notes
Call expects one to five bytes to be available in base stream.
- static read_int64(stream_reader: Callable[[], uint8]) int64 [source]
Reads 64-bit signed integer value using 7-bit encoding from the provided stream reader.
- Parameters:
stream_writer (function to write a byte value to a stream)
value (64-bit value to write)
Notes
Call expects one to nine bytes to be available in base stream.
- static read_uint16(stream_reader: Callable[[], uint8]) uint16 [source]
Reads 16-bit unsigned integer value using 7-bit encoding from the provided stream reader.
- Parameters:
stream_reader (function to read a byte value from a stream)
Notes
Call expects one to two bytes to be available in base stream.
- static read_uint32(stream_reader: Callable[[], uint8]) uint32 [source]
Reads 32-bit unsigned integer value using 7-bit encoding from the provided stream reader.
- Parameters:
stream_reader (function to read a byte value from a stream)
Notes
Call expects one to five bytes to be available in base stream.
- static read_uint64(stream_reader: Callable[[], uint8]) uint64 [source]
Reads 64-bit unsigned integer value using 7-bit encoding from the provided stream reader.
- Parameters:
stream_writer (function to write a byte value to a stream)
value (64-bit value to write)
Notes
Call expects one to nine bytes to be available in base stream.
- static write_int16(stream_writer: Callable[[uint8], int], value: int16) int [source]
Writes 16-bit signed integer value using 7-bit encoding to the provided stream writer.
- Parameters:
stream_writer (function to write a byte value to a stream)
value (16-bit value to write)
- static write_int32(stream_writer: Callable[[uint8], int], value: int32) int [source]
Writes 32-bit signed integer value using 7-bit encoding to the provided stream writer.
- Parameters:
stream_writer (function to write a byte value to a stream)
value (32-bit value to write)
- static write_int64(stream_writer: Callable[[uint8], int], value: int64) int [source]
Writes 64-bit signed integer value using 7-bit encoding to the provided stream writer.
- Parameters:
stream_writer (function to write a byte value to a stream)
value (64-bit value to write)
- static write_uint16(stream_writer: Callable[[uint8], int], value: uint16) int [source]
Writes 16-bit unsigned integer value using 7-bit encoding to the provided stream writer.
- Parameters:
stream_writer (function to write a byte value to a stream)
value (16-bit value to write)
gsf.endianorder module
- class gsf.endianorder.BigEndian[source]
Bases:
NativeEndian
Manages conversion of bytes to basic types in big endian order.
- swaporder = True
- target_byteorder = 'big'
- class gsf.endianorder.LittleEndian[source]
Bases:
NativeEndian
Manages conversion of bytes to basic types in little endian order.
- swaporder = False
- target_byteorder = 'little'
gsf.streamencoder module
- class gsf.streamencoder.StreamEncoder(read: Callable[[int], bytes], write: Callable[[bytes], int], default_byteorder: str = 'little')[source]
Bases:
object
Defines functions for encoding and decoding native types to and from a stream. For this class, a stream is simply an abstract notion based on provided functions that read and write byte buffers as Python bytes objects advancing a position in the base stream. The read/write functions simply wrap a base object that can handle input and output as bytes, e.g., a bytearray or a socket.
- property default_byteorder: str
Module contents
- class gsf.ByteSize[source]
Bases:
object
- FLOAT16 = 2
- FLOAT32 = 4
- FLOAT64 = 8
- INT16 = 2
- INT32 = 4
- INT64 = 8
- INT8 = 1
- UINT16 = 2
- UINT32 = 4
- UINT64 = 8
- UINT8 = 1
- class gsf.Empty[source]
Bases:
object
- DATETIME = datetime.datetime(1, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
- DECIMAL = Decimal('0')
- DOUBLE = np.float64(0.0)
- GUID = UUID('00000000-0000-0000-0000-000000000000')
- INT16 = np.int16(0)
- INT32 = np.int32(0)
- INT64 = np.int64(0)
- INT8 = np.int8(0)
- SINGLE = np.float32(0.0)
- STRING = ''
- TICKS = np.uint64(0)
- UINT16 = np.uint16(0)
- UINT32 = np.uint32(0)
- UINT64 = np.uint64(0)
- UINT8 = np.uint8(0)
- class gsf.Limits[source]
Bases:
object
- MAXBYTE = 255
- MAXINT16 = 32767
- MAXINT32 = 2147483647
- MAXINT64 = 9223372036854775807
- MAXTICKS = 3155378975999999999
- MAXUINT16 = 65535
- MAXUINT32 = 4294967295
- MAXUINT64 = 18446744073709551615
- MININT16 = -32768
- MININT32 = -2147483648
- MININT64 = -9223372036854775808