tslumd.tallyobj

class tslumd.tallyobj.Tally(*args, **kwargs)[source]

Bases: Dispatcher

A single tally object

Properties:
rh_tally: TallyColor Property(TallyColor)

State of the right-hand tally indicator

txt_tally: TallyColor Property(TallyColor)

State of the text tally indicator

lh_tally: TallyColor Property(TallyColor)

State of the left-hand tally indicator

brightness: int Property(int)

Tally indicator brightness from 0 to 3

text: str Property(str)

Text to display

control: bytes Property(bytes)

Any control data received for the tally indicator

normalized_brightness: float Property(float)

The brightness value normalized as a float from 0.0 to 1.0

Events:
on_update(instance: Tally, props_changed: set[str])

Fired when any property changes

on_control(instance: Tally, data: bytes)

Fired when control data is received for the tally indicator

New in version 0.0.2: The on_control event

Changed in version 0.0.5: Added container emulation

screen: Screen | None

The parent Screen this tally belongs to

New in version 0.0.3.

classmethod broadcast(**kwargs) Tally[source]

Create a broadcast tally

(with index set to 0xffff)

New in version 0.0.2.

classmethod from_display(display: Display, **kwargs) Tally[source]

Create an instance from the given Display object

set_color(tally_type: str | TallyType, color: str | TallyColor)[source]

Set the color property (or properties) for the given TallyType

Sets the rh_tally, txt_tally or lh_tally properties matching the TallyType value(s).

If the given tally_type is a combination of tally types, all of the matched attributes will be set to the given color.

Parameters:
>>> from tslumd import Tally, TallyType, TallyColor
>>> tally = Tally(0)
>>> tally.set_color(TallyType.rh_tally, TallyColor.RED)
>>> tally.rh_tally
<TallyColor.RED: 1>
>>> tally.set_color('lh_tally', 'green')
>>> tally.lh_tally
<TallyColor.GREEN: 2>
>>> tally.set_color('rh_tally|txt_tally', 'green')
>>> tally.rh_tally
<TallyColor.GREEN: 2>
>>> tally.txt_tally
<TallyColor.GREEN: 2>
>>> tally.set_color('all', 'off')
>>> tally.rh_tally
<TallyColor.OFF: 0>
>>> tally.txt_tally
<TallyColor.OFF: 0>
>>> tally.lh_tally
<TallyColor.OFF: 0>

New in version 0.0.4.

Changed in version 0.0.5: Allow string arguments and multiple tally_type members

get_color(tally_type: str | TallyType) TallyColor[source]

Get the color of the given tally_type

If tally_type is a combination of tally types, the color returned will be a combination all of the matched color properties.

Parameters:

tally_type (TallyType or str) –

TallyType member(s) to get the color values from.

If the argument is a string, it should be formatted as shown in TallyType.from_str()

>>> tally = Tally(0)
>>> tally.get_color('rh_tally')
<TallyColor.OFF: 0>
>>> tally.set_color('rh_tally', 'red')
>>> tally.get_color('rh_tally')
<TallyColor.RED: 1>
>>> tally.set_color('txt_tally', 'red')
>>> tally.get_color('rh_tally|txt_tally')
<TallyColor.RED: 1>
>>> tally.get_color('all')
<TallyColor.RED: 1>
>>> tally.set_color('lh_tally', 'green')
>>> tally.get_color('lh_tally')
<TallyColor.GREEN: 2>
>>> tally.get_color('all')
<TallyColor.AMBER: 3>

New in version 0.0.5.

merge_color(tally_type: TallyType, color: TallyColor)[source]

Merge the color property (or properties) for the given TallyType using the set_color() method

Combines the existing color value with the one provided using a bitwise | (or) operation

Parameters:

New in version 0.0.4.

merge(other: Tally, tally_type: TallyType = TallyType.all_tally)[source]

Merge the color(s) from another Tally instance into this one using the merge_color() method

Parameters:
  • other (Tally) – The Tally instance to merge with

  • tally_type (TallyType, optional) – The TallyType member(s) to merge. Multiple types can be specified using bitwise | operators. Default is all_tally (all three types)

New in version 0.0.4.

update(**kwargs) set[str][source]

Update any known properties from the given keyword-arguments

Returns:

The property names, if any, that changed

Return type:

set

update_from_display(display: Display) set[str][source]

Update this instance from the values of the given Display object

Returns:

The property names, if any, that changed

Return type:

set

to_dict() dict[source]

Serialize to a dict

class tslumd.tallyobj.Screen(*args, **kwargs)[source]

Bases: Dispatcher

A group of Tally displays

Properties:
scontrol: bytes Property(bytes)

Any control data received for the screen

Events:
on_tally_added(tally: Tally)

Fired when a new Tally instance is added to the screen

on_tally_update(tally: Tally, props_changed: set[str])

Fired when any Tally property changes. This is a retransmission of Tally.on_update

on_tally_control(tally: Tally, data: bytes)

Fired when control data is received for a Tally object. This is a retransmission of Tally.on_control

on_control(instance: Screen, data: bytes)

Fired when control data is received for the Screen itself

New in version 0.0.3.

tallies: dict[int, Tally]

Mapping of Tally objects within the screen using their index as keys

classmethod broadcast(**kwargs) Screen[source]

Create a broadcast Screen

(with index set to 0xffff)

broadcast_tally(**kwargs) Tally[source]

Create a temporary Tally using Tally.broadcast()

Parameters:

**kwargs – Keyword arguments to pass to the Tally constructor

Note

The tally object is not stored in tallies and no event propagation (on_tally_added, on_tally_update, on_tally_control) is handled by the Screen.

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

Create a Tally object and add it to tallies

Parameters:
  • index – The tally index

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

Raises:

KeyError – If the given index_ already exists

get_or_create_tally(index_: int) Tally[source]

If a Tally object matching the given index exists, return it. Otherwise create one and add it to tallies

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.

update_from_message(msg: Message)[source]

Handle an incoming Message