tslumd.sender

tslumd.sender.Client

A network client as a tuple of (address, port)

alias of Tuple[str, int]

class tslumd.sender.UmdSender(*args, **kwargs)[source]

Bases: Dispatcher

Send UMD Messages

Messages are sent immediately when a change is made to any of the Tally objects in tallies. These can be added by using the add_tally() method.

Alternatively, the set_tally_color() and set_tally_text() methods may be used.

Parameters:

Changed in version 0.0.4: The all_off_on_close parameter was added

tx_interval: float = 0.3

Interval to send tally messages, regardless of state changes

clients: set[Tuple[str, int]]

Set of clients to send messages to

all_off_on_close: bool

If True, a broadcast message will be sent before shutdown to turn off all tally lights in the system. (default is False)

New in version 0.0.4.

screens: dict[int, Screen]

Mapping of Screen objects by index

New in version 0.0.3.

tallies: dict[Tuple[int, int], Tally]

Mapping of Tally objects by their id

Note

This should not be altered directly. Use add_tally() instead

Changed in version 0.0.3: The keys are now a combination of the Screen and Tally indices

running: bool

True if the client / server are running

async open()[source]

Open connections and begin data transmission

async close()[source]

Stop sending to clients and close connections

async send_scontrol(screen_index: int, data: bytes)[source]

Send an SCONTROL message

Parameters:
  • screen_index – The screen index for the message

  • data – The data to send in the scontrol field

New in version 0.0.2.

async send_broadcast_scontrol(data: bytes)[source]

Send a broadcast SCONTROL message

Parameters:

data – The data to send in the scontrol field

New in version 0.0.2.

add_tally(tally_id: Tuple[int, int], **kwargs) Tally[source]

Create a Tally object and add it to tallies if one does not exist

If necessary, creates a Screen using get_or_create_screen()

Parameters:
  • tally_id – A tuple of (screen_index, tally_index)

  • **kwargs – Keyword arguments passed to create the tally instance

Raises:

KeyError – If the given tally_id already exists

Changed in version 0.0.3: Chaned the tally_index parameter to tally_id

get_or_create_tally(tally_id: Tuple[int, int]) Tally[source]

If a Tally object matching the given tally id exists, return it. Otherwise, create it using Screen.get_or_create_tally()

This method is similar to add_tally() and it can be used to avoid exception handling. It does not however take keyword arguments and is only intended for object creation.

New in version 0.0.3.

get_or_create_screen(index_: int) Screen[source]

Create a Screen object and add it to screens

Parameters:

index – The screen index

Raises:

KeyError – If the given index_ already exists

New in version 0.0.3.

set_tally_color(tally_id: Tuple[int, int], tally_type: str | TallyType, color: str | TallyColor)[source]

Set the tally color for the given index and tally type

Uses Tally.set_color(). See the method documentation for details

Parameters:

Changed in version 0.0.3: Chaned the tally_index parameter to tally_id

Changed in version 0.0.5: Accept string arguments and match behavior of Tally.set_color()

set_tally_text(tally_id: Tuple[int, int], text: str)[source]

Set the tally text for the given id

Parameters:
  • tally_id – A tuple of (screen_index, tally_index)

  • text – The text to set

Changed in version 0.0.3: Chaned the tally_index parameter to tally_id

async send_tally_control(tally_id: Tuple[int, int], data: bytes)[source]

Send control data for the given screen and tally index

Parameters:
  • tally_id – A tuple of (screen_index, tally_index)

  • control – The control data to send

New in version 0.0.2.

Changed in version 0.0.3: Chaned the tally_index parameter to tally_id

async send_broadcast_tally_control(screen_index: int, data: bytes, **kwargs)[source]

Send control data as broadcast to all listening displays

Parameters:
  • screen_index – The screen index

  • **kwargs – Additional keyword arguments to pass to the Tally constructor

New in version 0.0.2.

Changed in version 0.0.3: Added the screen_index parameter

async send_broadcast_tally(screen_index: int, **kwargs)[source]

Send a broadcast update to all listening displays

Parameters:
  • screen_index – The screen index

  • **kwargs – The keyword arguments to pass to the Tally constructor

New in version 0.0.2.

Changed in version 0.0.3: Added the screen_index parameter