lynx.blocks.SumBlock

class lynx.blocks.SumBlock[source]

Bases: Block

Sum block with configurable signs for each input.

Parameters:

signs – List of “+” or “-” strings, one per input port (minimum 2)

Ports:

Inputs: in1, in2, …, inN (one per sign) Output: out (single output)

Methods

__init__(id, signs[, position, label])

Initialize sum block.

add_parameter(name, value[, expression])

Add a parameter to the block.

add_port(port_id, port_type[, label])

Add a port to the block.

get_parameter(name)

Get parameter value by name.

get_port_sign(port_id)

Get the sign ('+', '-', or '|') for a given port.

get_ports()

Get all ports as dictionaries.

is_input_marker()

Check if this is an input marker block.

is_output_marker()

Check if this is an output marker block.

set_parameter(param_name, value)

Update block parameter and sync to parent diagram.

to_dict()

Serialize block to dictionary for JSON export.

__init__(id: str, signs: List[str], position: Dict[str, float] | None = None, label: str | None = None) None[source]

Initialize sum block.

Parameters:
  • id – Unique block identifier

  • signs – List of exactly 3 signs (“+”, “-”, or “|”) for [top, left, bottom] quadrants. “|” means no connection in that quadrant (Simulink convention)

  • position – Optional {x, y} position on canvas

  • label – Optional user-facing label (defaults to id)

Raises:
  • ValueError – If signs array doesn’t have exactly 3 elements

  • ValueError – If fewer than 2 active inputs (non-“|” signs)

  • ValueError – If signs array contains invalid characters

get_port_sign(port_id: str) str[source]

Get the sign (‘+’, ‘-’, or ‘|’) for a given port.

Parameters:

port_id – Port identifier (e.g., ‘in1’, ‘in2’, ‘in3’)

Returns:

Sign character (‘+’, ‘-’, or ‘|’)

Raises:

ValueError – If port_id is invalid