Python Module API

Python Module API

Syntalos provides a Python API to easily build new modules. Python modules do not run within the Syntalos process, and instead communicate with the main application via an interface provided by the syntalos_mlink Python module. This API can be used from either the Python Script module, or by standalone modules that are written in Python entirely.

The Python interface is documented below.

syntalos_mlink

Syntalos Python Module Interface

class VectorDouble(pybind11_builtins.pybind11_object):
VectorDouble()

__init__(args, *kwargs) Overloaded function.

  1. __init__(self: VectorDouble) -> None

  2. __init__(self: VectorDouble, arg0: list[float]) -> None

Copy constructor

  1. __init__(self: VectorDouble, arg0: Iterable) -> None
def count(unknown):

count(self: list[float], x: float) -> int

Return the number of times x appears in the list

def remove(unknown):

remove(self: list[float], x: float) -> None

Remove the first item from the list whose value is x. It is an error if there is no such item.

def append(unknown):

append(self: list[float], x: float) -> None

Add an item to the end of the list

def clear(unknown):

clear(self: list[float]) -> None

Clear the contents

def extend(unknown):

extend(args, *kwargs) Overloaded function.

  1. extend(self: list[float], L: list[float]) -> None

Extend the list by appending all the items in the given list

  1. extend(self: list[float], L: Iterable) -> None

Extend the list by appending all the items in the given list

def insert(unknown):

insert(self: list[float], i: int, x: float) -> None

Insert an item at a given position.

def pop(unknown):

pop(args, *kwargs) Overloaded function.

  1. pop(self: list[float]) -> float

Remove and return the last item

  1. pop(self: list[float], i: int) -> float

Remove and return the item at index i

class SyntalosPyError(builtins.Exception):

Common base class for all non-exit exceptions.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
def list_types_synonyms(unknown):

list_types_synonyms() -> object

class InputPort(pybind11_builtins.pybind11_object):

Representation of a module input port.

InputPort(*args, **kwargs)
on_data

(arg0: InputPort) -> Callable[[object], None]

metadata

(arg0: InputPort) -> QVariantHash

def set_throttle_items_per_sec(unknown):

set_throttle_items_per_sec(self: InputPort, items_per_sec: int) -> None

Limit the amount of input received to a set amount of elements per second.

name

(self: InputPort) -> str

class OutputPort(pybind11_builtins.pybind11_object):

Representation of a module output port.

OutputPort(*args, **kwargs)
def submit(unknown):

submit(self: OutputPort, arg0: object) -> None

Submit the given entity to the output port for transfer to its destination(s).

name

(self: OutputPort) -> str

def set_metadata_value(unknown):

set_metadata_value(self: OutputPort, arg0: str, arg1: object) -> None

Set (immutable) metadata value for this port.

def set_metadata_value_size(unknown):

set_metadata_value_size(self: OutputPort, arg0: str, arg1: object) -> None

Set (immutable) metadata value for a 2D size type for this port.

def firmata_register_digital_pin(unknown):

firmata_register_digital_pin(self: OutputPort, pin_id: int, name: str, is_output: bool, is_pullup: bool = False) -> FirmataControl

Convenience function to create a command to register a named digital pin and immediately submit it on this port. The registered pin can later be referred to by its name.

def firmata_submit_digital_value(unknown):

firmata_submit_digital_value(self: OutputPort, name: str, value: bool) -> FirmataControl

Convenience function to write a digital value to a named pin.

def firmata_submit_digital_pulse(unknown):

firmata_submit_digital_pulse(self: OutputPort, name: str, duration_msec: int = 50) -> FirmataControl

Convenience function to emit a digital pulse on a named pin.

class Frame(pybind11_builtins.pybind11_object):

A video frame.

Frame()

__init__(self: Frame) -> None

index

(self: Frame) -> int

time_usec

(self: Frame) -> datetime.timedelta

mat

(self: Frame) -> numpy.ndarray

class ControlCommandKind(pybind11_builtins.pybind11_object):

Members:

UNKNOWN

START

PAUSE

STOP

STEP

CUSTOM

ControlCommandKind()

__init__(self: ControlCommandKind, value: int) -> None

name

name(self: object) -> str

value

(arg0: ControlCommandKind) -> int

class ControlCommand(pybind11_builtins.pybind11_object):
ControlCommand()

__init__(args, *kwargs) Overloaded function.

  1. __init__(self: ControlCommand) -> None

  2. __init__(self: ControlCommand, arg0: ControlCommandKind) -> None

duration

(arg0: ControlCommand) -> int

command

(self: ControlCommand) -> QString

class FirmataCommandKind(pybind11_builtins.pybind11_object):

Members:

UNKNOWN

NEW_DIG_PIN

NEW_ANA_PIN

IO_MODE

WRITE_ANALOG

WRITE_DIGITAL

WRITE_DIGITAL_PULSE

SYSEX

FirmataCommandKind()

__init__(self: FirmataCommandKind, value: int) -> None

name

name(self: object) -> str

value

(arg0: FirmataCommandKind) -> int

WRITE_DIGITAL_PULSE = <FirmataCommandKind.WRITE_DIGITAL_PULSE: 6>
class FirmataControl(pybind11_builtins.pybind11_object):
FirmataControl()

__init__(args, *kwargs) Overloaded function.

  1. __init__(self: FirmataControl) -> None

  2. __init__(self: FirmataControl, arg0: FirmataCommandKind) -> None

pin_id

(self: FirmataControl) -> int

pin_name

(self: FirmataControl) -> QString

is_output

(self: FirmataControl) -> bool

is_pullup

(self: FirmataControl) -> bool

value

(self: FirmataControl) -> int

class FirmataData(pybind11_builtins.pybind11_object):
FirmataData()

__init__(self: FirmataData) -> None

pin_id

(self: FirmataData) -> int

pin_name

(self: FirmataData) -> QString

value

(self: FirmataData) -> int

is_digital

(self: FirmataData) -> bool

time

(self: FirmataData) -> datetime.timedelta

class IntSignalBlock(pybind11_builtins.pybind11_object):

A block of timestamped integer signal data.

IntSignalBlock()

__init__(self: IntSignalBlock) -> None

timestamps

(self: IntSignalBlock) -> numpy.ndarray[numpy.uint64[m, 1]]

data

(self: IntSignalBlock) -> numpy.ndarray[numpy.int32[m, n]]

length

(arg0: IntSignalBlock) -> int

rows

(arg0: IntSignalBlock) -> int

cols

(arg0: IntSignalBlock) -> int

class FloatSignalBlock(pybind11_builtins.pybind11_object):

A block of timestamped float signal data.

FloatSignalBlock()

__init__(self: FloatSignalBlock) -> None

timestamps

(self: FloatSignalBlock) -> numpy.ndarray[numpy.uint64[m, 1]]

data

(self: FloatSignalBlock) -> numpy.ndarray[numpy.float64[m, n]]

length

(arg0: FloatSignalBlock) -> int

rows

(arg0: FloatSignalBlock) -> int

cols

(arg0: FloatSignalBlock) -> int

def println(unknown):

println(text: str) -> None

Print text to stdout.

def raise_error(unknown):

raise_error(message: str) -> None

Emit an error message string, immediately terminating the current action and (if applicable) the experiment.

def time_since_start_msec(unknown):

time_since_start_msec() -> int

Get time since experiment started in milliseconds.

def time_since_start_usec(unknown):

time_since_start_usec() -> int

Get time since experiment started in microseconds.

def wait(unknown):

wait(msec: int) -> None

Wait (roughly) for the given amount of milliseconds without blocking communication with the master process.

def wait_sec(unknown):

wait_sec(sec: int) -> None

Wait (roughly) for the given amount of seconds without blocking communication with the master process.

def await_data(unknown):

await_data(timeout_usec: int = -1) -> None

Wait for new data to arrive and call selected callbacks. Also keep communication with the Syntalos master process.

def is_running(unknown):

is_running() -> bool

Return True if the experiment is still running, False if we are supposed to shut down.

def schedule_delayed_call(unknown):

schedule_delayed_call(delay_msec: int, callable_fn: Callable[[], None]) -> None

Schedule call to a callable to be processed after a set amount of milliseconds.

def get_input_port(unknown):

get_input_port(id: str) -> object

Get reference to input port with the give ID.

def get_output_port(unknown):

get_output_port(id: str) -> object

Get reference to output port with the give ID.

def call_on_show_settings(unknown):

call_on_show_settings(callable_fn: Callable[[QByteArray], None]) -> None

Call the given function when the module's settings dialog should be shown.

def call_on_show_display(unknown):

call_on_show_display(callable_fn: Callable[[], None]) -> None

Call the given function when the module's display window should be shown.

def save_settings(unknown):

save_settings(settings_data: QByteArray) -> None

Send module settings data to Syntalos for safekeeping.

def new_firmatactl_with_id_name(unknown):

new_firmatactl_with_id_name(kind: FirmataCommandKind, pin_id: int, name: str) -> FirmataControl

Create new Firmata control command with a given pin ID and registered name.

def new_firmatactl_with_id(unknown):

new_firmatactl_with_id(kind: FirmataCommandKind, pin_id: int) -> FirmataControl

Create new Firmata control command with a given pin ID.

def new_firmatactl_with_name(unknown):

new_firmatactl_with_name(kind: FirmataCommandKind, name: str) -> FirmataControl

Create new Firmata control command with a given pin name (the name needs to be registered previously).