baseio Module¶
BaseIO Class¶
- class tallypi.baseio.BaseIO(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.DispatcherBase 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
BaseInputandBaseOutputhave 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=Truekeyword argument to the class definition.This tells
BaseIOto track the subclass and makes it available inget_class_for_namespace()andget_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
- 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]¶
- 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.Optiondefinitions 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_options() → Dict[source]¶
Serialize the values defined in
get_init_options()using theconfig.Option.nameas keys andconfig.Option.serialize()as values.This can then be used to create an instance using the
create_from_options()method
- screen_matches(screen: tslumd.tallyobj.Screen) → bool[source]¶
Determine whether the given screen matches the
configUses either
SingleTallyConfig.matches_screen()orMultiTallyConfig.matches_screen(), depending on which of the two are used for theBaseIOsubclass
- 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
configUses either
SingleTallyConfig.matches()orMultiTallyConfig.matches(), depending on which of the two are used for theBaseIOsubclass- Parameters
tally – Either another
SingleTallyConfig, atslumd.tallyobj.Tallyinstance or a TallyKeytally_type – If provided, a
TallyTypemember (or members) to match againstreturn_matched – If False (the default), only return a boolean result, otherwise return the matched
SingleTallyConfigif 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.BaseIOBase class for tally inputs
- Parameters
config – The initial value for
config- Events
- on_screen_added(instance: BaseInput, screen: tslumd.tallyobj.Screen)¶
Fired when a
Screenhas been added
- on_tally_added(instance: BaseInput, tally: tslumd.tallyobj.Tally)¶
Fired when a
Tallyinstance has been added
- on_tally_updated(instance: BaseInput, tally: tslumd.tallyobj.Tally)¶
Fired when any
Tallyinstance has been updated
- get_screen(screen_index: int) → Optional[tslumd.tallyobj.Screen][source]¶
Get a
Screenobject by the given indexIf no screen exists,
Noneis returned
- get_all_screens() → Iterable[tslumd.tallyobj.Screen][source]¶
Get all available
Screeninstances for the input
- get_tally(tally_key: Tuple[int, int]) → Optional[tslumd.tallyobj.Tally][source]¶
Get a
Tallyobject by the given keyIf no tally information exists for this input,
Noneis returned- Parameters
tally_key (tslumd.common.TallyKey) – A tuple of (
screen_index,tally_index) formatted asSingleTallyConfig.tally_key
- get_all_tallies(screen_index: Optional[int] = None) → Iterable[tslumd.tallyobj.Tally][source]¶
Get all available
Tallyinstances 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
TallyColorfor the given TallyKey and TallyTypeIf the tally state is unknown for does not match the
config,Noneis returned
BaseOutput Class¶
- class tallypi.baseio.BaseOutput(*args, **kwargs)[source]¶
Bases:
tallypi.baseio.BaseIOBase class for tally outputs
- Parameters
config – The initial value for
config
- bound_inputs: Dict[str, tallypi.baseio.BaseInput]¶
Mapping of all
BaseInputinstances this object is bound to, stored using theidas 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
inputSearches for any
matching talliesin the input and callsbind_to_tally()for them.Store the input object in
bound_inputsBinds to the
BaseInput.on_tally_addedevent to listen for new tallies.
- 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
TallyCalls
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
Tallyobjects inbound_inputswith the given TallyKey
- 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_inputsfor any matching tally and tally_type. The result is a combination of all of the matches as described intslumd.tallyobj.Tally.merge_color()