Karen's Client Device Manager.
The sole purpose of the device container is to facilitate communication between one or more input/output devices and the brain.
The device container allows for multiple client devices to be attached to a single communication vehicle.
This minimizes the overhead on the device to send its collected content to the brain.
__init__(self, tcp_port=8081, hostname='localhost', ssl_cert_file=None, ssl_key_file=None, brain_url='http://localhost:8080')
special
Device Container Initialization
Parameters: |
tcp_port (int ) – The TCP port on which the brain's TCP server will listen for incoming connections
hostname (str ) – The network hostname or IP address for the TCP server daemon
ssl_cert_file (str ) – The path and file name of the SSL certificate (.crt) for secure communications
ssl_key_file (str ) – The path and file name of the SSL private key (.key or .pem) for secure communications
brain_url (str ) – The URL of the brain device.
|
Both the ssl_cert_file and ssl_key_file must be present in order for SSL to be leveraged.
addDevice(self, deviceType, obj, friendlyName=None, autoStart=True, autoRegister=True)
Adds a new input/output device and optionally starts it and registers it with the brain.
Parameters: |
deviceType (str ) – The type of the device being added (e.g. "karen.listener.Listener").
obj (object ) – The instantiated class object of the input/output device.
friendlyName (str ) – The friendly name of the device (e.g. "living room").
autoStart (bool ) – Indicates if this call should call the start() method on input/output device.
autoRegister (bool ) – Indicates if the client should automatically register with the brain
|
callbackHandler(self, inType, data)
The target of all input/output devices. Sends collected data to the brain. Posts request to "/data".
setHandler(self, handlerType, handlerCallback)
Sets the handler to be used for incoming control requests
start(self, useThreads=True, autoRegister=True, autoStartDevices=False)
Starts the client TCP daemon, optionally using threads.
Parameters: |
useThreads (bool ) – Indicates if the brain should be started on a new thread.
autoRegister (bool ) – Indicates if the client should automatically register with the brain
autoStartDevices (bool ) – Indicates if this call should also start any stopped or not started input/output devices.
|
stop(self)
Stops the client TCP server daemon.
stopDevices(self, deviceType=None, removeDevices=False)
Stops all connected input/output devices.
wait(self, seconds=0)
Waits for any active servers to complete before closing