-
Notifications
You must be signed in to change notification settings - Fork 156
Sensors & Devices Database
This document outlines some ideas for extending the devices and sensors subsystem in macchina.io.
macchina.io comes with a number of predefined device and sensor interfaces that provide a unified interface to different kinds of sensors and other devices, e.g. temperature sensors, GNSS sensors, accelerometers, switches, etc. Applications working with sensors generally don't need to know about the implementation details of a specific sensor, as long as a sensor implements one of the predefined interfaces. In addition to sensor data, the interfaces also give access to metadata, e.g. what physical quantities and unit is used.
Sensors and devices are implemented as OSP services and can be found via the central service registry.
For example, to find all temperature sensors available:
var sensorRefs = serviceRegistry.find('io.macchina.physicalQuantity == "temperature"');
This will return an array of ServiceRef objects referencing to services implementing the Sensor interface.
The ServiceRef objects also contain some metadata in the form of properties, e.g.
-
io.macchina.deviceType
- the general type of device (in this case "io.macchina.sensor") -
io.macchina.device
- the specific device type (e.g. "io.macchina.simulation.sensor") -
io.macchina.physicalQuantity
- the physical quantity measured by the sensor ("temperature", as used in the query above)
Similarly, the Sensor service interface also provides means to query a specific sensor's property, and to configure certain features of a sensor. This is depending on the specific implementation of the device.
Some of the typical properties available in a Sensor are:
-
displayValue
: the current value of the sensor as a string, formatted for displaying. -
valueChangedPeriod
: the minimum period between firings of thevalueChanged
event. -
valueChangedDelta
: the minimum delta the value must change for thevalueChanged
event to fire. -
deviceIdentifier
: an implementation-specific identifier of the underlying device (e.g. "io.macchina.simulation.sensor#1") -
symbolicName
: an implementation-specific name of the sensor implementation (e.g. "io.macchina.simulation.sensor") -
name
: a human-readable name of the sensor implementation (e.g. "Simulated Sensor") -
type
: the type of device interface the sensor implements (e.g. "io.macchina.sensor") -
physicalQuantity
: the physical quantity the sensor measures (e.g. "temperature") -
physicalUnit
" the physical unit of the value (e.g. "Cel").
The following devices types are defined:
-
io.macchina.accelerometer
: Accelerometer -
io.macchina.barcode
: BarcodeReader -
io.macchina.gnss
: GNSSSensor -
io.macchina.gyroscope
: Gyroscope -
io.macchina.io
: IO (GPIO) -
io.macchina.led
: LED -
io.macchina.magnetometer
: Magnetometer -
io.macchina.rotary
: RotaryEncoder -
io.macchina.sensor
: Sensor -
io.macchina.boolean
: BooleanSensor -
io.macchina.counter
: Counter -
io.macchina.serial
: SerialDevice -
io.macchina.switch
: Switch -
io.macchina.trigger
: Trigger