Class SimulatedSamplingSensorBase<UNIT>
Represents the base logic for a simulated sample sensor
Assembly: Meadow.Foundation.dll
View Source
public abstract class SimulatedSamplingSensorBase<UNIT> : SimulatedSensorBase, ISimulatedSensor, ISamplingSensor<UNIT>, ISensor<UNIT>, ISensor, ISamplingSensor where UNIT : struct
Inheritance: System.Object
-> Meadow.Foundation.Sensors.SimulatedSensorBase
Derived:
Meadow.Foundation.Sensors.SimulatedAccelerometer
Implements:
Meadow.Peripherals.Sensors.ISimulatedSensor
, Meadow.Peripherals.Sensors.ISamplingSensor<<UNIT>>
, Meadow.Peripherals.Sensors.ISensor<<UNIT>>
, Meadow.Peripherals.Sensors.ISensor
, Meadow.Peripherals.Sensors.ISamplingSensor
Properties
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; }
PreviousReading
View Source
protected UNIT? PreviousReading { get; }
Methods
GenerateSimulatedValue(SimulationBehavior)
Generates a value based on the provided behavior
View Source
protected abstract UNIT GenerateSimulatedValue(SimulationBehavior behavior)
Returns
<UNIT>
Parameters
Type | Name | Description |
---|---|---|
Meadow.Peripherals.Sensors.SimulationBehavior | behavior | The behavior to use when generating a value |
Read()
Convenience method to get the current sensor reading
View Source
public Task<UNIT> Read()
Returns
System.Threading.Tasks.Task<<UNIT>>
StartUpdating(TimeSpan?)
Starts updating the sensor on the updateInterval frequency specified
View Source
public void StartUpdating(TimeSpan? updateInterval = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.TimeSpan> | updateInterval | A TimeSpan that specifies how long to |
wait between readings |
StopUpdating()
Stops sampling the sensor
View Source
public void StopUpdating()
Events
Updated
Raised when a change is detected
View Source
public event EventHandler<IChangeResult<UNIT>>? Updated
Event Type
System.EventHandler<Meadow.IChangeResult<<UNIT>>>
Implements
Meadow.Peripherals.Sensors.ISimulatedSensor
Meadow.Peripherals.Sensors.ISamplingSensor<<UNIT>>
Meadow.Peripherals.Sensors.ISensor<<UNIT>>
Meadow.Peripherals.Sensors.ISensor
Meadow.Peripherals.Sensors.ISamplingSensor