Docs - Methods - Connect
Connecting to a switcher
This will start the connection process with the switcher. Once the connection process is started, the ATEMMax
object will try to connect to the switcher until it succeeds. While it’s connected it will automatically try to reconnect if it detects a connection loss.
The connTimeout
parameter can be used to specify a connection timeout in seconds (5
if not specified). When the ATEMMax
object sees no activity in this time it assumes a connection loss and tries to reconnect.
Waiting for connection
You can choose the way to wait for connection:
Wait: using events
You can register a handler for the connect
event and it will be called every time the connection is established (also after connection losses).
This is the recommended method for GUI programs (when you don’t control the main loop).
See the Events section.
Wait: using waitForConnection()
With no parameters, waitForConnection()
will keep on waiting until the switcher is connected.
If you specify infinite=False
, the method will use default timeout values to check if the connection is established in an acceptable time.
If you just want to wait for the initial handshake (e.g. to check if the switcher is alive), you can use the waitForFullHandshake
parameter:
If you want to change the timeout value, use the timeout
parameter, or change the default values (see below). Note that when timeout
is specified, infinite
is assumed to be False
Changing default wait timeouts
The default values for wait timeouts are:
ATEMProtocol.defaultConnectionTimeout
: full connection: 1.0 secondsATEMProtocol.defaultHandshakeTimeout
: basic handshake: 0.1 seconds
If you experience problems with these values, you can always change them before calling connect()
Wait: checking it for yourself
After calling connect()
you can manually check switcher.connected
to watch connection status.
See the connection state variables in the Data - Switcher State section.
Pinging a switcher
If you only want to check if your switcher is alive you can use ping()
instead of connect()
and then use waitForConnection
with no parameters.
ping()
also accepts a timeout
parameter:
Disconnecting from a switcher
After finishing your work with a switcher (even for ping
) you should close the connection.
If your script connects to the switcher, changes some settings and then exits, it’s safe to forget calling disconnect()
as the connection will be dropped when your script exits.