Package AccessEngine :: Module AEDeviceManager' :: Class _AEDeviceManager
[hide private]
[frames] | no frames]

Class _AEDeviceManager

source code

object --+
         |
        _AEDeviceManager

Creates and manages the devices and monitors use by SUE.

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.


Note: RB: instance variable marks is currently not used

Instance Methods [hide private]
 
__init__(self)
Creates the empty lists for devices and monitors.
source code
 
init(self)
Loads all I/O monitors and devices to be created 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, sem, layer)
Sends the referenced index marker to the referenced device.
source code
 
sendWelcome(self)
Outputs the SUE welcome message on all output devices.
source code
 
sendGoodbye(self)
Outputs the SUE goodbye message on all output devices.
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)
Gets all loaded input and output AEMonitors.
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 all AEOutput devices 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 AEUserInterface
getDevices(self)
Gets a list of 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]
list in_devs
All input devices registered and initialized
MonitorCollection in_mons
Collection of monitors to notify about input
dictionary marks
Maps index markers on devices
list out_devs
All output devices registered and initialized
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)
(Constructor)

source code 
Creates the empty lists for devices and monitors.
Overrides: object.__init__

init(self)

source code 

Loads all I/O monitors and devices to be created at startup.

Called by AEMain at startup.

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 AEScripts continue to exist until the AEDeviceManager 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:
  • dev (AEOutput) - Device that should receive the command
  • 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
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 or 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 (AEPor) - Point of regard to the start of the string if one exists or None if the string did not originate from an AEPor

sendIndex(self, dev, 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

sendWelcome(self)

source code 

Outputs the SUE welcome message on all output devices.

Instead of just sending the message to the default output device, it is now sent to all output devices, so you know your braille display works properly.

One question remains: Is there a case where you would not want a welcome message sent to an output device?

sendGoodbye(self)

source code 

Outputs the SUE goodbye message on all output devices.

Instead of just sending the message to the default output device, it is now sent to all output devices.

One question remains: Is there a case where you would not want a goodbye message sent to your output device?

_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:
  • dev (AEInput) - Device to attempt to register
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:
  • dev (AEInput) - Device to unregister

_unregisterOutputDevice(self, dev)

source code 

Unregisters the given output device.

Provides the device with a reference to the AESettingsManager 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:
  • dev (AEOutput) - Device to attempt to register
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.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.
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 
Gets all loaded input and output AEMonitors.
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 all AEOutput devices registered with the given capabilities.
Parameters:
  • caps (list of string) - Desired capabilities of the output device.
Returns: AEOutput
Output devices or None if caps could not be satisfied

Note: MW: We decided not to limit output devices to unique capabilities anymore. Instead roles are used to distingish the devices' funtions.

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 AETierManager about the gesture and allow it to activate the appropriate script task, which is registered to respond to the gesture in the active AETier.
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 script task

_onIndex(self, dev, index)

source code 

To Do: RB: Taken over from LSR. Used in _unregisterOutputDevice and _registerOutputDevice. This function needs to be implemented or removed. (Note: This function isn't implemented in any subclass either, because there are no subclasses of _AEDeviceManager)

getDevices(self)

source code 
Gets a list of all loaded devices.
Returns: list of AEUserInterface
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 AEDeviceManager is repopulated with devices.
Type:
list