baseio Module

BaseIO Class

class tallypi.baseio.BaseIO(*args, **kwargs)[source]

Bases: pydispatch.dispatch.Dispatcher

Base class for tally inputs and outputs

Parameters

config – The initial value for config

namespace: ClassVar[str]

Dotted name given to subclasses to uniquely identify them

BaseInput and BaseOutput have the root namespaces “input” and “output” (respectively).

Subclasses that are meant to be used as inputs or outputs should indicate this by adding a final=True keyword argument to the class definition.

This tells BaseIO to track the subclass and makes it available in get_class_for_namespace() and get_all_namespaces().

This is a class attribute and is generated using keyword arguments in the subclass definition:

>>> from tallypi.common import BaseInput

>>> class AwesomeInputBase(BaseInput, namespace='awesome'):
>>>     pass

>>> class AwesomeTCPInput(AwesomeInputBase, namespace='tcp', final=True):
>>>     pass

>>> print(AwesomeInputBase.namespace)
'input.awesome'
>>> print(AwesomeTCPInput.namespace)
'input.awesome.tcp'
>>> print(repr(BaseInput.get_class_for_namespace('input.awesome.tcp')))
<class '__main__.AwesomeTCPInput'>
config: tallypi.common.TallyConfig

The output tally configuration

running: bool

True if the display is running

property id: Optional[str]

Unique identifier when added as a member of manager.IOContainer

classmethod get_class_for_namespace(namespace: str)tallypi.baseio.BaseIO[source]

Get the BaseIO subclass matching the given namespace

classmethod get_all_namespaces(prefix: Optional[str] = '')Iterable[str][source]

Get all currently available namespaces

classmethod get_init_options()Tuple[tallypi.config.Option][source]

Get the config.Option definitions required for this object

classmethod create_from_options(values: Dict)tallypi.baseio.BaseIO[source]

Create an instance using definitions from get_init_options() and the given values

Parameters

values (dict) – A dict of values formatted as the result from the serialize_options() method

classmethod deserialize(data: Dict)tallypi.baseio.BaseIO[source]

Deserialize an object using data from the serialize() method

serialize()Dict[source]

Serialize the instance values and the class namespace

serialize_options()Dict[source]

Serialize the values defined in get_init_options() using the config.Option.name as keys and config.Option.serialize() as values.

This can then be used to create an instance using the create_from_options() method

async open()[source]

Initalize any necessary device communication

async close()[source]

Close device communication

screen_matches(screen: tslumd.tallyobj.Screen)bool[source]

Determine whether the given screen matches the config

Uses either SingleTallyConfig.matches_screen() or MultiTallyConfig.matches_screen(), depending on which of the two are used for the BaseIO subclass

tally_matches(tally: Union[tslumd.tallyobj.Tally, tallypi.common.SingleTallyConfig, Tuple[int, int]], tally_type: Optional[tslumd.common.TallyType] = <TallyType.all_tally: 7>, return_matched: Optional[bool] = False)Union[bool, tallypi.common.SingleTallyConfig][source]

Determine whether the given tally matches the config

Uses either SingleTallyConfig.matches() or MultiTallyConfig.matches(), depending on which of the two are used for the BaseIO subclass

Parameters
  • tally – Either another SingleTallyConfig, a tslumd.tallyobj.Tally instance or a TallyKey

  • tally_type – If provided, a TallyType member (or members) to match against

  • return_matched – If False (the default), only return a boolean result, otherwise return the matched SingleTallyConfig if one was found.

async on_receiver_tally_change(tally: tslumd.tallyobj.Tally, *args, **kwargs)[source]

Callback for tally updates from tslumd.tallyobj.Tally

BaseInput Class

class tallypi.baseio.BaseInput(*args, **kwargs)[source]

Bases: tallypi.baseio.BaseIO

Base class for tally inputs

Parameters

config – The initial value for config

Events
on_screen_added(instance: BaseInput, screen: tslumd.tallyobj.Screen)

Fired when a Screen has been added

on_tally_added(instance: BaseInput, tally: tslumd.tallyobj.Tally)

Fired when a Tally instance has been added

on_tally_updated(instance: BaseInput, tally: tslumd.tallyobj.Tally)

Fired when any Tally instance has been updated

get_screen(screen_index: int)Optional[tslumd.tallyobj.Screen][source]

Get a Screen object by the given index

If no screen exists, None is returned

get_all_screens()Iterable[tslumd.tallyobj.Screen][source]

Get all available Screen instances for the input

get_tally(tally_key: Tuple[int, int])Optional[tslumd.tallyobj.Tally][source]

Get a Tally object by the given key

If no tally information exists for this input, None is returned

Parameters

tally_key (tslumd.common.TallyKey) – A tuple of (screen_index, tally_index) formatted as SingleTallyConfig.tally_key

get_all_tallies(screen_index: Optional[int] = None)Iterable[tslumd.tallyobj.Tally][source]

Get all available Tally instances for the input

Parameters

screen_index (int, optional) – If present, only include tallies within the specified screen

get_tally_color(tally_key: Tuple[int, int], tally_type: tslumd.common.TallyType)Optional[tslumd.common.TallyColor][source]

Get the current TallyColor for the given TallyKey and TallyType

If the tally state is unknown for does not match the config, None is returned

BaseOutput Class

class tallypi.baseio.BaseOutput(*args, **kwargs)[source]

Bases: tallypi.baseio.BaseIO

Base class for tally outputs

Parameters

config – The initial value for config

bound_inputs: Dict[str, tallypi.baseio.BaseInput]

Mapping of all BaseInput instances this object is bound to, stored using the id as the key

(see bind_to_input())

async bind_to_input(inp: tallypi.baseio.BaseInput)[source]

Find and set up listeners for matching tallies in the input

async unbind_from_input(inp: tallypi.baseio.BaseInput)[source]

Remove all event handlers from an input that were previously set up by bind_to_input()

async bind_to_tally(inp: tallypi.baseio.BaseInput, tally: tslumd.tallyobj.Tally)[source]

Update current state and subscribe to changes from the given Tally

Calls on_receiver_tally_change() and binds tally update events to it

get_all_input_tallies(tally_key: Tuple[int, int])Iterable[Tuple[tallypi.baseio.BaseInput, tslumd.tallyobj.Tally]][source]

Get all Tally objects in bound_inputs with the given TallyKey

Yields
  • inp (BaseInput) – The BaseInput instance containing the tally

  • tally (Tally) – The Tally instance

get_merged_tally(tally: Union[Tuple[int, int], tslumd.tallyobj.Tally], tally_type: tslumd.common.TallyType)tslumd.common.TallyColor[source]

Get the merged tally color of the TallyKey / TallyType combination across all inputs

Searches in all of the bound_inputs for any matching tally and tally_type. The result is a combination of all of the matches as described in tslumd.tallyobj.Tally.merge_color()

Parameters