DeviceSensor Class

A sensor of the device (https://w3c.github.io/sensors/#virtual-sensors), added by DeviceSensorProvider.AddSensor: DeviceSensor.Update makes a new reading available to the sensor objects of the documents.

public sealed class DeviceSensor

Properties

NameDescription
CanProvideReadingsGets whether the sensor works (the can provide readings flag): when false, the sensor objects cannot connect to it.
IsRemovedGets whether the sensor was removed from the device (DeviceSensorProvider.RemoveSensor).
MaximumSamplingFrequencyGets the maximum sampling frequency of the sensor, in Hz.
MinimumSamplingFrequencyGets the minimum sampling frequency of the sensor, in Hz.
ReadingGets the latest reading of the sensor, or null when it has none.
RequestedSamplingFrequencyGets the sampling frequency requested by the sensor objects that use the sensor, in Hz (https://w3c.github.io/sensors/#virtual-sensor-requested-sampling-frequency): the highest frequency they asked for, within the bounds of the sensor, or 0 when no sensor object uses it.
TypeGets the type of the sensor.

CanProvideReadings

DeviceSensorProvider.cs

Gets whether the sensor works (the can provide readings flag): when false, the sensor objects cannot connect to it.

public bool CanProvideReadings { get; }

Property value

bool

Gets whether the sensor was removed from the device (DeviceSensorProvider.RemoveSensor).

public bool IsRemoved { get; }

Property value

bool

MaximumSamplingFrequency

DeviceSensorProvider.cs

Gets the maximum sampling frequency of the sensor, in Hz.

public double MaximumSamplingFrequency { get; }

Property value

double

MinimumSamplingFrequency

DeviceSensorProvider.cs

Gets the minimum sampling frequency of the sensor, in Hz.

public double MinimumSamplingFrequency { get; }

Property value

double

Gets the latest reading of the sensor, or null when it has none.

public DeviceSensorReading? Reading { get; }

Property value

DeviceSensorReading?

RequestedSamplingFrequency

DeviceSensorProvider.cs

Gets the sampling frequency requested by the sensor objects that use the sensor, in Hz (https://w3c.github.io/sensors/#virtual-sensor-requested-sampling-frequency): the highest frequency they asked for, within the bounds of the sensor, or 0 when no sensor object uses it.

public double RequestedSamplingFrequency { get; }

Property value

double

Gets the type of the sensor.

public DeviceSensorType Type { get; }

Property value

DeviceSensorType

Methods

NameDescription
Update(DeviceSensorReading)Makes a new reading available to the sensor objects that use the sensor (https://w3c.github.io/sensors/#update-virtual-sensor-reading-command): they process it from a task (it may be discarded by the threshold check of the sensor type, and it is delivered once the document is visible and focused). It can be called from any thread.

Update(DeviceSensorReading)

DeviceSensorProvider.cs

Makes a new reading available to the sensor objects that use the sensor (https://w3c.github.io/sensors/#update-virtual-sensor-reading-command): they process it from a task (it may be discarded by the threshold check of the sensor type, and it is delivered once the document is visible and focused). It can be called from any thread.

public void Update(DeviceSensorReading reading)

Parameters

reading DeviceSensorReading

Exceptions

ArgumentException
The reading does not have the shape of the readings of DeviceSensor.Type.