Module DeviceManager :: Class DeviceManager
[hide private]
[frames] | no frames]

Class DeviceManager

source code

object --+
         |
        DeviceManager

Creates and manages the devices and monitors use by LSR. Keeps a list of each and also defines a "default" for devices. Provides a common interface to all output and input devices and mirrors I/O to the monitors. Provides a mapping from output styles to semantic concepts in the user interface to allow customization of how information is presented.

Instance Methods [hide private]
 
__init__(self, acc_eng)
Creates the empty lists for devices and monitors.
source code
 
init(self, event_man, sett_man, **kwargs)
Called by AccessEngine at startup.
source code
 
loadDevices(self)
Iterates over all devices in the active profile and loads ones that provide functionality different from those already loaded.
source code
 
unloadDevices(self)
Unloads all devices from out_devs and in_devs, but keeps strong references to all objects in temp_devs until loadDevices is called again.
source code
 
close(self)
Shuts down this manager and all its registered AEOutput and AEInput devices and AEMonitors.
source code
object
send(self, dev, name, value, sem, layer)
Sends arbitrary data to a device.
source code
 
sendStop(self, dev, sem, layer)
Sends the stop command to the referenced output device.
source code
 
sendTalk(self, dev, sem, layer)
Tells the specified output device to send buffered data.
source code
 
sendFilename(self, dev, filename, sem, layer)
Sends the filename to the specified output device.
source code
 
sendString(self, dev, text, sem, layer, por=None)
Sends the string to the specified output device.
source code
 
sendIndex(self, dev, value, sem, layer)
Sends the referenced index marker to the referenced device.
source code
 
sendWelcome(self)
Outputs the LSR welcome message on the default output device.
source code
 
sendGoodbye(self)
Outputs the LSR goodbye message on the default output device.
source code
 
_isDuplicateDevice(self, dev, output)
Checks if the given device is a duplicate in that it provides no new interfaces beyond those provided by the devices already registered.
source code
boolean or None
_registerInputDevice(self, dev)
Registers the given device as an input device if the device implements the AEInput base class and provides some capabilities not already provided by another registered input device.
source code
 
_unregisterInputDevice(self, dev)
Unregisters the given input device.
source code
 
_unregisterOutputDevice(self, dev)
Unregisters the given output device.
source code
boolean or None
_registerOutputDevice(self, dev)
Registers the given device as an output device if the device implements the AEOutput base class and provides some subinterface not already provided by another registered output device.
source code
 
_initOutputStyles(self, dev)
Initializes styles for an AEOutput device.
source code
 
registerDevice(self, dev)
Registers the referenced device based on its one or more interfaces.
source code
 
unregisterDevice(self, dev)
Unregisters a device from both the input and output lists based on its capabilities.
source code
 
addMonitors(self, *monitors)
Adds one or more AEMonitors to the list of monitors to be notified about IO events.
source code
2-tuple AEMonitor.MonitorCollection
getMonitors(self)
Returns: Collections of all loaded input and output AEMonitors in that order
source code
AEOutput
getFirstOutput(self)
Gets the first AEOutput device to successfully load.
source code
AEOutput
getOutputByName(self, name)
Gets the AEOutput device registered under the given name.
source code
AEOutput
getOutputByCaps(self, caps)
Gets the AEOutput device registered with the given capabilities.
source code
AEInput
getInputByName(self, name)
Gets the AEInput device registered under the given name.
source code
AEOutput
getInputByCaps(self, caps)
Gets the AEInput device registered with the given capabilities.
source code
 
_onGesture(self, gesture, timestamp, **kwargs)
Creates an AEEvent indicating the given gesture was found on a registered input device.
source code
 
_onIndex(self, dev, index) source code
list of UIElement
getDevices(self)
Returns: References to all loaded devices
source code
AEOutput.Style
getStyle(self, dev, sem, layer)
Gets the style for semantic/layer of a given device.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Instance Variables [hide private]
AccessEngine acc_eng
The AccessEngine reference that created this class
EventManager event_manager
EventManager to which this DeviceManager can post AEEvents
list in_devs
All input devices registered and initialized
AEMonitor.MonitorCollection in_mons
Collection of monitors to notify about input
dictionary marks
Maps index markers on devices to
list out_devs
All output devices registered and initialized
AEMonitor.MonitorCollection out_mons
Collection of monitors to notify about output
list temp_devs
List of AEOutput and AEInput devices last removed in unloadDevices and held until the next call of loadDevices.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, acc_eng)
(Constructor)

source code 

Creates the empty lists for devices and monitors.

Parameters:
  • acc_eng (AccessEngine) - The AccessEngine reference that created this class
Overrides: object.__init__

init(self, event_man, sett_man, **kwargs)

source code 

Called by AccessEngine at startup.

Parameters:

unloadDevices(self)

source code 

Unloads all devices from out_devs and in_devs, but keeps strong references to all objects in temp_devs until loadDevices is called again. Keeping strong references ensures weak references in Perks continue to exist until the DeviceManager has new devices available for I/O.

close(self)

source code 

Shuts down this manager and all its registered AEOutput and AEInput devices and AEMonitors. Saves all style information for currently loaded devices.

send(self, dev, name, value, sem, layer)

source code 

Sends arbitrary data to a device. The device must recognize the name in order to decide what to do with the value data.

This is a generic method which receives all content and commands to be rendered and executed on a device. Standard name identifiers should be used whenever possible. For instance, AEConstants.Output.CMD_STOP and AEConstants.Output.CMD_TALK. However, device specific names and values are certainly possible.

Parameters:
  • name (object) - Descriptor of the data value sent
  • value (object) - Content value
  • sem (integer) - The semantic stream on which to send output; defaults to None for the default semantic.
  • layer (integer) - Layer on which the event occurred
  • dev (AEOutput) - Device that should receive the command
Returns: object
Return value specific to the given command

sendStop(self, dev, sem, layer)

source code 

Sends the stop command to the referenced output device.

Parameters:
  • dev (AEOutput) - Device that should receive the command
  • sem (integer) - Semantic description of the information to stop None to indicate stopping all output
  • layer (integer) - Layer on which the event occurred

sendTalk(self, dev, sem, layer)

source code 

Tells the specified output device to send buffered data.

Parameters:
  • dev (AEOutput) - Device that should receive the command
  • sem (integer) - Semantic information to start outputting or None to indicate that all buffered information should be output
  • layer (integer) - Layer on which the event occurred

sendFilename(self, dev, filename, sem, layer)

source code 

Sends the filename to the specified output device.

Parameters:
  • dev (AEOutput) - Device that should receive the command
  • filename (string) - The filename to send to the referenced device
  • sem (integer) - Semantic description of the text to send or None to indicate the information is void of any known semantic
  • layer (integer) - Layer on which the event occurred

sendString(self, dev, text, sem, layer, por=None)

source code 

Sends the string to the specified output device.

Parameters:
  • dev (AEOutput) - Device that should receive the command
  • text (string) - The text to send to the referenced device
  • sem (integer) - Semantic description of the text to send or None to indicate the information is void of any known semantic
  • layer (integer) - Layer on which the event occurred
  • por (POR) - Point of regard to the start of the string if one exists or None if the string did not originate from a POR

sendIndex(self, dev, value, sem, layer)

source code 

Sends the referenced index marker to the referenced device.

Parameters:
  • dev (AEOutput) - Device that should receive the command
  • sem (integer) - Semantic description of the index text to send or None to indicate the information is void of any known semantic
  • layer (integer) - Layer on which the event occurred

_isDuplicateDevice(self, dev, output)

source code 

Checks if the given device is a duplicate in that it provides no new interfaces beyond those provided by the devices already registered.

Parameters:
  • dev (AEInput or AEOutput class) - A device class
  • output (boolean) - Is the device an output device (True) or input (False)?

_registerInputDevice(self, dev)

source code 

Registers the given device as an input device if the device implements the AEInput base class and provides some capabilities not already provided by another registered input device. For instance, if a device reports it supports the "system keyboard" capability, no other system keyboard device will be loaded.

Parameters:
Returns: boolean or None
True if the device was registered, False if it is not an AEInput device, and None if it provides no new interfaces

_unregisterInputDevice(self, dev)

source code 

Unregisters the given input device. Removes this manager from the list of gesture listeners stored in the device.

Parameters:

_unregisterOutputDevice(self, dev)

source code 

Unregisters the given output device. Provides the device with a reference to the SettingsManager so it can save state. Removes this manager from the list of index listeners stored in the device.

Parameters:

_registerOutputDevice(self, dev)

source code 

Registers the given device as an output device if the device implements the AEOutput base class and provides some subinterface not already provided by another registered output device. For instance, if a device reports having "audio" capability, no other device providing just this capability will be loaded.

Parameters:
Returns: boolean or None
True if the device was registered, False if it is not an AEOutput device, and None if it provides no new interfaces

_initOutputStyles(self, dev)

source code 

Initializes styles for an AEOutput device. Calls AEOutput.Base.AEOutput.createDistinctStyles on the device to get an initial batch of styles to use to distinguish some types of information. If that method is not implemented, the exception is ignored. Future requests to use styles per semantic tag will resort to making flyweights for the default style on the device.

Parameters:

registerDevice(self, dev)

source code 

Registers the referenced device based on its one or more interfaces. When the interface is determined, the init() method is called on the device. Returns true when the reference is of a known type that initializes successfully.

Parameters:
Raises:
  • NotImplementedError - When the device implements none of the required interfaces
  • AEOutputError - When output device initialization fails
  • AEInputError - When input device initialization fails

unregisterDevice(self, dev)

source code 

Unregisters a device from both the input and output lists based on its capabilities.

Parameters:

addMonitors(self, *monitors)

source code 

Adds one or more AEMonitors to the list of monitors to be notified about IO events.

Parameters:

getMonitors(self)

source code 
Returns: 2-tuple AEMonitor.MonitorCollection
Collections of all loaded input and output AEMonitors in that order

getFirstOutput(self)

source code 

Gets the first AEOutput device to successfully load.

Returns: AEOutput
First loaded output device or None if no output is available

getOutputByName(self, name)

source code 

Gets the AEOutput device registered under the given name.

Parameters:
  • name (string) - Name of the output device
Returns: AEOutput
Output device or None if not registered

getOutputByCaps(self, caps)

source code 

Gets the AEOutput device registered with the given capabilities.

Parameters:
  • caps (list of string) - Desired capabilities of the output device.
Returns: AEOutput
Output device or None if caps could not be satisfied

getInputByName(self, name)

source code 

Gets the AEInput device registered under the given name.

Parameters:
  • name (string) - Name of the input device
Returns: AEInput
Input device or None if not registered

getInputByCaps(self, caps)

source code 

Gets the AEInput device registered with the given capabilities.

Parameters:
  • caps (list of string) - Desired capabilities of the input device.
Returns: AEOutput
Output device or None if caps could not be satisfied

_onGesture(self, gesture, timestamp, **kwargs)

source code 

Creates an AEEvent indicating the given gesture was found on a registered input device. When executed, the AEEvent will notify the TierManager about the gesture and allow it to activate the appropriate Task registered to respond to the gesture in the active Tier.

Parameters:
  • gesture (AEInput.Gesture) - Gesture seen on an input device
  • timestamp (float) - Time at which the event occurred
  • kwargs (dictionary) - Additional keyword arguments to pass to the Task

getDevices(self)

source code 
Returns: list of UIElement
References to all loaded devices

getStyle(self, dev, sem, layer)

source code 

Gets the style for semantic/layer of a given device.

Parameters:
  • dev (AEOutput) - The device from which to get the style.
  • sem (integer) - The device semantic from which to get the style, or None to get the device's default style.
  • layer (integer) - Layer on which the event occurred
Returns: AEOutput.Style
the AEOutput.Style for the given semantic of a device
Raises:
  • KeyError - When the semantic or layer is invalid

Instance Variable Details [hide private]

temp_devs

List of AEOutput and AEInput devices last removed in unloadDevices and held until the next call of loadDevices. The purpose of this list is to ensure strong references to all devices exist, and thus weak references are not destroyed, until the the DeviceManager is repopulated with devices.
Type:
list