Code reference
shapelink.shapelink_plugin
Receive data in real-time from a Shape-In instance via zmq
- class shapelink.shapelink_plugin.ShapeLinkPlugin(bind_to='tcp://*:6666', random_port=False, verbose=False)[source]
Shape-Link plug-in meta class
- Parameters
bind_to (str) – IP and port to bind to (where Shape-In runs)
random_port (bool) – If set to True, ZMQ will use its socket.bind_to_random_port method. This will override only the port number of the bind_to ShapeLinkPlugin argument.
verbose (bool) – Set to True to see additional debugging information.
- abstract choose_features()[source]
Abstract method to be overridden by plugins implementations.
Notes
When features are chosen by a plugin implementation, only those chosen features will be transferred between ShapeIn and the plugin. This has the effect of ignoring any features specified by the user in the –features (-f) option of the command line interface.
- abstract handle_event(event_data: shapelink.shapelink_plugin.EventData) bool [source]
Abstract method to be overridden by plugins implementations
- handle_messages()[source]
Handle messages from Shape-In
Please don’t override this function. Use
ShapeLinkPlugin.handle_event()
for your customized plugins.
- run_features_request_message(send_stream)[source]
Called before registration. The user can specify features for Shape-In to send. This limits the data being transferred. This can be useful for plugins that require only specific features.
feats is a list of three lists. The sublists are sc, tr, and im
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.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_reg_features=None, vector_reg_features=None, image_reg_features=None, image_shape=None, settings_names=None, settings_values=None)[source]
Register parameters that are sent to other processes
- shapelink.shapein_simulator.start_simulator(path, features=None, destination='tcp://localhost:6666', verbose=1)[source]
Run a Shape-In simulator using data from an RT-DC dataset
- Parameters
path (str) – File path to a .rtdc file
features (list, default None) – A list of RT-DC features e.g., [“image”, “circ”, “deform”]
destination (str) – The socket to which the ShapeInSimulator will connect. By default it is set to “tcp://localhost:6666”. These are the protocol, host and port in the form “protocol://host:port”.
verbose (int) – Prints extra information during the transfer process, such as simulator speed. Increment to increase verbosity.
See also
shapelink.cli.run_simulator
shapelink.msg_def
Definitions for message ids (numeric)