|
Mercury2 Hardware Manager
1.0dev
The hardware manager component of the Mercury2 ground station suite.
|
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 | |
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.
| 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.
| command_parser | A reference to the active CommandParser instance. |
| This | constructor may pass exceptions raised during the device driver initialization process (see _initialize_devices). |
|
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).
| Throws | DevicesAlreadyInitialized if drivers have already been loaded into the device manager. |
| Throws | DeviceConfigInvalid in the event that device configuration specified in self.config is invalid (wrong format). This may be passed on from _validate_devices(). |
| Throws | DriverNotFound in the event that a driver class can't be located. |
| Throws | DriverInitError in the event that a driver class can't be initialized (i.e. its constructor throws an exception). |
|
private |
Validates the provided device configuration.
This method verifies that the provided device configuration conforms to the defined schema.
| Throws | DeviceConfigInvalid in the event that the device configuration is invalid. |
| device_configuration | An 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.
| Throws | DeviceNotFound if the specified device can't be located. |
| device_id | The ID of the device associated with the returned driver. |