Code reference

shapelink.util

Utility functions

These functions replicate QDataStreams behavior in C++. In PySide2 QDataStream does not accept array type data.

In C++ an array is serialized by writing: 1) Uint32 number of elements 2) type array elements

more significant bytes are written first. (big-endian)

if numpy “to_bytes” is used the native little-endian format appears

shapelink.util.qstream_read_array(stream: PySide2.QtCore.QDataStream, datatype: numpy.dtype) → numpy.array[source]

Read array data from a stream with a specified type

shapelink.util.qstream_write_array(stream: PySide2.QtCore.QDataStream, array: numpy.array)int[source]

Write array data to a stream with a specified type :param stream: :param array: :return:

shapelink.shapein_simulator

Simulate a Shape-In instance

The communication is based on a simple REQ REP pattern all methods return when the transmission was acknowledged by the peer.

class shapelink.shapein_simulator.ShapeInSimulator(destination='tcp://localhost:6666', verbose=False)[source]
register_parameters(scalar_hdf5_names=None, vector_hdf5_names=None, image_hdf5_names=None, settings_names=None, settings_values=None)[source]

Register parameters that are sent to other processes

send_end_of_transmission()[source]

Send end of transmission packet

send_event(event_id: int, scalar_values: numpy.array, vector_values: List[numpy.array], image_values: List[numpy.array])bool[source]

Send a single event to the other process

shapelink.shapein_simulator.start_simulator(path, features=None, verbose=1)[source]

Run a Shape-In simulator using data from an RT-DC dataset

shapelink.msg_def

Definitions for message ids (numeric)

shapelink.msg_def.MSG_ID_EOT = -10

end of transmission

shapelink.msg_def.MSG_ID_EOT_ACK = -11

end of transmission acknowledged

shapelink.msg_def.MSG_ID_REGISTER = -1

registration

shapelink.msg_def.MSG_ID_REGISTER_ACK = -2

registration acknowledged