Welcome to vidhub-control’s documentation!¶
Overview¶
Interface with Videohub SDI Matrix Switchers and SmartView Monitors by Blackmagic Design.
The primary purpose is for use as a library in other applications, but a GUI application is included (requires installation of the Kivy framework
Since neither the devices nor the software for them support presets or macros, a need arose for instantaneous multiple routing changes. This, as well as setting the names for inputs and outputs within a single application can be accomplished using this project.
Links¶
Releases |
|
Source code |
|
Documentation |
Dependencies¶
This project relies heavily on asyncio and other features available in Python v3.5 or later.
- Core
- User interface (optional)
Installation¶
Download¶
For basic installation, clone or download the source code:
git clone https://github.com/nocarryr/vidhub-control
cd vidhub-control
Create virtual environment¶
(optional, but recommended)
Linux/MacOS¶
virtualenv --python=python3 venv
source venv/bin/activate
Windows¶
virtualenv --python=python3 venv
venv/Scripts/activate
Install vidhub-control¶
python setup.py install
Install Kivy¶
(optional)
Ensure all dependencies are met for your platform. Instructions can be found on the kivy download page
Linux (Ubuntu)¶
Follow the instructions for Installation in a Virtual Environment
Windows¶
pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
pip install kivy.deps.sdl2
pip install kivy
MacOS¶
Usage¶
To launch the user interface (Kivy required):
vidhubcontrol-ui
Note for Windows¶
The vidhubcontrol-ui script may not work. If this is the case, it can be launched by:
python vidhubcontrol/kivyui/main.py
Reference¶
vidhubcontrol.config
¶
- class vidhubcontrol.config.Config(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.config.ConfigBase
Config store for devices
Handles storage of device connection information and any user-defined values for the backends defined in the backends module. Data is stored in JSON format.
During
start()
, all previously stored devices will be loaded and begin communication. Devices are also discovered using Zeroconf through the discovery module.Since each device has a unique id, network address changes (due to DHCP, etc) are handled appropriately.
The configuration data is stored when:
A device is added or removed
A change is detected for a device’s network address
Any user-defined device value changes (device name, presets, etc)
The recommended method to start
Config
is through theload_async()
method.Example
import asyncio from vidhubcontrol.config import Config loop = asyncio.get_event_loop() conf = loop.run_until_complete(Config.load_async())
- Keyword Arguments
filename (
str
, optional) – Filename to load/save config data to. If not given, defaults toDEFAULT_FILENAME
- vidhubs¶
A
DictProperty
ofVidhubConfig
instances usingdevice_id
as keys- Type
- smartviews¶
A
DictProperty
ofSmartViewConfig
instances usingdevice_id
as keys- Type
- smartscopes¶
A
DictProperty
ofSmartScopeConfig
instances usingdevice_id
as keys- Type
- all_devices¶
A
DictProperty
containing all devices fromvidhubs
,smartviews
andsmartscopes
- Type
- DEFAULT_FILENAME = '~/vidhubcontrol.json'¶
- async add_device(backend)[source]¶
Adds a “backend” instance to the config
A subclass of
DeviceConfigBase
will be either created or updated from the given backend instance.If the
device_id
exists in the config, theDeviceConfigBase.backend
value of the matchingDeviceConfigBase
instance will be set to the givenbackend
. Otherwise, a newDeviceConfigBase
instance will be created using theDeviceConfigBase.from_existing()
classmethod.- Parameters
backend – An instance of one of the subclasses of
vidhubcontrol.backends.base.BackendBase
found in vidhubcontrol.backends
- async build_backend(device_type, backend_name, **kwargs)[source]¶
Creates a “backend” instance
The supplied keyword arguments are used to create the instance object which will be created using its
create()
classmethod.The appropriate subclass of
DeviceConfigBase
will be created and stored to the config usingadd_device()
.- Parameters
device_type (str) – Device type to create. Choices are “vidhub”, “smartview”, “smartscope”
backend_name (str) – The class name of the backend as found in vidhubcontrol.backends
- Returns
An instance of a
vidhubcontrol.backends.base.BackendBase
subclass
- connection_manager: vidhubcontrol.common.ConnectionManager¶
Connection manager
- property connection_state: vidhubcontrol.common.ConnectionState¶
The current
state
of theconnection_manager
- classmethod load(filename=None, **kwargs)[source]¶
Creates a Config instance, loading data from the given filename
- Parameters
filename (
str
, optional) – The filename to read config data from, defaults toConfig.DEFAULT_FILENAME
- Returns
A
Config
instance
- async classmethod load_async(filename=None, **kwargs)[source]¶
Creates a Config instance, loading data from the given filename
This coroutine method creates the
Config
instance and willawait
all start-up coroutines and futures before returning.- Parameters
filename (
str
, optional) – The filename to read config data from, defaults toDEFAULT_FILENAME
- Returns
A
Config
instance
- save(filename=None)[source]¶
Saves the config data to the given filename
- Parameters
filename (
str
, optional) – The filename to write config data to. If not supplied, the currentfilename
is used.
Notes
If the
filename
argument is provided, it will replace the existingfilename
value.
- class vidhubcontrol.config.DeviceConfigBase(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.config.ConfigBase
Base class for device config storage
- backend¶
An instance of
vidhubcontrol.backends.base.BackendBase
- async build_backend(cls=None, **kwargs)[source]¶
Creates a backend instance asynchronously
Keyword arguments will be passed to the
vidhubcontrol.backends.base.BackendBase.create_async()
method.- Parameters
cls (optional) – A subclass of
BackendBase
. If not present, the class will be determined from existing values ofdevice_type
andbackend_name
- Returns
An instance of
vidhubcontrol.backends.base.BackendBase
- connection_manager: vidhubcontrol.common.SyncronizedConnectionManager¶
A connection manager that syncronizes its state with the
backend
- property connection_state: vidhubcontrol.common.ConnectionState¶
The current
state
of theconnection_manager
- async classmethod create(**kwargs)[source]¶
Creates device config and backend instances asynchronously
Keyword arguments passed to this classmethod are passed to the init method and will be used to set its attributes.
If a “backend” keyword argument is supplied, it should be a running instance of
vidhubcontrol.backends.base.BackendBase
. It will then be used to collect config values from.If “backend” is not present, the appropriate one will be created using
build_backend()
.- Returns
An instance of
DeviceConfigBase
- async classmethod from_existing(backend, **kwargs)[source]¶
Creates a device config object from an existing backend
Keyword arguments will be passed to the
create()
method- Parameters
backend – An instance of
vidhubcontrol.backends.base.BackendBase
- Returns
An instance of
DeviceConfigBase
- class vidhubcontrol.config.SmartScopeConfig(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.config.DeviceConfigBase
Config container for SmartScope devices
- class vidhubcontrol.config.SmartViewConfig(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.config.DeviceConfigBase
Config container for SmartView devices
- class vidhubcontrol.config.VidhubConfig(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.config.DeviceConfigBase
Config container for VideoHub devices
- presets¶
Preset data collected from the device
presets
. Will be used on initialization to populate the preset data to the device- Type
List[Dict]
- async build_backend(cls=None, **kwargs)[source]¶
Creates a backend instance asynchronously
Keyword arguments will be passed to the
vidhubcontrol.backends.base.BackendBase.create_async()
method.- Parameters
cls (optional) – A subclass of
BackendBase
. If not present, the class will be determined from existing values ofdevice_type
andbackend_name
- Returns
An instance of
vidhubcontrol.backends.base.BackendBase
- async classmethod create(**kwargs)[source]¶
Creates device config and backend instances asynchronously
Keyword arguments passed to this classmethod are passed to the init method and will be used to set its attributes.
If a “backend” keyword argument is supplied, it should be a running instance of
vidhubcontrol.backends.base.BackendBase
. It will then be used to collect config values from.If “backend” is not present, the appropriate one will be created using
build_backend()
.- Returns
An instance of
DeviceConfigBase
- async classmethod from_existing(backend, **kwargs)[source]¶
Creates a device config object from an existing backend
Keyword arguments will be passed to the
create()
method- Parameters
backend – An instance of
vidhubcontrol.backends.base.BackendBase
- Returns
An instance of
DeviceConfigBase
vidhubcontrol.backends
¶
vidhubcontrol.backends.base
¶
- class vidhubcontrol.backends.base.BackendBase(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
Base class for communicating with devices
- Events
- on_preset_added(backend: BackendBase = self, preset: Preset = preset)¶
- on_preset_stored(backend: BackendBase = self, preset: Preset = preset)¶
This
Event
is emitted when an existingPreset
has been recorded (updated).
- connection_manager: vidhubcontrol.common.ConnectionManager¶
Manager for the device’s
ConnectionState
- property connection_state: vidhubcontrol.common.ConnectionState¶
The current
state
of theconnection_manager
- class vidhubcontrol.backends.base.Preset(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
Stores and recalls routing information
- crosspoints¶
The crosspoints that this preset has stored. This is a
DictProperty
- active¶
A flag indicating whether all of the crosspoints stored in this preset are currently active on the switcher. This is a
pydispatch.Property
- Type
- class vidhubcontrol.backends.base.SmartScopeMonitor(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.backends.base.SmartViewMonitor
A single instance of a monitor within a SmartScope device
- class vidhubcontrol.backends.base.SmartViewBackendBase(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.backends.base.BackendBase
Base class for SmartView devices
- inverted¶
True
if the device has been mounted in an inverted configuration (to optimize viewing angle).- Type
- monitors¶
A
list
containing instances ofSmartViewMonitor
orSmartScopeMonitor
, depending on device type.- Type
- Events
- on_monitor_property_change(self: SmartViewBackendBase, name: str, value: Any, monitor: SmartViewMonitor = monitor)¶
Dispatched when any
Property
value changes. The event signature for callbacks is(smartview_device, property_name, value, **kwargs)
containing a keyword argument “monitor” containing theSmartViewMonitor
instance.
- async set_monitor_property(monitor, name, value)[source]¶
Set a property value for the given
SmartViewMonitor
instance- Parameters
monitor – The
SmartViewMonitor
instance to setname (str) – Property name
value – The new value to set
This method is a coroutine.
- class vidhubcontrol.backends.base.SmartViewMonitor(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
A single instance of a monitor within a SmartView device
- widescreen_sd¶
Aspect ratio setting for SD format. Choices can be:
True
(stretching enabled),False
(pillar-box), orNone
(auto-detect).- Type
Optional[bool]
- identify¶
If set to
True
, the monitor’s border will be white for a brief duration to physically locate the device.- Type
- class vidhubcontrol.backends.base.VidhubBackendBase(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.backends.base.BackendBase
Base class for Videohub devices
- crosspoints¶
This represents the currently active routing of the switcher. Each element in the
list
represents an output (the zero-based index of thelist
) with its selected index as the value (also zero-based). This is apydispatch.properties.ListProperty
and can be observed using thebind()
method.- Type
List[int]
- output_labels¶
A
list
containing the names of each output as reported by the switcher This is apydispatch.properties.ListProperty
and can be observed using thebind()
method.- Type
List[str]
- input_labels¶
A
list
containing the names of each input as reported by the switcher This is apydispatch.properties.ListProperty
and can be observed using thebind()
method.- Type
List[str]
- crosspoint_control¶
This is similar to
crosspoints
but if modified from outside code, the crosspoint changes will be set on the device (no method calls required).pydispatch.properties.ListProperty
- Type
List[int]
- output_label_control¶
This is similar to
output_labels
but if modified from outside code, the label changes will be written to the device (no method calls required).pydispatch.properties.ListProperty
- Type
List[str]
- input_label_control¶
This is similar to
input_labels
but if modified from outside code, the label changes will be written to the device (no method calls required).pydispatch.properties.ListProperty
- Type
List[str]
- presets¶
The currently available (stored)
list
ofPreset
instancespydispatch.properties.ListProperty
- Type
- async add_preset(name=None)[source]¶
Adds a new
Preset
instanceThis method is used internally and should not normally be called outside of this module. Instead, see
store_preset()
- async set_crosspoints(*args)[source]¶
Set multiple crosspoints in one method call
This is useful for setting many routing changes as it reduces the number of commands sent to the switcher.
- Parameters
*args – Any number of output/input pairs to set. These should be given as
tuples
of(out_idx, in_idx)
as defined inset_crosspoint()
. They can be discontinuous and unordered.
- async set_input_labels(*args)[source]¶
Set multiple input labels in one method call
This is useful for setting many labels as it reduces the number of commands sent to the switcher.
- Parameters
*args – Any number of input/label pairs to set. These should be given as
tuples
of(in_idx, label)
as defined inset_input_label()
. They can be discontinuous and unordered.
- async set_output_labels(*args)[source]¶
Set multiple output labels in one method call
This is useful for setting many labels as it reduces the number of commands sent to the switcher.
- Parameters
*args – Any number of output/label pairs to set. These should be given as
tuples
of(out_idx, label)
as defined inset_output_label()
. They can be discontinuous and unordered.
- async store_preset(outputs_to_store=None, name=None, index=None, clear_current=True)[source]¶
Store the current switcher state to a
Preset
- Parameters
outputs_to_store (optional) – An iterable of the output numbers (zero-based) that should be saved in the preset. If given, only these outputs will be recorded and when recalled, any output not in this argument will be unchanged. If not given or
None
, all outputs will be recorded.name (optional) – The name to be given to the preset. If not provided or
None
the preset will be given a name based off of its index.index (optional) – The index for the preset. If given and the preset exists in the
presets
list, that preset will be updated. If there is no preset found with the index, a new one will be created. If not given orNone
, the next available index will be used and a new preset will be created.clear_current (bool) – If
True
, any previously existing data will be removed from the preset (if it exists). IfFalse
, the data (if existing) will be merged with the current switcher state. Default isTrue
- Returns
The
Preset
instance that was created or updated
This method is a
coroutine
vidhubcontrol.backends.telnet
¶
- class vidhubcontrol.backends.telnet.SmartScopeTelnetBackend(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.backends.telnet.SmartViewTelnetBackendBase
,vidhubcontrol.backends.base.SmartScopeBackendBase
- class vidhubcontrol.backends.telnet.SmartViewTelnetBackend(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.backends.telnet.SmartViewTelnetBackendBase
,vidhubcontrol.backends.base.SmartViewBackendBase
- class vidhubcontrol.backends.telnet.TelnetBackend(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.backends.telnet.TelnetBackendBase
,vidhubcontrol.backends.base.VidhubBackendBase
Base class for backends implementing telnet
- async set_crosspoints(*args)[source]¶
Set multiple crosspoints in one method call
This is useful for setting many routing changes as it reduces the number of commands sent to the switcher.
- Parameters
*args – Any number of output/input pairs to set. These should be given as
tuples
of(out_idx, in_idx)
as defined inset_crosspoint()
. They can be discontinuous and unordered.
- async set_input_labels(*args)[source]¶
Set multiple input labels in one method call
This is useful for setting many labels as it reduces the number of commands sent to the switcher.
- Parameters
*args – Any number of input/label pairs to set. These should be given as
tuples
of(in_idx, label)
as defined inset_input_label()
. They can be discontinuous and unordered.
- async set_output_labels(*args)[source]¶
Set multiple output labels in one method call
This is useful for setting many labels as it reduces the number of commands sent to the switcher.
- Parameters
*args – Any number of output/label pairs to set. These should be given as
tuples
of(out_idx, label)
as defined inset_output_label()
. They can be discontinuous and unordered.
vidhubcontrol.discovery
¶
- class vidhubcontrol.discovery.AddedMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
- class vidhubcontrol.discovery.BMDDiscovery(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.discovery.Listener
Zeroconf listener for Blackmagic devices
- vidhubs¶
Contains discovered Videohub devices. This
DictProperty
can be used to subscribe to changes.- Type
- smart_views¶
Contains discovered SmartView devices. This
DictProperty
can be used to subscribe to changes.- Type
- smart_scopes¶
Contains discovered SmartScope devices. This
DictProperty
can be used to subscribe to changes.- Type
- class vidhubcontrol.discovery.BrowserMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
- class vidhubcontrol.discovery.Listener(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
An async zeroconf service listener
Allows async communication with
zeroconf.Zeroconf
throughasyncio.AbstractEventLoop.run_in_executor()
calls.- Parameters
mainloop (
asyncio.BaseEventLoop
) – asyncio event loop instanceservice_type (str) – The fully qualified service type name to subscribe to
- services¶
All services currently discovered as instances of
ServiceInfo
. Stored usingServiceInfo.id
as keys- Type
- message_queue¶
Used to communicate actions and events with instances of
Message
- Type
asyncio.queues.Queue
- published_services¶
Stores services that have been published using
publish_service()
asServiceInfo
instances.- Type
- async add_message(msg: vidhubcontrol.discovery.Message)[source]¶
Adds a message to the
message_queue
- Parameters
msg (
Message
) – Message to send
- async publish_service(type_: str, port: int, name: Optional[str] = None, addresses: Optional[Union[str, bytes, ipaddress.IPv4Address]] = None, properties: Optional[Dict] = None, ttl: Optional[int] = 60)[source]¶
Publishes a service on the network
- Parameters
type (str) – Fully qualified service type
port (int) – The service port
name (str, optional) – Fully qualified service name. If not provided, this will be generated from the
type_
and the hostname detected byget_local_hostname()
addresses (optional) – If provided, an
iterable
of IP addresses to publish. Can beipaddress.IPv4Address
or any type that can be parsed byipaddress.ip_address()
properties (dict, optional) – Custom properties for the service
ttl (int, optional) – The TTL value to publish. Defaults to
PUBLISH_TTL
- async republish_service(type_: str, port: int, name: Optional[str] = None, addresses: Optional[Union[str, bytes, ipaddress.IPv4Address]] = None, properties: Optional[Dict] = None, ttl: Optional[int] = 60)[source]¶
Update an existing
ServiceInfo
and republish it
- async run()[source]¶
Main loop for communicating with
zeroconf.Zeroconf
Waits for messages on the
message_queue
and processes them. The loop will exit if an object placed on the queue is not an instance ofMessage
.
- async unpublish_service(type_: str, name: Optional[str] = None)[source]¶
Removes a service published through
publish_service()
- class vidhubcontrol.discovery.Message(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
Bases:
object
A message to communicate actions to and from
Listener
- info¶
The
ServiceInfo
related to the message
Note
This class and its subclasses are not meant to be used directly. They are used internally in
Listener
methods.
- class vidhubcontrol.discovery.PublishMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
- class vidhubcontrol.discovery.RegistrationMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
- class vidhubcontrol.discovery.RemovedMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
- class vidhubcontrol.discovery.RepublishMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
- class vidhubcontrol.discovery.ServiceInfo(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
Container for Zeroconf service information
Closely related to
zeroconf.ServiceInfo
- addresses¶
The service ip address
- property address: Optional[ipaddress.IPv4Address]¶
The first element of
addresses
- classmethod from_zc_info(info: zeroconf._services.info.ServiceInfo) vidhubcontrol.discovery.ServiceInfo [source]¶
Creates an instance from a
zeroconf.ServiceInfo
object- Parameters
info (
zeroconf.ServiceInfo
) –- Returns
An instance of
ServiceInfo
- to_zc_info() zeroconf._services.info.ServiceInfo [source]¶
Creates a copy as an instance of
zeroconf.ServiceInfo
- update(other: vidhubcontrol.discovery.ServiceInfo)[source]¶
Updates the
properties
from anotherServiceInfo
instance
- class vidhubcontrol.discovery.UnPublishMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
- class vidhubcontrol.discovery.UpdateMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]¶
vidhubcontrol.common
¶
- class vidhubcontrol.common.ConnectionManager(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
A manager for tracking and waiting for
connection states
A
asyncio.Condition
is used to to notify any waiting tasks of changes tostate
. This requires the underlying lock to beacquired
before calling any of the waiter or setter methods andreleased
afterwards.This class supports the asynchronous context manager protocol for use in
async with
statements.- Events
- state_changed(self: ConnectionManager, state: ConnectionState)¶
Emitted when the value of
state
has changed
- async acquire()[source]¶
Acquire the lock
This method blocks until the lock is unlocked, then sets it to locked and returns True.
- release()[source]¶
Release the lock
- Raises
RuntimeError – if called on an unlocked lock
- async set_failure(reason: Any, exc: Optional[Exception] = None, state: Optional[Union[vidhubcontrol.common.ConnectionState, str]] = ConnectionState.None)[source]¶
Set
state
to indicate a failure- Parameters
reason – A description of the failure
exc – The Exception that caused the failure (if available)
state – The new state to set. Must include
ConnectionState.failure
- Raises
RuntimeError – If the lock is not
acquired
before calling this method
- async set_state(state: Union[vidhubcontrol.common.ConnectionState, str])[source]¶
Set the
state
to the given valueThe state argument may be either a
ConnectionState
member or a string. (seeConnectionState.from_str()
)- Raises
RuntimeError – If the lock is not
acquired
before calling this method
- property state: vidhubcontrol.common.ConnectionState¶
The current state
- async syncronize(other: vidhubcontrol.common.ConnectionManager)[source]¶
Copy the
state
and failure values of anotherConnectionManager
Note
The lock must not be acquired before calling this method.
- async wait(timeout: Optional[float] = None) vidhubcontrol.common.ConnectionState [source]¶
Block until the next time
state
changes and return the value- Parameters
timeout – If given, the number of seconds to wait. Otherwise, this will wait indefinitely
- Raises
asyncio.TimeoutError – If timeout is given and no state changes occured
RuntimeError – If the lock is not
acquired
before calling this method
- async wait_for(state: Union[vidhubcontrol.common.ConnectionState, str], timeout: Optional[float] = None) vidhubcontrol.common.ConnectionState [source]¶
Wait for a specific state
The state argument may be a
ConnectionState
member or string as described inConnectionState.from_str()
.If the given state is
compound
or thestate
is set as compound, this will wait until all members from the state argument are contained within thestate
value.- Parameters
state – The state to wait for
timeout – If given, the number of seconds to wait. Otherwise, this will wait indefinitely
- Raises
asyncio.TimeoutError – If timeout is given and no matching state changes were found
RuntimeError – If the lock is not
acquired
before calling this method
- async wait_for_disconnected(timeout: Optional[float] = None) vidhubcontrol.common.ConnectionState [source]¶
Wait for
ConnectionState.not_connected
- Parameters
timeout – If given, the number of seconds to wait. Otherwise, this will wait indefinitely
- Raises
asyncio.TimeoutError – If timeout is given and no matching state changes were found
RuntimeError – If the lock is not
acquired
before calling this method
- async wait_for_established(timeout: Optional[float] = None) vidhubcontrol.common.ConnectionState [source]¶
Wait for either a success (
ConnectionState.connected
) or failure (ConnectionState.failure
)- Parameters
timeout – If given, the number of seconds to wait. Otherwise, this will wait indefinitely
- Raises
asyncio.TimeoutError – If timeout is given and no matching state changes were found
RuntimeError – If the lock is not
acquired
before calling this method
- class vidhubcontrol.common.ConnectionState(value)[source]¶
Bases:
enum.IntFlag
Enum to describe various connection states
Members may be combined using bitwise operators (&, |, ^, ~)
- connected = 8¶
Indicates the connection is active
- connecting = 2¶
Indicates an attempt to connect is being made
- disconnecting = 4¶
Indicates the connection is being closed
- failure = 16¶
Indicates an error occured
- classmethod from_str(s: str) vidhubcontrol.common.ConnectionState [source]¶
Create a
ConnectionState
member by name(s)Combined states can be created by separating their names with a “|”
>>> from vidhubcontrol.common import ConnectionState >>> ConnectionState.connected | ConnectionState.not_connected <ConnectionState.connected|not_connected: 9> >>> ConnectionState.disconnecting | ConnectionState.failure <ConnectionState.failure|disconnecting: 20> >>> # This combination is already defined as "waiting" >>> ConnectionState.connecting | ConnectionState.disconnecting <ConnectionState.waiting: 6>
- property is_connected: bool¶
Convenience property evaluating as True if
self == ConnectionState.connected
- not_connected = 1¶
Indicates there is no connection and no connection attempts are being made
- waiting = 6¶
Indicates the connection is either
connecting
ordisconnecting
- class vidhubcontrol.common.SyncronizedConnectionManager(*args, **kwargs)[source]¶
Bases:
vidhubcontrol.common.ConnectionManager
A connection manager that syncronizes itself with another
- property other: Optional[vidhubcontrol.common.ConnectionManager]¶
The manager currently being syncronized to
- async set_other(other: Optional[vidhubcontrol.common.ConnectionManager])[source]¶
Set the manager to syncronize with
This binds to the
state_changed()
event of other and calls thesyncronize()
method whenever the state of the other manager changes.If
None
is given,state
is set tonot_connected
Note
The lock must not be acquired before calling this method