DriverManager
Class manipulate drivers
DriverManager provides mechanisms to:
- initialize and configure drivers based on config files,
- return instance of driver by driver unique identifier,
- filter drivers by groups,
- check if driver is available,
- resolve dependencies and
- put driver out of order or recover driver if it is possible.
Each driver can be part of one or more of following groups: control, terrain & position.
Method Summary
Public Methods | ||
public |
callMethodByGroup(type: *, method: *, params: *) Get all drivers that can provide specific type of data (or execute specific command) and call method. |
|
public |
Get driver instance by driver name |
|
public |
getDriversByGroup(type: *): Object Get all drivers that can provide specific type of data. |
|
public |
async init() Initialize all drivers |
|
public |
isDriverAvailable(name: *): boolean Returns true if driver is available |
|
public |
isDriverOutOfOrder(name: *): boolean Check if driver is out of order |
|
public |
putDriverOutOfOrder(name: *, message: *) Put driver out of order |
Public Methods
public callMethodByGroup(type: *, method: *, params: *) source
Get all drivers that can provide specific type of data (or execute specific command) and call method.
Eg. imagine you have laptop and monitor. If a monitor is not available then your laptop is it totally ok with it, image will be sent only to laptop's monitor. However, if there is a monitor connected to the laptop then laptop will be aware of monitor and it will send an image to monitor too. Your laptop don't really recognize difference between displays, and it communicates between them in very similar way. To sum up, the same is for this method, method will be called to all drivers that are the part of the group.
Params:
Name | Type | Attribute | Description |
type | * | {String} - Data type which driver can provide. Can be: position & terrain. |
|
method | * | {String} - Method to be called. |
|
params | * | {Array} - Params to be passed to method. |
public getDriver(name: *): Object source
Get driver instance by driver name
Params:
Name | Type | Attribute | Description |
name | * | {String} - Driver name, eg. "MotionDriver", or "ModbusDriver". |
public getDriversByGroup(type: *): Object source
Get all drivers that can provide specific type of data.
Every driver that can provide a certain type of data has implemented universal mechanism for getting that data from the driver. That is extremely useful for services and in that case services implement only logic for data processing, not mechanisms for data collection from different drivers. Services are in this case also hardware independent.
Params:
Name | Type | Attribute | Description |
type | * | {String} - Data type which driver can provide. Can be: position & terrain. |
public isDriverAvailable(name: *): boolean source
Returns true if driver is available
Params:
Name | Type | Attribute | Description |
name | * | Driver name |
public isDriverOutOfOrder(name: *): boolean source
Check if driver is out of order
Params:
Name | Type | Attribute | Description |
name | * | {String} - Unique name of a driver |
public putDriverOutOfOrder(name: *, message: *) source
Put driver out of order
Params:
Name | Type | Attribute | Description |
name | * | {String} - Unique name of a driver |
|
message | * | {String} - Describe more why the fault happened |