Skip to main content

Class SimulatedTemperatureSensor

Represents a simulated temperature sensor that implements both ITemperatureSensor and ISimulatedSensor interfaces.

Assembly: Meadow.Foundation.dll
View Source
public class SimulatedTemperatureSensor : ITemperatureSensor, ISamplingSensor<Temperature>, ISensor<Temperature>, ISensor, ISamplingSensor, ISimulatedSensor

Implements:
Meadow.Peripherals.Sensors.ITemperatureSensor, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Temperature>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Temperature>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, Meadow.Peripherals.Sensors.ISimulatedSensor

Properties

SupportedBehaviors

Gets an array of supported simulation behaviors for the sensor.

View Source
public SimulationBehavior[] SupportedBehaviors { get; }

ValueType

Gets the type of the sensor's value.

View Source
public Type ValueType { get; }

UpdateInterval

A TimeSpan that specifies how long to wait between readings

View Source
public TimeSpan UpdateInterval { get; }

IsSampling

Gets a value indicating whether the sensor is currently sampling

View Source
public bool IsSampling { get; }

Temperature

Last value read from the Temperature sensor.

View Source
public Temperature? Temperature { get; }

Methods

Read()

Convenience method to get the current sensor reading

View Source
public Task<Temperature> Read()
Returns

System.Threading.Tasks.Task<Meadow.Units.Temperature>

StartUpdating(TimeSpan?)

Starts updating the sensor value at the specified interval

View Source
public void StartUpdating(TimeSpan? updateInterval = null)
Parameters
TypeName
System.Nullable<System.TimeSpan>updateInterval

StopUpdating()

Stops updating the sensor

View Source
public void StopUpdating()

SetSensorValue(object)

Sets the simulated value for the sensor.

View Source
public void SetSensorValue(object value)
Parameters
TypeNameDescription
System.ObjectvalueThe value to set for the sensor.

StartSimulation(SimulationBehavior)

Starts the simulation with the specified behavior.

View Source
public void StartSimulation(SimulationBehavior behavior)
Parameters
TypeNameDescription
Meadow.Peripherals.Sensors.SimulationBehaviorbehaviorThe simulation behavior to start.

Events

Updated

Raised when a change is detected

View Source
public event EventHandler<IChangeResult<Temperature>> Updated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Temperature>>

Implements

  • Meadow.Peripherals.Sensors.ITemperatureSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Temperature>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Temperature>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • Meadow.Peripherals.Sensors.ISimulatedSensor