common
Module¶
IO Classes¶
-
class
tallypi.common.
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
andBaseOutput
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 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
-
classmethod
get_class_for_namespace
(namespace: str) → tallypi.common.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.Option
definitions required for this object
-
classmethod
create_from_options
(values: Dict) → tallypi.common.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.common.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.name
as 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
config
Uses either
SingleTallyConfig.matches_screen()
orMultiTallyConfig.matches_screen()
, depending on which of the two are used for theBaseIO
subclass
-
tally_matches
(tally: tslumd.tallyobj.Tally) → bool[source]¶ Determine whether the given tally matches the
config
Uses either
SingleTallyConfig.matches()
orMultiTallyConfig.matches()
, depending on which of the two are used for theBaseIO
subclass
-
async
on_receiver_tally_change
(tally: tslumd.tallyobj.Tally, *args, **kwargs)[source]¶ Callback for tally updates from
tslumd.tallyobj.Tally
-
class
tallypi.common.
BaseInput
(*args, **kwargs)[source]¶ Bases:
tallypi.common.BaseIO
Base class for tally inputs
- Parameters
config – The initial value for
config
- Events
-
get_screen
(screen_index: int) → Optional[tslumd.tallyobj.Screen][source]¶ Get a
Screen
object by the given indexIf 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 keyIf no tally information exists for this input,
None
is returned- Parameters
tally_key (tslumd.common.TallyKey) – A tuple of (
screen_index
,tally_index
) formatted asSingleTallyConfig.tally_key
-
get_all_tallies
(screen_index: False) → 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_conf: tallypi.common.SingleTallyConfig) → Optional[tslumd.common.TallyColor][source]¶ Get the current
TallyColor
for the givenconfig specifier
If the tally state is unknown for does not match the
config
,None
is returned
-
class
tallypi.common.
BaseOutput
(*args, **kwargs)[source]¶ Bases:
tallypi.common.BaseIO
Base class for tally outputs
- Parameters
config – The initial value for
config
-
async
bind_to_input
(inp: tallypi.common.BaseInput)[source]¶ Find and set up listeners for matching tallies in the
input
Searches for any matching screens in the input and calls
bind_to_screen()
for them. Also binds to theBaseInput.on_screen_added
event to listen for new screens
-
async
bind_to_screen
(inp: tallypi.common.BaseInput, screen: tslumd.tallyobj.Screen)[source]¶ Find and set up listeners for matching tallies in the given
input
andScreen
Searches for any matching tallies in the input and calls
bind_to_tally()
for them. Also binds to theBaseInput.on_tally_added
event to listen for new tallies from the input
-
async
bind_to_tally
(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
TallyConfig Classes¶
-
class
tallypi.common.
TallyConfig
[source]¶ Bases:
object
Configuration data for tally assignment
-
classmethod
from_dict
(d: Dict) → tallypi.common.TallyConfig[source]¶ Create a
TallyConfig
from serialized data
-
classmethod
-
class
tallypi.common.
SingleTallyConfig
(tally_index: int, tally_type: tslumd.common.TallyType = <TallyType.no_tally: 0>, screen_index: Optional[int] = None, name: Optional[str] = '')[source]¶ Bases:
tallypi.common.TallyConfig
Configuration for a single tally
-
tally_index
: int¶ The tally index ranging from 0 to 65534 (
0xfffe
)The special value of 65535 (
0xffff
) is used as a “broadcast” address
-
tally_type
: tslumd.common.TallyType = 0¶ The
TallyType
-
screen_index
: Optional[int] = None¶ The
index
of thetslumd.tallyobj.Screen
the tally belongs to, ranging from 0 to 65534 (0xfffe
)If not provided (or
None
), the tally is assumed to belong to any screen. This is also the case if the value is 65535 (0xffff
), defined as the “broadcast” screen address.
-
property
tally_key
¶ A tuple of (
screen_index
,tally_index
) matching the format used fortslumd.tallyobj.Tally.id
If
screen_index
ortally_index
isNone
, they are set to 65535 (0xffff
)
-
property
is_broadcast_screen
¶ True
ifscreen_index
is set toNone
or the “broadcast” address of 65535 (0xffff
)
-
property
is_broadcast_tally
¶ True
iftally_index
is set toNone
or the “broadcast” address of 65535 (0xffff
)
-
matches
(other: Union[tslumd.tallyobj.Tally, tallypi.common.SingleTallyConfig]) → bool[source]¶ Determine whether the given tally argument matches this one
For
screen_index
thematches_screen()
method is used- Parameters
other – Either another
SingleTallyConfig
or atslumd.tallyobj.Tally
instance
-
matches_screen
(other: Union[tslumd.tallyobj.Tally, tallypi.common.SingleTallyConfig, tallypi.common.MultiTallyConfig, int]) → bool[source]¶ Determine whether the
screen_index
matches the given argumentFor
tslumd.tallyobj.Tally
, thescreen's
is_broadcast
value is taken into account as well as cases wherescreen_index
is set toNone
- Parameters
other – A
SingleTallyConfig
,MultiTallyConfig
,tslumd.tallyobj.Tally
orint
-
classmethod
from_dict
(d: Dict) → tallypi.common.SingleTallyConfig[source]¶ Create a
TallyConfig
from serialized data
-
create_screen
() → tslumd.tallyobj.Screen[source]¶ Create a
tslumd.tallyobj.Screen
with thescreen_index
of this object
-
create_tally
(screen: Optional[tslumd.tallyobj.Screen] = None) → Tuple[tslumd.tallyobj.Screen, tslumd.tallyobj.Tally][source]¶ Create a
tslumd.tallyobj.Tally
from this instance- Parameters
screen (tslumd.tallyobj.Screen, optional) – The parent
tslumd.tallyobj.Tally.screen
to add the tally to. If not provided, one will be created- Returns
screen (tslumd.tallyobj.Screen) – The parent screen that was either created or given as an argument
tally (tslumd.tallyobj.Tally) – The tally object
-
-
class
tallypi.common.
MultiTallyConfig
(tallies: List[tallypi.common.SingleTallyConfig] = <factory>, screen_index: Optional[int] = None, allow_all: bool = False, name: Optional[str] = '')[source]¶ Bases:
tallypi.common.TallyConfig
Configuration for multiple tallies
-
tallies
: List[tallypi.common.SingleTallyConfig]¶ A list of
SingleTallyConfig
instances
-
screen_index
: Optional[int] = None¶ The
index
of thetslumd.tallyobj.Screen
for the configuration ranging from 0 to 65534 (0xfffe
)This only takes effect if
allow_all
isTrue
and provides a method of filtering the tally assignments to a singletslumd.tallyobj.Screen
if desired.If not provided (or
None
), all tallies within all screens are considered to be members of the configuration. This is also the case if the value is 65535 (0xffff
), defined as the “broadcast” screen address.
-
allow_all
: bool = False¶ If
True
, all possible tally configurations exist within this instanceTallies can still be limited to a specific
screen_index
if desired
-
property
is_broadcast_screen
¶ True
ifscreen_index
is set toNone
or the “broadcast” address of 65535 (0xffff
)Note
Behavior is undefined if
allow_all
isFalse
-
matches
(tally: Union[tallypi.common.SingleTallyConfig, tslumd.tallyobj.Tally]) → bool[source]¶ Alias for
contains()
-
matches_screen
(other: Union[tslumd.tallyobj.Tally, tallypi.common.SingleTallyConfig, tallypi.common.MultiTallyConfig, int]) → bool[source]¶ Determine whether the
screen_index
matches the given argumentFor
tslumd.tallyobj.Tally
, thescreen's
is_broadcast
value is taken into account as well as cases wherescreen_index
is set toNone
- Parameters
other – A
SingleTallyConfig
,MultiTallyConfig
,tslumd.tallyobj.Tally
orint
Note
Behavior is undefined if
allow_all
isFalse
-
contains
(tally: Union[tslumd.tallyobj.Tally, tallypi.common.SingleTallyConfig]) → bool[source]¶ Determine whether the given tally argument is included in this configuration
The
matches_screen()
method is used to match thescreen_index
. Ifallow_all
isFalse
, each object intallies
ischecked
- Parameters
tally – Either a
SingleTallyConfig
or atslumd.tallyobj.Tally
instance
-
classmethod
from_dict
(d: Dict) → tallypi.common.MultiTallyConfig[source]¶ Create a
TallyConfig
from serialized data
-