Mercury2 Hardware Manager  1.0dev
The hardware manager component of the Mercury2 ground station suite.
 All Classes Namespaces Functions Variables Pages
hwm.hardware.devices.manager.DeviceManager Class Reference

Manages access to configured hardware devices. More...

Public Member Functions

def __init__
 Initializes the device manager and all configured devices. More...
 
def get_device_driver
 Loads and returns the driver for the specified device. More...
 

Public Attributes

 config
 
 devices
 
 virtual_devices
 

Private Member Functions

def _initialize_devices
 Initializes the drivers for each device. More...
 
def _validate_devices
 Validates the provided device configuration. More...
 

Private Attributes

 _command_parser
 

Detailed Description

Manages access to configured hardware devices.

This class is responsible for providing access to the hardware device drivers currently configured at the ground station. Like the other "manager" classes, there will only be a single instance of this class created early on. When initialized, the device manager initializes the appropriate drivers for the hardware devices specified in the configuration.

Note
All device usage locking is done by the device driver. See the driver base class for more.

Constructor & Destructor Documentation

def hwm.hardware.devices.manager.DeviceManager.__init__ (   self,
  command_parser 
)

Initializes the device manager and all configured devices.

 This constructor initializes the device manager and creates the appropriate driver class instances for all
 configured hardware devices.
Parameters
command_parserA reference to the active CommandParser instance.
Note
This class relies on configuration loaded into the configuration manager during the startup process. Therefore, if this class is initialized before the appropriate configuration files have been read, an exception will be generated.
Exceptions
Thisconstructor may pass exceptions raised during the device driver initialization process (see _initialize_devices).

Member Function Documentation

def hwm.hardware.devices.manager.DeviceManager._initialize_devices (   self)
private

Initializes the drivers for each device.

 This method stores references to device driver instances or classes as defined by the device configuration. If a
 device is a physical device, then its driver will be initialized and stored. However, if the device is a virtual
 device then a reference to its class will be stored instead (so it can be initialized on the fly later).
Note
Device drivers should be named so that the lower case version of the driver name (as specified in devices.yml) refers to the package and module in hwm.devices.drivers. Underscores are allowed to improve readability. For example, the driver "Test_Driver" refers to the "Test_Driver" class in the "test_driver" module in the "test_driver" package.
Exceptions
ThrowsDevicesAlreadyInitialized if drivers have already been loaded into the device manager.
ThrowsDeviceConfigInvalid in the event that device configuration specified in self.config is invalid (wrong format). This may be passed on from _validate_devices().
ThrowsDriverNotFound in the event that a driver class can't be located.
ThrowsDriverInitError in the event that a driver class can't be initialized (i.e. its constructor throws an exception).
def hwm.hardware.devices.manager.DeviceManager._validate_devices (   self,
  device_configuration 
)
private

Validates the provided device configuration.

 This method verifies that the provided device configuration conforms to the defined schema.
Note
This method doesn't validate any of the device settings. It is up to the device drivers to do this during initialization.
Exceptions
ThrowsDeviceConfigInvalid in the event that the device configuration is invalid.
Parameters
device_configurationAn array containing the available device configuration.
def hwm.hardware.devices.manager.DeviceManager.get_device_driver (   self,
  device_id 
)

Loads and returns the driver for the specified device.

 This method returns an instance of the device driver class for the specified device. If the requested device is a 
 physical device a reference to a previously initialized driver will be returned. If the requested device is a 
 virtual device a new instance will be constructed and returned.
Note
This method is typically called by pipelines during initialization when loading their devices. Virtual device driver instances are created on the fly because, unlike physical device drivers, they are typically tied to a specific pipeline with each pipeline having its own instance.
Exceptions
ThrowsDeviceNotFound if the specified device can't be located.
Parameters
device_idThe ID of the device associated with the returned driver.
Returns
Returns a reference to the driver class for the specified device.

The documentation for this class was generated from the following file: