tslumd.tallyobj

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

Bases: pydispatch.dispatch.Dispatcher

A single tally object

Properties
rh_tally: TallyColorProperty(TallyColor)

State of the right-hand tally indicator

txt_tally: TallyColorProperty(TallyColor)

State of the text tally indicator

lh_tally: TallyColorProperty(TallyColor)

State of the left-hand tally indicator

brightness: intProperty(int)

Tally indicator brightness from 0 to 3

text: strProperty(str)

Text to display

control: bytesProperty(bytes)

Any control data received for the tally indicator

normalized_brightness: floatProperty(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: Optional[tslumd.tallyobj.Screen]

The parent Screen this tally belongs to

New in version 0.0.3.

property indexint   [read-only]

Index of the tally object from 0 to 65534 (0xfffe)

property idtyping.Tuple[int, int]   [read-only]

A key to uniquely identify a Tally / Screen combination.

Tuple of (Screen.index, Tally.index)

Raises

ValueError – If the Tally.screen is None

New in version 0.0.3.

property is_broadcastbool   [read-only]

True if the tally is to be “broadcast”, meaning sent to all display indices.

(if the index is 0xffff)

New in version 0.0.2.

classmethod broadcast(**kwargs)tslumd.tallyobj.Tally[source]

Create a broadcast tally

(with index set to 0xffff)

New in version 0.0.2.

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

Create an instance from the given Display object

set_color(tally_type: Union[str, tslumd.common.TallyType], color: Union[str, tslumd.common.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: Union[str, tslumd.common.TallyType])tslumd.common.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: tslumd.common.TallyType, color: tslumd.common.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: tslumd.tallyobj.Tally, tally_type: Optional[tslumd.common.TallyType] = <TallyType.all_tally: 7>)[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: tslumd.messages.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: pydispatch.dispatch.Dispatcher

A group of Tally displays

Properties
scontrol: bytesProperty(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, tslumd.tallyobj.Tally]

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

property indexint   [read-only]

The screen index from 0 to 65534 (0xFFFE)

property is_broadcastbool   [read-only]

True if the screen is to be “broadcast”, meaning sent to all screen indices.

(if the index is 0xffff)

classmethod broadcast(**kwargs)tslumd.tallyobj.Screen[source]

Create a broadcast Screen

(with index set to 0xffff)

broadcast_tally(**kwargs)tslumd.tallyobj.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)tslumd.tallyobj.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)tslumd.tallyobj.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: tslumd.messages.Message)[source]

Handle an incoming Message