tslumd.tallyobj
¶
- class tslumd.tallyobj.Tally(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.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
- normalized_brightness: float → Property(float)¶
The
brightness
value normalized as a float from0.0
to1.0
- Events
New in version 0.0.2: The
on_control
eventChanged in version 0.0.5: Added container emulation
- screen: Optional[tslumd.tallyobj.Screen]¶
The parent
Screen
this tally belongs toNew in version 0.0.3.
- property id → typing.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
isNone
New in version 0.0.3.
- property is_broadcast → bool [read-only]¶
True
if the tally is to be “broadcast”, meaning sent to alldisplay indices
.(if the
index
is0xffff
)New in version 0.0.2.
- classmethod broadcast(**kwargs) → tslumd.tallyobj.Tally[source]¶
Create a
broadcast
tally(with
index
set to0xffff
)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
orlh_tally
properties matching theTallyType
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
tally_type (TallyType or str) –
The
TallyType
member(s) to set. Multiple types can be specified using bitwise|
operators.If the argument is a string, it should be formatted as shown in
TallyType.from_str()
color (TallyColor or str) – The
TallyColor
to set, or the name as a string
>>> 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()
methodCombines the existing color value with the one provided using a bitwise
|
(or) operation- Parameters
tally_type (TallyType) – The
TallyType
member(s) to merge. Multiple types can be specified using bitwise|
operators.color (TallyColor) – The
TallyColor
to merge
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
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
- 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
- class tslumd.tallyobj.Screen(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
A group of
Tally
displays- Properties
- Events
-
- on_tally_update(tally: Tally, props_changed: Set[str])¶
Fired when any
Tally
property changes. This is a retransmission ofTally.on_update
- on_tally_control(tally: Tally, data: bytes)¶
Fired when control data is received for a
Tally
object. This is a retransmission ofTally.on_control
New in version 0.0.3.
- tallies: Dict[int, tslumd.tallyobj.Tally]¶
Mapping of
Tally
objects within the screen using theirindex
as keys
- property is_broadcast → bool [read-only]¶
True
if the screen is to be “broadcast”, meaning sent to allscreen indices
.(if the
index
is0xffff
)
- classmethod broadcast(**kwargs) → tslumd.tallyobj.Screen[source]¶
-
(with
index
set to0xffff
)
- broadcast_tally(**kwargs) → tslumd.tallyobj.Tally[source]¶
Create a temporary
Tally
usingTally.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 theScreen
.
- add_tally(index_: int, **kwargs) → tslumd.tallyobj.Tally[source]¶
- 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 totallies
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