Class: SensorManager

SensorManager

new SensorManager()

Generic SensorManager object which hold information about all supported sensors
Source:

Members

(private, static) sensors

Initial value of listOfSensors
Source:

Methods

(static) assignSensor(type, id) → {Boolean}

Register or inform to the system that the sen-sor is going to be used. The used attribute of the sensor in the listOfSensors variable will be set to true if the sensor is eligible to be used. Appropriated error will be thrown if the sensor is using or unsupported.
Parameters:
Name Type Description
type String Sensor type
id String Sensor id
Source:
Throws:
Error when this type of sensor is using or unsupported
Returns:
True if register successful, false if not
Type
Boolean

(static) getIds(type) → {Array}

Retrieve all IDs supported by the sensor type
Parameters:
Name Type Description
type String Sensor type
Source:
Returns:
Array of ids
Type
Array

(static) isSupport(type, id) → {Boolean}

Check whether the input sensor type (along with its id if existed) is available in the system, regardless it is using or not.
Parameters:
Name Type Description
type String Sensor type
id String Sensor id
Source:
Returns:
True if this sensor type is supported, false if not
Type
Boolean

(static) isUsing(type, id) → {Boolean}

Check whether this sensor type (with specific id) is using
Parameters:
Name Type Description
type String Sensor type
id String Sensor id
Source:
Returns:
True if it is using, false if it is not
Type
Boolean

(static) isValid(type, id) → {Boolean}

Check the validity of a sensor type. Errors will be thrown if the sensor type isn’t supported by the system or it is using. If isValid() is passed without any error, this sensor type and id (if existed) is eligible to use.
Parameters:
Name Type Description
type String Sensor type
id String Sensor id
Source:
Throws:
Error when this type of sensor is using or unsupported
Returns:
- True if valid, false if not
Type
Boolean

(static) printListOfSensors()

Print the list of supported sensors, along with their ids.
Source:

(static) printListOfUsingSensors()

Print the list of sensors using at that time, along with their ids.
Source:

(private, static) setListOfSensors()

Initialize list of sensors from package.json file
Source:

(static) unassignSensor(type, id) → {Boolean}

Unregister or inform to the system that the sensor is going to stop using. The re-sources assigned to this sensor will be freed, and used attribute of this sensor in the listOfSensors variable will be set to false.
Parameters:
Name Type Description
type String Sensor type
id String Sensor id
Source:
Throws:
Error when this type of sensor is unused or unsupported
Returns:
True if unregister successful, false if not
Type
Boolean