yaq-yeps/302


is-sensor

YEP:302
Title:is-sensor
Authors:Blaise Thompson
Status:accepted
Tags:trait
Post-History:2020-04-22, 2020-07-14, 2021-03-17

Abstract

This YEP defines the is-sensor trait. Daemons implementing this trait make measurements.

Table of Contents

Motivation

Sensors are a core component of the instrumentation ecosystem. The is-sensor trait enforces a consistent interface across all measurement devices.

Proposal

Fundamentally is-sensor daemons expose one or many named channels to clients. Each channel may be a scalar or a multidimensional array. Each channel may have units.

In many cases a single sensor daemon exposes a large volume of information over the wire. Clients who wish to poll for updates may find it impractical to read out the entire state of the sensor every time. For this reason, yaq defines measurement_id, an integer that incriments when the channel values are changed. A very lightweight message get_measurement_id is offered for clients to poll for updates. The measurement_id is also returned alongside channel information when get_measured is called. Clients should expect measurement_id to overflow and typically should only watch for changes.

Many is-sensor daemons also implement the closely related trait has-measure-trigger (YEP-310). Daemons which implement is-sensor without has-measure-trigger are sensors that update "spontaniously" and cannot be software triggered. Because this trait has no setters, daemons implementing only this trait should always be busy.

message: get_measured

response: {type: map, values: [float, ndarray]}

Returns map of channel_name to measured_value. Always returns additional key measurement_id.

message: get_measurement_id

response: {'type': 'int'}

Get current measurement_id. Clients are encouraged to watch for this to be updated before calling get_measured to get entire measurement.

message: get_channel_names

response: {'type': 'array', 'items': 'string'}

Get map of channel names.

message: get_channel_shapes

response: {'type': 'map', 'values': {'type': 'array', 'items': 'int'}}

Get map of current channel shapes. Scalar represented by empty list.

message: get_channel_units

response: {'type': 'map', 'values': ['null', 'string']}

Get current channel units.

Discussion

Discussion can be found on the gitlab issue for this YEP.

Copyright

This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive.


built 2021-03-24 00:24:38                                      CC0: no copyright